Example usage for org.eclipse.jface.preference IPreferenceStore getInt

List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getInt.

Prototype

int getInt(String name);

Source Link

Document

Returns the current value of the integer-valued preference with the given name.

Usage

From source file:com.rcpcompany.uibindings.extests.manager.AbstractPreferenceStoreIntTest.java

License:Open Source License

/**
 * Tests for {@link IManager#getE()}.//w  w  w.  j a v  a 2s . c  o  m
 */
@Test
public void testGet() {
    assertNoLog(new Runnable() {
        @Override
        public void run() {
            final IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
            assertNotNull(ps);

            final int value = ps.getInt(getPreferenceName());
            assertEquals(getDefault(), value);
            assertEquals(getDefault(), m.eGet(getFeature()));

            ps.setValue(getPreferenceName(), getValues()[1]);

            for (final int s : getValues()) {
                testPS2M(s);
            }
            ps.setValue(getPreferenceName(), getDefault());
        }
    });
}

From source file:com.rcpcompany.uibindings.extests.manager.AbstractPreferenceStoreIntTest.java

License:Open Source License

public void testM2PS(final int newValue) {
    final int oldValue = (Integer) m.eGet(getFeature());
    final TestAdapter adapter = new TestAdapter(oldValue, newValue);

    final IPreferenceStore ps = Activator.getDefault().getPreferenceStore();

    assertNoLog(new Runnable() {
        @Override/* w  w  w . ja v  a2s.com*/
        public void run() {
            m.eAdapters().add(adapter);
            m.eSet(getFeature(), newValue);
            assertEquals(1, adapter.called);
            m.eAdapters().remove(adapter);

        }
    });
    final int s = ps.getInt(getPreferenceName());
    assertEquals(newValue, s);
    assertEquals(newValue, m.eGet(getFeature()));
}

From source file:com.rcpcompany.uibindings.internal.Activator.java

License:Open Source License

protected void updateManagerProperties() {
    final IManager manager = IManager.Factory.getManager();
    final IPreferenceStore preferenceStore = getPreferenceStore();

    Assert.isNotNull(manager);/*from  w w  w .  ja  v a 2  s  .  c  o  m*/

    boolean b;
    int i;
    String s;

    s = preferenceStore.getString(Constants.PREF_TEXT_COMMIT_STRATEGY);
    try {
        final TextCommitStrategy cs = TextCommitStrategy.valueOf(s);
        if (manager.getTextCommitStrategy() != cs) {
            manager.setTextCommitStrategy(cs);
        }
    } catch (final IllegalArgumentException ex) {
        LogUtils.error(this, "Unknown text commit strategy: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    i = preferenceStore.getInt(Constants.PREF_TEXT_COMMIT_STRATEGY_DELAY);
    if (manager.getTextCommitStrategyDelay() != i) {
        manager.setTextCommitStrategyDelay(i);
    }

    b = preferenceStore.getBoolean(Constants.PREF_AUTO_APPLY_QUICKFIX);
    if (manager.isAutoApplySingleQuickfix() != b) {
        manager.setAutoApplySingleQuickfix(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_DELETE_HANDLER_CHECK_ENABLED);
    if (manager.isDeleteHandlerCheckEnabled() != b) {
        manager.setDeleteHandlerCheckEnabled(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_EDIT_CELL_ANY_KEY);
    if (manager.isEditCellAnyKey() != b) {
        manager.setEditCellAnyKey(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_EDIT_CELL_SINGLE_CLICK);
    if (manager.isEditCellSingleClick() != b) {
        manager.setEditCellSingleClick(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_ALTERNATE_ROW_COLORS);
    if (manager.isAlternateRowColors() != b) {
        manager.setAlternateRowColors(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_VALIDATION_ERRORS_ARE_FATAL);
    if (manager.isValidationErrorsAreFatal() != b) {
        manager.setValidationErrorsAreFatal(b);
    }

    s = preferenceStore.getString(Constants.PREF_MESSAGE_DECORATION_POSITION);
    final DecorationPosition mdp = DecorationPosition.get(s);
    if (mdp != null) {
        if (manager.getMessageDecorationPosition() != mdp) {
            manager.setMessageDecorationPosition(mdp);
        }
    } else {
        LogUtils.error(this, "Unknown message decoration position: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    s = preferenceStore.getString(Constants.PREF_MESSAGE_DECORATION_MINIMUM_SEVERITY);
    final BindingMessageSeverity ms = BindingMessageSeverity.get(s);
    if (ms != null) {
        if (manager.getMessageDecorationMinimumSeverity() != ms) {
            manager.setMessageDecorationMinimumSeverity(ms);
        }
    } else {
        LogUtils.error(this, "Unknown message decoration minimum severity: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    s = preferenceStore.getString(Constants.PREF_ALTERNATIVE_DECORATION_POSITION);
    final DecorationPosition adp = DecorationPosition.get(s);
    if (adp != null) {
        if (manager.getAlternativeDecorationPosition() != adp) {
            manager.setAlternativeDecorationPosition(adp);
        }
    } else {
        LogUtils.error(this, "Unknown alternative decoration position: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    i = preferenceStore.getInt(Constants.PREF_VALIDATION_DELAY);
    if (manager.getValidationDelay() != i) {
        manager.setValidationDelay(i);
    }

    i = preferenceStore.getInt(Constants.PREF_VALIDATION_DELAY_WINDOW);
    if (manager.getValidationDelayWindow() != i) {
        manager.setValidationDelayWindow(i);
    }

    b = preferenceStore.getBoolean(Constants.PREF_REQUIRED_VBID_SHOWN);
    if (manager.isRequiredVBImageDecorationShown() != b) {
        manager.setRequiredVBImageDecorationShown(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_QUICKFIX_VBID_SHOWN);
    if (manager.isQuickfixVBImageDecorationShown() != b) {
        manager.setQuickfixVBImageDecorationShown(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_ASSIST_VBID_SHOWN);
    if (manager.isAssistVBImageDecorationShown() != b) {
        manager.setAssistVBImageDecorationShown(b);
    }

    b = preferenceStore.getBoolean(Constants.PREF_VIEW_NAVIGATION_RECORDED);
    if (manager.isViewNavigationRecorded() != b) {
        manager.setViewNavigationRecorded(b);
    }
}

From source file:com.reprezen.swagedit.core.preferences.KaiZenPreferencesUtils.java

License:Open Source License

public static int getTabWidth() {
    IPreferenceStore prefs = org.dadacoalition.yedit.Activator.getDefault().getPreferenceStore();
    return prefs.getInt(PreferenceConstants.SPACES_PER_TAB);
}

From source file:com.safi.workshop.sqlexplorer.preferences.OverlayPreferenceStore.java

License:Open Source License

void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;/*from w w w .j a v a 2  s  . c om*/
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }

}

From source file:com.sap.dirigible.ide.terminal.ui.TerminalView.java

License:Open Source License

private static String executeCommand(String[] args) throws IOException {
    if (args.length <= 0) {
        return "Need command to run";
    }/*  w  ww . ja v a  2  s .  co  m*/

    IPreferenceStore preferenceStore = TerminalPreferencePage.getTerminalPreferenceStore();
    boolean limitEnabled = preferenceStore.getBoolean(TerminalPreferencePage.LIMIT_ENABLED);
    int limitTimeout = preferenceStore.getInt(TerminalPreferencePage.LIMIT_TIMEOUT);

    ProcessBuilder processBuilder = ProcessUtils.createProcess(args);
    ProcessUtils.addEnvironmentVariables(processBuilder, null);
    ProcessUtils.removeEnvironmentVariables(processBuilder, null);
    //processBuilder.directory(new File(workingDirectory));
    processBuilder.redirectErrorStream(true);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Process process = ProcessUtils.startProcess(args, processBuilder);
    Piper pipe = new Piper(process.getInputStream(), out);
    new Thread(pipe).start();
    try {
        //process.waitFor();

        int i = 0;
        boolean deadYet = false;
        do {
            Thread.sleep(ProcessUtils.DEFAULT_WAIT_TIME);
            try {
                process.exitValue();
                deadYet = true;
            } catch (IllegalThreadStateException e) {
                if (limitEnabled) {
                    if (++i >= limitTimeout) {
                        process.destroy();
                        throw new RuntimeException("Exeeds timeout - "
                                + ((ProcessUtils.DEFAULT_WAIT_TIME / 1000) * ProcessUtils.DEFAULT_LOOP_COUNT));
                    }
                }
            }
        } while (!deadYet);

    } catch (Exception e) {
        logger.error(e.getMessage());
        return e.getMessage();
    }
    return new String(out.toByteArray());
}

From source file:com.subgraph.vega.ui.scanner.ScanExecutor.java

License:Open Source License

private String maybeLaunchScanFromWizard(Shell shell, NewScanWizard wizard, IScanner scanner) {
    URI targetURI = wizard.getScanHostURI();
    if (targetURI == null) {
        return null;
    }/*w  ww .  j  a va2 s .  c om*/
    scanner.lock();
    final IScannerConfig config = scanner.createScannerConfig();

    config.setBaseURI(targetURI);
    config.setCookieList(getCookieList(wizard.getCookieStringList(), targetURI));
    config.setBasicUsername(wizard.getBasicUsername());
    config.setBasicPassword(wizard.getBasicPassword());
    config.setBasicRealm(wizard.getBasicRealm());
    config.setBasicDomain(wizard.getBasicDomain());
    config.setExclusions(wizard.getExclusions());
    config.setNtlmUsername(wizard.getNtlmUsername());
    config.setNtlmPassword(wizard.getNtlmPassword());
    final IPreferenceStore preferences = Activator.getDefault().getPreferenceStore();
    config.setLogAllRequests(preferences.getBoolean("LogAllRequests"));
    config.setDisplayDebugOutput(preferences.getBoolean("DisplayDebugOutput"));
    config.setMaxRequestsPerSecond(preferences.getInt("MaxRequestsPerSecond"));
    config.setMaxDescendants(preferences.getInt("MaxScanDescendants"));
    config.setMaxChildren(preferences.getInt("MaxScanChildren"));
    config.setMaxDepth(preferences.getInt("MaxScanDepth"));
    config.setMaxDuplicatePaths(preferences.getInt("MaxScanDuplicatePaths"));
    config.setMaxResponseKilobytes(preferences.getInt("MaxResponseLength"));

    final Thread probeThread = new Thread(new ScanProbeTask(shell, targetURI, scanner, config));
    probeThread.start();
    return wizard.getTargetField();
}

From source file:com.sureassert.uc.SaUCPreferencePage.java

License:Open Source License

/**
 * Initializes states of the controls from the preference store.
 *//*ww w  .jav a  2s. c o  m*/
private void initializeValues() {

    IPreferenceStore store = getPreferenceStore();
    SaUCPreferences.setDefaults(store);
    runJunitAutomaticallyCheckbox.setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_JUNIT_AUTOMATION));
    junitExcludeFilterText.setText(store.getString(SaUCPreferences.PREF_KEY_JUNIT_EXCLUDE_FILTER));
    calculateCoverageCheckbox.setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_ENABLED));
    coverageProblemsCheckbox.setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_PROBLEMS_ENABLED));
    coverageProjectDecorationCheckbox
            .setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_PROJECT_DECORATION_ENABLED));
    coverageFileDecorationCheckbox
            .setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_FILE_DECORATION_ENABLED));
    coverageFilePercentCheckbox
            .setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_FILE_PERCENT_ENABLED));
    coverageDisplayEnabledCheckbox
            .setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_COVERAGE_DISPLAY_ENABLED));
    coverageWarnThreshold.setSelection(store.getInt(SaUCPreferences.PREF_KEY_COVERAGE_WARN_THRESHOLD));
    coverageErrorThreshold.setSelection(store.getInt(SaUCPreferences.PREF_KEY_COVERAGE_ERROR_THRESHOLD));
    // coverageRequiredThreshold.setSelection(store.getInt(SaUCPreferences.PREF_KEY_COVERAGE_REQUIRED_THRESHOLD));
    sourceStubsEnabledCheckbox
            .setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_STUBS_ALLOW_SOURCE_STUBS));
    // licenceKeyText.setText(store.getString(SaUCPreferences.PREF_KEY_LICENCE_KEY));
    // licenceEmailText.setText(store.getString(SaUCPreferences.PREF_KEY_LICENCE_EMAIL));
    // execConcurrentCheckbox.setSelection(store.getBoolean(SaUCPreferences.PREF_KEY_EXEC_CONCURRENT));

    rationalizeControls();
}

From source file:com.tetrade.eclipse.plugins.easyshell.preferences.EasyShellPreferencePage.java

License:Open Source License

/**
 * Creates the field editors. Field editors are abstractions of
 * the common GUI blocks needed to manipulate various types
 * of preferences. Each field editor knows how to save and
 * restore itself./*from   w w w  . j  a v a 2s .co m*/
 */
protected Control createContents(Composite parent) {

    IPreferenceStore store = getPreferenceStore();

    Composite mainColumn = new Composite(parent, SWT.NONE);
    GridLayout mainLayout = new GridLayout(1, false);
    mainColumn.setFont(parent.getFont());
    mainColumn.setLayout(mainLayout);

    Composite targetColumn = new Composite(mainColumn, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    targetColumn.setFont(parent.getFont());
    targetColumn.setLayout(layout);

    Label label = new Label(targetColumn, 0);
    label.setText("Presets");

    targetCombo = new Combo(targetColumn, SWT.READ_ONLY | SWT.DROP_DOWN);
    for (int i = 0; i < cmdLabels.length; i++) {
        targetCombo.add(cmdLabels[i]);
    }
    targetCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            refreshTarget();
        }
    });
    targetCombo.select(store.getInt(P_LIST));

    targetOpenEditor = new StringFieldEditor(P_TARGET, "&Shell Open command:", targetColumn);
    if (debug)
        System.out.println("Value: " + store.getString(P_TARGET));
    if (debug)
        System.out.println("Default: " + store.getDefaultString(P_TARGET));
    targetOpenEditor.setStringValue(store.getString(P_TARGET));

    targetRunEditor = new StringFieldEditor(P_TARGET_RUN, "&Shell Run command:", targetColumn);
    if (debug)
        System.out.println("Value: " + store.getString(P_TARGET_RUN));
    if (debug)
        System.out.println("Default: " + store.getDefaultString(P_TARGET_RUN));
    targetRunEditor.setStringValue(store.getString(P_TARGET_RUN));

    targetExploreEditor = new StringFieldEditor(P_TARGET_EXPLORE, "&Explore command:", targetColumn);
    if (debug)
        System.out.println("Value: " + store.getString(P_TARGET_EXPLORE));
    if (debug)
        System.out.println("Default: " + store.getDefaultString(P_TARGET_EXPLORE));
    targetExploreEditor.setStringValue(store.getString(P_TARGET_EXPLORE));

    targetCopyPathEditor = new StringFieldEditor(P_TARGET_COPYPATH, "Copy Path string:", targetColumn);
    if (debug)
        System.out.println("Value: " + store.getString(P_TARGET_COPYPATH));
    if (debug)
        System.out.println("Default: " + store.getDefaultString(P_TARGET_COPYPATH));
    targetCopyPathEditor.setStringValue(store.getString(P_TARGET_COPYPATH));

    label = new Label(mainColumn, 0);
    label.setText("Argument {0} is the drive letter on Win32.");
    label = new Label(mainColumn, 0);
    label.setText("Argument {1} is the parent path.");
    label = new Label(mainColumn, 0);
    label.setText("Argument {2} is the full path.");
    label = new Label(mainColumn, 0);
    label.setText("Argument {3} is the file name.");
    label = new Label(mainColumn, 0);
    label.setText("Argument {4} is the project name.");
    label = new Label(mainColumn, 0);
    label.setText("Argument {5} is the line separator.");

    return mainColumn;
}

From source file:com.threecrickets.creel.eclipse.Builder.java

License:LGPL

/**
 * Creates and configures a Creel engine using plugin preferences and
 * folders.//from   www .  j a  v a  2  s . c  o  m
 * 
 * @param project
 *        The project
 * @param folders
 *        Map of artifact types to folders
 * @return A Creel engine
 * @throws CoreException
 *         In case of an Eclipse error
 */
public static Engine createEngine(IProject project, Map<Artifact.Type, IContainer> folders)
        throws CoreException {
    IPreferenceStore preferences = Plugin.instance.getPreferenceStore();

    Engine engine = new Engine();
    IOConsole console = EclipseUtil.getConsole("Creel");
    IOConsoleOutputStream stream = console.newOutputStream();
    if (!preferences.getBoolean(PreferencesPage.QUIET))
        ((EventHandlers) engine.getEventHandler()).add(new ConsoleEventHandler(stream, false, false));
    engine.setVerbosity(preferences.getInt(PreferencesPage.VERBOSITY));
    engine.getDirectories().set(toDirectories(folders));

    return engine;
}