开发者

How to display given contents in View when developing Eclipse Plugin?

e.g. I'd like to show one given string(not fixed one) in one view of my Eclipse plugin,how to开发者_开发技巧 do it?thx.

bb@feijiao.info


If you follow the RCP tutorial, you will see that you can define your own view:

package de.vogella.rcp.intro.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

public class MyView extends ViewPart {

    @Override
    public void createPartControl(Composite parent) {
        Text text = new Text(parent, SWT.BORDER);
        text.setText("Imagine a fantastic user interface here");
    }

    @Override
    public void setFocus() {
    }
}

That will give you a View with a custom text.

alt text http://www.vogella.de/articles/RichClientPlatform/images/addview200.gif

If you keep a reference to the org.eclipse.swt.widgets.Text used to display some text, you can change that text.


my solution from VonC's thought.

//below codes are working for View.
//variable to keep reference to Canvas
private Canvas canvas = null;
...

//copy
public void createPartControl(Composite parent) {
    Canvas canvas = new Canvas(parent, SWT.BORDER | 
            SWT.NO_MERGE_PAINTS | SWT.NONE );
    this.canvas = canvas;
}

//...

//one getter method to get canvas
public Canvas getCanvas(){
    return this.canvas;
}
//////////////////////////////////
//////////////////////////////////
//below codes are working in PopupMenu's action
page.showView("org.act.bpel2automata.views.GraphView");
IViewPart view = page.findView("org.act.bpel2automata.views.GraphView");

//GraphView is defined by myself,               
if(view instanceof GraphView){
    GraphView gView = (GraphView)view;
    Canvas canvas = gView.getCanvas();
}

//other operations,like draw lines or sth.
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜