欧美三区_成人在线免费观看视频_欧美极品少妇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| 特黄一区二区三区 | 欧美成人免费全网站大片 | 欧美2区 | 欧美一级xxx | 欧美一区二区精品 | 久久亚洲春色中文字幕久久 | 国产激情在线观看 | 综合久久亚洲 | 学院传说之三生三世桃花缘 | 天天做天天爱夜夜大爽完整 | 奇米狠狠操 | 91精品最新国内在线播放 | 全免费A敌肛交毛片免费 | 中文字幕高清 | 免费午夜不卡毛片 | 三级黄色片网站 | 亚洲精品久久久久久国产精华液 | 国产小视频免费在线观看 | 激情五月激情综合网 | 天天操天天射天天爽 | 2019中文字幕在线视频 | 欧美一级α片毛片免费观看 | 成人综合视频网 | 欧美日韩亚洲综合另类ac | 中文字幕亚洲一区二区三区 | 久久精品免费一区二区三 | 91精品久久久久久久久久 | 狠狠色丁香婷婷综合久久片 | 日本高清香蕉色视频在线观看 | 久久黄色大片 | 日韩一区二区三区在线视频 | 在线看免费观看日本 | 欧美电影在线观看网站 | 日本高清视频在线播放 | 四虎精品| 久久久.com | 九九99久久精品在免费线bt | 一区二区三区四区在线观看视频 | 国产一区二区免费 |