<scope>test</scope>
</dependency>
- <!-- SWT for ARM -->
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.swt.gtk.linux.arm</artifactId>
- <version>3.108.0.v20180905-1254</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.swt.gtk.linux.aarch64</artifactId>
- <version>3.109.0.202003311246</version>
- </dependency>
-
- <!-- Additional text components (not in RCP distribution) -->
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.text</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.jface.text</artifactId>
- </dependency>
-
- <!-- SWT and JFace -->
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.swt</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.jface</artifactId>
- </dependency>
+ <!-- SWT native -->
<dependency>
<groupId>org.argeo.tp.rcp.e4</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
<!-- <artifactId>org.eclipse.swt.gtk.linux.ppc64le</artifactId> -->
<!-- </dependency> -->
-
-
- <!-- Eclipse launcher -->
+ <!-- SWT for ARM -->
<dependency>
<groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.equinox.launcher</artifactId>
+ <artifactId>org.eclipse.swt.gtk.linux.arm</artifactId>
+ <version>3.108.0.v20180905-1254</version>
</dependency>
<dependency>
<groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.equinox.launcher.gtk.linux.x86_64</artifactId>
+ <artifactId>org.eclipse.swt.gtk.linux.aarch64</artifactId>
+ <version>3.109.0.202003311246</version>
</dependency>
+
+
+ <!-- Eclipse launcher -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
+ <!-- <artifactId>org.eclipse.equinox.launcher</artifactId> -->
+ <!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
+ <!-- <artifactId>org.eclipse.equinox.launcher.gtk.linux.x86_64</artifactId> -->
+ <!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
<!-- <artifactId>org.eclipse.equinox.launcher.gtk.linux.x86</artifactId> -->
<!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
+ <!-- <artifactId>org.eclipse.equinox.launcher.cocoa.macosx.x86_64</artifactId> -->
+ <!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
+ <!-- <artifactId>org.eclipse.equinox.launcher.win32.win32.x86_64</artifactId> -->
+ <!-- </dependency> -->
+ <!-- <dependency> -->
+ <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
+ <!-- <artifactId>org.eclipse.equinox.launcher.win32.win32.x86</artifactId> -->
+ <!-- </dependency> -->
+
+ <!-- SWT JFace -->
<dependency>
<groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.equinox.launcher.cocoa.macosx.x86_64</artifactId>
+ <artifactId>org.eclipse.swt</artifactId>
</dependency>
<dependency>
<groupId>org.argeo.tp.rcp.e4</groupId>
- <artifactId>org.eclipse.equinox.launcher.win32.win32.x86_64</artifactId>
+ <artifactId>org.eclipse.jface</artifactId>
</dependency>
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.rcp.e4</groupId> -->
- <!-- <artifactId>org.eclipse.equinox.launcher.win32.win32.x86</artifactId> -->
- <!-- </dependency> -->
+
+ <!-- Additional text components (not in RCP distribution) -->
+ <dependency>
+ <groupId>org.argeo.tp.rcp.e4</groupId>
+ <artifactId>org.eclipse.text</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.tp.rcp.e4</groupId>
+ <artifactId>org.eclipse.jface.text</artifactId>
+ </dependency>
+
<!-- RCP -->
<dependency>
--- /dev/null
+package org.argeo.minidesktop;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/** Icons. */
+public class MiniDesktopImages {
+
+ public final Image homeIcon;
+ public final Image exitIcon;
+
+ public final Image terminalIcon;
+ public final Image browserIcon;
+ public final Image explorerIcon;
+ public final Image textEditorIcon;
+
+ public final Image folderIcon;
+ public final Image fileIcon;
+
+ public MiniDesktopImages(Display display) {
+ homeIcon = loadImage(display, "nav_home@2x.png");
+ exitIcon = loadImage(display, "delete@2x.png");
+
+ terminalIcon = loadImage(display, "console_view@2x.png");
+ browserIcon = loadImage(display, "external_browser@2x.png");
+ explorerIcon = loadImage(display, "fldr_obj@2x.png");
+ textEditorIcon = loadImage(display, "cheatsheet_obj@2x.png");
+
+ folderIcon = loadImage(display, "fldr_obj@2x.png");
+ fileIcon = loadImage(display, "file_obj@2x.png");
+ }
+
+ static Image loadImage(Display display, String path) {
+ InputStream stream = MiniDesktopImages.class.getResourceAsStream(path);
+ if (stream == null)
+ throw new IllegalArgumentException("Image " + path + " not found");
+ Image image = null;
+ try {
+ image = new Image(display, stream);
+ } catch (SWTException ex) {
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException ex) {
+ }
+ }
+ return image;
+ }
+}
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
private final boolean fullscreen;
private final boolean stacking;
+ private MiniDesktopImages images;
+
public MiniDesktopManager(boolean fullscreen, boolean stacking) {
this.fullscreen = fullscreen;
this.stacking = stacking;
}
public void init() {
+ Display.setAppName("Mini SWT Desktop");
display = Display.getCurrent();
if (display != null)
throw new IllegalStateException("Already a display " + display);
display = new Display();
+ images = new MiniDesktopImages(display);
+
int toolBarSize = 48;
if (isFullscreen()) {
Rectangle bounds = display.getBounds();
rootShell.setSize(bounds.width, bounds.height);
} else {
- rootShell = new Shell(display, SWT.SHELL_TRIM);
+ rootShell = new Shell(display, SWT.CLOSE | SWT.RESIZE);
Rectangle shellArea = rootShell.computeTrim(200, 200, 800, 480);
rootShell.setSize(shellArea.width, shellArea.height);
+ rootShell.setText(Display.getAppName());
+ rootShell.setImage(images.terminalIcon);
}
rootShell.setLayout(noSpaceGridLayout(new GridLayout(2, false)));
} else {
toolBar = new ToolBar(toolBarArea, SWT.VERTICAL | SWT.FLAT | SWT.BORDER);
createDock(toolBar);
- toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+ toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
}
if (isStacking()) {
- tabFolder = new CTabFolder(rootShell, SWT.MULTI);
+ tabFolder = new CTabFolder(rootShell, SWT.MULTI | SWT.BORDER | SWT.BOTTOM);
+ tabFolder.setLayout(noSpaceGridLayout(new GridLayout()));
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Color selectionBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
+ tabFolder.setSelectionBackground(selectionBackground);
+// tabFolder.setSelectionForeground(selectionBackground);
+// tabFolder.setSelectionBackground(
+// new Color[] { display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLUE) },
+// new int[] { 100 }, true);
+
// background
Control background = createBackground(tabFolder);
- CTabItem noCloseItem = new CTabItem(tabFolder, SWT.NONE);
- noCloseItem.setText("Home");
- noCloseItem.setControl(background);
+ CTabItem homeTabItem = new CTabItem(tabFolder, SWT.NONE);
+ homeTabItem.setText("Home");
+ homeTabItem.setImage(images.homeIcon);
+ homeTabItem.setControl(background);
+ tabFolder.setFocus();
} else {
- createBackground(rootShell);
+ if (isFullscreen())
+ createBackground(rootShell);
+ else
+ rootShell.pack();
}
rootShell.open();
protected void createDock(ToolBar toolBar) {
// Terminal
- addToolItem(toolBar, display.getSystemImage(SWT.ICON_INFORMATION), "Terminal", () -> {
+ addToolItem(toolBar, images.terminalIcon, "Terminal", () -> {
String url = System.getProperty("user.home");
- AppContext appContext = createAppParent();
+ AppContext appContext = createAppParent(images.terminalIcon);
new MiniTerminal(appContext.getAppParent(), url) {
@Override
});
// Web browser
- addToolItem(toolBar, display.getSystemImage(SWT.ICON_QUESTION), "Browser", () -> {
- String url = "https://duckduckgo.com/";
- AppContext appContext = createAppParent();
+ addToolItem(toolBar, images.browserIcon, "Browser", () -> {
+ String url = "https://start.duckduckgo.com/";
+ AppContext appContext = createAppParent(images.browserIcon);
new MiniBrowser(appContext.getAppParent(), url, false, false) {
@Override
protected void titleChanged(String title) {
});
// File explorer
- addToolItem(toolBar, display.getSystemImage(SWT.ICON_WARNING), "Explorer", () -> {
+ addToolItem(toolBar, images.explorerIcon, "Explorer", () -> {
String url = System.getProperty("user.home");
- AppContext appContext = createAppParent();
+ AppContext appContext = createAppParent(images.explorerIcon);
new MiniExplorer(appContext.getAppParent(), url) {
@Override
openApp(appContext);
});
+ // Separator
+ new ToolItem(toolBar, SWT.SEPARATOR);
+
// Exit
- addToolItem(toolBar, display.getSystemImage(SWT.ICON_ERROR), "Exit", () -> rootShell.dispose());
+ addToolItem(toolBar, images.exitIcon, "Exit", () -> rootShell.dispose());
toolBar.pack();
}
});
}
- protected AppContext createAppParent() {
+ protected AppContext createAppParent(Image icon) {
if (isStacking()) {
- Composite appParent = new Composite(tabFolder, SWT.NONE);
+ Composite appParent = new Composite(tabFolder, SWT.CLOSE);
appParent.setLayout(noSpaceGridLayout(new GridLayout()));
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
+ item.setImage(icon);
item.setControl(appParent);
return new AppContext(item);
} else {
- Shell shell = new Shell(rootShell, SWT.SHELL_TRIM);
+ Shell shell = new Shell(rootShell.getDisplay(), SWT.SHELL_TRIM);
+ shell.setImage(icon);
return new AppContext(shell);
}
}
shell.setSize(new Point(800, 480));
}
if (appContext.tabItem != null) {
+ tabFolder.setFocus();
tabFolder.setSelection(appContext.tabItem);
}
}