private void storeProfilingSettings(ProfilingSettings settings) { Preferences pref = getPreferences(); pref.putInt(ProfilingSettings.PROP_SAMPLING_FREQUENCY, settings.getSamplingFrequency()); pref.putInt(ProfilingSettings.PROP_CPU_PROFILING_TYPE, settings.getCPUProfilingType()); pref.putInt(ProfilingSettings.PROP_SAMPLING_INTERVAL, settings.getSamplingInterval()); pref.putBoolean(ProfilingSettings.PROP_EXCLUDE_WAIT_TIME, settings.getExcludeWaitTime()); pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_SPAWNED_THREADS, settings.getInstrumentSpawnedThreads()); pref.putInt(ProfilingSettings.PROP_N_PROFILED_THREADS_LIMIT, settings.getNProfiledThreadsLimit()); pref.putInt(ProfilingSettings.PROP_INSTR_SCHEME, settings.getInstrScheme()); pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_METHOD_INVOKE, settings.getInstrumentMethodInvoke()); pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_GETTER_SETTER_METHODS, settings.getInstrumentGetterSetterMethods()); pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_EMPTY_METHODS, settings.getInstrumentEmptyMethods()); pref.putInt(ProfilingSettings.PROP_OBJ_ALLOC_STACK_SAMPLING_INTERVAL, settings.getAllocTrackEvery()); pref.putBoolean(ProfilingSettings.PROP_RUN_GC_ON_GET_RESULTS_IN_MEMORY_PROFILING, settings.getRunGCOnGetResultsInMemoryProfiling()); pref.putBoolean(ProfilingSettings.PROP_THREADS_SAMPLING_ENABLED, settings.getThreadsSamplingEnabled()); }
private void checkContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException { for(String s : tree) { int equalIdx = s.lastIndexOf('='); assertTrue(equalIdx != -1); String value = s.substring(equalIdx + 1); String key; String nodePath; int slashIdx = s.lastIndexOf('/', equalIdx); if (slashIdx != -1) { key = s.substring(slashIdx + 1, equalIdx); nodePath = s.substring(0, slashIdx); } else { key = s.substring(0, equalIdx); nodePath = ""; } assertTrue(prefsId + " doesn't contain node '" + nodePath + "'", prefs.nodeExists(nodePath)); Preferences node = prefs.node(nodePath); String realValue = node.get(key, null); assertNotNull(prefsId + ", '" + nodePath + "' node doesn't contain key '" + key + "'", realValue); assertEquals(prefsId + ", '" + nodePath + "' node, '" + key + "' contains wrong value", value, realValue); } }
private void setImages() { Preferences preferences = Preferences.userNodeForPackage(Player.class); volDown.setGraphic(volDownImage); volUp.setGraphic(volUpImage); previous.setGraphic(previousImage); play.setGraphic(playImage); next.setGraphic(nextImage); final boolean isShuffleMode = preferences.getBoolean("ShuffleMode", false); shuffle.setGraphic(isShuffleMode ? shufflePressedImage : shuffleImage); final boolean isLoopMode = preferences.getBoolean("LoopMode", false); loop.setGraphic(isLoopMode ? loopPressedImage: loopImage); volSlider.valueChangingProperty().addListener(rootController.volumeUpdated(volSlider)); }
private boolean promptToDelete(Preferences prefs) { Object result = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.msg_clear_keys"), NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.title_clear_keys"), NotifyDescriptor.OK_CANCEL_OPTION)); if (result == NotifyDescriptor.OK_OPTION) { try { LOG.log(Level.FINE, "agreed to delete stored passwords: {0}", Arrays.asList(prefs.keys())); prefs.clear(); return testSampleKey(prefs); } catch (BackingStoreException x) { LOG.log(Level.INFO, null, x); } } else { LOG.fine("refused to delete stored passwords"); } return false; }
@Override protected void storeListData(final JList list, final String optionID, final Preferences node) { StringBuilder sb = null; for (int i = 0; i < list.getModel().getSize(); i++) { if (sb == null) { sb = new StringBuilder(); } else { sb.append(';'); } if (classMembersOrder.equals(optionID)) { Element e = (Element) list.getModel().getElementAt(i); if (e.isStatic) sb.append("STATIC "); //NOI18N sb.append(e.kind.name()); } else { Visibility v = (Visibility) list.getModel().getElementAt(i); sb.append(v.kind); } } String value = sb != null ? sb.toString() : ""; //NOI18N if (getDefaultAsString(optionID).equals(value)) node.remove(optionID); else node.put(optionID, value); }
private void generateRow(int rowIndex) { Preferences prefs = userRoot().node("General"); if (!prefs.getBoolean("generate", true)) return; assert (rowIndex < proofData.size()); ProofRow row = proofData.getRow(rowIndex); Rule rule = row.getRule(); if (rule == null || rule.hasCompleteInfo() == false || row.getFormula() != null) { return; } Formula generated = null; try { generated = rule.generateFormula(proofData, rowIndex); } catch (VerificationInputException e) { return; } if (generated == null) return; row.setFormula(generated); for (ProofListener listener : this.listeners) { listener.rowUpdated(generated.toString(), true, rowIndex + 1); } }
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 }
/** * Checks that modifications to the ihnerited store are not fired if * the local store overrides */ public void testInheritedEventsMasked() throws Exception { Preferences stored = new MapPreferences(); Preferences inherited = new MapPreferences(); inherited.putInt("intValue", 100); stored.putInt("intValue", 10); MemoryPreferences mem = MemoryPreferences.getWithInherited(this, inherited, stored); Preferences test = mem.getPreferences(); PL pl = new PL(); test.addPreferenceChangeListener(pl); // change pl.arm(); inherited.putInt("intValue", 3); pl.waitEvent(); assertEquals(0, pl.changeCount); // remove not inherited pl.arm(); inherited.remove("intValue"); pl.waitEvent(); assertEquals(0, pl.changeCount); }
private JComponent createBooleanOption(OptionDescriptor option, Preferences prefs) { JCheckBox checkBox = new JCheckBox(); org.openide.awt.Mnemonics.setLocalizedText(checkBox, option.displayName); checkBox.setToolTipText(option.tooltip); checkBox.addActionListener(new ActionListenerImpl(option.preferencesKey, prefs)); checkBox.setSelected(prefs.getBoolean(option.preferencesKey, Boolean.TRUE == option.defaultValue)); prefs.putBoolean(option.preferencesKey, checkBox.isSelected()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridheight = 1; constraints.gridwidth = 2; constraints.gridx = 0; constraints.gridy = row++; constraints.weightx = 0; constraints.weighty = 0; add(checkBox, constraints); return checkBox; }
private Preferences indexerProfileNode(SourceIndexerFactory srcFactory) { String nn = srcFactory.getIndexerName(); if (nn.length() >= Preferences.MAX_NAME_LENGTH) { // such long nodes are constructer e.g. from class names int i = nn.lastIndexOf('.'); if (i >= 0) { nn = nn.substring(i + 1); } if (nn.length() < 3 || nn.length() >= Preferences.MAX_NAME_LENGTH) { String hashCode = Integer.toHexString(nn.hashCode()); // attempt to derive +- unique node name nn = srcFactory.getClass().getSimpleName() + "_" + hashCode; // NOI18N } } return NbPreferences.forModule(srcFactory.getClass()).node("RepositoryUpdater"). // NOI18N node(nn); }
private Properties getStoredProperties() { return AccessController .doPrivileged((PrivilegedAction<Properties>) () -> { Properties p = new Properties(); String notePath = "/com/sun/media/sound/softsynthesizer"; try { Preferences prefroot = Preferences.userRoot(); if (prefroot.nodeExists(notePath)) { Preferences prefs = prefroot.node(notePath); String[] prefs_keys = prefs.keys(); for (String prefs_key : prefs_keys) { String val = prefs.get(prefs_key, null); if (val != null) { p.setProperty(prefs_key, val); } } } } catch (final BackingStoreException ignored) { } return p; }); }
public void testFlushTree1() throws BackingStoreException { String [] origTree = new String [] { "CodeStyle/profile=GLOBAL", }; String [] newTree = new String [] { "CodeStyle/text/x-java/tab-size=2", "CodeStyle/text/x-java/override-global-settings=true", "CodeStyle/text/x-java/expand-tabs=true", "CodeStyle/profile=PROJECT", }; Preferences orig = Preferences.userRoot().node(getName()); write(orig, origTree); checkContains(orig, origTree, "Orig"); checkNotContains(orig, newTree, "Orig"); Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig); checkEquals("Test should be the same as Orig", orig, test); write(test, newTree); checkContains(test, newTree, "Test"); test.flush(); checkEquals("Test didn't flush to Orig", test, orig); }
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); }
protected CategorySupport(Preferences preferences, String id, JPanel panel, String previewText, String[]... forcedOptions) { this.preferences = preferences; this.id = id; this.panel = panel; this.previewText = previewText != null ? previewText : NbBundle.getMessage(CategorySupport.class, "SAMPLE_Default"); //NOI18N // Scan the panel for its components scan(panel, components); // Initialize the preview preferences Preferences forcedPrefs = new PreviewPreferences(); for (String[] option : forcedOptions) { forcedPrefs.put( option[0], option[1]); } this.previewPrefs = new ProxyPreferences(forcedPrefs, preferences); // Load and hook up all the components loadFrom(preferences); addListeners(); }
public void testFieldFix208072d() throws Exception { Preferences prefs = CodeStylePreferences.get((FileObject) null, JavacParser.MIME_TYPE).getPreferences(); prefs.put("classMembersOrder", "STATIC_INIT;STATIC METHOD;INSTANCE_INIT;CONSTRUCTOR;METHOD;STATIC CLASS;CLASS;STATIC FIELD;FIELD"); prefs.put("classMemberInsertionPoint", "LAST_IN_CATEGORY"); performFixTest("package test;\n" + "import java.util.logging.Level;\n" + "import java.util.logging.Logger;\n" + "public class Test {\n" + " static {\n" + " int ii = |1 + 2 * 3|;\n" + " }\n" + " private static final int II = 0;\n" + "}\n", ("package test;\n" + "import java.util.logging.Level;\n" + "import java.util.logging.Logger;\n" + "public class Test {\n" + " private static int ZZ = 1 + 2 * 3;\n" + " static {\n" + " int ii = ZZ;\n" + " }\n" + " private static final int II = 0;\n" + "}\n").replaceAll("[ \t\n]+", " "), new DialogDisplayerImpl2("ZZ", IntroduceFieldPanel.INIT_FIELD, false, EnumSet.<Modifier>of(Modifier.PRIVATE), false, true), 5, 2); }
private void init() { Preferences prefs = getConfigurationsRoot(); try { for (String kid:prefs.childrenNames()) { if (kid.startsWith(RULE_PREFIX)) { Preferences p = prefs.node(kid); String displayName = p.get("display.name", "unknown"); create(kid.substring(RULE_PREFIX.length()), displayName); } } } catch (BackingStoreException ex) { Exceptions.printStackTrace(ex); } if (configs.isEmpty()) { create("default", NbBundle.getMessage(ConfigurationsManager.class, "DN_Default")); } prefs.putInt(KEY_CONFIGURATIONS_VERSION, CURRENT_CONFIGURATIONS_VERSION); }
public static @CheckForNull File[] find(@NonNull URL root, boolean javadoc) { String k = root.toString(); Preferences n = node(javadoc); String v = n.get(k, null); if (v == null) { return null; } String[] split = StringUtils.split(v, "||"); List<File> toRet = new ArrayList<File>(); for (String vv : split) { File f = FileUtilities.convertStringToFile(vv); if (f.isFile()) { toRet.add(f); } else { //what do we do when one of the possibly more files is gone? //in most cases we are dealing with exactly one file, so keep the //previous behaviour of removing it. n.remove(k); } } return toRet.toArray(new File[0]); }
private static void selectInitialEditor() { List<Class<? extends PdfEditor>> classes = new ArrayList<>(pdfEditorClasses.size() + 2); classes.add(findEditorClass( System.getProperty("pdfjumbler.editor", null) )); classes.add(findEditorClass( Preferences.userNodeForPackage(PdfJumbler.class).get("editor", null) )); classes.addAll(pdfEditorClasses); for (Class<? extends PdfEditor> cls : classes) { if (cls == null) { continue; } System.err.print("Trying to instantiate editor: " + cls + "... "); try { editor = cls.newInstance(); } catch (Exception e) { System.err.println("Error: " + e.getClass().getCanonicalName()); e.printStackTrace(); continue; } System.err.println("ok."); break; } if (editor == null) { JOptionPane.showMessageDialog( null, resources.getString("NO_PDF_EDITOR_TEXT"), resources.getString("NO_PDF_EDITOR_TITLE"), JOptionPane.ERROR_MESSAGE ); System.exit(101); } }
public void testNewLineIndentationBeforeAbsolutLabeledStatement() throws Exception { Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class); preferences.putBoolean("absoluteLabelIndent", true); try { performNewLineIndentationTest("package t;\npublic class T {\n public void op() {|mylabel:\n }\n}\n", "package t;\npublic class T {\n public void op() {\nmylabel:\n }\n}\n"); } finally { preferences.remove("absoluteLabelIndent"); } }
@Override protected String getSpi(String key) { for(Preferences p : delegates) { String value = p.get(key, null); if (value != null) { return value; } } return null; }
public static ProjectConfig getLast() { Preferences prefs = Preferences.userRoot(); try { if (prefs.nodeExists(userPrefFolder) && (prefs = prefs.node(userPrefFolder)).nodeExists(userPrefKey) && (prefs = prefs.node(userPrefKey)).nodeExists(pathsAKey) && prefs.nodeExists(pathsBKey) && prefs.nodeExists(pathsSharedKey)) { Function<String, Path> deserializer = str -> Paths.get(str); List<Path> pathsA = loadList(prefs.node(pathsAKey), deserializer); List<Path> pathsB = loadList(prefs.node(pathsBKey), deserializer); List<Path> classPathA = loadList(prefs.node(classPathAKey), deserializer); List<Path> classPathB = loadList(prefs.node(classPathBKey), deserializer); List<Path> pathsShared = loadList(prefs.node(pathsSharedKey), deserializer); boolean inputsBeforeClassPath = prefs.getBoolean(inputsBeforeClassPathKey, false); ProjectConfig ret = new ProjectConfig(pathsA, pathsB, classPathA, classPathB, pathsShared, inputsBeforeClassPath); ret.setUidSettings(prefs.get("uidHost", null), prefs.getInt("uidPort", 0), prefs.get("uidUser", null), prefs.get("uidPassword", null), prefs.get("uidProject", null), prefs.get("uidVersionA", null), prefs.get("uidVersionB", null)); return ret; } } catch (BackingStoreException e) { } return new ProjectConfig(); }
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); } }
JPDABreakpoint () { Preferences preferences = NbPreferences.forModule(getClass()).node("debugging"); // NOI18N int num = preferences.getInt("default.suspend.action", -1); // NOI18N [TODO] create property name constant, use it in ActionsPanel if (num == -1) { Properties p = Properties.getDefault().getProperties("debugger.options.JPDA"); num = p.getInt("BreakpointSuspend", JPDABreakpoint.SUSPEND_EVENT_THREAD); } switch (num) { case 0: suspend = SUSPEND_NONE; break; case 1: suspend = SUSPEND_EVENT_THREAD; break; case 2: suspend = SUSPEND_ALL; } }
public static List<String> getImmutableTypes(Preferences p) { String val = p.get(PREF_IMMUTABLE_CLASSES, ""); StringTokenizer tukac = new StringTokenizer(", ", val); List<String> res = new ArrayList<>(3); while (tukac.hasMoreTokens()) { String token = tukac.nextToken(); if (token.isEmpty()) { continue; } res.add(token); } return res; }
@Override public void start(final Stage primaryStage) throws Exception { primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.getIcons().add(new Image("/com/matthieu42/steamtradertools/bundles/images/Icon_STTBluepng.png")); Preferences prefs = Preferences.userNodeForPackage(com.matthieu42.steamtradertools.model.Main.class); String language = prefs.get(PreferencesKeys.LANGUAGE.toString(),Locale.ENGLISH.getDisplayLanguage()); Locale locale; if(language.equals(Locale.FRENCH.getDisplayLanguage())) { locale = Locale.FRENCH; } else locale = Locale.ENGLISH; I18n.setLocale(locale); I18n.setBundle("com/matthieu42/steamtradertools/bundles/lang",locale); final AllAppList allAppList = new AllAppList(); final UserAppList userAppList = new UserAppList(); File steamAppList = new File("steamAppList.xml"); if (!steamAppList.exists()) { FXMLLoader splashLoader = new FXMLLoader(getClass().getResource("/com/matthieu42/steamtradertools/view/loadview.fxml"),I18n.getResourceBundle()); AnchorPane pane = splashLoader.load(); primaryStage.setScene(new Scene(pane)); primaryStage.show(); Task<Void> syncApp = allAppList.init(); syncApp.setOnSucceeded(t -> { allAppList.saveToXml(); continueLaunch(allAppList,userAppList,primaryStage); }); syncApp.setOnFailed(t -> { return; }); new Thread(syncApp).start(); } else { allAppList.loadFromXml(); continueLaunch(allAppList,userAppList,primaryStage); } }
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); } }
public void setFlagsSetting(FlagsSetting flagsSetting) { FlagsSetting old = this.getFlagsSetting(); this.flagsSetting = flagsSetting; Preferences prefs = getPreferences(); firePropertyChange(PROP_FLAGS, old, flagsSetting); prefs.put(PROP_FLAGS, flagsSetting.getFlagString()); }
protected String getSpi(String key) { for(Preferences p : delegates) { String value = p.get(key, null); if (value != null) { return value; } } return null; }
private Preferences createShellPreferences() { Project p = env.getProject(); if (p != null) { return ProjectUtils.getPreferences(p, ShellSession.class, false).node("jshell"); } else { return NbPreferences.forModule(ShellSession.class).node("jshell"); } }
@Override public JComponent getCustomizer(Preferences prefs) { JComponent customizer = new WrongStringComparisonCustomizer(prefs); prefs.putBoolean(STRING_LITERALS_FIRST, getStringLiteralsFirst(prefs)); prefs.putBoolean(TERNARY_NULL_CHECK, getTernaryNullCheck(prefs)); return customizer; }
public void store( Preferences target ) { try { for (String key : keys()) { target.put(key, get(key, null)); } } catch (BackingStoreException ex) { Exceptions.printStackTrace(ex); } }
@Override public void actionPerformed(ActionEvent e) { javax.swing.SwingUtilities.invokeLater(() -> { try { // final JFrame f = new JFrame("Preferences"); final FontChooser2 fc = new FontChooser2(TEdit); fc.setResizable(false); fc.setVisible(true); Font myNewFont = fc.getSelectedFont(); // System.out.println("You chose " + myNewFont); if(myNewFont!=null){ TEdit.getTextArea().setFont(myNewFont); Preferences Config = TEdit.getConfig(); Config.put("FONT_NAME",myNewFont.getName()); Config.putInt("FONT_SIZE",myNewFont.getSize()); Config.putInt("FONT_STYLE", myNewFont.getStyle()); Config.putInt("PRECISION",jc.MC.getPrecision()); Config.flush(); } //f.pack(); // adjust for new size fc.dispose(); } catch (Exception e1) { System.out.println(e1.getMessage()); } }); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
/** * Charge les paramètres depuis les préférences utilisateur. * @return Parameters * @throws BackingStoreException e */ public static Parameters createFromUserPreferences() throws BackingStoreException { final Properties properties = new Properties(); final Preferences prefs = Preferences.userNodeForPackage(Parameters.class); for (final String key : prefs.keys()) { final String value = prefs.get(key, null); if (value != null && !value.isEmpty()) { properties.put(key, value); } } return new Parameters(properties); }
private void loadButtonsFromPreferences() { // TODO show a loading symbol ConceptButtonFactory factory = new ConceptButtonFactory(conceptService, eventBus, i18n); try { List<Button> buttons = Arrays.stream(panePreferences.childrenNames()) .map(nodeName -> { Preferences buttonPreferences = panePreferences.node(nodeName); String conceptName = buttonPreferences.get(PREF_BUTTON_NAME, BAD_KEY); int order = buttonPreferences.getInt(PREF_BUTTON_ORDER, 0); Button button = factory.build(conceptName); return new ButtonPref(button, order); }) .filter(buttonPref -> !buttonPref.getButton().getText().equals(BAD_KEY)) .sorted(Comparator.comparingInt(ButtonPref::getOrder)) .map(ButtonPref::getButton) .collect(Collectors.toList()); getPane().getChildren().addAll(buttons); } catch (Exception e) { eventBus.send(new ShowNonfatalErrorAlert( i18n.getString("cbpanel.alert.prefsfail.load.title"), i18n.getString("cbpanel.alert.prefsfail.load.header"), i18n.getString("cbpanel.alert.prefsfail.load.content"), e)); } }
/** Gets current severiry of the hint. * @return Hints severity in current profile. */ public final HintSeverity getSeverity(Preferences p) { String s = p.get(SEVERITY_KEY, null ); HintSeverity severity = s == null ? defaultSeverity : fromPreferenceString(s); if(!id2Saved.containsKey(SEVERITY_KEY)) { id2Saved.put(SEVERITY_KEY, severity); } return severity; }
public static synchronized EditorRenderingHints get(MimePath mimePath) { EditorRenderingHints erh = CACHE.get(mimePath); if (erh == null) { Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class); erh = new EditorRenderingHints(prefs); CACHE.put(mimePath, erh); } return erh; }
public Preferences getPreferences() { // Map<String, Preferences> override = HintsSettings.getPreferencesOverride(); // if (override != null) { // Preferences p = override.get(getId()); // if (p != null) { // return p; // } // } return NbPreferences.forModule(this.getClass()).node(getId()); //NOI18N }
private boolean arePrefsChanged(String mimeType) { boolean isChanged = false; Preferences prefs = selector.getPreferences(mimeType); Preferences savedPrefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class); HashSet<String> hashSet = new HashSet<String>(); try { hashSet.addAll(Arrays.asList(prefs.keys())); hashSet.addAll(Arrays.asList(savedPrefs.keys())); } catch (BackingStoreException ex) { return false; } for (String key : hashSet) { String current = prefs.get(key, null); String saved = savedPrefs.get(key, null); if (saved == null) { if (key.equals(SimpleValueNames.ON_SAVE_REMOVE_TRAILING_WHITESPACE) || key.equals(SimpleValueNames.ON_SAVE_REFORMAT)) { saved = "never"; // NOI18N } else if (key.equals(SimpleValueNames.ON_SAVE_USE_GLOBAL_SETTINGS)) { saved = "true"; // NOI18N } else { saved = selector.getSavedValue(mimeType, key); } } isChanged |= current == null ? saved != null : !current.equals(saved); if (isChanged) { // no need to iterate further return true; } } return isChanged; }
public void reset() { // Reset system properties. System.setProperties(null); // From "L" release onwards, calling System.setProperties(null) clears the java.io.tmpdir, // so we set it again. No-op on earlier releases. System.setProperty("java.io.tmpdir", tmpDir); if (JAVA_RUNTIME_VERSION != null) { System.setProperty("java.runtime.version", JAVA_RUNTIME_VERSION); } if (JAVA_VM_INFO != null) { System.setProperty("java.vm.info", JAVA_VM_INFO); } if (JAVA_VM_VERSION != null) { System.setProperty("java.vm.version", JAVA_VM_VERSION); } if (JAVA_VM_VENDOR != null) { System.setProperty("java.vm.vendor", JAVA_VM_VENDOR); } if (JAVA_VM_NAME != null) { System.setProperty("java.vm.name", JAVA_VM_NAME); } // Require writable java.home and user.dir directories for preferences if ("Dalvik".equals(System.getProperty("java.vm.name"))) { String javaHome = tmpDir + "/java.home"; IoUtils.safeMkdirs(new File(javaHome)); System.setProperty("java.home", javaHome); } String userHome = System.getProperty("user.home"); if (userHome.length() == 0) { userHome = tmpDir + "/user.home"; IoUtils.safeMkdirs(new File(userHome)); System.setProperty("user.home", userHome); } // Localization Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); // Preferences // Temporarily silence the java.util.prefs logger, which otherwise emits // an unactionable warning. See RI bug 4751540. Logger loggerToMute = Logger.getLogger("java.util.prefs"); boolean usedParentHandlers = loggerToMute.getUseParentHandlers(); loggerToMute.setUseParentHandlers(false); try { // resetPreferences(Preferences.systemRoot()); resetPreferences(Preferences.userRoot()); } finally { loggerToMute.setUseParentHandlers(usedParentHandlers); } // HttpURLConnection Authenticator.setDefault(null); CookieHandler.setDefault(null); ResponseCache.setDefault(null); HttpsURLConnection.setDefaultHostnameVerifier(defaultHostnameVerifier); HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory); // Logging LogManager.getLogManager().reset(); Logger.getLogger("").addHandler(new ConsoleHandler()); // Cleanup to force CloseGuard warnings etc System.gc(); System.runFinalization(); }
public void testLineIndentationBeforeHalfIndentedNewArrayInit() throws Exception { Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class); preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name()); try { performLineIndentationTest("package t;\npublic class T {\n public void op() {\n int[] arr = new int[]\n| {\n }\n}\n", "package t;\npublic class T {\n public void op() {\n int[] arr = new int[]\n {\n }\n}\n"); } finally { preferences.remove("otherBracePlacement"); } }