本文整理匯總了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()));
}
}
});
}
示例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
}
}
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
}
}
}
}
示例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
}
示例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);
}
示例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);
}
}
示例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 ();
}
}
} );
}
示例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();
}
示例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);
}
示例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();
}
示例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());
}
示例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();
}