the project list will now be populated with data from the server
This commit is contained in:
parent
3634a61ee5
commit
bd77c2de28
10 changed files with 207 additions and 201 deletions
|
|
@ -13,7 +13,6 @@ 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.server.message.CoderMessage;
|
||||
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
|
@ -24,12 +23,11 @@ import javafx.scene.control.Button;
|
|||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
|
||||
public class EditorWindow extends GuiWindow {
|
||||
|
||||
private HashSet<EditorWindowListener> listsners = new HashSet<EditorWindowListener>();
|
||||
private HashSet<EditorWindowListener> listsners;
|
||||
|
||||
@FXML private TreeView<String> fileTreeView;
|
||||
@FXML private TextArea editTextArea;
|
||||
|
|
@ -39,6 +37,7 @@ public class EditorWindow extends GuiWindow {
|
|||
|
||||
public EditorWindow() throws IOException{
|
||||
super(EditorWindow.class.getResource("EditorWindow.fxml"));
|
||||
listsners = new HashSet<EditorWindowListener>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -49,17 +48,23 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleCompile(ActionEvent event){
|
||||
|
||||
for(EditorWindowListener listener : listsners){
|
||||
listener.compile();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupFileTreeView(){
|
||||
|
|
@ -104,7 +109,7 @@ public class EditorWindow extends GuiWindow {
|
|||
propertySheet.getItems().add(p2);
|
||||
}
|
||||
|
||||
public void addMessageSentListener(EditorWindowListener listener) {
|
||||
public void addEditorWindowListener(EditorWindowListener listener) {
|
||||
this.listsners.add(listener);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,8 @@ package com.coder.client.gui.editor;
|
|||
|
||||
public interface EditorWindowListener {
|
||||
|
||||
public void willShow();
|
||||
public void compile();
|
||||
public void run();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import javafx.scene.input.KeyCode;
|
|||
import javafx.scene.input.KeyEvent;
|
||||
|
||||
import com.coder.client.gui.GuiWindow;
|
||||
import com.coder.client.gui.selectProject.SelectProjectDialogListener;
|
||||
|
||||
public class LoginDialog extends GuiWindow {
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
|
|
|
|||
18
src/com/coder/client/gui/selectProject/ProjectListItem.java
Normal file
18
src/com/coder/client/gui/selectProject/ProjectListItem.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package com.coder.client.gui.selectProject;
|
||||
|
||||
public class ProjectListItem {
|
||||
private String projectName;
|
||||
private String type;
|
||||
private String description;
|
||||
|
||||
public ProjectListItem(String projectName, String type, String description) {
|
||||
this.projectName = projectName;
|
||||
this.type = type;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "ProjectName="+projectName+", type="+type+", description="+description;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,20 +8,26 @@ import java.util.logging.Logger;
|
|||
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import com.coder.client.gui.GuiWindow;
|
||||
import com.coder.server.message.ProjectListData;
|
||||
|
||||
public class SelectProjectDialog extends GuiWindow {
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
private HashSet<SelectProjectDialogListener> listeners;
|
||||
private ObservableList<ProjectListItem> projectList;
|
||||
|
||||
@FXML private ListView projectListView;
|
||||
@FXML private ListView<ProjectListItem> projectListView;
|
||||
@FXML private Button newProjectButton;
|
||||
@FXML private Button cancelButton;
|
||||
@FXML private Button openProjectButton;
|
||||
|
|
@ -40,7 +46,24 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
|
||||
@Override
|
||||
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
||||
|
||||
projectList = FXCollections.observableArrayList();
|
||||
projectListView.setItems(projectList);
|
||||
projectListView.setCellFactory(new Callback<ListView<ProjectListItem>, ListCell<ProjectListItem>>(){
|
||||
@Override
|
||||
public ListCell<ProjectListItem> call(ListView<ProjectListItem> arg0) {
|
||||
ListCell<ProjectListItem> cell = new ListCell<ProjectListItem>(){
|
||||
@Override
|
||||
protected void updateItem(ProjectListItem item, boolean empty){
|
||||
super.updateItem(item, empty);
|
||||
if(item != null){
|
||||
setText(item.toString());
|
||||
//setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
@ -62,6 +85,8 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
for(SelectProjectDialogListener listener : this.listeners){
|
||||
listener.newProject();
|
||||
}
|
||||
ProjectListItem item = new ProjectListItem("name", "type", "decription");
|
||||
this.projectList.add(item);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
@ -71,6 +96,13 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void refresh(ActionEvent event){
|
||||
for(SelectProjectDialogListener listener : this.listeners){
|
||||
listener.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void openProject(ActionEvent event){
|
||||
for(SelectProjectDialogListener listener : this.listeners){
|
||||
|
|
@ -85,11 +117,14 @@ public class SelectProjectDialog extends GuiWindow {
|
|||
}
|
||||
|
||||
public void clearProjectList(){
|
||||
logger.fine("Clearing project list");
|
||||
//TODO
|
||||
}
|
||||
|
||||
public void addProjectToList(String name, String type){
|
||||
//TODO
|
||||
|
||||
public void addProjectToList(String projectName, ProjectListData projectData) {
|
||||
logger.fine("Adding project \"" + projectName + "\" of type " + projectData.type + "to project list");
|
||||
ProjectListItem item = new ProjectListItem(projectName, projectData.type, projectData.description);
|
||||
this.projectList.add(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,6 @@ public interface SelectProjectDialogListener {
|
|||
|
||||
void willShow();
|
||||
|
||||
void refresh();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ import com.coder.client.gui.GuiWindow;
|
|||
public class SelectServerDialog extends GuiWindow {
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
private HashSet<SelectServerDialogListener> listeners;
|
||||
private String url = null;
|
||||
private String address = null;
|
||||
private int port = -1;
|
||||
|
||||
@FXML private Button cancelButton;
|
||||
@FXML private Button connectButton;
|
||||
|
|
@ -32,7 +33,7 @@ public class SelectServerDialog extends GuiWindow {
|
|||
for(SelectServerDialogListener listener : this.listeners){
|
||||
listener.willShow();
|
||||
}
|
||||
if(url != null){
|
||||
if(address != null && port != -1){
|
||||
connectButton.fire();
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +54,7 @@ public class SelectServerDialog extends GuiWindow {
|
|||
@FXML
|
||||
protected void connect(ActionEvent event){
|
||||
for(SelectServerDialogListener listener : this.listeners){
|
||||
listener.connect(url);
|
||||
listener.connect(address, port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,8 +62,13 @@ public class SelectServerDialog extends GuiWindow {
|
|||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
public void setURL(String url) {
|
||||
this.url = url;
|
||||
public void setServerAddress(String serverAddress) {
|
||||
this.address = serverAddress;
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
this.port = serverPort;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ public interface SelectServerDialogListener {
|
|||
|
||||
void cancel();
|
||||
|
||||
void connect(String url);
|
||||
void connect(String serverAddress, int port);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue