1 package org
.argeo
.cms
.desktop
;
3 import org
.eclipse
.swt
.SWT
;
4 import org
.eclipse
.swt
.events
.SelectionAdapter
;
5 import org
.eclipse
.swt
.events
.SelectionEvent
;
6 import org
.eclipse
.swt
.graphics
.Point
;
7 import org
.eclipse
.swt
.graphics
.Rectangle
;
8 import org
.eclipse
.swt
.layout
.GridData
;
9 import org
.eclipse
.swt
.layout
.GridLayout
;
10 import org
.eclipse
.swt
.widgets
.Composite
;
11 import org
.eclipse
.swt
.widgets
.Display
;
12 import org
.eclipse
.swt
.widgets
.Shell
;
13 import org
.eclipse
.swt
.widgets
.ToolBar
;
14 import org
.eclipse
.swt
.widgets
.ToolItem
;
16 public class CmsDesktopManager
{
17 private Display display
;
19 private Shell rootShell
;
20 private Shell toolBarShell
;
23 display
= Display
.getCurrent();
25 throw new IllegalStateException("Already a display " + display
);
26 display
= new Display();
31 rootShell
= new Shell(display
, SWT
.NO_TRIM
);
32 // rootShell.setMaximized(true);
33 rootShell
.setFullScreen(true);
34 Rectangle bounds
= display
.getBounds();
36 rootShell
.setSize(bounds
.width
, bounds
.height
);
37 // Point realSize = rootShell.getSize();
38 // rootShell.setBounds(bounds);
39 // Rectangle realBounds = rootShell.getBounds();
41 rootShell
= new Shell(display
, SWT
.SHELL_TRIM
);
42 Rectangle shellArea
= rootShell
.computeTrim(200, 200, 800, 480);
43 rootShell
.setSize(shellArea
.width
, shellArea
.height
);
46 rootShell
.setLayout(new GridLayout(2, false));
47 Composite toolBarArea
= new Composite(rootShell
, SWT
.NONE
);
48 toolBarArea
.setLayoutData(new GridData(toolBarSize
, rootShell
.getSize().y
));
52 toolBarShell
= new Shell(rootShell
, SWT
.NO_TRIM
| SWT
.ON_TOP
);
53 toolBar
= new ToolBar(toolBarShell
, SWT
.VERTICAL
| SWT
.FLAT
| SWT
.BORDER
);
56 toolBarArea
.setLayoutData(new GridData(toolBar
.getSize().x
, toolBar
.getSize().y
));
58 toolBar
= new ToolBar(toolBarArea
, SWT
.VERTICAL
| SWT
.FLAT
| SWT
.BORDER
);
60 toolBarArea
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, false, false));
63 Composite backgroundArea
= new Composite(rootShell
, SWT
.NONE
);
64 backgroundArea
.setLayout(new GridLayout(6, true));
65 DesktopLayer desktopLayer
= new DesktopLayer();
66 desktopLayer
.init(backgroundArea
);
68 // rootShell.layout(true, true);
70 if (toolBarShell
!= null) {
71 toolBarShell
.setLocation(new Point(0, 0));
76 protected void createDock(ToolBar toolBar
) {
78 // toolBar.setLocation(clientArea.x, clientArea.y);
80 ToolItem closeI
= new ToolItem(toolBar
, SWT
.PUSH
);
81 closeI
.setImage(display
.getSystemImage(SWT
.ICON_ERROR
));
82 closeI
.setToolTipText("Close");
83 closeI
.addSelectionListener(new SelectionAdapter() {
86 public void widgetSelected(SelectionEvent e
) {
92 ToolItem searchI
= new ToolItem(toolBar
, SWT
.PUSH
);
93 searchI
.setImage(display
.getSystemImage(SWT
.ICON_QUESTION
));
94 searchI
.setToolTipText("Search");
95 searchI
.addSelectionListener(new SelectionAdapter() {
98 public void widgetSelected(SelectionEvent e
) {
99 // rootShell.dispose();
103 // toolBar.setSize(48, toolBar.getSize().y);
108 while (!rootShell
.isDisposed()) {
109 if (!display
.readAndDispatch())
114 public void dispose() {
115 if (!rootShell
.isDisposed())
119 protected boolean isFullScreen() {
123 public static void main(String
[] args
) {
124 CmsDesktopManager desktopManager
= new CmsDesktopManager();
125 desktopManager
.init();
126 // Runtime.getRuntime().addShutdownHook(new Thread(() ->
127 // desktopManager.dispose(), "Dispose desktop manager"));
128 desktopManager
.run();
129 desktopManager
.dispose();