简体   繁体   English

像模式窗口一样打开Eclipse插件视图

[英]Open Eclipse plugin view like a modal window

I have developed an eclipse RCP plugin, which is intended to run as an Eclipse application, and can be extracted as an standalone Eclipse product. 我已经开发了一个eclipse RCP插件,该插件旨在作为Eclipse应用程序运行,并且可以作为独立的Eclipse产品提取。 Now, i want to reuse the same, by adding it as an plugin, so that i can be accessed from within eclipse. 现在,我想通过将其添加为插件来重复使用它,以便可以在Eclipse中访问我。

I am able to install the same into my eclipse workspace and can see the view via Window > Show View . 我可以将其安装到我的Eclipse工作区中,并可以通过Window> Show View看到视图 However the view opens into the area below the editor (along with Console view), instead of opening as a standalone window. 但是,视图将打开到编辑器下方的区域(以及控制台视图),而不是作为独立窗口打开。

Please point me towards a way, by which the View opens in a separate window, just like the 'Search' window. 请为我指出一种方法,通过该方法可以在单独的窗口中打开“视图”,就像“搜索”窗口一样。

The view extends ' ViewPart ' and uses composites. 该视图扩展了“ ViewPart ”并使用复合材料。 Relevant bits from Plugin.xml below: 以下来自Plugin.xml的相关位:

<extension id="application" point="org.eclipse.core.runtime.applications">
      <application>
         <run class="xxx.Application"></run>
      </application>
</extension>
<extension point="org.eclipse.ui.perspectives">
      <perspective name="xxxReview.perspective" class="extension.Perspective" id="xxxReview.perspective">
      </perspective>
</extension>
<extension point="org.eclipse.ui.views">
      <view class="view.xxxView" id="xxxView" name="xxxView" restorable="true">
      </view>
</extension>

If you have your own perspective defined, you can always override 如果定义了自己的视角,则可以始终覆盖

public void createInitialLayout(IPageLayout layout) {
    layout.addStandaloneView(xxxView, false, IPageLayout.TOP, 0.04f, IPageLayout.ID_EDITOR_AREA);
    ...
}

If you need the view to be available in some of native Eclipse perspectives, try perspectiveExtensions with a standalone view 如果您需要该视图在某些本机Eclipse透视图中可用,请尝试使用独立视图的PerspectiveExtensions

<extension point="org.eclipse.ui.views"> 
  <view class="view.xxxView" id="xxxView" name="xxxView" restorable="true" />
</extension>

<extension point="org.eclipse.ui.perspectiveExtensions">
    <perspectiveExtension targetID="*">
        <view id="xxxView" visible="false" standalone="true"
            relative="org.eclipse.ui.views.ResourceNavigator" relationship="bottom" /> 
    </perspectiveExtension>
</extension>

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_perspectiveExtensions.html http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_perspectiveExtensions.html

Finally made it work by extending SWT Dialog. 最终通过扩展SWT对话框使其工作。

public class xxxView extends Dialog {

    /** The file Name Text field. */
    private Text fileNameText;

    /** The constructor. **/
    protected xxxView(Shell parentShell) {
        super(parentShell);
    }

    /** Create Dialog View. **/
    protected Control createDialogArea(Composite parent) {

        //Added View components here.
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM