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.liferay.ide.project.ui.pref.TargetPlatformSettingsPage.java

License:Open Source License

private void initvaules() {
    IPreferenceStore store = getPreStore();
    String version;/*from w  w  w  .j a  v  a2  s  .  c  om*/

    if (store != null) {
        version = store.getString(ITargetPlatformConstant.CURRENT_TARGETFORM_VERSION).replace("[", "")
                .replace("]", "");

        if (version == null || version.equals("")) {
            version = ITargetPlatformConstant.DEFAULT_TARGETFORM_VERSION;
        }
    } else {
        version = ITargetPlatformConstant.DEFAULT_TARGETFORM_VERSION;
    }

    final ISelection selection = new StructuredSelection(version);
    targetPlatFormVersion.setSelection(selection);
}

From source file:com.liferay.ide.ui.util.UIUtil.java

License:Open Source License

private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) {
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();

    String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);

    if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) {
        // Return whether or not we should always switch
        return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
    }/*from  w  w w .  j a v a 2s .  c o m*/

    String desc = finalPersp.getDescription();
    String message;

    if (desc == null || desc.length() == 0) {
        message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel());
    } else {
        message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessageWithDesc,
                new String[] { finalPersp.getLabel(), desc });
    }

    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(),
            ResourceMessages.NewProject_perspSwitchTitle, message, null, false, store,
            IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);

    int result = dialog.getReturnCode();

    // If we are not going to prompt anymore propogate the choice.
    if (dialog.getToggleState()) {
        String preferenceValue;

        if (result == IDialogConstants.YES_ID) {
            // Doesn't matter if it is replace or new window
            // as we are going to use the open perspective setting
            preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE;
        } else {
            preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE;
        }

        // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond
        PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE,
                preferenceValue);
    }

    return result == IDialogConstants.YES_ID;
}

From source file:com.liferay.ide.xml.search.ui.validators.LiferayBaseValidator.java

License:Open Source License

@Override
public boolean isValidTarget(IProject project) {
    LiferayXMLSearchUI plugin = LiferayXMLSearchUI.getDefault();

    IPreferenceStore preferenceStore = plugin.getPreferenceStore();

    String[] ignoreList = preferenceStore.getString(LiferayXMLSearchUI.PREF_KEY_IGNORE_PROJECTS_LIST)
            .split(",");

    for (String ignore : ignoreList) {
        if (ignore.trim().equals(project.getName())) {
            return false;
        }/*from  w  w  w.ja  va2 s  .c  o m*/
    }

    return true;
}

From source file:com.matlab.eclipse.mconsole.internal.ui.wizards.NewMatlabProjectWizard.java

License:Open Source License

/**
 * Prompts the user for whether to switch perspectives.
 * /*from w w w  .  j  av  a  2  s. co  m*/
 * @param window
 *            The workbench window in which to switch perspectives; must not
 *            be <code>null</code>
 * @param finalPersp
 *            The perspective to switch to; must not be <code>null</code>.
 * 
 * @return <code>true</code> if it's OK to switch, <code>false</code>
 *         otherwise
 */
private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) {
    IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
    String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) {
        // Return whether or not we should always switch
        return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm);
    }

    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(),
            ResourceMessages.NewProject_perspSwitchTitle,
            NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()), null /*
                                                                                                  * use the default
                                                                                                  * message for the
                                                                                                  * toggle
                                                                                                  */,
            false /*
                  * toggle
                  * is
                  * initially
                  * unchecked
                  */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE);
    int result = dialog.getReturnCode();

    // If we are not going to prompt anymore propogate the choice.
    if (dialog.getToggleState()) {
        String preferenceValue;
        if (result == IDialogConstants.YES_ID)
            // Doesn't matter if it is replace or new window
            // as we are going to use the open perspective setting
            preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE;
        else
            preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE;

        // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond
        PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE,
                preferenceValue);
    }
    return result == IDialogConstants.YES_ID;
}

From source file:com.matlab.eclipse.meditor.actions.MatlabExportAsAction.java

License:Open Source License

public void run(IAction action) {
    try {/*from   ww w .ja va  2s  .  c  o  m*/
        MatlabEditor editor = (MatlabEditor) getTextEditor();
        String matlabFileName = editor.getEditorInput().getName();

        // ask user for filename:
        FileDialog saveDialog = new FileDialog(editor.getSite().getShell(), SWT.SAVE);
        saveDialog.setFilterExtensions(new String[] { "*.xml", "*.html", "*.tex", "*.pdf", "*.*" });
        saveDialog.setFilterNames(
                new String[] { "XML files", "HTML files", "LaTeX source files", "PDF files", "all files" });
        saveDialog.setText("Export");
        // start from the directory last used
        IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
        String lastPath = preferenceStore.getString(PREF_LAST_PATH);
        String lastExtension = preferenceStore.getString(PREF_LAST_EXTENSION);
        if (!lastPath.equals("")) {
            saveDialog.setFilterPath(lastPath);
        }
        // suggest a filename similar to the matlab-file's name
        String extension = "xml";
        if (!lastExtension.equals("")) {
            extension = lastExtension;
        }
        String suggestedFileName = matlabFileName.replace(".m", "." + extension);
        saveDialog.setFileName(suggestedFileName);

        // show dialog to ask user for filename
        String targetFileName = saveDialog.open();
        if (targetFileName != null) {
            IPath targetFilePath = Path.fromOSString(targetFileName);
            String targetFileExtension = targetFilePath.getFileExtension();

            boolean xmlOutput = targetFileExtension.compareToIgnoreCase("xml") == 0;
            boolean htmlOutput = targetFileExtension.compareToIgnoreCase("html") == 0;
            boolean latexOutput = targetFileExtension.compareToIgnoreCase("tex") == 0;
            boolean pdfOutput = targetFileExtension.compareToIgnoreCase("pdf") == 0;
            boolean someOutput = xmlOutput || htmlOutput || latexOutput || pdfOutput;

            // export
            if (!targetFilePath.isEmpty() && someOutput) {
                // save used directory
                String outputDir = saveDialog.getFilterPath();
                preferenceStore.setValue(PREF_LAST_PATH, outputDir);
                preferenceStore.setValue(PREF_LAST_EXTENSION, targetFileExtension);
                MatlabSelection selection = new MatlabSelection(editor, false);
                IDocument document = selection.doc;
                IPath XMLFilePath = targetFilePath.removeFileExtension().addFileExtension("xml");

                Properties metadata = MatlabengineExportPrefsPage.getMetadataAsProperties();
                metadata.setProperty(XMLExporter.FILETITLE_KEY, matlabFileName);

                Properties exportProperties = MatlabengineExportPrefsPage.getExportProperties();

                exportProperties.setProperty(XMLExporter.OUTPUT_XML_KEY, Boolean.toString(xmlOutput));
                exportProperties.setProperty(XMLExporter.OUTPUT_HTML_KEY, Boolean.toString(htmlOutput));
                exportProperties.setProperty(XMLExporter.OUTPUT_LATEX_KEY, Boolean.toString(latexOutput));
                exportProperties.setProperty(XMLExporter.OUTPUT_PDF_KEY, Boolean.toString(pdfOutput));

                XMLExporterThread exporter = new XMLExporterThread(document, metadata, exportProperties,
                        XMLFilePath);

                exporter.doExportOperations();
            } else {
                Activator.errorDialog(XMLExporterThread.EXPORT_EXCEPTION_MSG,
                        new Exception("No target file or no supported filetype specified"));
            }
        }
    } catch (Exception e) {
        Activator.errorDialog(XMLExporterThread.EXPORT_EXCEPTION_MSG, e);
    }
}

From source file:com.mentor.nucleus.bp.als.oal.test.TestInvocation.java

License:Open Source License

public void testInvocationPassR2I() throws RecognitionException, TokenStreamException {
    // Make sure the prefs are set to catch this error
    IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
    String i2rp = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION);
    String r2ic = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION);
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, MessageDialogWithToggle.NEVER);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, MessageDialogWithToggle.NEVER);

    String act = "paramVal(i: 3.14);"; //$NON-NLS-1$
    for (int i = 0; i < m_invocation_prefix.length; ++i) {
        String x = OalParserTest.parseAction(m_invocation_prefix[i] + act, OalParserTest.ACTIVITY_TYPE_FUNC,
                OalParserTest.TEST_VOID_NO_PARM);
        assertTrue(x.contains("Parameter ->i<- has been assigned value of different type"));//$NON-NLS-1$
    }//w w  w.j  a va2s  .  c  o m

    // Set the prefs back to original state
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, i2rp);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, r2ic);
}

From source file:com.mentor.nucleus.bp.als.oal.test.TestInvocation.java

License:Open Source License

public void testInvocationPassI2R() throws RecognitionException, TokenStreamException {
    // Make sure the prefs are set to catch this error
    IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
    String i2rp = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION);
    String r2ic = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION);
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, MessageDialogWithToggle.NEVER);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, MessageDialogWithToggle.NEVER);

    String act = "paramValRef( i: 3, r: j );"; //$NON-NLS-1$
    for (int i = 0; i < m_invocation_prefix.length; ++i) {
        String x = OalParserTest.parseAction("j = 2; " + m_invocation_prefix[i] + act, //$NON-NLS-1$
                OalParserTest.ACTIVITY_TYPE_FUNC, OalParserTest.TEST_VOID_NO_PARM);
        assertTrue(x.contains("Parameter ->r<- has been assigned value of different type"));//$NON-NLS-1$
    }//  www .  j  a  va2  s .  com
    OalParserTest.clearActionData(OalParserTest.ACTIVITY_TYPE_FUNC, OalParserTest.TEST_VOID_NO_PARM);

    // Set the prefs back to original state
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, i2rp);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, r2ic);
}

From source file:com.mentor.nucleus.bp.als.oal.test.TestInvocation_Generics.java

License:Open Source License

public void testInvocationPassR2I() throws RecognitionException, TokenStreamException {
    // Make sure the prefs are set to catch this error
    IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
    String i2rp = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION);
    String r2ic = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION);
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, MessageDialogWithToggle.NEVER);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, MessageDialogWithToggle.NEVER);

    String act = "paramVal(i: 3.14);"; //$NON-NLS-1$
    for (int i = 0; i < m_invocation_prefix.length; ++i) {
        String x = OalParserTest_Generics.parseAction(m_invocation_prefix[i] + act,
                OalParserTest_Generics.ACTIVITY_TYPE_FUNC, OalParserTest_Generics.TEST_VOID_NO_PARM);
        assertTrue(x.contains("Parameter ->i<- has been assigned value of different type"));//$NON-NLS-1$
    }/*from   ww  w. j  a v a2 s .c om*/

    // Set the prefs back to original state
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, i2rp);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, r2ic);
}

From source file:com.mentor.nucleus.bp.als.oal.test.TestInvocation_Generics.java

License:Open Source License

public void testInvocationPassI2R() throws RecognitionException, TokenStreamException {
    // Make sure the prefs are set to catch this error
    IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore();
    String i2rp = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION);
    String r2ic = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION);
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, MessageDialogWithToggle.NEVER);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, MessageDialogWithToggle.NEVER);

    String act = "paramValRef( i: 3, r: j );"; //$NON-NLS-1$
    for (int i = 0; i < m_invocation_prefix.length; ++i) {
        String x = OalParserTest_Generics.parseAction("j = 2; " + m_invocation_prefix[i] + act, //$NON-NLS-1$
                OalParserTest_Generics.ACTIVITY_TYPE_FUNC, OalParserTest_Generics.TEST_VOID_NO_PARM);
        assertTrue(x.contains("Parameter ->r<- has been assigned value of different type"));//$NON-NLS-1$
    }// w w  w . jav  a  2  s . co  m
    OalParserTest_Generics.clearActionData(OalParserTest_Generics.ACTIVITY_TYPE_FUNC,
            OalParserTest_Generics.TEST_VOID_NO_PARM);

    // Set the prefs back to original state
    store.setValue(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION, i2rp);
    store.setValue(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION, r2ic);
}

From source file:com.mentor.nucleus.bp.core.common.BridgePointPreferencesStore.java

License:Open Source License

public IPreferenceModel loadModel(IPreferenceStore store, BasePlugin plugin, IPreferenceModel model) {
    BridgePointPreferencesModel prefs = null;

    if (model == null)
        prefs = new BridgePointPreferencesModel();
    else {/*  w w  w. ja  v  a2 s  . co  m*/
        if (!(model instanceof BridgePointPreferencesModel)) {
            throw new IllegalArgumentException("Cannot load instance of " + model.getClass().getName());
        }
        prefs = (BridgePointPreferencesModel) model;
    }

    prefs.parseAllOnResourceChange = store.getString(BridgePointPreferencesStore.PARSE_ALL_ON_RESOURCE_CHANGE);
    prefs.allowIntToRealPromotion = store.getString(BridgePointPreferencesStore.ALLOW_INT_TO_REAL_PROMOTION);
    prefs.allowRealToIntCoercion = store.getString(BridgePointPreferencesStore.ALLOW_REAL_TO_INT_COERCION);
    prefs.allowImplicitComponentAddressing = store
            .getBoolean(BridgePointPreferencesStore.ALLOW_IMPLICIT_COMPONENT_ADDRESSING);
    prefs.allowOperationsInWhere = store.getBoolean(BridgePointPreferencesStore.ALLOW_OPERATIONS_IN_WHERE);
    prefs.enableErrorForEmptySynchronousMessage = store
            .getBoolean(BridgePointPreferencesStore.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE);
    prefs.enableErrorForEmptySynchronousMessageRealized = store
            .getBoolean(BridgePointPreferencesStore.ENABLE_ERROR_FOR_EMPTY_SYNCHRONOUS_MESSAGE_REALIZED);
    prefs.disableGradients = store.getBoolean(BridgePointPreferencesStore.DISABLE_GRADIENTS);
    prefs.invertGradients = store.getBoolean(BridgePointPreferencesStore.INVERT_GRADIENTS);
    prefs.gradientBaseColor = store.getLong(BridgePointPreferencesStore.GRADIENT_BASE_COLOR);
    if (prefs.gradientBaseColor == 0L) {
        prefs.gradientBaseColor = 0xc8c8c8;
    }
    prefs.exportOAL = store.getString(BridgePointPreferencesStore.EXPORT_OAL);
    prefs.exportGraphics = store.getString(BridgePointPreferencesStore.EXPORT_GRAPHICS);
    prefs.messageDirection = store.getString(BridgePointPreferencesStore.MESSAGE_DIRECTION);
    prefs.showTransitionActions = store.getBoolean(BridgePointPreferencesStore.SHOW_TRANSITION_ACTIONS);
    prefs.showEventParameters = store.getBoolean(BridgePointPreferencesStore.SHOW_EVENT_PARAMETERS);

    prefs.enableFLAs = store.getBoolean(BridgePointPreferencesStore.ENABLE_FIXED_LENGTH_ARRAYS);
    prefs.enableDSAs = store.getBoolean(BridgePointPreferencesStore.ENABLE_DYNAMICALLY_SIZED_ARRAYS);

    prefs.enableDeterministicVerifier = store
            .getBoolean(BridgePointPreferencesStore.ENABLE_DETERMINISTIC_VERIFIER);

    prefs.enableInstanceReferences = store.getBoolean(BridgePointPreferencesStore.ENABLE_INSTANCE_REFERENCES);

    prefs.enableVerifierAudit = store.getBoolean(BridgePointPreferencesStore.ENABLE_VERIFIER_AUDIT);
    prefs.enableSelectAudit = store.getInt(BridgePointPreferencesStore.ENABLE_SELECT_AUDIT);
    prefs.enableRelateAudit = store.getInt(BridgePointPreferencesStore.ENABLE_RELATE_AUDIT);
    prefs.enableUnrelateAudit = store.getInt(BridgePointPreferencesStore.ENABLE_UNRELATE_AUDIT);
    prefs.enableDeleteAudit = store.getInt(BridgePointPreferencesStore.ENABLE_DELETE_AUDIT);
    prefs.startUpTime = store.getInt(BridgePointPreferencesStore.START_UP_TIME);

    prefs.showGrid = store.getBoolean(BridgePointPreferencesStore.SHOW_GRID);
    prefs.snapToGrid = store.getBoolean(BridgePointPreferencesStore.SNAP_TO_GRID);
    prefs.gridSpacing = store.getInt(BridgePointPreferencesStore.GRID_SPACING);
    prefs.defaultRoutingStyle = store.getString(BridgePointPreferencesStore.DEFAULT_ROUTING_STYLE);
    prefs.emitRTOData = store.getBoolean(BridgePointPreferencesStore.EMIT_RTO_DATA);
    prefs.showReferenceRemovalDialog = store.getBoolean(BridgePointPreferencesStore.SHOW_SYNC_DELETION_DIALOG);
    prefs.showReferenceSyncReport = store.getBoolean(BridgePointPreferencesStore.SHOW_SYNC_REPORT);

    prefs.useDefaultNamesForNewModelElements = store
            .getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION);

    return prefs;
}