一些心得

切换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

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

一些心得

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭