java.util.prefs.PreferenceChangeEvent Java Examples

The following examples show how to use java.util.prefs.PreferenceChangeEvent. 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: DefaultFoldingOptions.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String updateCheckers(PreferenceChangeEvent evt) {
    String pk = evt.getKey();
    if (pk != null) {
        if (pk.equals(SimpleValueNames.CODE_FOLDING_ENABLE)) {
            updateEnabledState();
            return pk;
        }
        if (pk.equals(PREF_OVERRIDE_DEFAULTS)) {
            updateOverrideChanged();
        } else if (!pk.startsWith(COLLAPSE_PREFIX)) {
            return pk;
        }
    } else {
        updateEnabledState();
    }
    String c = pk == null ? null : pk.substring(COLLAPSE_PREFIX.length());
    for (JCheckBox cb : controls) {
        FoldType ft = (FoldType)cb.getClientProperty("type"); // NOI18N
        FoldType ftp = ft.parent();
        if (c == null || ft.code().equals(c) || (ftp != null && ftp.code().equals(c))) {
            updateChecker(pk, cb, ft);
            return pk;
        }
    }
    return pk;
}
 
Example #2
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    String settingName = evt == null ? null : evt.getKey();
    if (settingName == null || COMPLETION_CASE_SENSITIVE.equals(settingName)) {
        caseSensitive = preferences.getBoolean(COMPLETION_CASE_SENSITIVE, COMPLETION_CASE_SENSITIVE_DEFAULT);
    }
    if (settingName == null || SHOW_DEPRECATED_MEMBERS.equals(settingName)) {
        showDeprecatedMembers = preferences.getBoolean(SHOW_DEPRECATED_MEMBERS, SHOW_DEPRECATED_MEMBERS_DEFAULT);
    }
    if (settingName == null || JAVA_COMPLETION_BLACKLIST.equals(settingName)) {
        String blacklist = preferences.get(JAVA_COMPLETION_BLACKLIST, EMPTY);
        updateExcluder(excludeRef, blacklist);
    }
    if (settingName == null || JAVA_COMPLETION_WHITELIST.equals(settingName)) {
        String whitelist = preferences.get(JAVA_COMPLETION_WHITELIST, EMPTY);
        updateExcluder(includeRef, whitelist);
    }
    if (settingName == null || JAVA_COMPLETION_EXCLUDER_METHODS.equals(settingName)) {
        javaCompletionExcluderMethods = preferences.getBoolean(JAVA_COMPLETION_EXCLUDER_METHODS, JAVA_COMPLETION_EXCLUDER_METHODS_DEFAULT);
    }
    if (settingName == null || JAVA_COMPLETION_SUBWORDS.equals(settingName)) {
        javaCompletionSubwords = preferences.getBoolean(JAVA_COMPLETION_SUBWORDS, JAVA_COMPLETION_SUBWORDS_DEFAULT);
    }
}
 
Example #3
Source File: GlobalPreferences.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void preferenceChange(final PreferenceChangeEvent evt) {
    synchronized(listenerMap) {
        Set<ComparableWeakReference<PreferenceChangeListener>> set = listenerMap.get(evt.getKey());
        if (set != null) {
            final Set<PreferenceChangeListener> tmpListeners = new HashSet<PreferenceChangeListener>();
            Collection<ComparableWeakReference<PreferenceChangeListener>> deadRefs = new ArrayList<ComparableWeakReference<PreferenceChangeListener>>();
            for(ComparableWeakReference<PreferenceChangeListener> pclRef : set) {
                if (pclRef.get() != null) {
                    tmpListeners.add(pclRef.get());
                } else {
                    deadRefs.add(pclRef);
                }
            }
            set.removeAll(deadRefs);
            dispatcher.submit(new Runnable() {
                public void run() {
                    for(PreferenceChangeListener pcl : tmpListeners) {
                        pcl.preferenceChange(evt);
                    }
                }
            });
        }
    }
}
 
Example #4
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    String settingName = evt == null ? null : evt.getKey();
    if (settingName == null || CodeCompletionPanel.GUESS_METHOD_ARGUMENTS.equals(settingName)) {
        guessMethodArguments = preferences.getBoolean(CodeCompletionPanel.GUESS_METHOD_ARGUMENTS, CodeCompletionPanel.GUESS_METHOD_ARGUMENTS_DEFAULT);
    }
    if (settingName == null || CodeCompletionPanel.JAVA_AUTO_POPUP_ON_IDENTIFIER_PART.equals(settingName)) {
        autoPopupOnJavaIdentifierPart = preferences.getBoolean(CodeCompletionPanel.JAVA_AUTO_POPUP_ON_IDENTIFIER_PART, CodeCompletionPanel.JAVA_AUTO_POPUP_ON_IDENTIFIER_PART_DEFAULT);
    }
    if (settingName == null || CodeCompletionPanel.JAVA_AUTO_COMPLETION_TRIGGERS.equals(settingName)) {
        javaCompletionAutoPopupTriggers = preferences.get(CodeCompletionPanel.JAVA_AUTO_COMPLETION_TRIGGERS, CodeCompletionPanel.JAVA_AUTO_COMPLETION_TRIGGERS_DEFAULT);
    }
    if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_SELECTORS.equals(settingName)) {
        javaCompletionSelectors = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_SELECTORS, CodeCompletionPanel.JAVA_COMPLETION_SELECTORS_DEFAULT);
    }
    if (settingName == null || CodeCompletionPanel.JAVADOC_AUTO_COMPLETION_TRIGGERS.equals(settingName)) {
        javadocCompletionAutoPopupTriggers = preferences.get(CodeCompletionPanel.JAVADOC_AUTO_COMPLETION_TRIGGERS, CodeCompletionPanel.JAVADOC_AUTO_COMPLETION_TRIGGERS_DEFAULT);
    }
    if (settingName == null || CodeCompletionPanel.JAVADOC_COMPLETION_SELECTORS.equals(settingName)) {
        javadocCompletionSelectors = preferences.get(CodeCompletionPanel.JAVADOC_COMPLETION_SELECTORS, CodeCompletionPanel.JAVADOC_COMPLETION_SELECTORS_DEFAULT);
    }
}
 
Example #5
Source File: RecentProjects.java    From Logisim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent event) {
	Preferences prefs = event.getNode();
	String prop = event.getKey();
	if (prop.startsWith(BASE_PROPERTY)) {
		String rest = prop.substring(BASE_PROPERTY.length());
		int index = -1;
		try {
			index = Integer.parseInt(rest);
			if (index < 0 || index >= NUM_RECENT)
				index = -1;
		} catch (NumberFormatException e) {
		}
		if (index >= 0) {
			File oldValue = recentFiles[index];
			long oldTime = recentTimes[index];
			getAndDecode(prefs, index);
			File newValue = recentFiles[index];
			long newTime = recentTimes[index];
			if (!isSame(oldValue, newValue) || oldTime != newTime) {
				AppPreferences.firePropertyChange(AppPreferences.RECENT_PROJECTS, new FileTime(oldValue, oldTime),
						new FileTime(newValue, newTime));
			}
		}
	}
}
 
Example #6
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 #7
Source File: CommitPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    if (evt.getKey().startsWith(HgModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
        Runnable inAWT = new Runnable() {
            @Override
            public void run() {
                commitTable.dataChanged();
                listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
            }
        };
        // this can be called from a background thread - e.g. change of exclusion status in Versioning view
        if (EventQueue.isDispatchThread()) {
            inAWT.run();
        } else {
            EventQueue.invokeLater(inAWT);
        }
    }
}
 
Example #8
Source File: KarmaChildrenList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    if (!KarmaPreferences.isDebug(project)) {
        // possibly close browser tab
        KarmaServers.getInstance().closeDebugUrl(project);
    }
    // possibly restart server
    if (KarmaServers.getInstance().isServerRunning(project)) {
        KarmaServers.getInstance().stopServer(project, false);
        if (KarmaPreferences.isEnabled(project)) {
            ValidationResult result = new KarmaPreferencesValidator()
                    .validate(project)
                    .getResult();
            if (result.isFaultless()) {
                KarmaServers.getInstance().startServer(project);
            }
        }
    }
    changeSupport.fireChange();
}
 
Example #9
Source File: VCSCommitPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {        
    if (evt.getKey().startsWith(PROP_COMMIT_EXCLUSIONS)) { // XXX - need setting
        Runnable inAWT = new Runnable() {
            @Override
            public void run() {
                commitTable.dataChanged();
                listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
            }
        };
        // this can be called from a background thread - e.g. change of exclusion status in Versioning view
        if (EventQueue.isDispatchThread()) {
            inAWT.run();
        } else {
            EventQueue.invokeLater(inAWT);
        }
    }
}
 
Example #10
Source File: ListeningTopComponent.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public final void preferenceChange(final PreferenceChangeEvent event) {
    LOGGER.finer("PreferenceChange");

    final Map<String, Consumer<PreferenceChangeEvent>> preferenceMonitorsCopy;
    synchronized (preferenceMonitors) {
        preferenceMonitorsCopy = new HashMap<>(preferenceMonitors);
    }
    preferenceMonitorsCopy.forEach((preference, handler) -> {
        if (event.getKey().equals(preference)) {
            LOGGER.log(Level.FINER, "ManualUpdate::UpdatePreferences::{0}", preference);

            if (handler != null) {
                handler.accept(event);
            }
        }
    });

    handlePreferenceChange(event);
}
 
Example #11
Source File: PrefMonitorStringOpts.java    From Logisim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent event) {
	Preferences prefs = event.getNode();
	String prop = event.getKey();
	String name = getIdentifier();
	if (prop.equals(name)) {
		String oldValue = value;
		String newValue = prefs.get(name, dflt);
		if (!isSame(oldValue, newValue)) {
			String[] o = opts;
			String chosen = null;
			for (int i = 0; i < o.length; i++) {
				if (isSame(o[i], newValue)) {
					chosen = o[i];
					break;
				}
			}
			if (chosen == null)
				chosen = dflt;
			value = chosen;
			AppPreferences.firePropertyChange(name, oldValue, chosen);
		}
	}
}
 
Example #12
Source File: Server.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void preferenceChange(PreferenceChangeEvent e) {

        int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT));
        if (curPort != port) {
            initializeNetwork();
        }
    }
 
Example #13
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 #14
Source File: HtmlPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    String settingName = evt == null ? null : evt.getKey();
    if (settingName == null || HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES_AFTER_EQS.equals(settingName)) {
        autocompleQuotesAfterEQS = preferences.getBoolean(HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES_AFTER_EQS, HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES_AFTER_EQS_DEFAULT);
    }
    if (settingName == null || HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES.equals(settingName)) {
        autocompleQuotes = preferences.getBoolean(HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES, HtmlCompletionOptionsPanel.HTML_AUTOCOMPLETE_QUOTES_DEFAULT);
    }
    if (settingName == null || HtmlCompletionOptionsPanel.HTML_COMPLETION_END_TAG_ADTER_LT.equals(settingName)) {
        completionOffersEndTagAfterLt = preferences.getBoolean(HtmlCompletionOptionsPanel.HTML_COMPLETION_END_TAG_ADTER_LT, HtmlCompletionOptionsPanel.HTML_COMPLETION_END_TAG_ADTER_LT_DEFAULT);
    }
    if (settingName == null || HtmlCompletionOptionsPanel.HTML_COMPLETION_AUTOPOPUP_WINDOW.equals(settingName)) {
        autoPopupCompletionWindow = preferences.getBoolean(HtmlCompletionOptionsPanel.HTML_COMPLETION_AUTOPOPUP_WINDOW, HtmlCompletionOptionsPanel.HTML_COMPLETION_AUTOPOPUP_WINDOW_DEFAULT);
    }
    if (settingName == null || HtmlCompletionOptionsPanel.HTML_END_TAG_AUTOCOMPLETION_AUTOPOPUP.equals(settingName)) {
        autoPopupEndTagAutoCompletion = preferences.getBoolean(HtmlCompletionOptionsPanel.HTML_END_TAG_AUTOCOMPLETION_AUTOPOPUP, HtmlCompletionOptionsPanel.HTML_END_TAG_AUTOCOMPLETION_AUTOPOPUP_DEFAULT);
    }
    if (settingName == null || SELECTOR_TYPE_PROPERTY_NAME.equals(settingName)) {
        selectorType = SelectorType.valueOf(preferences.get(SELECTOR_TYPE_PROPERTY_NAME, SELECTOR_TYPE_DEFAULT.name()));
    }
    if (settingName == null || SECTION_MODE_PROPERTY_NAME.equals(settingName)) {
        sectionMode = Mode.valueOf(preferences.get(SECTION_MODE_PROPERTY_NAME, SECTION_MODE_DEFAULT.name()));
    }
    if (settingName == null || mimetypesWithEnabledHtmlErrorChecking_key.equals(settingName)) {
        mimetypesWithEnabledHtmlErrorChecking = preferences.get(mimetypesWithEnabledHtmlErrorChecking_key, mimetypesWithEnabledHtmlErrorChecking_default);
    }
}
 
Example #15
Source File: SmartyOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private SmartyOptions() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #16
Source File: ProxyPreferencesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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));
    }
}
 
Example #17
Source File: Nette2Options.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Nette2Options() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #18
Source File: WordMatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void preferenceChange(PreferenceChangeEvent evt) {
    if (evt != null) { // real change event
        staticWordsDocs.clear();
    }
    maxSearchLen = prefs.getInt(EditorPreferencesKeys.WORD_MATCH_SEARCH_LEN, EditorPreferencesDefaults.defaultWordMatchSearchLen);
    wrapSearch = prefs.getBoolean(EditorPreferencesKeys.WORD_MATCH_WRAP_SEARCH, EditorPreferencesDefaults.defaultWordMatchWrapSearch);
    matchOneChar = prefs.getBoolean(EditorPreferencesKeys.WORD_MATCH_MATCH_ONE_CHAR, EditorPreferencesDefaults.defaultWordMatchMatchOneChar);
    matchCase = prefs.getBoolean(EditorPreferencesKeys.WORD_MATCH_MATCH_CASE, EditorPreferencesDefaults.defaultWordMatchMatchCase);
    smartCase = prefs.getBoolean(EditorPreferencesKeys.WORD_MATCH_SMART_CASE, EditorPreferencesDefaults.defaultWordMatchSmartCase);
}
 
Example #19
Source File: ExtFormatter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void preferenceChange(PreferenceChangeEvent evt) {
    String key = evt == null ? null : evt.getKey();
    if (key == null || EditorPreferencesKeys.INDENT_HOT_CHARS_ACCEPTOR.equals(key)) {
        indentHotCharsAcceptor = (Acceptor) SettingsConversions.callFactory(
            prefs, MimePath.parse(mimeType), EditorPreferencesKeys.INDENT_HOT_CHARS_ACCEPTOR, AcceptorFactory.FALSE);
    }

    if (key == null || EditorPreferencesKeys.REINDENT_WITH_TEXT_BEFORE.equals(key)) {
        reindentWithTextBefore = prefs.getBoolean(EditorPreferencesKeys.REINDENT_WITH_TEXT_BEFORE, false);
    }
}
 
Example #20
Source File: FoldOptionsController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    if (suppressPrefChanges == Boolean.TRUE) {
        return;
    }
    boolean ch = detectIsChanged();
    MemoryPreferences defMime;
    synchronized (preferences) {
        defMime = preferences.get(""); // NOI18N
    }
    if (defMime != null && defMime.getPreferences() == evt.getNode()) {
        if (FoldUtilitiesImpl.PREF_CODE_FOLDING_ENABLED.equals(evt.getKey())) {
            // propagate to all preferences, suppress events
            suppressPrefChanges = true;
            Collection<MemoryPreferences> col;
            
            synchronized (preferences) {
                col = new ArrayList<>(preferences.values());
            }
            try {
                for (MemoryPreferences p : col) {
                    if (p != defMime) {
                        if (((OverridePreferences)p.getPreferences()).isOverriden(FoldUtilitiesImpl.PREF_CODE_FOLDING_ENABLED)) {
                            p.getPreferences().remove(FoldUtilitiesImpl.PREF_CODE_FOLDING_ENABLED);
                        }
                    } 
                }
            } finally {
                suppressPrefChanges = false;
            }
        }
    }
    if (ch != changed) {
        propSupport.firePropertyChange(PROP_CHANGED, !ch, ch);
        changed = true;
    }
}
 
Example #21
Source File: DefaultFoldingOptions.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(final PreferenceChangeEvent evt) {
    // the inherited legacy 'method' fold setting in "" mime type is changed in the same Swing event
    // as the real 'member' setting, so updating in the next event should read the already changed value.
    // similar for javadoc and inner classes.
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            fireChanged(updateCheckers(evt));
        }
    });
}
 
Example #22
Source File: Doctrine2Options.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Doctrine2Options() {
    getPreferences().addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            changeSupport.fireChange();
        }
    });
}
 
Example #23
Source File: AlwaysEnabledActionTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void checkPreferencesAction(Action a, Preferences prefsNode) throws Exception {
    prefsNode.putBoolean("myKey", true);
    prefsNode.sync();
    class L implements PreferenceChangeListener {
        boolean notified;

        public synchronized void preferenceChange(PreferenceChangeEvent evt) {
            notified = true;
            notifyAll();
        }

        public synchronized void waitFor() throws Exception {
            while (!notified) {
                wait();
            }
            notified = false;
        }
    }
    L listener = new L();

    // Verify value
    assertTrue("Expected true as preference value", prefsNode.getBoolean("myKey", false));

    TestCase.assertTrue("Expected to be instance of Presenter.Menu", a instanceof Presenter.Menu);
    JMenuItem item = ((Presenter.Menu) a).getMenuPresenter();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.addPreferenceChangeListener(listener);
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
    TestCase.assertFalse("Expected to not be selected", item.isSelected());
    a.actionPerformed(null); // new ActionEvent(null, 0, ""));
    listener.waitFor();
    TestCase.assertTrue("Expected to be selected", item.isSelected());
    prefsNode.putBoolean("myKey", false);
    prefsNode.sync();
    listener.waitFor();
}
 
Example #24
Source File: ProxyPreferencesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: BraceMatchingSidebarComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    String prefName = evt == null ? null : evt.getKey();
    
    if (SimpleValueNames.BRACE_SHOW_OUTLINE.equals(prefName)) {
        showOutline = prefs.getBoolean(SimpleValueNames.BRACE_SHOW_OUTLINE, true);
        updatePreferredSize();
        BraceMatchingSidebarComponent.this.repaint();
    } else if (SimpleValueNames.BRACE_FIRST_TOOLTIP.equals(prefName)) {
        showToolTip = prefs.getBoolean(SimpleValueNames.BRACE_FIRST_TOOLTIP, true);
    }
}
 
Example #26
Source File: ProxyPreferencesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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));
    }
}
 
Example #27
Source File: ProxyPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void preferenceChange(PreferenceChangeEvent evt) {
    synchronized (ProxyPreferences.this.lock) {
        if (evt.getKey() != null) {
            checkDelegates();
            for(int i = 0; i < delegateIdx; i++) {
                if (delegates[i] != null && delegates[i].get(evt.getKey(), null) != null) {
                    // ignore
                    return;
                }
            }
        }
    }

    firePrefChange(evt.getKey(), evt.getNewValue());
}
 
Example #28
Source File: OptionsUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    String settingName = evt == null ? null : evt.getKey();

    if (settingName == null || AUTO_COMPLETION_TYPE_RESOLUTION.equals(settingName)) {
        autoCompletionTypeResolution = preferences.getBoolean(
                AUTO_COMPLETION_TYPE_RESOLUTION,
                AUTO_COMPLETION_TYPE_RESOLUTION_DEFAULT);
    }

    if (settingName == null || AUTO_COMPLETION_SMART_QUOTES.equals(settingName)) {
        autoCompletionSmartQuotes = preferences.getBoolean(
                AUTO_COMPLETION_SMART_QUOTES,
                AUTO_COMPLETION_SMART_QUOTES_DEFAULT);
    }

    if (settingName == null || AUTO_STRING_CONCATINATION.equals(settingName)) {
        autoStringConcatination = preferences.getBoolean(
                AUTO_STRING_CONCATINATION,
                AUTO_STRING_CONCATINATION_DEFAULT);
    }
    
    if (settingName == null || AUTO_COMPLETION_FULL.equals(settingName)) {
        autoCompletionFull = preferences.getBoolean(
                AUTO_COMPLETION_FULL,
                AUTO_COMPLETION_FULL_DEFAULT);
    }
    if (settingName == null || AUTO_COMPLETION_AFTER_DOT.equals(settingName)) {
        autoCompletionAfterDot = preferences.getBoolean(
                AUTO_COMPLETION_AFTER_DOT,
                AUTO_COMPLETION_AFTER_DOT_DEFAULT);
    }
    if (settingName == null || COMPETION_ITEM_SIGNATURE_WIDTH.equals(settingName)) {
        codeCompletionItemSignatureWidth = preferences.getInt(
                COMPETION_ITEM_SIGNATURE_WIDTH,
                COMPETION_ITEM_SIGNATURE_WIDTH_DEFAULT);
    }
}
 
Example #29
Source File: PixelInfoView.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new pixel info view.
 */
public PixelInfoView() {
    super(new BorderLayout());
    displayFilterListener = createDisplayFilterListener();
    productNodeListener = createProductNodeListener();
    positionTableModel = new PixelInfoViewTableModel(new String[]{"Position", "Value", "Unit"});
    timeTableModel = new PixelInfoViewTableModel(new String[]{"Time", "Value", "Unit"});
    bandsTableModel = new PixelInfoViewTableModel(new String[]{"Band", "Value", "Unit"});
    tiePointGridsTableModel = new PixelInfoViewTableModel(new String[]{"Tie-Point Grid", "Value", "Unit"});
    flagsTableModel = new PixelInfoViewTableModel(new String[]{"Flag", "Value",});
    modelUpdater = new PixelInfoViewModelUpdater(this, positionTableModel,
                                                 timeTableModel,
                                                 bandsTableModel,
                                                 tiePointGridsTableModel,
                                                 flagsTableModel
    );
    updateService = new PixelInfoUpdateService(modelUpdater);
    setDisplayFilter(new DisplayFilter());
    final Preferences preferences = SnapApp.getDefault().getPreferences();
    preferences.addPreferenceChangeListener(new PreferenceChangeListener() {
        @Override
        public void preferenceChange(PreferenceChangeEvent evt) {
            final String propertyName = evt.getKey();
            if (PREFERENCE_KEY_SHOW_ONLY_DISPLAYED_BAND_PIXEL_VALUES.equals(propertyName)) {
                setShowOnlyLoadedBands(preferences);
            } else if (PREFERENCE_KEY_SHOW_PIXEL_POS_DECIMALS.equals(propertyName)) {
                setShowPixelPosDecimals(preferences);
            } else if (PREFERENCE_KEY_SHOW_GEO_POS_DECIMALS.equals(propertyName)) {
                setShowGeoPosDecimals(preferences);
            } else if (PREFERENCE_KEY_SHOW_PIXEL_POS_OFFSET_ONE.equals(propertyName)) {
                setShowPixelPosOffset1(preferences);
            }
        }
    });
    setShowOnlyLoadedBands(preferences);
    setShowPixelPosDecimals(preferences);
    setShowGeoPosDecimals(preferences);
    setShowPixelPosOffset1(preferences);
    createUI();
}
 
Example #30
Source File: PropertiesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    if (evt.getKey().startsWith(SvnModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
        propertiesTable.dataChanged();
        listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
    }
}