Java 类java.util.prefs.PreferenceChangeListener 实例源码

项目:incubator-netbeans    文件:M2RepositoryBrowser.java   
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()));
            }
        }
    });
}
项目:incubator-netbeans    文件:WordMatch.java   
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

        }
    }
}
项目:incubator-netbeans    文件:DebuggingNodeModel.java   
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));
}
项目:incubator-netbeans    文件:NodeSelectionProjectPanel.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:SideBarFactoryImpl.java   
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);
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
private void firePrefEvents(List<EventBag<PreferenceChangeListener, PreferenceChangeEvent>> events) {
    if (noEvents) {
        return;
    }

    for(EventBag<PreferenceChangeListener, PreferenceChangeEvent> bag : events) {
        for(PreferenceChangeEvent event : bag.getEvents()) {
            for(PreferenceChangeListener l : bag.getListeners()) {
                try {
                    l.preferenceChange(event);
                } catch (Throwable t) {
                    LOG.log(Level.WARNING, null, t);
                }
            }
        }
    }
}
项目:incubator-netbeans    文件:ProjectAwareCodeStylePreferences.java   
private void initProjectPreferences(final FileObject file) {
    ProjectManager.mutex().postReadRequest(new Runnable() {
        public @Override void run() {
            Preferences projectRoot = findProjectPreferences(file);
            if (projectRoot != null) {
                synchronized (Csp.this) {
                    Preferences allLangCodeStyle = projectRoot.node(NODE_CODE_STYLE);
                    Preferences p = allLangCodeStyle.node(PROJECT_PROFILE);

                    // determine if we are using code style preferences from the project
                    String usedProfile = allLangCodeStyle.get(PROP_USED_PROFILE, DEFAULT_PROFILE);
                    useProject = PROJECT_PROFILE.equals(usedProfile);
                    projectPrefs = Csp.this.mimeType == null ?
                        p :
                        new ProxyPreferences(projectRoot.node(Csp.this.mimeType).node(NODE_CODE_STYLE).node(PROJECT_PROFILE), p);

                    // listen on changes
                    allLangCodeStyle.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, switchTrakcer, allLangCodeStyle));
                }
            }
        }
    });
    LOG.fine("file '" + filePath + "' (" + mimeType + ") is using " + (useProject ? "project" : "global") + " Preferences; doc=" + s2s(refDoc == null ? null : refDoc.get())); //NOI18N
}
项目:incubator-netbeans    文件:NbEditorToolBar.java   
public NbEditorToolBar(JTextComponent component) {
        this.componentRef = new WeakReference(component);

        setFloatable(false);
        //mkleint - instead of here, assign the border in CloneableEditor and MultiView module.
//        // special border installed by core or no border if not available
//        Border b = (Border)UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
//        setBorder(b);
        addMouseListener(sharedMouseListener);

        installModulesInstallationListener();
        installNoOpActionMappings();

        lookupResult = MimeLookup.getLookup(DocumentUtilities.getMimeType(component)).lookupResult(KeyBindingSettings.class);
        lookupResult.addLookupListener(WeakListeners.create(LookupListener.class, keybindingsTracker, lookupResult));

        String mimeType = DocumentUtilities.getMimeType(component);
        preferences = MimeLookup.getLookup(mimeType == null ? MimePath.EMPTY : MimePath.parse(mimeType)).lookup(Preferences.class);
        preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsTracker, preferences));

        refreshToolbarButtons();
        setBorderPainted(true);
    }
项目:incubator-netbeans    文件:FormDesignerTC.java   
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);
    }
}
项目:neoscada    文件:AbstractPreferencesDiscoverer.java   
protected void initialize ()
{
    loadAll ();

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

        @Override
        public void preferenceChange ( final PreferenceChangeEvent evt )
        {
            if ( PREF_NAME.equals ( evt.getKey () ) )
            {
                refresh ();
            }
        }
    } );
}
项目:jshint-for-netbeans    文件:Installer.java   
@Override
public void restored() {

    // If an instance of JSHint can't be created, adding listeners makes no sense.
    try {
        JSHint jshint = JSHint.getInstance(); // Also prevents possible later interruption
    } catch (IOException ex) {

        // JSHintPanel should never let this happen.
        return;
    }

    p.addPreferenceChangeListener(new PreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent pce) {
            if (pce.getKey().equals("show.annotations")) {
                updateChangeListenersOnEditorRegistry();
            }
        }
    });
    updateChangeListenersOnEditorRegistry();
}
项目:cross-preferences    文件:PreferencesTestSupport.java   
protected ScheduledFuture<?> testPrefChange(final PreferenceChangeListener listener, final Preferences prefs,
                                            final String key, final String value, final int count) {
    final ArgumentCaptor<PreferenceChangeEvent> captor = ArgumentCaptor.forClass(PreferenceChangeEvent.class);

    final Runnable task = new Runnable() {
        @Override public void run() {
            verify(listener, times(count)).preferenceChange(captor.capture());

            PreferenceChangeEvent event = captor.getValue();
            assertSame(event.getNode(), prefs);
            assertEquals(event.getKey(), key);
            assertEquals(event.getNewValue(), value);
        }
    };

    return schedule(task);
}
项目:cross-preferences    文件:CrossPreferencesAcceptanceTest.java   
@Test(dataProvider = "chroot", groups = {"prefs", "backing-store"}, dependsOnGroups = {"hierarchy", "kv"})
    public void shouldSyncKeyValueUpdates(Preferences prefs) throws Exception {
        final Preferences s = prefs.node("sync");

        final PreferenceChangeListener listener = prefListener(s);
        s.putInt("a", 1);
        final ScheduledFuture<?> set = testPrefChange(listener, s, "a", "1", 1);
//        s.flush();
        assertEquals(getFromBackingStore(s, "a"), "1");
        set.get();

        putInBackingStore(s, "a", "2");
        final ScheduledFuture<?> change = testPrefChange(listener, s, "a", "2", 2);
//        s.sync();
        assertEquals(s.getInt("a", 1), 2);
        change.get();

        removeKeyFromBackingStore(s, "a");
        final ScheduledFuture<?> remove = testPrefChange(listener, s, "a", null, 3);
//        s.sync();
        assertEquals(s.getInt("a", 0), 0);
        remove.get();

    }
项目:In-the-Box-Fork    文件:AbstractPreferencesTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "removePreferenceChangeListener",
    args = {java.util.prefs.PreferenceChangeListener.class}
)
public void testRemovePreferenceChangeListener() throws BackingStoreException {
    MockPreferenceChangeListener mpcl = new MockPreferenceChangeListener();
    parent.addPreferenceChangeListener(mpcl);
    assertFalse(mpcl.isChanged());
    parent.putInt("IntValue", 33);
    parent.flush();
    assertTrue(mpcl.isChanged());
    parent.removePreferenceChangeListener(mpcl);
    parent.putInt("IntValue", 33);
    parent.flush();
    assertFalse(mpcl.isChanged());
}
项目:incubator-netbeans    文件:FoldViewFactory.java   
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();
}
项目:incubator-netbeans    文件:DefaultFoldingOptions.java   
@Override
public void setDefaultPreferences(Preferences pref) {
    if (this.defaultPrefs != null) {
        defaultPrefs.removePreferenceChangeListener(weakL);
    }
    // anomaly: if the local Preference contains 'removedKey' for a preference
    // which has been turned to default, it blocks all change propagations.
    this.defaultPrefs = pref;
    if (pref != null) {
        weakL = WeakListeners.create(PreferenceChangeListener.class, this, pref);
        pref.addPreferenceChangeListener(weakL);
    }
}
项目:incubator-netbeans    文件:BaseDocument.java   
private void setMimeType(String mimeType) {
        if (!this.mimeType.equals(mimeType)) {
//            String oldMimeType = this.mimeType;
            this.mimeType = mimeType;

//            new Throwable("~~~ setMimeType: '" + oldMimeType + "' -> '" + mimeType + "'").printStackTrace(System.out);
//
            if (prefs != null && weakPrefsListener != null) {
                try {
                    prefs.removePreferenceChangeListener(weakPrefsListener);
//                    System.out.println("~~~ setMimeType: " + s2s(prefs) + " removing " + s2s(weakPrefsListener));
                } catch (IllegalArgumentException e) {
//                    System.out.println("~~~ IAE: doc=" + s2s(this) + ", '" + oldMimeType + "' -> '" + this.mimeType + "', prefs=" + s2s(prefs) + ", wpl=" + s2s(weakPrefsListener));
                }
                weakPrefsListener = null;
            }
            prefs = MimeLookup.getLookup(this.mimeType).lookup(Preferences.class);
            prefsListener.preferenceChange(null);
//            System.out.println("~~~ setMimeType: '" + this.mimeType + "' -> " + s2s(prefs));

            // reinitialize the document
            EditorKit kit = getEditorKit();
            if (kit instanceof BaseKit) {
                // careful here!! some kits set document's mime type from initDocument
                // even worse, the new mime type can be different from the one passed to the constructor,
                // which will result in recursive call to this method
                ((BaseKit) kit).initDocument(this);
            }

            if (weakPrefsListener == null) {
                weakPrefsListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
                prefs.addPreferenceChangeListener(weakPrefsListener);
//                System.out.println("~~~ setMimeType: " + s2s(prefs) + " adding " + s2s(weakPrefsListener));
            }
        }
    }
项目:incubator-netbeans    文件:GlyphGutter.java   
@SuppressWarnings({"LeakingThisInConstructor", "OverridableMethodCallInConstructor"})
public GlyphGutter(EditorUI eui) {
    super();
    this.editorUI = eui;
    init = false;
    annos = eui.getDocument().getAnnotations();

    // Annotations class is model for this view, so the listener on changes in
    // Annotations must be added here
    annos.addAnnotationsListener(this);

    // do initialization
    init();
    update();
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    editorUIListener = new EditorUIListener();
    eui.addPropertyChangeListener(editorUIListener);
    eui.getComponent().addPropertyChangeListener(editorUIListener);
    setOpaque (true);

    String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(eui.getComponent());
    coloringMap = ColoringMap.get(mimeType);
    coloringMap.addPropertyChangeListener(WeakListeners.propertyChange(coloringMapListener, coloringMap));

    prefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs));
    prefsListener.preferenceChange(null);
}
项目:incubator-netbeans    文件:BaseKit.java   
public KeybindingsAndPreferencesTracker(String mimeType) {
    this.mimeType = mimeType;
    Lookup lookup = MimeLookup.getLookup(mimeType);

    this.lookupResult = lookup.lookupResult(KeyBindingSettings.class);
    this.lookupResult.addLookupListener(WeakListeners.create(LookupListener.class, this, this.lookupResult));
    this.lookupResult.allInstances();

    this.prefs = lookup.lookup(Preferences.class);
    this.prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, this.prefs));
}
项目:incubator-netbeans    文件:CodeFoldingSideBar.java   
public CodeFoldingSideBar(JTextComponent component){
    super();
    this.component = component;

    // The same property tag is used by migrated implementation of the SideBar.
    // The new implementation is registered with weight higher than CF used to have, so if a
    // legacy client registers subclass of this CFSB, it will register the client property first and win.
    if (component.getClientProperty("org.netbeans.editor.CodeFoldingSidebar") == null) {  // NOI18N
        component.putClientProperty("org.netbeans.editor.CodeFoldingSidebar", Boolean.TRUE); // NOI18N
    } else {
        alreadyPresent = true;
        prefs = null;
        return;
    }

    addMouseListener(listener);
    addMouseMotionListener(listener);

    FoldHierarchy foldHierarchy = FoldHierarchy.get(component);
    foldHierarchy.addFoldHierarchyListener(WeakListeners.create(FoldHierarchyListener.class, listener, foldHierarchy));

    Document doc = getDocument();
    doc.addDocumentListener(WeakListeners.document(listener, doc));
    setOpaque(true);

    prefs = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component)).lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs));
    prefsListener.preferenceChange(null);

    ViewHierarchy.get(component).addViewHierarchyListener(new ViewHierarchyListener() {

        @Override
        public void viewHierarchyChanged(ViewHierarchyEvent evt) {
            checkRepaint(evt);
        }

    });
}
项目:incubator-netbeans    文件:VariablesTreeModelFilter.java   
public VariablesTreeModelFilter (ContextProvider lookupProvider) {
    this.lookupProvider = lookupProvider;
    evaluationRP = lookupProvider.lookupFirst(null, RequestProcessor.class);
    evalListener = new EvaluatorListener();
    //CodeEvaluatorUI.addResultListener(WeakListeners.propertyChange(evalListener, new ResultListenerRemoval()));
    result = CodeEvaluator.Result.get(lookupProvider.lookupFirst(null, DebuggerEngine.class));
    result.addListener(evalListener);
    prefListener = new VariablesPreferenceChangeListener();
    preferences.addPreferenceChangeListener(WeakListeners.create(
            PreferenceChangeListener.class, prefListener, preferences));
    Properties properties = Properties.getDefault().getProperties("debugger.options.JPDA"); // NOI18N
    properties.addPropertyChangeListener(WeakListeners.propertyChange(prefListener, properties));
}
项目:incubator-netbeans    文件:DebuggingMonitorModel.java   
Children(JPDADebugger debugger, DebuggingViewSupportImpl dvSupport,
         ModelListener modelListener, DebuggingTreeModel modelEventSource) {
    this.debugger = debugger;
    this.dvSupport = dvSupport;
    this.modelListener = modelListener;
    this.modelEventSource = modelEventSource;
    prefListener = new MonitorPreferenceChangeListener();
    preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListener, preferences));
    deadlockDetector = debugger.getThreadsCollector().getDeadlockDetector();
    deadlockDetector.addPropertyChangeListener(new DeadlockListener());
}
项目:incubator-netbeans    文件:WordMatch.java   
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);
        }
    }
}
项目:incubator-netbeans    文件:AbstractEditorAction.java   
public PreferencesNodeAndListener(String key) {
    this.key = key;
    node = (Preferences) getValue(AbstractEditorAction.PREFERENCES_NODE_KEY);
    if (node == null) {
        throw new IllegalStateException(
                "PREFERENCES_KEY_KEY property set but PREFERENCES_NODE_KEY not for action=" + // NOI18N
                AbstractEditorAction.this);
    }
    node.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, node));
    AbstractEditorAction.this.addPropertyChangeListener(this);
    putValue(Action.SELECTED_KEY, preferencesValue());
}
项目:incubator-netbeans    文件:OptionCodeCompletionSettings.java   
private static void lazyInit() {
    if (!inited) {
        inited = true;

        // correctly we should use a proper mime type for the document where the completion runs,
        // but at the moment this is enough, because completion settings are mainted globaly for all mime types
        Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, settingsListener, prefs));
        setCaseSensitive(prefs.getBoolean(SimpleValueNames.COMPLETION_CASE_SENSITIVE, false));
    }
}
项目:incubator-netbeans    文件:VersioningPanelController.java   
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()));
}
项目:incubator-netbeans    文件:MultiDiffPanelController.java   
private void attachListeners() {
    panel.tgbHeadVsWorking.addActionListener(this);
    panel.tgbHeadVsIndex.addActionListener(this);
    panel.tgbIndexVsWorking.addActionListener(this);
    panel.btnCommit.addActionListener(this);
    panel.btnRevert.addActionListener(this);
    panel.btnRefresh.addActionListener(this);
    Git.getInstance().getFileStatusCache().addPropertyChangeListener(list = WeakListeners.propertyChange(this, Git.getInstance().getFileStatusCache()));
    GitModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(
            prefList = WeakListeners.create(PreferenceChangeListener.class, this, GitModuleConfig.getDefault().getPreferences()));
}
项目:incubator-netbeans    文件:Info.java   
@Override 
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
    if (prefChangeListenerSet.compareAndSet(false, true)) {
        NbPreferences.forModule(Info.class).addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferenceChangeListener, NbPreferences.forModule(Info.class)));
    }
    if (!pcs.hasListeners(null)) {
        project.getLookup().lookup(NbMavenProject.class).addPropertyChangeListener(this);
    }
    pcs.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:GsfCompletionProvider.java   
private static void lazyInit() {
    if (!inited) {
        inited = true;

        // correctly we should use a proper mime type for the document where the completion runs,
        // but at the moment this is enough, because completion settings are mainted globaly for all mime types
        // (ie. their the same for all mime types). Also, if using a specific mime type
        // this code should hold the prefs instance somewhere, but not in a static field!
        Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
        prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, settingsListener, prefs));

        setCaseSensitive(prefs.getBoolean(SimpleValueNames.COMPLETION_CASE_SENSITIVE, false));
        setAutoPopup(prefs.getBoolean(SimpleValueNames.COMPLETION_AUTO_POPUP, false));
    }
}
项目:incubator-netbeans    文件:MissingModuleProblemsProvider.java   
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;
}
项目:incubator-netbeans    文件:TestPreferences.java   
public void testAddPreferenceChangeListener() throws BackingStoreException, InterruptedException {
    final Preferences pref = getPreferencesNode();
    PreferenceChangeListener l = new PreferenceChangeListener() {
        public void preferenceChange(PreferenceChangeEvent evt) {
            synchronized (TestPreferences.class) {
                //assertionerrors cause deadlock here
                assertSame(pref, evt.getNode());
                assertEquals("key", evt.getKey());
                assertEquals(evt.getNewValue(),pref.get(evt.getKey(),null), evt.getNewValue());
                TestPreferences.class.notifyAll();
            }
        }
    };
    pref.addPreferenceChangeListener(l);
    try {
        synchronized (TestPreferences.class) {
            pref.put("key","AddPreferenceChangeListener");
            pref.flush();
            TestPreferences.class.wait();
        }

        synchronized (TestPreferences.class) {
            pref.remove("key");
            pref.flush();
            TestPreferences.class.wait();
        }

        synchronized (TestPreferences.class) {
            pref.put("key","AddPreferenceChangeListener2");
            pref.flush();
            TestPreferences.class.wait();
        }
    } finally {
        pref.removePreferenceChangeListener(l);
    }
}
项目:incubator-netbeans    文件:BreadcrumbsController.java   
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));
            }
        }
    });
}
项目:incubator-netbeans    文件:BraceMatchingSidebarComponent.java   
@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();
}
项目:incubator-netbeans    文件:Utilities.java   
private static void lazyInit() {
    if (inited.compareAndSet(false, true)) {
        preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
        preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
        preferencesTracker.preferenceChange(null);
    }
}
项目:incubator-netbeans    文件:NonProxyHostsTest.java   
@Override
protected void setUp () throws Exception {
    super.setUp ();
    System.setProperty ("netbeans.system_http_proxy", SYSTEM_PROXY_HOST + ":" + SYSTEM_PROXY_PORT);
    System.setProperty ("netbeans.system_socks_proxy", SYSTEM_PROXY_HOST + ":" + SYSTEM_PROXY_PORT);
    System.setProperty ("netbeans.system_http_non_proxy_hosts", "*.other.org");
    System.setProperty ("http.nonProxyHosts", "*.netbeans.org");
    selector = ProxySelector.getDefault ();
    proxyPreferences  = NbPreferences.root ().node ("/org/netbeans/core");
    proxyPreferences.addPreferenceChangeListener (new PreferenceChangeListener () {
        public void preferenceChange (PreferenceChangeEvent arg0) {
            isWaiting = false;
        }
    });
    proxyPreferences.put ("proxyHttpHost", USER_PROXY_HOST);
    proxyPreferences.put ("proxyHttpPort", USER_PROXY_PORT);
    proxyPreferences.put ("proxySocksHost", USER_PROXY_HOST);
    proxyPreferences.put ("proxySocksPort", USER_PROXY_PORT);
    while (isWaiting);
    isWaiting = true;
    TO_LOCALHOST = new URI ("http://localhost");
    TO_LOCAL_DOMAIN_1 = new URI ("http://core.netbeans.org");
    TO_LOCAL_DOMAIN_2 = new URI ("http://core.other.org");
    TO_EXTERNAL = new URI ("http://worldwide.net");

    SOCKS_TO_LOCALHOST = new URI ("socket://localhost:8041");
    SOCKS_TO_LOCAL_DOMAIN_1 = new URI ("socket://core.netbeans.org");
    SOCKS_TO_LOCAL_DOMAIN_2 = new URI ("socket://core.other.org");
    SOCKS_TO_EXTERNAL = new URI ("socket://worldwide.net");
}
项目:incubator-netbeans    文件:PreferencesImpl.java   
@Override
public void removePreferenceChangeListener(PreferenceChangeListener pcl) {
    try {
        super.removePreferenceChangeListener(pcl);
    } catch (IllegalArgumentException e) {
        // ignore, see #143581
    }
}
项目:incubator-netbeans    文件:PreferencesImpl.java   
private Preferences getInherited() {
    if (inherited == null && mimePath.length() > 0) {
        String type = MimePath.parse(mimePath).getInheritedType();
        if (type != null) {
            inherited = factory.createPreferences(MimePath.parse(type));
        } else {
            inherited = factory.createPreferences(MimePath.EMPTY);
        }

        inherited.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, inherited));
    }

    return inherited;
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
@Override
public void remove(String key) {
    EventBag<PreferenceChangeListener, PreferenceChangeEvent> bag = null;

    // do not try to remove a non-existent key; it could lead to ugly 'remove' entries persisted in settings.
    if (get(key, null) == null) {
        return;
    }
    synchronized (tree.treeLock()) {
        checkNotNull(key, "key"); //NOI18N
        checkRemoved();
        if (removedKeys.add(key)) {
            data.remove(key);
            bag = new EventBag<PreferenceChangeListener, PreferenceChangeEvent>();
            bag.addListeners(prefListeners);
            if (inheritedPrefs != null) {
                bag.addEvent(new PreferenceChangeEvent(this, key, 
                        inheritedPrefs.get(key, null)));
            } else {
                bag.addEvent(new PreferenceChangeEvent(this, key, null));
            }
        }
    }

    if (bag != null) {
        firePrefEvents(Collections.singletonList(bag));
    }
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
@Override
public void sync() throws BackingStoreException {
    ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>> prefEvents = new ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>>();
    ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>> nodeEvents = new ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>>();

    synchronized (tree.treeLock()) {
        _sync(prefEvents, nodeEvents);
    }

    fireNodeEvents(nodeEvents);
    firePrefEvents(prefEvents);
}
项目:incubator-netbeans    文件:ProxyPreferencesImpl.java   
private void _put(String key, String value, String javaType) {
    EventBag<PreferenceChangeListener, PreferenceChangeEvent> bag = null;

    synchronized (tree.treeLock()) {
        checkNotNull(key, "key"); //NOI18N
        checkNotNull(value, "value"); //NOI18N
        checkRemoved();

        String orig = get(key, null);
        if (orig == null || !orig.equals(value)) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Overwriting '" + key + "' = '" + value + "'"); //NOI18N
            }

            data.put(key, new TypedValue(value, javaType));
            removedKeys.remove(key);

            bag = new EventBag<PreferenceChangeListener, PreferenceChangeEvent>();
            bag.addListeners(prefListeners);
            bag.addEvent(new PreferenceChangeEvent(this, key, value));
        }
    }

    if (bag != null) {
        firePrefEvents(Collections.singletonList(bag));
    }
}