List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.aptana.ide.wizards.LibraryProjectWizard.java
License:Open Source License
/** * Prompts the user for whether to switch perspectives. * //ww w . j a v a 2s.co m * @param window * The workbench window in which to switch perspectives; must not be <code>null</code> * @param finalPersp * The perspective to switch to; must not be <code>null</code>. * @return <code>true</code> if it's OK to switch, <code>false</code> otherwise */ private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) { IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) { // Return whether or not we should always switch return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm); } MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ResourceMessages.NewProject_perspSwitchTitle, NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()), null /* use the default message for the toggle */, false /* toggle is initially unchecked */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); int result = dialog.getReturnCode(); // If we are not going to prompt anymore propogate the choice. if (dialog.getToggleState()) { String preferenceValue; if (result == IDialogConstants.YES_ID) { // Doesn't matter if it is replace or new window // as we are going to use the open perspective setting preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE; } else { preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE; } // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue); } return result == IDialogConstants.YES_ID; }
From source file:com.aptana.internal.ui.text.spelling.SpellCheckEngine.java
License:Open Source License
/** * Resets the current checker's user dictionary. *//*from w w w .jav a 2 s . c om*/ private synchronized void resetUserDictionary() { if (this.fChecker == null) { return; } // Update user dictionary if (this.fUserDictionary != null) { this.fChecker.removeDictionary(this.fUserDictionary); this.fUserDictionary.unload(); this.fUserDictionary = null; } final IPreferenceStore store = Activator.getSpellingPreferenceStore(); // Activator.getSpellingPreferenceStore()(); final String filePath = store.getString(PreferenceConstants.SPELLING_USER_DICTIONARY); // IStringVariableManager variableManager= // VariablesPlugin.getDefault().getStringVariableManager(); // try { // filePath= variableManager.performStringSubstitution(filePath); // } catch (CoreException e) { // JavaPlugin.log(e); // return; // } if (filePath.length() > 0) { try { final File file = new File(filePath); if (!file.exists() && !file.createNewFile()) { return; } final URL url = new URL("file", null, filePath); //$NON-NLS-1$ final InputStream stream = url.openStream(); if (stream != null) { try { this.fUserDictionary = new PersistentSpellDictionary(url); this.fChecker.addDictionary(this.fUserDictionary); } finally { stream.close(); } } } catch (final MalformedURLException exception) { // Do nothing } catch (final IOException exception) { // Do nothing } } }
From source file:com.aptana.js.debug.ui.internal.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */// w ww. j a v a2 s . c o m public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = UIUtils.getActiveShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtil.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchBrowserUtil.launchExternalBrowser(URL_INSTALL_PDM, "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ return Boolean.TRUE; case 1: return Boolean.TRUE; case 3: WorkbenchBrowserUtil.launchExternalBrowser(URL_DOCS_INSTALL_IE_DEBUGGER); return Boolean.TRUE; default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format( Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, ((String) source).substring(5))); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, ((String) source).substring(10))); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } } IPreferenceStore store = JSDebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return Boolean.TRUE; } } String message = MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, (String) source); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IJSDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return Boolean.TRUE; case IDialogConstants.NO_ID: return Boolean.FALSE; default: break; } String urlString = (((String) source).indexOf("Internet Explorer") != -1) //$NON-NLS-1$ ? URL_DOCS_INSTALL_IE_DEBUGGER : URL_DOCS_INSTALL_DEBUGGER; WorkbenchBrowserUtil.launchExternalBrowser(urlString); } }
From source file:com.aptana.js.interactive_console.console.JSConsole.java
License:Open Source License
/** * @return the prompt to be used in the console. *//*from w w w. jav a2s. c om*/ @Override protected ScriptConsolePrompt createConsolePrompt() { IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String newPrompt = store.getString(JSConsoleConstants.PREF_NEW_PROMPT); String continuePrompt = store.getString(JSConsoleConstants.PREF_CONTINUE_PROMPT); if (newPrompt == null || newPrompt.length() == 0) { newPrompt = JSConsoleConstants.DEFAULT_NEW_PROMPT; } if (continuePrompt == null || continuePrompt.length() == 0) { continuePrompt = JSConsoleConstants.DEFAULT_CONTINUE_PROMPT; } return new ScriptConsolePrompt(newPrompt, continuePrompt); }
From source file:com.aptana.portal.ui.dispatch.actionControllers.PreferenceActionController.java
License:Open Source License
@SuppressWarnings("unchecked") /**//w w w . j av a 2 s . c o m * Returns a preference value for the key given with the attributes. */ @ControllerAction public Object getPreferenceValue(Object arguments) { Object check = checkArguments(arguments); if (check != null) { return check; } IPreferenceStore preferenceStore = PortalUIPlugin.getDefault().getPreferenceStore(); try { Map<String, String> map = (Map<String, String>) ((Object[]) arguments)[0]; return preferenceStore.getString(map.get(KEY)); } catch (Throwable t) { IdeLog.logError(PortalUIPlugin.getDefault(), t); return IBrowserNotificationConstants.JSON_ERROR; } }
From source file:com.aptana.portal.ui.dispatch.configurationProcessors.InstallerConfigurationProcessor.java
License:Open Source License
/** * Cache the installed application location and version in the preferences. * /* ww w . ja va 2 s . c o m*/ * @param installDir * - The directory the application was installed to. * @param versionedFileLocation * - Can be the URL that we grabbed the installer from, or any other string that contains a version * information in a form of x.y.z. * @param appName * - The application name (e.g. xampp) */ @SuppressWarnings("unchecked") public void cacheVersion(String installDir, String versionedFileLocation, String appName) { IPreferenceStore preferenceStore = PortalUIPlugin.getDefault().getPreferenceStore(); String versions = preferenceStore.getString(IPortalPreferences.CACHED_VERSIONS_PROPERTY_NAME); Map<String, Map<String, String>> versionsMap = null; if (versions == null || versions.equals(StringUtil.EMPTY)) { versionsMap = new HashMap<String, Map<String, String>>(); } else { versionsMap = (Map<String, Map<String, String>>) JSON.parse(versions); } Map<String, String> appVersionMap = new HashMap<String, String>(); Version version = VersionUtil.parseVersion(versionedFileLocation); if (version != null) { appVersionMap.put(IPortalPreferences.CACHED_VERSION_PROPERTY, version.toString()); appVersionMap.put(IPortalPreferences.CACHED_LOCATION_PROPERTY, installDir); versionsMap.put(appName.toLowerCase(), appVersionMap); preferenceStore.setValue(IPortalPreferences.CACHED_VERSIONS_PROPERTY_NAME, JSON.toString(versionsMap)); } else { IdeLog.logError(PortalUIPlugin.getDefault(), MessageFormat.format( "Could not cache the location and version for {0}. Install dir: {1}, versionedFileLocation: {2}", //$NON-NLS-1$ appName, installDir, versionedFileLocation), new Exception()); } }
From source file:com.aptana.radrails.rcp.IDEWorkbenchAdvisor.java
License:Open Source License
public void postStartup() { tearDownSplash32Workaround();/* w w w .j av a 2 s .c o m*/ try { IPreferenceStore prefStore = MainPlugin.getDefault().getPreferenceStore(); if (prefStore != null && prefStore.getBoolean( com.aptana.radrails.rcp.main.preferences.IPreferenceConstants.REOPEN_EDITORS_ON_STARTUP)) { IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); ArrayList openFiles = getOpenEditors(windows); IPreferenceStore store = IdePlugin.getDefault().getPreferenceStore(); String fileString = store.getString(PREFERENCE_OPEN_FILES); if (fileString != null) { String[] files = fileString.split(PREFERENCE_FILE_DELIMETER); for (int i = 0; i < files.length; i++) { String file = files[i]; if (!StringUtils.EMPTY.equals(file)) { File f = new File(file); if (f.exists() && !openFiles.contains(file)) { WorkbenchHelper.openFile(f, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } } } } } } catch (Exception ex) { IdeLog.logError(IdePlugin.getDefault(), Messages.ApplicationWorkbenchAdvisor_ErrorPostStartup, ex); } try { refreshFromLocal(); activateProxyService(); ((Workbench) PlatformUI.getWorkbench()).registerService(ISelectionConversionService.class, new IDESelectionConversionService()); initializeSettingsChangeListener(); Display.getCurrent().addListener(SWT.Settings, settingsChangeListener); } finally {// Resume background jobs after we startup Job.getJobManager().resume(); } }
From source file:com.aptana.ui.DialogUtils.java
License:Open Source License
/** * openIgnoreMessageDialogInformation//from www . j a v a 2s .c om * * @param shell * @param title * @param message * @param store * @param key * @return int */ public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, IPreferenceStore store, String key) { if (!store.getString(key).equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle d = MessageDialogWithToggle.openInformation(shell, title, message, Messages.DialogUtils_HideMessage, false, store, key); if (d.getReturnCode() == 3) { return MessageDialog.CANCEL; } } return MessageDialog.OK; }
From source file:com.aptana.ui.DialogUtils.java
License:Open Source License
/** * openIgnoreMessageDialogConfirm//from www.j a v a 2s.co m * * @param shell * @param title * @param message * @param store * @param key * Key to store the show/hide this message. Message will be hidden if true * @return int */ public static int openIgnoreMessageDialogConfirm(Shell shell, String title, String message, IPreferenceStore store, String key) { if (!store.getString(key).equals(MessageDialogWithToggle.ALWAYS)) { MessageDialogWithToggle d = MessageDialogWithToggle.openYesNoQuestion(shell, title, message, Messages.DialogUtils_HideMessage, false, store, key); if (d.getReturnCode() == 3) { return MessageDialog.CANCEL; } } return MessageDialog.OK; }
From source file:com.arc.cdt.importer.internal.ui.NewProjectCreatorPage.java
License:Open Source License
private void browseToNewProjectLocation() { if (mDirectoryDialog == null) { mDirectoryDialog = new DirectoryDialog(getShell(), SWT.SAVE); mDirectoryDialog.setText("Select location of converted project"); IPreferenceStore pref = ImporterPlugin.getDefault().getPreferenceStore(); String dir = pref.getString(LOCATION_DIR_FILTER_ID); if (dir != null) { mDirectoryDialog.setFilterPath(dir); }/*from ww w . j a va 2 s . com*/ } String fn = mDirectoryDialog.open(); if (fn != null) { mNewProjectLocation.setText(fn); this.validateNewProjectLocation(); } String dir = mDirectoryDialog.getFilterPath(); if (dir != null) { ImporterPlugin.getDefault().getPreferenceStore().putValue(LOCATION_DIR_FILTER_ID, dir); } }