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

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

Introduction

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

Prototype

void putValue(String name, String value);

Source Link

Document

Sets the current value of the preference with the given name to the given string value without sending a property change.

Usage

From source file:org.parallelj.designer.extension.edit.parts.BusinessProcedureNameExtendedEditPart.java

License:Open Source License

/**
 * @return icon image for BusinessProcedureName label
 */// www. j a v a  2s.  co  m
@Override
protected Image getLabelIcon() {
    // this will retrieve image path from preference or from businesscontribution
    if (this.getParent() instanceof BusinessProcedureExtendedEditPart) {

        String path = null;
        BusinessProcedureExtendedEditPart businessProcedureExtendedEditPart = (BusinessProcedureExtendedEditPart) this
                .getParent();
        IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();

        if (businessProcedureExtendedEditPart.getBusinessProcedureContribution() == null) {
            path = preferenceStore.getString(this.getLabelText());
        } else {
            path = businessProcedureExtendedEditPart.getBusinessProcedureContribution().getImgPath();
            preferenceStore.putValue(this.getLabelText(), path);
        }

        String[] split = path.split(":");
        return ImageLoader.getImage(split[0], split[1]);
    }
    return null;
}

From source file:org.python.pydev.editorinput.PySourceLocatorPrefs.java

License:Open Source License

/**
 * Adds a path to the translation table.
 * /*from  w w  w  .j a va2 s  . c o  m*/
 * @param translation the translation path to be added. 
 * E.g.: 
 * path asked, new path -- means that a request for the "path asked" should return the "new path"
 * path asked, DONTASK -- means that if some request for that file was asked it should silently ignore it
 * 
 * E.g.: 
 * c:\foo\c.py,c:\temp\c.py
 * c:\foo\c.py,DONTASK
 */
private static void addPathTranslation(String[] translation) {
    String valid = isValid(translation);
    if (valid != null) {
        throw new RuntimeException(valid);
    }
    IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore();
    String available = store.getString(PydevEditorPrefs.SOURCE_LOCATION_PATHS);

    if (available == null || available.trim().length() == 0) {
        available = StringUtils.join(",", translation);
    } else {
        String pathAsked = translation[0].trim();

        String existent = getPathTranslation(pathAsked);
        if (existent != null) {
            List<String> splitted = StringUtils.splitAndRemoveEmptyTrimmed(available, '\n');
            final int size = splitted.size();
            for (int i = 0; i < size; i++) {
                String s = splitted.get(i);
                String initialPart = StringUtils.splitAndRemoveEmptyTrimmed(s, ',').get(0).trim();
                if (initialPart.equals(pathAsked)) {
                    splitted.set(i, StringUtils.join(",", translation));
                    break;
                }
            }
            available = StringUtils.join("\n", splitted);
        } else {
            available += "\n";
            available += StringUtils.join(",", translation);
        }
    }
    store.putValue(PydevEditorPrefs.SOURCE_LOCATION_PATHS, available);
}

From source file:org.python.pydev.logging.ping.LogInfoProvider.java

License:Open Source License

public String getApplicationId() {
    IPreferencesService preferencesService = Platform.getPreferencesService();
    if (preferencesService == null) {
        return TESTING_ID;
    }// ww w.ja va2  s  . c  o  m
    //Note: this is the same qualifier/id used by aptana plugins (so that we don't generate
    //a new one if there's already one registered).
    String qualifier = "com.aptana.db";
    String key = "ide-id";
    String id = preferencesService.getString(qualifier, key, null, null);

    if (id == null) {
        Preferences node = null;
        String keyNodeInPrefs = qualifier + "." + key;
        String keySettingInPrefs = "UUID";

        try {
            node = Preferences.userRoot().node(keyNodeInPrefs);
            id = node.get(keySettingInPrefs, "");
        } catch (Exception e1) {
            Log.log(e1);
        }
        IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore();

        if (id == null || id.length() == 0) {
            id = preferenceStore.getString(keyNodeInPrefs + keySettingInPrefs);
        }

        if (id == null || id.length() == 0) {
            id = UUID.randomUUID().toString();
        }

        //if we got here it was not initially found, so, save it in all locations we look for!
        preferenceStore.putValue(keyNodeInPrefs + keySettingInPrefs, id);

        if (node != null) {
            try {
                node.put(keySettingInPrefs, id);
            } catch (Exception e) {
                Log.log(e);
            }
        }

        // saves the id in configuration scope so it's shared by all workspaces
        IEclipsePreferences prefs = (new ConfigurationScope()).getNode(qualifier);
        prefs.put(key, id);
        try {
            prefs.flush();
        } catch (BackingStoreException e) {
            Log.log(e);
        }
    }
    return id;
}

From source file:org.search.niem.uml.papyrus.preferences.NIEMPreferenceConverter.java

License:Open Source License

public static void setValue(final IPreferenceStore store, final String name, final AggregationKind value) {
    final AggregationKind oldValue = getAggregationKind(store, name);
    if (oldValue == null || !oldValue.equals(value)) {
        store.putValue(name, asString(value));
        store.firePropertyChangeEvent(name, oldValue, value);
    }/*from   w  w w .  j a va2  s.  c  o  m*/
}

From source file:org.summer.sdt.internal.ui.JavaPlugin.java

License:Open Source License

/**
 * Installs backwards compatibility for the preference store.
 *//*from   w  w  w. j  a va  2  s  .c o m*/
private void ensurePreferenceStoreBackwardsCompatibility() {

    IPreferenceStore store = getPreferenceStore();

    // must add here to guarantee that it is the first in the listener list
    fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
    fMembersOrderPreferenceCache.install(store);

    /*
     * Installs backwards compatibility: propagate the Java editor font from a
     * pre-2.1 plug-in to the Platform UI's preference store to preserve
     * the Java editor font from a pre-2.1 workspace. This is done only
     * once.
     */
    String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$
    if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) {
        if (!store.getBoolean(fontPropagatedKey))
            PreferenceConverter.setValue(getDeprecatedWorkbenchPreferenceStore(),
                    PreferenceConstants.EDITOR_TEXT_FONT,
                    PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT));
    }
    store.setValue(fontPropagatedKey, true);

    /*
     * Backwards compatibility: set the Java editor font in this plug-in's
     * preference store to let older versions access it. Since 2.1 the
     * Java editor font is managed by the workbench font preference page.
     */
    PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT,
            JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));

    fFontPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty()))
                PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT,
                        JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT));
        }
    };
    JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);

    /*
     * Backwards compatibility: propagate the Java editor tab width from a
     * pre-3.0 plug-in to the new preference key. This is done only once.
     */
    final String oldTabWidthKey = DEPRECATED_EDITOR_TAB_WIDTH;
    final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH;
    String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$
    if (store.contains(oldTabWidthKey) && !store.isDefault(oldTabWidthKey)) {
        if (!store.getBoolean(tabWidthPropagatedKey))
            store.setValue(newTabWidthKey, store.getInt(oldTabWidthKey));
    }
    store.setValue(tabWidthPropagatedKey, true);

    /*
     * Backwards compatibility: set the Java editor tab width in this plug-in's
     * preference store with the old key to let older versions access it.
     * Since 3.0 the tab width is managed by the extended text editor and
     * uses a new key.
     */
    store.putValue(oldTabWidthKey, store.getString(newTabWidthKey));

    fPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (newTabWidthKey.equals(event.getProperty())) {
                IPreferenceStore prefStore = getPreferenceStore();
                prefStore.putValue(oldTabWidthKey, prefStore.getString(newTabWidthKey));
            }
        }
    };
    store.addPropertyChangeListener(fPropertyChangeListener);

    /*
     * Backward compatibility for the refactoring preference key.
     */
    //      store.setValue(
    //         PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD,
    //         RefactoringCore.getConditionCheckingFailedSeverity());

    // The commented call above triggers the eager loading of the LTK core plug-in
    // Since the condition checking failed severity is guaranteed to be of RefactoringStatus.SEVERITY_WARNING,
    // we directly insert the inlined value of this constant
    store.setToDefault(DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD);

    if (!store.getBoolean(JavaDocLocations.PREF_JAVADOCLOCATIONS_MIGRATED)) {
        JavaDocLocations.migrateToClasspathAttributes();
    }

    FormatterProfileStore.checkCurrentOptionsVersion();

    /*
     * Backward compatibility: migrate "alphabetic ordering" preference to point the sorter
     * preference to the alphabetic sorter.
     */
    String proposalOrderMigrated = "proposalOrderMigrated"; //$NON-NLS-1$

    if (store.contains(DEPRECATED_CODEASSIST_ORDER_PROPOSALS)) {
        if (!store.getBoolean(proposalOrderMigrated)) {
            boolean alphabetic = store.getBoolean(DEPRECATED_CODEASSIST_ORDER_PROPOSALS);
            if (alphabetic)
                store.setValue(PreferenceConstants.CODEASSIST_SORTER, "org.summer.sdt.ui.AlphabeticSorter"); //$NON-NLS-1$
        }
    }
    store.setValue(proposalOrderMigrated, true);

}

From source file:org.talend.designer.abstractmap.ui.prefs.MapPreferenceInitializer.java

License:Open Source License

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore prefs = getPluginPreferenceStore();
    prefs.putValue(MapPrefsConstants.LINK_STYLE, LINK_STYLE.AUTO.toString());

}

From source file:org.talend.designer.codegen.components.ui.ComponentPreferenceInitializer.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore preferenceStore = CodeGeneratorActivator.getDefault().getPreferenceStore();

    preferenceStore.putValue(IComponentPreferenceConstant.LIMIT, "1000"); //$NON-NLS-1$
    preferenceStore.setDefault(IComponentPreferenceConstant.LIMIT, "1000"); //$NON-NLS-1$

    preferenceStore.putValue(IComponentPreferenceConstant.LINK_STYLE, LINK_STYLE.AUTO.toString());
}

From source file:org.talend.rcp.intro.Application.java

License:Open Source License

@Override
public Object start(IApplicationContext context) throws Exception {

    Display display = PlatformUI.createDisplay();

    try {// w  w  w .  j  a  v  a  2 s  .c om
        // setup MavenResolver properties
        // before set, must check user setting first.
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IMavenUIService.class)) {
            IMavenUIService mavenUIService = (IMavenUIService) GlobalServiceRegister.getDefault()
                    .getService(IMavenUIService.class);
            if (mavenUIService != null) {
                mavenUIService.checkUserSettings(new NullProgressMonitor());
                mavenUIService.updateMavenResolver(false);
                mavenUIService.addMavenConfigurationChangeListener();
            }
        }

        Shell shell = new Shell(display, SWT.ON_TOP);
        Object instanceLocationCheck = acquireWorkspaceLock(shell);
        if (instanceLocationCheck != null) {// no workspace selected so return.
            shell.dispose();
            return instanceLocationCheck;
        }

        /*
         * setSqlpatternUsibility(context); setRefProjectUsibility(context);
         */
        CoreRepositoryPlugin.getDefault().setRCPMode();

        checkBrowserSupport();

        // it is removed to plugin org.talend.license.gui
        // if (!ArrayUtils.contains(Platform.getApplicationArgs(),
        // EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND)
        //                    && !Boolean.parseBoolean(System.getProperty("talend.project.reload"))) {//$NON-NLS-1$ 
        // openLicenseAndRegister(shell);
        // }

        IMigrationToolService service = (IMigrationToolService) GlobalServiceRegister.getDefault()
                .getService(IMigrationToolService.class);
        service.executeWorspaceTasks();
        // saveConnectionBean(email);

        boolean logUserOnProject = logUserOnProject(display.getActiveShell());
        try {
            if (!logUserOnProject) {
                // MOD qiongli 2010-11-1,bug 16723: Code Cleansing
                // Platform.endSplash();
                context.applicationRunning();
                // ~
                return EXIT_OK;
            }
        } finally {
            shell.dispose();
        }

        // if some commands are set to relaunch (not restart) the eclipse then relaunch it
        // this happens when project type does not match the running product type
        if (System.getProperty(org.eclipse.equinox.app.IApplicationContext.EXIT_DATA_PROPERTY) != null) {
            return IApplication.EXIT_RELAUNCH;
        }

        boolean afterUpdate = false;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
            ICoreTisService tisService = (ICoreTisService) GlobalServiceRegister.getDefault()
                    .getService(ICoreTisService.class);
            afterUpdate = tisService.needRestartAfterUpdate();
        }

        // common restart
        if (LoginHelper.isRestart) {
            // if after update,need to lauch the product by loading all new version plugins
            if (afterUpdate) {
                EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
                        EclipseCommandLine.TALEND_RELOAD_COMMAND, Boolean.TRUE.toString(), false);
                // if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
                EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
                        EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND, null, true);
                return IApplication.EXIT_RELAUNCH;
            }
            return IApplication.EXIT_RESTART;
        }

        IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
                .getService(IBrandingService.class);

        // for talend product only to add the links on the left of the coolbar
        // other products will simply reuse the default presentation factory.
        if (brandingService.isPoweredbyTalend()) {
            // setup the presentation factory, which is defined in the plugin.xml of the org.talend.rcp
            IPreferenceStore store = PlatformUI.getPreferenceStore();
            store.putValue(IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID,
                    "org.talend.rcp.presentationfactory"); //$NON-NLS-1$
        }
        // clean the clearPersistedState if branding or project type change
        IPreferenceStore store = PlatformUI.getPreferenceStore();
        String lastProjectType = store.getString("last_started_project_type");
        String projectType = ProjectManager.getInstance().getCurrentProject().getEmfProject().getType();
        if (projectType == null) {
            // for local project
            projectType = System.getProperty("talend.branding.type");
        }
        if (lastProjectType != null && !"".equals(lastProjectType) && !lastProjectType.equals(projectType)
                || BrandingChecker.isBrandingChanged()) {
            if (projectType != null) {
                store.putValue("last_started_project_type", projectType);
            }
            System.setProperty("clearPersistedState", Boolean.TRUE.toString());
        }

        int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART) {
            // use relaunch instead of restart to remove change the restart property that may have been added in the
            // previous
            // relaunch
            EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
                    EclipseCommandLine.TALEND_RELOAD_COMMAND, Boolean.FALSE.toString(), false);
            EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
                    EclipseCommandLine.TALEND_PROJECT_TYPE_COMMAND, null, true);
            // if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
            EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
                    EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND, null, true, true);
            // TDI-8426, fix the swith project failure, when in dev also.
            // if dev, can't be restart, so specially for dev.
            if (Platform.inDevelopmentMode()) {
                return IApplication.EXIT_RESTART;
            }
            return IApplication.EXIT_RELAUNCH;
        } else {
            return IApplication.EXIT_OK;
        }
    } finally {
        display.dispose();
        Location instanceLoc = Platform.getInstanceLocation();
        if (instanceLoc != null) { // release workspace lock for current app only, not for anothers.
            instanceLoc.release();
        }
    }

}

From source file:org.talend.updates.runtime.ui.UpdateStudioWizard.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from ww w  . j  av a 2s  .c om
public boolean performFinish() {
    storeDoNotShowAgainPref();
    InstallNewFeatureJob installNewFeatureJob = new InstallNewFeatureJob(
            new HashSet<ExtraFeature>(updateWizardModel.selectedExtraFeatures),
            updateWizardModel.getFeatureRepositories());
    installNewFeatureJob.schedule();
    // listen to the job end so that we can ask the user to restart the Studio
    installNewFeatureJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent jobEvent) {
            MultiStatus results = (MultiStatus) jobEvent.getResult();
            IStatus[] installStatus = results.getChildren();
            boolean hasAnyFailure = false;
            boolean hasAnySuccess = false;
            boolean hasCancel = false;
            for (IStatus status : installStatus) {
                if (!status.isOK()) {// ask the user to restart the Studio
                    if (status.getSeverity() == IStatus.CANCEL) {
                        hasCancel = true;
                    } else {
                        hasAnyFailure = true;
                    }
                } else {
                    hasAnySuccess = true;
                }
            }
            // if cancel,should do nothing,not display any pop message
            if (hasCancel) {
                return;
            }
            // display message in case of any success
            String firstPartOfMessage = Messages
                    .getString("UpdateStudioWizard.all.feautures.installed.successfully"); //$NON-NLS-1$
            if (hasAnySuccess) {
                if (hasAnyFailure) {
                    firstPartOfMessage = Messages
                            .getString("UpdateStudioWizard.some.feautures.installed.sucessfully"); //$NON-NLS-1$
                } // else only success to keep initial message
                final String finalMessage = firstPartOfMessage
                        + Messages.getString("UpdateStudioWizard.do.you.want.to.restart"); //$NON-NLS-1$
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        IPreferenceStore store = PlatformUI.getPreferenceStore();
                        // reset the last type of project set.
                        // this will force from the Application class to reset all the perspectives
                        store.putValue("last_started_project_type", "NO_TYPE");

                        boolean isOkToRestart = MessageDialog.openQuestion(getShell(),
                                Messages.getString("UpdateStudioWizard.install.sucessfull"), finalMessage); //$NON-NLS-1$
                        if (isOkToRestart) {
                            PlatformUI.getWorkbench().restart();
                        }
                    }
                });
            } // else only failure or canceled so do nothing cause error are reported by Eclipse

        }
    });
    return true;
}

From source file:org.wesnoth.product.WorkbenchActionBuilder.java

License:Open Source License

/**
 * Creates the feature-dependent actions for the menu bar.
 *///from   ww  w  .  j av a 2 s .  c  o m
private void makeFeatureDependentActions(IWorkbenchWindow window) {
    AboutInfo[] infos = null;

    IPreferenceStore prefs = IDEWorkbenchPlugin.getDefault().getPreferenceStore();

    // Optimization: avoid obtaining the about infos if the platform state
    // is
    // unchanged from last time. See bug 75130 for details.
    String stateKey = "platformState"; //$NON-NLS-1$
    String prevState = prefs.getString(stateKey);
    String currentState = String.valueOf(Platform.getStateStamp());
    boolean sameState = currentState.equals(prevState);
    if (!sameState) {
        prefs.putValue(stateKey, currentState);
    }

    // See if a welcome page is specified.
    // Optimization: if welcome pages were found on a previous run, then
    // just add the action.
    String quickStartKey = IDEActionFactory.QUICK_START.getId();
    String showQuickStart = prefs.getString(quickStartKey);
    if (sameState && "true".equals(showQuickStart)) { //$NON-NLS-1$
        quickStartAction = IDEActionFactory.QUICK_START.create(window);
        register(quickStartAction);
    } else if (sameState && "false".equals(showQuickStart)) { //$NON-NLS-1$
        // do nothing
    } else {
        // do the work
        infos = IDEWorkbenchPlugin.getDefault().getFeatureInfos();
        boolean found = hasWelcomePage(infos);
        prefs.setValue(quickStartKey, String.valueOf(found));
        if (found) {
            quickStartAction = IDEActionFactory.QUICK_START.create(window);
            register(quickStartAction);
        }
    }

    // See if a tips and tricks page is specified.
    // Optimization: if tips and tricks were found on a previous run, then
    // just add the action.
    String tipsAndTricksKey = IDEActionFactory.TIPS_AND_TRICKS.getId();
    String showTipsAndTricks = prefs.getString(tipsAndTricksKey);
    if (sameState && "true".equals(showTipsAndTricks)) { //$NON-NLS-1$
        tipsAndTricksAction = IDEActionFactory.TIPS_AND_TRICKS.create(window);
        register(tipsAndTricksAction);
    } else if (sameState && "false".equals(showTipsAndTricks)) { //$NON-NLS-1$
        // do nothing
    } else {
        // do the work
        if (infos == null) {
            infos = IDEWorkbenchPlugin.getDefault().getFeatureInfos();
        }
        boolean found = hasTipsAndTricks(infos);
        prefs.setValue(tipsAndTricksKey, String.valueOf(found));
        if (found) {
            tipsAndTricksAction = IDEActionFactory.TIPS_AND_TRICKS.create(window);
            register(tipsAndTricksAction);
        }
    }
}