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.CompactLogFormatter;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class CoderClient extends Application{
|
public class CoderClient extends Application{
|
||||||
|
|
@ -106,7 +107,7 @@ public class CoderClient extends Application{
|
||||||
selectServerDialog.setServerPort(serverPort);
|
selectServerDialog.setServerPort(serverPort);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void exit() {
|
||||||
logger.info("terminating");
|
logger.info("terminating");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
@ -162,11 +163,16 @@ public class CoderClient extends Application{
|
||||||
private void setupSessionListener(){
|
private void setupSessionListener(){
|
||||||
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
|
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void projectListRspReceived(Map<String, ProjectListData> projectListRsp) {
|
public void projectListRspReceived(final Map<String, ProjectListData> projectListRsp) {
|
||||||
for(String projectName : projectListRsp.keySet()){
|
Platform.runLater(new Runnable() {
|
||||||
ProjectListData projectData = projectListRsp.get(projectName);
|
@Override
|
||||||
selectProjectDialog.addProjectToList(projectName, projectData);
|
public void run() {
|
||||||
}
|
for(String projectName : projectListRsp.keySet()){
|
||||||
|
ProjectListData projectData = projectListRsp.get(projectName);
|
||||||
|
selectProjectDialog.addProjectToList(projectName, projectData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void projectRspReceived(ProjectRspMsg projectRspMsg) {
|
public void projectRspReceived(ProjectRspMsg projectRspMsg) {
|
||||||
|
|
@ -243,6 +249,7 @@ public class CoderClient extends Application{
|
||||||
|
|
||||||
private void closeCurrentSession(){
|
private void closeCurrentSession(){
|
||||||
if(this.session != null){
|
if(this.session != null){
|
||||||
|
logger.info("disconnecting from server");
|
||||||
session.close();
|
session.close();
|
||||||
session = null;
|
session = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ public abstract class GuiWindow implements Initializable{
|
||||||
*/
|
*/
|
||||||
public void showOnStage(Stage stage){
|
public void showOnStage(Stage stage){
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
stage.setTitle(getTitle());
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
willShow();
|
willShow();
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
@ -47,6 +48,7 @@ public abstract class GuiWindow implements Initializable{
|
||||||
modalStage.initModality(Modality.WINDOW_MODAL);
|
modalStage.initModality(Modality.WINDOW_MODAL);
|
||||||
modalStage.initOwner(parent);
|
modalStage.initOwner(parent);
|
||||||
modalStage.setScene(scene);
|
modalStage.setScene(scene);
|
||||||
|
modalStage.setTitle(getTitle());
|
||||||
this.stage = modalStage;
|
this.stage = modalStage;
|
||||||
willShow();
|
willShow();
|
||||||
modalStage.showAndWait();
|
modalStage.showAndWait();
|
||||||
|
|
@ -58,6 +60,8 @@ public abstract class GuiWindow implements Initializable{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract String getTitle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every time before showed on stage
|
* Called every time before showed on stage
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -113,4 +113,9 @@ public class EditorWindow extends GuiWindow {
|
||||||
this.listsners.add(listener);
|
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){
|
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) {
|
public void addLoginDialogListener(LoginDialogListener listener) {
|
||||||
this.listeners.add(listener);
|
this.listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTitle() {
|
||||||
|
return "Login";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?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>
|
<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>
|
<content>
|
||||||
<ListView fx:id="projectListView" prefHeight="200.0" prefWidth="200.0" />
|
<ListView fx:id="projectListView" prefHeight="200.0" prefWidth="200.0" />
|
||||||
</content>
|
</content>
|
||||||
</ScrollPane>
|
</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>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
<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" />
|
<Insets left="10.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button mnemonicParsing="false" onAction="#refresh" text="Refresh">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets left="10.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</AnchorPane>
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,16 @@ public class SelectProjectDialog extends GuiWindow {
|
||||||
projectListView.setCellFactory(new Callback<ListView<ProjectListItem>, ListCell<ProjectListItem>>(){
|
projectListView.setCellFactory(new Callback<ListView<ProjectListItem>, ListCell<ProjectListItem>>(){
|
||||||
@Override
|
@Override
|
||||||
public ListCell<ProjectListItem> call(ListView<ProjectListItem> arg0) {
|
public ListCell<ProjectListItem> call(ListView<ProjectListItem> arg0) {
|
||||||
|
System.out.println("cell factory");
|
||||||
ListCell<ProjectListItem> cell = new ListCell<ProjectListItem>(){
|
ListCell<ProjectListItem> cell = new ListCell<ProjectListItem>(){
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(ProjectListItem item, boolean empty){
|
protected void updateItem(ProjectListItem item, boolean empty){
|
||||||
|
System.out.println("update item: " + item);
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
|
if(empty){
|
||||||
|
setText("");
|
||||||
|
setGraphic(null);
|
||||||
|
}
|
||||||
if(item != null){
|
if(item != null){
|
||||||
setText(item.toString());
|
setText(item.toString());
|
||||||
//setGraphic(null);
|
//setGraphic(null);
|
||||||
|
|
@ -124,5 +130,10 @@ public class SelectProjectDialog extends GuiWindow {
|
||||||
ProjectListItem item = new ProjectListItem(projectName, projectData.type, projectData.description);
|
ProjectListItem item = new ProjectListItem(projectName, projectData.type, projectData.description);
|
||||||
this.projectList.add(item);
|
this.projectList.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTitle() {
|
||||||
|
return "Select Project";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?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">
|
<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>
|
<children>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
|
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
|
||||||
|
|
@ -24,7 +23,7 @@
|
||||||
<children>
|
<children>
|
||||||
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
|
<HBox alignment="CENTER_RIGHT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="Cancel">
|
<Button fx:id="exitButton" mnemonicParsing="false" onAction="#exit" text="Exit">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class SelectServerDialog extends GuiWindow {
|
||||||
private String address = null;
|
private String address = null;
|
||||||
private int port = -1;
|
private int port = -1;
|
||||||
|
|
||||||
@FXML private Button cancelButton;
|
@FXML private Button exitButton;
|
||||||
@FXML private Button connectButton;
|
@FXML private Button connectButton;
|
||||||
|
|
||||||
public SelectServerDialog() throws IOException {
|
public SelectServerDialog() throws IOException {
|
||||||
|
|
@ -45,9 +45,9 @@ public class SelectServerDialog extends GuiWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void cancel(ActionEvent event){
|
protected void exit(ActionEvent event){
|
||||||
for(SelectServerDialogListener listener : this.listeners){
|
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 willShow();
|
||||||
|
|
||||||
void cancel();
|
void exit();
|
||||||
|
|
||||||
void connect(String serverAddress, int port);
|
void connect(String serverAddress, int port);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue