From 76d4205ee382818c1bd0c5a3bb84d738f5278751 Mon Sep 17 00:00:00 2001 From: Jiri Kaplan Date: Mon, 25 Jan 2021 16:03:39 +0100 Subject: [PATCH] Introducing com.eclipsesource.megit.plugin to have more control. Should fix issue #8. Should implement things mentioned in #2. --- com.eclipsesource.megit.parent/pom.xml | 1 + com.eclipsesource.megit.plugin/.classpath | 7 +++ com.eclipsesource.megit.plugin/.gitignore | 1 + com.eclipsesource.megit.plugin/.project | 28 ++++++++++++ .../LegacyIDE.e4xmi | 38 ++++++++++++++++ .../META-INF/MANIFEST.MF | 19 ++++++++ .../build.properties | 7 +++ com.eclipsesource.megit.plugin/plugin.xml | 24 ++++++++++ .../plugin_customization.ini | 2 +- com.eclipsesource.megit.plugin/pom.xml | 15 +++++++ .../eclipsesource/megit/plugin/Activator.java | 44 +++++++++++++++++++ .../eclipsesource/megit/plugin/LifeCycle.java | 40 +++++++++++++++++ .../build.properties | 3 +- .../feature.xml | 6 +++ com.eclipsesource.megit.product/megit.product | 7 +-- 15 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 com.eclipsesource.megit.plugin/.classpath create mode 100644 com.eclipsesource.megit.plugin/.gitignore create mode 100644 com.eclipsesource.megit.plugin/.project create mode 100644 com.eclipsesource.megit.plugin/LegacyIDE.e4xmi create mode 100644 com.eclipsesource.megit.plugin/META-INF/MANIFEST.MF create mode 100644 com.eclipsesource.megit.plugin/build.properties create mode 100644 com.eclipsesource.megit.plugin/plugin.xml rename {com.eclipsesource.megit.product.feature => com.eclipsesource.megit.plugin}/plugin_customization.ini (86%) create mode 100644 com.eclipsesource.megit.plugin/pom.xml create mode 100644 com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/Activator.java create mode 100644 com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/LifeCycle.java diff --git a/com.eclipsesource.megit.parent/pom.xml b/com.eclipsesource.megit.parent/pom.xml index e91f9c8..0ca4977 100644 --- a/com.eclipsesource.megit.parent/pom.xml +++ b/com.eclipsesource.megit.parent/pom.xml @@ -38,6 +38,7 @@ ../com.eclipsesource.megit.product + ../com.eclipsesource.megit.plugin ../com.eclipsesource.megit.product.feature ../com.eclipsesource.megit.target diff --git a/com.eclipsesource.megit.plugin/.classpath b/com.eclipsesource.megit.plugin/.classpath new file mode 100644 index 0000000..eca7bdb --- /dev/null +++ b/com.eclipsesource.megit.plugin/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/com.eclipsesource.megit.plugin/.gitignore b/com.eclipsesource.megit.plugin/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/com.eclipsesource.megit.plugin/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/com.eclipsesource.megit.plugin/.project b/com.eclipsesource.megit.plugin/.project new file mode 100644 index 0000000..c1b6866 --- /dev/null +++ b/com.eclipsesource.megit.plugin/.project @@ -0,0 +1,28 @@ + + + com.eclipsesource.megit.plugin + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.eclipsesource.megit.plugin/LegacyIDE.e4xmi b/com.eclipsesource.megit.plugin/LegacyIDE.e4xmi new file mode 100644 index 0000000..2866dbf --- /dev/null +++ b/com.eclipsesource.megit.plugin/LegacyIDE.e4xmi @@ -0,0 +1,38 @@ + + + + + + + + + stretch + + + Draggable + + + Draggable + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.eclipsesource.megit.plugin/META-INF/MANIFEST.MF b/com.eclipsesource.megit.plugin/META-INF/MANIFEST.MF new file mode 100644 index 0000000..18dbb33 --- /dev/null +++ b/com.eclipsesource.megit.plugin/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plugin +Bundle-SymbolicName: com.eclipsesource.megit.plugin;singleton:=true +Bundle-Version: 0.0.1.qualifier +Bundle-Activator: com.eclipsesource.megit.plugin.Activator +Bundle-Vendor: ECLIPSESOURCE +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.e4.ui.di, + org.eclipse.e4.ui.workbench, + org.eclipse.e4.ui.model.workbench, + org.eclipse.osgi.services, + org.eclipse.e4.core.di.annotations, + org.eclipse.e4.core.contexts, + javax.inject +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.eclipsesource.megit.plugin +Bundle-ActivationPolicy: lazy diff --git a/com.eclipsesource.megit.plugin/build.properties b/com.eclipsesource.megit.plugin/build.properties new file mode 100644 index 0000000..2eb3155 --- /dev/null +++ b/com.eclipsesource.megit.plugin/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin_customization.ini,\ + LegacyIDE.e4xmi diff --git a/com.eclipsesource.megit.plugin/plugin.xml b/com.eclipsesource.megit.plugin/plugin.xml new file mode 100644 index 0000000..b657fae --- /dev/null +++ b/com.eclipsesource.megit.plugin/plugin.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/com.eclipsesource.megit.product.feature/plugin_customization.ini b/com.eclipsesource.megit.plugin/plugin_customization.ini similarity index 86% rename from com.eclipsesource.megit.product.feature/plugin_customization.ini rename to com.eclipsesource.megit.plugin/plugin_customization.ini index 119026b..5bad722 100644 --- a/com.eclipsesource.megit.product.feature/plugin_customization.ini +++ b/com.eclipsesource.megit.plugin/plugin_customization.ini @@ -2,4 +2,4 @@ eclipse.preferences.version=1 org.eclipse.core.resources/encoding=UTF-8 org.eclipse.ui/defaultPerspectiveId=org.eclipse.egit.ui.GitRepositoryExploring org.eclipse.ui/SHOW_MEMORY_MONITOR=true -org.eclipse.ui/showIntro=false +org.eclipse.ui/showIntro=false \ No newline at end of file diff --git a/com.eclipsesource.megit.plugin/pom.xml b/com.eclipsesource.megit.plugin/pom.xml new file mode 100644 index 0000000..076edaf --- /dev/null +++ b/com.eclipsesource.megit.plugin/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + com.eclipsesource.megit + com.eclipsesource.megit.parent + 0.0.1-SNAPSHOT + ../com.eclipsesource.megit.parent + + com.eclipsesource.megit.plugin + eclipse-plugin + diff --git a/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/Activator.java b/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/Activator.java new file mode 100644 index 0000000..f1d411c --- /dev/null +++ b/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/Activator.java @@ -0,0 +1,44 @@ +package com.eclipsesource.megit.plugin; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.eclipsesource.megit.plugin"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/LifeCycle.java b/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/LifeCycle.java new file mode 100644 index 0000000..1956efc --- /dev/null +++ b/com.eclipsesource.megit.plugin/src/com/eclipsesource/megit/plugin/LifeCycle.java @@ -0,0 +1,40 @@ +package com.eclipsesource.megit.plugin; + +import java.util.List; + +import javax.inject.Inject; + +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.di.UIEventTopic; +import org.eclipse.e4.ui.model.application.MApplication; +import org.eclipse.e4.ui.model.application.ui.MUIElement; +import org.eclipse.e4.ui.workbench.IPresentationEngine; +import org.eclipse.e4.ui.workbench.UIEvents; +import org.eclipse.e4.ui.workbench.modeling.EModelService; +import org.osgi.service.event.Event; + +public class LifeCycle { + + private static final String FIRST_RUN_TAG = "firstRunTag"; + private static final String EDITOR_AREA = "org.eclipse.ui.editorss"; + + @Optional + @Inject + public void minimizeEditorAreaOnAppStartup( + @UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) final Event event, EModelService modelService, + MApplication app) { + MUIElement editorArea = modelService.find(EDITOR_AREA, app); + if (shouldMinimize(editorArea)) { + editorArea.getTags().add(IPresentationEngine.MINIMIZED); + editorArea.getTags().add(FIRST_RUN_TAG); + } + } + + private boolean shouldMinimize(MUIElement element) { + if (element != null) { + List tags = element.getTags(); + return !tags.contains(FIRST_RUN_TAG) && !tags.contains(IPresentationEngine.MINIMIZED); + } + return false; + } +} diff --git a/com.eclipsesource.megit.product.feature/build.properties b/com.eclipsesource.megit.product.feature/build.properties index 7b756fb..b045d39 100644 --- a/com.eclipsesource.megit.product.feature/build.properties +++ b/com.eclipsesource.megit.product.feature/build.properties @@ -1,2 +1 @@ -bin.includes = feature.xml -root=file:plugin_customization.ini +bin.includes = feature.xml \ No newline at end of file diff --git a/com.eclipsesource.megit.product.feature/feature.xml b/com.eclipsesource.megit.product.feature/feature.xml index 98daee6..b221fc7 100644 --- a/com.eclipsesource.megit.product.feature/feature.xml +++ b/com.eclipsesource.megit.product.feature/feature.xml @@ -17,4 +17,10 @@ [Enter License Description here.] + + diff --git a/com.eclipsesource.megit.product/megit.product b/com.eclipsesource.megit.product/megit.product index c65d86f..0bd6dcf 100644 --- a/com.eclipsesource.megit.product/megit.product +++ b/com.eclipsesource.megit.product/megit.product @@ -1,8 +1,7 @@ - - + @@ -17,14 +16,12 @@ - - @@ -323,9 +320,9 @@ version(s), and exceptions or additional permissions here}." + -