当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceChangeListener类代码示例

本文整理汇总了Java中java.util.prefs.PreferenceChangeListener的典型用法代码示例。如果您正苦于以下问题:Java PreferenceChangeListener类的具体用法?Java PreferenceChangeListener怎么用?Java PreferenceChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PreferenceChangeListener类属于java.util.prefs包,在下文中一共展示了PreferenceChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: M2RepositoryBrowser

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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()));
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:M2RepositoryBrowser.java

示例2: propertyChange

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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

        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:WordMatch.java

示例3: DebuggingNodeModel

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DebuggingNodeModel.java

示例4: NodeSelectionProjectPanel

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NodeSelectionProjectPanel.java

示例5: SideBar

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SideBarFactoryImpl.java

示例6: firePrefEvents

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProxyPreferencesImpl.java

示例7: initProjectPreferences

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProjectAwareCodeStylePreferences.java

示例8: NbEditorToolBar

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NbEditorToolBar.java

示例9: setupAssistant

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FormDesignerTC.java

示例10: initialize

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
protected void initialize ()
{
    loadAll ();

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

        @Override
        public void preferenceChange ( final PreferenceChangeEvent evt )
        {
            if ( PREF_NAME.equals ( evt.getKey () ) )
            {
                refresh ();
            }
        }
    } );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:AbstractPreferencesDiscoverer.java

示例11: restored

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
@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();
}
 
开发者ID:luka-zitnik,项目名称:jshint-for-netbeans,代码行数:24,代码来源:Installer.java

示例12: testPrefChange

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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);
}
 
开发者ID:adobe-research,项目名称:cross-preferences,代码行数:18,代码来源:PreferencesTestSupport.java

示例13: shouldSyncKeyValueUpdates

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
@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();

    }
 
开发者ID:adobe-research,项目名称:cross-preferences,代码行数:25,代码来源:CrossPreferencesAcceptanceTest.java

示例14: testRemovePreferenceChangeListener

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
@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());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:AbstractPreferencesTest.java

示例15: FoldViewFactory

import java.util.prefs.PreferenceChangeListener; //导入依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:FoldViewFactory.java


注:本文中的java.util.prefs.PreferenceChangeListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。