欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 三A级做爰片免费观看国产电影 | 999精品嫩草久久久久久99 | 中文字幕成人av | 国产在线精品区 | 青草悠悠视频在线观看 | 欧美一区二区三区在线可观看 | 国产日韩一区二区三区 | 国产精品嫩草影视在线观看 | 四虎免费在线视频 | 久草天堂 | 成人欧美在线观看免费视频 | 成年黄网站在线观看免费 | 舔操| 欧美在线视频一区二区 | 国产人成久久久精品 | 201天天爱天天做 | 毛片2| 国产欧美亚洲精品a | 色人阁网站 | 亚州一区二区三区 | 国产精一区二区 | 亚洲 欧美 日韩中文字幕一区二区 | 日本天天色 | a高清免费毛片久久 | 天海翼一区 | 污视频在线免费播放 | 久久久久成人精品免费播放动漫 | 91传媒蜜桃香蕉在线观看 | 国产午夜精品久久久久小说 | 激情五月色综合婷婷大片 | 国产精品视频分类 | 狠久久 | 国产成人小视频 | 一区二区三区四区国产 | 日本成人在线网站 | 久草成人在线 | 国产成人在线一区二区 | 日本一区视频在线播放 | 中文字幕亚洲精品 | 亚洲视频一区二区 | 一级片网址|