有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    如果遵循RCP tutorial,您将看到可以定义自己的视图:

    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() {
        }
    }
    

    这将为您提供一个带有自定义文本的视图

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

    如果保留对用于显示某些文本的org.eclipse.swt.widgets.Text的引用,则可以更改该文本

  2. # 2 楼答案

    我的解决方案来自VonC的想法

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