user347744
user347744

Reputation: 41

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.

[email protected]

Upvotes: 1

Views: 908

Answers (2)

user347744
user347744

Reputation: 41

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.
...

Upvotes: 1

VonC
VonC

Reputation: 1330102

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.

Upvotes: 1

Related Questions