corefx - added jfx progress bar under the menu, make use of the progress bar for start/stop
This commit is contained in:
parent
1b728770f1
commit
8864169683
3 changed files with 32 additions and 23 deletions
|
@ -13,6 +13,7 @@ import com.core.ui.*;
|
|||
import com.core.ui.dialogs.*;
|
||||
import com.core.utils.ConfigUtils;
|
||||
import com.core.websocket.CoreWebSocket;
|
||||
import com.jfoenix.controls.JFXProgressBar;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.embed.swing.SwingNode;
|
||||
|
@ -47,6 +48,7 @@ public class Controller implements Initializable {
|
|||
@FXML private BorderPane borderPane;
|
||||
@FXML private SwingNode swingNode;
|
||||
@FXML private MenuItem saveXmlMenuItem;
|
||||
@FXML private JFXProgressBar progressBar;
|
||||
|
||||
private Application application;
|
||||
private Stage window;
|
||||
|
|
|
@ -15,7 +15,6 @@ import javafx.event.ActionEvent;
|
|||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
@ -237,24 +236,26 @@ public class GraphToolbar extends VBox {
|
|||
}
|
||||
|
||||
private void startSession() {
|
||||
controller.getProgressBar().setVisible(true);
|
||||
runButton.setDisable(true);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
ProgressBar progressBar = new ProgressBar();
|
||||
progressBar.setPrefWidth(Double.MAX_VALUE);
|
||||
controller.getBorderPane().setBottom(progressBar);
|
||||
|
||||
boolean result = controller.getCoreClient().start();
|
||||
if (result) {
|
||||
Toast.success("Session Started");
|
||||
setRunButton(true);
|
||||
}
|
||||
|
||||
controller.getBorderPane().setBottom(null);
|
||||
} catch (IOException ex) {
|
||||
logger.error("failure starting session", ex);
|
||||
}
|
||||
controller.getProgressBar().setVisible(false);
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void stopSession() {
|
||||
controller.getProgressBar().setVisible(true);
|
||||
runButton.setDisable(true);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
boolean result = controller.getCoreClient().stop();
|
||||
if (result) {
|
||||
|
@ -264,6 +265,8 @@ public class GraphToolbar extends VBox {
|
|||
} catch (IOException ex) {
|
||||
logger.error("failure to stopSession session", ex);
|
||||
}
|
||||
controller.getProgressBar().setVisible(false);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void setRunButton(boolean isRunning) {
|
||||
|
@ -277,6 +280,7 @@ public class GraphToolbar extends VBox {
|
|||
if (runButton.getGraphic() != stopIcon) {
|
||||
runButton.setGraphic(stopIcon);
|
||||
}
|
||||
runButton.setDisable(false);
|
||||
});
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
|
@ -287,6 +291,7 @@ public class GraphToolbar extends VBox {
|
|||
if (runButton.getGraphic() != startIcon) {
|
||||
runButton.setGraphic(startIcon);
|
||||
}
|
||||
runButton.setDisable(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXProgressBar?>
|
||||
<?import javafx.embed.swing.SwingNode?>
|
||||
<?import javafx.scene.control.Menu?>
|
||||
<?import javafx.scene.control.MenuBar?>
|
||||
|
@ -57,6 +58,7 @@
|
|||
</Menu>
|
||||
</menus>
|
||||
</MenuBar>
|
||||
<JFXProgressBar fx:id="progressBar" maxWidth="1.7976931348623157E308" visible="false" />
|
||||
</children>
|
||||
</VBox>
|
||||
</top>
|
||||
|
|
Loading…
Add table
Reference in a new issue