锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 鍘熸潵鏄緗簡榪欎釜瀵艱嚧鐨?/p> configurer.setSaveAndRestore(true);
瑙e喅鏂規硶:
浠g爜濡備笅:
涓銆佸悓鏃跺叧闂墍鏈夋墦寮鐨剉iew
鍦╲iew涓?鍙湁涓涓猚lose,姣忔鍙兘鍏抽棴褰撳墠紿楀彛
鍦╡clipse鐨勭紪杈戠獥鍙g殑鏍囬涓婄偣鍙抽敭,閲岄潰鏈?close All
鍙互浣跨敤閬嶅巻鐨勬柟娉曪紝閬嶅巻鎵鏈夋墦寮鐨刅iew錛岀劧鍚庡皢鍏墮殣钘忥細
AsyncUtil.asyncExec(new Runnable()
{
public void run()
{
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference[] iViewReferences = page.getViewReferences();
for (IViewReference iViewReference: iViewReferences)
if (!ID.equals(iViewReference.getId()))
page.hideView(iViewReference);
}
});
浜屻丷CP涓駭鐢熺洰鏍囧尯鐨凚ar
浜х敓綰㈢嚎鍖哄煙鐨凚ar,瀹炵幇鏂規硶濡備笅錛?br />
1銆佽繖涓槸perspective錛岃鍒涘緩澶氫釜perspective錛岀劧鍚庤緗煇涓負active
2銆佸湪WorkbenchWindowAdvisor涓璸reWindowOpen鍐咃紝鍔犱笅闈㈣繖孌典唬鐮?br />
public void preWindowOpen() {
IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
IWorkbenchPreferenceConstants.TOP_RIGHT);
apiStore.setValue(
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
false);
}
3銆侀渶瑕佸姞 config.setShowPespectivebar(true);
涓夈丷CP欏圭洰錛嶏紞紿楀彛鍏抽棴浜嬩歡
鍦ˋpplicationWorkbenchWindowAdvisor涓璷verride
public boolean preWindowShellClose() {
// do nothing, but allow the close() to proceed
MessageBox msgBox = new MessageBox(new Shell(), SWT.YES|SWT.NO|SWT.ICON_QUESTION);
msgBox.setText("閫鍑虹郴緇?);
msgBox.setMessage("紜畾閫鍑虹郴緇?");
if(msgBox.open()==SWT.YES){
return true;
}
return false;
}
浠ュ悗浣跨敤IWorkbenchWindow鐨刧etShell().close();閮戒細璋冪敤璇ュ浠g爜.
鍥涖佸湪RCP涓璁$晫闈㈤傚悎妗岄潰澶у皬
final int screenWidth = Display.getCurrent().getBounds().width;
final int screenHeight = Display.getCurrent().getBounds().height;
浜斻乀reeviewer涓氳繃浠g爜錛岄変腑鏍戜笂鐨勬煇涓猲ode鑺傜偣
StructuredSelection sel=new StructuredSelection(node);
tree.setSelected(sel);
鍏乀reeViewer瀹炵幇鍙屽嚮灞曞紑銆佸叧闂?nbsp;
private class DoubleEventPro implements MouseListener {
public void mouseDoubleClick(MouseEvent e) {
TreeItem item = viewer.getTree().getItem(new Point(e.x, e.y));
if (item != null && item.getItem(0).getText().trim().length() == 0) {
viewer.expandToLevel(item.getData(), 1);
return;
}
if (item != null && item.getItemCount() > 0
&& item.getItem(0).getText().trim().length() > 0) {
item.setExpanded(!item.getExpanded());
}
}
public void mouseDown(MouseEvent e) {
}
public void mouseUp(MouseEvent e) {
}
}
涓冦?濡備綍灞忚斀鎺夎鍥劇獥鍙d笂鐨勫彸閿脊鍑鴻彍鍗曪紵
鏂規硶涓錛氬湪 postWindowOpen() 涓墽琛屼笅闈㈣鍙?
PlatformUI.getWorkbench().getDisplay().addFilter(SWT.MouseUp, new Listener() {
public void handleEvent(final Event event) {
if(event.widget == your editor && event.button == 3) {
int hwndCursor = OS.GetCapture ();
OS.PostMessage(hwndCursor, OS.WM_LBUTTONDOWN, hwndCursor, OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16));
}
}
});
鍏跺畠錛歰rg.eclipse.ui.internal.presentations.util鍖呬腑鐨凷tandardViewSystemMenu綾繪帶鍒剁潃榪欎簺鑿滃崟錛岃繕娌℃潵寰楁ヤ粩緇嗙爺絀訛紝鐮旂┒榪囧悗鍐嶈ˉ鍏?/font>
鍏佸湪浣跨敤tableviewer鐨勬椂鍊欏鍏ュぇ閲忔暟鎹殑闂
鍒涘緩浜嗕竴涓猼ableviewer錛岀劧鍚庝嬌鐢╯etInput鏂規硶瀵煎叆鏁版嵁錛屽鏋滄暟鎹噺寰堝ぇ鐨勮瘽鏍規湰灝辨棤鏁堢巼鍙█浜嗭紝浠ヤ笅鏄嚑縐嶈В鍐崇殑鏂規硶錛?/font>
鏂規硶涓錛氶氳繃縐誨姩婊氬姩鏉℃潵杈懼埌鑷姩鍔犺澆鐨勭洰鐨勶紝鍦ㄦ粴鍔ㄦ潯鐨勪簨浠朵腑鍔犲叆緲婚〉鐨勪唬鐮侊紝鍙互鍙傝冦奅clipse浠庡叆闂ㄥ埌綺鵑氥嬬浜岀増鐨凱383
鏂規硶浜岋細鍒嗛〉鏄劇ず錛?/font>http://www.eclipseworld.org/bbs/read-cec-tid-11678-keyword-table.html錛?/font>
鏂規硶涓夛細浣跨敤 Virtual Tables錛孞Face3.2鐨刅iewer宸茬粡鏀寔SWT.VIRTUAL鏍峰紡
http://www.eclipse.org/articles/Article-SWT-Virtual/Virtual-in-SWT.html
1 int COUNT = 10000;
2 final String [] itemStrings = new String [COUNT];
3 for (int i = 0; i < COUNT; i++) {
4 itemStrings = "item " + i;
5 }
6 final Table table = new Table(parent, SWT.BORDER | SWT.VIRTUAL);
7 table.addListener(SWT.SetData, new Listener() {
8 public void handleEvent(Event event) {
9 TableItem item = (TableItem)event.item;
10 int index = event.index;
11 item.setText(itemStrings [index]);
12 }
13 });
14 table.setItemCount(COUNT);
涔濄佸湪閫忚鍥懼揩鎹鋒柟寮忔爮涓悓鏃舵樉紺哄涓忚鍥懼揩鎹鋒柟寮?/font>
濡傛灉鍦ㄧ▼搴忎腑鍋氫簡澶氫釜涓忚鍥撅紝榛樿鍙樉紺哄垵濮嬮忚鍥懼揩鎹鋒柟寮忥紝姣忔閮借 鎵撳紑閫忚鍥鋸斺攐ther錛岀壒楹葷儲錛屾墍浠ワ紝涓涓嬫彁渚涗袱縐嶆柟娉曪細
1銆佸湪鍒囨崲鏍忎腑鏄劇ず
public class PIMWorkbenchAdvisor extends WorkbenchAdvisor {
@Override
public void postStartup() {
super.postStartup();
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
//2007.01.11 璁劇疆鍚屾椂鏄劇ず澶氫釜閫忚鍥炬爣
PerspectiveBarManager barManager=((WorkbenchWindow)activeWorkbenchWindow).getPerspectiveBar();
if(barManager != null){
IPerspectiveDescriptor mailPerspective =
WorkbenchPlugin.getDefault().getPerspectiveRegistry
().findPerspectiveWithId("MyWork_mail.perspective");
PerspectiveBarContributionItem item=new
PerspectiveBarContributionItem(mailPerspective,activeWorkbenchWindow.getActivePage());
barManager.addItem(item);
}
}
2銆佸湪涓嬫媺妗嗕腑(shortcut)鏄劇ず
public class UiPerspective implements IPerspectiveFactory
{
public void createInitialLayout(IPageLayout layout){
....
//澧炲姞閫忚鍥?br />
layout.addPerspectiveShortcut("net.sf.pim.plugin.UiPerspective");
layout.addPerspectiveShortcut("MyWork_mail.perspective");
}
}
鍗併佹帶鍒?#8220;鏈榪戞墦寮鏂囨。”鐨勪釜鏁?br />
RCP涓湪緇ф壙ActionBarAdvisor鐨勭被涓畾涔?
private IContributionItem reOpenAction = ContributionItemFactory.REOPEN_EDITORS.create(window);
鐒跺悗鍦╢illMenuBar(IMenuManager menuBar)鏂規硶涓坊鍔犱笂闈㈢殑aciton
榪愯鏃?#8220;鏈榪戞墦寮鐨勬枃妗?#8221;鍙湁4涓紝濡傛灉鎯寵嚜宸辨帶鍒?#8220;鏈榪戞墦寮鐨勬枃妗?#8221;鐨勬暟閲忥紝鍒欒緗竴涓媁orkbench涓殑鍒濆鍖栭閫夐」鏃禦ECENT_FILES鐨勯粯璁ゅ弬鏁板煎錛?br />
WorkbenchPlugin.getDefault().getPreferenceStore().setDefault(IPreferenceConstants.RECENT_FILES,10);
鍗佷竴銆佽緗瓻clipse RCP紼嬪簭鐨勫瑙傚拰棣栭夐」
RCP搴旂敤紼嬪簭鐨勭己鐪佸瑙傛槸涓涓┖鐧界獥鍙o紝涓鑸垜浠閫氳繃涓涓猈orkbenchAdvisor綾誨鐣岄潰榪涜瀹氬埗銆?
WorkbenchAdvisor鏈夊緢澶氬洖璋冩柟娉曪紝鍙互鍦╬reWindowOpen()鏂規硶閲岃緗彍鍗曘佸伐鍏鋒潯銆佺姸鎬佹爮銆佽繘搴︽爮銆侀忚鍥懼垏鎹㈠伐鍏鋒槸鍚﹀彲
瑙侊紝鍦╢illActionBars()鏂規硶閲屾坊鍔犺彍鍗曞拰宸ュ叿鏉¢」錛屽湪getInitialWindowPerspectiveId()鏂規硶閲屾寚瀹氶閫夌殑
閫忚鍥俱?/font>
緙虹渷鎯呭喌涓嬶紝閫忚鍥懼垏鎹㈠伐鍏蜂綅浜庣獥鍙e乏涓婅錛屽湪Eclipse閲屽彲浠ラ氳繃Window->Preferences-> Workbench->Appearance鏀瑰彉瀹冪殑浣嶇疆錛岄偅涔堟庢牱鐢ㄧ▼搴忔帶鍒跺畠鍛紵鏈変袱涓柟娉曪紝絎竴涓槸浣跨敤濡備笅浠g爜璁劇疆 IPreferenceStore涓殑鍙橀噺錛?/font>
IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);
鍙︿竴涓柟娉曟槸鍦╬lugin鎵鍦ㄧ洰褰曞緩涓涓悕涓簆lugin_customization.ini鐨勬枃浠訛紝閲岄潰鍐欏涓嬪唴瀹癸細
your.plugin.id/DOCK_PERSPECTIVE_BAR=topRight
鍏朵粬涓巔lugin鐩稿叧鐨凱reference鍊煎彲浠ョ敤鍚屾牱鏂規硶璁劇疆銆?/font>
Update:鍦ㄦ渶鏂扮殑Eclipse 3.1M5a鐗堟湰涓紝瀵筊CP搴旂敤紼嬪簭鑿滃崟鍜屽伐鍏鋒潯鐨勫畾鍒舵柟娉曟湁鎵鏀瑰彉錛屽簲璇ヤ嬌鐢ㄦ柊鍔犲叆鐨凙ctionBarAdvisor綾繪潵瀹屾垚姝ら」宸ヤ綔銆?/font>
鍗佷簩銆佽幏寰楄嚜宸卞紑鍙戠殑plugin琚畨瑁呯殑鐩綍
/** *//**
* @return 鏈彃浠剁殑瀹夎璺緞
*/
public String getInstallDir() ...{
if (installPath == null) ...{
URL localUrl = null;
try ...{
localUrl = FileLocator.toFileURL(getDefault().getBundle()
.getEntry("/"));
installPath = localUrl.getFile().substring(1);
} catch (Exception e) ...{
log(e);
}
}
return installPath;
}
杞夎嚜http://duguanglong002.blog.163.com/blog/static/26955626200955415545/
棣栧厛瑕佸姞鍏clipse鐨勮獮璦鍖咃紝瀹樻柟鏈夋彁渚?a >www.eclipse.org娉ㄦ剰閬╃敤鐨勭増鏈?br />
瑕佸垏鎻涗笉鍚岀殑鐣岄潰瑾炶█錛屽彧闇鐨勫揩鎹烽張鎺ヤ腑鍔犲叆鍙冩暩錛?br />
-nl "zh_CN" 綈¢珨涓枃
-nl "zh_TW" 綣侀珨涓枃
-nl "en_US" 鑻辨枃
C:\Program Files\eclipse\eclipse.exe -nl "en_US"
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
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.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public class HookSysTray {
private TrayItem trayItem;
public HookSysTray() {
}
public void createSysTray(final IWorkbenchWindow window) {
trayItem = initTrayItem(window);
if(trayItem != null) {
trayPopupMenu(window);
trayMinimize(window);
}
}
//鏈灝忓寲鍒伴P
private void trayMinimize(final IWorkbenchWindow window) {
// TODO Auto-generated method stub
window.getShell().addShellListener(new ShellAdapter(){
@Override
public void shellIconified(ShellEvent e) {
// TODO Auto-generated method stub
window.getShell().setVisible(false);
}
});
trayItem.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event event) {
// TODO Auto-generated method stub
Shell shell = window.getShell();
if(!shell.isVisible()) {
shell.setVisible(true);
window.getShell().setMinimized(false);
}
}
});
}
//棰朠鍑鴻彍?
private void trayPopupMenu(final IWorkbenchWindow window) {
// TODO Auto-generated method stub
trayItem.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
// TODO Auto-generated method stub
MenuManager trayMenu = new MenuManager();
Menu menu = trayMenu.createContextMenu(window.getShell());
fillTrayItem(trayMenu, window);
menu.setVisible(true);
}
});
}
//閫犻P鑿滈浘
private void fillTrayItem(IMenuManager trayMenu, final IWorkbenchWindow window) {
Action exitSystem = new Action("閫鍑虹郴緄盵&E]",
AbstractUIPlugin.imageDescriptorFromPlugin(
IAppConstants.APPLICATION_ID, IImagekey.EXIT_STSTEN)) {
@Override
public void run() {
// TODO Auto-generated method stub
PlatformUI.getWorkbench().close();
}
};
trayMenu.add(exitSystem);
}
//鍒濆鍖?br />
private TrayItem initTrayItem(IWorkbenchWindow window) {
// TODO Auto-generated method stub
final Tray tray = window.getShell().getDisplay().getSystemTray();
if(tray == null)
return null;
trayItem = new TrayItem(tray, SWT.NONE);
trayItem.setImage(CacheImage.getInstance().getImage(
IAppConstants.APPLICATION_ID, IImagekey.WINDOW_IMAGE));
trayItem.setToolTipText(IAppConstants.APPLICATION_TITLE);
return trayItem;
}
//鏈灝忓寲紼嬪紡紿楀彛
public void windowMinimized(final Shell shell) {
shell.setMinimized(true);
shell.setVisible(false);
}
//
public void disponse() {
if(trayItem != null)
trayItem.dispose();
}
}
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public class CacheImage {
private final Map<String, Image> imageMap = new HashMap<String, Image>();
private static CacheImage INSTANCE = null;
private CacheImage(){
}
//鍠緥
public static CacheImage getInstance() {
if(INSTANCE == null)
INSTANCE = new CacheImage();
return INSTANCE;
}
//鐛插緱鍦栫墖
public Image getImage(String applicationId, String imageName) {
if(imageName == null)
return null;
Image image = imageMap.get(imageName);
if(image == null) {
image = AbstractUIPlugin.imageDescriptorFromPlugin(applicationId,
imageName).createImage();//鎳夌敤紼嬪簭鐨処D錛屽湒鐗囩殑璺緫
imageMap.put(imageName, image);
}
return image;
}
//dispose璩囨簮
public void dispose() {
Iterator<Image> iterator = imageMap.values().iterator();
while(iterator.hasNext())
iterator.next().dispose();
imageMap.clear();
}
}
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.views.IViewDescriptor;
public class ShowViewAction extends Action implements IWorkbenchAction {
private IWorkbenchWindow workbenchWindow;
private IViewDescriptor desc;
public ShowViewAction(IWorkbenchWindow window, IViewDescriptor desc) {
super("");
/** 鑾峰緱瑙嗗浘鐨勫悕縐?*/
String label = desc.getLabel();
/** 璁劇疆鎿嶄綔鐨勫悕縐?*/
setText(label);
/** 璁劇疆鎿嶄綔鐨勫浘鏍囦負瑙嗗浘鐨勫浘鏍?*/
setImageDescriptor(desc.getImageDescriptor());
/** 璁劇疆鎿嶄綔鐨勬彁紺烘枃鏈?*/
setToolTipText(label);
setId("ShowView" + desc.getId());
this.workbenchWindow = window;
this.desc = desc;
}
@Override
public void run() {
/** 鑾峰緱褰撳墠宸ヤ綔鍖哄強鑾峰緱宸ヤ綔欏甸潰 */
IWorkbenchPage page = workbenchWindow.getActivePage();
/** 濡傛灉欏甸潰涓嶄負null */
if (page != null) {
try {
/** 鏄劇ず瑙嗗浘 */
page.showView(desc.getId());
} catch (PartInitException e) {
ErrorDialog.openError(workbenchWindow.getShell(), "鎵撳紑瑙嗗浘閿欒
錛?, e.getMessage(), e.getStatus());
}
}
}
@Override
public void dispose() {
workbenchWindow = null;
}
}
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.views.IViewDescriptor;
public class ActionManager {
public static IWorkbenchAction createHelloWorldAction(IWorkbenchWindow window) {
if(window == null)
throw new IllegalArgumentException();
IWorkbenchAction helloWorldAction = new HelloWorldAction(window);
return helloWorldAction;
}
/**鑾峰緱plugin.xml鏂囦歡涓厤緗殑瑙嗗浘淇℃伅*/
public static IWorkbenchAction createShowViewAction(IWorkbenchWindow window, String viewId) {
if(window == null)
throw new IllegalArgumentException();
IViewDescriptor desc = window.getWorkbench().getViewRegistry().find(viewId);
IWorkbenchAction action = new ShowViewAction(window, desc);
return action;
}
}
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);//宸ュ叿鏍?br />
configurer.setShowStatusLine(false);//鐘舵佹爮
configurer.setShowPerspectiveBar(true);//閫忚鍥?br />
configurer.setShowProgressIndicator(true);//榪涘害鏉?br />
final IWorkbenchWindow window = super.getWindowConfigurer().getWindow();
/** 鍒涘緩緋葷粺鎵樼洏 */
trayItem = initTrayItem(window);
/** 濡傛灉鏀寔緋葷粺鎵樼洏錛屽垯鍒涘緩鎵樼洏鐨勮彍鍗?*/
if(trayItem != null) {
createPopupMenu(window);
}
}
/**
* 鍒涘緩緋葷粺鎵樼洏鑿滃崟
*
* @param window
* 宸ヤ綔鍙扮獥鍙e璞?br />
*/
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);
}
});
}
/**
* 鍒濆鍖栫郴緇熸墭鐩樺璞?br />
*
* @param window
* 宸ヤ綔鍙扮獥鍙e璞?br />
* @return 璇ョ▼搴忔墍瀵瑰簲鐨勭郴緇熸墭鐩樺璞?br />
*/
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();
}
}
}