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

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

Introduction

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

Prototype

String getString(String name);

Source Link

Document

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

Usage

From source file:com.siteview.mde.internal.ui.preferences.MainPreferencePage.java

License:Open Source License

protected Control createContents(Composite parent) {
    IPreferenceStore store = MDEPlugin.getDefault().getPreferenceStore();
    MDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();

    Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
    ((GridLayout) composite.getLayout()).verticalSpacing = 15;
    ((GridLayout) composite.getLayout()).marginTop = 15;

    Composite optionComp = SWTFactory.createComposite(composite, 1, 1, GridData.FILL_HORIZONTAL, 0, 0);

    fOverwriteBuildFiles = new Button(optionComp, SWT.CHECK);
    fOverwriteBuildFiles.setText(MDEUIMessages.MainPreferencePage_promptBeforeOverwrite);
    fOverwriteBuildFiles.setSelection(!MessageDialogWithToggle.ALWAYS
            .equals(store.getString(IPreferenceConstants.OVERWRITE_BUILD_FILES_ON_EXPORT)));

    fAutoManage = new Button(optionComp, SWT.CHECK);
    fAutoManage.setText(MDEUIMessages.MainPreferencePage_updateStale);
    fAutoManage.setSelection(launchingStore.getBoolean(ILaunchingPreferenceConstants.PROP_AUTO_MANAGE));

    fPromptOnRemove = new Button(optionComp, SWT.CHECK);
    fPromptOnRemove.setText(MDEUIMessages.MainPreferencePage_promtBeforeRemove);
    fPromptOnRemove.setSelection(!MessageDialogWithToggle.ALWAYS
            .equals(store.getString(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET)));
    fPromptOnRemove.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            MDEPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.PROP_PROMPT_REMOVE_TARGET,
                    fPromptOnRemove.getSelection() ? MessageDialogWithToggle.PROMPT
                            : MessageDialogWithToggle.ALWAYS);

        }/* w  w w. j av  a 2  s. c  om*/

    });

    fAddToJavaSearch = new Button(optionComp, SWT.CHECK);
    fAddToJavaSearch.setText(MDEUIMessages.MainPreferencePage_addToJavaSearch);
    fAddToJavaSearch.setSelection(store.getBoolean(IPreferenceConstants.ADD_TO_JAVA_SEARCH));

    Group group = SWTFactory.createGroup(composite, MDEUIMessages.Preferences_MainPage_showObjects, 2, 1,
            GridData.FILL_HORIZONTAL);
    fUseID = new Button(group, SWT.RADIO);
    fUseID.setText(MDEUIMessages.Preferences_MainPage_useIds);

    fUseName = new Button(group, SWT.RADIO);
    fUseName.setText(MDEUIMessages.Preferences_MainPage_useFullNames);

    fShowSourceBundles = SWTFactory.createCheckButton(group, MDEUIMessages.MainPreferencePage_showSourceBundles,
            null, store.getBoolean(IPreferenceConstants.PROP_SHOW_SOURCE_BUNDLES), 2);

    if (store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_IDS)) {
        fUseID.setSelection(true);
    } else {
        fUseName.setSelection(true);
    }

    new DefaultRuntimeWorkspaceBlock().createControl(composite);
    fRuntimeWorkspaceLocation
            .setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION));
    boolean runtimeLocationIsContainer = launchingStore
            .getBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER);
    fRuntimeWorkspaceLocationRadio.setSelection(!runtimeLocationIsContainer);
    fRuntimeWorkspacesContainerRadio.setSelection(runtimeLocationIsContainer);

    new DefaultJUnitWorkspaceBlock().createControl(composite);
    fJUnitWorkspaceLocation
            .setText(launchingStore.getString(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION));
    boolean jUnitLocationIsContainer = launchingStore
            .getBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER);
    fJUnitWorkspaceLocationRadio.setSelection(!jUnitLocationIsContainer);
    fJUnitWorkspacesContainerRadio.setSelection(jUnitLocationIsContainer);

    return composite;
}

From source file:com.siteview.mde.internal.ui.wizards.plugin.NewProjectCreationPage.java

License:Open Source License

protected void createProjectTypeGroup(Composite container) {
    Group group = new Group(container, SWT.NONE);
    group.setText(MDEUIMessages.ProjectStructurePage_settings);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/* w w  w .  ja v a  2s. c o  m*/
    group.setLayout(layout);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fJavaButton = createButton(group, SWT.CHECK, 2, 0);
    fJavaButton.setText(MDEUIMessages.ProjectStructurePage_java);
    fJavaButton.setSelection(true);
    fJavaButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean enabled = fJavaButton.getSelection();
            fSourceLabel.setEnabled(enabled);
            fSourceText.setEnabled(enabled);
            fOutputlabel.setEnabled(enabled);
            fOutputText.setEnabled(enabled);
            setPageComplete(validatePage());
        }
    });

    fSourceLabel = createLabel(group, MDEUIMessages.ProjectStructurePage_source);
    fSourceText = createText(group);
    IPreferenceStore store = PreferenceConstants.getPreferenceStore();
    fSourceText.setText(store.getString(PreferenceConstants.SRCBIN_SRCNAME));

    fOutputlabel = createLabel(group, MDEUIMessages.ProjectStructurePage_output);
    fOutputText = createText(group);
    fOutputText.setText(store.getString(PreferenceConstants.SRCBIN_BINNAME));
}

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

License:Open Source License

/**
 * Initializes states of the controls from the preference store.
 *//*ww  w  . j  av a2 s.c om*/
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.svcdelivery.liquibase.eclipse.internal.ui.Activator.java

License:Apache License

private void readPreferences() {
    IPreferenceStore store = getPreferenceStore();
    String defaultVersionString = store.getString(DEFAULT_SERVICE_VERSION);
    if (defaultVersionString != null && defaultVersionString.length() > 0) {
        try {/*  www.j  a v a  2s  .co m*/
            defaultLiquibaseVersion = Version.parseVersion(defaultVersionString);
        } catch (IllegalArgumentException e) {
        }
    }
}

From source file:com.telink.tc32eclipse.core.toolinfo.FindTCDB.java

License:Open Source License

/**
 * Runs TCDB with the given arguments.//from  ww w  . j  av  a  2 s.  c o m
 * <p>
 * The Output of stdout and stderr are merged and returned in a <code>List&lt;String&gt;</code>.
 * If the "use Console" flag is set in the Preferences, the complete output is shown on a
 * Console as well.
 * </p>
 * <p>
 * If the command fails to execute an entry is written to the log and an
 * {@link TCDBException} with the reason is thrown.
 * </p>
 * 
 * @param arguments
 *            <code>List&lt;String&gt;</code> with the arguments
 * @param monitor
 *            <code>IProgressMonitor</code> to cancel the running process.
 * @param forceconsole
 *            If <code>true</code> all output is copied to the console, regardless of the "use
 *            console" flag.
 * @param cwd
 *            <code>IPath</code> with a current working directory or <code>null</code> to use
 *            the default working directory (usually the one defined with the system property
 *            <code>user.dir</code). May not be empty.
 * @param programmerconfig
 *            The TCDB Programmer configuration currently is use. Required for the TCDB
 *            invocation delay value. If <code>null</code> no invocation delay will be done.
 * @return A list of all output lines, or <code>null</code> if the command could not be
 *         launched.
 * @throws TCDBException
 *             when TCDB cannot be started or when TCDB returned an error errors.
 */
public List<String> runCommand(List<String> arglist, IProgressMonitor monitor, boolean forceconsole, IPath cwd,
        ProgrammerConfig programmerconfig) throws TCDBException {

    try {
        monitor.beginTask("Running TCDB", 100);

        // Check if the CWD is valid
        if (cwd != null && cwd.isEmpty()) {
            throw new TCDBException(Reason.INVALID_CWD, "CWD does not point to a valid directory.");
        }

        // PS String command = getToolFullPath().toOSString();
        String command = getToolFullPath().toPortableString();

        // Check if the user has a custom configuration file
        IPreferenceStore TCDBprefs = TCDBPreferences.getPreferenceStore();
        boolean usecustomconfig = TCDBprefs.getBoolean(TCDBPreferences.KEY_USECUSTOMCONFIG);
        if (usecustomconfig) {
            String newconfigfile = TCDBprefs.getString(TCDBPreferences.KEY_CONFIGFILE);
            arglist.add("-C" + newconfigfile);
        }

        // Set up the External Command
        ExternalCommandLauncher tcdbtools = new ExternalCommandLauncher(command, arglist, cwd);
        tcdbtools.redirectErrorStream(true);

        MessageConsole console = null;
        // Set the Console (if requested by the user in the preferences)
        if (fPrefsStore.getBoolean(TCDBPreferences.KEY_USECONSOLE) || forceconsole) {
            console = TC32Plugin.getDefault().getConsole("TCDB");
            tcdbtools.setConsole(console);
        }

        ICommandOutputListener outputlistener = new OutputListener(monitor);
        tcdbtools.setCommandOutputListener(outputlistener);

        // Run TCDB
        try {
            fAbortReason = null;
            int result = tcdbtools.launch(new SubProgressMonitor(monitor, 80));

            // Test if TCDB was aborted
            if (fAbortReason != null) {
                throw new TCDBException(fAbortReason, fAbortLine);
            }

            if (result == -1) {
                throw new TCDBException(Reason.USER_CANCEL, "");
            }
        } catch (IOException e) {
            // Something didn't work while running the external command
            throw new TCDBException(Reason.NO_TCDB_FOUND,
                    "Cannot run TCDB executable. Please check the TC32 path preferences.", e);
        }

        // Everything was fine: get the ooutput from TCDB and return it
        // to the caller
        List<String> stdout = tcdbtools.getStdOut();

        monitor.worked(10);

        return stdout;
    } finally {
        monitor.done();
        //fLastTCDBFinish = System.currentTimeMillis();
    }
}

From source file:com.telink.tc32eclipse.core.toolinfo.TCDB.java

License:Open Source License

/**
 * Runs TCDB with the given arguments./*www  .java 2s. c om*/
 * <p>
 * The Output of stdout and stderr are merged and returned in a <code>List&lt;String&gt;</code>.
 * If the "use Console" flag is set in the Preferences, the complete output is shown on a
 * Console as well.
 * </p>
 * <p>
 * If the command fails to execute an entry is written to the log and an
 * {@link TCDBException} with the reason is thrown.
 * </p>
 * 
 * @param arguments
 *            <code>List&lt;String&gt;</code> with the arguments
 * @param monitor
 *            <code>IProgressMonitor</code> to cancel the running process.
 * @param forceconsole
 *            If <code>true</code> all output is copied to the console, regardless of the "use
 *            console" flag.
 * @param cwd
 *            <code>IPath</code> with a current working directory or <code>null</code> to use
 *            the default working directory (usually the one defined with the system property
 *            <code>user.dir</code). May not be empty.
 * @param programmerconfig
 *            The TCDB Programmer configuration currently is use. Required for the TCDB
 *            invocation delay value. If <code>null</code> no invocation delay will be done.
 * @return A list of all output lines, or <code>null</code> if the command could not be
 *         launched.
 * @throws TCDBException
 *             when TCDB cannot be started or when TCDB returned an error errors.
 */
public List<String> runCommand(List<String> arglist, IProgressMonitor monitor, boolean forceconsole, IPath cwd,
        ProgrammerConfig programmerconfig) throws TCDBException {

    try {
        monitor.beginTask("Running Telink Tools", 100);

        // Check if the CWD is valid
        if (cwd != null && cwd.isEmpty()) {
            throw new TCDBException(Reason.INVALID_CWD, "CWD does not point to a valid directory.");
        }

        // PS String command = getToolFullPath().toOSString();
        String command = getToolFullPath().toPortableString();

        // Check if the user has a custom configuration file
        IPreferenceStore TCDBprefs = TCDBPreferences.getPreferenceStore();
        boolean usecustomconfig = TCDBprefs.getBoolean(TCDBPreferences.KEY_USECUSTOMCONFIG);

        if (usecustomconfig) {
            String newconfigfile = TCDBprefs.getString(TCDBPreferences.KEY_CONFIGFILE);
            arglist.add("-C" + newconfigfile);
        }

        // Set up the External Command
        ExternalCommandLauncher TCDB = new ExternalCommandLauncher(command, arglist, cwd);
        TCDB.redirectErrorStream(true);

        MessageConsole console = null;
        // Set the Console (if requested by the user in the preferences)
        if (fPrefsStore.getBoolean(TCDBPreferences.KEY_USECONSOLE) || forceconsole) {
            console = TC32Plugin.getDefault().getConsole("Telink Binary Loader Console");
            TCDB.setConsole(console);
        }

        ICommandOutputListener outputlistener = new OutputListener(monitor);
        TCDB.setCommandOutputListener(outputlistener);

        // Run TCDB
        try {
            fAbortReason = null;
            int result = TCDB.launch(new SubProgressMonitor(monitor, 200));

            // Test if TCDB was aborted
            if (fAbortReason != null) {
                throw new TCDBException(fAbortReason, fAbortLine);
            }

            if (result == -1) {
                throw new TCDBException(Reason.USER_CANCEL, "");
            }
        } catch (IOException e) {
            // Something didn't work while running the external command
            throw new TCDBException(Reason.NO_TCDB_FOUND,
                    "Cannot run TCDB executable. Please check the TC32 path preferences.", e);
        }

        // Everything was fine: get the ooutput from TCDB and return it
        // to the caller
        List<String> stdout = TCDB.getStdOut();

        monitor.worked(10);

        return stdout;
    } finally {
        //monitor.done();//JW need reboot mcu
        //fLastTCDBFinish = System.currentTimeMillis();
    }
}

From source file:com.telink.tc32eclipse.ui.dialogs.TCDBErrorDialog.java

License:Open Source License

/**
 * Open an Error Dialog for an TCDBException.
 * <p>/*from  w w  w  .  j a va 2s.  co m*/
 * This method will take the Exception reason from the given {@link TCDBException} and
 * display a human readable message.
 * </p>
 * <p>
 * This Dialog is modal and will block until OK is clicked or the dialog is closed with ESC or
 * the window close button.
 * </P>
 * 
 * @param parent
 *            the parent shell of the dialog, or <code>null</code> if none
 * @param exc
 *            The <code>TCDBException</code> that contains the root cause.
 * @param config
 *            The <code>ProgrammerConfig</code> in use while the Exception occured. Used for
 *            more detailed error messages and may be <code>null</code> if not available.
 */
public static void openTCDBError(Shell parentShell, Throwable exc, ProgrammerConfig config) {
    String message, source;

    if (exc instanceof TCDBException) {
        TCDBException TCDBexc = (TCDBException) exc;

        // Get the Programmer id and the port from the given
        // ProgrammerConfig (if not null)
        // These are used below for more detailed error messages
        String programmer = "";
        String port = "";
        if (config != null) {
            programmer = "\"" + config.getProgrammer() + "\"";
            //port = config.getPort().equals("") ? "" : "\"" + config.getPort() + "\"";
        }

        // Also a custom TCDB configfile might be the cause of errors.
        String customconfig = "";
        IPreferenceStore TCDBstore = TCDBPreferences.getPreferenceStore();
        if (TCDBstore.getBoolean(TCDBPreferences.KEY_USECUSTOMCONFIG)) {
            customconfig = TCDBstore.getString(TCDBPreferences.KEY_CONFIGFILE);
        }

        // The nice thing about enums: using them in a switch statement!
        switch (TCDBexc.getReason()) {
        case UNKNOWN:
            message = "An error occured while accessing TCDB.\n\n" + "See below for details.";
            break;

        case NO_TCDB_FOUND:
            message = "TCDB executable can not be found.\n\n"
                    + "Check in the TC32 Preferences if the path to TCDB is correct.";
            break;

        case CANT_ACCESS_TCDB:
            message = "TCDB executable can not be accessed.\n\n"
                    + "Check in the TC32 Preferences if the path to TCDB is correct\n"
                    + "(Window > Preferences... -> TC32 -> Paths)";
            break;

        case CONFIG_NOT_FOUND:
            if (customconfig.length() == 0) {
                message = "TCDB can not find its default configuration file.\n\n" + "Check your TCDB setup.";
            } else {
                source = "TCDB can not find configuration file [{0}].\n\n"
                        + "Check in the TCDB Preferences if the path to the custom TCDB configuration file is correct\n"
                        + "(Window > Preferences... -> TC32 -> TCDB)";
                message = MessageFormat.format(source, customconfig);
            }
            break;

        case NO_PROGRAMMER:
            message = "No Programmer selected\n\n" + "Check the TCDB properties for the project.";
            break;

        case UNKNOWN_PROGRAMMER:
            source = "TCDB does not recognize the selected programmer id {0}\n\n"
                    + "Check the current Programmer Configuration.";
            message = MessageFormat.format(source, programmer);
            break;

        case UNKNOWN_MCU:
            message = "TCDB does not recognize the selected MCU type.\n\n"
                    + "Check the TC32 Target Hardware settings if the selected MCU is supported by TCDB.";
            break;

        case TIMEOUT:
            source = "Operation timed out while trying to access the TCDB programmer {0}\n\n"
                    + "Check that the Programmer is connected and switched on.";
            message = MessageFormat.format(source, programmer);
            break;

        case PORT_BLOCKED:
            source = "The port {0} for the Programmer {1} is blocked.\n\n"
                    + "Check that no other instances of TCDB or any other programm is using the port";
            message = MessageFormat.format(source, port, programmer);
            break;

        case NO_USB:
            source = "Could not open the USB device with the port name {0}.\n\n" + "Please check that\n"
                    + " - the programmer device is connected an switched on\n\n"
                    + "Also check in the configuration for programmer {1} that\n"
                    + " - the port name is correct\n"
                    + " - the \"Delay between TCDB invocations\" is set to a sufficently high value";
            message = MessageFormat.format(source, port, programmer);
            break;

        case PARSE_ERROR:
            message = "Could not understand the output from TCDB.\n\n"
                    + " - Either TCDB returned an error message that is not covered by the TC32 Eclipse Pluguin\n"
                    + " - or you have a newer TCDB version with a changed output format.\n\n"
                    + "In either case check the TCDB return message below and contact\n";
            break;

        case INVALID_CWD:
            message = "Invalid Build directory.\n"
                    + "Please check the Build directory on the \"Builder settings\" tab\n"
                    + "(Project -> Properties -> C Build)";
            break;

        case USER_CANCEL:
            message = "Operation cancelled.\n";
            break;

        case SYNC_FAIL:
            source = "Programmer {0} could not connect to the target hardware.\n\n"
                    + "Please check that the target hardware is connected correctly.";
            message = MessageFormat.format(source, programmer);
            break;

        case INIT_FAIL:
            source = "Programmer {0} could not initialize the target hardware.\n\n"
                    + "Please check that the target hardware is connected correctly.";
            message = MessageFormat.format(source, programmer);
            break;

        case NO_TARGET_POWER:
            source = "Target Hardware is not powered.\n\n"
                    + "Please check that the target hardware is connected correctly and has power.";
            message = MessageFormat.format(source, programmer);
            break;

        case INVALID_PORT:
            if (port.length() == 0) {
                // The user has not specified a port, so the OS default is used (but seemingly invalid).
                // Try to get the port used by TCDB from the TCDB output
                String abortline = TCDBexc.getMessage();
                String[] split = abortline.split("\"");
                if (split.length >= 2) {
                    port = split[1];
                } else {
                    port = "???";
                }
            }
            source = "TCDB has problems accessing the port \"{0}\".\n\n"
                    + "Please check that the correct port has been selected in the programmer configuration.";
            message = MessageFormat.format(source, port);
            break;

        case USB_RECEIVE_ERROR:
            message = "Problems receiving data from USB\n\n";
            break;

        default:
            message = "An unhandled Error occured while accessing TCDB.\n\n";
        }

    } else {
        // The throwable is not an instance of TCDBException
        // Why does the caller think this class is called
        // TCDBErrorDialog?
        // Nevertheless we just display the message from the Throwable
        message = exc.getLocalizedMessage();
    }

    // Set the status for the dialog
    IStatus status = new Status(IStatus.ERROR, TC32Plugin.PLUGIN_ID, exc.getLocalizedMessage(), exc.getCause());

    // Now open the Dialog.
    // while dialog.open() will return something, we don't care if the user
    // has pressed OK or ESC or the window close button.
    ErrorDialog dialog = new TCDBErrorDialog(parentShell, message, status);
    dialog.open();
    return;
}

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 ava 2  s.c o  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.trivadis.loganalysis.ui.internal.Perspective.java

License:Open Source License

private static boolean shouldSwitchPerspective(String key, String title, String message) {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    String preference = store.getString(key);
    Selection guard = (preference != null && !preference.equals("")) ? Selection.valueOf(preference)
            : Selection.PROMPT;/*from  w ww.  j av  a 2s.c  o  m*/
    if (Selection.PROMPT.equals(guard)) {
        MessageDialogWithToggle dialog = openYesNoQuestion(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message, null, false,
                store, key);
        guard = getConfirmCancel(dialog);
        if (dialog.getToggleState()) {
            saveSetting(key, guard);
        }
    }

    return guard.equals(Selection.ALWAYS);
}

From source file:com.twinsoft.convertigo.eclipse.ConvertigoPlugin.java

License:Open Source License

public static String getProperty(String key) {
    IPreferenceStore preferenceStore = ConvertigoPlugin.getDefault().getPreferenceStore();
    logDebug2("Looking for property : \"" + key + "\"");

    String result = preferenceStore.getString(key);

    logDebug("==> Getting property " + key + ": \"" + result + "\"");

    return result;
}