Java 类org.eclipse.ui.internal.WorkbenchPlugin 实例源码

项目:n4js    文件:N4JSApplicationWorkbenchWindowAdvisor.java   
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();
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
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);

}
项目:PDFReporter-Studio    文件:MultiPageToolbarEditorSite.java   
public IKeyBindingService getKeyBindingService() {
    if (service == null) {
        service = getMultiPageEditor().getEditorSite().getKeyBindingService();
        if (service instanceof INestableKeyBindingService) {
            INestableKeyBindingService nestableService = (INestableKeyBindingService) service;
            service = nestableService.getKeyBindingService(this);

        } else {
            /*
             * This is an internal reference, and should not be copied by client code. If you are thinking of copying this,
             * DON'T DO IT.
             */
            WorkbenchPlugin
                    .log("MultiPageEditorSite.getKeyBindingService()   Parent key binding service was not an instance of INestableKeyBindingService.  It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }
    return service;
}
项目:APICloud-Studio    文件:ThemePreferencePage.java   
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);
    }
}
项目:APICloud-Studio    文件:ThemeUIComposite.java   
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);
}
项目:mytourbook    文件:LocalizeDialog.java   
private void addPluginsTab(TabFolder tabFolder) {
    TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    languageSet.associate(tabItem, Messages.LocalizeDialog_TabTitle_Plugins);

    AboutBundleData[] bundleInfos;



    // create a data object for each bundle, remove duplicates, and include only resolved bundles (bug 65548)
    Map map = new HashMap();
    Bundle[] bundles = WorkbenchPlugin.getDefault().getBundles();
    for (int i = 0; i < bundles.length; ++i) {
        AboutBundleData data = new AboutBundleData(bundles[i]);
        if (BundleUtility.isReady(data.getState()) && !map.containsKey(data.getVersionedId())) {
            map.put(data.getVersionedId(), data);
        }
    }
    bundleInfos = (AboutBundleData[]) map.values().toArray(
            new AboutBundleData[0]);

    Composite c = new Composite(tabFolder, SWT.NONE);
    tabItem.setControl(c);

    createPluginsTab(c, bundleInfos);
}
项目:OpenSPIFe    文件:EnsembleWorkbenchAdvisor.java   
@Override
public synchronized AbstractStatusHandler getWorkbenchErrorHandler() {
    return new WorkbenchErrorHandler() {
        @Override
        public void handle(StatusAdapter statusAdapter, int style) {
            if (isClosing) {
                // we are shutting down, so just log
                WorkbenchPlugin.log(statusAdapter.getStatus());
                return;
            }
            if ((style & StatusManager.SHOW) != 0) {
                style = style | StatusManager.BLOCK;
            }
            super.handle(statusAdapter, style);
        }
    };
}
项目:translationstudio8    文件:KeysPreferencePage.java   
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;
}
项目:translationstudio8    文件:KeyController2.java   
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;
}
项目:gef-gwt    文件:CommandAction.java   
/**
 * Build a command from the executable extension information.
 * 
 * @param commandService
 *            to get the Command object
 * @param commandId
 *            the command id for this action
 * @param parameterMap
 */
private void createCommand(ICommandService commandService,
        String commandId, Map parameterMap) {
    Command cmd = commandService.getCommand(commandId);
    if (!cmd.isDefined()) {
        WorkbenchPlugin.log("Command " + commandId + " is undefined"); //$NON-NLS-1$//$NON-NLS-2$
        return;
    }

    if (parameterMap == null) {
        parameterizedCommand = new ParameterizedCommand(cmd, null);
        return;
    }

    parameterizedCommand = ParameterizedCommand.generateCommand(cmd,
            parameterMap);
}
项目:gef-gwt    文件:CommandAction.java   
public void runWithEvent(Event event) {
    if (handlerService == null) {
        String commandId = (parameterizedCommand == null ? "unknownCommand" //$NON-NLS-1$
                : parameterizedCommand.getId());
        WorkbenchPlugin.log("Cannot run " + commandId //$NON-NLS-1$
                + " before command action has been initialized"); //$NON-NLS-1$
        return;
    }
    try {
        if (parameterizedCommand != null) {
            handlerService.executeCommand(parameterizedCommand, event);
        }
    } catch (Exception e) {
        WorkbenchPlugin.log(e);
    }
}
项目:tmxeditor8    文件:ApplicationActionBarAdvisor.java   
/**
 * 创建文件菜单
 * @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;
}
项目:tmxeditor8    文件:ApplicationActionBarAdvisor.java   
/**
 * 移除无用的菜单项:<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] });
        }
    }
}
项目:tmxeditor8    文件:KeysPreferencePage.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
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;
}
项目:tmxeditor8    文件:KeysPreferencePage.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
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;
}
项目:relations    文件:AbstractExtensionHandler.java   
protected void runWizardDialog(final Shell inShell,
        final AbstractExtensionWizard inWizard) {
    final IDialogSettings lWorkbenchSettings = WorkbenchPlugin.getDefault()
            .getDialogSettings();
    IDialogSettings lWizardSettings = lWorkbenchSettings
            .getSection("NewWizardAction"); //$NON-NLS-1$
    if (lWizardSettings == null) {
        lWizardSettings = lWorkbenchSettings
                .addNewSection("NewWizardAction"); //$NON-NLS-1$
    }
    inWizard.setDialogSettings(lWizardSettings);
    inWizard.setForcePreviousAndNextButtons(true);

    final WizardDialog dialog = new WizardDialog(inShell, inWizard);
    dialog.create();
    dialog.open();
}
项目:n4js    文件:NpmExportWizard.java   
/** */
public NpmExportWizard() {

    IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
    IDialogSettings section = workbenchSettings.getSection("NpmExportWizard");//$NON-NLS-1$
    if (section == null) {
        section = workbenchSettings.addNewSection("NpmExportWizard");//$NON-NLS-1$
    }
    setDialogSettings(section);
}
项目:n4js    文件:ADocSpecExportWizard.java   
/**
 * 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);
}
项目:Hydrograph    文件:Application.java   
public Object start(IApplicationContext context) throws Exception {
    Display display = PlatformUI.createDisplay();
    Shell shell = WorkbenchPlugin.getSplashShell(display);

    if (OSValidator.isWindows() && !PreStartActivity.isDevLaunchMode(context.getArguments())) {
        PreStartActivity activity = new PreStartActivity(shell);
        if (ToolProvider.getSystemJavaCompiler() == null) {
            activity.performPreStartActivity();
        } else {
            activity.updateINIOnJDkUpgrade();
        }
    }
    try {
        Object instanceLocationCheck = checkInstanceLocation(shell, context.getArguments());
        if (instanceLocationCheck != null) {
            WorkbenchPlugin.unsetSplashShell(display);
               context.applicationRunning();
               return instanceLocationCheck;
           }
        int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART)
            return IApplication.EXIT_RESTART;
        else
            return IApplication.EXIT_OK;
    } finally {
        if (display != null) {
            display.dispose();
        }
        Location instanceLoc = Platform.getInstanceLocation();
        if (instanceLoc != null){
            instanceLoc.release();
        }
    }

}
项目:Hydrograph    文件:HydrographInstallationDialog.java   
@Override
protected IDialogSettings getDialogBoundsSettings() {
    IDialogSettings settings = WorkbenchPlugin.getDefault()
            .getDialogSettings();
    IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
    if (section == null) {
        section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
    }
    return section;
}
项目:tlaplus    文件:FilteredItemsSelectionDialog.java   
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);
}
项目:tlaplus    文件:TLCPreferenceInitializer.java   
/**
   * @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_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);
}
  }
项目:cft    文件:ServerDescriptor.java   
@Override
public void configureServer(IServerWorkingCopy wc) throws CoreException {
    Object object = WorkbenchPlugin.createExtension(element, "callback"); //$NON-NLS-1$
    if (object instanceof ServerHandlerCallback) {
        ((ServerHandlerCallback) object).configureServer(wc);
    }
}
项目:yamcs-studio    文件:YamcsStudioActionBarAdvisor.java   
private void removeActionById(String actionSetId) {
    // Use of an internal API is required to remove actions that are provided
    // by including Eclipse bundles.
    ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
    IActionSetDescriptor[] actionSets = reg.getActionSets();
    for (int i = 0; i < actionSets.length; i++) {
        if (actionSets[i].getId().equals(actionSetId)) {
            IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension();
            reg.removeExtension(ext, new Object[] { actionSets[i] });
            return;
        }
    }
}
项目:dockerfoundry    文件:ServerDescriptor.java   
@Override
public void configureServer(IServerWorkingCopy wc) throws CoreException {
    Object object = WorkbenchPlugin.createExtension(element, "callback"); //$NON-NLS-1$
    if (object instanceof ServerHandlerCallback) {
        ((ServerHandlerCallback) object).configureServer(wc);
    }
}
项目:PDFReporter-Studio    文件:MultiPageToolbarEditorPart.java   
/**
 * This method can be used by implementors of {@link MultiPageEditorPart#createPageContainer(Composite)} to deactivate
 * the active inner editor services while their header has focus. A deactivateSite() must have a matching call to
 * activateSite() when appropriate.
 * <p>
 * An new inner editor will have its site activated on a {@link MultiPageEditorPart#pageChange(int)}.
 * </p>
 * <p>
 * <b>Note:</b> This API is evolving in 3.4 and this might not be its final form.
 * </p>
 * 
 * @param immediate
 *          immediately deactivate the legacy keybinding service
 * @param containerSiteActive
 *          Leave the page container site active.
 * @since 3.4
 * @see #activateSite()
 * @see #createPageContainer(Composite)
 * @see #getPageSite(int)
 * @see #PAGE_CONTAINER_SITE
 */
protected final void deactivateSite(boolean immediate, boolean containerSiteActive) {
    // Deactivate the nested services from the last active service locator.
    if (activeServiceLocator != null) {
        activeServiceLocator.deactivate();
        activeServiceLocator = null;
    }

    final int pageIndex = getActivePage();
    final IKeyBindingService service = getSite().getKeyBindingService();
    if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) {
        // There is no selected page, so deactivate the active service.
        if (service instanceof INestableKeyBindingService) {
            final INestableKeyBindingService nestableService = (INestableKeyBindingService) service;
            nestableService.activateKeyBindingService(null);
        } else {
            WorkbenchPlugin
                    .log("MultiPageEditorPart.deactivateSite()   Parent key binding service was not an instance of INestableKeyBindingService.  It was an instance of " + service.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    if (containerSiteActive) {
        IServiceLocator containerSite = getPageContainerSite();
        if (containerSite instanceof INestable) {
            activeServiceLocator = (INestable) containerSite;
            activeServiceLocator.activate();
        }
    }
}
项目:mytourbook    文件:ApplicationWorkbenchWindowAdvisor.java   
@Override
    public void preWindowOpen() {

        final IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

        configurer.setInitialSize(new Point(950, 700));

        configurer.setShowPerspectiveBar(true);
        configurer.setShowCoolBar(true);
        configurer.setShowProgressIndicator(true);

// status line shows photo selection and loading state
//      configurer.setShowStatusLine(false);

        configurer.setTitle(_appTitle);

        final IPreferenceStore uiPrefStore = PlatformUI.getPreferenceStore();

        uiPrefStore.setValue(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, true);
        uiPrefStore.setValue(IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP, true);

        // show memory monitor
        final boolean isMemoryMonitorVisible = _prefStore
                .getBoolean(ITourbookPreferences.APPEARANCE_SHOW_MEMORY_MONITOR);
        uiPrefStore.setValue(IWorkbenchPreferenceConstants.SHOW_MEMORY_MONITOR, isMemoryMonitorVisible);

        hookTitleUpdateListeners(configurer);

        /*
         * display the progress dialog for UI jobs, when pressing the hide button there is no other
         * way to display the dialog again
         */
        WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RUN_IN_BACKGROUND, false);

        // must be initialized early to set photoServiceProvider in the Photo
        TourPhotoManager.restoreState();

        FormatManager.updateDisplayFormats();
    }
项目:OpenSPIFe    文件:AbstractEnsembleProjectExportWizard.java   
/**
    * Creates a wizard for exporting workspace resources to the local file system.
    */
public AbstractEnsembleProjectExportWizard() {
       IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
       IDialogSettings section = workbenchSettings
               .getSection("FileSystemExportWizard");//$NON-NLS-1$
       if (section == null) {
        section = workbenchSettings.addNewSection("FileSystemExportWizard");//$NON-NLS-1$
    }
       setDialogSettings(section);
   }
项目:translationstudio8    文件:ApplicationActionBarAdvisor.java   
/**
 * 创建文件菜单
 * @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(newAction);
    menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));
    menu.add(new Separator());
    menu.add(closeAction);
    menu.add(closeAllAction);
    menu.add(refreshAction);
    // menu.add(new Separator("net.heartsome.cat.ts.ui.menu.file.separator"));
    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;
}
项目:translationstudio8    文件:ApplicationActionBarAdvisor.java   
/**
 * 移除无用的菜单项:<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] });
        }
    }
}
项目:translationstudio8    文件:ExportProjectWizard.java   
public ExportProjectWizard() {
    setWindowTitle(Messages.getString("wizard.ExportProjectWizard.title"));
    setNeedsProgressMonitor(true);

     IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
        IDialogSettings section = workbenchSettings
                .getSection("ExportProjectWizard");//$NON-NLS-1$
        if (section == null) {
            section = workbenchSettings.addNewSection("ExportProjectWizard");//$NON-NLS-1$
        }
        setDialogSettings(section);
}
项目:translationstudio8    文件:KeysPreferencePage.java   
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;
}
项目:translationstudio8    文件:KeyController2.java   
/**
 * 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);
}
项目:sadlos2    文件:OwlFileImportWizard.java   
/**
   * Creates a wizard for importing resources into the workspace from
   * the file system.
   */
  public OwlFileImportWizard() {
      IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
      IDialogSettings section = workbenchSettings
              .getSection("OwlFileImportWizard");//$NON-NLS-1$
      if (section == null) {
    section = workbenchSettings.addNewSection("OwlFileImportWizard");//$NON-NLS-1$
}
      setDialogSettings(section);
  }
项目:gef-gwt    文件:WorkbenchPart.java   
/**
 * Fires a property changed event.
 * 
 * @param propertyId
 *            the id of the property that changed
 */
protected void firePropertyChange(final int propertyId) {
    Object[] array = getListeners();
    for (int nX = 0; nX < array.length; nX++) {
        final IPropertyListener l = (IPropertyListener) array[nX];
        try {
            l.propertyChanged(WorkbenchPart.this, propertyId);
        } catch (RuntimeException e) {
            WorkbenchPlugin.log(e);
        }
    }
}
项目:gef-gwt    文件:WorkbenchPart.java   
/**
 * @since 3.3
 */
protected void firePartPropertyChanged(String key, String oldValue,
        String newValue) {
    final PropertyChangeEvent event = new PropertyChangeEvent(this, key,
            oldValue, newValue);
    Object[] l = partChangeListeners.getListeners();
    for (int i = 0; i < l.length; i++) {
        try {
            ((IPropertyChangeListener) l[i]).propertyChange(event);
        } catch (RuntimeException e) {
            WorkbenchPlugin.log(e);
        }
    }
}
项目:tmxeditor8    文件:KeysPreferencePage.java   
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;
}
项目:tmxeditor8    文件:KeyController2.java   
/**
 * 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);
}