@NonNull JavaPlatform findActivePlatform() { synchronized (LOCK) { activePlatformValid = true; if (platformManager == null) { platformManager = JavaPlatformManager.getDefault(); platformManager.addPropertyChangeListener(WeakListeners.propertyChange(this, platformManager)); NbMavenProject watch = project.getProjectWatcher(); watch.addPropertyChangeListener(this); } //TODO ideally we would handle this by toolchains in future. //only use the default auximpl otherwise we get recursive calls problems. String val = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true); JavaPlatform plat = getActivePlatform(val); if (plat == null) { //TODO report how? Logger.getLogger(BootClassPathImpl.class.getName()).log(Level.FINE, "Cannot find java platform with id of ''{0}''", val); //NOI18N plat = platformManager.getDefaultPlatform(); activePlatformValid = false; } //Invalid platform ID or default platform return plat; } }
private void initOptionsListener() { optionsListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Lines lines = getDocumentLines(); if (lines != null) { String pn = evt.getPropertyName(); OutputOptions opts = io.getOptions(); updateOptionsProperty(pn, lines, opts); OutputTab.this.repaint(); } } }; this.io.getOptions().addPropertyChangeListener( WeakListeners.propertyChange(optionsListener, io.getOptions())); }
public TagNode (File repository, GitTag tag) { super(Children.LEAF, repository, Lookups.singleton(new Revision(tag.getTaggedObjectId(), tag.getTagName()))); tagName = tag.getTagName(); message = tag.getMessage(); revisionId = tag.getTaggedObjectId(); setIconBaseWithExtension("org/netbeans/modules/git/resources/icons/tag.png"); //NOI18N RepositoryInfo info = RepositoryInfo.getInstance(repository); if (info == null) { LOG.log(Level.INFO, "TagNode() : Null info for {0}", repository); //NOI18N list = null; } else { info.addPropertyChangeListener(WeakListeners.propertyChange(list = new PropertyChangeListener() { @Override public void propertyChange (PropertyChangeEvent evt) { if (RepositoryInfo.PROPERTY_ACTIVE_BRANCH.equals(evt.getPropertyName()) || RepositoryInfo.PROPERTY_HEAD.equals(evt.getPropertyName())) { refreshActiveBranch((GitBranch) evt.getNewValue()); } } }, info)); refreshActiveBranch(info.getActiveBranch()); } }
ModulesChildFactory(NbMavenProjectImpl proj) { project = proj; NbMavenProject watcher = project.getProjectWatcher(); listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { refresh(false); } } }; watcher.addPropertyChangeListener(WeakListeners.propertyChange(listener, watcher)); }
public void setActiveAction(Action a) { if (a == action) { // In this case there is in fact no extra context a = null; } synchronized (this) { if (a != contextAction) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("setActiveAction(): from " + contextAction + " to " + a + "\n"); // NOI18N } contextAction = a; if (a != null && !listenedContextActions.contains(a)) { listenedContextActions.add(a); a.addPropertyChangeListener(WeakListeners.propertyChange(this, a)); if (LOG.isLoggable(Level.FINE)) { LOG.fine("setActiveAction(): started listening on " + a + "\n"); // NOI18N } } updatePresenter(null); // Update presenter completely } } }
/** #25793 fix - adds project name to given ant script name if needed. * @return ant script name annotated with project name or ant script name unchanged */ private String annotateWithProjectName (String name) { DataObject d = getDataObject(); if (d.getPrimaryFile().getNameExt().equals("build.xml")) { // NOI18N // #25793: show project name in case the script name does not suffice AntProjectCookie cookie = d.getCookie(AntProjectCookie.class); Element pel = cookie.getProjectElement(); if (pel != null) { String projectName = pel.getAttribute("name"); // NOI18N if (!projectName.equals("")) { // NOI18N name = NbBundle.getMessage(AntProjectDataEditor.class, "LBL_editor_tab", name, projectName); } } if (!addedChangeListener) { cookie.addChangeListener(WeakListeners.change(this, cookie)); addedChangeListener = true; } } return name; }
public Component getToolbarPresenter () { class AntButton extends JButton implements PropertyChangeListener { public AntButton() { super(AntActionInstance.this); // XXX setVisible(false) said to be poor on GTK L&F; consider using #26338 instead setVisible(isEnabled()); AntActionInstance.this.addPropertyChangeListener(WeakListeners.propertyChange(this, AntActionInstance.this)); } public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N setVisible(isEnabled()); } } } return new AntButton(); }
@Override public HighlightsSequence getHighlights(int startOffset, int endOffset) { synchronized (this) { if (rubyBackground != null) { if (hierarchy == null) { hierarchy = TokenHierarchy.get(document); if (hierarchy != null) { hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy)); } } if (hierarchy != null) { return new Highlights(version, hierarchy, startOffset, endOffset); } } return HighlightsSequence.EMPTY; } }
private synchronized boolean updateCandidates() { boolean affected = false; final JavaPlatform[] newPlatforms = jpm.getInstalledPlatforms(); final Map<JavaPlatform, PropertyChangeListener> oldPlatforms = new HashMap<>(platforms); final Map<JavaPlatform, PropertyChangeListener> newState = new LinkedHashMap<>(newPlatforms.length); for (JavaPlatform jp : newPlatforms) { PropertyChangeListener l; if ((l=oldPlatforms.remove(jp))!=null) { newState.put(jp,l); } else if (contains(jp,artifact)) { affected = true; l = WeakListeners.propertyChange(this, this.jpm); jp.addPropertyChangeListener(l); newState.put(jp,l); } } for (Map.Entry<JavaPlatform,PropertyChangeListener> e : oldPlatforms.entrySet()) { affected = true; e.getKey().removePropertyChangeListener(e.getValue()); } platforms = newState; return affected; }
private UnsubmittedTasksContainer getUnsubmittedTasksContainer () throws CoreException { synchronized (this) { if (unsubmittedTasksContainer == null) { unsubmittedTasksContainer = MylynSupport.getInstance().getUnsubmittedTasksContainer(getTaskRepository()); unsubmittedTasksContainer.addPropertyChangeListener(WeakListeners.propertyChange(unsubmittedTasksListener = new PropertyChangeListener() { @Override public void propertyChange (PropertyChangeEvent evt) { if (UnsubmittedTasksContainer.EVENT_ISSUES_CHANGED.equals(evt.getPropertyName())) { fireUnsubmittedIssuesChanged(); } } }, unsubmittedTasksContainer)); } return unsubmittedTasksContainer; } }
MetaInf (String rootFolder) { if (rootFolder != null && rootFolder.length() == 0) { rootFolder = null; } this.rootFolder = rootFolder; moduleLookupResult = org.openide.util.Lookup.getDefault().lookupResult(ModuleInfo.class); //System.err.println("\nModules = "+moduleLookupResult.allInstances().size()+"\n"); modulesChangeListener = new ModuleChangeListener(null); moduleLookupResult.addLookupListener( WeakListeners.create(org.openide.util.LookupListener.class, modulesChangeListener, moduleLookupResult)); listenOnDisabledModulesTask = RP.create(new Runnable() { @Override public void run() { // This may take a while... listenOnDisabledModules(); } }); }
private CosAction( @NonNull final J2SEActionProvider owner, @NonNull final PropertyEvaluator eval, @NonNull final SourceRoots src, @NonNull final SourceRoots tests) { this.owner = owner; this.eval = eval; this.src = src; this.tests = tests; this.mapper = new BuildArtifactMapper(); this.currentListeners = new HashMap<>(); this.cs = new ChangeSupport(this); this.importantFilesCache = new AtomicReference<>(Pair.of(null,null)); this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval)); this.src.addPropertyChangeListener(WeakListeners.propertyChange(this, this.src)); this.tests.addPropertyChangeListener(WeakListeners.propertyChange(this, this.tests)); updateRootsListeners(); instances.put(owner.getProject(), new WeakReference<>(this)); }
private Iterable<WhiteListImplementation> getWhiteLists() { synchronized (this) { if (cache != null) { return cache.keySet(); } } final Map<WhiteListImplementation,ChangeListener> map = new IdentityHashMap<WhiteListImplementation,ChangeListener>(); for (WhiteListQueryImplementation wlq : lr.allInstances()) { final WhiteListImplementation wl = wlq.getWhiteList(file); if (wl != null) { final ChangeListener cl = WeakListeners.change(this, wl); wl.addChangeListener(cl); map.put(wl, cl); } } synchronized (this) { if (cache == null) { cache = map; } return cache.keySet(); } }
private void addListener(PropertiesDataObject dataObj) { PropertyChangeListener l =weakEnvPropListeners.get(dataObj); VetoableChangeListener v = weakEnvVetoListeners.get(dataObj); if (l != null) { dataObj.removePropertyChangeListener(l); } else { l = WeakListeners.propertyChange(this, dataObj); weakEnvPropListeners.put(dataObj, l); } if (v != null) { dataObj.removeVetoableChangeListener(v); } else { v = WeakListeners.vetoableChange(this, dataObj); weakEnvVetoListeners.put(dataObj, v); } dataObj.addPropertyChangeListener(l); dataObj.addVetoableChangeListener(v); }
@SuppressWarnings("LeakingThisInConstructor") MainProjectAction(String command, ProjectActionPerformer performer, String name, Icon icon, Lookup lookup) { super(icon, lookup, new Class<?>[] {Project.class, DataObject.class}); this.command = command; this.performer = performer; this.name = name; String presenterName = ""; if (name != null) { presenterName = MessageFormat.format(name, -1); } setDisplayName(presenterName); if ( icon != null ) { setSmallIcon( icon ); } // Start listening on open projects list to correctly enable the action OpenProjectList.getDefault().addPropertyChangeListener( WeakListeners.propertyChange( this, OpenProjectList.getDefault() ) ); // XXX #47160: listen to changes in supported commands on current project, when that becomes possible }
private Coloring getColoring() { if (attribs == null) { if (fcsLookupResult == null) { fcsLookupResult = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)) .lookupResult(FontColorSettings.class); fcsLookupResult.addLookupListener(WeakListeners.create(LookupListener.class, fcsTracker, fcsLookupResult)); } FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next(); AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_BAR_COLORING); specificAttrs = attr; if (attr == null) { attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING); } else { attr = AttributesUtilities.createComposite( attr, fcs.getFontColors(FontColorNames.DEFAULT_COLORING)); } attribs = attr; } return Coloring.fromAttributeSet(attribs); }
private ShowEditorOnlyAction() { super( NbBundle.getMessage( ShowEditorOnlyAction.class, "CTL_ShowOnlyEditor") ); addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if( Action.ACCELERATOR_KEY.equals(evt.getPropertyName()) ) { synchronized( ShowEditorOnlyAction.this ) { menuItems = null; createItems(); } } } }); TopComponent.getRegistry().addPropertyChangeListener( WeakListeners.propertyChange(this, TopComponent.getRegistry())); // #126355 - may be called outside dispatch thread if (EventQueue.isDispatchThread()) { updateState(); } else { SwingUtilities.invokeLater(this); } }
public ComposedTextHighlighting(JTextComponent component, Document document, String mimeType) { // Prepare the highlight FontColorSettings fcs = MimeLookup.getLookup(MimePath.parse(mimeType)).lookup(FontColorSettings.class); AttributeSet dc = fcs.getFontColors(FontColorNames.DEFAULT_COLORING); Color background = (Color) dc.getAttribute(StyleConstants.Background); Color foreground = (Color) dc.getAttribute(StyleConstants.Foreground); highlightInverse = AttributesUtilities.createImmutable(StyleConstants.Background, foreground, StyleConstants.Foreground, background); highlightUnderlined = AttributesUtilities.createImmutable(StyleConstants.Underline, foreground); // Create the highlights container this.bag = new OffsetsBag(document); this.bag.addHighlightsChangeListener(this); // Start listening on the document this.document = document; this.document.addDocumentListener(WeakListeners.document(this, this.document)); this.component = component; }
private void listenOn(ClassLoader cl) { boolean doesNotContainCl = false; synchronized(moduleChangeListeners) { if (!moduleChangeListeners.containsKey(cl)) { doesNotContainCl = true; } } if (doesNotContainCl) { Collection<? extends ModuleInfo> allInstances = moduleLookupResult.allInstances(); synchronized (moduleChangeListeners) { if (!moduleChangeListeners.containsKey(cl)) { // Still does not contain for (ModuleInfo mi : allInstances) { if (mi.isEnabled() && mi.getClassLoader() == cl) { ModuleChangeListener l = new ModuleChangeListener(cl); mi.addPropertyChangeListener(WeakListeners.propertyChange(l, mi)); moduleChangeListeners.put(cl, l); } } } } } }
private void updateActiveEditor() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(this); return; } JTextComponent c = findActivePane(); if (c == null) { editorReleased(); return; } if (activeEditor != null && activeEditor.get() == c) { return; } editorReleased(); activeEditor = new WeakReference<>(c); wCaretL = WeakListeners.create(CaretListener.class, this, c); c.addCaretListener(this); selectCurrentNode(); }
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == null || "caret".equals(evt.getPropertyName())) { //NOI18N if (caret != null) { caret.removeChangeListener(caretListener); caretListener = null; } caret = component.getCaret(); if (caret != null) { caretListener = WeakListeners.change(this, caret); caret.addChangeListener(caretListener); } updateLineInfo(true); } }
public synchronized void propertyChange(PropertyChangeEvent evt) { if (document != pane.getDocument()) { if (document != null) { document.removeDocumentListener(weakDocL); weakDocL = null; } document = pane.getDocument(); weakDocL = WeakListeners.document(this, document); document.addDocumentListener(weakDocL); document = pane.getDocument(); synchronized (tokenListLock) { tokenList = null; } doUpdateCurrentVisibleSpan(); } }
@Override public void setModel (DiffNode[] nodes, EditorCookie[] editorCookies, Object modelData) { this.editorCookies = editorCookies; tableModel.setNodes(this.nodes = nodes); changeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); String propertyName = e.getPropertyName(); if (EditorCookie.Observable.PROP_MODIFIED.equals(propertyName) && (source instanceof EditorCookie.Observable)) { statusModifiedChanged((EditorCookie.Observable) source); } } }; for (EditorCookie editorCookie : this.editorCookies) { if (editorCookie instanceof EditorCookie.Observable) { ((EditorCookie.Observable) editorCookie).addPropertyChangeListener(WeakListeners.propertyChange(changeListener, editorCookie)); } } }
public MultiModuleJavadocForBinaryQueryImpl( @NonNull final AntProjectHelper helper, @NonNull final PropertyEvaluator evaluator, @NonNull final MultiModule modules, @NonNull final String[] binaryProperties, @NonNull final String javadocProperty) { Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("evaluator", evaluator); //NOI18N Parameters.notNull("modules", modules); //NOI18N Parameters.notNull("binaryProperties", binaryProperties); //NOI18N Parameters.notNull("javadocProperty", javadocProperty); //NOI18N this.helper = helper; this.evaluator = evaluator; this.modules = modules; this.binaryProperties = binaryProperties; this.javadocProperty = javadocProperty; this.cache = new ConcurrentHashMap<>(); this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, this.evaluator)); this.modules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.modules)); }
/** Creates a new instance of SyntaxHighlighting */ public SyntaxHighlighting(Document document) { this.document = document; String mimeType = (String) document.getProperty("mimeType"); //NOI18N if (mimeType != null && mimeType.startsWith("test")) { //NOI18N this.mimeTypeForOptions = mimeType; } else { this.mimeTypeForOptions = null; } // Start listening on changes in global colorings since they may affect colorings for target language findFCSInfo("", null); hierarchy = TokenHierarchy.get(document); hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy)); }
MultiModuleFileBuiltQueryImpl( @NonNull final AntProjectHelper helper, @NonNull final PropertyEvaluator evaluator, @NonNull final MultiModule sourceModules, @NonNull final MultiModule testModules) { Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("evaluator", evaluator); //NOI18N Parameters.notNull("sourceModules", sourceModules); //NOI18N Parameters.notNull("testModules", testModules); this.helper = helper; this.eval = evaluator; this.sourceModules = sourceModules; this.testModules = testModules; this.currentPaths = new ArrayList<>(); this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval)); this.sourceModules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.sourceModules)); this.testModules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.testModules)); }
/** Initializes this instance. Used by construction and deserialization. */ private void initialize() { initComponents(); setupActions(); BundleStructure structure = bundleStructure; PropertiesDataObject dataObject; Node[] node = new Node[structure.getEntryCount()]; nameUpdaterListener = new NameUpdater(); for( int i=0; i<structure.getEntryCount();i++) { dataObject = dataObjectsList.get(i); node[i] = dataObject.getNodeDelegate(); weakNameUpdateListeners.put(dataObject,WeakListeners.propertyChange(nameUpdaterListener, dataObject)); dataObject.addPropertyChangeListener(weakNameUpdateListeners.get(dataObject)); } setActivatedNodes(node); updateName(); }
private URL[] findJavadoc() { URL[] roots = rootsCache.get(); if (roots == null) { JavadocForBinaryQuery.Result res = resCache.get(); if (res == null) { try { res = JavadocForBinaryQuery.findJavadoc(uri.toURL()); if (resCache.compareAndSet(null, res)) { res.addChangeListener(WeakListeners.change(this, res)); } else { res = resCache.get(); } } catch (MalformedURLException e) { //pass with res null } } roots = res == null ? new URL[0] : res.getRoots(); rootsCache.set(roots); } return roots; }
private void addListeners() { BundleStructure structure = bundleStructure; PropertiesDataObject dataObj; weakEnvPropListeners = new HashMap<PropertiesDataObject, PropertyChangeListener>(); weakEnvVetoListeners = new HashMap<PropertiesDataObject, VetoableChangeListener>(); PropertyChangeListener l; VetoableChangeListener v; for(int i=0;i<structure.getEntryCount();i++) { dataObj = (PropertiesDataObject) structure.getNthEntry(i).getDataObject(); l = WeakListeners.propertyChange(this, dataObj); weakEnvPropListeners.put(dataObj, l); dataObj.addPropertyChangeListener(l); v = WeakListeners.vetoableChange(this, dataObj); weakEnvVetoListeners.put(dataObj, v); dataObj.addVetoableChangeListener(v); } }
/** Create a new presenter. * @param obj XML file describing it */ public ShortcutAction(DataObject obj, String helpID, boolean showmaster) { this.obj = obj; this.helpID = helpID; this.showmaster = showmaster; putValue("noIconInMenu", true); // NOI18N Installer.log.log(Level.FINE, "new ShortcutAction: {0} {1} showmaster={2}", new Object[] {obj, helpID, showmaster}); updateText(); updateIcon(); updateEnabled(); if (obj.isValid()) { Node n = obj.getNodeDelegate(); n.addNodeListener(org.openide.nodes.NodeOp.weakNodeListener (this, n)); } Help h = findHelp(); if (h != null) { h.addChangeListener(WeakListeners.change(this, h)); } }
public ViewUpdates(DocumentView docView) { this.docView = docView; incomingModificationListener = new IncomingModificationListener(); Document doc = docView.getDocument(); // View hierarchy uses a pair of its own document listeners and DocumentView ignores // document change notifications sent from BasicTextUI.RootView. // First listener - incomingModificationListener at DocumentListenerPriority.FIRST notifies the hierarchy // about incoming document modification. // Second listener is "this" at DocumentListenerPriority.VIEW updates the view hierarchy structure // according to the document modification. // These two listeners avoid situation when a document modification modifies line structure // and so the view hierarchy (which uses swing Positions for line view statrts) is inconsistent // since e.g. with insert there may be gaps between views and with removal there may be overlapping views // but the document listeners that are just being notified include a highlighting layer's document listener // BEFORE the BasicTextUI.RootView listener. At that point the highlighting layer would fire a highlighting // change and the view hierarchy would attempt to rebuild itself but that would fail. listenerPriorityAwareDoc = DocumentUtilities.addPriorityDocumentListener(doc, WeakListeners.create(DocumentListener.class, incomingModificationListener, null), DocumentListenerPriority.FIRST); // Add the second listener in all cases. DocumentUtilities.addDocumentListener(doc, WeakListeners.create(DocumentListener.class, this, doc), DocumentListenerPriority.VIEW); }
void initFactories() { // Init view factories List<EditorViewFactory.Factory> factoryFactories = EditorViewFactory.factories(); int size = factoryFactories.size(); List<EditorViewFactory> factoryList = new ArrayList<EditorViewFactory>(size); for (int i = 0; i < size; i++) { EditorViewFactory.Factory factoryFactory = factoryFactories.get(i); if (factoryFactories != null) { EditorViewFactory factory = factoryFactory.createEditorViewFactory(docView); if (factory != null) { factory.addEditorViewFactoryListener(WeakListeners.create( EditorViewFactoryListener.class, this, factory)); factoryList.add(factory); } } } viewFactories = factoryList.toArray(new EditorViewFactory[factoryList.size()]); if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "ViewUpdates initializing for {0}, factories: {1}", new Object[] { docView.getTextComponent(), Arrays.asList(viewFactories) }); } }
protected LogDevicesComboBoxSupport(LogReader reader) { this.reader = reader; // get notification for logged devices reader.addPropertyChangeListener(WeakListeners.propertyChange(this, reader)); // get notifications for attached and detached devices AndroidDebugBridge.addDeviceChangeListener(this); Lookup lookup = Utilities.actionsGlobalContext(); deviceLookup = lookup.lookupResult(IDevice.class); deviceLookup.addLookupListener(this); update(); }
/** * Creates new support for the given directory and file name(s). * @param directory directory * @param fileNames file name(s) * @return new support */ public static ImportantFilesSupport create(FileObject directory, String... fileNames) { Parameters.notNull("directory", directory); // NOI18N Parameters.notNull("fileNames", fileNames); // NOI18N ImportantFilesSupport support = new ImportantFilesSupport(directory, fileNames); directory.addFileChangeListener(WeakListeners.create(FileChangeListener.class, support.fileChangeListener, directory)); return support; }
@Override public void addNotify() { super.addNotify(); // run under mutex ExplorerManager em = ExplorerManager.find(this); if (em != manager) { if (manager != null) { manager.removeVetoableChangeListener(wlvc); manager.removePropertyChangeListener(wlpc); } manager = em; manager.addVetoableChangeListener(wlvc = WeakListeners.vetoableChange(managerListener, manager)); manager.addPropertyChangeListener(wlpc = WeakListeners.propertyChange(managerListener, manager)); setNode(manager.getExploredContext()); updateSelection(); } else { // bugfix #23509, the listener were removed --> add it again if (!listenerActive && (manager != null)) { manager.addVetoableChangeListener(wlvc = WeakListeners.vetoableChange(managerListener, manager)); manager.addPropertyChangeListener(wlpc = WeakListeners.propertyChange(managerListener, manager)); } } if (!listenerActive) { listenerActive = true; list.getSelectionModel().addListSelectionListener(managerListener); model.addListDataListener(managerListener); // bugfix #23974, model doesn't reflect an explorer context change // because any listener was not active setNode(manager.getExploredContext()); list.addMouseListener(popupSupport); } }
void attachListeners() { if (listenersInitialized.compareAndSet(false, true)) { eval.addPropertyChangeListener(this); JavaPlatformManager.getDefault().addPropertyChangeListener(WeakListeners.propertyChange(this, JavaPlatformManager.getDefault())); LibraryManager.addOpenManagersPropertyChangeListener(new OpenManagersWeakListener(this)); addLibraryManagerListener(); } else { throw new IllegalStateException(); } }
/** * Initializes a specified presenter. * * @param presenter presenter to initialize */ private void initialize(AbstractButton presenter, boolean useIcons) { if (useIcons) { // set the presenter's icon: Image icon = ImageUtilities.loadImage( "org/netbeans/modules/url/urlObject.png"); //NOI18N try { FileObject file = dataObject.getPrimaryFile(); icon = FileUIUtils.getImageDecorator(file.getFileSystem()). annotateIcon(icon, BeanInfo.ICON_COLOR_16x16, dataObject.files()); } catch (FileStateInvalidException fsie) { // OK, so we use the default icon } presenter.setIcon(new ImageIcon(icon)); } /* set the presenter's text and ensure it is maintained up-to-date: */ NameChangeListener listener = new NameChangeListener(presenter); presenter.addPropertyChangeListener( WeakListeners.propertyChange(listener, dataObject)); updateName(presenter); /* * The above code works with the assumption that it is called * from the AWT event dispatching thread (it manipulates * the presenter's display name). The same applies to * NameChangeListener's method propertyChange(...). * * At least, both mentioned parts of code should be called from * the same thread since method updateText(...) is not thread-safe. */ presenter.addActionListener(this); HelpCtx.setHelpIDString(presenter, dataObject.getHelpCtx().getHelpID()); }
ReducedChildren(DataFolder folder, ChangeableDataFilter filter, SourceGroup g) { this.folder = folder; this.filter = filter; this.g = g; filter.addChangeListener(WeakListeners.change(this, filter)); folder.addPropertyChangeListener(WeakListeners.propertyChange(this, folder)); }
public void init() { REFRESH_PROCESSOR.post(new Runnable() { public void run() { synchronized (ChildFactory.this) { registry.addChangeListener( WeakListeners.create(ChangeListener.class, ChildFactory.this, registry)); updateState(new ChangeEvent(registry)); } } }); }
public void run() { Status _status = null; synchronized (node) { _status = node.status; } if (_status == null) { FileObject jf = node.getDataObject().getPrimaryFile(); _status = FileBuiltQuery.getStatus(jf); synchronized (node) { if (_status != null && node.status == null) { node.status = _status; node.status.addChangeListener(WeakListeners.change(node, node.status)); } } } boolean isPackageInfo = "package-info.java".equals(node.getDataObject().getPrimaryFile().getNameExt()); boolean newIsCompiled = _status != null && !isPackageInfo ? _status.isBuilt() : true; boolean oldIsCompiled = node.isCompiled.getAndSet( newIsCompiled ? null : getImage( NEEDS_COMPILE_BADGE_URL, "<img src=\"{0}\"> " + getMessage(JavaNode.class, "TP_NeedsCompileBadge") //NOI18N )) == null; if (newIsCompiled != oldIsCompiled) { node.fireIconChange(); node.fireOpenedIconChange(); } }