java.util.prefs.PreferenceChangeListener Java Examples

The following examples show how to use java.util.prefs.PreferenceChangeListener. 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: PreferenceUtilites.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Add a PreferenceChangeListener to a specified preference node.
 * <p>
 * For example, to listen for font size changes, listen to
 * "org/netbeans/core/output2".
 *
 * @param preferenceNode The preference node to listen to.
 * @param pcl A PreferenceChangeListener
 *
 * @return True if the addPreferenceChangeListener() worked, false
 * otherwise.
 */
public static boolean addPreferenceChangeListener(final String preferenceNode, final PreferenceChangeListener pcl) {
    try {
        Preferences p = NbPreferences.root();
        if (p.nodeExists(preferenceNode)) {
            p = p.node(preferenceNode);
            p.addPreferenceChangeListener(pcl);

            return true;
        }
    } catch (BackingStoreException ex) {
        Exceptions.printStackTrace(ex);
    }

    return false;
}
 
Example #2
Source File: FormDesignerTC.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void setupAssistant() {
    if (formEditorSupport.isOpened()) {
        updateAssistant();
        settingsListener = new PreferenceChangeListener() {
            @Override
            public void preferenceChange(PreferenceChangeEvent evt) {
                if (FormLoaderSettings.PROP_ASSISTANT_SHOWN.equals(evt.getKey())) {
                    updateAssistant();
                }
            }
        };
        FormLoaderSettings.getPreferences().addPreferenceChangeListener(settingsListener);
    } else if (FormLoaderSettings.getInstance().getAssistantShown()) {
        // only placeholder space during loading
        Component c = new JPanel();
        c.setPreferredSize(new Dimension(10, 41));
        c.setBackground(FormLoaderSettings.getInstance().getFormDesignerBackgroundColor());
        add(c, BorderLayout.NORTH);
    }
}
 
Example #3
Source File: NodeSelectionProjectPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: BootCPNodeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public PlatformProvider (
        @NonNull final Project project,
        @NonNull final ClassPath boot) {
    this.project = project;
    this.boot = boot;
    final JavaPlatformManager jps = JavaPlatformManager.getDefault();
    jps.addPropertyChangeListener(WeakListeners.propertyChange(this, jps));
    Preferences prefs = NbGradleProject.getPreferences(project, false);
    prefs.addPreferenceChangeListener(
            WeakListeners.create(PreferenceChangeListener.class, this, prefs));
    NbGradleProject.addPropertyChangeListener(project, WeakListeners.propertyChange(this,project));
    
    if (this.boot != null) {
        this.boot.addPropertyChangeListener(WeakListeners.propertyChange(this, this.boot));
    }
}
 
Example #5
Source File: WordMatch.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    String propName = evt.getPropertyName();

    if (EditorUI.COMPONENT_PROPERTY.equals(propName)) {
        if (prefs != null && weakListener != null) {
            prefs.removePreferenceChangeListener(weakListener);
        }
            
        JTextComponent newC = (JTextComponent)evt.getNewValue();
        if (newC != null) { // just installed
            String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(newC);
            prefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
            weakListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
            prefs.addPreferenceChangeListener(weakListener);
            prefsListener.preferenceChange(null);
        } else { // just deinstalled

        }
    }
}
 
Example #6
Source File: AbstractPreferencesDiscoverer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
protected void initialize ()
{
    loadAll ();

    getNode ().addPreferenceChangeListener ( this.listener = new PreferenceChangeListener () {

        @Override
        public void preferenceChange ( final PreferenceChangeEvent evt )
        {
            if ( PREF_NAME.equals ( evt.getKey () ) )
            {
                refresh ();
            }
        }
    } );
}
 
Example #7
Source File: M2RepositoryBrowser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private M2RepositoryBrowser() {
    super(Children.create(new RootNodes(), true));
    setName(NAME);
    setDisplayName(CTL_M2RepositoryBrowserTopComponent2(RepositoryPreferences.isIndexRepositories() ? "" : CTL_M2RepositoriesDisabled()));
    setShortDescription(HINT_M2RepositoryBrowserTopComponent());
    setIconBaseWithExtension(ICON_PATH);
    NbPreferences.root().node("org/netbeans/modules/maven/nexus/indexing").addPreferenceChangeListener(new PreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            if (RepositoryPreferences.PROP_INDEX.equals(evt.getKey())) {
                setDisplayName(CTL_M2RepositoryBrowserTopComponent2(RepositoryPreferences.isIndexRepositories() ? "" : CTL_M2RepositoriesDisabled()));
            }
        }
    });
}
 
Example #8
Source File: SideBarFactoryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public SideBar(Document forDocument) {
    super(new BorderLayout());
    this.forDocument = forDocument;
    add(new BreadCrumbComponent(), BorderLayout.CENTER);

    JButton closeButton = CloseButtonFactory.createBigCloseButton();

    add(closeButton, BorderLayout.EAST);
    
    prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
    
    closeButton.addActionListener(new ActionListener() {
        @Override public void actionPerformed(ActionEvent e) {
            prefs.putBoolean(KEY_BREADCRUMBS, false);
        }
    });
    
    setBorder(new SeparatorBorder());
    preferenceChange(null);
}
 
Example #9
Source File: Field.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param name of the field; must be unique within the store
 * @param label to display to the user
 * @param storeData store/fetch data from here, may be null.
 */
protected Field(String name, String label, PersistenceManager storeData) {
  this.name = name;
  this.label = label;
  this.storeData = storeData;

  // listen for changes to this value
  if (storeData != null) {
    storeData.addPreferenceChangeListener(new PreferenceChangeListener() {
      public void preferenceChange(PreferenceChangeEvent evt) {
        if (evt.getKey().equals(getName())) {
          // the value in the store has change: update the edit component
          // send event if its different from previous
          setNewValueFromStore();
        }
      }
    });
  }
}
 
Example #10
Source File: DebuggingNodeModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public DebuggingNodeModel(ContextProvider lookupProvider) {
    debugger = lookupProvider.lookupFirst(null, JPDADebugger.class);
    dvSupport = (DebuggingViewSupportImpl) lookupProvider.lookupFirst(null, DebuggingView.DVSupport.class);
    currentThreadListener = new CurrentThreadListener();
    debugger.addPropertyChangeListener(WeakListeners.propertyChange(currentThreadListener, debugger));
    deadlockDetector = debugger.getThreadsCollector().getDeadlockDetector();
    deadlockDetector.addPropertyChangeListener(new DeadlockListener());
    rp = lookupProvider.lookupFirst(null, RequestProcessor.class);
    sourcePath = lookupProvider.lookupFirst(null, SourcePath.class);
    session = lookupProvider.lookupFirst(null, Session.class);
    sessionLanguageListener = new SessionLanguageListener();
    session.addPropertyChangeListener(Session.PROP_CURRENT_LANGUAGE,
            WeakListeners.propertyChange(sessionLanguageListener,
                                         new ListenerDetaching(Session.PROP_CURRENT_LANGUAGE, session)));
    prefListener = new DebuggingPreferenceChangeListener();
    preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListener, preferences));
}
 
Example #11
Source File: PhpOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private PhpOptions() {
    propertyChangeSupport = new PropertyChangeSupport(this);
    getPhpOptions().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            String key = evt.getKey();
            String newValue = evt.getNewValue();
            if (PHP_INTERPRETER.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_INTERPRETER, null, newValue);
            } else if (PHP_DEBUGGER_PORT.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_PORT, null, Integer.valueOf(newValue));
            } else if (PHP_DEBUGGER_SESSION_ID.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_SESSION_ID, null, newValue);
            } else if (PHP_DEBUGGER_STOP_AT_FIRST_LINE.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_STOP_AT_FIRST_LINE, null, Boolean.valueOf(newValue));
            } else if (PHP_DEBUGGER_WATCHES_AND_EVAL.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_WATCHES_AND_EVAL, null, Boolean.valueOf(newValue));
            } else if (PHP_DEBUGGER_MAX_STRUCTURES_DEPTH.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_MAX_STRUCTURES_DEPTH, null, Boolean.valueOf(newValue));
            } else if (PHP_DEBUGGER_MAX_CHILDREN.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_MAX_CHILDREN, null, Boolean.valueOf(newValue));
            } else if (PHP_DEBUGGER_SHOW_URLS.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_SHOW_URLS, null, Boolean.valueOf(newValue));
            } else if (PHP_DEBUGGER_SHOW_CONSOLE.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_DEBUGGER_SHOW_CONSOLE, null, Boolean.valueOf(newValue));
            } else if (PHP_GLOBAL_INCLUDE_PATH.equals(key)) {
                propertyChangeSupport.firePropertyChange(PROP_PHP_GLOBAL_INCLUDE_PATH, null, newValue);
            }
        }
    });
}
 
Example #12
Source File: WebProjectBrowserProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void addPropertyChangeListener(final PropertyChangeListener propertyListener) {
    PreferenceChangeListener preferencesListener = new PreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            propertyListener.propertyChange(new PropertyChangeEvent(evt.getNode(), evt.getKey(), null, evt.getNewValue()));
        }
    };
    
    pcs.addPropertyChangeListener(propertyListener);
    getPreferences().addPreferenceChangeListener(preferencesListener);
    
    mapper.put(propertyListener, preferencesListener);
}
 
Example #13
Source File: BootClassPathImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public BootClassPathImpl(Project proj, boolean modulesOnly) {
    super(proj);
    this.modulesOnly = modulesOnly;
    platformManager = JavaPlatformManager.getDefault();
    platformManager.addPropertyChangeListener(WeakListeners.propertyChange(this, platformManager));
    NbGradleProject.getPreferences(project, false).addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            if (RunUtils.PROP_JDK_PLATFORM.equals(evt.getKey())) {
                clearResourceCache();
            }
        }
    });
}
 
Example #14
Source File: FoldViewFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public FoldViewFactory(View documentView) {
    super(documentView);
    foldHierarchy = FoldHierarchy.get(textComponent());
    // the view factory may get eventually GCed, but the FoldHierarchy can survive, snce it is tied to the component.
    weakL = WeakListeners.create(FoldHierarchyListener.class, this, foldHierarchy);
    foldHierarchy.addFoldHierarchyListener(weakL);
    // Go through folds and search for collapsed fold.
    foldHierarchy.lock();
    try {
        @SuppressWarnings("unchecked")
        Iterator<Fold> it = FoldUtilities.collapsedFoldIterator(foldHierarchy, 0, Integer.MAX_VALUE);
        collapsedFoldEncountered = it.hasNext();
    } finally {
        foldHierarchy.unlock();
    }

    displayAllFoldsExpanded = Boolean.TRUE.equals(textComponent().getClientProperty(DISPLAY_ALL_FOLDS_EXPANDED_PROPERTY));
    
    String mime = DocumentUtilities.getMimeType(document());
    
    Lookup lkp = MimeLookup.getLookup(mime);
    colorSource = lkp.lookupResult(FontColorSettings.class);
    colorSource.addLookupListener(WeakListeners.create(LookupListener.class, this, colorSource));
    colorSettings = (FontColorSettings)colorSource.allInstances().iterator().next();
    prefs = lkp.lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
    
    initViewFlags();
}
 
Example #15
Source File: Formatter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Construct new formatter.
* @param kitClass the class of the kit for which this formatter is being
*  constructed.
*/
public Formatter(Class kitClass) {
    this.kitClass = kitClass;
    
    String mimeType = BaseKit.getKit(kitClass).getContentType();
    prefs = MimeLookup.getLookup(MimePath.parse(mimeType)).lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs));
}
 
Example #16
Source File: WebProjectBrowserProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Preferences getPreferences() {
    if (preferences == null) {
        preferences = ProjectUtils.getPreferences(project, MavenProjectSupport.class, false);
        preferences.addPreferenceChangeListener(new PreferenceChangeListener() {

            @Override
            public void preferenceChange(PreferenceChangeEvent evt) {
                if (MavenJavaEEConstants.SELECTED_BROWSER.equals(evt.getKey())) {
                    pcs.firePropertyChange(PROP_BROWSER_ACTIVE, null, null);
                }
            }
        });
    }
    return preferences;
}
 
Example #17
Source File: ZendOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private ZendOptions() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #18
Source File: VersioningPanelController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void attachListeners() {
    panel.tgbHeadVsWorking.addActionListener(this);
    panel.tgbHeadVsIndex.addActionListener(this);
    panel.tgbIndexVsWorking.addActionListener(this);
    panel.btnCommit.addActionListener(this);
    panel.btnRevert.addActionListener(this);
    panel.btnDiff.addActionListener(this);
    panel.btnRefresh.addActionListener(this);
    panel.listButton.addActionListener(this);
    panel.treeButton.addActionListener(this);
    Git.getInstance().getFileStatusCache().addPropertyChangeListener(this);
    GitModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(
            list = WeakListeners.create(PreferenceChangeListener.class, this, GitModuleConfig.getDefault().getPreferences()));
}
 
Example #19
Source File: SymfonyOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private SymfonyOptions() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #20
Source File: HudsonOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private HudsonOptions() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #21
Source File: InheritedPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public InheritedPreferences(Preferences inherited, Preferences stored) {
    super(null, ""); // NOI18N
    this.inherited = inherited;
    if (!(stored instanceof OverridePreferences)) {
        throw new IllegalArgumentException();
    }
    this.stored = stored;
    stored.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, stored));
    inherited.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, inherited));
}
 
Example #22
Source File: FoldHierarchyExecution.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains Preferences that control folding for this Hierarchy.
 * 
 * @return Preferences object
 */
public Preferences getFoldPreferences() {
    if (foldPreferences == null) {
        synchronized (this) {
            if (foldPreferences != null) {
                return foldPreferences;
            }
            String mimeType = getMimeType();
            // internally does MimeLookup lookup(Preferences.class)
            Preferences prefs = LegacySettingsSync.get().processMime(mimeType);
            if ("".equals(mimeType)) {
                // do not cache; typically the editor kit will be changed to something other
                return prefs;
            }
            foldPreferences = prefs;
            PreferenceChangeListener weakPrefL = WeakListeners.create(PreferenceChangeListener.class, 
                prefL = new PreferenceChangeListener() {
                @Override
                public void preferenceChange(PreferenceChangeEvent evt) {
                    if (evt.getKey() == null || evt.getKey().startsWith(FoldUtilitiesImpl.PREF_COLLAPSE_PREFIX)) {
                        if (!initialFoldState.isEmpty()) {
                            initialFoldState = new HashMap<FoldType, Boolean>();
                        }
                    }
                    if (evt.getKey() != null && FoldUtilitiesImpl.PREF_CODE_FOLDING_ENABLED.equals(evt.getKey())) {
                        foldingEnabledSettingChange();
                    }
                }
            }, foldPreferences);
            foldPreferences.addPreferenceChangeListener(weakPrefL);
        }
    }
    return foldPreferences;
}
 
Example #23
Source File: WordMatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void checkInitPrefs() {
    if (weakListener == null) {
        String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(doc);
        if (mimeType != null) {
            prefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
            weakListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
            prefs.addPreferenceChangeListener(weakListener);
            prefsListener.preferenceChange(null);
        }
    }
}
 
Example #24
Source File: BraceMatchingSidebarComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public BraceMatchingSidebarComponent(JTextComponent editor) {
    this.editor = editor;
    this.mimeType = DocumentUtilities.getMimeType(editor);
    this.prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    
    final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
            FontColorSettings.class);
    prefListenerGC = new PrefListener();
    this.colorResult = r;
    r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
    loadPreferences();
    
    editorPane = findEditorPane(editor);
    Component parent = editor.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    if (parent instanceof JViewport) {
        this.viewport = (JViewport)parent;
        // see #219015; need to listen on viewport change to show/hide the tooltip
        viewport.addChangeListener(WeakListeners.change(this, viewport));
    }
    TextUI ui = editor.getUI();
    if (ui instanceof BaseTextUI) {
        baseUI = (BaseTextUI)ui;
        MasterMatcher.get(editor).addMatchListener(this);
    } else {
        baseUI = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    updatePreferredSize();
}
 
Example #25
Source File: OptionsUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void lazyInit() {
    if (inited.compareAndSet(false, true)) {
        preferences = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
        preferences.addPreferenceChangeListener(WeakListeners.create(
                PreferenceChangeListener.class, preferencesTracker, preferences));
        preferencesTracker.preferenceChange(null);
    }
}
 
Example #26
Source File: CssPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void lazyIntialize() {
    if (initialized.compareAndSet(false, true)) {
        preferences = MimeLookup.getLookup(CssLanguage.CSS_MIME_TYPE).lookup(Preferences.class);
        preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
        preferencesTracker.preferenceChange(null);
    }
}
 
Example #27
Source File: CssPrepOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private CssPrepOptions() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            String key = evt.getKey();
            String newValue = evt.getNewValue();
            if (SASS_PATH.equals(key)) {
                propertyChangeSupport.firePropertyChange(SASS_PATH_PROPERTY, null, newValue);
            } else if (LESS_PATH.equals(key)) {
                propertyChangeSupport.firePropertyChange(LESS_PATH_PROPERTY, null, newValue);
            }
        }
    });
}
 
Example #28
Source File: OptionsUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void lazyInit() {
    if (INITED.compareAndSet(false, true)) {
        preferences = MimeLookup.getLookup(SQLLanguageConfig.mimeType).lookup(Preferences.class);
        preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, PREFERENCES_TRACKER, preferences));
        PREFERENCES_TRACKER.preferenceChange(null);
    }
}
 
Example #29
Source File: BreadcrumbsController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void addBreadCrumbsEnabledListener(@NonNull final ChangeListener l) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    
    prefs.addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override public void preferenceChange(PreferenceChangeEvent evt) {
            if (evt == null || SideBarFactoryImpl.KEY_BREADCRUMBS.equals(evt.getKey())) {
                l.stateChanged(new ChangeEvent(evt));
            }
        }
    });
}
 
Example #30
Source File: HudsonInstanceNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
InstanceNodeChildren(HudsonInstance instance) {
    this.instance = instance;
    instance.addHudsonChangeListener(this);
    instance.prefs().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override public void preferenceChange(PreferenceChangeEvent evt) {
            refreshKeys();
        }
    });
}