2015-10-20 15:52:23 +00:00
|
|
|
package com.coder.client.gui.selectProject;
|
2015-10-20 14:26:58 +00:00
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
import zutil.log.LogUtil;
|
|
|
|
|
|
|
|
|
|
import javafx.event.ActionEvent;
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
|
import javafx.scene.control.ListView;
|
|
|
|
|
import javafx.scene.input.KeyCode;
|
|
|
|
|
import javafx.scene.input.KeyEvent;
|
|
|
|
|
|
|
|
|
|
import com.coder.client.gui.GuiWindow;
|
|
|
|
|
|
|
|
|
|
public class SelectProjectDialog extends GuiWindow {
|
|
|
|
|
public static final Logger logger = LogUtil.getLogger();
|
|
|
|
|
private HashSet<SelectProjectDialogListener> listeners;
|
|
|
|
|
|
|
|
|
|
@FXML private ListView projectListView;
|
|
|
|
|
@FXML private Button newProjectButton;
|
|
|
|
|
@FXML private Button cancelButton;
|
|
|
|
|
@FXML private Button openProjectButton;
|
|
|
|
|
|
|
|
|
|
public SelectProjectDialog() throws IOException {
|
|
|
|
|
super(SelectProjectDialog.class.getResource("SelectProjectDialog.fxml"));
|
|
|
|
|
listeners = new HashSet<SelectProjectDialogListener>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void willShow() {
|
|
|
|
|
for(SelectProjectDialogListener listener : this.listeners){
|
|
|
|
|
listener.willShow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
protected void keyPressed(KeyEvent event) {
|
|
|
|
|
if(event.getCode() == KeyCode.ENTER){
|
|
|
|
|
logger.fine("User pressed the ENTER key");
|
|
|
|
|
openProjectButton.fire();
|
|
|
|
|
}else if(event.getCode() == KeyCode.ESCAPE){
|
|
|
|
|
logger.fine("User pressed the ESCAPE key");
|
|
|
|
|
cancelButton.fire();
|
|
|
|
|
}else if(event.getCode() == KeyCode.N && event.isControlDown()){ //CTRL+N
|
|
|
|
|
logger.fine("User pressed CTRL+N");
|
|
|
|
|
newProjectButton.fire();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
protected void newProject(ActionEvent event){
|
|
|
|
|
for(SelectProjectDialogListener listener : this.listeners){
|
|
|
|
|
listener.newProject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
protected void cancel(ActionEvent event){
|
|
|
|
|
for(SelectProjectDialogListener listener : this.listeners){
|
|
|
|
|
listener.cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
protected void openProject(ActionEvent event){
|
|
|
|
|
for(SelectProjectDialogListener listener : this.listeners){
|
|
|
|
|
//TODO: get selected project in the list view
|
|
|
|
|
String selectedProjectName = "project name";
|
|
|
|
|
listener.openProject(selectedProjectName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addSelectProjectDialogListener(SelectProjectDialogListener listener){
|
|
|
|
|
this.listeners.add(listener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearProjectList(){
|
|
|
|
|
//TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addProjectToList(String name, String type){
|
|
|
|
|
//TODO
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|