From 115ea2c9ff3e595f25ca9905e2b60be9a2d724c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E9=87=8C=E4=B8=8D=E7=9F=A5=E8=BA=AB=E6=98=AF?= =?UTF-8?q?=E5=AE=A2?= Date: Sat, 8 Jun 2024 22:12:46 +0800 Subject: [PATCH] feat: Support SWT Snippets (#71) --- .../META-INF/MANIFEST.MF | 3 +- examples/org.eclipse.swt.snippets/plugin.xml | 32 +++++++++++++++++++ .../eclipse/swt/snippets/SnippetExplorer.java | 4 +-- .../eclipse/swt/snippets/SnippetHandler.java | 15 +++++++++ .../feature.xml | 7 ++++ .../plugin.xml | 11 +++---- .../examples/swt/rcp/Perspective.java | 4 +-- 7 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 examples/org.eclipse.swt.snippets/plugin.xml create mode 100644 examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetHandler.java diff --git a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF index ac46d67..7037343 100644 --- a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF +++ b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.swt.snippets;singleton:=true Bundle-Version: 3.4.0 Bundle-Vendor: %providerName Bundle-Localization: plugin -Require-Bundle: org.eclipse.swt +Require-Bundle: org.eclipse.swt, + org.eclipse.ui Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.swt.snippets Bundle-ActivationPolicy: lazy diff --git a/examples/org.eclipse.swt.snippets/plugin.xml b/examples/org.eclipse.swt.snippets/plugin.xml new file mode 100644 index 0000000..06d1fd2 --- /dev/null +++ b/examples/org.eclipse.swt.snippets/plugin.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetExplorer.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetExplorer.java index 9fa31b3..063ea24 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetExplorer.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetExplorer.java @@ -89,8 +89,8 @@ public class SnippetExplorer { */ private static final int SHUTDOWN_GRACE_TIME_MS = 5000; /** Link to online snippet source. Used if no local source is available. */ - private static final String SNIPPET_SOURCE_LINK_TEMPLATE = "https://github.com/eclipse-platform/" - + "eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/%s.java"; + private static final String SNIPPET_SOURCE_LINK_TEMPLATE = "https://github.com/unknowIfGuestInDream/tlstudio" + + "/tree/master/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/%s.java"; /** * Whether or not SWT support creating of multiple {@link Display} instances on diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetHandler.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetHandler.java new file mode 100644 index 0000000..ef1d290 --- /dev/null +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetHandler.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.snippets; + +import org.eclipse.core.commands.*; + +public class SnippetHandler extends AbstractHandler{ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + try { + SnippetExplorer.main(null); + } catch (Exception e) { + e.printStackTrace(); + } + return Integer.valueOf(0); + } +} diff --git a/features/com.tlcsdm.tlstudio.examples.swt.rcp.feature/feature.xml b/features/com.tlcsdm.tlstudio.examples.swt.rcp.feature/feature.xml index b40bef5..eb8f12a 100644 --- a/features/com.tlcsdm.tlstudio.examples.swt.rcp.feature/feature.xml +++ b/features/com.tlcsdm.tlstudio.examples.swt.rcp.feature/feature.xml @@ -66,4 +66,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/releng/com.tlcsdm.tlstudio.examples.swt.rcp/plugin.xml b/releng/com.tlcsdm.tlstudio.examples.swt.rcp/plugin.xml index 1734924..580b77b 100644 --- a/releng/com.tlcsdm.tlstudio.examples.swt.rcp/plugin.xml +++ b/releng/com.tlcsdm.tlstudio.examples.swt.rcp/plugin.xml @@ -113,9 +113,6 @@ - @@ -135,10 +132,10 @@ name="startupProgressRect" value="0,385,600,15"> - - + + diff --git a/releng/com.tlcsdm.tlstudio.examples.swt.rcp/src/com/tlcsdm/tlstudio/examples/swt/rcp/Perspective.java b/releng/com.tlcsdm.tlstudio.examples.swt.rcp/src/com/tlcsdm/tlstudio/examples/swt/rcp/Perspective.java index e533fa4..8cf4e57 100644 --- a/releng/com.tlcsdm.tlstudio.examples.swt.rcp/src/com/tlcsdm/tlstudio/examples/swt/rcp/Perspective.java +++ b/releng/com.tlcsdm.tlstudio.examples.swt.rcp/src/com/tlcsdm/tlstudio/examples/swt/rcp/Perspective.java @@ -23,8 +23,8 @@ public void createInitialLayout(IPageLayout layout) { layout.createFolder("leftBottom", IPageLayout.TOP, 0.3f, "left").addView(LAYOUT_VIEWID); layout.createFolder("right", IPageLayout.LEFT, 0.5f, layout.getEditorArea()); layout.createFolder("rightTop", IPageLayout.TOP, 0.25f, "right").addView(CONTROL_VIEWID); - layout.createFolder("rightTop1", IPageLayout.TOP, 0.5f, "right").addView(PAINT_VIEWID); - layout.createFolder("rightBottom", IPageLayout.TOP, 0.25f, "right").addView(CONSOLEVIEWID); + layout.createFolder("rightTop1", IPageLayout.TOP, 0.6f, "right").addView(PAINT_VIEWID); + layout.createFolder("rightBottom", IPageLayout.TOP, 0.15f, "right").addView(CONSOLEVIEWID); } }