Skip to content

Commit

Permalink
devonfw#1454 Possible to open GUI through Eclipse Plugin; Window Titl…
Browse files Browse the repository at this point in the history
…e & Icon added
  • Loading branch information
NelsonNew committed Nov 7, 2022
1 parent 27797cf commit 641c5ff
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 34 deletions.
1 change: 0 additions & 1 deletion cobigen-eclipse/cobigen-eclipse-feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<properties>
<skip.deployment>false</skip.deployment>
<enforcer.skip>true</enforcer.skip>
</properties>

</project>
1 change: 0 additions & 1 deletion cobigen-eclipse/cobigen-eclipse-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<properties>
<tycho.testArgLine.enriched>${surefireArgLineIntegration} -Xms512m -Xmx2048m -XX:+DisableExplicitGC</tycho.testArgLine.enriched>
<enforcer.skip>true</enforcer.skip>
</properties>

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion cobigen-eclipse/cobigen-eclipse/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
name="Adapt Template">
</command>
<command
id="com.devonfw.cobigen.eclipseplugin.adapt_template"
id="com.devonfw.cobigen.eclipseplugin.manage_template_sets"
name="Manage Template Sets">
</command>
</extension>
Expand Down
2 changes: 0 additions & 2 deletions cobigen-eclipse/cobigen-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

<properties>
<license.skipAggregateDownloadLicenses>false</license.skipAggregateDownloadLicenses>
<skip.deployment>false</skip.deployment>
<enforcer.skip>true</enforcer.skip>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions cobigen-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<properties>
<tycho-repo.url>https://oss.sonatype.org/content/groups/public/</tycho-repo.url>
<eclipse-repository>https://download.eclipse.org/releases/photon</eclipse-repository>
<java.version>11</java.version>
</properties>

<modules>
Expand Down
5 changes: 5 additions & 0 deletions cobigen-gui/gui/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="eclipse-target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="eclipse-target/classes"/>
</classpath>
11 changes: 6 additions & 5 deletions cobigen-gui/gui/src/main/java/com/devonfw/cobigen/gui/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -70,9 +76,4 @@ private static Parent loadFXML(String fxml) throws IOException {
return fxmlLoader.load();
}

public static void main(String[] args) {

launch();
}

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

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane fx:id="outerPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="463.0" prefWidth="652.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.devonfw.cobigen.gui.Controller">
<AnchorPane fx:id="outerPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="463.0" prefWidth="652.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.devonfw.cobigen.gui.Controller">
<children>
<SplitPane fx:id="verticalSplitPane" dividerPositions="0.33008213552361404" prefHeight="463.0" prefWidth="652.0">
<items>
Expand Down

0 comments on commit 641c5ff

Please sign in to comment.