List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
/** * Inits all preference values./*from ww w . j av a 2s .c o m*/ * * @author Joerg Sigle * @author Gerry Weirich * @author Andreas Brker * @author Markus Krger * * Adopted for Elexis by Joerg Sigle 02/2012, adding comments and monitoring output, * and reproducing the functionality of changes made by Gerry Weirich in 06/2007 * for his NOAText plugin 1.4.1 to a file obtained from an older version of the ag.ion noa library. * * Changes required because of different preference store layout in Elexis. * There are corresponding changes in: * LocalOfficeApplicationsPreferencesPage.java * PREFS_PREVENT_TERMINATION * initPreferenceValues() * performOk() * NOAUIPlugin.java * PREFERENCE_OFFICE_HOME * PREFERENCE_PREVENT_TERMINATION * internalStartApplication(). */ private void initPreferenceValues() { System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues() begin - adopted for Elexis and NOAText_jsl by GW/JS"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): allocating preferenceStore = new SettingsPreferenceStore(Hub.localCfg)"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): instead of using = NOAUIPlugin.getDefault().getPreferenceStore()"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): initializing dialog fields from internal storage or default values"); IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHomePath = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); boolean preventTermination = preferenceStore.getBoolean(PREFS_PREVENT_TERMINATION); //IPreferenceStore preferenceStore = NOAUIPlugin.getDefault().getPreferenceStore(); //String officeHomePath = preferenceStore.getString(NOAUIPlugin.PREFERENCE_OFFICE_HOME); //boolean preventTermination = preferenceStore.getBoolean(NOAUIPlugin.PREFERENCE_PREVENT_TERMINATION); textHome.setText(officeHomePath); buttonPreventTermination.setSelection(preventTermination); //When we read the two timeout settings, use try/catch so that data that can't be interpreted as integer numbers doesn't cause any harm. //The trim() is needed before parseInt(), otherwise an leading space will cause failure (though that is less probable in a string coming from internal storage). //See corresponding code in initPreferenceValues() and performOk(). System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): ToDo: refactor to move repeatedly used constants into single places or even out of the code."); Integer timeoutBootstrapConnect = getTimeoutBootstrapConnect(preferenceStore); //This also observes defaults and min/max values textTimeoutBootstrapConnect.setText(timeoutBootstrapConnect.toString()); Integer timeoutThreadedWatchdog = getTimeoutThreadedWatchdog(preferenceStore); //This also observes defaults and min/max values textTimeoutThreadedWatchdog.setText(timeoutThreadedWatchdog.toString()); //20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 begin for (int i = 0; i < PREFERENCE_cotf_elements.length; i++) { for (int j = 0; j < PREFERENCE_cotf_parameters.length; j++) { //Intermediate string variable just to supply debugging output. String s = getCotfOption(preferenceStore, i, j); //Specifically, textCotfOption[0][0] and [0][2] will NOT have been created for theconstant1 element. Therefore, don't try to set them to anything! if (textCotfOption[i][j] != null) { System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): About to set textCotfOption[" + i + "][" + j + "] to <" + s + ">..."); textCotfOption[i][j].setText(s); } } } System.out.println("LocalOfficeApplicationPreferencesPage: initPreferenceValues() end"); }
From source file:ag.ion.noa4e.ui.NOAUIPlugin.java
License:Open Source License
/** * Starts local office application.//from ww w.ja va2s . com * * @param shell shell to be used * @param officeApplication office application to be started * * @return information whether the office application was started or not - only * if the status severity is <code>IStatus.OK</code> the application was started * * @author Joerg Sigle * @date 24.06.2012 * @date 20.02.2012 * * @author Andreas Brker * @date 28.06.2006 */ public static IStatus startLocalOfficeApplication(Shell shell, IOfficeApplication officeApplication) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(Shell, officeApplication) begin"); while (true) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): while (true) trying to start..."); IStatus status = internalStartApplication(shell, officeApplication); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): returned from trying to start."); if (status == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status=" + status.toString()); if (status.getSeverity() == IStatus.ERROR) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): WARNING: status.getSeverity()==IStatus.ERROR"); if (MessageDialog.openQuestion(shell, Messages.NOAUIPlugin_dialog_change_preferences_title, Messages.NOAUIPlugin_dialog_change_preferences_message)) { PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell, LocalOfficeApplicationPreferencesPage.PAGE_ID, null, null); if (preferenceDialog.open() == Window.CANCEL) return Status.CANCEL_STATUS; else continue; } } else System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: !status.getSeverity()==IStatus.ERROR"); try { //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: internalStartApplication(2): getting officeHome (WARNING: probably from the wrong source)..."); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): getting officeHome..."); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): Using js mod adopted for Elexis, reproducing prior GW adoptions, P_OOBASEDIR via ...(Hub.localCfg)"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //String officeHome = getDefault().getPreferenceStore().getString(PREFERENCE_OFFICE_HOME); //Newly inserted lines: IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHome = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); if (officeHome == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): WARNING: officeHome==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): officeHome=" + officeHome); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying to get preventTermination setting..."); //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: WARNING: THIS PROBABLY REFERENCES THE WRONG PREFERENCE STORE. SEE LocalPreferences...GWeirich/JS mods"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //boolean preventTermination = getDefault().getPreferenceStore().getBoolean(PREFERENCE_PREVENT_TERMINATION); //Newly inserted lines: //Already declared further above: IPreferenceStore preferenceStore = new SettingsPreferenceStore(Hub.localCfg); boolean preventTermination = preferenceStore.getBoolean(PREFS_PREVENT_TERMINATION); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): got preventTermination setting=" + preventTermination); if (preventTermination) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying officeApplication.getDesktopService().activateTerminationPrevention()..."); officeApplication.getDesktopService().activateTerminationPrevention(); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: officeApplication.getDesktopService().activateTerminationPrevention()"); } } catch (OfficeApplicationException officeApplicationException) { //no prevention System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): FAILED: preventTermination could NOT be set."); } System.out.println("NOAUIPlugin: startLocalOfficeApplication(2) end, returning status"); return status; } }
From source file:ar.com.tadp.prolog.core.completion.PrologCompletionProposal.java
License:Open Source License
@Override protected boolean insertCompletion() { final IPreferenceStore preference = PrologCorePlugin.getDefault().getPreferenceStore(); return preference.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION); }
From source file:at.spardat.xma.gui.projectw.XMAProjectCreationWizzard.java
License:Open Source License
private void adjustSrcBinDirSettings() { if (srcBinSrcName != null) return;// w ww. j a va2s. c o m IPreferenceStore store = PreferenceConstants.getPreferenceStore(); srcBinFolderInNewProject = store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ); srcBinSrcName = store.getString(PreferenceConstants.SRCBIN_SRCNAME); srcBinBinName = store.getString(PreferenceConstants.SRCBIN_BINNAME); store.setValue(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ, true); store.setValue(PreferenceConstants.SRCBIN_SRCNAME, "src"); store.setValue(PreferenceConstants.SRCBIN_BINNAME, "classes"); }
From source file:au.gov.ga.earthsci.eclipse.extras.ide.ChooseWorkspaceData.java
License:Open Source License
/** * Look in the config area preference store for the list of recently used * workspaces.// w ww .j av a2 s.c o m * * NOTE: During the transition phase the file will be checked if no config * preferences are found. * * @return true if the values were successfully retrieved and false * otherwise */ public boolean readPersistedData() { IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, Activator.PLUGIN_ID); // The old way was to store this information in a file, the new is to // use the configuration area preference store. To help users with the // transition, this code always looks for values in the preference // store; they are used if found. If there aren't any related // preferences, then the file method is used instead. This class always // writes to the preference store, so the fall-back should be needed no // more than once per-user, per-configuration. // This code always sets the value of the protocol to a non-zero value // (currently at 2). If the value comes back as the default (0), then // none of the preferences were set, revert to the file method. int protocol = store.getInt(IDE.Preferences.RECENT_WORKSPACES_PROTOCOL); if (protocol == IPreferenceStore.INT_DEFAULT_DEFAULT && readPersistedData_file()) { return true; } // 2. get value for showDialog showDialog = store.getBoolean(IDE.Preferences.SHOW_WORKSPACE_SELECTION_DIALOG); // 3. use value of numRecent to create proper length array int max = store.getInt(IDE.Preferences.MAX_RECENT_WORKSPACES); max = Math.max(max, RECENT_MAX_LENGTH); // 4. load values of recent workspaces into array String workspacePathPref = store.getString(IDE.Preferences.RECENT_WORKSPACES); recentWorkspaces = decodeStoredWorkspacePaths(protocol, max, workspacePathPref); return true; }
From source file:autosave.AutoSaveActivator.java
License:Apache License
/** * *//*from w ww . ja v a2 s . c o m*/ public void registerListener() { final IPreferenceStore store = AutoSaveActivator.getDefault().getPreferenceStore(); final boolean isEnabled = store.getBoolean(AutoSavePreferencePage.ENABLED); if (isEnabled) { getWorkbench().addWindowListener(new IWindowListener() { @Override public void windowActivated(final IWorkbenchWindow window) { } @Override public void windowClosed(final IWorkbenchWindow window) { } @Override public void windowDeactivated(final IWorkbenchWindow window) { final boolean isEnabled = store.getBoolean(AutoSavePreferencePage.ENABLED); if (isEnabled) { try { if (!triggeredSave.getAndSet(true)) { PlatformUI.getWorkbench().saveAllEditors(false); triggeredSave.set(false); } } catch (final Throwable e) { // do not save again, and catch throwable cause of SWTErrors triggeredSave.set(true); } } } @Override public void windowOpened(final IWorkbenchWindow window) { } }); } }
From source file:bndtools.editor.contents.ExportPatternsListPart.java
License:Open Source License
@Override protected void doAddClauses(Collection<? extends ExportedPackage> pkgs, int index, boolean select) { Map<String, File> missingPkgInfoDirs; try {// ww w . j a v a 2s . c o m missingPkgInfoDirs = findSourcePackagesWithoutPackageInfo(pkgs); } catch (Exception e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error finding source package for exported 1packages.", e)); missingPkgInfoDirs = Collections.emptyMap(); } Collection<File> generatePkgInfoDirs = new ArrayList<File>(missingPkgInfoDirs.size()); IPreferenceStore store = Plugin.getDefault().getPreferenceStore(); boolean noAskPackageInfo = store.getBoolean(Plugin.PREF_NOASK_PACKAGEINFO); if (noAskPackageInfo || missingPkgInfoDirs.isEmpty()) { generatePkgInfoDirs.addAll(missingPkgInfoDirs.values()); } else { PackageInfoDialog dlg = new PackageInfoDialog(getSection().getShell(), missingPkgInfoDirs); if (dlg.open() == Window.CANCEL) return; store.setValue(Plugin.PREF_NOASK_PACKAGEINFO, dlg.isDontAsk()); generatePkgInfoDirs.addAll(dlg.getSelectedPackageDirs()); } try { generatePackageInfos(generatePkgInfoDirs); } catch (CoreException e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error generated packageinfo files.", e)); } // Actually add the new exports super.doAddClauses(pkgs, index, select); }
From source file:ca.mcgill.cs.swevo.ppa.ui.PPAJavaProjectHelper.java
License:Open Source License
private List getDefaultClassPath(IJavaProject jproj) { List list = new ArrayList(); IResource srcFolder;//from w w w. jav a2 s. c o m IPreferenceStore store = PreferenceConstants.getPreferenceStore(); String sourceFolderName = store.getString(PreferenceConstants.SRCBIN_SRCNAME); if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ) && sourceFolderName.length() > 0) { srcFolder = jproj.getProject().getFolder(sourceFolderName); } else { srcFolder = jproj.getProject(); } list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder)); IClasspathEntry[] jreEntries = PreferenceConstants.getDefaultJRELibrary(); list.addAll(getExistingEntries(jreEntries)); return list; }
From source file:ca.uvic.chisel.javasketch.ui.internal.preferences.SketchPluginPreferenceInitializer.java
License:Open Source License
@Override public void initializeDefaultPreferences() { IPreferenceStore store = SketchPlugin.getDefault().getPreferenceStore(); store.setDefault(ISketchPluginPreferences.COMPACT_LOOPS_PREFERENCE, true); store.setDefault(ISketchPluginPreferences.DISPLAY_GROUPS_PREFERENCE, true); store.setDefault(SketchUI.PREFERENCE_FILTER_PACKAGE_EXPLORER, true); //in previous versions, the package explorer filter was off by default //we want to turn it on. store.setDefault("preference.packageExplore.update", false); if (!store.getBoolean("preference.packageExplore.update")) { store.setValue("preference.packageExplore.update", true); store.setValue(SketchUI.PREFERENCE_FILTER_PACKAGE_EXPLORER, true); }// w w w . j a va 2 s . com }
From source file:ca.uvic.chisel.javasketch.ui.internal.presentation.ASTMessageGrouper.java
License:Open Source License
@Override public IMessageGrouping[] calculateGroups(UMLSequenceViewer viewer, Object activationElement, Object[] children) {/*from ww w.j a v a2 s . c o m*/ // if (true) { // return calculateGroups2(viewer, activationElement, children); // } HashMap<ASTMessageGroupingTree, ASTMessageGrouping> groups = new HashMap<ASTMessageGroupingTree, ASTMessageGrouping>(); IPreferenceStore store = SketchPlugin.getDefault().getPreferenceStore(); LinkedList<ASTMessageGroupingTree> unusedLoops = new LinkedList<ASTMessageGroupingTree>(); LinkedList<ASTMessageGroupingTree> unusedGroups = new LinkedList<ASTMessageGroupingTree>(); boolean compactLoops = store.getBoolean(ISketchPluginPreferences.COMPACT_LOOPS_PREFERENCE); boolean useCombinedFragments = store.getBoolean(ISketchPluginPreferences.DISPLAY_GROUPS_PREFERENCE); if (!useCombinedFragments) { return new IMessageGrouping[0]; } if (activationElement instanceof IActivation) { IActivation parent = (IActivation) activationElement; IProgramSketch sketch = SketchPlugin.getDefault().getSketch(parent); if (sketch != null) { PresentationData pd = PresentationData.connect(sketch); if (pd != null) { try { ASTMessageGroupingTree tree = pd.getGroups(parent); if (tree == null) { return new IMessageGrouping[0]; } //search through the tree to find all loops if (compactLoops) { unusedGroups.add(tree); while (unusedGroups.size() > 0) { ASTMessageGroupingTree node = unusedGroups.removeFirst(); if (pd.isGroupVisible(parent, node)) { if (node.isLoop()) { unusedLoops.add(node); } for (ASTMessageGroupingTree child : node.getChildren()) { unusedGroups.add(child); } } } } for (int i = 0; i < children.length; i++) { Object child = children[i]; if (child instanceof IMessage) { ASTMessageGroupingTree node = tree.getMessageContainer((IMessage) child); //put in the node and all of its parents. while (node != null && node.getParent() != null) { ASTMessageGrouping grouping = groups.get(node); if (grouping == null) { // if (compactLoops && node.isLoop()) { grouping = new ASTMessageGrouping(activationElement, node); grouping.setOffset(i); groups.put(node, grouping); // } else if (useCombinedFragments && !node.isLoop()) { // grouping = new ASTMessageGrouping(activationElement, node); // grouping.setOffset(i); // groups.put(node, grouping); // } } if (grouping != null) { grouping.setLength(i - grouping.getOffset() + 1); } node = node.getParent(); } } } } finally { pd.disconnect(); } } } } for (ASTMessageGroupingTree node : groups.keySet()) { updateGrouping(groups.get(node), node.getNode()); } ASTMessageGrouping[] result = groups.values().toArray(new ASTMessageGrouping[groups.values().size()]); Arrays.sort(result); return result; }