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
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue