Lines 43-49
Link Here
|
43 |
|
43 |
|
44 |
import java.beans.PropertyChangeEvent; |
44 |
import java.beans.PropertyChangeEvent; |
45 |
import java.beans.PropertyChangeListener; |
45 |
import java.beans.PropertyChangeListener; |
46 |
import java.beans.PropertyChangeSupport; |
|
|
47 |
import java.io.File; |
46 |
import java.io.File; |
48 |
import java.io.IOException; |
47 |
import java.io.IOException; |
49 |
import java.lang.ref.Reference; |
48 |
import java.lang.ref.Reference; |
Lines 71-83
Link Here
|
71 |
import org.netbeans.api.java.classpath.GlobalPathRegistry; |
70 |
import org.netbeans.api.java.classpath.GlobalPathRegistry; |
72 |
import org.netbeans.api.java.project.JavaProjectConstants; |
71 |
import org.netbeans.api.java.project.JavaProjectConstants; |
73 |
import org.netbeans.api.project.Project; |
72 |
import org.netbeans.api.project.Project; |
74 |
import org.netbeans.api.project.ProjectInformation; |
|
|
75 |
import org.netbeans.api.project.ProjectManager; |
73 |
import org.netbeans.api.project.ProjectManager; |
76 |
import org.netbeans.api.project.SourceGroup; |
74 |
import org.netbeans.api.project.SourceGroup; |
77 |
import org.netbeans.api.project.ant.AntArtifact; |
75 |
import org.netbeans.api.project.ant.AntArtifact; |
78 |
import org.netbeans.api.project.ant.AntBuildExtender; |
76 |
import org.netbeans.api.project.ant.AntBuildExtender; |
79 |
import org.netbeans.api.queries.FileBuiltQuery.Status; |
77 |
import org.netbeans.api.queries.FileBuiltQuery.Status; |
80 |
import org.netbeans.modules.java.api.common.SourceRoots; |
78 |
import org.netbeans.modules.java.api.common.SourceRoots; |
|
|
79 |
import org.netbeans.modules.java.api.common.ant.ProjectInfoImpl; |
81 |
import org.netbeans.modules.java.api.common.ant.UpdateHelper; |
80 |
import org.netbeans.modules.java.api.common.ant.UpdateHelper; |
82 |
import org.netbeans.modules.java.api.common.ant.UpdateImplementation; |
81 |
import org.netbeans.modules.java.api.common.ant.UpdateImplementation; |
83 |
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; |
82 |
import org.netbeans.modules.java.api.common.classpath.ClassPathModifier; |
Lines 97-105
Link Here
|
97 |
import org.netbeans.spi.project.support.LookupProviderSupport; |
96 |
import org.netbeans.spi.project.support.LookupProviderSupport; |
98 |
import org.netbeans.spi.project.ant.AntBuildExtenderImplementation; |
97 |
import org.netbeans.spi.project.ant.AntBuildExtenderImplementation; |
99 |
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration; |
98 |
import org.netbeans.spi.project.support.ant.AntBasedProjectRegistration; |
100 |
import org.netbeans.spi.project.support.ant.AntProjectEvent; |
|
|
101 |
import org.netbeans.spi.project.support.ant.AntProjectHelper; |
99 |
import org.netbeans.spi.project.support.ant.AntProjectHelper; |
102 |
import org.netbeans.spi.project.support.ant.AntProjectListener; |
|
|
103 |
import org.netbeans.spi.project.support.ant.EditableProperties; |
100 |
import org.netbeans.spi.project.support.ant.EditableProperties; |
104 |
import org.netbeans.spi.project.support.ant.FilterPropertyProvider; |
101 |
import org.netbeans.spi.project.support.ant.FilterPropertyProvider; |
105 |
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; |
102 |
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; |
Lines 130-136
Link Here
|
130 |
import org.openide.util.lookup.Lookups; |
127 |
import org.openide.util.lookup.Lookups; |
131 |
import org.w3c.dom.Document; |
128 |
import org.w3c.dom.Document; |
132 |
import org.w3c.dom.Element; |
129 |
import org.w3c.dom.Element; |
133 |
import org.w3c.dom.Text; |
|
|
134 |
import org.w3c.dom.Node; |
130 |
import org.w3c.dom.Node; |
135 |
import org.w3c.dom.NodeList; |
131 |
import org.w3c.dom.NodeList; |
136 |
|
132 |
|
Lines 146-152
Link Here
|
146 |
privateName=J2SEProjectType.PRIVATE_CONFIGURATION_NAME, |
142 |
privateName=J2SEProjectType.PRIVATE_CONFIGURATION_NAME, |
147 |
privateNamespace= J2SEProjectType.PRIVATE_CONFIGURATION_NAMESPACE |
143 |
privateNamespace= J2SEProjectType.PRIVATE_CONFIGURATION_NAMESPACE |
148 |
) |
144 |
) |
149 |
public final class J2SEProject implements Project, AntProjectListener { |
145 |
public final class J2SEProject implements Project { |
150 |
|
146 |
|
151 |
private static final Icon J2SE_PROJECT_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", false); // NOI18N |
147 |
private static final Icon J2SE_PROJECT_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/java/j2seproject/ui/resources/j2seProject.png", false); // NOI18N |
152 |
private static final Logger LOG = Logger.getLogger(J2SEProject.class.getName()); |
148 |
private static final Logger LOG = Logger.getLogger(J2SEProject.class.getName()); |
Lines 194-200
Link Here
|
194 |
final J2SEActionProvider actionProvider = new J2SEActionProvider( this, this.updateHelper ); |
190 |
final J2SEActionProvider actionProvider = new J2SEActionProvider( this, this.updateHelper ); |
195 |
lookup = createLookup(aux, actionProvider); |
191 |
lookup = createLookup(aux, actionProvider); |
196 |
actionProvider.startFSListener(); |
192 |
actionProvider.startFSListener(); |
197 |
helper.addAntProjectListener(this); |
|
|
198 |
} |
193 |
} |
199 |
|
194 |
|
200 |
private ClassPathModifier.Callback createClassPathModifierCallback() { |
195 |
private ClassPathModifier.Callback createClassPathModifierCallback() { |
Lines 317-325
Link Here
|
317 |
@SuppressWarnings("deprecation") Object cpe = new org.netbeans.modules.java.api.common.classpath.ClassPathExtender( |
312 |
@SuppressWarnings("deprecation") Object cpe = new org.netbeans.modules.java.api.common.classpath.ClassPathExtender( |
318 |
cpMod, ProjectProperties.JAVAC_CLASSPATH, null); |
313 |
cpMod, ProjectProperties.JAVAC_CLASSPATH, null); |
319 |
J2SESources srcs = new J2SESources(this, helper, eval, getSourceRoots(), getTestSourceRoots()); |
314 |
J2SESources srcs = new J2SESources(this, helper, eval, getSourceRoots(), getTestSourceRoots()); |
|
|
315 |
ProjectInfoImpl projectInfo = new ProjectInfoImpl(this, helper, J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, J2SE_PROJECT_ICON); |
320 |
final Lookup base = Lookups.fixed( |
316 |
final Lookup base = Lookups.fixed( |
321 |
J2SEProject.this, |
317 |
J2SEProject.this, |
322 |
new Info(), |
318 |
projectInfo, |
323 |
aux, |
319 |
aux, |
324 |
helper.createCacheDirectoryProvider(), |
320 |
helper.createCacheDirectoryProvider(), |
325 |
helper.createAuxiliaryProperties(), |
321 |
helper.createAuxiliaryProperties(), |
Lines 372-390
Link Here
|
372 |
return this.cpMod; |
368 |
return this.cpMod; |
373 |
} |
369 |
} |
374 |
|
370 |
|
375 |
public void configurationXmlChanged(AntProjectEvent ev) { |
|
|
376 |
if (ev.getPath().equals(AntProjectHelper.PROJECT_XML_PATH)) { |
377 |
// Could be various kinds of changes, but name & displayName might have changed. |
378 |
Info info = (Info)getLookup().lookup(ProjectInformation.class); |
379 |
info.firePropertyChange(ProjectInformation.PROP_NAME); |
380 |
info.firePropertyChange(ProjectInformation.PROP_DISPLAY_NAME); |
381 |
} |
382 |
} |
383 |
|
384 |
public void propertiesChanged(AntProjectEvent ev) { |
385 |
// currently ignored (probably better to listen to evaluator() if you need to) |
386 |
} |
387 |
|
388 |
// Package private methods ------------------------------------------------- |
371 |
// Package private methods ------------------------------------------------- |
389 |
|
372 |
|
390 |
/** |
373 |
/** |
Lines 452-524
Link Here
|
452 |
} |
435 |
} |
453 |
|
436 |
|
454 |
// Private innerclasses ---------------------------------------------------- |
437 |
// Private innerclasses ---------------------------------------------------- |
455 |
//when #110886 gets implemented, this class is obsolete |
|
|
456 |
private final class Info implements ProjectInformation { |
457 |
|
458 |
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); |
459 |
private WeakReference<String> cachedName = null; |
460 |
|
461 |
Info() {} |
462 |
|
463 |
void firePropertyChange(String prop) { |
464 |
pcs.firePropertyChange(prop, null, null); |
465 |
synchronized (pcs) { |
466 |
cachedName = null; |
467 |
} |
468 |
} |
469 |
|
470 |
public String getName() { |
471 |
return PropertyUtils.getUsablePropertyName(getDisplayName()); |
472 |
} |
473 |
|
474 |
public String getDisplayName() { |
475 |
synchronized (pcs) { |
476 |
if (cachedName != null) { |
477 |
String dn = cachedName.get(); |
478 |
if (dn != null) { |
479 |
return dn; |
480 |
} |
481 |
} |
482 |
} |
483 |
String dn = ProjectManager.mutex().readAccess(new Mutex.Action<String>() { |
484 |
public String run() { |
485 |
Element data = updateHelper.getPrimaryConfigurationData(true); |
486 |
// XXX replace by XMLUtil when that has findElement, findText, etc. |
487 |
NodeList nl = data.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N |
488 |
if (nl.getLength() == 1) { |
489 |
nl = nl.item(0).getChildNodes(); |
490 |
if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) { |
491 |
String val = ((Text) nl.item(0)).getNodeValue(); |
492 |
return val != null ? val : "???"; //NOI18N |
493 |
} |
494 |
} |
495 |
return "???"; // NOI18N |
496 |
} |
497 |
}); |
498 |
synchronized (pcs) { |
499 |
cachedName = new WeakReference<String>(dn); |
500 |
} |
501 |
return dn; |
502 |
} |
503 |
|
504 |
public Icon getIcon() { |
505 |
return J2SE_PROJECT_ICON; |
506 |
} |
507 |
|
508 |
public Project getProject() { |
509 |
return J2SEProject.this; |
510 |
} |
511 |
|
512 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
513 |
pcs.addPropertyChangeListener(listener); |
514 |
} |
515 |
|
516 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
517 |
pcs.removePropertyChangeListener(listener); |
518 |
} |
519 |
|
520 |
} |
521 |
|
522 |
private final class ProjectXmlSavedHookImpl extends ProjectXmlSavedHook { |
438 |
private final class ProjectXmlSavedHookImpl extends ProjectXmlSavedHook { |
523 |
|
439 |
|
524 |
ProjectXmlSavedHookImpl() {} |
440 |
ProjectXmlSavedHookImpl() {} |