org.openide.util.WeakListeners Java Examples
The following examples show how to use
org.openide.util.WeakListeners.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Tab.java From netbeans with Apache License 2.0 | 6 votes |
/** Initialize this top component properly with information * obtained from specified root context node */ private void initializeWithRootContext (Node rc) { // update TC's attributes setToolTipText(rc.getDisplayName()); setName(rc.getDisplayName()); updateTitle(); // attach listener if (weakRcL == null) { weakRcL = WeakListeners.propertyChange( rcListener(), rc ); } rc.addPropertyChangeListener(weakRcL); if (weakNRcL == null) { weakNRcL = NodeOp.weakNodeListener ( rcListener(), rc ); } rc.addNodeListener(weakNRcL); }
Example #2
Source File: HpiPluginWarning.java From netbeans with Apache License 2.0 | 6 votes |
@Messages({ "HpiPluginWarning_problem_displayName=Missing Hudson/Jenkins plugin support", "HpiPluginWarning_problem_description=Hudson/Jenkins plugin development support was removed from NetBeans 7.3. Install https://github.com/stapler/netbeans-stapler-plugin (available from Plugin Portal).", "HpiPluginWarning_unresolved=Automated installation from Plugin Portal not yet implemented; install the “Jenkins Plugin Support” and “Stapler Support” plugins." }) @Override public Collection<? extends ProjectProblem> getProblems() { for (ModuleInfo mi : modules.allInstances()) { if (mi.getCodeNameBase().equals("org.kohsuke.stapler.netbeans.jenkinsdev")) { if (mi.isEnabled()) { return Collections.emptySet(); } else { mi.addPropertyChangeListener(WeakListeners.propertyChange(this, mi)); // XXX better to display a specialized warning continue; } } } return Collections.singleton(ProjectProblem.createWarning(HpiPluginWarning_problem_displayName(), HpiPluginWarning_problem_description(), new ProjectProblemResolverImpl())); }
Example #3
Source File: PortTypeOperationFaultPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates new form PortTypeOperationFaultPanel */ public PortTypeOperationFaultPanel(SectionView view, Fault fault){ super(view); this.fault = fault; this.model = this.fault.getModel(); initComponents(); disableEnterKey(); sync(); addModifier(javaClassText); addModifier(defaultJavaClassCB); addValidatee(javaClassText); defaultListener = new DefaultItemListener(); ItemListener il = (ItemListener)WeakListeners.create(ItemListener.class, defaultListener, defaultJavaClassCB); defaultJavaClassCB.addItemListener(il); }
Example #4
Source File: BasicSearchForm.java From netbeans with Apache License 2.0 | 6 votes |
/** * Set options that depend on current context, and listeners that ensure * they stay valid when the context changes. */ private void setContextAwareOptions(boolean searchAndReplace) { if (!searchAndReplace) { updateSearchInGeneratedForActiveTopComponent(); topComponentRegistryListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals( TopComponent.Registry.PROP_ACTIVATED)) { updateSearchInGeneratedForActiveTopComponent(); } } }; TopComponent.getRegistry().addPropertyChangeListener( WeakListeners.propertyChange(topComponentRegistryListener, TopComponent.getRegistry())); } }
Example #5
Source File: FrameworkConfigFilesNodeFactory.java From netbeans with Apache License 2.0 | 6 votes |
private void listenOnFrameworks() { List<PhpFrameworkProvider> frameworks = project.getFrameworks(); List<ImportantFilesImplementation> newConfigFiles = new ArrayList<>(frameworks.size()); PhpModule phpModule = project.getPhpModule(); for (PhpFrameworkProvider framework : frameworks) { ImportantFilesImplementation configurationFiles = framework.getConfigurationFiles2(phpModule); if (configurationFiles != null) { newConfigFiles.add(configurationFiles); configurationFiles.addChangeListener(WeakListeners.change(this, configurationFiles)); } else { File[] files = framework.getConfigurationFiles(phpModule); if (files.length > 0) { LOGGER.log(Level.INFO, "PHP framework {0} uses deprecated method, switch to PhpFrameworkProvider.getConfigurationFiles2()", framework.getIdentifier()); ImportantFilesImplementation dummyConfigFiles = new ImportantFilesImplementationImpl(project, framework.getIdentifier(), files); newConfigFiles.add(dummyConfigFiles); } } } configFiles.clear(); configFiles.addAll(newConfigFiles); }
Example #6
Source File: PlatformSourceForBinaryQuery.java From netbeans with Apache License 2.0 | 6 votes |
public Result ( @NonNull final JavaPlatformManager jpm, @NonNull final URL artifact, @NonNull final Collection<? extends JavaPlatform> platforms) { Parameters.notNull("jpm", jpm); //NOI18N Parameters.notNull("artifact", artifact); //NOI18N Parameters.notNull("platforms", platforms); //NOI18N this.jpm = jpm; this.artifact = artifact; synchronized (this) { this.platforms = new LinkedHashMap<>(); for (JavaPlatform platform : platforms) { final PropertyChangeListener l = WeakListeners.propertyChange(this, platform); platform.addPropertyChangeListener(l); this.platforms.put(platform, l); } this.jpm.addPropertyChangeListener(WeakListeners.propertyChange(this, this.jpm)); } }
Example #7
Source File: MissingNbInstallationProblemProvider.java From netbeans with Apache License 2.0 | 6 votes |
public MissingNbInstallationProblemProvider(Project prj) { pchs = new PropertyChangeSupport(this); project = prj; propertyListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (OpenProjects.PROPERTY_OPEN_PROJECTS.equals(evt.getPropertyName()) && OpenProjects.getDefault().isProjectOpen(project)) { pchs.firePropertyChange(PROP_PROBLEMS, null, null); } if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) { pchs.firePropertyChange(PROP_PROBLEMS, null, null); } } }; weak = WeakListeners.propertyChange(propertyListener, this); }
Example #8
Source File: EditorSettingsCopy.java From netbeans with Apache License 2.0 | 6 votes |
/** Prepares settings. */ private void prepareSettings() { if (prepared) return; prepared = true; // Set listening on changes of settings. fontsColors = MimeLookup.getLookup(PropertiesKit.PROPERTIES_MIME_TYPE).lookupResult(FontColorSettings.class); fontsColors.addLookupListener(WeakListeners.create(LookupListener.class, fontsColorsTracker, fontsColors)); keybindings = MimeLookup.getLookup(PropertiesKit.PROPERTIES_MIME_TYPE).lookupResult(KeyBindingSettings.class); keybindings.addLookupListener(WeakListeners.create(LookupListener.class, keybindingsTracker, keybindings)); // Init settings. updateColors(); updateKeyStrokes(); }
Example #9
Source File: SequentialPropertyEvaluator.java From netbeans with Apache License 2.0 | 6 votes |
/** * @param preprovider an initial context (may be null) * @param providers a sequential list of property groups */ public SequentialPropertyEvaluator(final PropertyProvider preprovider, final PropertyProvider... providers) { this.preprovider = preprovider; this.providers = providers; ProjectManager.mutex().readAccess(new Mutex.Action<Void>() { public Void run() { if (preprovider != null) { predefs = copyAndCompact(preprovider.getProperties()); // XXX defer until someone is listening? preprovider.addChangeListener(WeakListeners.change(SequentialPropertyEvaluator.this, preprovider)); } else { predefs = Collections.emptyMap(); } orderedDefs = new ArrayList<Map<String, String>>(providers.length); for (PropertyProvider pp : providers) { orderedDefs.add(copyAndCompact(pp.getProperties())); pp.addChangeListener(WeakListeners.change(SequentialPropertyEvaluator.this, pp)); } return null; } }); // XXX defer until someone asks for them? defs = evaluateAll(predefs, orderedDefs); }
Example #10
Source File: ApplicationProfilerView.java From visualvm with GNU General Public License v2.0 | 6 votes |
public MasterViewSupport(final Application application, ProfilingResultsSupport profilingResultsView, CPUSettingsSupport cpuSettingsSupport, MemorySettingsSupport memorySettingsSupport, JDBCSettingsSupport jdbcSettingsSupport, boolean classSharingBreaksProfiling) { this.application = application; this.profilingResultsView = profilingResultsView; this.cpuSettingsSupport = cpuSettingsSupport; this.memorySettingsSupport = memorySettingsSupport; this.jdbcSettingsSupport = jdbcSettingsSupport; this.classSharingBreaksProfiling = classSharingBreaksProfiling; initComponents(); initSettings(); refreshStatus(); timer = new Timer(1000, this); timer.setInitialDelay(1000); NetBeansProfiler.getDefaultNB().addProfilingStateListener(this); // TODO: should listen for PROPERTY_AVAILABLE instead of DataSource removal application.notifyWhenRemoved(this); application.addPropertyChangeListener(Stateful.PROPERTY_STATE, WeakListeners.propertyChange(this,application)); }
Example #11
Source File: EditorContextDispatcher.java From netbeans with Apache License 2.0 | 6 votes |
private EditorContextDispatcher() { refreshProcessor = new RequestProcessor("Refresh Editor Context", 1); // NOI18N resFileObject = Utilities.actionsGlobalContext().lookupResult(FileObject.class); EditorLookupListener ell = new EditorLookupListener(FileObject.class); resFileObject.addLookupListener(ell); ell.lookupChanged(false); // To initialize data erListener = new EditorRegistryListener(); EditorRegistry.addPropertyChangeListener(WeakListeners.propertyChange(erListener, EditorRegistry.class)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // To initialize data: ((EditorRegistryListener) erListener).update(false); } }); }
Example #12
Source File: AndroidProjectSdkConfig.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Creates new form AndroidProjectSdkConfig */ public AndroidProjectSdkConfig(ProjectCustomizer.Category category, Lookup context) { initComponents(); this.category = category; androidProjectImpl = context.lookup(NbAndroidProject.class); if (androidProjectImpl != null) { sdk = androidProjectImpl.getLookup().lookup(AndroidSdk.class); if (sdk != null) { sdkList.setModel(new DefaultComboBoxModel(AndroidSdkProvider.getInstalledSDKs())); sdkList.setSelectedItem(sdk); AndroidSdkProvider.getDefault().addPropertyChangeListener(WeakListeners.propertyChange(this, AndroidSdkProvider.PROP_INSTALLED_SDKS, AndroidSdkProvider.getDefault())); } } category.setStoreListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!sdkList.getSelectedItem().equals(sdk) && androidProjectImpl != null) { androidProjectImpl.changeDefaultSdk((AndroidSdk) sdkList.getSelectedItem()); } } }); }
Example #13
Source File: MultiModuleBinaryForSourceQueryImpl.java From netbeans with Apache License 2.0 | 6 votes |
R( @NonNull final URL url, @NonNull final MultiModule modules, @NonNull final String moduleName, @NonNull final String[] templates) { Parameters.notNull("url", url); //NOI18N Parameters.notNull("modules", modules); //NOI18N Parameters.notNull("moduleName", moduleName); //NOI18N Parameters.notNull("templates", templates); //NOI18N this.url = url; this.pp = new EvaluatorPropertyProvider(MultiModuleBinaryForSourceQueryImpl.this.evaluator); this.evaluator = PropertyUtils.sequentialPropertyEvaluator( PropertyUtils.fixedPropertyProvider(Collections.singletonMap("module.name",moduleName)), //NOI18N pp); this.modules = modules; this.moduleName = moduleName; this.templates = templates; this.cache = new AtomicReference(); this.listeners = new ChangeSupport(this); this.propsCache = new AtomicReference<>(); this.scp = new AtomicReference<>(); MultiModuleBinaryForSourceQueryImpl.this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, MultiModuleBinaryForSourceQueryImpl.this.evaluator)); this.modules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.modules)); }
Example #14
Source File: PropertiesOpen.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example #15
Source File: JspKit.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates a new instance of the syntax coloring parser */ @Override public Syntax createSyntax(Document doc) { final Jsp11Syntax newSyntax = new Jsp11Syntax(new HtmlSyntax(), new JavaSyntax(null, true)); if(ATTACH_COLORING_LISTENER_TO_SYNTAX.get()) { DataObject dobj = NbEditorUtilities.getDataObject(doc); FileObject fobj = (dobj != null) ? dobj.getPrimaryFile() : null; // tag library coloring data stuff JspColoringData data = JspUtils.getJSPColoringData(fobj); // construct the listener PropertyChangeListener pList = new ColoringListener(doc, data, newSyntax); // attach the listener // PENDING - listen on the language //jspdo.addPropertyChangeListener(WeakListeners.propertyChange(pList, jspdo)); if (data != null) { data.addPropertyChangeListener(WeakListeners.propertyChange(pList, data)); } } return newSyntax; }
Example #16
Source File: GulpBuildTool.java From netbeans with Apache License 2.0 | 6 votes |
public GulpTasks getGulpTasks(@NullAllowed FileObject gulpfile) { if (gulpfile == null || gulpfile.getParent().equals(project.getProjectDirectory())) { return getProjectGulpTasks(); } GulpTasks tasks = gulpTasks.get(gulpfile); if (tasks != null) { return tasks; } Gulpfile file = Gulpfile.create(gulpfile.getParent()); tasks = GulpTasks.create(project, file); GulpTasks currentTasks = gulpTasks.putIfAbsent(gulpfile, tasks); if (currentTasks != null) { return currentTasks; } // register listener file.addChangeListener(WeakListeners.change(cleanupListener, file)); return tasks; }
Example #17
Source File: NodeSelectionProjectPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates new form ActualSelectionProjectPanel */ public NodeSelectionProjectPanel() { super(new BorderLayout()); JButton closeButton = CloseButtonFactory.createBigCloseButton(); prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs)); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs.putBoolean(KEY_ACTUALSELECTIONPROJECT, false); } }); add(closeButton, BorderLayout.EAST); setBorder(new SeparatorBorder()); preferenceChange(null); }
Example #18
Source File: ExternalBindingTablePanel.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates a new instance of ExternalBindingTablePanel */ public ExternalBindingTablePanel(EBTableModel model, Node node) { super(model); getTable().getAccessibleContext().setAccessibleName(NbBundle.getMessage(ExternalBindingTablePanel.class, "LBL_CUSTOMIZATION_FILES")); getTable().getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ExternalBindingTablePanel.class, "LBL_CUSTOMIZATION_FILES")); this.model = model; this.node = node; this.editButton.setVisible(false); //can't edit an entry addedBindings = new HashMap<String, FileObject>(); addActionListener = new AddActionListener(); ActionListener addListener = (ActionListener)WeakListeners.create(ActionListener.class, addActionListener, addButton); addButton.addActionListener(addListener); removeActionListener = new RemoveActionListener(); ActionListener removeListener = (ActionListener)WeakListeners.create(ActionListener.class, removeActionListener, removeButton); removeButton.addActionListener(removeListener); }
Example #19
Source File: NodeRegistry.java From netbeans with Apache License 2.0 | 6 votes |
/** * Initialize the registry * @param folder the name of the xml layer folder to use * @param dataLookup the lookup to use when creating providers */ private void init(String folder, final Lookup dataLookup) { Lookup lookup = Lookups.forPath(PATH + folder + NODEPROVIDERS); lookupResult = lookup.lookupResult(NodeProviderFactory.class); initProviders(dataLookup); // listen for changes and re-init the providers when the lookup changes lookupResult.addLookupListener(WeakListeners.create(LookupListener.class, lookupListener = new LookupListener() { @Override public void resultChanged(LookupEvent ev) { initProviders(dataLookup); changeSupport.fireChange(); } }, lookupResult) ); }
Example #20
Source File: MinimizeModeAction.java From netbeans with Apache License 2.0 | 6 votes |
public MinimizeModeAction() { putValue(NAME, NbBundle.getMessage(CloseModeAction.class, "CTL_MinimizeModeAction")); TopComponent.getRegistry().addPropertyChangeListener( WeakListeners.propertyChange(this, TopComponent.getRegistry())); WindowManager.getDefault().addPropertyChangeListener( WeakListeners.propertyChange(this, WindowManager.getDefault())); if (SwingUtilities.isEventDispatchThread()) { updateEnabled(); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateEnabled(); } }); } }
Example #21
Source File: JavacParser.java From netbeans with Apache License 2.0 | 6 votes |
private void init(final Task task) { if (!initialized) { ClasspathInfo _tmpInfo = null; if (task instanceof ClasspathInfo.Provider && (_tmpInfo = ((ClasspathInfo.Provider)task).getClasspathInfo()) != null) { if (cpInfo != null && weakCpListener != null) { cpInfo.removeChangeListener(weakCpListener); this.weakCpListener = null; } cpInfo = _tmpInfo; this.weakCpListener = WeakListeners.change(cpInfoListener, cpInfo); cpInfo.addChangeListener (this.weakCpListener); root = Optional.ofNullable(cpInfo.getClassPath(PathKind.SOURCE)) .map((cp)-> { FileObject[] roots = cp.getRoots(); return roots.length > 0 ? roots[0] : null; }) .orElse(null); } else { throw new IllegalArgumentException("No classpath provided by task: " + task); } initialized = true; } }
Example #22
Source File: MissingModuleProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
private Preferences getPreferences() { Preferences prefs = prefsCache.get(); if (prefs == null) { prefs = ProjectUtils.getPreferences(project, MissingModuleProblemsProvider.class, true); if (prefsCache.compareAndSet(null, prefs)) { prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs)); } } return prefs; }
Example #23
Source File: GradlePersistenceProvider.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new instance of GradlePersistenceProvider */ public GradlePersistenceProvider(Project proj, Lookup lkp) { this.project = proj; NbGradleProject watcher = lkp.lookup(NbGradleProject.class); locProvider = new PersistenceLocationProviderImpl(proj); scopeProvider = new PersistenceScopeProviderImpl(locProvider, proj); scopesProvider = new PersistenceScopesProviderImpl(scopeProvider); propChangeSupport.addPropertyChangeListener(locProvider); propChangeSupport.addPropertyChangeListener(scopesProvider); //TODO add FileChangeListener on persistence.xml watcher.addPropertyChangeListener(WeakListeners.propertyChange(res, watcher)); }
Example #24
Source File: SetMainProject.java From netbeans with Apache License 2.0 | 5 votes |
@SuppressWarnings("LeakingThisInConstructor") public SetMainProject( Lookup context ) { super( SetMainProject.class.getName() /*this is a fake command to make ActionUtils.SHORTCUTS_MANAGER work*/, LBL_SetAsMainProjectAction_Name(), null, context ); // wpcl = WeakListeners.propertyChange( this, OpenProjectList.getDefault() ); // OpenProjectList.getDefault().addPropertyChangeListener( wpcl ); if ( context == null ) { OpenProjectList.getDefault().addPropertyChangeListener( WeakListeners.propertyChange( this, OpenProjectList.getDefault() ) ); } putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); refresh(getLookup(), true); }
Example #25
Source File: ExportLegendImageAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
public ExportLegendImageAction(Lookup lookup) { super(Bundle.CTL_ExportLegendImageAction_MenuText(), HELP_ID); putValue("popupText",Bundle.CTL_ExportLegendImageAction_PopupText()); imageFileFilters = new SnapFileFilter[IMAGE_FORMAT_DESCRIPTIONS.length]; for (int i = 0; i < IMAGE_FORMAT_DESCRIPTIONS.length; i++) { imageFileFilters[i] = createFileFilter(IMAGE_FORMAT_DESCRIPTIONS[i]); } result = lookup.lookupResult(ProductSceneView.class); result.addLookupListener(WeakListeners.create(LookupListener.class, this, result)); setEnabled(false); }
Example #26
Source File: ApplicationDescriptor.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected void setApplicationType(ApplicationType type) { // if (this.type != null) this.type.removePropertyChangeListener(this); this.type = type; this.type.addPropertyChangeListener(WeakListeners.propertyChange(this, this.type)); // this.type.addPropertyChangeListener(this); }
Example #27
Source File: ProjectClassPathImplementation.java From netbeans with Apache License 2.0 | 5 votes |
public static ProjectClassPathImplementation forProject(Project project) { GrailsProjectConfig config = GrailsProjectConfig.forProject(project); ProjectClassPathImplementation impl = new ProjectClassPathImplementation(config); BuildConfig build = ((GrailsProject) config.getProject()).getBuildConfig(); build.addPropertyChangeListener(WeakListeners.propertyChange(impl.buildConfigListener, build)); config.addPropertyChangeListener(WeakListeners.propertyChange(impl.projectConfigListener, config)); return impl; }
Example #28
Source File: POMModelVisitor.java From netbeans with Apache License 2.0 | 5 votes |
public PomListChildren(POMCutHolder holder, POMQNames names, Class type, KeyGenerator<T> generator, POMModelPanel.Configuration configuration, POMQName childName) { this.holder = holder; this.names = names; this.type = type; this.keyGenerator = generator; this.childName = childName; this.configuration = configuration; this.configuration.addPropertyChangeListener(WeakListeners.propertyChange(this, this.configuration)); }
Example #29
Source File: NonLexerSyntaxHighlighting.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of NonLexerSytaxHighlighting */ public NonLexerSyntaxHighlighting(Document document, String mimeType) { this.mimePath = MimePath.parse(mimeType); this.document = document; this.document.addDocumentListener(WeakListeners.document(this, document)); }
Example #30
Source File: MenuBaseAction.java From constellation with Apache License 2.0 | 5 votes |
/** * constructor This method must be called by each child class to ensure that * the lookups are properly initialised */ public MenuBaseAction() { lookup = Utilities.actionsGlobalContext(); graphNodeSet = Utilities.actionsGlobalContext().lookupResult(GraphNode.class); graphNodeSet.addLookupListener( WeakListeners.create(LookupListener.class, this, graphNodeSet)); resultChanged(new LookupEvent(graphNodeSet)); }