diff --git a/plc4j/tools/pom.xml b/plc4j/tools/pom.xml index 9fe529019a0..657d894a663 100644 --- a/plc4j/tools/pom.xml +++ b/plc4j/tools/pom.xml @@ -40,7 +40,6 @@ plc4x-server scraper scraper-ng - ui \ No newline at end of file diff --git a/plc4j/tools/ui/pom.xml b/plc4j/tools/ui/pom.xml deleted file mode 100644 index 1ad8e3ad5fe..00000000000 --- a/plc4j/tools/ui/pom.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools - 0.11.0-SNAPSHOT - - - plc4j-ui - - PLC4J: Tools: UI - Utility used to execute PLC4X API calls in a GUI. - - - 21 - - - - - - org.openjfx - javafx-maven-plugin - 0.0.8 - - org.apache.plc4x.java.ui.Plc4xUi - - - - run - - - debug - - - - - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-ban-duplicate-classes - - true - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-driver-ab-eth - org.apache.plc4x:plc4j-driver-ads - org.apache.plc4x:plc4j-driver-bacnet - org.apache.plc4x:plc4j-driver-can - org.apache.plc4x:plc4j-driver-c-bus - org.apache.plc4x:plc4j-driver-eip - org.apache.plc4x:plc4j-driver-firmata - org.apache.plc4x:plc4j-driver-knxnetip - org.apache.plc4x:plc4j-driver-modbus - org.apache.plc4x:plc4j-driver-opcua - org.apache.plc4x:plc4j-driver-plc4x - org.apache.plc4x:plc4j-driver-profinet - org.apache.plc4x:plc4j-driver-s7 - - - - - - - - - org.apache.plc4x - plc4j-api - 0.11.0-SNAPSHOT - - - - org.openjfx - javafx-base - ${javafx.version} - ${javafx.platform} - - - org.openjfx - javafx-graphics - ${javafx.version} - ${javafx.platform} - - - org.openjfx - javafx-controls - ${javafx.version} - ${javafx.platform} - - - org.openjfx - javafx-fxml - ${javafx.version} - ${javafx.platform} - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - org.kordamp.ikonli - ikonli-javafx - 12.3.1 - - - org.kordamp.ikonli - ikonli-core - 12.3.1 - - - org.kordamp.ikonli - ikonli-materialdesign-pack - 12.3.1 - - - - org.apache.plc4x - plc4j-driver-ab-eth - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-ads - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-bacnet - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-c-bus - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-can - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-eip - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-firmata - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-knxnetip - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-modbus - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-opcua - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-plc4x - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-profinet - 0.11.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-s7 - 0.11.0-SNAPSHOT - - - - \ No newline at end of file diff --git a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/ConnectionTabController.java b/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/ConnectionTabController.java deleted file mode 100644 index 114273edf67..00000000000 --- a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/ConnectionTabController.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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 org.apache.plc4x.java.ui; - -import javafx.fxml.FXML; -import javafx.scene.control.*; -import javafx.scene.control.cell.TreeItemPropertyValueFactory; -import javafx.scene.input.MouseEvent; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcBrowseItem; -import org.apache.plc4x.java.api.messages.PlcBrowseItemArrayInfo; -import org.apache.plc4x.java.api.messages.PlcBrowseResponse; -import org.apache.plc4x.java.api.model.ArrayInfo; -import org.apache.plc4x.java.api.types.PlcValueType; -import org.kordamp.ikonli.javafx.FontIcon; -import org.kordamp.ikonli.materialdesign.MaterialDesign; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.concurrent.ExecutionException; - -public class ConnectionTabController { - - @FXML - public Tab tab; - - @FXML - public TreeTableView resourceTreeView; - - private PlcConnection connection; - - @FXML - public void initialize() { - TreeTableColumn addressColumn = new TreeTableColumn<>("Address"); - addressColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("address")); - resourceTreeView.getColumns().add(addressColumn); - - TreeTableColumn nameColumn = new TreeTableColumn<>("Name"); - nameColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("name")); - resourceTreeView.getColumns().add(nameColumn); - - TreeTableColumn typeColumn = new TreeTableColumn<>("Type"); - typeColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("type")); - resourceTreeView.getColumns().add(typeColumn); - - TreeTableColumn readableColumn = new TreeTableColumn<>("Readable"); - readableColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("readable")); - resourceTreeView.getColumns().add(readableColumn); - - TreeTableColumn writableColumn = new TreeTableColumn<>("Writable"); - writableColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("writable")); - resourceTreeView.getColumns().add(writableColumn); - - TreeTableColumn subscribableColumn = new TreeTableColumn<>("Subscribable"); - subscribableColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("subscribable")); - resourceTreeView.getColumns().add(subscribableColumn); - } - - void setConnection(String connectionName, PlcConnection connection) { - tab.setText(connectionName); - - this.connection = connection; - - if(connection.getMetadata().canBrowse()) { - try { - PlcBrowseResponse browseResponse = connection.browseRequestBuilder().build().execute().get(); - - TreeItem rootItem = new TreeItem<>( - new ConnectionTabController.TreeEntry("", "", PlcValueType.NULL, - false, false, false)); - rootItem.setGraphic(new FontIcon(MaterialDesign.MDI_FOLDER)); - rootItem.setExpanded(true); - - // Sort the entries first. - for (String queryName : browseResponse.getQueryNames()) { - List values = browseResponse.getValues(queryName); - values.sort(new PlcBrowseItemComparator()); - // Then add the elements to the tree. - for (PlcBrowseItem value : values) { - rootItem.getChildren().add(getTreeItemForBrowseItem(value)); - } - } - - resourceTreeView.setRoot(rootItem); - } catch (ExecutionException | InterruptedException e) { - throw new RuntimeException(e); - } - } - } - - private TreeItem getTreeItemForBrowseItem(PlcBrowseItem browseItem) { - StringBuilder addressSuffix = new StringBuilder(); - if ((browseItem.getTag().getPlcValueType() == PlcValueType.List) && (browseItem.getTag().getArrayInfo() != null)){ - addressSuffix.append(" "); - for (ArrayInfo arrayInfo : browseItem.getTag().getArrayInfo()) { - addressSuffix.append("[").append(arrayInfo.getLowerBound()).append(" .. ").append(arrayInfo.getUpperBound()).append("]"); - } - } - TreeItem treeItem = new TreeItem<>(new ConnectionTabController.TreeEntry( - browseItem.getTag().getAddressString() + addressSuffix, browseItem.getName(), browseItem.getTag().getPlcValueType(), - browseItem.isReadable(), browseItem.isWritable(), browseItem.isSubscribable())); - if(!browseItem.getChildren().isEmpty()) { - // Sort the entries first. - List values = new ArrayList<>(browseItem.getChildren().values()); - // Then add the elements to the tree. - values.sort(new PlcBrowseItemComparator()); - for (PlcBrowseItem child : values) { - treeItem.getChildren().add(getTreeItemForBrowseItem(child)); - } - } - return treeItem; - } - - @FXML - public void handleTreeSelectionChanged(MouseEvent mouseEvent) { - - } - - public static class TreeEntry { - - private final String address; - - private final String name; - - private final PlcValueType type; - - private final boolean readable; - - private final boolean writable; - - private final boolean subscribable; - - public TreeEntry(String address, String name, PlcValueType type, boolean readable, boolean writable, boolean subscribable) { - this.address = address; - this.name = name; - this.type = type; - this.readable = readable; - this.writable = writable; - this.subscribable = subscribable; - } - - public String getAddress() { - return address; - } - - public String getName() { - return name; - } - - public PlcValueType getType() { - return type; - } - - public boolean isReadable() { - return readable; - } - - public boolean isWritable() { - return writable; - } - - public boolean isSubscribable() { - return subscribable; - } - } - - static class PlcBrowseItemComparator implements Comparator { - @Override - public int compare(PlcBrowseItem o1, PlcBrowseItem o2) { - return o1.getTag().getAddressString().compareTo(o2.getTag().getAddressString()); - } - } - -} diff --git a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/FxmlController.java b/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/FxmlController.java deleted file mode 100644 index dc10b523a3c..00000000000 --- a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/FxmlController.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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 org.apache.plc4x.java.ui; - -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.control.*; -import javafx.scene.control.cell.TextFieldTreeCell; -import javafx.scene.input.MouseButton; -import javafx.scene.input.MouseEvent; -import javafx.scene.paint.Paint; - -import javafx.util.StringConverter; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcDiscoveryItem; -import org.apache.plc4x.java.api.messages.PlcDiscoveryResponse; -import org.kordamp.ikonli.javafx.FontIcon; -import org.kordamp.ikonli.materialdesign.MaterialDesign; - -import java.io.IOException; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; - -public class FxmlController { - - private final PlcDriverManager driverManager; - - @FXML - public TreeView plcTreeView; - - @FXML - public Button browseButton; - - @FXML - public TabPane connectionTabs; - - public FxmlController() { - driverManager = PlcDriverManager.getDefault(); - } - - @FXML - public void initialize() throws Exception { - plcTreeView.setCellFactory(treeEntryTreeView -> new TextFieldTreeCell<>(new StringConverter<>() { - @Override - public String toString(TreeEntry treeEntry) { - return treeEntry.getName(); - } - - @Override - public TreeEntry fromString(String string) { - return null; - } - })); - TreeItem rootItem = new TreeItem<>(new TreeEntry( - TreeEntryType.ROOT, "", "Available Drivers")); - rootItem.setGraphic(new FontIcon(MaterialDesign.MDI_FOLDER)); - for (String protocolCode : driverManager.listDrivers()) { - PlcDriver driver = driverManager.getDriver(protocolCode); - TreeItem driverItem = new TreeItem<>(new TreeEntry( - TreeEntryType.DRIVER, driver.getProtocolCode(), driver.getProtocolName())); - FontIcon icon; - if(driver.getMetadata().canDiscover()) { - icon = new FontIcon(MaterialDesign.MDI_CHECK_CIRCLE); - icon.setIconColor(Paint.valueOf("green")); - } else { - icon = new FontIcon(MaterialDesign.MDI_MINUS_CIRCLE); - icon.setIconColor(Paint.valueOf("red")); - } - driverItem.setGraphic(icon); - rootItem.getChildren().add(driverItem); - } - rootItem.setExpanded(true); - plcTreeView.setRoot(rootItem); - - browseButton.setDisable(true); - } - - @FXML - public void handleTreeSelectionChanged(MouseEvent mouseEvent) { - MultipleSelectionModel> selectionModel = plcTreeView.getSelectionModel(); - boolean buttonEnabled = false; - if(!selectionModel.getSelectedItems().isEmpty()) { - TreeEntry selectedItem = selectionModel.getSelectedItems().get(0).getValue(); - switch (selectedItem.getType()) { - case DRIVER: - try { - buttonEnabled = driverManager.getDriver(selectedItem.getCode()).getMetadata().canDiscover(); - } catch (Exception e) { - // Ignore ... - } - // If the item was double-clicked, start the scan right away. - if(buttonEnabled && mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) { - try { - handleBrowseButtonClicked(null); - } catch (Exception e) { - // Ignore ... - } - } - break; - case PLC: - if(mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) { - String connectionString = selectedItem.getCode(); - try { - PlcConnection connection = driverManager.getConnectionManager().getConnection(connectionString); - FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("connection-tab.fxml"))); - - Tab connectionTab = loader.load(); - ConnectionTabController controller = loader.getController(); - controller.setConnection(selectedItem.getName(), connection); - - connectionTabs.getTabs().add(connectionTab); - } catch (PlcConnectionException | IOException e) { - throw new RuntimeException(e); - } - } - break; - case ADDRESS: - buttonEnabled = true; - break; - } - } - browseButton.setDisable(!buttonEnabled); - } - - @FXML - public void handleBrowseButtonClicked(ActionEvent actionEvent) throws Exception { - MultipleSelectionModel> selectionModel = plcTreeView.getSelectionModel(); - if(!selectionModel.getSelectedItems().isEmpty()) { - TreeItem selectedTreeItem = selectionModel.getSelectedItems().get(0); - TreeEntry selectedItem = selectedTreeItem.getValue(); - selectedTreeItem.setExpanded(true); - PlcDriver driver = driverManager.getDriver(selectedItem.getCode()); - CompletableFuture browseFuture = driver.discoveryRequestBuilder().build().execute(); - browseFuture.whenComplete((response, throwable) -> { - if(throwable == null) { - for (PlcDiscoveryItem discoveredPlc : response.getValues()) { - TreeItem plcItem = new TreeItem<>(new TreeEntry( - TreeEntryType.PLC, discoveredPlc.getConnectionUrl(), discoveredPlc.getName())); - plcItem.setGraphic(new FontIcon(MaterialDesign.MDI_LAN_CONNECT)); - selectedTreeItem.getChildren().add(plcItem); - } - } - }); - } - } - - public enum TreeEntryType { - ROOT, - DRIVER, - PLC, - ADDRESS - } - - public static class TreeEntry { - - private final TreeEntryType type; - - private final String code; - - private final String name; - - public TreeEntry(TreeEntryType type, String code, String name) { - this.type = type; - this.code = code; - this.name = name; - } - - public TreeEntryType getType() { - return type; - } - - public String getCode() { - return code; - } - - public String getName() { - return name; - } - - } - -} diff --git a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/Plc4xUi.java b/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/Plc4xUi.java deleted file mode 100644 index af4e618fdf1..00000000000 --- a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/Plc4xUi.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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 org.apache.plc4x.java.ui; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.util.Objects; - -public class Plc4xUi extends Application { - - public static void main(String[] args) { - launch(args); - } - - @Override - public void start(Stage primaryStage) throws Exception { - Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("ui.fxml"))); - Scene scene = new Scene(root, 800, 600); - scene.getStylesheets().add("ui.css"); - - primaryStage.setTitle("PLC4X UI"); - primaryStage.setScene(scene); - primaryStage.show(); - } - -} diff --git a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/UiIcon.java b/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/UiIcon.java deleted file mode 100644 index c9a2cf03c4f..00000000000 --- a/plc4j/tools/ui/src/main/java/org/apache/plc4x/java/ui/UiIcon.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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 org.apache.plc4x.java.ui; - -import org.kordamp.ikonli.Ikon; - -public enum UiIcon implements Ikon { - - FOLDER("ui-icon-folder", '\ue815'); - - private final String description; - private final char icon; - - UiIcon(String description, char icon) { - this.description = description; - this.icon = icon; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public int getCode() { - return icon; - } - - public static UiIcon findByDescription(String description) { - for (UiIcon icon : values()) { - if (icon.description.equals(description)) { - return icon; - } - } - throw new IllegalArgumentException("Icon not supported: " + description); - } - -} diff --git a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/connection-tab.fxml b/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/connection-tab.fxml deleted file mode 100644 index d4a609507e7..00000000000 --- a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/connection-tab.fxml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.css b/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.css deleted file mode 100644 index ba830d1f799..00000000000 --- a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.css +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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. - */ diff --git a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.fxml b/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.fxml deleted file mode 100644 index d258afd52e7..00000000000 --- a/plc4j/tools/ui/src/main/resources/org/apache/plc4x/java/ui/ui.fxml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - -