关闭

一些心得

467人阅读 评论(0) 收藏 举报

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

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:7908次
    • 积分:164
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:2篇
    • 评论:1条
    文章存档
    最新评论