Refactoring: Moving GUI program logic from CoderClient to each controller class
-Removing the Session Guard -Adding a SessionHandler -Adding a ProjectHandler
This commit is contained in:
parent
0a580f8c53
commit
5a9e709ae8
22 changed files with 656 additions and 655 deletions
|
|
@ -3,17 +3,26 @@ package com.coder.client.gui.editor;
|
|||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.controlsfx.control.PropertySheet;
|
||||
import org.controlsfx.property.editor.PropertyEditor;
|
||||
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import com.coder.client.CoderClient;
|
||||
import com.coder.client.gui.GuiWindow;
|
||||
import com.coder.client.property.CheckBoxProperty;
|
||||
import com.coder.client.property.CoderClientProperty;
|
||||
import com.coder.client.property.ComboBoxProperty;
|
||||
|
||||
import com.coder.client.session.ProjectRspMsgListener;
|
||||
import com.coder.client.session.ProjectTypeRspMsgListener;
|
||||
import com.coder.client.session.SessionListener;
|
||||
import com.coder.server.message.ProjectRspMsg;
|
||||
import com.coder.server.message.ProjectTypeRspMsg;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
|
@ -26,9 +35,9 @@ import javafx.scene.control.TreeView;
|
|||
import javafx.util.Callback;
|
||||
|
||||
public class EditorWindow extends GuiWindow {
|
||||
|
||||
private HashSet<EditorWindowListener> listsners;
|
||||
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
private CoderClient client;
|
||||
|
||||
@FXML private TreeView<String> fileTreeView;
|
||||
@FXML private TextArea editTextArea;
|
||||
@FXML private PropertySheet propertySheet;
|
||||
|
|
@ -37,9 +46,31 @@ public class EditorWindow extends GuiWindow {
|
|||
@FXML private Button exitButton;
|
||||
@FXML private Button changeProjectButton;
|
||||
|
||||
public EditorWindow() throws IOException{
|
||||
public EditorWindow(CoderClient client) throws IOException{
|
||||
super(EditorWindow.class.getResource("EditorWindow.fxml"));
|
||||
listsners = new HashSet<EditorWindowListener>();
|
||||
this.client = client;
|
||||
client.getSessionHandler().addMessageListener(new ProjectRspMsgListener() {
|
||||
@Override
|
||||
public void messageReceived(final ProjectRspMsg msg) {
|
||||
logger.fine("a ProjectRspMsg received");
|
||||
if(msg.error != null){
|
||||
return;
|
||||
}
|
||||
setProjectName(msg.name);
|
||||
|
||||
Properties projectConfig = msg.config;
|
||||
String projectDescription = msg.description;
|
||||
List<String> fileList = msg.fileList;
|
||||
String projectType = msg.type;
|
||||
//TODO: handle msg
|
||||
}
|
||||
});
|
||||
client.getSessionHandler().addMessageListener(new ProjectTypeRspMsgListener() {
|
||||
@Override
|
||||
public void messageReceived(ProjectTypeRspMsg msg) {
|
||||
//TODO: update the project properties
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -50,37 +81,28 @@ public class EditorWindow extends GuiWindow {
|
|||
|
||||
@Override
|
||||
protected void willShow(){
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.willShow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleRun(ActionEvent event){
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.run();
|
||||
}
|
||||
protected void run(ActionEvent event){
|
||||
//TODO
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleCompile(ActionEvent event){
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.compile();
|
||||
}
|
||||
protected void compile(ActionEvent event){
|
||||
//TODO
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleChangeProject(ActionEvent event){
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.changeProject();
|
||||
}
|
||||
protected void changeProject(ActionEvent event){
|
||||
client.getProjectHandler().setProject(null);
|
||||
client.getProjectHandler().selectProject();
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleExit(ActionEvent event){
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.exit();
|
||||
}
|
||||
protected void exit(ActionEvent event){
|
||||
client.exit();
|
||||
}
|
||||
|
||||
private void setupFileTreeView(){
|
||||
|
|
@ -124,18 +146,13 @@ public class EditorWindow extends GuiWindow {
|
|||
CheckBoxProperty p2 = new CheckBoxProperty("Melt?", false);
|
||||
propertySheet.getItems().add(p2);
|
||||
}
|
||||
|
||||
public void addEditorWindowListener(EditorWindowListener listener) {
|
||||
this.listsners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "Coder Client";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorMessage(String msg) {
|
||||
private void setErrorMessage(String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
|
@ -144,4 +161,9 @@ public class EditorWindow extends GuiWindow {
|
|||
fileTreeView.getRoot().setValue(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDescriptiveName() {
|
||||
return "Editor Window";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue