Forráskód Böngészése

new client with vaadin

Willie 6 éve
szülő
commit
18b26e9a32

+ 1 - 0
SPSEmulator-client/.classpath

@@ -35,5 +35,6 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/SPSEmulator-model"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

+ 4 - 3
SPSEmulator-client/pom.xml

@@ -60,6 +60,7 @@
 					<skipTests>true</skipTests>
 				</configuration>
 			</plugin>
+<!-- 
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-jar-plugin</artifactId>
@@ -92,12 +93,12 @@
 						<goals>
 							<goal>shade</goal>
 						</goals>
-						<!-- <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
-							<mainClass></mainClass> </transformer> </transformers> </configuration> -->
+						<configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
+							<mainClass></mainClass> </transformer> </transformers> </configuration>
 					</execution>
 				</executions>
 			</plugin>
-			<!-- <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> <version>1.7.24</version> 
+ -->			<!-- <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> <version>1.7.24</version> 
 				<executions> <execution> <id>l4j-clui</id> <phase>package</phase> <goals> <goal>launch4j</goal> </goals> <configuration> 
 				<dontWrapJar>false</dontWrapJar> <headerType>console</headerType> <jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar> 
 				<outfile>${project.build.directory}/MCSSPSTools.exe</outfile> <downloadUrl>http://java.com/download</downloadUrl> <classPath> 

+ 3 - 3
SPSEmulator-gui/.classpath

@@ -13,20 +13,20 @@
 	</classpathentry>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
 		<attributes>
+			<attribute name="test" value="true"/>
 			<attribute name="optional" value="true"/>
 			<attribute name="maven.pomderived" value="true"/>
-			<attribute name="test" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
 		<attributes>
+			<attribute name="module" value="true"/>
 			<attribute name="maven.pomderived" value="true"/>
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
 		<attributes>
 			<attribute name="maven.pomderived" value="true"/>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="output" path="target/classes"/>

+ 2 - 2
SPSEmulator-gui/.project

@@ -16,12 +16,12 @@
 			</arguments>
 		</buildCommand>
 		<buildCommand>
-			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
 			<arguments>
 			</arguments>
 		</buildCommand>
 		<buildCommand>
-			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
 			<arguments>
 			</arguments>
 		</buildCommand>

+ 122 - 115
SPSEmulator-gui/pom.xml

@@ -1,136 +1,143 @@
-<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>de.mcs.tools.sps</groupId>
-    <artifactId>spsemulator-gui</artifactId>
-    <name>SPSEmulator-GUI</name>
-    <version>1.0-SNAPSHOT</version>
-    <packaging>war</packaging>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>de.mcs.tools.sps</groupId>
+  <artifactId>spsemulator-gui</artifactId>
+  <name>SPSEmulator-GUI</name>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>war</packaging>
 
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <failOnMissingWebXml>false</failOnMissingWebXml>
+  <properties>
+    <maven.compiler.source>1.8</maven.compiler.source>
+    <maven.compiler.target>1.8</maven.compiler.target>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    <failOnMissingWebXml>false</failOnMissingWebXml>
 
-        <vaadin.version>12.0.5</vaadin.version>
-        <jetty.version>9.4.11.v20180605</jetty.version>
-    </properties>
+    <vaadin.version>12.0.5</vaadin.version>
+    <jetty.version>9.4.11.v20180605</jetty.version>
+  </properties>
 
-    <repositories>
+  <repositories>
         <!-- Repository used by many Vaadin add-ons -->
-        <repository>
-            <id>Vaadin Directory</id>
-            <url>http://maven.vaadin.com/vaadin-addons</url>
-        </repository>
+    <repository>
+      <id>Vaadin Directory</id>
+      <url>http://maven.vaadin.com/vaadin-addons</url>
+    </repository>
         <!-- Repository needed for the prerelease versions of Vaadin -->
-        <repository>
-            <id>vaadin-prereleases</id>
-            <url>https://maven.vaadin.com/vaadin-prereleases</url>
-        </repository>
-    </repositories>
+    <repository>
+      <id>vaadin-prereleases</id>
+      <url>https://maven.vaadin.com/vaadin-prereleases</url>
+    </repository>
+  </repositories>
 
-    <pluginRepositories>
+  <pluginRepositories>
         <!-- Repository needed for the prerelease versions of Vaadin -->
-        <pluginRepository>
-            <id>vaadin-prereleases</id>
-            <url>https://maven.vaadin.com/vaadin-prereleases</url>
-        </pluginRepository>
-    </pluginRepositories>
-
-    <dependencyManagement>
-        <dependencies>
-            <dependency>
-                <groupId>com.vaadin</groupId>
-                <artifactId>vaadin-bom</artifactId>
-                <type>pom</type>
-                <scope>import</scope>
-                <version>${vaadin.version}</version>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
+    <pluginRepository>
+      <id>vaadin-prereleases</id>
+      <url>https://maven.vaadin.com/vaadin-prereleases</url>
+    </pluginRepository>
+  </pluginRepositories>
 
+  <dependencyManagement>
     <dependencies>
-        <dependency>
-            <groupId>com.vaadin</groupId>
-            <artifactId>vaadin-core</artifactId>
-        </dependency>
+      <dependency>
+        <groupId>com.vaadin</groupId>
+        <artifactId>vaadin-bom</artifactId>
+        <type>pom</type>
+        <scope>import</scope>
+        <version>${vaadin.version}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.vaadin</groupId>
+      <artifactId>vaadin-core</artifactId>
+    </dependency>
 
         <!-- Added to provide logging output as Flow uses -->
         <!-- the unbound SLF4J no-operation (NOP) logger implementation -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-        </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+    </dependency>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-            <version>3.1.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils</artifactId>
-            <version>1.9.2</version>
-            <type>jar</type>
-        </dependency>
-    </dependencies>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <version>3.1.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils</artifactId>
+      <version>1.9.2</version>
+      <type>jar</type>
+    </dependency>
+     <dependency>
+      <groupId>de.mcs.tools.sps</groupId>
+      <artifactId>SPSEmulator-client</artifactId>
+      <version>0.0.1-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.eclipse.jetty</groupId>
-                <artifactId>jetty-maven-plugin</artifactId>
-                <version>${jetty.version}</version>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.eclipse.jetty</groupId>
+        <artifactId>jetty-maven-plugin</artifactId>
+        <version>${jetty.version}</version>
+      </plugin>
+    </plugins>
+  </build>
 
-    <profiles>
-        <profile>
+  <profiles>
+    <profile>
             <!-- Production mode can be activated with either property or profile -->
-            <id>production-mode</id>
-            <activation>
-                <property>
-                    <name>vaadin.productionMode</name>
-                </property>
-            </activation>
+      <id>production-mode</id>
+      <activation>
+        <property>
+          <name>vaadin.productionMode</name>
+        </property>
+      </activation>
 
-            <properties>
-                <vaadin.productionMode>true</vaadin.productionMode>
-            </properties>
+      <properties>
+        <vaadin.productionMode>true</vaadin.productionMode>
+      </properties>
 
-            <dependencies>
-                <dependency>
-                    <groupId>com.vaadin</groupId>
-                    <artifactId>flow-server-production-mode</artifactId>
-                </dependency>
-            </dependencies>
+      <dependencies>
+        <dependency>
+          <groupId>com.vaadin</groupId>
+          <artifactId>flow-server-production-mode</artifactId>
+        </dependency>
+      </dependencies>
 
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>com.vaadin</groupId>
-                        <artifactId>vaadin-maven-plugin</artifactId>
-                        <version>${vaadin.version}</version>
-                        <executions>
-                            <execution>
-                                <goals>
-                                    <goal>copy-production-files</goal>
-                                    <goal>package-for-production</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.vaadin</groupId>
+            <artifactId>vaadin-maven-plugin</artifactId>
+            <version>${vaadin.version}</version>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>copy-production-files</goal>
+                  <goal>package-for-production</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
 
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-war-plugin</artifactId>
-                        <version>3.1.0</version>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-war-plugin</artifactId>
+            <version>3.1.0</version>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>

+ 6 - 5
SPSEmulator-gui/src/main/java/de/mcs/tools/sps/ui/MainLayout.java

@@ -30,10 +30,11 @@ import com.vaadin.flow.server.PWA;
 import com.vaadin.flow.server.PageConfigurator;
 
 import de.mcs.tools.sps.ui.views.assemblerview.AssemblerView;
-import de.mcs.tools.sps.ui.views.categorieslist.CategoriesList;
+import de.mcs.tools.sps.ui.views.emulatorview.EmulatorView;
 
 /**
- * The main layout contains the header with the navigation buttons, and the child views below that.
+ * The main layout contains the header with the navigation buttons, and the
+ * child views below that.
  */
 @HtmlImport("frontend://styles/shared-styles.html")
 @PWA(name = "ArduinoSPS/TinySPS", shortName = "ArduinoSPS")
@@ -45,13 +46,13 @@ public class MainLayout extends Div implements RouterLayout, PageConfigurator {
     title.addClassName("main-layout__title");
 
     RouterLink reviews = new RouterLink(null, AssemblerView.class);
-    reviews.add(new Icon(VaadinIcon.LINES), new Text("Assembler"));
+    reviews.add(new Icon(VaadinIcon.LINES), new Text("SPS Assembler"));
     reviews.addClassName("main-layout__nav-item");
     // Only show as active for the exact URL, but not for sub paths
     reviews.setHighlightCondition(HighlightConditions.sameLocation());
 
-    RouterLink categories = new RouterLink(null, CategoriesList.class);
-    categories.add(new Icon(VaadinIcon.COG), new Text("Emulator"));
+    RouterLink categories = new RouterLink(null, EmulatorView.class);
+    categories.add(new Icon(VaadinIcon.COG), new Text("SPS Emulator"));
     categories.addClassName("main-layout__nav-item");
 
     Div navigation = new Div(reviews, categories);

+ 45 - 10
SPSEmulator-gui/src/main/java/de/mcs/tools/sps/ui/views/assemblerview/AssemblerView.java

@@ -3,14 +3,21 @@
  */
 package de.mcs.tools.sps.ui.views.assemblerview;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.flow.component.button.Button;
 import com.vaadin.flow.component.combobox.ComboBox;
-import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.html.H2;
+import com.vaadin.flow.component.html.Label;
+import com.vaadin.flow.component.icon.Icon;
+import com.vaadin.flow.component.icon.VaadinIcon;
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
 import com.vaadin.flow.component.orderedlayout.VerticalLayout;
 import com.vaadin.flow.component.textfield.TextArea;
 import com.vaadin.flow.router.PageTitle;
 import com.vaadin.flow.router.Route;
 
+import de.mcs.tools.sps.emulator.model.Hardware;
 import de.mcs.tools.sps.ui.MainLayout;
 
 /**
@@ -18,13 +25,16 @@ import de.mcs.tools.sps.ui.MainLayout;
  *
  */
 @Route(value = "", layout = MainLayout.class)
-@PageTitle("Assembler")
+@PageTitle("SPS Assembler")
 public class AssemblerView extends VerticalLayout {
 
-  private final H2 header = new H2("SPSAssembler");
+  private final Label header = new Label("SPS Assembler");
   private final TextArea source = new TextArea("source");
-  private final ComboBox<String> hardware = new ComboBox<>("Hardware:");
-  private final ComboBox<String> outputFormat = new ComboBox<>("Output Format:");
+  private final Label lbHardware = new Label("Hardware:");
+  private final ComboBox<String> cbHardware = new ComboBox<>();
+  private final Label lbOutputFormat = new Label("Output Format:");
+  private final ComboBox<String> cbOutputFormat = new ComboBox<>();
+  private final Button btCompile = new Button(new Icon(VaadinIcon.CODE));
 
   /**
    * 
@@ -32,14 +42,22 @@ public class AssemblerView extends VerticalLayout {
   public AssemblerView() {
     initView();
 
-    Div viewToolbar = new Div();
+    initComboBoxes();
+
+    HorizontalLayout viewToolbar = new HorizontalLayout();
     viewToolbar.addClassName("view-toolbar");
-    viewToolbar.add(header);
-    viewToolbar.add(hardware);
-    viewToolbar.add(outputFormat);
+    viewToolbar.add(lbHardware);
+    viewToolbar.add(cbHardware);
+    viewToolbar.add(lbOutputFormat);
+    viewToolbar.add(cbOutputFormat);
+    viewToolbar.add(btCompile);
+    viewToolbar.setVerticalComponentAlignment(Alignment.CENTER, lbHardware, lbOutputFormat);
     add(viewToolbar);
 
+    btCompile.getElement().setAttribute("title", "compile");
+
     VerticalLayout container = new VerticalLayout();
+    container.setPadding(false);
     container.setClassName("view-container");
     container.setAlignItems(Alignment.STRETCH);
     source.setSizeFull();
@@ -47,6 +65,23 @@ public class AssemblerView extends VerticalLayout {
     add(container);
   }
 
+  private void initComboBoxes() {
+    List<String> items = new ArrayList<>();
+    for (Hardware hardwareItem : Hardware.values()) {
+      items.add(hardwareItem.name());
+    }
+    cbHardware.setItems(items);
+    cbHardware.setValue("HOLTEK");
+
+    items = new ArrayList<>();
+    items.add("IntelHEX");
+    items.add("TPSText");
+    items.add("HEXText");
+
+    cbOutputFormat.setItems(items);
+    cbOutputFormat.setValue("IntelHEX");
+  }
+
   private void initView() {
     addClassName("assembler-view");
     setDefaultHorizontalComponentAlignment(Alignment.STRETCH);

+ 0 - 165
SPSEmulator-gui/src/main/java/de/mcs/tools/sps/ui/views/categorieslist/CategoriesList.java

@@ -1,165 +0,0 @@
-/*
- * Copyright 2000-2017 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package de.mcs.tools.sps.ui.views.categorieslist;
-
-import java.util.List;
-
-import com.vaadin.flow.component.button.Button;
-import com.vaadin.flow.component.button.ButtonVariant;
-import com.vaadin.flow.component.grid.Grid;
-import com.vaadin.flow.component.grid.Grid.SelectionMode;
-import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.html.H2;
-import com.vaadin.flow.component.icon.Icon;
-import com.vaadin.flow.component.notification.Notification;
-import com.vaadin.flow.component.notification.Notification.Position;
-import com.vaadin.flow.component.orderedlayout.VerticalLayout;
-import com.vaadin.flow.component.textfield.TextField;
-import com.vaadin.flow.data.renderer.ComponentRenderer;
-import com.vaadin.flow.data.value.ValueChangeMode;
-import com.vaadin.flow.router.PageTitle;
-import com.vaadin.flow.router.Route;
-import de.mcs.tools.sps.backend.Category;
-import de.mcs.tools.sps.backend.CategoryService;
-import de.mcs.tools.sps.backend.Review;
-import de.mcs.tools.sps.backend.ReviewService;
-import de.mcs.tools.sps.ui.MainLayout;
-import de.mcs.tools.sps.ui.common.AbstractEditorDialog;
-
-/**
- * Displays the list of available categories, with a search filter as well as
- * buttons to add a new category or edit existing ones.
- */
-@Route(value = "categories", layout = MainLayout.class)
-@PageTitle("Categories List")
-public class CategoriesList extends VerticalLayout {
-
-    private final TextField searchField = new TextField("",
-            "Search categories");
-    private final H2 header = new H2("Categories");
-    private final Grid<Category> grid = new Grid<>();
-
-    private final CategoryEditorDialog form = new CategoryEditorDialog(
-            this::saveCategory, this::deleteCategory);
-
-    public CategoriesList() {
-        initView();
-
-        addSearchBar();
-        addContent();
-
-        updateView();
-    }
-
-    private void initView() {
-        addClassName("categories-list");
-        setDefaultHorizontalComponentAlignment(Alignment.STRETCH);
-    }
-
-    private void addSearchBar() {
-        Div viewToolbar = new Div();
-        viewToolbar.addClassName("view-toolbar");
-
-        searchField.setPrefixComponent(new Icon("lumo", "search"));
-        searchField.addClassName("view-toolbar__search-field");
-        searchField.addValueChangeListener(e -> updateView());
-        searchField.setValueChangeMode(ValueChangeMode.EAGER);
-
-        Button newButton = new Button("New category", new Icon("lumo", "plus"));
-        newButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
-        newButton.addClassName("view-toolbar__button");
-        newButton.addClickListener(e -> form.open(new Category(),
-                AbstractEditorDialog.Operation.ADD));
-
-        viewToolbar.add(searchField, newButton);
-        add(viewToolbar);
-    }
-
-    private void addContent() {
-        VerticalLayout container = new VerticalLayout();
-        container.setClassName("view-container");
-        container.setAlignItems(Alignment.STRETCH);
-
-        grid.addColumn(Category::getName).setHeader("Name").setWidth("8em")
-                .setResizable(true);
-        grid.addColumn(this::getReviewCount).setHeader("Beverages")
-                .setWidth("6em");
-        grid.addColumn(new ComponentRenderer<>(this::createEditButton))
-                .setFlexGrow(0);
-        grid.setSelectionMode(SelectionMode.NONE);
-
-        container.add(header, grid);
-        add(container);
-    }
-
-    private Button createEditButton(Category category) {
-        Button edit = new Button("Edit", event -> form.open(category,
-                AbstractEditorDialog.Operation.EDIT));
-        edit.setIcon(new Icon("lumo", "edit"));
-        edit.addClassName("review__edit");
-        edit.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
-        if (CategoryService.getInstance().getUndefinedCategory().getId()
-                .equals(category.getId())) {
-            edit.setEnabled(false);
-        }
-        return edit;
-    }
-
-    private String getReviewCount(Category category) {
-        List<Review> reviewsInCategory = ReviewService.getInstance()
-                .findReviews(category.getName());
-        int sum = reviewsInCategory.stream().mapToInt(Review::getCount).sum();
-        return Integer.toString(sum);
-    }
-
-    private void updateView() {
-        List<Category> categories = CategoryService.getInstance()
-                .findCategories(searchField.getValue());
-        grid.setItems(categories);
-
-        if (searchField.getValue().length() > 0) {
-            header.setText("Search for “" + searchField.getValue() + "”");
-        } else {
-            header.setText("Categories");
-        }
-    }
-
-    private void saveCategory(Category category,
-            AbstractEditorDialog.Operation operation) {
-        CategoryService.getInstance().saveCategory(category);
-
-        Notification.show(
-                "Category successfully " + operation.getNameInText() + "ed.",
-                3000, Position.BOTTOM_START);
-        updateView();
-    }
-
-    private void deleteCategory(Category category) {
-        List<Review> reviewsInCategory = ReviewService.getInstance()
-                .findReviews(category.getName());
-
-        reviewsInCategory.forEach(review -> {
-            review.setCategory(
-                    CategoryService.getInstance().getUndefinedCategory());
-            ReviewService.getInstance().saveReview(review);
-        });
-        CategoryService.getInstance().deleteCategory(category);
-
-        Notification.show("Category successfully deleted.", 3000,
-                Position.BOTTOM_START);
-        updateView();
-    }
-}

+ 0 - 73
SPSEmulator-gui/src/main/java/de/mcs/tools/sps/ui/views/categorieslist/CategoryEditorDialog.java

@@ -1,73 +0,0 @@
-/*
- * Copyright 2000-2017 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package de.mcs.tools.sps.ui.views.categorieslist;
-
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-
-import com.vaadin.flow.component.textfield.TextField;
-import com.vaadin.flow.data.validator.StringLengthValidator;
-import de.mcs.tools.sps.backend.Category;
-import de.mcs.tools.sps.backend.CategoryService;
-import de.mcs.tools.sps.backend.ReviewService;
-import de.mcs.tools.sps.ui.common.AbstractEditorDialog;
-
-/**
- * A dialog for editing {@link Category} objects.
- */
-public class CategoryEditorDialog extends AbstractEditorDialog<Category> {
-
-    private final TextField categoryNameField = new TextField("Name");
-
-    public CategoryEditorDialog(BiConsumer<Category, Operation> itemSaver,
-            Consumer<Category> itemDeleter) {
-        super("category", itemSaver, itemDeleter);
-
-        addNameField();
-    }
-
-    private void addNameField() {
-        getFormLayout().add(categoryNameField);
-
-        getBinder().forField(categoryNameField)
-                .withConverter(String::trim, String::trim)
-                .withValidator(new StringLengthValidator(
-                        "Category name must contain at least 3 printable characters",
-                        3, null))
-                .withValidator(
-                        name -> CategoryService.getInstance()
-                                .findCategories(name).size() == 0,
-                        "Category name must be unique")
-                .bind(Category::getName, Category::setName);
-    }
-
-    @Override
-    protected void confirmDelete() {
-        int reviewCount = ReviewService.getInstance()
-                .findReviews(getCurrentItem().getName()).size();
-        if (reviewCount > 0) {
-            openConfirmationDialog("Delete category",
-                    "Are you sure you want to delete the “"
-                            + getCurrentItem().getName()
-                            + "” category? There are " + reviewCount
-                            + " reviews associated with this category.",
-                    "Deleting the category will mark the associated reviews as “undefined”. "
-                            + "You can edit individual reviews to select another category.");
-        } else {
-            doDelete(getCurrentItem());
-        }
-    }
-}

+ 157 - 0
SPSEmulator-gui/src/main/java/de/mcs/tools/sps/ui/views/emulatorview/EmulatorView.java

@@ -0,0 +1,157 @@
+/*
+ * Copyright 2000-2017 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package de.mcs.tools.sps.ui.views.emulatorview;
+
+import java.util.List;
+
+import com.vaadin.flow.component.button.Button;
+import com.vaadin.flow.component.checkbox.CheckboxGroup;
+import com.vaadin.flow.component.checkbox.CheckboxGroupVariant;
+import com.vaadin.flow.component.grid.Grid;
+import com.vaadin.flow.component.grid.Grid.SelectionMode;
+import com.vaadin.flow.component.icon.Icon;
+import com.vaadin.flow.component.icon.VaadinIcon;
+import com.vaadin.flow.component.notification.Notification;
+import com.vaadin.flow.component.notification.Notification.Position;
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
+import com.vaadin.flow.component.orderedlayout.VerticalLayout;
+import com.vaadin.flow.router.PageTitle;
+import com.vaadin.flow.router.Route;
+
+import de.mcs.tools.sps.backend.Category;
+import de.mcs.tools.sps.backend.CategoryService;
+import de.mcs.tools.sps.backend.Review;
+import de.mcs.tools.sps.backend.ReviewService;
+import de.mcs.tools.sps.ui.MainLayout;
+import de.mcs.tools.sps.ui.common.AbstractEditorDialog;
+
+/**
+ * Displays the list of available categories, with a search filter as well as
+ * buttons to add a new category or edit existing ones.
+ */
+@Route(value = "emulator", layout = MainLayout.class)
+@PageTitle("SPS Emulator")
+public class EmulatorView extends VerticalLayout {
+
+  private final Button btStart = new Button(new Icon(VaadinIcon.STEP_FORWARD));
+  private final Button btPause = new Button(new Icon(VaadinIcon.PAUSE));
+  private final Button btStop = new Button(new Icon(VaadinIcon.STOP));
+  private final Grid<Category> grid = new Grid<>();
+
+  CheckboxGroup<String> cbgInput = new CheckboxGroup<>();
+  CheckboxGroup<String> cbgBtn = new CheckboxGroup<>();
+  CheckboxGroup<String> cbgOutput = new CheckboxGroup<>();
+
+  public EmulatorView() {
+    initView();
+
+    addToolBar();
+    addContent();
+
+    updateView();
+  }
+
+  private void initView() {
+    addClassName("emulator-view");
+    setDefaultHorizontalComponentAlignment(Alignment.STRETCH);
+  }
+
+  private void addToolBar() {
+    HorizontalLayout viewToolbar = new HorizontalLayout();
+    viewToolbar.addClassName("view-toolbar");
+    viewToolbar.add(btStart);
+    viewToolbar.add(btPause);
+    viewToolbar.add(btStop);
+    add(viewToolbar);
+  }
+
+  private void addContent() {
+    HorizontalLayout mainContainer = new HorizontalLayout();
+
+    VerticalLayout sourceContainer = new VerticalLayout();
+    sourceContainer.setClassName("view-container");
+    sourceContainer.setAlignItems(Alignment.STRETCH);
+
+    grid.addColumn(Category::getName).setHeader("No.").setWidth("8em").setResizable(true);
+    grid.addColumn(this::getReviewCount).setHeader("Mnemonic").setWidth("6em");
+    grid.setSelectionMode(SelectionMode.NONE);
+
+    sourceContainer.add(grid);
+    mainContainer.add(sourceContainer);
+
+    VerticalLayout emulatorContainer = new VerticalLayout();
+    HorizontalLayout inputContainer = new HorizontalLayout();
+    inputContainer.setClassName("border");
+    cbgInput.setItems("Input 1", "Input 2", "Input 3", "Input 4");
+    cbgInput.addThemeVariants(CheckboxGroupVariant.LUMO_VERTICAL);
+
+    inputContainer.add(cbgInput);
+
+    cbgBtn.setItems("SEL", "PRG");
+    cbgBtn.addThemeVariants(CheckboxGroupVariant.LUMO_VERTICAL);
+
+    inputContainer.add(cbgBtn);
+    emulatorContainer.add(inputContainer);
+
+    HorizontalLayout outputContainer = new HorizontalLayout();
+    cbgOutput.setItems("Output 1", "Output 2", "Output 3", "Output 4");
+    cbgOutput.addThemeVariants(CheckboxGroupVariant.LUMO_VERTICAL);
+
+    outputContainer.add(cbgOutput);
+    emulatorContainer.add(outputContainer);
+
+    mainContainer.add(emulatorContainer);
+    add(mainContainer);
+  }
+
+  private String getReviewCount(Category category) {
+    List<Review> reviewsInCategory = ReviewService.getInstance().findReviews(category.getName());
+    int sum = reviewsInCategory.stream().mapToInt(Review::getCount).sum();
+    return Integer.toString(sum);
+  }
+
+  private void updateView() {
+    // List<Category> categories =
+    // CategoryService.getInstance().findCategories(searchField.getValue());
+    // grid.setItems(categories);
+    //
+    // if (searchField.getValue().length() > 0) {
+    // header.setText("Search for “" + searchField.getValue() + "”");
+    // } else {
+    // header.setText("Categories");
+    // }
+  }
+
+  private void saveCategory(Category category, AbstractEditorDialog.Operation operation) {
+    CategoryService.getInstance().saveCategory(category);
+
+    Notification.show("Category successfully " + operation.getNameInText() + "ed.", 3000, Position.BOTTOM_START);
+    updateView();
+  }
+
+  private void deleteCategory(Category category) {
+    List<Review> reviewsInCategory = ReviewService.getInstance().findReviews(category.getName());
+
+    reviewsInCategory.forEach(review -> {
+      review.setCategory(CategoryService.getInstance().getUndefinedCategory());
+      ReviewService.getInstance().saveReview(review);
+    });
+    CategoryService.getInstance().deleteCategory(category);
+
+    Notification.show("Category successfully deleted.", 3000, Position.BOTTOM_START);
+    updateView();
+  }
+}

+ 6 - 0
SPSEmulator-gui/src/main/webapp/frontend/styles/shared-styles.html

@@ -142,6 +142,12 @@
             box-sizing: border-box;
             pointer-events: none;
         }
+        
+        .border {
+           border-radius: 5px;
+           border-style: solid;
+           border-width: 1px;
+        }
     </style>
 
     <dom-module id="my-dialog-styles" theme-for="vaadin-dialog-overlay">

+ 4 - 4
SPSEmulator-model/pom.xml

@@ -60,7 +60,7 @@
 					<skipTests>true</skipTests>
 				</configuration>
 			</plugin>
-			<plugin>
+<!-- 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-jar-plugin</artifactId>
 				<version>2.6</version>
@@ -92,12 +92,12 @@
 						<goals>
 							<goal>shade</goal>
 						</goals>
-						<!-- <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
-							<mainClass></mainClass> </transformer> </transformers> </configuration> -->
+						<configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
+							<mainClass></mainClass> </transformer> </transformers> </configuration>
 					</execution>
 				</executions>
 			</plugin>
-			<!-- <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> <version>1.7.24</version> 
+ -->			<!-- <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> <version>1.7.24</version> 
 				<executions> <execution> <id>l4j-clui</id> <phase>package</phase> <goals> <goal>launch4j</goal> </goals> <configuration> 
 				<dontWrapJar>false</dontWrapJar> <headerType>console</headerType> <jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar> 
 				<outfile>${project.build.directory}/MCSSPSTools.exe</outfile> <downloadUrl>http://java.com/download</downloadUrl> <classPath> 

+ 1 - 0
SPSEmulator-service/.classpath

@@ -35,5 +35,6 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/SPSEmulator-model"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>