List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:org.apache.directory.studio.schemaeditor.view.views.SearchViewSortingDialog.java
License:Apache License
/** * Initializes the fields for the stored preferences. *//* w ww. ja v a 2s . co m*/ private void initFieldsFromPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); int grouping = store.getInt(PluginConstants.PREFS_SEARCH_VIEW_GROUPING); if (grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_ATTRIBUTE_TYPES_FIRST) { attributeTypesFirst.setSelection(true); } else if (grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_OBJECT_CLASSES_FIRST) { objectClassesFirst.setSelection(true); } else if (grouping == PluginConstants.PREFS_SEARCH_VIEW_GROUPING_MIXED) { mixedButton.setSelection(true); } int sortingBy = store.getInt(PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY); if (sortingBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_FIRSTNAME) { sortingCombo.select(0); } else if (sortingBy == PluginConstants.PREFS_SEARCH_VIEW_SORTING_BY_OID) { sortingCombo.select(1); } int sortingOrder = store.getInt(PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER); if (sortingOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_ASCENDING) { ascendingButton.setSelection(true); } else if (sortingOrder == PluginConstants.PREFS_SEARCH_VIEW_SORTING_ORDER_DESCENDING) { descendingButton.setSelection(true); } }
From source file:org.axdt.common.preferences.fields.IntegerField.java
License:Open Source License
public Integer getValue(IPreferenceStore store) { return store.getInt(key); }
From source file:org.bonitasoft.studio.application.BonitaRegistration.java
License:Open Source License
private static void sendUserInfoEncoded(final IPreferenceStore prefStore, final String email, final String data) { if (prefStore.getInt(BonitaRegistration.BONITA_INFO_SENT) != 1 && data != null && data.length() > 0 && email != null && email.length() > 0) { Job job = new Job("Send user infos") { @Override// ww w. jav a 2 s . co m protected IStatus run(IProgressMonitor monitor) { try { // Send data URL url = new URL("http://stats.bonitasoft.org/stats.php"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(email); wr.write(data); wr.flush(); // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { if (line.equals("1")) { prefStore.setValue(BonitaRegistration.BONITA_INFO_SENT, 1); } } wr.close(); rd.close(); } catch (Exception e) { // may not be online saving info for sending it later prefStore.setValue(BonitaRegistration.BONITA_USER_INFOS, data); prefStore.setValue(BonitaRegistration.BONITA_INFO_SENT, 0); return Status.CANCEL_STATUS; } return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); } }
From source file:org.bonitasoft.studio.application.BonitaStudioWorkbenchAdvisor.java
License:Open Source License
private void sendUserInfo() { String noRegister = System.getProperty("bonita.noregister"); //$NON-NLS-1$ if (noRegister == null || !noRegister.equals("1")) { //$NON-NLS-1$ IPreferenceStore prefStore = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore(); int ok = prefStore.getInt(BonitaRegistration.BONITA_USER_REGISTERED); int nbTry = prefStore.getInt(BonitaRegistration.BONITA_USER_REGISTER_TRY); int infoSent = prefStore.getInt(BonitaRegistration.BONITA_INFO_SENT); if (nbTry <= BonitaRegistration.BONITA_USER_REGISTER_MAXTRY) { if (ok != 1) { IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance() .getConfigurationElements("org.bonitasoft.studio.application.registration"); //$NON-NLS-1$ IPostStartupContribution contrib = null; for (IConfigurationElement elem : elements) { try { contrib = (IPostStartupContribution) elem.createExecutableExtension("class"); //$NON-NLS-1$ } catch (CoreException e) { BonitaStudioLog.error(e); }//from w w w.j a va2s . c o m if (contrib != null) { prefStore.setValue(BonitaRegistration.BONITA_USER_REGISTER_TRY, ++nbTry); contrib.execute(); break; } } if (elements.length == 0) { prefStore.setValue(BonitaRegistration.BONITA_USER_REGISTERED, 1); BonitaRegistration.sendUserInfo(prefStore, "bonita_sp"); } } else if (infoSent == 0) { // registered but was offline // try to send data BonitaRegistration.sendUserInfo(prefStore, prefStore.getString(BonitaRegistration.BONITA_USER_MAIL)); } } } }
From source file:org.bonitasoft.studio.application.registration.BonitaRegistration.java
License:Open Source License
protected boolean isDataValidToSend(final IPreferenceStore prefStore, final String email, final String data) { return prefStore.getInt(BonitaRegistration.BONITA_INFO_SENT) != 1 && data != null && data.length() > 0 && email != null && email.length() > 0; }
From source file:org.bonitasoft.studio.properties.sections.appearance.BonitaRulerGridPropertySection.java
License:Open Source License
/** * //from w w w .j a va 2 s . com * Sets up controls with proper layouts and groups * @param parent */ private void initializeControls(Composite parent) { parent.setLayout(new GridLayout(1, false)); // Top row composite Composite topComposite = getWidgetFactory().createComposite(parent); topComposite.setLayout(new GridLayout(2, false)); // Create the groups for this section createDisplayGroup(topComposite); createMeasurementGroup(topComposite); // Bottom row composite Composite bottomComposite = getWidgetFactory().createComposite(parent); bottomComposite.setLayout(new GridLayout(2, false)); // Create grid line settings createGridlineGroup(bottomComposite); Composite extraComposite = getWidgetFactory().createComposite(bottomComposite); extraComposite.setLayout(new GridLayout(1, false)); // Create snap to grid checkbox snapToGridButton = getWidgetFactory().createButton(extraComposite, SNAP_TO_GRID_LABEL, SWT.CHECK); snapToGridButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to grid workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGRID, snapToGridButton.getSelection()); } }); // Create snap to geometry checkbox snapToGeometryButton = getWidgetFactory().createButton(extraComposite, SNAP_TO_GEOMETRY_LABEL, SWT.CHECK); snapToGeometryButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to geometry workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGEOMETRY, snapToGeometryButton.getSelection()); } }); // Create restore to preferences defaults restoreButton = getWidgetFactory().createButton(extraComposite, RESTORE_LABEL, SWT.PUSH); restoreButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { restorePreferenceValues(); } private void restorePreferenceValues() { IPreferenceStore preferenceStore = getPreferenceStore(); // The workspace properties will always exist because it is set // IPreferenceStore wsPrefStore = getWorkspaceViewerProperties(); if (wsPrefStore.getBoolean(WorkspaceViewerProperties.GRIDORDER) == false) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDORDER, true); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINECOLOR) != LIGHT_GRAY_RGB) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINECOLOR, LIGHT_GRAY_RGB); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINESTYLE) != SWT.LINE_SOLID) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINESTYLE, SWT.LINE_SOLID); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWRULERS) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWRULERS, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGEOMETRY) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGEOMETRY, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)); } if ((wsPrefStore.getInt(WorkspaceViewerProperties.RULERUNIT) != preferenceStore .getInt(IPreferenceConstants.PREF_RULER_UNITS)) || (wsPrefStore.getDouble(WorkspaceViewerProperties.GRIDSPACING) != preferenceStore .getDouble(IPreferenceConstants.PREF_GRID_SPACING))) { wsPrefStore.setValue(WorkspaceViewerProperties.RULERUNIT, preferenceStore.getInt(IPreferenceConstants.PREF_RULER_UNITS)); wsPrefStore.setValue(WorkspaceViewerProperties.GRIDSPACING, preferenceStore.getDouble(IPreferenceConstants.PREF_GRID_SPACING)); } // reset the input values setInput(getPart(), null); } }); }
From source file:org.bonitasoft.studio.simulation.commands.RunSimulationHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { if (isEnabled()) { RunSimulationWizard wizard = new RunSimulationWizard(selectedProcess); CustomWizardDialog wizardDialog = new CustomWizardDialog(Display.getCurrent().getActiveShell(), wizard, Messages.run);/*from ww w . j a v a 2s .c om*/ if (wizardDialog.open() == IDialogConstants.OK_ID) { IProgressService progressManager = PlatformUI.getWorkbench().getProgressService(); SimulationWithMonitorRunner runnable = new SimulationWithMonitorRunner(wizard.getSelectedProcess(), wizard.getPath(), wizard.getLoadProfileId(), wizard.getTimespan()); try { progressManager.busyCursorWhile(runnable); if (!runnable.isCancelled() && runnable.getReportFile() != null) { String name = runnable.getReportFile(); IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(name)); if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage(); try { IPreferenceStore webStore = WebBrowserUIPlugin.getInstance().getPreferenceStore(); int oldValue = webStore.getInt("browser-choice"); webStore.setValue("browser-choice", WebBrowserPreference.INTERNAL); IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( IWorkbenchBrowserSupport.AS_EDITOR, "", fileStore.getName(), ""); //$NON-NLS-1$ try { browser.openURL(new URL("file", "", name)); } catch (MalformedURLException e) { BonitaStudioLog.error(e); } webStore.setValue("browser-choice", oldValue); } catch (PartInitException e) { BonitaStudioLog.error(e); } } } } catch (InvocationTargetException e) { BonitaStudioLog.error(e); } catch (InterruptedException e) { BonitaStudioLog.error(e); } } } return null; }
From source file:org.brainwy.liclipsetext.editor.languages.indent.LanguageIndent.java
License:Open Source License
/** * @return the tab width (gets from eclipse preferences if needed). *///ww w . j a v a 2 s . c o m public Integer getTabWidth() { if (tabWidth == null) { try { IPreferenceStore preferenceStore = LiClipseTextPreferences.getChainedPreferenceStore(); return preferenceStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); } catch (Exception e) { return 4; //default } } return tabWidth; }
From source file:org.brainwy.liclipsetext.editor.languages.indent.LanguageIndent.java
License:Open Source License
public static String getDefaultIndentString() { IPreferenceStore preferenceStore = LiClipseTextPreferences.getChainedPreferenceStore(); boolean spacesForTabs = preferenceStore .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS); if (spacesForTabs) { int tabWidth; try {//from w w w . j ava2 s . c o m tabWidth = preferenceStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); } catch (Exception e) { tabWidth = 4; } return new FastStringBuffer(tabWidth).appendN(' ', tabWidth).toString(); } else { return "\t"; } }
From source file:org.brainwy.liclipsetext.shared_core.preferences.ScopedPreferences.java
License:Open Source License
@Override public int getInt(IPreferenceStore pluginPreferenceStore, String keyInPreferenceStore, IAdaptable adaptable) { Object object = getFromProjectOrUserSettings(keyInPreferenceStore, adaptable); if (object != null) { return toInt(object); }/*ww w . jav a 2 s . co m*/ // Ok, not in project or user settings: get it from the workspace settings. return pluginPreferenceStore.getInt(keyInPreferenceStore); }