<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 6  文章 - 129  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(14)

    隨筆檔案(6)

    文章分類(467)

    文章檔案(423)

    相冊

    收藏夾(18)

    JAVA

    搜索

    •  

    積分與排名

    • 積分 - 825769
    • 排名 - 49

    最新評論

    閱讀排行榜

    評論排行榜

    package testrcp.app;

    import org.eclipse.jface.action.MenuManager;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.graphics.Point;
    import org.eclipse.swt.graphics.Rectangle;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Tray;
    import org.eclipse.swt.widgets.TrayItem;
    import org.eclipse.ui.IWorkbenchWindow;
    import org.eclipse.ui.application.ActionBarAdvisor;
    import org.eclipse.ui.application.IActionBarConfigurer;
    import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
    import org.eclipse.ui.application.WorkbenchWindowAdvisor;

    public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

     private TrayItem trayItem;//系統托盤對象
     private Image trayImage;//系統托盤圖標對象
     /** 程序的菜單條 */
     private ApplicationActionBarAdvisor actionBarAdvisor;
     
        public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
            super(configurer);
        }
        /** 創建菜單條對象 */
        public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
            actionBarAdvisor = new ApplicationActionBarAdvisor(configurer);
         return actionBarAdvisor;
        }
       
        /** 打開窗口前調用該方法,對窗口初始化設置 */
        public void preWindowOpen() {
            IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
            configurer.setInitialSize(new Point(600, 400));
            configurer.setShowCoolBar(true);//工具欄
            configurer.setShowStatusLine(false);//狀態欄
           
            configurer.setShowPerspectiveBar(true);//透視圖
            configurer.setShowProgressIndicator(true);//進度條
           
            final IWorkbenchWindow window = super.getWindowConfigurer().getWindow();
            /** 創建系統托盤 */
            trayItem = initTrayItem(window);
            /** 如果支持系統托盤,則創建托盤的菜單 */
            if(trayItem != null) {
             createPopupMenu(window);
            }
        }
       
        /**
      * 創建系統托盤菜單
      *
      * @param window
      *            工作臺窗口對象
      */
        private void createPopupMenu(final IWorkbenchWindow window) {
      trayItem.addListener(SWT.MenuDetect, new Listener() {

       @Override
       public void handleEvent(Event event) {
        MenuManager trayMenu = new MenuManager();
        Menu menu = trayMenu.createContextMenu(window.getShell());
        /**
         * 調用fillTrayItem方法創建系統托盤對象,可以直接利用菜單欄中的操作 而不需要,重新創建操作
         */
        actionBarAdvisor.fillTrayItem(trayMenu);
        menu.setVisible(true);
       }
       
      });
      
     }

     /**
      * 初始化系統托盤對象
      *
      * @param window
      *            工作臺窗口對象
      * @return 該程序所對應的系統托盤對象
      */
     private TrayItem initTrayItem(IWorkbenchWindow window) {
      final Tray tray = Display.getCurrent().getSystemTray();
      if(tray == null)
       return null;
      TrayItem trayItem = new TrayItem(tray, SWT.NONE);
      trayImage = Activator.getImageDescriptor("icons/logo.gif").createImage();
      trayItem.setImage(trayImage);
      trayItem.setToolTipText("System Tray");
      
      return trayItem;
     }

     @Override
     public void postWindowOpen() {
      //窗口居中顯示
      Shell shell = getWindowConfigurer().getWindow().getShell();
      Rectangle screenSize = Display.getDefault().getClientArea();
      Rectangle frameSize = shell.getBounds();
      shell.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
     }
       
     /** 釋放窗口,釋放系統托盤 */
     public void dispose() {
      if (trayImage != null) {
       trayImage.dispose();
       trayItem.dispose();
      }
     }

    }



    posted on 2008-12-05 23:42 Ke 閱讀(914) 評論(0)  編輯  收藏 所屬分類: eclipse RCP
    主站蜘蛛池模板: 成人网站免费观看| 国产高清免费的视频| 国产精品亚洲综合专区片高清久久久| 亚洲精品一二三区| 香港经典a毛片免费观看看| 狼友av永久网站免费观看| 亚洲av片不卡无码久久| 无码国产精品一区二区免费虚拟VR| 久久久久亚洲av无码专区喷水| 亚洲精品日韩一区二区小说| 成年大片免费视频| 亚洲欧美国产日韩av野草社区| 女人体1963午夜免费视频| 亚洲欧洲免费视频| 中文字幕天天躁日日躁狠狠躁免费| 久久精品国产亚洲AV电影| h在线观看视频免费网站| 精品亚洲成A人无码成A在线观看 | 亚洲国产日韩在线| 久久久久久免费视频| 亚洲精品无码专区| 亚洲毛片不卡av在线播放一区| aaa毛片免费观看| 白白国产永久免费视频| japanese色国产在线看免费| 噜噜嘿在线视频免费观看| 激情无码亚洲一区二区三区 | 亚洲中文字幕AV每天更新| 亚洲电影日韩精品| 久久中文字幕免费视频| 亚洲一区免费视频| 亚洲伦乱亚洲h视频| 91香蕉在线观看免费高清| 亚洲国产精品美女久久久久| 国产成人高清亚洲| 日本片免费观看一区二区| 看免费毛片天天看| 亚洲国产人成在线观看69网站| 啦啦啦中文在线观看电视剧免费版 | 亚洲国产精品乱码一区二区| 国产麻豆剧传媒精品国产免费|