eclipse插件开发:Hello-world

由于后续要开发eclipse插件,先参考官网文档,写个hello-world

 1. 先创建一个插件工程

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 2. 将自动生成的类SampleView中的代码替换成官网的代码

package com.example.helloworld;

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

public class HelloWorldView extends ViewPart {

    Label label;
    public HelloWorldView() {
    }
    public void createPartControl(Composite parent) {
       label = new Label(parent, SWT.WRAP);
       label.setText("Hello World");
    }
    public void setFocus() {
       // set focus to my widget.  For a label, this doesn't
       // make much sense, but for more complex sets of widgets
       // you would decide which one gets the focus.
    }
}

 

3. 点击菜单栏的Run-Run,会启动一个新的eclipse

4. 在这个新的eclipse中,点击菜单栏的Window-Show View-Other,选择我们新创建的视图

 

 5. 打开之后展示了我们设置的内容,这样一个简单的hello-world插件就做好啦

 

 

 

 

 

 

参考文档:https://help.eclipse.org/latest/index.jsp

posted @ 2022-01-05 18:44  到三国卖栗子  阅读(106)  评论(0编辑  收藏  举报