corefx - added session create to sessions dialog
This commit is contained in:
parent
6f0e22cc28
commit
77e8006570
3 changed files with 27 additions and 10 deletions
|
@ -128,7 +128,7 @@ public class Controller implements Initializable {
|
||||||
nodeEmaneDialog.setModels(emaneModels);
|
nodeEmaneDialog.setModels(emaneModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinSession(Integer joinId) throws IOException {
|
public void joinSession(Integer sessionId) throws IOException {
|
||||||
// clear graph
|
// clear graph
|
||||||
networkGraph.reset();
|
networkGraph.reset();
|
||||||
|
|
||||||
|
@ -137,15 +137,15 @@ public class Controller implements Initializable {
|
||||||
mobilityDialog.setNode(null);
|
mobilityDialog.setNode(null);
|
||||||
|
|
||||||
// get session to join
|
// get session to join
|
||||||
Session session = coreClient.getSession(joinId);
|
Session session = coreClient.getSession(sessionId);
|
||||||
SessionState sessionState = SessionState.get(session.getState());
|
SessionState sessionState = SessionState.get(session.getState());
|
||||||
|
|
||||||
// update client to use this session
|
// update client to use this session
|
||||||
coreClient.updateSession(joinId);
|
coreClient.updateSession(sessionId);
|
||||||
coreClient.updateState(sessionState);
|
coreClient.updateState(sessionState);
|
||||||
|
|
||||||
// display all nodes
|
// display all nodes
|
||||||
logger.info("joining core session({}) state({}): {}", joinId, sessionState, session);
|
logger.info("joining core session({}) state({}): {}", sessionId, sessionState, session);
|
||||||
for (CoreNode node : session.getNodes()) {
|
for (CoreNode node : session.getNodes()) {
|
||||||
NodeType nodeType = NodeType.find(node.getType(), node.getModel());
|
NodeType nodeType = NodeType.find(node.getType(), node.getModel());
|
||||||
if (nodeType == null) {
|
if (nodeType == null) {
|
||||||
|
@ -370,12 +370,12 @@ public class Controller implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onJoinSessionMenu(ActionEvent event) {
|
private void onSessionMenu(ActionEvent event) {
|
||||||
logger.info("join sessions menu clicked!");
|
logger.info("sessions menu clicked");
|
||||||
try {
|
try {
|
||||||
sessionsDialog.showDialog();
|
sessionsDialog.showDialog();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.error("error getting session dialog", ex);
|
Toast.error("Error retrieving sessions", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,24 +29,41 @@ public class SessionsDialog extends StageDialog {
|
||||||
|
|
||||||
setTitle("Sessions");
|
setTitle("Sessions");
|
||||||
|
|
||||||
|
JFXButton createButton = createButton("New");
|
||||||
|
createButton.setOnAction(event -> {
|
||||||
|
close();
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
SessionOverview sessionOverview = getCoreClient().createSession();
|
||||||
|
controller.joinSession(sessionOverview.getId());
|
||||||
|
Toast.success(String.format("Created Session %s", sessionOverview.getId()));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.error("Error creating new session", ex);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
JFXButton joinButton = createButton("Join");
|
JFXButton joinButton = createButton("Join");
|
||||||
joinButton.setOnAction(event -> {
|
joinButton.setOnAction(event -> {
|
||||||
SessionRow row = sessionsTable.getSelectionModel().getSelectedItem();
|
SessionRow row = sessionsTable.getSelectionModel().getSelectedItem();
|
||||||
logger.info("selected session: {}", row);
|
logger.info("selected session: {}", row);
|
||||||
try {
|
try {
|
||||||
getController().joinSession(row.getId());
|
controller.joinSession(row.getId());
|
||||||
Toast.info(String.format("Joined Session %s", row.getId()));
|
Toast.info(String.format("Joined Session %s", row.getId()));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Toast.error(String.format("error joining session: %s", row.getId()), ex);
|
Toast.error(String.format("Error joining session: %s", row.getId()), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
|
joinButton.setDisable(true);
|
||||||
addCancelButton();
|
addCancelButton();
|
||||||
|
|
||||||
sessionIdColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
|
sessionIdColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||||
stateColumn.setCellValueFactory(new PropertyValueFactory<>("state"));
|
stateColumn.setCellValueFactory(new PropertyValueFactory<>("state"));
|
||||||
nodeCountColumn.setCellValueFactory(new PropertyValueFactory<>("nodes"));
|
nodeCountColumn.setCellValueFactory(new PropertyValueFactory<>("nodes"));
|
||||||
|
sessionsTable.getSelectionModel().selectedItemProperty().addListener((ov, prev, current) -> {
|
||||||
|
joinButton.setDisable(current == null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onOpenXmlAction" text="Open XML" />
|
<MenuItem mnemonicParsing="false" onAction="#onOpenXmlAction" text="Open XML" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#onSessionMenu" text="Sessions" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuNodeTypes" text="Nodes" />
|
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuNodeTypes" text="Nodes" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuPreferences" text="Preferences" />
|
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuPreferences" text="Preferences" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Session">
|
<Menu mnemonicParsing="false" text="Session">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onJoinSessionMenu" text="Join" />
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onSessionHooksMenu" text="Hooks" />
|
<MenuItem mnemonicParsing="false" onAction="#onSessionHooksMenu" text="Hooks" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuLocation" text="Location" />
|
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuLocation" text="Location" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuBackground" text="Background" />
|
<MenuItem mnemonicParsing="false" onAction="#onOptionsMenuBackground" text="Background" />
|
||||||
|
|
Loading…
Reference in a new issue