diff --git a/cobigen-eclipse/cobigen-eclipse-feature/pom.xml b/cobigen-eclipse/cobigen-eclipse-feature/pom.xml index 8e02f39315..706e825c4a 100644 --- a/cobigen-eclipse/cobigen-eclipse-feature/pom.xml +++ b/cobigen-eclipse/cobigen-eclipse-feature/pom.xml @@ -14,7 +14,6 @@ false - true diff --git a/cobigen-eclipse/cobigen-eclipse-test/pom.xml b/cobigen-eclipse/cobigen-eclipse-test/pom.xml index 2f18ede16e..9d7d23bbd7 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/pom.xml +++ b/cobigen-eclipse/cobigen-eclipse-test/pom.xml @@ -12,7 +12,6 @@ ${surefireArgLineIntegration} -Xms512m -Xmx2048m -XX:+DisableExplicitGC - true diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenGUITest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenGUITest.java new file mode 100644 index 0000000000..bea75c98c4 --- /dev/null +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/OpenGUITest.java @@ -0,0 +1,59 @@ +package com.devonfw.cobigen.eclipse.test; + +import java.io.File; + +import org.apache.commons.io.FileUtils; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.devonfw.cobigen.eclipse.test.common.SystemTest; +import com.devonfw.cobigen.eclipse.test.common.utils.EclipseCobiGenUtils; +import com.devonfw.cobigen.eclipse.test.common.utils.EclipseUtils; + +/** + * Class for testing Manage Template Sets with a click on the Home Button + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class OpenGUITest extends SystemTest { + + /** Root path of the Test Resources */ + private static final String resourcesRootPath = "src/main/resources/OpenAPITest/"; + + /** + * Setup workbench appropriately for tests + * + * @throws Exception test fails + */ + @BeforeClass + public static void setupClass() throws Exception { + + EclipseUtils.cleanWorkspace(bot, true); + } + + /** + * Testing to open the Template Set Management GUI and clicking Home Button + * + * @throws Exception test fails + */ + @Test + public void testOpenTemplateSetManagementGUI() throws Exception { + + // copy sample project to external location and import it into the workspace + String testProjName = "ExtTestProj"; + IJavaProject project = this.tmpMavenProjectRule.createProject(testProjName); + FileUtils.copyFile(new File(resourcesRootPath + "input/adapt-templates.yml"), + project.getUnderlyingResource().getLocation().append("adapt-templates.yml").toFile()); + project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + this.tmpMavenProjectRule.updateProject(); + + // open GUI + EclipseCobiGenUtils.runAndCaptureManageTemplateSets(bot); + } + +} diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java index 0bd01c5ee6..d9a44afa69 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/common/utils/EclipseCobiGenUtils.java @@ -404,6 +404,28 @@ public static void runAndCaptureAdaptTemplates(SWTWorkbenchBot bot) throws Excep informationDialog.bot().button("Ok").click(); } + /** + * Checks the CobiGen Manage Template Sets and takes screenshots of it. + * + * @param bot to process the Manage Template Sets command + * @throws Exception test fails + */ + public static void runAndCaptureManageTemplateSets(SWTWorkbenchBot bot) throws Exception { + + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); + bot.waitUntil(new AllJobsAreFinished(), DEFAULT_TIMEOUT); // build might take some time + + SWTBotView view = bot.viewById(JavaUI.ID_PACKAGES); + view.bot().tree().contextMenu("CobiGen").menu("Manage Template Sets...").click(); + bot.waitUntil(new AnyShellIsActive("Template Set Manager"), DEFAULT_TIMEOUT); + + takeScreenshot(bot, "Template Set Manager"); + SWTBotShell gui = bot.shell("Template Set Manager"); + // TODO + gui.bot().button("#").click(); + + } + /** * Takes a screenshot (*.jpeg) of the current screen encoding test method and class and appends the given identifier * to the file name diff --git a/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF b/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF index 15712fc71c..34835a1d87 100644 --- a/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF +++ b/cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF @@ -66,6 +66,15 @@ Bundle-ClassPath: ., lib/paranamer.jar, lib/slf4j-api.jar, lib/txw2.jar, - lib/zt-exec.jar + lib/zt-exec.jar, + lib/gui.jar, + lib/javafx-base.jar, + lib/javafx-base-win.jar, + lib/javafx-controls.jar, + lib/javafx-controls-win.jar, + lib/javafx-fxml.jar, + lib/javafx-fxml-win.jar, + lib/javafx-graphics.jar, + lib/javafx-graphics-win.jar Export-Package: com.devonfw.cobigen.eclipse.common.constants.external, com.devonfw.cobigen.eclipse.common.tools diff --git a/cobigen-eclipse/cobigen-eclipse/build.properties b/cobigen-eclipse/cobigen-eclipse/build.properties index 64d6a6e2a5..3637ba0744 100644 --- a/cobigen-eclipse/cobigen-eclipse/build.properties +++ b/cobigen-eclipse/cobigen-eclipse/build.properties @@ -49,4 +49,13 @@ bin.includes = .,\ lib/paranamer.jar,\ lib/slf4j-api.jar,\ lib/txw2.jar,\ - lib/zt-exec.jar + lib/zt-exec.jar,\ + lib/gui.jar,\ + lib/javafx-base.jar,\ + lib/javafx-base-win.jar,\ + lib/javafx-controls.jar,\ + lib/javafx-controls-win.jar,\ + lib/javafx-fxml.jar,\ + lib/javafx-fxml-win.jar,\ + lib/javafx-graphics.jar,\ + lib/javafx-graphics-win.jar diff --git a/cobigen-eclipse/cobigen-eclipse/plugin.xml b/cobigen-eclipse/cobigen-eclipse/plugin.xml index c5deb9d123..d8d6e14612 100644 --- a/cobigen-eclipse/cobigen-eclipse/plugin.xml +++ b/cobigen-eclipse/cobigen-eclipse/plugin.xml @@ -20,7 +20,7 @@ name="Adapt Template"> diff --git a/cobigen-eclipse/cobigen-eclipse/pom.xml b/cobigen-eclipse/cobigen-eclipse/pom.xml index 732aa69a4d..eff89f5c1a 100644 --- a/cobigen-eclipse/cobigen-eclipse/pom.xml +++ b/cobigen-eclipse/cobigen-eclipse/pom.xml @@ -13,8 +13,6 @@ false - false - true diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/ManageTemplateSetsHandler.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/ManageTemplateSetsHandler.java index 2abc107d65..aa88164524 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/ManageTemplateSetsHandler.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/ManageTemplateSetsHandler.java @@ -5,15 +5,13 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.devonfw.cobigen.eclipse.common.tools.ResourcesPluginUtil; import com.devonfw.cobigen.gui.AppLauncher; /** - * TODO nneuhaus This type ... + * Handler for the Package-Explorer Event * */ public class ManageTemplateSetsHandler extends AbstractHandler { @@ -23,12 +21,10 @@ public class ManageTemplateSetsHandler extends AbstractHandler { */ private static final Logger LOG = LoggerFactory.getLogger(ManageTemplateSetsHandler.class); - public AppLauncher launcher; - /** - * Location of workspace root + * Launcher for GUI */ - IPath ws = ResourcesPluginUtil.getWorkspaceLocation(); + public AppLauncher launcher; @Override public Object execute(ExecutionEvent event) throws ExecutionException { @@ -38,12 +34,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException { try { wait(1337); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } while (this.launcher.app.window.isShowing()) { - TimeUnit.SECONDS.sleep(1); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + e.printStackTrace(); + } } return null; diff --git a/cobigen-eclipse/pom.xml b/cobigen-eclipse/pom.xml index 2ec7ef8031..638c25a381 100644 --- a/cobigen-eclipse/pom.xml +++ b/cobigen-eclipse/pom.xml @@ -15,6 +15,7 @@ https://oss.sonatype.org/content/groups/public/ https://download.eclipse.org/releases/photon + 11 diff --git a/cobigen-gui/gui/.classpath b/cobigen-gui/gui/.classpath index 32ea7d01ae..7bc6c5ddac 100644 --- a/cobigen-gui/gui/.classpath +++ b/cobigen-gui/gui/.classpath @@ -23,5 +23,10 @@ + + + + + diff --git a/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/App.java b/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/App.java index e521693463..304871c0c1 100644 --- a/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/App.java +++ b/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/App.java @@ -7,6 +7,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.image.Image; import javafx.stage.Stage; public class App extends Application { @@ -53,10 +54,15 @@ public void start(Stage stage) throws IOException { scene = new Scene(loadFXML("primary")); scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm()); + Image image = new Image(App.class.getResource("icons/devon-icon.jpg").toExternalForm()); + this.window.getIcons().add(image); + this.window.setTitle("Template Set Manager"); + this.window.setScene(scene); this.window.showAndWait(); // stage.setScene(scene); // stage.show(); + } static void setRoot(String fxml) throws IOException { @@ -70,9 +76,4 @@ private static Parent loadFXML(String fxml) throws IOException { return fxmlLoader.load(); } - public static void main(String[] args) { - - launch(); - } - } diff --git a/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/AppLauncher.java b/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/AppLauncher.java index 9d13004e7a..fc1d6fe284 100644 --- a/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/AppLauncher.java +++ b/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/AppLauncher.java @@ -21,17 +21,17 @@ public void run() { this.app.printSomething(); } - // public static void main(String[] args) { - // - // new Thread() { - // @Override - // public void run() { - // - // javafx.application.Application.launch(App.class); - // } - // }.start(); - // App app = App.waitForApp(); - // app.printSomething(); - // } + public static void main(String[] args) { + + new Thread() { + @Override + public void run() { + + javafx.application.Application.launch(App.class); + } + }.start(); + App app = App.waitForApp(); + app.printSomething(); + } } diff --git a/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/icons/devon-icon.jpg b/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/icons/devon-icon.jpg new file mode 100644 index 0000000000..b6867b41e6 Binary files /dev/null and b/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/icons/devon-icon.jpg differ diff --git a/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/primary.fxml b/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/primary.fxml index 4b7aff6f89..66e547b63d 100644 --- a/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/primary.fxml +++ b/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/primary.fxml @@ -18,7 +18,7 @@ - + diff --git a/cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/styles.css b/cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/styles.css similarity index 100% rename from cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/styles.css rename to cobigen-gui/gui/src/main/resources/com/devonfw/cobigen/gui/styles.css