首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >月食自定义透视改变了进入火星的开普勒

月食自定义透视改变了进入火星的开普勒
EN

Stack Overflow用户
提问于 2016-02-19 03:20:12
回答 1查看 76关注 0票数 0

我正在更新一个现有的RCP 3应用程序从开普勒到火星。它是由另一个人写的,所以当我去的时候,不得不学到很多关于RCP的知识。

开普勒成功的原因是:

代码语言:javascript
复制
public class ShowSelectViewDialogHandler extends DialogHandler {

/**
 * The name of the parameter providing the view identifier.
 */
private static final String VIEW_ID_COMMAND_PARAMETER_NAME = "org.eclipse.ui.views.showView.viewId"; //$NON-NLS-1$
private static final String MAKE_FAST_COMMAND_PARAMETER_NAME = "org.eclipse.ui.views.showView.makeFast"; //$NON-NLS-1$

private final IHandler handler;

/**
 * Creates a new ShowViewHandler that will open the view in its default location.
 */
public ShowSelectViewDialogHandler (final IHandler handler) {
    this.handler = handler;
}

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {
    Object result = null;

    IWorkbenchWindow window = EDMUIApplication.instance().getWorkbenchAdvisor().getWorkbenchWindowAdvisor().getWindow();

    Map<String, String> parameters = event.getParameters();
    String viewId = parameters.get(ShowSelectViewDialogHandler.VIEW_ID_COMMAND_PARAMETER_NAME);
    String makeFast = parameters.get(ShowSelectViewDialogHandler.MAKE_FAST_COMMAND_PARAMETER_NAME);

    if (viewId == null) {
        ShowViewDialog dialog = new ShowViewDialog(window, new EDMUIViewRegistry(EDMUIConstants.CATEGORY_IDS));
        if (dialog.open() == Window.OK) {
            for (IViewDescriptor viewDescriptor : dialog.getSelection()) {
                result = this.openView(window, viewDescriptor.getId(), makeFast);
            }
        }
    } else {
        result = this.openView(window, viewId, makeFast);
    }

    return result;
}

/**
 * Opens the view with the given ID.
 * 
 * @param window - workbench window of the view.
 * @param viewId - id of the view to open.
 * @param makeFast - command parameter.
 * @return result of the handler execution.
 * @throws ExecutionException - if default handler execution fails.
 */
private Object openView(final IWorkbenchWindow window, final String viewId, final String makeFast) throws ExecutionException {
    Object result = null;
    try {
        Parameterization[] parameterization = this.createParameterization(viewId, makeFast, IWorkbenchCommandConstants.VIEWS_SHOW_VIEW);
        result = this.executeDefaultHandler(this.handler, window, parameterization, IWorkbenchCommandConstants.VIEWS_SHOW_VIEW);
    } catch (NotDefinedException ex) {
        throw new ExecutionException(ex.getMessage(), ex);
    }

    return result;
}

/**
 * Creates parameterization for the command.
 * 
 * @param viewId - view id parameter value.
 * @param makeFast - make fast parameter value.
 * @param commandId - id of the command.
 * @return created parameterization.
 * @throws NotDefinedException - if there is no such parameter.
 */
private Parameterization[] createParameterization(final String viewId, final String makeFast, final String commandId) throws NotDefinedException {
    ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
    Command command = commandService.getCommand(IWorkbenchCommandConstants.VIEWS_SHOW_VIEW);

    IParameter viewIdParameter = command.getParameter(ShowSelectViewDialogHandler.VIEW_ID_COMMAND_PARAMETER_NAME);
    IParameter makeFastParameter = command.getParameter(ShowSelectViewDialogHandler.MAKE_FAST_COMMAND_PARAMETER_NAME);
    return new Parameterization[] { new Parameterization(viewIdParameter, viewId), new Parameterization(makeFastParameter, makeFast) };
}

但是现在ShowViewDialog的签名已经改变了。此外,原作者还指出,他的方法是基于ShowViewHandler的,必须有一个更好的更标准的方法来实现同样的影响,即控制我们减少的视图集的显示。

对于如何实现这一点,有什么想法吗?也许有一个教程,我找到了Vogella的一个,但它是相当普遍的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-19 08:27:36

ShowViewDialog是一个内部对话框,所以不应该首先使用它。正如您已经发现的,内部对话框可以在没有警告的情况下更改。

看起来您的代码正在使用您自己的IViewRegistry实现。要坚持只使用官方API,您必须编写自己版本的“显示视图”对话框。这是一个相当简单的对话框,使用FilteredTreeIViewRegistrygetCategoriesgetViews方法。

没有比这更标准的方法了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35496715

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档