类org.eclipse.ui.internal.ide.IDEInternalPreferences源码实例Demo

下面列出了怎么用org.eclipse.ui.internal.ide.IDEInternalPreferences的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * 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;
}
 
/**
 * 设置在拖动文件到导航视图时的模式为直接复制,见类 {@link CopyFilesAndFoldersOperation} 的方法 CopyFilesAndFoldersOperation
 * robert	09-26
 */
private void setDragModle(){
	IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE,
			IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
	store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE,
			IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
}
 
/**
 * 设置在拖动文件到导航视图时的模式为直接复制,见类 {@link CopyFilesAndFoldersOperation} 的方法 CopyFilesAndFoldersOperation
 * robert	09-26
 */
private void setDragModle(){
	IPreferenceStore store= IDEWorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE,
			IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
	store.setValue(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE,
			IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY);
}
 
 类所在包
 同包方法