corefx - updated node types dialog to display services for a given node type
This commit is contained in:
parent
61f80ffb9c
commit
eacb4d0cc0
7 changed files with 54 additions and 10 deletions
|
@ -80,10 +80,6 @@ public class Controller implements Initializable {
|
||||||
private GuiPreferencesDialog guiPreferencesDialog = new GuiPreferencesDialog(this);
|
private GuiPreferencesDialog guiPreferencesDialog = new GuiPreferencesDialog(this);
|
||||||
|
|
||||||
public void connectToCore(String coreUrl) {
|
public void connectToCore(String coreUrl) {
|
||||||
// clear out any previously set information
|
|
||||||
bottom.getChildren().remove(mobilityPlayer);
|
|
||||||
mobilityDialog.setNode(null);
|
|
||||||
|
|
||||||
coreWebSocket.stop();
|
coreWebSocket.stop();
|
||||||
|
|
||||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||||
|
@ -131,6 +127,10 @@ public class Controller implements Initializable {
|
||||||
// clear graph
|
// clear graph
|
||||||
networkGraph.reset();
|
networkGraph.reset();
|
||||||
|
|
||||||
|
// clear out any previously set information
|
||||||
|
bottom.getChildren().remove(mobilityPlayer);
|
||||||
|
mobilityDialog.setNode(null);
|
||||||
|
|
||||||
// get session to join
|
// get session to join
|
||||||
Session session = coreClient.getSession(joinId);
|
Session session = coreClient.getSession(joinId);
|
||||||
SessionState sessionState = SessionState.get(session.getState());
|
SessionState sessionState = SessionState.get(session.getState());
|
||||||
|
@ -168,6 +168,7 @@ public class Controller implements Initializable {
|
||||||
// update other components for new session
|
// update other components for new session
|
||||||
graphToolbar.setRunButton(coreClient.isRunning());
|
graphToolbar.setRunButton(coreClient.isRunning());
|
||||||
hooksDialog.updateHooks();
|
hooksDialog.updateHooks();
|
||||||
|
nodeTypesDialog.updateDefaultServices();
|
||||||
|
|
||||||
// display first mobility script in player
|
// display first mobility script in player
|
||||||
Map<Integer, MobilityConfig> mobilityConfigMap = coreClient.getMobilityConfigs();
|
Map<Integer, MobilityConfig> mobilityConfigMap = coreClient.getMobilityConfigs();
|
||||||
|
|
|
@ -31,6 +31,8 @@ public interface ICoreClient {
|
||||||
|
|
||||||
Map<String, List<String>> getServices() throws IOException;
|
Map<String, List<String>> getServices() throws IOException;
|
||||||
|
|
||||||
|
Map<String, List<String>> defaultServices() throws IOException;
|
||||||
|
|
||||||
CoreService getService(CoreNode node, String serviceName) throws IOException;
|
CoreService getService(CoreNode node, String serviceName) throws IOException;
|
||||||
|
|
||||||
boolean setService(CoreNode node, String serviceName, CoreService service) throws IOException;
|
boolean setService(CoreNode node, String serviceName, CoreService service) throws IOException;
|
||||||
|
|
|
@ -128,6 +128,13 @@ public class CoreRestClient implements ICoreClient {
|
||||||
return WebUtils.postFile(url, file);
|
return WebUtils.postFile(url, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<String>> defaultServices() throws IOException {
|
||||||
|
String url = getUrl(String.format("sessions/%s/services/default", sessionId));
|
||||||
|
GetDefaultServices getDefaultServices = WebUtils.getJson(url, GetDefaultServices.class);
|
||||||
|
return getDefaultServices.getDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CoreService getService(CoreNode node, String serviceName) throws IOException {
|
public CoreService getService(CoreNode node, String serviceName) throws IOException {
|
||||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", sessionId, node.getId(), serviceName));
|
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", sessionId, node.getId(), serviceName));
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.core.client.rest;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GetDefaultServices {
|
||||||
|
private Map<String, List<String>> defaults = new HashMap<>();
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ public class NetworkGraph {
|
||||||
// node render properties
|
// node render properties
|
||||||
renderContext.setVertexLabelTransformer(CoreNode::getName);
|
renderContext.setVertexLabelTransformer(CoreNode::getName);
|
||||||
renderContext.setVertexShapeTransformer(node -> {
|
renderContext.setVertexShapeTransformer(node -> {
|
||||||
double offset = -(IconUtils.ICON_SIZE / 2);
|
double offset = -(IconUtils.ICON_SIZE / 2.0);
|
||||||
return new Ellipse2D.Double(offset, offset, IconUtils.ICON_SIZE, IconUtils.ICON_SIZE);
|
return new Ellipse2D.Double(offset, offset, IconUtils.ICON_SIZE, IconUtils.ICON_SIZE);
|
||||||
});
|
});
|
||||||
renderContext.setVertexIconTransformer(vertex -> {
|
renderContext.setVertexIconTransformer(vertex -> {
|
||||||
|
@ -348,8 +348,8 @@ public class NetworkGraph {
|
||||||
|
|
||||||
public void addNode(CoreNode node) {
|
public void addNode(CoreNode node) {
|
||||||
vertexId = Math.max(node.getId() + 1, node.getId());
|
vertexId = Math.max(node.getId() + 1, node.getId());
|
||||||
Double x = Math.abs(node.getPosition().getX());
|
double x = Math.abs(node.getPosition().getX());
|
||||||
Double y = Math.abs(node.getPosition().getY());
|
double y = Math.abs(node.getPosition().getY());
|
||||||
logger.info("adding session node: {}", node);
|
logger.info("adding session node: {}", node);
|
||||||
graph.addVertex(node);
|
graph.addVertex(node);
|
||||||
graphLayout.setLocation(node, x, y);
|
graphLayout.setLocation(node, x, y);
|
||||||
|
@ -363,8 +363,8 @@ public class NetworkGraph {
|
||||||
node.getPosition().setY(nodeData.getPosition().getY());
|
node.getPosition().setY(nodeData.getPosition().getY());
|
||||||
|
|
||||||
// set graph node location
|
// set graph node location
|
||||||
Double x = Math.abs(node.getPosition().getX());
|
double x = Math.abs(node.getPosition().getX());
|
||||||
Double y = Math.abs(node.getPosition().getY());
|
double y = Math.abs(node.getPosition().getY());
|
||||||
graphLayout.setLocation(node, x, y);
|
graphLayout.setLocation(node, x, y);
|
||||||
graphViewer.repaint();
|
graphViewer.repaint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,17 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NodeTypesDialog extends StageDialog {
|
public class NodeTypesDialog extends StageDialog {
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
private final Map<String, NodeType> nodeTypeMap = new HashMap<>();
|
private final Map<String, NodeType> nodeTypeMap = new HashMap<>();
|
||||||
private NodeType selectedNodeType;
|
private NodeType selectedNodeType;
|
||||||
|
private Map<String, List<String>> defaultServices = new HashMap<>();
|
||||||
@FXML private JFXListView<String> listView;
|
@FXML private JFXListView<String> listView;
|
||||||
@FXML private JFXTextField modelTextField;
|
@FXML private JFXTextField modelTextField;
|
||||||
@FXML private JFXTextField displayTextField;
|
@FXML private JFXTextField displayTextField;
|
||||||
|
@ -31,6 +35,7 @@ public class NodeTypesDialog extends StageDialog {
|
||||||
@FXML private JFXButton saveButton;
|
@FXML private JFXButton saveButton;
|
||||||
@FXML private JFXButton addButton;
|
@FXML private JFXButton addButton;
|
||||||
@FXML private JFXButton deleteButton;
|
@FXML private JFXButton deleteButton;
|
||||||
|
@FXML private JFXListView<String> nodeServicesListView;
|
||||||
|
|
||||||
public NodeTypesDialog(Controller controller) {
|
public NodeTypesDialog(Controller controller) {
|
||||||
super(controller, "/fxml/node_types_dialog.fxml");
|
super(controller, "/fxml/node_types_dialog.fxml");
|
||||||
|
@ -48,6 +53,8 @@ public class NodeTypesDialog extends StageDialog {
|
||||||
iconTextField.setText(nodeType.getIcon());
|
iconTextField.setText(nodeType.getIcon());
|
||||||
iconImage.setImage(new Image(nodeType.getIcon()));
|
iconImage.setImage(new Image(nodeType.getIcon()));
|
||||||
selectedNodeType = nodeType;
|
selectedNodeType = nodeType;
|
||||||
|
List<String> services = defaultServices.getOrDefault(nodeType.getModel(), Collections.emptyList());
|
||||||
|
nodeServicesListView.getItems().setAll(services);
|
||||||
});
|
});
|
||||||
|
|
||||||
iconButton.setOnAction(event -> {
|
iconButton.setOnAction(event -> {
|
||||||
|
@ -79,6 +86,15 @@ public class NodeTypesDialog extends StageDialog {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateDefaultServices() {
|
||||||
|
try {
|
||||||
|
defaultServices = getCoreClient().defaultServices();
|
||||||
|
listView.getSelectionModel().selectFirst();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.error("Error getting default services", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void showDialog() {
|
public void showDialog() {
|
||||||
listView.getItems().clear();
|
listView.getItems().clear();
|
||||||
nodeTypeMap.clear();
|
nodeTypeMap.clear();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<GridPane hgap="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="10.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171">
|
<GridPane hgap="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="33.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="33.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
@ -66,6 +66,8 @@
|
||||||
<JFXButton fx:id="iconButton" maxWidth="1.7976931348623157E308" styleClass="core-button" text="Find" GridPane.columnIndex="1" />
|
<JFXButton fx:id="iconButton" maxWidth="1.7976931348623157E308" styleClass="core-button" text="Find" GridPane.columnIndex="1" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<Label text="Services" />
|
||||||
|
<JFXListView fx:id="nodeServicesListView" VBox.vgrow="ALWAYS" />
|
||||||
</children>
|
</children>
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets />
|
<Insets />
|
||||||
|
|
Loading…
Add table
Reference in a new issue