1 package org
.argeo
.slc
.client
.rcp
;
3 import org
.argeo
.security
.ui
.rcp
.SecureWorkbenchWindowAdvisor
;
4 import org
.eclipse
.swt
.SWT
;
5 import org
.eclipse
.swt
.graphics
.Image
;
6 import org
.eclipse
.swt
.graphics
.Point
;
7 import org
.eclipse
.swt
.widgets
.Event
;
8 import org
.eclipse
.swt
.widgets
.Listener
;
9 import org
.eclipse
.swt
.widgets
.Menu
;
10 import org
.eclipse
.swt
.widgets
.MenuItem
;
11 import org
.eclipse
.swt
.widgets
.Shell
;
12 import org
.eclipse
.swt
.widgets
.Tray
;
13 import org
.eclipse
.swt
.widgets
.TrayItem
;
14 import org
.eclipse
.ui
.IWorkbenchWindow
;
15 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
16 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
17 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
20 * Set here initial default size of the UI
25 public class SlcSecureWorkbenchWindowAdvisor
extends
26 SecureWorkbenchWindowAdvisor
{
28 private TrayItem trayItem
;
30 public SlcSecureWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer
) {
34 // public ActionBarAdvisor createActionBarAdvisor(
35 // IActionBarConfigurer configurer) {
36 // return new ApplicationActionBarAdvisor(configurer);
40 public void postWindowOpen() {
45 public boolean preWindowShellClose() {
46 // hide but do not dispose if tray is supported
47 if (trayItem
!= null) {
48 getWindowConfigurer().getWindow().getShell().setVisible(false);
54 /** Init tray support */
55 protected void initTray() {
56 IWorkbenchWindow window
= getWindowConfigurer().getWindow();
57 final Tray tray
= window
.getShell().getDisplay().getSystemTray();
58 trayItem
= new TrayItem(tray
, SWT
.NONE
);
63 Image trayImage
= ClientRcpPlugin
.getDefault().getImageRegistry()
64 .get("argeoTrayIcon");
65 trayItem
.setImage(trayImage
);
66 trayItem
.setToolTipText("Argeo SLC");
69 // TODO: contribute more commands
70 trayItem
.addListener(SWT
.MenuDetect
, new Listener() {
71 public void handleEvent(Event event
) {
72 IWorkbenchWindow window
= getWindowConfigurer().getWindow();
73 Menu menu
= new Menu(window
.getShell(), SWT
.POP_UP
);
74 MenuItem exit
= new MenuItem(menu
, SWT
.NONE
);
76 exit
.addListener(SWT
.Selection
, new Listener() {
77 public void handleEvent(Event event
) {
78 getWindowConfigurer().getWorkbenchConfigurer()
79 .getWorkbench().close();
82 menu
.setVisible(true);
86 // add behavior when clicked upon
87 trayItem
.addListener(SWT
.Selection
, new Listener() {
88 public void handleEvent(Event event
) {
89 Shell shell
= getWindowConfigurer().getWindow().getShell();
90 if (shell
.isVisible()) {
91 if (shell
.getMinimized())
92 shell
.setMinimized(false);
94 shell
.setVisible(false);
95 shell
.setMinimized(true);
98 shell
.setVisible(true);
101 shell
.setMinimized(false);
108 public void dispose() {
109 if (trayItem
!= null)