org.eclipse.ui.internal.ide.IDEInternalPreferences#org.eclipse.ui.internal.util.PrefUtil源码实例Demo

下面列出了org.eclipse.ui.internal.ide.IDEInternalPreferences#org.eclipse.ui.internal.util.PrefUtil 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void updateDefaultEditorMappingIfAbsent() {
	final EditorRegistry registry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry();
	for (final IFileEditorMapping editorMapping : registry.getFileEditorMappings()) {
		final IEditorDescriptor defaultEditor = editorMapping.getDefaultEditor();
		if (null == defaultEditor) {

			final String extension = editorMapping.getExtension();
			LOGGER.info("No default editor is associated with files with extension: '." + extension + "'.");
			final IEditorDescriptor defaultTextEditor = registry.findEditor(DEFAULT_TEXT_EDITOR_ID);
			if (null != defaultTextEditor) {
				((FileEditorMapping) editorMapping).setDefaultEditor(defaultTextEditor);
				String editorName = defaultTextEditor.getLabel();
				if (null == editorName) {
					editorName = defaultTextEditor.getId();
				}
				if (null != editorName) {
					LOGGER.info("Associated files with extension " + extension + " with '" + editorName + "'.");
				}
			}
		}
	}
	registry.saveAssociations();
	PrefUtil.savePrefs();
}
 
源代码2 项目: MergeProcessor   文件: LifeCycleHook.java
@ProcessRemovals
public void removeElementsFromContext() {
	/*
	 * WorkbenchWindow.populateStandardTrim(MTrimBar) automatically shows the heap
	 * status in the status line. LifeCycleHook.removeElementsFromContext(...) is
	 * called before the element is created. Therefore, we set the preference to not
	 * show the heap status.
	 * 
	 * This behaviour is only known in the 3.x legacy compatibility mode.
	 */
	PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, false);
}
 
/**
 * Prompts the user for whether to switch perspectives.
 *
 * @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);
	}
	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 /* 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;
}
 
源代码4 项目: gama   文件: Application.java
public static void ClearWorkspace(final boolean clear) {
	PrefUtil.getInternalPreferenceStore().setValue(CLEAR_WORKSPACE, Boolean.valueOf(clear).toString());
	PrefUtil.saveInternalPrefs();
}
 
源代码5 项目: gama   文件: Application.java
public static boolean IsClearWorkspace() {
	final boolean result = PrefUtil.getInternalPreferenceStore().getBoolean(CLEAR_WORKSPACE);
	DEBUG.OUT("Value of clearWorkspace pref: " + result);
	return result;
}
 
源代码6 项目: bonita-studio   文件: PreferenceInitializer.java
protected IPreferenceStore getAPIPreferenceStore() {
    return PrefUtil.getAPIPreferenceStore();
}
 
源代码7 项目: bonita-studio   文件: BOSSplashHandler.java
@Override
public void init(final Shell splash) {
    super.init(splash);
    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    final IProduct product = Platform.getProduct();
    if (product != null) {
        progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
        messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
        foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }

    final Rectangle progressRect = StringConverter.asRectangle(progressRectString);
    setProgressRect(progressRect);

    final Rectangle messageRect = StringConverter.asRectangle(messageRectString);
    setMessageRect(messageRect);

    int foregroundColorInteger;
    try {
        foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
    } catch (final Exception ex) {
        foregroundColorInteger = 0xD2D7FF; // off white
    }

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16,
            (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16,
            (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    // the following code will be removed for release time
    if (PrefUtil.getInternalPreferenceStore().getBoolean(
            "SHOW_BUILDID_ON_STARTUP")) { //$NON-NLS-1$
        final String buildId = System.getProperty(
                "eclipse.buildId", "Unknown Build"); //$NON-NLS-1$ //$NON-NLS-2$
        // find the specified location.  Not currently API
        // hardcoded to be sensible with our current splash Graphic
        final String buildIdLocString = product.getProperty("buildIdLocation"); //$NON-NLS-1$
        final Point buildIdPoint = StringConverter.asPoint(buildIdLocString,
                new Point(322, 190));
        getContent().addPaintListener(new PaintListener() {

            @Override
            public void paintControl(final PaintEvent e) {
                e.gc.setForeground(getForeground());
                e.gc.setBackground(getForeground()) ;
                e.gc
                .drawText(buildId, buildIdPoint.x, buildIdPoint.y,
                        true);
            }
        });
    }
    else {
        getContent(); // ensure creation of the progress
    }
}
 
@Override
public void openIntro() {
    PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.SHOW_INTRO, true);
    PrefUtil.saveAPIPrefs();
}