List of usage examples for org.eclipse.jface.preference IPreferenceStore setValue
void setValue(String name, boolean value);
From source file:com.aptana.ide.editors.preferences.ProblemsPreferencePage.java
License:Open Source License
/** * This is a hook for subclasses to do special things when the ok button is pressed. For example, re-implement this * method if you want to save the page's data into the preference bundle. * //w ww. j a v a2 s . c o m * @return boolean */ public boolean performOk() { IPreferenceStore store = doGetPreferenceStore(); List<Object> items = _tableEditor.getItems(); store.setValue(doGetPreferenceString(), ErrorDescriptor .serializeErrorDescriptors((ErrorDescriptor[]) items.toArray(new ErrorDescriptor[0]))); List<String> validatorItems = new ArrayList<String>(); Object[] checkedItems = _validatorViewer.getCheckedElements(); if (checkedItems.length > 0) { for (int i = 0; i < checkedItems.length; i++) { validatorItems.add(checkedItems[i].toString()); } store.setValue(IPreferenceConstants.VALIDATORS_LIST, StringUtils.join(",", validatorItems.toArray(new String[0]))); //$NON-NLS-1$ } else { // Store special value to indicate the fact that user unselected all the validators. // This help us distinguish no-selection state from initial state wherein nothing is stored as preference // initially. store.setValue(IPreferenceConstants.VALIDATORS_LIST, IPreferenceConstants.VALIDATORS_NONE); } doGetPlugin().savePluginPreferences(); return true; }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Imports a colorization and saves it to preference and global registry. * /* w w w . ja v a2s .c o m*/ * @param file - * imported colorization * @param mimeType */ public void importColorization(File file, String mimeType) { InputStream stream = null; try { String id = ids.get(mimeType); if (id != null) { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); stream = file.toURL().openStream(); this.loadXML(stream); if (mimeType != null) { store.setValue(id, content); } } } catch (Exception e1) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.ColorizerReader_ERROR_IMPORTING); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e) { } } }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Loads a colorization from the preference store * /*www.j a va 2 s. c om*/ * @param id * @param register * @return - language colorizer */ public LanguageColorizer loadColorization(String id, boolean register) { registerColorizer = register; colorizer = null; mimeType = null; try { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); InputStream stream = null; if (content.length() > 0) { stream = new ByteArrayInputStream(content.getBytes()); this.loadXML(stream); if (mimeType != null) { setPreferenceId(mimeType, id); store.setValue(id, content); } } } catch (Exception e) { colorizer = null; } return colorizer; }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerReader.java
License:Open Source License
/** * Loads a colorization file into the language registry * /*from ww w .j av a2 s .c om*/ * @param url * @param id * @param useDefault * @return - language colorizer */ public LanguageColorizer loadColorizationFromURL(URL url, String id, boolean useDefault) { InputStream stream = null; colorizer = null; mimeType = null; try { IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); String content = store.getString(id); if (content.length() > 0 && !useDefault) { stream = new ByteArrayInputStream(content.getBytes()); } else { stream = url.openStream(); } this.loadXML(stream); if (mimeType != null) { setPreferenceId(mimeType, id); urls.put(mimeType, url); store.setValue(id, content); } } catch (Exception e) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), StringUtils.format(Messages.ColorizerReader_ERROR_LOADING, id)); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e) { } } return colorizer; }
From source file:com.aptana.ide.editors.unified.colorizer.ColorizerWriter.java
License:Open Source License
/** * Builds a colorization preference./* w ww. j a va 2 s . c o m*/ * * @param lc - * language colorizer. * @param language - * language. * @param prefID - * preference ID. * @throws LexerException * IF lexer error occurs. */ public void buildColorizationPreference(LanguageColorizer lc, String language, String prefID) throws LexerException { try { Document document = buildDom(lc, language); // Save file TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ DOMSource domSource = new DOMSource(document); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); transformer.transform(domSource, result); IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore(); store.setValue(prefID, writer.toString()); } catch (Exception e) { throw new LexerException(Messages.ColorizerWriter_ERROR_SAVING, e); } }
From source file:com.aptana.ide.installer.wizard.InstallerWizardDialog.java
License:Open Source License
private void saveStates() { // stores the state of "Do not show again" checkbox IPreferenceStore prefs = Activator.getDefault().getPreferenceStore(); prefs.setValue(IPreferenceConstants.WIZARD_DO_NOT_SHOW_AGAIN, fDoNotShowButton.getSelection()); }
From source file:com.aptana.ide.intro.IntroStartup.java
License:Open Source License
/** * Show the My Aptana start page.//from w w w .ja va 2s .com */ protected void showMyAptana() { IPreferenceStore store = IntroPlugin.getDefault().getPreferenceStore(); boolean shownPreviously = store.getBoolean(IPreferenceConstants.SHOWN_PREVIOUSLY) || "true".equals(System.getProperty(IGNORE)); //$NON-NLS-1$ if (!shownPreviously) { store.setValue(IPreferenceConstants.SHOWN_PREVIOUSLY, true); showStartupPage(); return; } String showStartPage = store.getString(IPreferenceConstants.SHOW_STARTPAGE_ON_STARTUP); boolean portalPreviouslyOpened = PortalPlugin.getDefault().getPreferenceStore().getBoolean( com.aptana.ide.server.portal.preferences.IPreferenceConstants.MY_APTANA_PREVIOUSLY_OPENED); if (showStartPage.equals(IPreferenceConstants.ALWAYS_SHOW) || portalPreviouslyOpened) { showStartupPage(); return; } if (showStartPage.equals(IPreferenceConstants.NEVER_SHOW)) { return; } // this has a side effect of updating the feature change list store boolean changed = FeatureChangeManager.getManager().areFeaturesChanged(); if (changed) { IdeLog.logInfo(IntroPlugin.getDefault(), "Features Changed"); //$NON-NLS-1$ List<FeatureChange> changeList = FeatureChangeManager.getManager().getFeatureChangeList(); if (changeList != null && changeList.size() > 0) { showStartupPage(); } } else { IdeLog.logInfo(IntroPlugin.getDefault(), "Unchanged feature store"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.intro.IntroStartup.java
License:Open Source License
private void showStartupPage() { UIJob job = new UIJob("Showing Startup Page") { //$NON-NLS-1$ public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchPart activePart = null; IWorkbenchPage page = null;/*from w w w . j a va2 s .co m*/ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { page = window.getActivePage(); activePart = page.getActivePart(); } IPreferenceStore prefs = IntroPlugin.getDefault().getPreferenceStore(); String editorId = prefs.getString(IPreferenceConstants.INTRO_EDITOR_ID); IEditorPart editorPart = CoreUIUtils.openEditor(editorId, false); if (editorPart == null) { // falls back to the default editorId = prefs.getDefaultString(IPreferenceConstants.INTRO_EDITOR_ID); prefs.setValue(IPreferenceConstants.INTRO_EDITOR_ID, editorId); CoreUIUtils.openEditor(editorId, false); } // makes the active part re-grab the focus if (activePart != null) { page.activate(activePart); } return Status.OK_STATUS; } }; job.schedule(1000); }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Writes rules to preferences.//www . j av a2 s .c o m * @param rules - rules to write. */ private void saveRules(List<Rule> rules) { //clearing previous values clearList(); //saving IPreferenceStore store = getPreferenceStore(); store.setValue(LENGTH_KEY, rules.size()); for (int i = 0; i < rules.size(); i++) { Rule rule = rules.get(i); store.setValue(NAME_KEY + i, rule.getName()); store.setValue(CONTENT_KEY + i, rule.getRule()); store.setValue(REGEXP_KEY + i, rule.isRegexp()); store.setValue(CASEINSENSITIVE_KEY + i, rule.isCaseInsensitive()); } }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Clears list in preferences./* w w w . j a va2 s. c om*/ */ private void clearList() { IPreferenceStore store = getPreferenceStore(); int length = store.getDefaultInt(LENGTH_KEY); for (int i = 0; i < length; i++) { store.setValue(NAME_KEY + i, ""); //$NON-NLS-1$ store.setValue(CONTENT_KEY + i, ""); //$NON-NLS-1$ store.setValue(REGEXP_KEY + i, false); store.setValue(CASEINSENSITIVE_KEY + i, false); } }