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
|
|
@ -18,7 +18,10 @@ import com.coder.client.gui.selectServer.SelectServerDialog;
|
|||
import com.coder.client.gui.selectServer.SelectServerDialogListener;
|
||||
import com.coder.server.CoderServer;
|
||||
import com.coder.server.message.CoderMessage;
|
||||
import com.coder.server.message.ConfigData;
|
||||
import com.coder.server.message.ProjectListData;
|
||||
import com.coder.server.message.ProjectListReqMsg;
|
||||
import com.coder.server.message.ProjectRspMsg;
|
||||
|
||||
import zutil.log.CompactLogFormatter;
|
||||
import zutil.log.LogUtil;
|
||||
|
|
@ -27,21 +30,22 @@ import javafx.stage.Stage;
|
|||
|
||||
public class CoderClient extends Application{
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
private int port = CoderServer.SERVER_PORT;
|
||||
private static final int DEFAULT_CONNECTION_RETRIES = 5;
|
||||
|
||||
private Session session;
|
||||
private Stage mainStage;
|
||||
private int connectionRetriesLimit = DEFAULT_CONNECTION_RETRIES; //if zero, try forever
|
||||
|
||||
private String url;
|
||||
private String username = null;
|
||||
private char[] password = null;
|
||||
|
||||
//GUI elements
|
||||
private EditorWindow editorWindow;
|
||||
private LoginDialog loginDialog;
|
||||
private SelectProjectDialog selectProjectDialog;
|
||||
private SelectServerDialog selectServerDialog;
|
||||
|
||||
//state variables
|
||||
private String serverURL = null;
|
||||
private int serverPort = CoderServer.SERVER_PORT;
|
||||
private String username = null;
|
||||
private char[] password = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(args);
|
||||
}
|
||||
|
|
@ -55,80 +59,78 @@ public class CoderClient extends Application{
|
|||
|
||||
//parse program arguments
|
||||
Map<String, String> params = this.getParameters().getNamed();
|
||||
String url = null;
|
||||
String username = null;
|
||||
char[] password = null;
|
||||
boolean reconnectForever = false;
|
||||
for(String key : params.keySet()){
|
||||
String value = params.get(key);
|
||||
if(key.equals("username")){
|
||||
username = value;
|
||||
this.username = value;
|
||||
}else if(key.equals("password")){
|
||||
password = value.toCharArray();
|
||||
}else if(key.equals("retry-connect-forever")){
|
||||
reconnectForever = true;
|
||||
this.password = value.toCharArray();
|
||||
}else if(key.equals("url")){
|
||||
url = value;
|
||||
this.serverURL = value;
|
||||
}else if(key.equals("port")){
|
||||
try{
|
||||
this.serverPort = Integer.parseInt(value);
|
||||
}catch(NumberFormatException e){
|
||||
logger.warning("port argument to program is not of a integer type. using default port.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create a client instance
|
||||
if(url != null){
|
||||
this.url = url;
|
||||
}
|
||||
if(username != null){
|
||||
this.username = username;
|
||||
if(password != null){
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
if(reconnectForever){
|
||||
this.connectionRetriesLimit = 0;
|
||||
if(this.username == null){ //ignore the password if no username was set
|
||||
this.password = null;
|
||||
}
|
||||
|
||||
//loading GUI
|
||||
this.mainStage = mainStage;
|
||||
mainStage.setTitle("CoderClient");
|
||||
this.editorWindow = new EditorWindow();
|
||||
this.loginDialog = new LoginDialog();
|
||||
this.selectProjectDialog = new SelectProjectDialog();
|
||||
this.selectServerDialog = new SelectServerDialog();
|
||||
|
||||
//register listeners
|
||||
registerListeners();
|
||||
try{
|
||||
setupSelectServerDialog();
|
||||
setupLoginDialog();
|
||||
setupSelectProjectDialog();
|
||||
setupEditWindow();
|
||||
}catch(IOException e){
|
||||
logger.log(Level.SEVERE, "could not load all GUI elements", e);
|
||||
}
|
||||
|
||||
//start program logic
|
||||
selectServerDialog.showOnStage(mainStage);
|
||||
|
||||
//run();
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
|
||||
private void setupSelectServerDialog() throws IOException{
|
||||
this.selectServerDialog = new SelectServerDialog();
|
||||
this.selectServerDialog.addSelectProjectDialogListener(new SelectServerDialogListener() {
|
||||
@Override
|
||||
public void willShow() {
|
||||
selectServerDialog.setURL(url);
|
||||
closeCurrentSession();
|
||||
selectServerDialog.setServerAddress(serverURL);
|
||||
selectServerDialog.setServerPort(serverPort);
|
||||
}
|
||||
@Override
|
||||
public void cancel() {
|
||||
//TODO
|
||||
logger.info("terminating");
|
||||
System.exit(0);
|
||||
}
|
||||
@Override
|
||||
public void connect(String serverUrl) {
|
||||
public void connect(String address, int port) {
|
||||
//selectServerDialog.hide();
|
||||
url = serverUrl;
|
||||
serverURL = address;
|
||||
serverPort = port;
|
||||
//connect session
|
||||
session = Session.setupConnection(url, port);
|
||||
session = Session.setupConnection(serverURL, serverPort);
|
||||
if(session == null){
|
||||
logger.warning("Could not setup a connection to " + url + ":" + port);
|
||||
url = null;
|
||||
logger.warning("Could not setup a connection to " + serverURL + ":" + port);
|
||||
serverURL = null;
|
||||
selectServerDialog.showOnStage(mainStage);
|
||||
}else{
|
||||
loginDialog.showOnStage(mainStage);
|
||||
}
|
||||
loginDialog.showOnStage(mainStage);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setupLoginDialog() throws IOException {
|
||||
this.loginDialog = new LoginDialog();
|
||||
this.loginDialog.addLoginDialogListener(new LoginDialogListener(){
|
||||
@Override
|
||||
public void willShow() {
|
||||
|
|
@ -137,7 +139,9 @@ public class CoderClient extends Application{
|
|||
}
|
||||
@Override
|
||||
public void cancel() {
|
||||
//TODO
|
||||
serverURL = null;
|
||||
serverPort = CoderServer.SERVER_PORT;
|
||||
selectServerDialog.showOnStage(mainStage);
|
||||
}
|
||||
@Override
|
||||
public void login(String uname, char[] paswd) {
|
||||
|
|
@ -151,25 +155,40 @@ public class CoderClient extends Application{
|
|||
password = null;
|
||||
loginDialog.showOnStage(mainStage);
|
||||
}
|
||||
setupSessionListener(); //resister a message listener to the session
|
||||
session.start(); //start receiving traffic from the server
|
||||
selectProjectDialog.showOnStage(mainStage);
|
||||
}
|
||||
});
|
||||
private void setupSessionListener(){
|
||||
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
|
||||
@Override
|
||||
public void projectListRspReceived(Map<String, ProjectListData> projectListRsp) {
|
||||
for(String projectName : projectListRsp.keySet()){
|
||||
ProjectListData projectData = projectListRsp.get(projectName);
|
||||
selectProjectDialog.addProjectToList(projectName, projectData);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void projectRspReceived(ProjectRspMsg projectRspMsg) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void projectTypeRspReceived(Map<String, ConfigData> projectTypeRsp) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupSelectProjectDialog() throws IOException {
|
||||
this.selectProjectDialog = new SelectProjectDialog();
|
||||
this.selectProjectDialog.addSelectProjectDialogListener(new SelectProjectDialogListener() {
|
||||
@Override
|
||||
public void willShow() {
|
||||
//clear current list of project
|
||||
selectProjectDialog.clearProjectList();
|
||||
|
||||
//send a request for a new list of projects
|
||||
CoderMessage msg = new CoderMessage();
|
||||
msg.ProjectListReq = new ProjectListReqMsg();
|
||||
try {
|
||||
session.send(msg);
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Unable to send ProjectListReqMsg", e);
|
||||
closeCurrentSession();
|
||||
}
|
||||
sendProjectListReq();
|
||||
}
|
||||
@Override
|
||||
public void openProject(String selectedProjectName) {
|
||||
|
|
@ -181,14 +200,45 @@ public class CoderClient extends Application{
|
|||
}
|
||||
@Override
|
||||
public void cancel() {
|
||||
serverURL = null;
|
||||
serverPort = CoderServer.SERVER_PORT;
|
||||
selectServerDialog.showOnStage(mainStage);
|
||||
}
|
||||
@Override
|
||||
public void refresh() {
|
||||
selectProjectDialog.clearProjectList();
|
||||
sendProjectListReq();
|
||||
}
|
||||
private void sendProjectListReq(){
|
||||
//send a request for a new list of projects
|
||||
CoderMessage msg = new CoderMessage();
|
||||
msg.ProjectListReq = new ProjectListReqMsg();
|
||||
try {
|
||||
session.send(msg);
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "Unable to send ProjectListReqMsg", e);
|
||||
closeCurrentSession();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupEditWindow() throws IOException {
|
||||
this.editorWindow = new EditorWindow();
|
||||
this.editorWindow.addEditorWindowListener(new EditorWindowListener() {
|
||||
@Override
|
||||
public void willShow() {
|
||||
//TODO
|
||||
}
|
||||
@Override
|
||||
public void compile() {
|
||||
//TODO
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
//TODO
|
||||
}
|
||||
});
|
||||
|
||||
this.editorWindow.addMessageSentListener(new EditorWindowListener() {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void closeCurrentSession(){
|
||||
|
|
@ -197,106 +247,5 @@ public class CoderClient extends Application{
|
|||
session = null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
public void run(){
|
||||
//keep track of the number of connection retries to the server
|
||||
int connectionRetries = 0;
|
||||
while(true){
|
||||
//close previous session if applicable
|
||||
closeCurrentSession();
|
||||
|
||||
//setup a new session
|
||||
if(connectionRetries > 0){
|
||||
logger.fine("This is reconnection try number: " + connectionRetries);
|
||||
}
|
||||
logger.fine("Setting up a connected session");
|
||||
this.session = Session.setupConnection(url, port);
|
||||
if(session == null){
|
||||
logger.warning("Could not setup a connection to " + url + ":" + port);
|
||||
connectionRetries++;
|
||||
if(connectionRetriesLimit > 0 && connectionRetries > connectionRetriesLimit){
|
||||
//stop trying to connect
|
||||
logger.severe("Was not able to conenct to the remote host.");
|
||||
break;
|
||||
}else{
|
||||
//wait for awhile and try to connect one more
|
||||
logger.info("Will retry to connect once more in 2 seconds.");
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//get user credentials
|
||||
if(username != null && !username.isEmpty() && password != null && password.length > 0){
|
||||
//do nothing, already have all credentials we need
|
||||
logger.fine("All login credentials have already been given. No need for a login dialog.");
|
||||
}else{
|
||||
//ask for username and password in a dialog window
|
||||
logger.info("All or some login credentials have not been given. Using a dialog for input.");
|
||||
loginDialog.setUsername(username);
|
||||
loginDialog.showModal(this.mainStage);
|
||||
if(loginDialog.getAction() == LoginDialogAction.CANCEL){
|
||||
logger.fine("Login dialog closed or canceled by the user. terminating.");
|
||||
break;
|
||||
}
|
||||
username = loginDialog.getUsername();
|
||||
password = loginDialog.getPassword();
|
||||
}
|
||||
logger.fine("The username: \"" + username + "\" will be used as the credential holder");
|
||||
|
||||
//authenticate the user
|
||||
boolean authenticated = session.authenticate(username, password);
|
||||
if(!authenticated){
|
||||
JOptionPane.showMessageDialog(null, "Wrong username or password", "Authentication Failed", JOptionPane.INFORMATION_MESSAGE);
|
||||
logger.severe("Authentication failed: wrong username or password");
|
||||
continue;
|
||||
}
|
||||
|
||||
//resister a message listener to the session
|
||||
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
|
||||
@Override
|
||||
public void projectListRspReceived(Map<String, ProjectListData> projectListRsp) {
|
||||
for(String projectName : projectListRsp.keySet()){
|
||||
ProjectListData projectData = projectListRsp.get(projectName);
|
||||
selectProjectDialog.addProjectToList(projectName, projectData.type);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void projectTypeRspReceived(Map<String, ConfigData> projectTypeRsp) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void projectRspReceived(ProjectRspMsg projectRspMsg) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
});
|
||||
|
||||
//start receiving traffic from the server
|
||||
session.start();
|
||||
|
||||
//show the project selector dialog
|
||||
this.selectProjectDialog.showModal(mainStage);
|
||||
|
||||
//wait here until the session is closed for some reason
|
||||
|
||||
while(session.isConnected()){
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
//hide the main GUI
|
||||
logger.fine("The socket was closed.");
|
||||
mainStage.close();
|
||||
Thread.yield();
|
||||
}
|
||||
logger.info("The program till now terminate");
|
||||
closeCurrentSession();
|
||||
// this.projectEditorWindow.dispose();
|
||||
System.exit(0);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,12 @@
|
|||
package com.coder.client;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import zutil.Encrypter;
|
||||
import zutil.Hasher;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.json.JSONObjectInputStream;
|
||||
import zutil.parser.json.JSONObjectOutputStream;
|
||||
|
|
@ -28,7 +17,6 @@ import com.coder.server.message.CoderMessage;
|
|||
|
||||
public class Session extends Thread {
|
||||
public static final Logger logger = LogUtil.getLogger();
|
||||
private static final int AUTH_HASH_ITERATIONS = 500;
|
||||
|
||||
private HashSet<CoderMessageReceivedListener> messageReceivedlisteners = new HashSet<CoderMessageReceivedListener>();
|
||||
|
||||
|
|
@ -82,11 +70,11 @@ public class Session extends Thread {
|
|||
try {
|
||||
msg = in.readGenericObject();
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "socket is probably closed by the peer", e);
|
||||
//logger.log(Level.SEVERE, "socket is probably closed by the peer", e);
|
||||
break;
|
||||
}
|
||||
if(msg == null){
|
||||
logger.severe("socket is probably closed by the peer");
|
||||
//logger.severe("socket is probably closed by the peer");
|
||||
break;
|
||||
}else{
|
||||
handleMessage(msg);
|
||||
|
|
|
|||
|
|
@ -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