Skip to content

Commit

Permalink
#21: Added ability to set workspace description in extension and bran…
Browse files Browse the repository at this point in the history
…ding plugin.
  • Loading branch information
scottresnik authored and nedtwigg committed Dec 8, 2016
1 parent 4e0748a commit f24ac1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ private static String rect(int x, int y, int width, int height) {
* The map is used to modify the template files.
*/
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
public static void create(File root, BufferedImage splash, BufferedImage icon, String name, String perspective) throws IOException {
public static void create(File root, BufferedImage splash, BufferedImage icon, String name, String perspective, String description) throws IOException {
String startupMessageRect = rect(MESSAGE_MARGIN, splash.getHeight() - MESSAGE_VOFFSET, splash.getWidth() - 2 * MESSAGE_MARGIN, MESSAGE_HEIGHT);
String startupProgressRect = rect(PROGRESS_MARGIN, splash.getHeight() - PROGRESS_MARGIN - PROGRESS_HEIGHT, splash.getWidth() - 2 * PROGRESS_MARGIN, PROGRESS_HEIGHT);
ImmutableMap<String, Function<String, String>> map = ImmutableMap.of(
"plugin.xml", str -> str.replace("%name%", name)
.replace("%startupMessageRect%", startupMessageRect)
.replace("%startupProgressRect%", startupProgressRect),
.replace("%startupProgressRect%", startupProgressRect)
.replace("%productBlurb%", description),
"plugin_customization.ini", str -> str.replace("org.eclipse.jdt.ui.JavaPerspective", perspective));

FileMisc.cleanDir(root);
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/diffplug/gradle/oomph/OomphIdeExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class OomphIdeExtension implements P2Declarative {
@Nonnull
String name;
@Nonnull
String description;
@Nonnull
String perspective;
@Nonnull
Object ideDir = "build/oomph-ide" + FileMisc.macApp();
Expand All @@ -96,6 +98,7 @@ public OomphIdeExtension(Project project) throws IOException {
this.project = Objects.requireNonNull(project);
this.workspaceRegistry = WorkspaceRegistry.instance();
this.name = project.getRootProject().getName();
this.description = this.name;
this.perspective = Perspectives.RESOURCES;
this.runP2Using = app -> Errors.rethrow().run(() -> app.runUsingBootstrapper(project));
}
Expand Down Expand Up @@ -131,6 +134,11 @@ public void name(String name) {
this.name = Objects.requireNonNull(name);
}

/** Sets the description of the generated IDE. Defaults to name. */
public void description(String description) {
this.description = Objects.requireNonNull(description);
}

/** Sets the starting perspective (window layout), see {@link Perspectives} for common perspectives. */
public void perspective(String perspective) {
this.perspective = Objects.requireNonNull(perspective);
Expand Down Expand Up @@ -348,7 +356,7 @@ void writeBrandingPlugin(File ideDir) throws IOException {
}

File branding = new File(ideDir, FileMisc.macContentsEclipse() + "dropins/com.diffplug.goomph.branding");
BrandingProductPlugin.create(branding, splashImg, iconImg, name, perspective);
BrandingProductPlugin.create(branding, splashImg, iconImg, name, perspective, description);
File bundlesInfo = new File(ideDir, FileMisc.macContentsEclipse() + "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info");
FileMisc.modifyFile(bundlesInfo, content -> {
return content + "com.diffplug.goomph.branding,1.0.0,dropins/com.diffplug.goomph.branding/,4,true" + System.lineSeparator();
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/com/diffplug/gradle/oomph/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<?eclipse version="3.0"?>
<plugin>
<extension id="product" point="org.eclipse.core.runtime.products">
<product name="%name%" application="org.eclipse.ui.ide.workbench" description="%productBlurb">
<product name="%name%" application="org.eclipse.ui.ide.workbench" description="%productBlurb%">
<!-- For documentation on updating icons, see http://wiki.eclipse.org/Platform-releng/Updating_Branding -->
<property name="windowImages" value="eclipse16.png,eclipse32.png,eclipse48.png,eclipse64.png,eclipse128.png,eclipse256.png"/>
<property name="aboutImage" value="eclipse128.png"/>
<property name="aboutText" value="%productBlurb"/>
<property name="aboutText" value="%productBlurb%"/>
<property name="appName" value="%name%"/>
<property name="preferenceCustomization" value="plugin_customization.ini"/>
<property name="applicationXMI" value="org.eclipse.platform/LegacyIDE.e4xmi"/>
Expand Down

0 comments on commit f24ac1b

Please sign in to comment.