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:org.deved.antlride.common.ui.text.folding.AntlrAbstractFoldingStructureProvider.java

License:Open Source License

protected void initializePreferences(IPreferenceStore store) {
    fBlockLinesMin = store.getInt(PreferenceConstants.EDITOR_FOLDING_LINES_LIMIT);

    fDocsFolding = store.getBoolean(PreferenceConstants.EDITOR_DOCS_FOLDING_ENABLED);

    fCommentsFolding = store.getBoolean(PreferenceConstants.EDITOR_COMMENTS_FOLDING_ENABLED);

    fFoldNewLines = store.getBoolean(PreferenceConstants.EDITOR_COMMENT_FOLDING_JOIN_NEWLINES);

    fInitCollapseComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INIT_COMMENTS);

    fInitCollapseHeaderComments = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INIT_HEADER_COMMENTS);

    fInitCollapseDocs = store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INIT_DOCS);

    fInitCollapseClasses = store.getBoolean(getInitiallyFoldClassesKey());
    fInitCollapseMethods = store.getBoolean(getInitiallyFoldMethodsKey());
}

From source file:org.drools.eclipse.preferences.DroolsPreferencePage.java

License:Apache License

private void initializeValues() {
    IPreferenceStore store = getPreferenceStore();
    buildAllCheckBox.setSelection(store.getBoolean(IDroolsConstants.BUILD_ALL));
    collapseEditorCheckBox.setSelection(store.getBoolean(IDroolsConstants.EDITOR_FOLDING));
    cacheParsedRulesCheckBox.setSelection(store.getBoolean(IDroolsConstants.CACHE_PARSED_RULES));
    String skin = store.getString(IDroolsConstants.SKIN);
    int index = 0;
    if ("BPMN".equals(skin)) {
        index = 1;//from www  .  j av  a 2 s . co  m
    }
    if ("BPMN2".equals(skin)) {
        index = 2;
    }
    processSkinCombo.select(index);
    allowNodeCustomizationCheckBox.setSelection(store.getBoolean(IDroolsConstants.ALLOW_NODE_CUSTOMIZATION));
    internalAPICombo.select(store.getInt(IDroolsConstants.INTERNAL_API));
}

From source file:org.drools.eclipse.task.preferences.DroolsTaskPreferencePage.java

License:Apache License

private void initializeValues() {
    IPreferenceStore store = getPreferenceStore();
    ipAddressText.setText(store.getString(DroolsTaskConstants.SERVER_IP_ADDRESS));
    portText.setText(store.getInt(DroolsTaskConstants.SERVER_PORT) + "");
    languageText.setText(store.getString(DroolsTaskConstants.LANGUAGE));
}

From source file:org.drools.eclipse.task.views.TaskView.java

License:Apache License

public TaskView() {
    IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
    ipAddress = preferenceStore.getString(DroolsTaskConstants.SERVER_IP_ADDRESS);
    port = preferenceStore.getInt(DroolsTaskConstants.SERVER_PORT);
    language = preferenceStore.getString(DroolsTaskConstants.LANGUAGE);
    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (DroolsTaskConstants.SERVER_IP_ADDRESS.equals(event.getProperty())) {
                ipAddress = (String) event.getNewValue();
            } else if (DroolsTaskConstants.SERVER_PORT.equals(event.getProperty())) {
                port = (Integer) event.getNewValue();
            } else if (DroolsTaskConstants.LANGUAGE.equals(event.getProperty())) {
                language = (String) event.getNewValue();
            }//w w  w . ja v a 2 s.  c o m
        }
    });
}

From source file:org.ebayopensource.vjet.eclipse.core.test.ui.VjoAutoEditorStrategyTester.java

License:Open Source License

public void testBug2512() throws Exception {
    String js = "autoEdit/indentTest2512";

    FixtureManager m_fixtureManager = FixtureUtils.setUpFixture(this, js + ".js");
    IFile file = ResourcesPlugin.getWorkspace().getRoot()
            .getFile(new Path(getProjectName() + "/src/" + js + ".js"));

    VjoEditor editor = (VjoEditor) IDE/*ww  w  .ja v  a  2  s  .  c  o  m*/
            .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);

    try {
        IPreferenceStore store = VjetUIPlugin.getDefault().getPreferenceStore();
        testTabSize(store.getInt(CodeFormatterConstants.FORMATTER_TAB_SIZE), editor);
        store.setValue(CodeFormatterConstants.FORMATTER_TAB_SIZE, 10);
        testTabSize(10, editor);

    } finally {
        FixtureUtils.tearDownFixture(m_fixtureManager);
    }

}

From source file:org.eclipse.andmore.ddms.DdmsPlugin.java

License:Apache License

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);

    final Display display = getDisplay();

    // get the eclipse store
    final IPreferenceStore eclipseStore = getPreferenceStore();

    AndroidDebugBridge.addDeviceChangeListener(this);

    DdmUiPreferences.setStore(eclipseStore);

    // DdmUiPreferences.displayCharts();

    // set the consoles.
    mDdmsConsole = new MessageConsole("DDMS", null); //$NON-NLS-1$
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { mDdmsConsole });

    final MessageConsoleStream consoleStream = mDdmsConsole.newMessageStream();
    final MessageConsoleStream errorConsoleStream = mDdmsConsole.newMessageStream();
    mRed = new Color(display, 0xFF, 0x00, 0x00);

    // because this can be run, in some cases, by a non UI thread, and
    // because/* ww  w  .  j  a v  a  2s  .c o  m*/
    // changing the console properties update the UI, we need to make this
    // change
    // in the UI thread.
    display.asyncExec(new Runnable() {
        @Override
        public void run() {
            errorConsoleStream.setColor(mRed);
        }
    });

    // set up the ddms log to use the ddms console.
    Log.setLogOutput(new ILogOutput() {
        @Override
        public void printLog(LogLevel logLevel, String tag, String message) {
            if (logLevel.getPriority() >= LogLevel.ERROR.getPriority()) {
                printToStream(errorConsoleStream, tag, message);
                showConsoleView(mDdmsConsole);
            } else {
                printToStream(consoleStream, tag, message);
            }
        }

        @Override
        public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) {
            printLog(logLevel, tag, message);
            // dialog box only run in UI thread..
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    Shell shell = display.getActiveShell();
                    if (logLevel == LogLevel.ERROR) {
                        MessageDialog.openError(shell, tag, message);
                    } else {
                        MessageDialog.openWarning(shell, tag, message);
                    }
                }
            });
        }

    });

    // set up the ddms console to use this objects
    DdmConsole.setConsole(new IDdmConsole() {
        @Override
        public void printErrorToConsole(String message) {
            printToStream(errorConsoleStream, null, message);
            showConsoleView(mDdmsConsole);
        }

        @Override
        public void printErrorToConsole(String[] messages) {
            for (String m : messages) {
                printToStream(errorConsoleStream, null, m);
            }
            showConsoleView(mDdmsConsole);
        }

        @Override
        public void printToConsole(String message) {
            printToStream(consoleStream, null, message);
        }

        @Override
        public void printToConsole(String[] messages) {
            for (String m : messages) {
                printToStream(consoleStream, null, m);
            }
        }
    });

    // set the listener for the preference change
    eclipseStore.addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            // get the name of the property that changed.
            String property = event.getProperty();

            if (PreferenceInitializer.ATTR_DEBUG_PORT_BASE.equals(property)) {
                DdmPreferences
                        .setDebugPortBase(eclipseStore.getInt(PreferenceInitializer.ATTR_DEBUG_PORT_BASE));
            } else if (PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT.equals(property)) {
                DdmPreferences.setSelectedDebugPort(
                        eclipseStore.getInt(PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT));
            } else if (PreferenceInitializer.ATTR_THREAD_INTERVAL.equals(property)) {
                DdmUiPreferences.setThreadRefreshInterval(
                        eclipseStore.getInt(PreferenceInitializer.ATTR_THREAD_INTERVAL));
            } else if (PreferenceInitializer.ATTR_LOG_LEVEL.equals(property)) {
                DdmPreferences.setLogLevel(eclipseStore.getString(PreferenceInitializer.ATTR_LOG_LEVEL));
            } else if (PreferenceInitializer.ATTR_TIME_OUT.equals(property)) {
                DdmPreferences.setTimeOut(eclipseStore.getInt(PreferenceInitializer.ATTR_TIME_OUT));
            } else if (PreferenceInitializer.ATTR_USE_ADBHOST.equals(property)) {
                DdmPreferences.setUseAdbHost(eclipseStore.getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST));
            } else if (PreferenceInitializer.ATTR_ADBHOST_VALUE.equals(property)) {
                DdmPreferences
                        .setAdbHostValue(eclipseStore.getString(PreferenceInitializer.ATTR_ADBHOST_VALUE));
            }
        }
    });

    // do some last initializations

    // set the preferences.
    PreferenceInitializer.setupPreferences();

    // this class is set as the main source revealer and will look at all
    // the implementations
    // of the extension point. see #reveal(String, String, int)
    StackTracePanel.setSourceRevealer(this);

    /*
     * Load the extension point implementations. The first step is to load
     * the IConfigurationElement representing the implementations. The 2nd
     * step is to use these objects to instantiate the implementation
     * classes.
     * 
     * Because the 2nd step will trigger loading the plug-ins providing the
     * implementations, and those plug-ins could access DDMS classes (like
     * ADT), this 2nd step should be done in a Job to ensure that DDMS is
     * loaded, so that the other plug-ins can load.
     * 
     * Both steps could be done in the 2nd step but some of DDMS UI rely on
     * knowing if there is an implementation or not (DeviceView), so we do
     * the first steps in start() and, in some case, record it.
     */

    // get the IConfigurationElement for the debuggerConnector right away.
    final IConfigurationElement[] dcce = findConfigElements("org.eclipse.andmore.ddms.debuggerConnector"); //$NON-NLS-1$
    mHasDebuggerConnectors = dcce.length > 0;

    // get the other configElements and instantiante them in a Job.
    new Job(Messages.DdmsPlugin_DDMS_Post_Create_Init) {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // init the lib
                AndroidDebugBridge.init(true /* debugger support */);

                // get the available adb locators
                IConfigurationElement[] elements = findConfigElements("org.eclipse.andmore.ddms.toolsLocator"); //$NON-NLS-1$

                IToolsLocator[] locators = instantiateToolsLocators(elements);

                for (IToolsLocator locator : locators) {
                    try {
                        String adbLocation = locator.getAdbLocation();
                        String traceviewLocation = locator.getTraceViewLocation();
                        String hprofConvLocation = locator.getHprofConvLocation();
                        if (adbLocation != null && traceviewLocation != null && hprofConvLocation != null) {
                            // checks if the location is valid.
                            if (setToolsLocation(adbLocation, hprofConvLocation, traceviewLocation)) {

                                AndroidDebugBridge.createBridge(sAdbLocation, true /* forceNewBridge */);

                                // no need to look at the other locators.
                                break;
                            }
                        }
                    } catch (Throwable t) {
                        // ignore, we'll just not use this implementation.
                    }
                }

                // get the available debugger connectors
                mDebuggerConnectors = instantiateDebuggerConnectors(dcce);

                // get the available Traceview Launchers.
                elements = findConfigElements("org.eclipse.andmore.ddms.traceviewLauncher"); //$NON-NLS-1$
                mTraceviewLaunchers = instantiateTraceviewLauncher(elements);

                return Status.OK_STATUS;
            } catch (CoreException e) {
                return e.getStatus();
            }
        }
    }.schedule();
}

From source file:org.eclipse.andmore.internal.sdk.Sdk.java

License:Open Source License

/**
 * Tries to fix all currently open Android legacy editors.
 * <p/>//from  www  . j ava 2  s  . com
 * If an editor is found to match one of the legacy ids, we'll try to close it.
 * If that succeeds, we try to reopen it using the new common editor ID.
 * <p/>
 * This method must be run from the UI thread.
 */
private void fixOpenLegacyEditors() {

    AndmoreAndroidPlugin adt = AndmoreAndroidPlugin.getDefault();
    if (adt == null) {
        return;
    }

    final IPreferenceStore store = adt.getPreferenceStore();
    int currentValue = store.getInt(AdtPrefs.PREFS_FIX_LEGACY_EDITORS);
    // The target version we're comparing to. This must be incremented each time
    // we change the processing here so that a new version of the plugin would
    // try to fix existing editors.
    final int targetValue = 1;

    if (currentValue >= targetValue) {
        return;
    }

    // To be able to close and open editors we need to make sure this is done
    // in the UI thread, which this isn't invoked from.
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            HashSet<String> legacyIds = new HashSet<String>(Arrays.asList(CommonXmlEditor.LEGACY_EDITOR_IDS));

            for (IWorkbenchWindow win : PlatformUI.getWorkbench().getWorkbenchWindows()) {
                for (IWorkbenchPage page : win.getPages()) {
                    for (IEditorReference ref : page.getEditorReferences()) {
                        try {
                            IEditorInput input = ref.getEditorInput();
                            if (input instanceof IFileEditorInput) {
                                IFile file = ((IFileEditorInput) input).getFile();
                                IEditorPart part = ref.getEditor(true /*restore*/);
                                if (part != null) {
                                    IWorkbenchPartSite site = part.getSite();
                                    if (site != null) {
                                        String id = site.getId();
                                        if (legacyIds.contains(id)) {
                                            // This editor matches one of legacy editor IDs.
                                            fixEditor(page, part, input, file, id);
                                        }
                                    }
                                }
                            }
                        } catch (Exception e) {
                            // ignore
                        }
                    }
                }
            }

            // Remember that we managed to do fix all editors
            store.setValue(AdtPrefs.PREFS_FIX_LEGACY_EDITORS, targetValue);
        }

        private void fixEditor(IWorkbenchPage page, IEditorPart part, IEditorInput input, IFile file,
                String id) {
            IDE.setDefaultEditor(file, CommonXmlEditor.ID);

            boolean ok = page.closeEditor(part, true /*save*/);

            AndmoreAndroidPlugin.log(IStatus.INFO, "Closed legacy editor ID %s for %s: %s", //$NON-NLS-1$
                    id, file.getFullPath(), ok ? "Success" : "Failed");//$NON-NLS-1$ //$NON-NLS-2$

            if (ok) {
                // Try to reopen it with the new ID
                try {
                    page.openEditor(input, CommonXmlEditor.ID);
                } catch (PartInitException e) {
                    AndmoreAndroidPlugin.log(e, "Failed to reopen %s", //$NON-NLS-1$
                            file.getFullPath());
                }
            }
        }
    });
}

From source file:org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormatter.java

License:Open Source License

/**
 * Creates a string that represents one indent (can be spaces or tabs..)
 * /*from  w w w. j a  v  a 2 s  .co m*/
 * @return one indentation
 */
public static StringBuffer createIndent() {
    StringBuffer oneIndent = new StringBuffer();
    IPreferenceStore pluginPrefs = AntUIPlugin.getDefault().getPreferenceStore();
    pluginPrefs.getBoolean(AntEditorPreferenceConstants.FORMATTER_TAB_CHAR);

    if (!pluginPrefs.getBoolean(AntEditorPreferenceConstants.FORMATTER_TAB_CHAR)) {
        int tabLen = pluginPrefs.getInt(AntEditorPreferenceConstants.FORMATTER_TAB_SIZE);
        for (int i = 0; i < tabLen; i++) {
            oneIndent.append(' ');
        }
    } else {
        oneIndent.append('\t'); // default
    }

    return oneIndent;
}

From source file:org.eclipse.babel.editor.preferences.ReportingPrefPage.java

License:Open Source License

/**
 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
 *//*  ww w. j a va2s  .  c o  m*/
protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    new Label(composite, SWT.NONE).setText(Messages.prefs_perform_intro1);
    new Label(composite, SWT.NONE).setText(Messages.prefs_perform_intro2);
    new Label(composite, SWT.NONE).setText(" "); //$NON-NLS-1$

    // Report missing values?
    field = createFieldComposite(composite);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    field.setLayoutData(gridData);
    new Label(field, SWT.NONE).setText(Messages.prefs_perform_missingVals);
    reportMissingVals = new Combo(field, SWT.READ_ONLY);
    populateCombo(reportMissingVals, prefs.getInt(MsgEditorPreferences.REPORT_MISSING_VALUES_LEVEL));
    // reportMissingVals.setSelection(
    // prefs.getBoolean(MsgEditorPreferences.REPORT_MISSING_VALUES));

    // Report duplicate values?
    field = createFieldComposite(composite);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    field.setLayoutData(gridData);
    new Label(field, SWT.NONE).setText(Messages.prefs_perform_duplVals);
    reportDuplVals = new Combo(field, SWT.READ_ONLY);
    populateCombo(reportDuplVals, prefs.getInt(MsgEditorPreferences.REPORT_DUPL_VALUES_LEVEL));

    // Report similar values?
    field = createFieldComposite(composite);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    field.setLayoutData(gridData);

    new Label(field, SWT.NONE).setText(Messages.prefs_perform_simVals);
    reportSimVals = new Combo(field, SWT.READ_ONLY);
    populateCombo(reportSimVals, prefs.getInt(MsgEditorPreferences.REPORT_SIM_VALUES_LEVEL));
    reportSimVals.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });

    Composite simValModeGroup = new Composite(composite, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = indentPixels;
    gridLayout.marginHeight = 0;
    gridLayout.verticalSpacing = 0;
    simValModeGroup.setLayout(gridLayout);

    // Report similar values: word count
    reportSimValsMode[0] = new Button(simValModeGroup, SWT.RADIO);
    reportSimValsMode[0].setSelection(prefs.getBoolean(MsgEditorPreferences.REPORT_SIM_VALUES_WORD_COMPARE));
    new Label(simValModeGroup, SWT.NONE).setText(Messages.prefs_perform_simVals_wordCount);

    // Report similar values: Levensthein
    reportSimValsMode[1] = new Button(simValModeGroup, SWT.RADIO);
    reportSimValsMode[1].setSelection(prefs.getBoolean(MsgEditorPreferences.REPORT_SIM_VALUES_LEVENSTHEIN));
    new Label(simValModeGroup, SWT.NONE).setText(Messages.prefs_perform_simVals_levensthein);

    // Report similar values: precision level
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(Messages.prefs_perform_simVals_precision);
    reportSimPrecision = new Text(field, SWT.BORDER);
    reportSimPrecision.setText(prefs.getString(MsgEditorPreferences.REPORT_SIM_VALUES_PRECISION));
    reportSimPrecision.setTextLimit(6);
    setWidthInChars(reportSimPrecision, 6);
    reportSimPrecision.addKeyListener(
            new DoubleTextValidatorKeyListener(Messages.prefs_perform_simVals_precision_error, 0, 1));

    refreshEnabledStatuses();

    return composite;
}

From source file:org.eclipse.birt.chart.ui.swt.fieldassist.FieldAssistHelper.java

License:Open Source License

private int getMarginWidth() {
    IPreferenceStore store = getPreferenceStore();
    return store.getInt(PreferenceConstants.PREF_DECORATOR_MARGINWIDTH);
}