Java Code Examples for java.util.prefs.Preferences#getBoolean()

The following examples show how to use java.util.prefs.Preferences#getBoolean() . 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: DeployHook.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String showBrowserOnRun() {
    Preferences prefs = NbGradleProject.getPreferences(project, false);
    if (prefs.getBoolean(CustomizerRunWar.PROP_SHOW_IN_BROWSER, true)) {
        return prefs.get(CustomizerRunWar.PROP_SHOW_PAGE, "");
    } else {
        return null;
    }
}
 
Example 2
Source File: AbstractCamelCasePosition.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isUsingCamelCase() {
    Preferences p = NbPreferences.root ();
    if ( p == null ) {
        return false;
    }
    return p.getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
}
 
Example 3
Source File: FmtSpaces.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void loadFrom(Preferences preferences) {
    for (Item item : getAllItems()) {
        boolean df = FmtOptions.getDefaultAsBoolean(item.id);
        item.value = preferences.getBoolean(item.id, df);
    }
}
 
Example 4
Source File: Main.java    From ProtocolAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Load settings for sampler and flank detector from registry/config file
 */
public void loadAudioPreferences() {
	Preferences p = Preferences.userNodeForPackage(this.getClass());
	m_AudioSampler.setSource(p.getInt("SourceNumber", 0) >= 0 ? p.getInt("SourceNumber", 0) : 0);
	if (p.getBoolean("Mono", true)) {
		m_AudioSampler.setChannel(Channel.MONO);
	} else {
		m_AudioSampler.setChannel(p.getBoolean("LeftChannel", true) ? Channel.LEFT : Channel.RIGHT);
	}
	m_FlankDetector.setFlankSwing(p.getInt("FlankSwing", 80));
	m_FlankDetector.setFlankLength(p.getInt("FlankLength", 3));
	m_FlankDetector.setFlankHoldoff(p.getInt("FlankHoldoff", 1));
	m_FlankDetector.setPulseWidthCompensation(p.getInt("PulseWidthCompensation", 0));
	m_Filter.setActive(p.getBoolean("UseFilter", false));
}
 
Example 5
Source File: DeveloperOptionsPanelController.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isChanged() {
    final Preferences prefs = NbPreferences.forModule(DeveloperPreferenceKeys.class);
    final DeveloperOptionsPanel developerOptionsPanel = getPanel();
    return !(developerOptionsPanel.getGcOnOpen() == prefs.getBoolean(DeveloperPreferenceKeys.FORCE_GC_ON_OPEN, DeveloperPreferenceKeys.FORCE_GC_ON_OPEN_DEFAULT)
            && developerOptionsPanel.getGcOnClose() == prefs.getBoolean(DeveloperPreferenceKeys.FORCE_GC_ON_CLOSE, DeveloperPreferenceKeys.FORCE_GC_ON_CLOSE_DEFAULT)
            && developerOptionsPanel.getDebugGl() == prefs.getBoolean(DeveloperPreferenceKeys.DEBUG_GL, DeveloperPreferenceKeys.DEBUG_GL_DEFAULT)
            && developerOptionsPanel.getPrintGl() == prefs.getBoolean(DeveloperPreferenceKeys.PRINT_GL_CAPABILITIES, DeveloperPreferenceKeys.PRINT_GL_CAPABILITIES_DEFAULT)
            && developerOptionsPanel.getDisplayFps() == prefs.getBoolean(DeveloperPreferenceKeys.DISPLAY_FRAME_RATE, DeveloperPreferenceKeys.DISPLAY_FRAME_RATE_DEFAULT));
}
 
Example 6
Source File: PixelPosStatusLineElementProvider.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void updateSettings() {
    final Preferences preferences = SnapApp.getDefault().getPreferences();
    showPixelOffsetDecimals = preferences.getBoolean(
            PREFERENCE_KEY_SHOW_PIXEL_POS_DECIMALS,
            PREFERENCE_DEFAULT_SHOW_PIXEL_POS_DECIMALS);

    showGeoPosOffsetDecimals = preferences.getBoolean(
            PREFERENCE_KEY_SHOW_GEO_POS_DECIMALS,
            PREFERENCE_DEFAULT_SHOW_GEO_POS_DECIMALS);
}
 
Example 7
Source File: KeyBindings.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public void loadSettings(Preferences preferences) {
	for(GuiActionValue guiActionValue : keyBindings) {
		String value = preferences.get(guiActionValue.getGuiAction().name(), Character.toString(guiActionValue.getValue()));
		guiActionValue.setValue(value.charAt(0));
	}
	leftMouseClickCentersMap = preferences.getBoolean(LEFT_MOUSE_CLICK_CENTERS_MAP, leftMouseClickCentersMap);
	int animationSleepTime = preferences.getInt(ANIMATION_SPEED, AnimationSpeed.NORMAL.getSleepTime());
	animationSpeed = AnimationSpeed.valueOf(animationSleepTime);
}
 
Example 8
Source File: Autosaver.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    StatusDisplayer.getDefault().setStatusText(String.format("Auto saving %s at %s...", "", new Date()));

    final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
    final boolean autosaveEnabled = prefs.getBoolean(ApplicationPreferenceKeys.AUTOSAVE_ENABLED, ApplicationPreferenceKeys.AUTOSAVE_ENABLED_DEFAULT);
    if (autosaveEnabled) {
        runAutosave();
    }

    final int autosaveSchedule = prefs.getInt(ApplicationPreferenceKeys.AUTOSAVE_SCHEDULE, ApplicationPreferenceKeys.AUTOSAVE_SCHEDULE_DEFAULT);
    final int delayMinutes = autosaveSchedule;
    schedule(delayMinutes);
}
 
Example 9
Source File: ThemeHelper.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void loadThemes() {
    Preferences p = Preferences.userNodeForPackage(this.getClass());
    boolean darkTheme = p.getBoolean("darkTheme", true);
    setDarkTheme(darkTheme);
}
 
Example 10
Source File: HintsSettings.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isEnabled(HintsManager manager, UserConfigurableRule hint, Preferences preferences ) {        
    return preferences.getBoolean(ENABLED_KEY, hint.getDefaultEnabled());
}
 
Example 11
Source File: CfgPropsCompletionQuery.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
private void completePropName(CompletionResultSet completionResultSet, String filter, int startOffset, int caretOffset) {
    final Preferences prefs = NbPreferences.forModule(PrefConstants.class);
    final boolean bDeprLast = prefs.getBoolean(PREF_DEPR_SORT_LAST, true);
    final boolean bErrorShow = prefs.getBoolean(PREF_DEPR_ERROR_SHOW, true);
    long mark = System.currentTimeMillis();
    // check if completing a property map key
    if (filter != null) {
        ClassPath cpExec = Utils.execClasspathForProj(proj);
        for (String mapProp : sbs.getMapPropertyNames()) {
            if (filter.length() > mapProp.length() && filter.contains(mapProp)) {
                String key = filter.substring(mapProp.length() + 1);
                logger.log(FINER, "Completing key for map property {0} from: ''{1}''", new Object[]{mapProp, key});
                final ConfigurationMetadataProperty propMetadata = sbs.getPropertyMetadata(mapProp);
                // if key data type is an enum complete with enum values
                final String keyDataType = extractMapKeyType(propMetadata);
                if (!keyDataType.contains("<")) {
                    Utils.completeEnum(cpExec, keyDataType, key, hint -> {
                        completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1,
                                caretOffset));
                    });
                }
                // check if key data type is boolean
                if (keyDataType.equals("java.lang.Boolean")) {
                    Utils.completeBoolean(key, hint -> {
                        completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1,
                                caretOffset));
                    });
                }
                // check if key data type is Charset
                if (keyDataType.equals("java.nio.charset.Charset")) {
                    Utils.completeCharset(key, hint -> {
                        completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1,
                                caretOffset));
                    });
                }
                // add metadata defined key hints to completion list
                final Hints hints = propMetadata.getHints();
                if (!hints.getKeyHints().isEmpty()) {
                    String keyLowcase = key.toLowerCase();
                    for (ValueHint keyHint : hints.getKeyHints()) {
                        if (keyHint.getValue().toString().toLowerCase().contains(keyLowcase)) {
                            completionResultSet.addItem(new KeyCompletionItem(keyHint, startOffset + mapProp.length() + 1,
                                    caretOffset));
                        }
                    }
                }
                // invoke key providers
                if (!hints.getKeyProviders().isEmpty()) {
                    logger.log(FINER, "Key providers for {0}:", mapProp);
                    for (ValueProvider vp : hints.getKeyProviders()) {
                        logger.log(FINER, "  {0} - params: {1}", new Object[]{vp.getName(), vp.getParameters()});
                        sbs.getHintProvider(vp.getName()).provide(vp.getParameters(), propMetadata, key, true,
                                completionResultSet, startOffset + mapProp.length() + 1, caretOffset);
                    }
                }
            }
        }
    }
    for (ConfigurationMetadataProperty propMeta : sbs.queryPropertyMetadata(filter)) {
        if (Utils.isErrorDeprecated(propMeta)) {
            // show error level deprecated props based on pref
            if (bErrorShow) {
                completionResultSet.addItem(new CfgPropCompletionItem(propMeta, startOffset, caretOffset, bDeprLast));
            }
        } else {
            completionResultSet.addItem(new CfgPropCompletionItem(propMeta, startOffset, caretOffset, bDeprLast));
        }
    }
    final long elapsed = System.currentTimeMillis() - mark;
    logger.log(FINE, "Name completion of ''{0}'' took: {1} msecs", new Object[]{filter, elapsed});
}
 
Example 12
Source File: NbEditorKit.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected @Override void toggleLineNumbers() {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean visible = prefs.getBoolean(SimpleValueNames.LINE_NUMBER_VISIBLE, EditorPreferencesDefaults.defaultLineNumberVisible);
    prefs.putBoolean(SimpleValueNames.LINE_NUMBER_VISIBLE, !visible);
}
 
Example 13
Source File: Model.java    From netbeans with Apache License 2.0 4 votes vote down vote up
Boolean isBraceOutline() {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    return prefs.getBoolean(SimpleValueNames.BRACE_SHOW_OUTLINE, true);
}
 
Example 14
Source File: VariablesViewButtons.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isResultsViewNested() {
    Preferences preferences = NbPreferences.forModule(ContextProvider.class).node(PREFERENCES_NAME); // NOI18N
    return preferences.getBoolean(SHOW_EVALUTOR_RESULT, true);
}
 
Example 15
Source File: DesktopController.java    From CPUSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Loads preferences
 */
public void loadPreferences() {
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    mediator.setCurrentMachineDirectory(System.getProperty("user.dir"));
    currentTextDirectory = System.getProperty("user.dir");
    // the next two lines sometimes cause problems (exceptions to be thrown)
    //        currentMachineDirectory = prefs.get("machineDirectory", System
    // .getProperty("user.dir"));
    //        currentTextDirectory = prefs.get("textDirectory", System.getProperty
    // ("user.dir"));


    int numTextFiles = prefs.getInt("numTextFiles", 0);
    for (int i = 0; i < numTextFiles; i++) {
        reopenTextFiles.offer(prefs.get("reopenTextFile" + i, ""));
    }

    updateReopenTextMenu();

    int numMachineFiles = prefs.getInt("numMachineFiles", 0);
    for (int i = 0; i < numMachineFiles; i++) {
        reopenMachineFiles.offer(prefs.get("reopenMachineFile" + i, ""));
    }

    updateReopenMachineMenu();

    regDataBase = prefs.get("regDataBase", "Dec");
    ramAddressBase = prefs.get("ramAddressBase", "Dec");
    ramDataBase = prefs.get("ramDataBase", "Decimal");

    assmFontData.fontSize = prefs.get("assmFontSize", "12");
    assmFontData.font = prefs.get("assmFont", "Courier New");
    assmFontData.background = prefs.get("assmBackground", "#fff");
    assmFontData.selection = prefs.get("assmSelection", "#ddd");

    registerTableFontData.fontSize = prefs.get("registerTableFontSize", "12");
    registerTableFontData.font = prefs.get("registerTableFont", "Courier New");
    registerTableFontData.background = prefs.get("registerTableBackground", "#fff");
    registerTableFontData.selection = prefs.get("registerTableSelection", "#ddd");

    ramTableFontData.fontSize = prefs.get("ramTableFontSize", "12");
    ramTableFontData.font = prefs.get("ramTableFont", "Courier New");
    ramTableFontData.background = prefs.get("ramTableBackground", "#fff");
    ramTableFontData.selection = prefs.get("ramTableSelection", "#ddd");

    for (String[] defaultBinding : DEFAULT_KEY_BINDINGS) {
        String menuName = defaultBinding[0];
        String keyCode = prefs.get(menuName, defaultBinding[1]);
        keyBindings.put(menuName, new KeyCodeInfo(keyCode));
    }

    otherSettings.autoSave = prefs.getBoolean("autoSave", false);
    otherSettings.showLineNumbers.set(prefs.getBoolean("showLineNumbers", true));
    otherSettings.clearConsoleOnRun = prefs.getBoolean("clearConsoleOnRun", true);
    otherSettings.lineWrap.set(prefs.getBoolean("lineWrap", false));
}
 
Example 16
Source File: ErrorFixesFakeHint.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isCreateFinalFieldsForCtor(Preferences p) {
    return p.getBoolean(FINAL_FIELDS_FROM_CTOR, true);
}
 
Example 17
Source File: JsonPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Returns true if comments are allowed for JSON files.
 * @return the comments status
 */
public boolean isCommentSupported() {
    final Preferences prefs = getPreferences();
    return prefs.getBoolean(PREF_JSON_COMMENTS, false);
}
 
Example 18
Source File: UninitializedVariableHint.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public boolean checkVariablesInitializedByReference(Preferences preferences) {
    return preferences.getBoolean(CHECK_VARIABLES_INITIALIZED_BY_REFERENCE, false);
}
 
Example 19
Source File: PersistentComponentCheckBox.java    From snowblossom with Apache License 2.0 3 votes vote down vote up
public PersistentComponentCheckBox(Preferences iprefs, String label, String ipath, boolean default_value)
{
  super(label, iprefs.getBoolean(ipath, default_value));

  this.prefs = iprefs;
  this.pref_path = ipath;

  this.value = prefs.getBoolean(pref_path, !default_value);

  this.addChangeListener(this);

  stateChanged(null);

}
 
Example 20
Source File: JXTipOfTheDay.java    From Pixelitor with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param showOnStartupPref
 * @return true if the key named "ShowTipOnStartup" is not set to false
 */
public static boolean isShowingOnStartup(Preferences showOnStartupPref) {
  return showOnStartupPref.getBoolean(PREFERENCE_KEY, true);
}