org.eclipse.ui.internal.WorkbenchPlugin Java Examples

The following examples show how to use org.eclipse.ui.internal.WorkbenchPlugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSApplicationWorkbenchWindowAdvisor.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: DeployArtifactsHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void openSuccessDialog(Shell activeShell, IStatus status)
        throws LoginException, BonitaHomeNotSetException, ServerAPIException, UnknownAPITypeException {
    APISession session = BOSEngineManager.getInstance().loginDefaultTenant(Repository.NULL_PROGRESS_MONITOR);
    DeployedAppContentProvider contentProvider = new DeployedAppContentProvider(status,
            BOSEngineManager.getInstance().getApplicationAPI(session),
            BOSEngineManager.getInstance().getProfileAPI(session),
            BOSEngineManager.getInstance().getIdentityAPI(session));
    if (contentProvider.getItems().length > 0) {
        if (IDialogConstants.OPEN_ID == DeploySuccessDialog.open(activeShell, contentProvider,
                WorkbenchPlugin.getDefault().getDialogSettings())) {
            try {
                new OpenBrowserOperation(contentProvider.getSelectedURL()).execute();
            } catch (MalformedURLException | UnsupportedEncodingException | URISyntaxException e) {
                BonitaStudioLog.error(e);
            }
        }
    } else {
        MessageDialog.openWarning(activeShell, Messages.deployStatus, String.format(
                Messages.deploySuccessButNoAppToOpenMsg, new ActiveOrganizationProvider().getDefaultUser()));
    }
    if (session != null) {
        BOSEngineManager.getInstance().logoutDefaultTenant(session);
    }
}
 
Example #3
Source File: ExportRepositoryWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public ExportRepositoryWizard(final List<IRepositoryStore<? extends IRepositoryFileStore>> stores, final boolean isZip,
        final Set<Object> defaultSelectedFiles, final String defaultFileName, final String wizardTitle) {
    this.stores = stores;
    setDefaultPageImageDescriptor(Pics.getWizban());
    setNeedsProgressMonitor(true);
    this.isZip = isZip;
    this.wizardTitle = wizardTitle;
    this.defaultSelectedFiles = defaultSelectedFiles;
    this.defaultFileName = defaultFileName;
    setWindowTitle(wizardTitle);
    final IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
            .getDialogSettings();
    IDialogSettings wizardSettings = workbenchSettings
            .getSection("ExportRepositoryWizard"); //$NON-NLS-1$
    if (wizardSettings == null) {
        wizardSettings = workbenchSettings.addNewSection("ExportRepositoryWizard"); //$NON-NLS-1$
    }
    setDialogSettings(wizardSettings);
}
 
Example #4
Source File: KeyController2.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private static BindingManager loadModelBackend(IServiceLocator locator) {
	IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
	BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
	final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
	try {
		Scheme modelActiveScheme = null;
		for (int i = 0; i < definedSchemes.length; i++) {
			final Scheme scheme = definedSchemes[i];
			final Scheme copy = bindingManager.getScheme(scheme.getId());
			copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
			if (definedSchemes[i] == bindingService.getActiveScheme()) {
				modelActiveScheme = copy;
			}
		}
		bindingManager.setActiveScheme(modelActiveScheme);
	} catch (final NotDefinedException e) {
		StatusManager.getManager()
				.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
						"Keys page found an undefined scheme", e)); //$NON-NLS-1$
	}
	bindingManager.setLocale(bindingService.getLocale());
	bindingManager.setPlatform(bindingService.getPlatform());
	bindingManager.setBindings(bindingService.getBindings());
	return bindingManager;
}
 
Example #5
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Image getColumnImage(Object element, int index) {
	BindingElement be = (BindingElement) element;
	switch (index) {
	case COMMAND_NAME_COLUMN:
		final String commandId = be.getId();
		final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId);
		if (imageDescriptor == null) {
			return null;
		}
		try {
			return localResourceManager.createImage(imageDescriptor);
		} catch (final DeviceResourceException e) {
			final String message = "Problem retrieving image for a command '" //$NON-NLS-1$
					+ commandId + '\'';
			final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e);
			WorkbenchPlugin.log(message, status);
		}
		return null;
	}

	return null;
}
 
Example #6
Source File: KeyController2.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
private static BindingManager loadModelBackend(IServiceLocator locator) {
	IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
	BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
	final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
	try {
		Scheme modelActiveScheme = null;
		for (int i = 0; i < definedSchemes.length; i++) {
			final Scheme scheme = definedSchemes[i];
			final Scheme copy = bindingManager.getScheme(scheme.getId());
			copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
			if (definedSchemes[i] == bindingService.getActiveScheme()) {
				modelActiveScheme = copy;
			}
		}
		bindingManager.setActiveScheme(modelActiveScheme);
	} catch (final NotDefinedException e) {
		StatusManager.getManager()
				.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
						"Keys page found an undefined scheme", e)); //$NON-NLS-1$
	}
	bindingManager.setLocale(bindingService.getLocale());
	bindingManager.setPlatform(bindingService.getPlatform());
	bindingManager.setBindings(bindingService.getBindings());
	return bindingManager;
}
 
Example #7
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Image getColumnImage(Object element, int index) {
	BindingElement be = (BindingElement) element;
	switch (index) {
	case COMMAND_NAME_COLUMN:
		final String commandId = be.getId();
		final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId);
		if (imageDescriptor == null) {
			return null;
		}
		try {
			return localResourceManager.createImage(imageDescriptor);
		} catch (final DeviceResourceException e) {
			final String message = "Problem retrieving image for a command '" //$NON-NLS-1$
					+ commandId + '\'';
			final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e);
			WorkbenchPlugin.log(message, status);
		}
		return null;
	}

	return null;
}
 
Example #8
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 移除无用的菜单项:<br/>
 * File 菜单下的“open file...”和“Convert Line Delimiters To”
 */
private void removeUnusedAction() {
	ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
	IActionSetDescriptor[] actionSets = reg.getActionSets();

	List<String> actionSetIds = Arrays.asList("org.eclipse.ui.actionSet.openFiles",
			"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
			"org.eclipse.ui.actions.showKeyAssistHandler", "org.eclipse.ui.edit.text.actionSet.navigation",
			"org.eclipse.ui.edit.text.actionSet.annotationNavigation");
	for (int i = 0; i < actionSets.length; i++) {
		if (actionSetIds.contains(actionSets[i].getId())) {
			IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension();
			reg.removeExtension(ext, new Object[] { actionSets[i] });
		}
	}
}
 
Example #9
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 创建文件菜单
 * @return 返回文件菜单的 menu manager;
 */
private MenuManager createFileMenu() {
	MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.file"),
			IWorkbenchActionConstants.M_FILE); // &File
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
	// 添加 new.ext group,这样 IDE 中定义的 Open File... 可以显示在最顶端
	menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
	menu.add(new Separator());
	menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
	menu.add(new GroupMarker("xliff.switch"));
	menu.add(new GroupMarker("rtf.switch"));
	menu.add(new GroupMarker("xliff.split"));
	menu.add(new Separator());
	// 设置保存文件记录条数为 5 条
	WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 5);
	menu.add(new GroupMarker(IWorkbenchActionConstants.HISTORY_GROUP));
	menu.add(exitAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
	return menu;
}
 
Example #10
Source File: KeyController2.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
private static BindingManager loadModelBackend(IServiceLocator locator) {
	IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
	BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
	final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
	try {
		Scheme modelActiveScheme = null;
		for (int i = 0; i < definedSchemes.length; i++) {
			final Scheme scheme = definedSchemes[i];
			final Scheme copy = bindingManager.getScheme(scheme.getId());
			copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
			if (definedSchemes[i] == bindingService.getActiveScheme()) {
				modelActiveScheme = copy;
			}
		}
		bindingManager.setActiveScheme(modelActiveScheme);
	} catch (final NotDefinedException e) {
		StatusManager.getManager()
				.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
						"Keys page found an undefined scheme", e)); //$NON-NLS-1$
	}
	bindingManager.setLocale(bindingService.getLocale());
	bindingManager.setPlatform(bindingService.getPlatform());
	bindingManager.setBindings(bindingService.getBindings());
	return bindingManager;
}
 
Example #11
Source File: KeysPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Image getColumnImage(Object element, int index) {
	BindingElement be = (BindingElement) element;
	switch (index) {
	case COMMAND_NAME_COLUMN:
		final String commandId = be.getId();
		final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId);
		if (imageDescriptor == null) {
			return null;
		}
		try {
			return localResourceManager.createImage(imageDescriptor);
		} catch (final DeviceResourceException e) {
			final String message = "Problem retrieving image for a command '" //$NON-NLS-1$
					+ commandId + '\'';
			final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e);
			WorkbenchPlugin.log(message, status);
		}
		return null;
	}

	return null;
}
 
Example #12
Source File: ThemeUIComposite.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setFont(String fontId, FontData[] data) {
	String fdString = PreferenceConverter.getStoredRepresentation(data);

	Font existing = JFaceResources.getFont(fontId);
	String existingString = "";
	if (!(existing.isDisposed())) {
		existingString = PreferenceConverter
				.getStoredRepresentation(existing.getFontData());
	}
	if (existingString.equals(fdString)) {
		return;
	}
	JFaceResources.getFontRegistry().put(fontId, data);

	ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	String key = ThemeElementHelper.createPreferenceKey(currentTheme,fontId);
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(key, fdString);
}
 
Example #13
Source File: ThemePreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setFont(String fontId, FontData[] data)
{
	String fdString = PreferenceConverter.getStoredRepresentation(data);
	// Only set new values if they're different from existing!
	Font existing = JFaceResources.getFont(fontId);
	String existingString = ""; //$NON-NLS-1$
	if (!existing.isDisposed())
	{
		existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
	}
	if (!existingString.equals(fdString))
	{
		// put in registry...
		JFaceResources.getFontRegistry().put(fontId, data);
		// Save to prefs...
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
		String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
		IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
		store.setValue(key, fdString);
	}
}
 
Example #14
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 6 votes vote down vote up
protected IStatus run(IProgressMonitor monitor) {
	if (monitor.isCanceled()) {
		return new Status(IStatus.CANCEL, WorkbenchPlugin.PI_WORKBENCH,
				IStatus.CANCEL, EMPTY_STRING, null);
	}

	if (FilteredItemsSelectionDialog.this != null) {
		GranualProgressMonitor wrappedMonitor = new GranualProgressMonitor(
				monitor);
		FilteredItemsSelectionDialog.this.reloadCache(true,
				wrappedMonitor);
	}

	if (!monitor.isCanceled()) {
		refreshJob.schedule();
	}

	return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
			EMPTY_STRING, null);

}
 
Example #15
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 移除无用的菜单项:<br/>
 * File 菜单下的“open file...”和“Convert Line Delimiters To”
 */
private void removeUnusedAction() {
	ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
	IActionSetDescriptor[] actionSets = reg.getActionSets();

	List<String> actionSetIds = Arrays.asList("org.eclipse.ui.actionSet.openFiles",
			"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
			"org.eclipse.ui.actions.showKeyAssistHandler");
	for (int i = 0; i < actionSets.length; i++) {
		if (actionSetIds.contains(actionSets[i].getId())) {
			IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension();
			reg.removeExtension(ext, new Object[] { actionSets[i] });
		}
	}
}
 
Example #16
Source File: RcpActionBarAdvisor.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void removeActionSets() {
	// currently we just remove the cheat-sheets here; see:
	// http://random-eclipse-tips.blogspot.de/2009/02/eclipse-rcp-removing-unwanted_02.html
	var reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
	for (var aset : reg.getActionSets()) {
		if (Objects.equals(aset.getId(),
				"org.eclipse.ui.cheatsheets.actionSet")) {
			var ext = aset.getConfigurationElement()
					.getDeclaringExtension();
			reg.removeExtension(ext, new Object[]{aset});
		}
	}
}
 
Example #17
Source File: CustomPopupMenuExtender.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void registryChanged(final IRegistryChangeEvent event) {
    Display display = Display.getDefault();
    if (part != null) {
        display = part.getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
    }
    //check the delta to see if there are any viewer contribution changes.  if so, null our builder to cause reparsing on the next menu show
    IExtensionDelta[] deltas = event.getExtensionDeltas();
    for (IExtensionDelta delta : deltas) {
        IExtensionPoint extensionPoint = delta.getExtensionPoint();
        if (extensionPoint.getContributor().getName().equals(WorkbenchPlugin.PI_WORKBENCH)
                && extensionPoint.getSimpleIdentifier().equals(
                        IWorkbenchRegistryConstants.PL_POPUP_MENU)) {

            boolean clearPopups = false;
            IConfigurationElement[] elements = delta.getExtension().getConfigurationElements();
            for (IConfigurationElement element : elements) {
                if (element.getName().equals(IWorkbenchRegistryConstants.TAG_VIEWER_CONTRIBUTION)) {
                    clearPopups = true;
                    break;
                }
            }

            if (clearPopups) {
                display.syncExec(() -> clearStaticActions());
            }
        }
    }
}
 
Example #18
Source File: ExportBarWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ExportBarWizard(){
	setDefaultPageImageDescriptor(Pics.getWizban()) ;
	setNeedsProgressMonitor(true) ;
	IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
			.getDialogSettings();
	IDialogSettings wizardSettings = workbenchSettings
			.getSection("ExportBarWizard"); //$NON-NLS-1$
			if (wizardSettings == null) {
				wizardSettings = workbenchSettings.addNewSection("ExportBarWizard"); //$NON-NLS-1$
			}
			setDialogSettings(wizardSettings);
			setWindowTitle(Messages.buildTitle);
}
 
Example #19
Source File: ConfigurationWizardDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ConfigurationWizardDialog(Shell parentShell, IWizard newWizard) {
    super(parentShell, newWizard);
    IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
    dialogSettings = workbenchSettings.getSection(ConfigurationWizardDialog.class.getName());
    if (dialogSettings == null) {
        dialogSettings = workbenchSettings.addNewSection(ConfigurationWizardDialog.class.getName());
    }
    isSimpleMode = dialogSettings.getBoolean(CONFIGURATION_WIZARD_DIALOG_SIMPLE_MODE);
}
 
Example #20
Source File: PreferenceInitializer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void initializeWorkbenchPreferences() {
    IScopeContext context = DefaultScope.INSTANCE;
    IEclipsePreferences node = context.getNode(WorkbenchPlugin
            .getDefault().getBundle().getSymbolicName());

    node.putBoolean(IPreferenceConstants.RUN_IN_BACKGROUND, false);
}
 
Example #21
Source File: KeyController2.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Logs the given exception, and opens an error dialog saying that something went wrong. The exception is assumed to
 * have something to do with the preference store.
 * @param exception
 *            The exception to be logged; must not be <code>null</code>.
 */
private final void logPreferenceStoreException(final Throwable exception) {
	final String message = NewKeysPreferenceMessages.PreferenceStoreError_Message;
	String exceptionMessage = exception.getMessage();
	if (exceptionMessage == null) {
		exceptionMessage = message;
	}
	final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, exceptionMessage, exception);
	WorkbenchPlugin.log(message, status);
	StatusUtil.handleStatus(message, exception, StatusManager.SHOW);
}
 
Example #22
Source File: ADocSpecExportWizard.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Default constructor
 */
public ADocSpecExportWizard() {
	IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
	IDialogSettings section = workbenchSettings.getSection(WIZARD_NAME);// $NON-NLS-1$
	if (section == null) {
		section = workbenchSettings.addNewSection(WIZARD_NAME);// $NON-NLS-1$
	}
	setDialogSettings(section);
}
 
Example #23
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected IDialogSettings getDialogSettings() {
	IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();

	IDialogSettings settings = workbenchSettings.getSection(TAG_DIALOG_SECTION);

	if (settings == null) {
		settings = workbenchSettings.addNewSection(TAG_DIALOG_SECTION);
	}
	return settings;
}
 
Example #24
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 5 votes vote down vote up
public IStatus runInUIThread(IProgressMonitor monitor) {
	if (monitor.isCanceled())
		return new Status(IStatus.OK, WorkbenchPlugin.PI_WORKBENCH,
				IStatus.OK, EMPTY_STRING, null);

	if (FilteredItemsSelectionDialog.this != null) {
		FilteredItemsSelectionDialog.this.refresh();
	}

	return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
			EMPTY_STRING, null);
}
 
Example #25
Source File: ApplicationActionBarAdvisor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 移除无用的菜单项:<br/>
 * File 菜单下的“open file...”和“Convert Line Delimiters To”
 */
private void removeUnusedAction() {
	ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
	IActionSetDescriptor[] actionSets = reg.getActionSets();

	List<String> actionSetIds = Arrays.asList("org.eclipse.ui.actionSet.openFiles",
			"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
			"org.eclipse.ui.actions.showKeyAssistHandler");
	for (int i = 0; i < actionSets.length; i++) {
		if (actionSetIds.contains(actionSets[i].getId())) {
			IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension();
			reg.removeExtension(ext, new Object[] { actionSets[i] });
		}
	}
}
 
Example #26
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件菜单
 * @return 返回文件菜单的 menu manager;
 */
private MenuManager createFileMenu() {
	MenuManager menu = new MenuManager(Messages.getString("ts.ApplicationActionBarAdvisor.menu.file"),
			IWorkbenchActionConstants.M_FILE); // &File
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
	// 添加 new.ext group,这样 IDE 中定义的 Open File... 可以显示在最顶端
	menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
	menu.add(new Separator());
	menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));
	menu.add(new GroupMarker("xliff.switch"));
	menu.add(new GroupMarker("rtf.switch"));
	menu.add(new GroupMarker("xliff.split"));
	menu.add(new Separator());
	// 设置保存文件记录条数为 5 条
	WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 5);
	// 添加文件访问列表
	ContributionItemFactory REOPEN_EDITORS = new ContributionItemFactory("reopenEditors") { //$NON-NLS-1$
		/* (non-javadoc) method declared on ContributionItemFactory */
		public IContributionItem create(IWorkbenchWindow window) {
			if (window == null) {
				throw new IllegalArgumentException();
			}
			return new ReopenEditorMenu(window, getId(), false);
		}
	};
	menu.add(REOPEN_EDITORS.create(window));

	menu.add(exitAction);
	menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
	return menu;
}
 
Example #27
Source File: KeyController2.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Logs the given exception, and opens an error dialog saying that something went wrong. The exception is assumed to
 * have something to do with the preference store.
 * @param exception
 *            The exception to be logged; must not be <code>null</code>.
 */
private final void logPreferenceStoreException(final Throwable exception) {
	final String message = NewKeysPreferenceMessages.PreferenceStoreError_Message;
	String exceptionMessage = exception.getMessage();
	if (exceptionMessage == null) {
		exceptionMessage = message;
	}
	final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, exceptionMessage, exception);
	WorkbenchPlugin.log(message, status);
	StatusUtil.handleStatus(message, exception, StatusManager.SHOW);
}
 
Example #28
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected IDialogSettings getDialogSettings() {
	IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();

	IDialogSettings settings = workbenchSettings.getSection(TAG_DIALOG_SECTION);

	if (settings == null) {
		settings = workbenchSettings.addNewSection(TAG_DIALOG_SECTION);
	}
	return settings;
}
 
Example #29
Source File: TLCPreferenceInitializer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
   * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
   */
  public void initializeDefaultPreferences()
  {
      final IPreferenceStore uiPreferencesStore = TLCUIActivator.getDefault().getPreferenceStore();
      final IPreferenceStore tlcPreferencesStore = TLCActivator.getDefault().getPreferenceStore();

      tlcPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      // This is so bad.. we store them in parallel because one is needed by plugin relied upon the PreferencePage
      //      and the other by a plugin which is on the opposite side of the dependency. (TLCModelLaunchDelegate)
      uiPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_TRACE_MAX_SHOW_ERRORS, 10000);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_POPUP_ERRORS, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_REVALIDATE_ON_MODIFY, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_DEFAULT_WORKERS_COUNT,
      							  TLCConsumptionProfile.LOCAL_NORMAL.getWorkerThreads());
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXIMUM_HEAP_SIZE_DEFAULT, MAX_HEAP_SIZE_DEFAULT);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXSETSIZE_DEFAULT, TLCGlobals.setBound);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPBITS_DEFAULT, 1);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPSETIMPL_DEFAULT, FPSetFactory.getImplementationDefault());
      // store.setDefault(ITLCPreferenceConstants.I_TLC_DELETE_PREVIOUS_FILES, true);

// By default we want the Toolbox to show a modal progress dialog upon TLC
// startup. A user can opt to subsequently suppress the dialog.
// This restores the behavior prior to https://bugs.eclipse.org/146205#c10.
      if (!uiPreferencesStore.contains(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS)) {
	final IEclipsePreferences node = InstanceScope.INSTANCE
			.getNode(WorkbenchPlugin.getDefault().getBundle().getSymbolicName());
	node.putBoolean(IPreferenceConstants.RUN_IN_BACKGROUND, false);
	try {
		node.flush();
	} catch (final BackingStoreException e) {
		TLCUIActivator.getDefault().logError("Error trying to flush the workbench plugin preferences store.",
				e);
	}
	uiPreferencesStore.setValue(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS, true);
}
  }
 
Example #30
Source File: KeyController2.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Logs the given exception, and opens an error dialog saying that something went wrong. The exception is assumed to
 * have something to do with the preference store.
 * @param exception
 *            The exception to be logged; must not be <code>null</code>.
 */
private final void logPreferenceStoreException(final Throwable exception) {
	final String message = NewKeysPreferenceMessages.PreferenceStoreError_Message;
	String exceptionMessage = exception.getMessage();
	if (exceptionMessage == null) {
		exceptionMessage = message;
	}
	final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, exceptionMessage, exception);
	WorkbenchPlugin.log(message, status);
	StatusUtil.handleStatus(message, exception, StatusManager.SHOW);
}