new support classes added
This commit is contained in:
parent
9764f546da
commit
83e0196c50
21 changed files with 798 additions and 9 deletions
5
src/com/coder/client/gui/Controller.java
Normal file
5
src/com/coder/client/gui/Controller.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package com.coder.client.gui;
|
||||
|
||||
public class Controller {
|
||||
|
||||
}
|
||||
32
src/com/coder/client/gui/EditorWindow.java
Normal file
32
src/com/coder/client/gui/EditorWindow.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package com.coder.client.gui;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class EditorWindow extends Application {
|
||||
|
||||
public EditorWindow(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("EditorWindowGUI.fxml"));
|
||||
|
||||
EditorWindowController editorController = loader.<EditorWindowController>getController();
|
||||
|
||||
Scene editorScene = new Scene((Parent)loader.load());
|
||||
|
||||
stage.setTitle("CoderClient");
|
||||
stage.setScene(editorScene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(EditorWindow.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
113
src/com/coder/client/gui/EditorWindowController.java
Normal file
113
src/com/coder/client/gui/EditorWindowController.java
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
package com.coder.client.gui;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.controlsfx.control.PropertySheet;
|
||||
import org.controlsfx.property.editor.PropertyEditor;
|
||||
|
||||
import com.coder.client.GUIMessageSentListener;
|
||||
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;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.control.TreeItem;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
public class EditorWindowController extends Controller implements Initializable {
|
||||
|
||||
private HashSet<GUIMessageSentListener> GUIMessageSentListeners = new HashSet<GUIMessageSentListener>();
|
||||
|
||||
@FXML private TreeView<String> fileTreeView;
|
||||
@FXML private TextArea editTextArea;
|
||||
@FXML private PropertySheet propertySheet;
|
||||
@FXML private Button compileButton;
|
||||
@FXML private Button runButton;
|
||||
|
||||
public EditorWindowController(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
|
||||
|
||||
setupPropertySheet();
|
||||
setupFileTreeView();
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleRun(ActionEvent event){
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handleCompile(ActionEvent event){
|
||||
|
||||
}
|
||||
|
||||
private void setupFileTreeView(){
|
||||
fileTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends TreeItem<String>> item, TreeItem<String> oldValue, TreeItem<String> newValue) {
|
||||
if(newValue != fileTreeView.getRoot()){
|
||||
System.out.println("INFO: item " + newValue + " selected");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TreeItem<String> root = new TreeItem<String>("root");
|
||||
root.setExpanded(true);
|
||||
fileTreeView.setRoot(root);
|
||||
|
||||
}
|
||||
|
||||
private void setupPropertySheet(){
|
||||
//handle custom ProperySheet.Item's editor
|
||||
propertySheet.setPropertyEditorFactory(new Callback<PropertySheet.Item, PropertyEditor<?>>(){
|
||||
@Override
|
||||
public PropertyEditor<?> call(PropertySheet.Item param) {
|
||||
//only support internal types
|
||||
if(param instanceof CoderClientProperty){
|
||||
return ((CoderClientProperty<?>)param).getEditor();
|
||||
}
|
||||
//not a internal property type
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
propertySheet.getItems().clear();
|
||||
|
||||
ArrayList<String> boards = new ArrayList<String>();
|
||||
boards.add("UNO");
|
||||
boards.add("Mega");
|
||||
ComboBoxProperty p1 = new ComboBoxProperty("Port", null, boards);
|
||||
propertySheet.getItems().add(p1);
|
||||
|
||||
CheckBoxProperty p2 = new CheckBoxProperty("Melt?", false);
|
||||
propertySheet.getItems().add(p2);
|
||||
}
|
||||
|
||||
public void addMessageSentListener(GUIMessageSentListener listener) {
|
||||
this.GUIMessageSentListeners.add(listener);
|
||||
}
|
||||
|
||||
private void sendMessage(CoderMessage msg){
|
||||
for(GUIMessageSentListener listener : GUIMessageSentListeners){
|
||||
listener.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
47
src/com/coder/client/gui/EditorWindowGUI.fxml
Normal file
47
src/com/coder/client/gui/EditorWindowGUI.fxml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import org.controlsfx.control.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<SplitPane dividerPositions="0.26588628762541805, 0.7391304347826086" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.coder.client.gui.EditorWindowController">
|
||||
<items>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" SplitPane.resizableWithParent="false">
|
||||
<children>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="398.0" prefWidth="156.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<TreeView fx:id="fileTreeView" prefHeight="398.0" prefWidth="156.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children></AnchorPane>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
|
||||
<children>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="398.0" prefWidth="271.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<TextArea fx:id="editTextArea" prefHeight="398.0" prefWidth="271.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children></AnchorPane>
|
||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" SplitPane.resizableWithParent="false">
|
||||
<children>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<PropertySheet fx:id="propertySheet" modeSwitcherVisible="false" searchBoxVisible="false" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<HBox alignment="CENTER" maxHeight="50.0" prefHeight="50.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
||||
<children>
|
||||
<Button fx:id="compileButton" mnemonicParsing="false" onAction="#handleCompile" text="Compile">
|
||||
<HBox.margin>
|
||||
<Insets right="15.0" />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<Button fx:id="runButton" mnemonicParsing="false" onAction="#handleRun" text="Run" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
Loading…
Add table
Add a link
Reference in a new issue