Skip to content

Commit

Permalink
Added console, maintaining compatibility with Pand, code cleanup and …
Browse files Browse the repository at this point in the history
…fixes.
  • Loading branch information
cyaffle authored and dzikoysk committed May 1, 2016
1 parent 42bc896 commit f94fb91
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.panda_lang</groupId>
<artifactId>lily</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lily</name>
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/panda_lang/lily/Lily.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ public void start(Stage stage) throws Exception {

// Lily's ui
Parent root = FXMLLoader.load(getClass().getResource("/ui/interface.fxml"));
Scene scene = new Scene(root, bounds.getWidth() - 20, bounds.getHeight() * 0.5);
Scene scene = new Scene(root, bounds.getWidth() - 2, bounds.getHeight() * 0.9);
root.getStylesheets().add("/ui/themes/default_material.css");
stage.getIcons().add(new Image("/ui/icons/icon.png"));

// Lily's position
stage.setWidth(bounds.getWidth() - 20);
stage.setHeight(bounds.getHeight() * 0.8);
stage.setWidth(bounds.getWidth() - 2);
stage.setHeight(bounds.getHeight() * 0.9);
stage.setX((bounds.getWidth() - stage.getWidth()) / 2);
stage.setY((bounds.getHeight() - stage.getHeight()) / 2);

// Others
panda.initializeDefaultElements();
stage.setTitle("Lily the Panda IDE");
stage.setMaximized(true);
stage.setScene(scene);
stage.show();
}
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/org/panda_lang/lily/ui/ConsolePane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package org.panda_lang.lily.ui;

import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Region;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public class ConsolePane extends BorderPane {

private static ConsolePane instance;
private final ConsoleOutputStream consoleOutputStream;
private final TextArea textArea;

protected ConsolePane() {
this.textArea = new TextArea();
this.consoleOutputStream = new ConsoleOutputStream(this);

instance = this;
setCenter(textArea);
System.setOut(new PrintStream(consoleOutputStream));
}

public void bind(Region parent) {
prefWidthProperty().bind(parent.prefWidthProperty());
prefHeightProperty().bind(parent.prefHeightProperty());
}

public void clear() {
textArea.setText("");
}

public void write(char c) {
textArea.setText(textArea.getText() + c);
}

public TextArea getTextArea() {
return textArea;
}

public ConsoleOutputStream getConsoleOutputStream() {
return consoleOutputStream;
}

public static ConsolePane getInstance() {
return instance == null ? new ConsolePane() : instance;
}

private class ConsoleOutputStream extends OutputStream {

private final ConsolePane consolePane;

public ConsoleOutputStream(ConsolePane consolePane) {
this.consolePane = consolePane;
}

@Override
public void write(int b) throws IOException {
consolePane.write((char) b);
}

}

}
16 changes: 13 additions & 3 deletions src/main/java/org/panda_lang/lily/ui/Interface.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public class Interface implements Initializable {
@FXML private MenuItem menuRunRun;
@FXML private MenuItem menuHelpAbout;

@FXML private SplitPane splitPane;
@FXML private SplitPane workspacePane;
@FXML private SplitPane workspaceEditorPane;
@FXML private SplitPane workspaceAssistantsPane;
@FXML private TreeView<String> filesTree;
@FXML private TabPane tabPane;

Expand All @@ -48,8 +50,10 @@ public void initialize(URL url, ResourceBundle rb) {
// Initialize Interface
Lily.instance.initAnInterface(this);

// SplitPane
splitPane.setDividerPositions(0.25, 0.75);
// Dividers
workspacePane.setDividerPositions(0.75, 0.25);
workspaceEditorPane.setDividerPositions(0.25, 0.75);
workspaceAssistantsPane.setDividerPositions(1, 0);

// ProjectTree
tree = new ProjectTree(filesTree);
Expand Down Expand Up @@ -99,6 +103,12 @@ protected void initializeActions() {

// Action: Run -> Run
menuRunRun.setOnAction(event -> {
ConsolePane consolePane = ConsolePane.getInstance();
consolePane.clear();
workspaceAssistantsPane.getItems().clear();
workspaceAssistantsPane.getItems().add(consolePane);
consolePane.bind(workspaceAssistantsPane);

String source = (String) getCurrentTab().getWebEngine().executeScript("editor.getValue()");
PandaScript pandaScript = Lily.instance.getPanda().getPandaLoader().loadSimpleScript(source);
pandaScript.call(MethodBlock.class, "main");
Expand Down
13 changes: 8 additions & 5 deletions src/main/resources/ui/interface.fxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?><?import javafx.scene.layout.*?>
<?import javafx.scene.control.*?><?import javafx.scene.layout.*?><?import javafx.scene.web.WebView?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="1000.0" fx:controller="org.panda_lang.lily.ui.Interface">
<top>
<BorderPane prefHeight="50.0" prefWidth="1000.0" BorderPane.alignment="CENTER">
Expand Down Expand Up @@ -48,12 +48,15 @@
</BorderPane>
</top>
<center>
<SplitPane fx:id="splitPane" dividerPositions="0.1" prefHeight="200.0" prefWidth="1000.0" BorderPane.alignment="CENTER">
<TreeView fx:id="filesTree" editable="true" prefHeight="200.0" prefWidth="400.0"/>
<TabPane fx:id="tabPane" tabClosingPolicy="SELECTED_TAB" prefHeight="200.0" prefWidth="600.0"/>
<SplitPane fx:id="workspacePane" orientation="VERTICAL" prefWidth="1000.0" prefHeight="320.0">
<SplitPane fx:id="workspaceEditorPane" orientation="HORIZONTAL" prefHeight="250.0" prefWidth="1000.0">
<TreeView fx:id="filesTree" editable="true" prefWidth="400.0" prefHeight="250.0"/>
<TabPane fx:id="tabPane" tabClosingPolicy="SELECTED_TAB" prefWidth="600.0" prefHeight="250.0" />
</SplitPane>
<SplitPane fx:id="workspaceAssistantsPane" orientation="HORIZONTAL" prefWidth="1000.0" prefHeight="70.0" />
</SplitPane>
</center>
<bottom>
<ToolBar prefHeight="20.0" prefWidth="1000.0" BorderPane.alignment="CENTER"/>
<ToolBar fx:id="bottomToolBar" prefHeight="20.0" prefWidth="1000.0" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
17 changes: 8 additions & 9 deletions src/main/resources/ui/themes/dark_material.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@

.tool-bar {
-fx-background-color: #212121;
-fx-border-width: 1px 0px 0px 0px;
-fx-border-width: 1 0 0 0;
-fx-border-color: #2c2c2c #2c2c2c #2c2c2c #2c2c2c;
}

/* SplitPane */
.split-pane {
-fx-margin: 0px;
-fx-padding: 0px;
-fx-border-width: 1px 0px 0px 0px;
-fx-margin: 0;
-fx-padding: 0;
-fx-border-width: 1 0 0 0;
-fx-border-color: #2c2c2c #2c2c2c #2c2c2c #2c2c2c;
-fx-background-color: #212121;
}

.split-pane:horizontal > .split-pane-divider {
-fx-padding: 0 0 0 0;
.split-pane:vertical > .split-pane-divider, .split-pane:horizontal > .split-pane-divider {
-fx-padding: 0 0 0 10;
-fx-border-color: #212121;
-fx-background-color: #212121;
}

/* ScrollBar */
.scroll-bar:horizontal, .scroll-bar:vertical {
.scroll-bar:horizontal, .scroll-bar:vertical {
-fx-background-color: transparent;
}

Expand Down Expand Up @@ -94,12 +94,11 @@
/* TabPane */
.tab-pane {
-fx-background-color: #282829;
-fx-border-width: 0px 0px 0px 0px;
-fx-border-width: 0 0 0 0;
}

.tab-pane *.tab-header-background {
-fx-background-color: null;
-fx-effect: innershadow(two-pass-box , transparent , 0, 0.0 , 0 , 0);
}

.tab {
Expand Down
47 changes: 32 additions & 15 deletions src/main/resources/ui/themes/default_material.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* Pane */
.pane {
-fx-background-color: #2a2a2a;
}

/* Menu */
.menu-bar {
Expand All @@ -9,7 +13,7 @@
}

.menu .label {
-fx-text-fill: #FFFFFF;
-fx-text-fill: #ffffff;
}

.context-menu {
Expand All @@ -26,45 +30,46 @@

.tool-bar {
-fx-background-color: #2a2a2a;
-fx-border-width: 1px 0px 0px 0px;
-fx-border-width: 1 0 0 0;
-fx-border-color: #2c2c2c #2c2c2c #2c2c2c #2c2c2c;
}

/* SplitPane */
.split-pane {
-fx-margin: 0px;
-fx-padding: 0px;
-fx-border-width: 1px 0px 0px 0px;
-fx-margin: 0;
-fx-padding: 0;
-fx-border-width: 1 0 0 0;
-fx-border-color: #2c2c2c #2c2c2c #2c2c2c #2c2c2c;
-fx-background-color: #2a2a2a;
}

.split-pane:horizontal > .split-pane-divider {
.split-pane:horizontal > .split-pane-divider, .split-pane:vertical > .split-pane-divider {
-fx-padding: 0 0 0 0;
-fx-border-color: #2a2a2a;
-fx-border-color: #333333;
-fx-background-color: #2a2a2a;
}

/* ScrollBar */
.scroll-bar:horizontal, .scroll-bar:vertical {
-fx-background-color: transparent;
-fx-background-color: #2a2a2a;
}

.scroll-bar:horizontal .track, .scroll-bar:vertical .track {
-fx-background-color: transparent;
-fx-background-color: #2a2a2a;
}

.scroll-bar:horizontal .increment-button, .scroll-bar:horizontal .decrement-button {
-fx-background-color: transparent;
-fx-background-color: #2a2a2a;
-fx-padding: 0 -2 0 -2;
}

.scroll-bar:vertical .increment-button, .scroll-bar:vertical .decrement-button {
-fx-background-color: transparent;
-fx-padding: -2 0 -2 0;
-fx-background-color: #2a2a2a;
-fx-padding: 0 -2 0 -2;
}

.scroll-bar .increment-arrow, .scroll-bar .decrement-arrow {
-fx-background-color: #2a2a2a;
-fx-shape: " ";
}

Expand Down Expand Up @@ -99,7 +104,6 @@

.tab-pane *.tab-header-background {
-fx-background-color: #2a2a2a;
-fx-effect: innershadow(two-pass-box, transparent, 0, 0, 0, 0);
-fx-border-width: 0 0 0 0;
}

Expand All @@ -121,12 +125,25 @@
}

.tab-close-button {
-fx-font-size: 8px;
-fx-font-size: 8;
}

/* WebView */
.web-view {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
-fx-border-width: 0px;
-fx-border-width: 0;
}

/* TextArea */
.text-area, .text-area .content {
width: 100%;
-fx-background-color: #2d2d30;
-fx-font-family: monospace;
-fx-font-size: 12;
-fx-border-width: 0 0 0 0;
-fx-text-fill: #ffffff;
-fx-border-radius: 0;
-fx-border-color: #2d2d30;
-fx-background-radius: 0;
}

0 comments on commit f94fb91

Please sign in to comment.