some more buttons in the GUI and fixed the project list logic when the list was cleared.
This commit is contained in:
parent
eb35156313
commit
120dded24f
9 changed files with 63 additions and 17 deletions
|
|
@ -26,6 +26,7 @@ import com.coder.server.message.ProjectRspMsg;
|
|||
import zutil.log.CompactLogFormatter;
|
||||
import zutil.log.LogUtil;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class CoderClient extends Application{
|
||||
|
|
@ -106,7 +107,7 @@ public class CoderClient extends Application{
|
|||
selectServerDialog.setServerPort(serverPort);
|
||||
}
|
||||
@Override
|
||||
public void cancel() {
|
||||
public void exit() {
|
||||
logger.info("terminating");
|
||||
System.exit(0);
|
||||
}
|
||||
|
|
@ -162,11 +163,16 @@ public class CoderClient extends Application{
|
|||
private void setupSessionListener(){
|
||||
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
|
||||
@Override
|
||||
public void projectListRspReceived(Map<String, ProjectListData> projectListRsp) {
|
||||
for(String projectName : projectListRsp.keySet()){
|
||||
ProjectListData projectData = projectListRsp.get(projectName);
|
||||
selectProjectDialog.addProjectToList(projectName, projectData);
|
||||
}
|
||||
public void projectListRspReceived(final Map<String, ProjectListData> projectListRsp) {
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(String projectName : projectListRsp.keySet()){
|
||||
ProjectListData projectData = projectListRsp.get(projectName);
|
||||
selectProjectDialog.addProjectToList(projectName, projectData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void projectRspReceived(ProjectRspMsg projectRspMsg) {
|
||||
|
|
@ -243,6 +249,7 @@ public class CoderClient extends Application{
|
|||
|
||||
private void closeCurrentSession(){
|
||||
if(this.session != null){
|
||||
logger.info("disconnecting from server");
|
||||
session.close();
|
||||
session = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public abstract class GuiWindow implements Initializable{
|
|||
*/
|
||||
public void showOnStage(Stage stage){
|
||||
stage.setScene(scene);
|
||||
stage.setTitle(getTitle());
|
||||
this.stage = stage;
|
||||
willShow();
|
||||
stage.show();
|
||||
|
|
@ -47,6 +48,7 @@ public abstract class GuiWindow implements Initializable{
|
|||
modalStage.initModality(Modality.WINDOW_MODAL);
|
||||
modalStage.initOwner(parent);
|
||||
modalStage.setScene(scene);
|
||||
modalStage.setTitle(getTitle());
|
||||
this.stage = modalStage;
|
||||
willShow();
|
||||
modalStage.showAndWait();
|
||||
|
|
@ -58,6 +60,8 @@ public abstract class GuiWindow implements Initializable{
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract String getTitle();
|
||||
|
||||
/**
|
||||
* Called every time before showed on stage
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -113,4 +113,9 @@ public class EditorWindow extends GuiWindow {
|
|||
this.listsners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "Coder Client";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,20 @@ public class LoginDialog extends GuiWindow {
|
|||
}
|
||||
|
||||
public void setPassword(char[] password){
|
||||
passwordPasswordField.setText(new String(password));
|
||||
if(password != null){
|
||||
passwordPasswordField.setText(new String(password));
|
||||
}else{
|
||||
passwordPasswordField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
public void addLoginDialogListener(LoginDialogListener listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "Login";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="217.0" prefWidth="396.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="164.0" prefWidth="396.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<ListView fx:id="projectListView" prefHeight="200.0" prefWidth="200.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<GridPane prefHeight="77.0" prefWidth="396.0">
|
||||
<GridPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="50.0" prefWidth="396.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
|
|
@ -43,9 +44,14 @@
|
|||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<Button mnemonicParsing="false" onAction="#refresh" text="Refresh">
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</VBox>
|
||||
</AnchorPane>
|
||||
|
|
|
|||
|
|
@ -51,10 +51,16 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
projectListView.setCellFactory(new Callback<ListView<ProjectListItem>, ListCell<ProjectListItem>>(){
|
||||
@Override
|
||||
public ListCell<ProjectListItem> call(ListView<ProjectListItem> arg0) {
|
||||
System.out.println("cell factory");
|
||||
ListCell<ProjectListItem> cell = new ListCell<ProjectListItem>(){
|
||||
@Override
|
||||
protected void updateItem(ProjectListItem item, boolean empty){
|
||||
System.out.println("update item: " + item);
|
||||
super.updateItem(item, empty);
|
||||
if(empty){
|
||||
setText("");
|
||||
setGraphic(null);
|
||||
}
|
||||
if(item != null){
|
||||
setText(item.toString());
|
||||
//setGraphic(null);
|
||||
|
|
@ -124,5 +130,10 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
ProjectListItem item = new ProjectListItem(projectName, projectData.type, projectData.description);
|
||||
this.projectList.add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "Select Project";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="217.0" prefWidth="396.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
|
||||
|
|
@ -24,7 +23,7 @@
|
|||
<children>
|
||||
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
|
||||
<children>
|
||||
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="Cancel">
|
||||
<Button fx:id="exitButton" mnemonicParsing="false" onAction="#exit" text="Exit">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
</HBox.margin>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class SelectServerDialog extends GuiWindow {
|
|||
private String address = null;
|
||||
private int port = -1;
|
||||
|
||||
@FXML private Button cancelButton;
|
||||
@FXML private Button exitButton;
|
||||
@FXML private Button connectButton;
|
||||
|
||||
public SelectServerDialog() throws IOException {
|
||||
|
|
@ -45,9 +45,9 @@ public class SelectServerDialog extends GuiWindow {
|
|||
}
|
||||
|
||||
@FXML
|
||||
protected void cancel(ActionEvent event){
|
||||
protected void exit(ActionEvent event){
|
||||
for(SelectServerDialogListener listener : this.listeners){
|
||||
listener.cancel();
|
||||
listener.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,4 +71,9 @@ public class SelectServerDialog extends GuiWindow {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "Select Server";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ public interface SelectServerDialogListener {
|
|||
|
||||
void willShow();
|
||||
|
||||
void cancel();
|
||||
void exit();
|
||||
|
||||
void connect(String serverAddress, int port);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue