欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

在RCP中實現系統托盤功能

系統 1611 0
在RCP中實現系統托盤功能
在RCP中加入系統托盤功能,類似msn和QQ。功能就不說了。
在RCP的WorkbenchWindowAdvisor的postWindowOpen()中創建系統托盤,另外要override preWindowShellClose()方法,否則按程序右上角的X,整個程序就會被關閉,重寫后實現程序最小化的功能。

ApplicationWorkbenchWindowAdvisor.java

<!--CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt--><style type="text/css"> <!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }--> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = --><!-- = Further information: http://www.java2html.de = -->
<!-- start source code --> <!-- end source code -->
/**
*ApplicationWorkbenchWindowAdvisor.java
*/
package com.mi.pwdgate;

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

import com.mi.pwdgate.util.SystemTrayMaster;

publicclass ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor{

private SystemTrayMastertrayMaster;
/*
*(non-Javadoc)
*
*@seeorg.eclipse.ui.application.WorkbenchWindowAdvisor#postWindowOpen()
*/
public void postWindowOpen(){
createSystemTray();
}

private void createSystemTray(){
trayMaster= new SystemTrayMaster();
trayMaster.createSystemTray();
}

/*
*(non-Javadoc)
*
*@seeorg.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowShellClose()
*/
public boolean preWindowShellClose(){
trayMaster.minimizeWindow();
returnfalse ;
}
}
<!--CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt--><style type="text/css"> <!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }--> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = --><!-- = Further information: http://www.java2html.de = -->
<!-- start source code -->

/**
*SystemTrayMaster.java
*/
package com.mi.pwdgate.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
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.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tray;
import org.eclipse.swt.widgets.TrayItem;
import org.eclipse.ui.PlatformUI;

/**
*@authormoneyice2006-5-9
*/
publicclass SystemTrayMaster implements SelectionListener,Listener{
privatefinalclass RestoreWindowListener extends SelectionAdapter{
public void widgetSelected(SelectionEvente){
restoreWindow();
}
}

private Menumenu;

private MenuItem[]menuItems=new MenuItem[0];

private RestoreWindowListenerrestoreWindowListener;

public SystemTrayMaster(){
this .restoreWindowListener= new RestoreWindowListener();
}

//ClosestheApplication
protected void closeApplication(){
PlatformUI.getWorkbench().close();
}

//clickthetray
public void widgetSelected(SelectionEvente){
}

//doubleclickthetray
public void widgetDefaultSelected(SelectionEvente){
restoreWindow();
}

//Getssystemshell
private ShellgetShell(){
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
}

//MinimizestheWindow
public void minimizeWindow(){
getShell().setMinimized( true );
getShell().setVisible( false );
}

//Restoresthewindow
protected void restoreWindow(){
Shellshell=PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
shell.open();
shell.setMinimized( false );
shell.forceActive();
shell.forceFocus();
}

public void showMenu(){
clearItems();
MenuItemopenItem;
MenuItemcloseItem;
openItem= new MenuItem( this .menu,SWT.PUSH);
closeItem= new MenuItem( this .menu,SWT.NONE);
closeItem.setText("Close");
closeItem.addSelectionListener( new SelectionAdapter(){
public void widgetSelected(SelectionEvente){
closeApplication();
}
});
this .menuItems= new MenuItem[]{openItem,closeItem};

openItem.setText("OpenPasswordGate");
openItem.addSelectionListener( this .restoreWindowListener);
this .menu.setVisible( true );
}

private void clearItems(){
for ( int i=0;i< this .menuItems.length;i++){
MenuItemitem= this .menuItems[i];
item.removeSelectionListener( this .restoreWindowListener);
this .menuItems[i].dispose();
}
}

public void handleEvent(Eventevent){
showMenu();
}

public void createSystemTray(){
//Getssystemtray
Traytray=Display.getDefault().getSystemTray();
//Createstrayitem
TrayItemitem= new TrayItem(tray,SWT.NONE);
item.setText("PasswordGate");
item.setToolTipText("PasswordGate");
//Setsimagefortray
Imageimage=ImageShop.get("default");
item.setImage(image);

item.addSelectionListener( this );
item.addListener(SWT.MenuDetect, this );

menu= new Menu(getShell(),SWT.POP_UP);
}
}

?¨??o???§è???????????

在RCP中實現系統托盤功能


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 成人国产精品免费视频不卡 | 一级一级一级一级毛片 | 欧区一欧区二欧区三史无前例 | 2021精品国产综合久久 | 精品国产第一国产综合精品 | 国产成人精品高清免费 | 亚洲一区二区三区视频 | 欧美日韩在线一区二区三区 | 超碰一区二区三区 | 男女免费在线视频 | 青草青草久热精品视频在线网站 | 免费观看成人碰视频公开 | 欧美在线观看视频 | 精品一区二区三区四区五区 | 国产小视频在线观看免费 | 久热免费在线视频 | 免费人成年短视频在线观看免费网站 | 免费毛片网站 | 国产高清一区 | 激情大乳女做爰办公室韩国 | 大吊一区二区 | 亚洲一区二区视频 | 91在线激情 | 国产亚洲精品久久久久久一区二区 | 亚洲成人精品久久久 | 日本黄色中文字幕 | 狠狠干91 | 免费视频精品一区二区 | 在线观看国产免费高清不卡 | 一呦二呦三呦国产精品 | 9191在线| 成人欧美视频在线观看 | 49pao强力免费打造在线高清 | 99久久久国产精品 | 香蕉久久夜色精品国产小优 | 国产美女www| 国产人成精品一区二区三 | 欧美日批| 亚洲AV国产成人精品区三上 | 精品国产不卡一区二区三区 | 亚洲午夜久久久久久尤物 |