在Eclipse启动时推迟插件自动加载/打开

时间:2017-07-16 08:42:46

标签: eclipse-plugin eclipse-rcp eclipse-pde

我在eclipse中的PDE下创建了一个新的插件。 将其导出为可部署的插件并将其粘贴到eclipse的plugins文件夹中。 在Eclipse的启动时,插件自动加载并与Eclipse底部的控制台和其他窗口堆叠在一起。

我想推迟自动加载/打开。 我希望只有在我通过Show View>My Plugin明确打开它时才能打开它 以下是我的plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin autoStart="false">

   <extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="com.Myplugin.packages.Application">
         </run>
      </application>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            name="Myplugin"
            class="com.Myplugin.packages.Perspective"
            id="Myplugin.perspective">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            name="Myplugin"
            class="com.Myplugin.login.view.OpenView"
            id="Myplugin.view">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="*">
         <view
               closeable="false"
               id="Myplugin.view"
               minimized="false"
               relationship="stack"
               relative="org.eclipse.debug.ui.ModuleView"
               standalone="true"
               visible="true">
         </view>
      </perspectiveExtension>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu">
      </menuContribution>
   </extension>
</plugin>

Perspective.java:

 public class Perspective implements IPerspectiveFactory {
    public void createInitialLayout(IPageLayout layout) {
        try{
        layout.setEditorAreaVisible(false);
        layout.setFixed(true);
        PlatformUI.getWorkbench().getActiveWorkbenchWindow()
            .addPerspectiveListener(new PerspectiveListener());
        }catch(Exception e){
            OpenView.log4jCallingForError("Perspective error : " +getStackTrace(e));
//          Plugin.getLog().log(new Status(Status.INFO, Activator.PLUGIN_ID, Status.OK, e.getMessage(), e));

        }
    }

    public static String getStackTrace(final Throwable throwable) {
         final StringWriter sw = new StringWriter();
         final PrintWriter pw = new PrintWriter(sw, true);
         throwable.printStackTrace(pw);
         return sw.getBuffer().toString();
    }

}

2 个答案:

答案 0 :(得分:0)

您在视图的透视扩展定义中指定了visible="true" - 这使得视图在显示透视图后立即可见。将其替换为visible="false"

注意:您可能必须重置透视图以获取透视定义的更改。

答案 1 :(得分:0)

更改我的视图属性
<view
               closeable="false"
               id="Myplugin.view"
               minimized="false"
               relationship="stack"
               relative="org.eclipse.debug.ui.ModuleView"
               standalone="true"
               visible="true">
         </view>

到这个

<view
           closeable="true"
           id="Myplugin.view:*"
           minimized="false"
           relationship="stack"
           relative="org.eclipse.ui.views.ResourceNavigator"
           standalone="true"
           visible="false">
     </view>

为我工作。