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

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

Introduction

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

Prototype

void setValue(String name, boolean value);

Source Link

Document

Sets the current value of the boolean-valued preference with the given name.

Usage

From source file:com.blackducksoftware.integration.eclipseplugin.preferences.PreferenceDefaults.java

License:Apache License

private void storeValues() {
    activateByDefault.store();/*from  ww w  .jav  a  2 s. c o m*/
    final IPreferenceStore prefStore = getPreferenceStore();
    for (final BooleanFieldEditor isActive : activeProjectPreferences) {
        prefStore.setValue(isActive.getPreferenceName(), isActive.getBooleanValue());
    }
}

From source file:com.bluexml.side.util.dependencies.WorkbenchPreferencePage1.java

License:Open Source License

public boolean performOk() {
    IPreferenceStore store = getPreferenceStore();
    // store the open view mode setting
    store.setValue(MAVEN_REPO_LOCATION, values.get(MAVEN_REPO_LOCATION).toString());
    return true;//from   w ww.jav  a2s  .c o m
}

From source file:com.bluexml.side.util.dependencies.WorkbenchPreferencePage1.java

License:Open Source License

public static void setRepoVersion(String repoId, String version) {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.setValue(getPreferencesIdForRepo(repoId), version);
}

From source file:com.bmw.spdxeditor.SPDXPreferencesPage.java

License:Apache License

protected void performApply() {
    System.out.println("performApply");
    IPreferenceStore store = getPreferenceStore();
    if (creatorText.getText().equalsIgnoreCase("noassertion")) {
        store.setValue(DEFAULT_FILE_CREATOR, "NOASSERTION");
    } else if (StringUtils.isEmpty(creatorTypes.getText())) {
        MessageDialog.openError(getShell(), "Error", "Select value in dropdown box first.");
    } else if (StringUtils.isEmpty(creatorText.getText())) {
        MessageDialog.openError(getShell(), "Error", "Enter value for creator name.");
    } else {//from w  w  w .j  a v  a 2  s  .  co  m
        String defaultCreator = creatorTypes.getText() + ":" + creatorText.getText();
        logger.info("Default creator set to: {}", defaultCreator);
        store.setValue(DEFAULT_FILE_CREATOR, defaultCreator);
        MessageDialog.openInformation(getShell(), "Creator set", "Default SPDX file creator has been set.");
    }
    System.out.println("storeNeedsSaving: " + store.needsSaving());
}

From source file:com.boothen.jsonedit.preferences.JsonPreferenceStore.java

License:Open Source License

public void updateEditorPreferences() {
    IPreferenceStore preferenceStore = getIPreferenceStore();
    preferenceStore.setValue(ERROR_TEXT_STYLE, editorPreferenceStore.getString(ERROR_TEXT_STYLE));
    preferenceStore.setValue(ERROR_INDICATION, editorPreferenceStore.getBoolean(ERROR_INDICATION));
    preferenceStore.setValue(ERROR_INDICATION_COLOR, editorPreferenceStore.getString(ERROR_INDICATION_COLOR));
}

From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java

License:Apache License

public void run(Object element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Process Launch",
                    "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }//from  www .j a v a  2 s . c o m

        if (MdwPlugin.getDefault().getPreferenceStore()
                .getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) {
            // web-based process launch
            try {
                IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch");
                if (viewPart != null) {
                    ProcessLaunchView launchView = (ProcessLaunchView) viewPart;
                    launchView.setProcess(processVersion);
                }
            } catch (PartInitException ex) {
                PluginMessages.log(ex);
            }
        } else {
            if (editorPart == null) {
                // process must be open
                open((WorkflowElement) element);
            }
            ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
            launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE);
        }
    } else if (element instanceof Activity) {
        Activity activity = (Activity) element;
        WorkflowProcess processVersion = activity.getProcess();

        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Activity Launch",
                    "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }

        ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE);
    } else if (element instanceof ExternalEvent) {
        ExternalEvent externalEvent = (ExternalEvent) element;
        ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE);
    } else if (element instanceof Template) {
        Template template = (Template) element;
        IEditorPart editorPart = template.getFileEditor();
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Run Template",
                    "Save template '" + template.getName() + "' before running?"))
                editorPart.doSave(new NullProgressMonitor());
        }

        template.openFile(new NullProgressMonitor());
        new TemplateRunDialog(getShell(), template).open();
    } else if (element instanceof Page) {
        Page page = (Page) element;
        IEditorPart editorPart = page.getFileEditor();
        if (editorPart != null) {
            if (editorPart.isDirty()) {
                if (MessageDialog.openQuestion(getShell(), "Run Page",
                        "Save page '" + page.getName() + "' before running?"))
                    editorPart.doSave(new NullProgressMonitor());
            }
        }
        page.run();
    } else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
        ServerSettings serverSettings;
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            if (workflowProject.isRemote())
                throw new IllegalArgumentException("Cannot run server for remote projects.");
            serverSettings = workflowProject.getServerSettings();
        } else {
            serverSettings = (ServerSettings) element;
        }

        if (ServerRunner.isServerRunning()) {
            String question = "A server may be running already.  Shut down the currently-running server?";
            MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question,
                    MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0);
            int res = dlg.open();
            if (res == 0)
                new ServerRunner(serverSettings, getShell().getDisplay()).stop();
            else if (res == 2)
                return;
        }

        if (serverSettings.getHome() == null && element instanceof WorkflowProject) {
            final IProject project = serverSettings.getProject().isCloudProject()
                    ? serverSettings.getProject().getSourceProject()
                    : serverSettings.getProject().getEarProject();
            @SuppressWarnings("restriction")
            org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog
                    .createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project);
            if (dialog != null)
                dialog.open();
        } else {
            IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore();
            if (element instanceof WorkflowProject)
                prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT,
                        ((WorkflowProject) element).getName());
            else
                prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());

            ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay());
            if (serverSettings.getProject() != null)
                runner.setJavaProject(serverSettings.getProject().getJavaProject());
            runner.start();
        }
    }
}

From source file:com.centurylink.mdw.plugin.designer.dialogs.ExportAsDialog.java

License:Apache License

@Override
protected void okPressed() {
    exportType = getFileExtension();/*from  w  w  w .  j  a  va 2  s  .  c o m*/
    BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
        public void run() {
            Set<String> options = getOptions();
            try {
                ExportHelper exporter = new ExportHelper(options, getElementOrder());
                exporter.exportProcess(getFilepath(), exportType, flowchartPage.getProcess(),
                        flowchartPage.canvas);
                IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
                for (String format : FORMATS.keySet()) {
                    if (FORMATS.get(format).equals(exportType))
                        prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_EXPORT_FORMAT, exportType);
                }
                prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_EXPORT_DOCUMENTATION,
                        options.contains(ExportHelper.DOCUMENTATION));
                prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_EXPORT_ATTRIBUTES,
                        options.contains(ExportHelper.ATTRIBUTES));
                prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_EXPORT_VARIABLES,
                        options.contains(ExportHelper.VARIABLES));
                prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_EXPORT_ELEMENT_ORDER, getElementOrder());
            } catch (Exception ex) {
                PluginMessages.uiError(getShell(), ex, "Print Process");
            }
        }
    });

    setReturnCode(OK);
    close();
}

From source file:com.centurylink.mdw.plugin.designer.dialogs.ProcessSaveDialog.java

License:Apache License

@Override
protected void okPressed() {
    String warning = null;//from w ww .j a  va 2s .co  m

    if (overwriteButton.getSelection() && !getButton(Dialog.OK).getText().equals("Force Update")
            && !getButton(Dialog.OK).getText().equals("Force Save") && hasInstances()) {
        warning = INSTANCES_MESSAGE + "\n\n" + "It is recommended that you increment the version when saving\n"
                + "rather than overwriting the existing version.  Otherwise Designer\n"
                + "may not correctly display previous incompatible instances.\n\n"
                + "To update the existing version, click 'Force Update' to confirm.";

        getButton(Dialog.OK).setText("Force Update");
    } else if (!getButton(Dialog.OK).getText().equals("Force Save") && process.getProject().isProduction()) {
        warning = "This process is for project '" + getProcess().getProject().getSourceProjectName()
                + "',\nwhich is flagged as a production environment.\n\nPlease click 'Force Save' to confirm.\n\nThis action will be audit logged.";

        getButton(Dialog.OK).setText("Force Save");
    } else if (MdwPlugin.getSettings().isWarnOverrideAttrsNotCarriedForward()
            && process.getProject().isFilePersist() && !overwriteButton.getSelection()
            && !carryOverrideAttributesCheckbox.getSelection()
            && !getButton(Dialog.OK).getText().equals("Save Anyway")) {
        warning = "Any override attributes will not be carried forward";
        if (!process.overrideAttributesApplied())
            warning += "\n(server not running when process loaded).";
        else
            warning += ".";
        getButton(Dialog.OK).setText("Save Anyway");
    }

    if (warning != null) {
        WarningTray tray = getWarningTray();
        tray.setMessage(warning);
        tray.open();
        return;
    }

    if (overwriteButton.getSelection()) {
        if (getButton(Dialog.OK).getText().equals("Force Update"))
            setReturnCode(FORCE_UPDATE);
        else
            setReturnCode(OVERWRITE);
    } else {
        if (newMinorButton.getSelection())
            version = process.getNewVersion(false);
        else if (newMajorButton.getSelection())
            version = process.getNewVersion(true);

        setReturnCode(NEW_VERSION);
    }

    IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
    if (rememberSelectionCheckbox.getSelection()) {
        Increment increment = Increment.Minor;
        if (newMajorButton.getSelection())
            increment = Increment.Major;
        else if (overwriteButton.getSelection())
            increment = Increment.Overwrite;
        prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_SAVE_INCREMENT, increment.toString());
    } else {
        prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_SAVE_INCREMENT, "");
    }
    prefsStore.setValue(PreferenceConstants.PREFS_ENFORCE_PROCESS_VALIDATION_RULES,
            enforceValidationCheckbox.getSelection());
    if (!process.getProject().isFilePersist())
        prefsStore.setValue(PreferenceConstants.PREFS_KEEP_PROCESSES_LOCKED_WHEN_SAVING,
                keepLockedCheckbox.getSelection());
    if (carryOverrideAttributesCheckbox != null)
        prefsStore.setValue(PreferenceConstants.PREFS_CARRY_FORWARD_OVERRIDE_ATTRS,
                carryOverrideAttributesCheckbox.getSelection());

    close();
}

From source file:com.centurylink.mdw.plugin.designer.dialogs.TemplateRunDialog.java

License:Apache License

@Override
protected void okPressed() {
    try {/*from   w  w  w. j av a  2  s. co m*/
        IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
        prefsStore.setValue(PreferenceConstants.PREFS_TEMPLATE_INPUT_FILE, inputFilePath);
        prefsStore.setValue(PreferenceConstants.PREFS_TEMPLATE_INPUT_LOCATION, inputDirPath);
        prefsStore.setValue(PreferenceConstants.PREFS_TEMPLATE_OUTPUT_LOCATION, outputDirPath);
        prefsStore.setValue(PreferenceConstants.PREFS_VELOCITY_PROPERTY_FILE_LOCATION, velocityPropFilePath);
        prefsStore.setValue(PreferenceConstants.PREFS_VELOCITY_TOOLBOX_FILE_LOCATION, velocityToolsFilePath);

        String input = inputFilePath == null || inputFilePath.length() == 0 ? inputDirPath : inputFilePath;
        template.runWith(input, outputDirPath, velocityPropFilePath, velocityToolsFilePath);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Run Template", template.getProject());
    }

    super.okPressed();
}

From source file:com.centurylink.mdw.plugin.designer.dialogs.VersionableImportDialog.java

License:Apache License

@Override
protected void okPressed() {
    IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
    prefsStore.setValue(PreferenceConstants.PREFS_KEEP_RESOURCES_LOCKED_WHEN_SAVING,
            keepLockedCheckbox.getSelection());

    close();//from w  w w.  j  a v a  2  s .  c om
}