一些心得

切换perspective和显示view的代码

IWorkbench work = PlatFormUI.getWorkbench();
  work.showPerspective(PERSP_ID, work.getActiveWorkbenchWindow());
  work.getActiveWorkbenchWindow().getActivePage().showView(VIEW_ID);

注册画面的代码放在哪儿最好?
1、application的run()中

public class MyApplication
     implements IPlatformRunnable {

     public Object run(Object args) {
         final Display display = PlatformUI.createDisplay();

 try {
             if (authenticate(display)) {
                 final WorkbenchAdvisor advisor = new MyWorkbenchAdvisor();
              
                 final int returnCode =
                     PlatformUI.createAndRunWorkbench(display, advisor);

                 return
                     (returnCode == PlatformUI.RETURN_RESTART)
                         ? IPlatformRunnable.EXIT_RESTART
                         : IPlatformRunnable.EXIT_OK;
             }

             Platform.endSplash();

             return IPlatformRunnable.EXIT_OK;
         }
         finally {
             display.dispose();
         }
     }

     private boolean authenticate(Display display) {
         final LoginDialog loginDialog =
             new LoginDialog(new Shell(display));

         loginDialog.open();

         return loginDialog.isAuthenticated();
     }
}

2、在workbenchadvisor中

It should also be possible to use IWorkbench.close() or IWorkbenchConfigurer.emergencyClosing() from within WorkbenchAdvisor lifecycle methods like preStartup().

读源码有得

本日读的源码是org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/aboutdialog.java

1、如何定义自己的buttonId

private final static int FEATURES_ID = IDialogConstants.CLIENT_ID + 1;
2、如何取得product

product = Platform.getProduct();

3、如何处理button事件

覆盖protected void buttonPressed(int buttonId) ;

4、如何创建cursor

  final Cursor hand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
        final Cursor busy = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
        setHandCursor(hand);
        setBusyCursor(busy);
        getShell().addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                setHandCursor(null);
                hand.dispose();
                setBusyCursor(null);
                busy.dispose();
            }
        });

5、创建一个ArrayList跟踪待dispose的image,在close事件中dispose them

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值