2016-05-20 5 views
1

EclipseプラグインのパースペクティブにButtons \ DropDownメニューを追加するパターンとは何ですか?Eclipseプラグインパースペクティブのボタンとドロップダウンメニューを追加するパターンとは

明らかに私はSWTを使用してキャンバスに追加できます。しかし、完全なEclipse Workspaceを利用しないことで、私が逃した気がします。

Eclipse-Pluginの開発者は、これに最も適した方法を教えてください。

+0

どこに追加しますか?あなたのビュー/エディタ内?ビューツールバーで?メインメニュー/ツールバーで?それぞれのケースで答えが異なるので、より具体的にする必要があります。 –

+0

それは私の質問です。私はそれらをパースペクティブのキャンバスにボタンとして追加するか、既存のメニューに追加するか、ボタンなどのための別のパースペクティブを用意する必要があります。パースペクティブをリンクすることはできますか? –

+0

パースペクティブは、ビューとエディタの配置であり、ウィンドウ全体を占有します。あなたは、キャンバスをパースペクティブにすることはできません。それは、ビューまたはエディタになければなりません。 –

答えて

1

パースペクティブには、ビュー、エディタ、拡張機能などを含めることができます。ボタン、コンボ、その他のSWTコントロールを追加するには、ビューまたはエディタを使用する必要があります。パースペクティブは、ビュー、エディターなどがeclipseワークベンチでどのように配置されるかを定義します。

eclipseプラグインでは、plugin.xmlファイルが作成されます。その内部には、パースペクティブの拡張を追加することができます。例えば

<extension 
     point="org.eclipse.ui.perspectives"> 
     <perspective 
      class="perspectives.MyPerspective" 
      fixed="true" 
      id="Perspective.myPerspective" 
      name="MyPerspective"> 
     </perspective> 
    </extension> 

あなたは、パースペクティブエクステンションからビューとエディタを追加できます。

<extension 
     point="org.eclipse.ui.perspectiveExtensions"> 
     <perspectiveExtension 
      targetID="Perspective.myPerspective"> 
      <view 
        id="org.eclipse.jdt.ui.PackageExplorer" 
        minimized="false" 
        moveable="false" 
        ratio="0.5" 
        relationship="left" 
        relative="org.eclipse.ui.console.ConsoleView" 
        visible="true"> 
      </view> 
    </perspectiveExtension> 
    </extension> 

ビューおよびエディタは、プログラムによって遠近法で追加できます。

IPerspectiveFactoryを拡張します。 createInitialLayout()内にコードを配置する

public void createInitialLayout(IPageLayout layout){   
     layout.addStandaloneView(MyView.ID, false, IPageLayout.LEFT, 0.25f,layout.getEditorArea()); 

     // Multiple views and editors can be added here with its area and direction. 
     //You can set them moveable false or closable false. If you want them fixed. 
     } 

ビュークラスは次のようになります:

public class MyView extends ViewPart 
{ 
    public static final String ID = "myproject.views.MyView"; 
    // ID is a normal string and could be anything 

    @Override 
    public void createPartControl(Composite parent) { 
    // Here parent is your composite where u can add your SWT controls e.g. 
     Text text = new Text(parent, SWT.BORDER); 
    } 
} 

私はそれが助けを、あなたが訪問することができ、あなたの助けになると思う:

http://www.programcreek.com/2013/02/eclipse-plug-in-development-creat-a-perspective/

または

http://www.vogella.com/tutorials/EclipsePlugin/article.html

+0

良いもの。複数のビューを持つ上のポインタや参照は、パースペクティブなものではありませんか? –

+0

編集された回答をご覧ください。 –

関連する問題