Skip to content

Commit

Permalink
feat: Support SWT Snippets (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknowIfGuestInDream committed Jun 8, 2024
1 parent 9a16b2f commit 115ea2c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
3 changes: 2 additions & 1 deletion examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 32 additions & 0 deletions examples/org.eclipse.swt.snippets/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="window"
label="Window">
<command
commandId="org.eclipse.swt.snippets.launcher"
label="SWT Snippets"
style="push">
</command>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="org.eclipse.swt.snippets.launcher"
name="SWT Snippets">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="org.eclipse.swt.snippets.launcher"
class="org.eclipse.swt.snippets.SnippetHandler" />
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,11 @@
version="0.0.0"
unpack="false"/>

<plugin
id="org.eclipse.swt.snippets"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
11 changes: 4 additions & 7 deletions releng/com.tlcsdm.tlstudio.examples.swt.rcp/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@
<product
name="SWT Examples Product"
application="com.tlcsdm.tlstudio.examples.swt.rcp.application">
<property
name="aboutText"
value="%aboutText" />
<property
name="windowImages"
value="icons/eclipse16.png,icons/eclipse32.png,icons/eclipse48.png,icons/eclipse64.png,icons/eclipse128.png,icons/eclipse256.png" />
Expand All @@ -135,10 +132,10 @@
name="startupProgressRect"
value="0,385,600,15">
</property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
<property
name="preferenceCustomization"
value="plugin_customization.ini">
</property>
</product>
</extension>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 115ea2c

Please sign in to comment.