diff --git a/SmartNotes/lib/asm-4.0.jar b/SmartNotes/lib/asm-4.0.jar new file mode 100644 index 0000000..6d63075 Binary files /dev/null and b/SmartNotes/lib/asm-4.0.jar differ diff --git a/SmartNotes/lib/asm-analysis-4.0.jar b/SmartNotes/lib/asm-analysis-4.0.jar new file mode 100644 index 0000000..48bb9b8 Binary files /dev/null and b/SmartNotes/lib/asm-analysis-4.0.jar differ diff --git a/SmartNotes/lib/asm-tree-4.0.jar b/SmartNotes/lib/asm-tree-4.0.jar new file mode 100644 index 0000000..aa99d3a Binary files /dev/null and b/SmartNotes/lib/asm-tree-4.0.jar differ diff --git a/SmartNotes/lib/asm-util-4.0.jar b/SmartNotes/lib/asm-util-4.0.jar new file mode 100644 index 0000000..0e10595 Binary files /dev/null and b/SmartNotes/lib/asm-util-4.0.jar differ diff --git a/SmartNotes/lib/parboiled-core-1.1.7.jar b/SmartNotes/lib/parboiled-core-1.1.7.jar new file mode 100644 index 0000000..ee49777 Binary files /dev/null and b/SmartNotes/lib/parboiled-core-1.1.7.jar differ diff --git a/SmartNotes/lib/parboiled-java-1.1.7.jar b/SmartNotes/lib/parboiled-java-1.1.7.jar new file mode 100644 index 0000000..e3289cd Binary files /dev/null and b/SmartNotes/lib/parboiled-java-1.1.7.jar differ diff --git a/SmartNotes/lib/pegdown-1.6.0.jar b/SmartNotes/lib/pegdown-1.6.0.jar new file mode 100644 index 0000000..9eb06e6 Binary files /dev/null and b/SmartNotes/lib/pegdown-1.6.0.jar differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/ExplorerItem.java b/SmartNotes/src/com/madeorsk/smartnotes/ExplorerItem.java index 1a8d580..241bac7 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/ExplorerItem.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/ExplorerItem.java @@ -33,7 +33,7 @@ public class ExplorerItem extends HBox else { explorer.requestLoad((Note) ExplorerItem.this.item); - SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getNoteBox(explorer)); + SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getViewBox(explorer)); } } }); diff --git a/SmartNotes/src/com/madeorsk/smartnotes/ListBox.java b/SmartNotes/src/com/madeorsk/smartnotes/ListBox.java index 47c180e..7444666 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/ListBox.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/ListBox.java @@ -26,13 +26,17 @@ import javafx.util.Duration; public class ListBox extends ScrollPane { + private boolean editable; + private VBox main; private VBox listContainer; private Runnable listChangeListener; - public ListBox() + public ListBox(boolean editable) { + this.editable = editable; + this.setFitToHeight(true); this.setFitToWidth(true); @@ -41,49 +45,52 @@ public class ListBox extends ScrollPane this.listContainer = new VBox(); this.main.getChildren().add(this.listContainer); - final HBox addListItemBox = new HBox(); + if (this.editable) { - addListItemBox.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/AddCheckbox.png"))); - Label addListItemLabel = new Label("Add a new item"); - addListItemLabel.setPadding(new Insets(0, 0, 0, 13)); - addListItemLabel.setId("text"); - addListItemBox.getChildren().add(addListItemLabel); - addListItemBox.setAlignment(Pos.CENTER_LEFT); - addListItemBox.setCursor(Cursor.HAND); - // Fade and opacity - addListItemBox.setOpacity(0.4); - addListItemBox.setOnMouseEntered(new EventHandler() + final HBox addListItemBox = new HBox(); { - @Override - public void handle(MouseEvent e) + addListItemBox.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/AddCheckbox.png"))); + Label addListItemLabel = new Label("Add a new item"); + addListItemLabel.setPadding(new Insets(0, 0, 0, 13)); + addListItemLabel.setId("text"); + addListItemBox.getChildren().add(addListItemLabel); + addListItemBox.setAlignment(Pos.CENTER_LEFT); + addListItemBox.setCursor(Cursor.HAND); + // Fade and opacity + addListItemBox.setOpacity(0.4); + addListItemBox.setOnMouseEntered(new EventHandler() { - FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox); - transition.setFromValue(0.4); - transition.setToValue(1.0); - transition.play(); - } - }); - addListItemBox.setOnMouseExited(new EventHandler() - { - @Override - public void handle(MouseEvent e) + @Override + public void handle(MouseEvent e) + { + FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox); + transition.setFromValue(0.4); + transition.setToValue(1.0); + transition.play(); + } + }); + addListItemBox.setOnMouseExited(new EventHandler() { - FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox); - transition.setFromValue(1.0); - transition.setToValue(0.4); - transition.play(); - } - }); - addListItemBox.setOnMouseClicked(new EventHandler() - { - @Override - public void handle(MouseEvent e) + @Override + public void handle(MouseEvent e) + { + FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox); + transition.setFromValue(1.0); + transition.setToValue(0.4); + transition.play(); + } + }); + addListItemBox.setOnMouseClicked(new EventHandler() { - ListBox.this.listContainer.getChildren().add(new ListBoxItem("")); - } - }); + @Override + public void handle(MouseEvent e) + { + ListBox.this.listContainer.getChildren().add(new ListBoxItem("", ListBox.this.editable)); + } + }); + } + this.main.getChildren().add(addListItemBox); } - this.main.getChildren().add(addListItemBox); this.setContent(this.main); } @@ -92,7 +99,7 @@ public class ListBox extends ScrollPane { this.listContainer.getChildren().clear(); for(String item : content.keySet()) - this.listContainer.getChildren().add(new ListBoxItem(item).setChecked(content.get(item).booleanValue())); + this.listContainer.getChildren().add(new ListBoxItem(item, this.editable).setChecked(content.get(item).booleanValue())); } public void setListChangeListener(Runnable listener) @@ -117,7 +124,7 @@ public class ListBox extends ScrollPane private ListCheckbox checkbox; private TextField field; - public ListBoxItem(String text) + public ListBoxItem(String text, boolean editable) { ChangeListener change = new ChangeListener() { @@ -133,8 +140,22 @@ public class ListBox extends ScrollPane this.getChildren().add(this.checkbox); this.field = new TextField(text); this.field.setId("text"); + this.field.setEditable(editable); this.field.prefWidthProperty().bind(ListBox.this.listContainer.widthProperty().subtract(this.checkbox.widthProperty())); - this.field.textProperty().addListener(change); + if (editable) + this.field.textProperty().addListener(change); + else + { + this.field.setCursor(Cursor.HAND); + this.field.setOnMouseClicked(new EventHandler() + { + @Override + public void handle(MouseEvent e) + { + ListBoxItem.this.setChecked(!ListBoxItem.this.isChecked()); + } + }); + } this.getChildren().add(this.field); } diff --git a/SmartNotes/src/com/madeorsk/smartnotes/NotesExplorer.java b/SmartNotes/src/com/madeorsk/smartnotes/NotesExplorer.java index 5f80e01..bdea321 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/NotesExplorer.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/NotesExplorer.java @@ -104,7 +104,7 @@ public class NotesExplorer extends VBox public void handle(MouseEvent event) { TextNote note = new TextNote(); - SmartNotes.instance.setContent(note.getNoteBox(NotesExplorer.this)); + SmartNotes.instance.setContent(note.getEditBox(NotesExplorer.this)); int id = NotesExplorer.this.getNextId(); NotesExplorer.this.notes.put(id, note); diff --git a/SmartNotes/src/com/madeorsk/smartnotes/SmartNotes.java b/SmartNotes/src/com/madeorsk/smartnotes/SmartNotes.java index a4847db..36d82f4 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/SmartNotes.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/SmartNotes.java @@ -1,12 +1,20 @@ package com.madeorsk.smartnotes; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Text; + import javafx.application.Application; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.concurrent.Worker.State; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.ScrollPane; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import javafx.scene.text.Font; +import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.stage.WindowEvent; @@ -23,6 +31,7 @@ public class SmartNotes extends Application } public static SmartNotes instance; + public static WebView webView; private Scene scene; private VBox root; private NotesExplorer explorer; @@ -31,8 +40,35 @@ public class SmartNotes extends Application public void start(Stage stage) throws Exception { instance = this; + webView = new WebView(); + final String css = Utils.loadText("/com/madeorsk/smartnotes/webView.css"); + webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, State oldValue, State newValue) + { + if (newValue == State.SUCCEEDED) + { + Document doc = webView.getEngine().getDocument(); + Element styleNode = doc.createElement("style"); + Text styleContent = doc.createTextNode(css); + styleNode.appendChild(styleContent); + doc.getDocumentElement().getElementsByTagName("head").item(0).appendChild(styleNode); + System.out.println(webView.getEngine().executeScript("document.documentElement.innerHTML")); + } + } + }); - Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/CutiveMono-Regular.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Sans.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Sans Bold.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Sans Italic.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Sans Bold Italic.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Bold.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Italic.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Bold Italic.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Code.ttf"), 10); + Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/Courier Prime Code Italic.ttf"), 10); this.root = new VBox(); this.root.setStyle("-fx-background-color: #282828;"); diff --git a/SmartNotes/src/com/madeorsk/smartnotes/TypeSelector.java b/SmartNotes/src/com/madeorsk/smartnotes/TypeSelector.java index 990d0f6..de81362 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/TypeSelector.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/TypeSelector.java @@ -36,7 +36,7 @@ public class TypeSelector extends HBox textNote.setNoteColor(note.getNoteColor()); explorer.replaceNote(note, textNote); explorer.requestSave(textNote); - SmartNotes.instance.setContent(textNote.getNoteBox(explorer)); + SmartNotes.instance.setContent(textNote.getEditBox(explorer)); } }); } @@ -59,7 +59,7 @@ public class TypeSelector extends HBox listNote.setNoteColor(note.getNoteColor()); explorer.replaceNote(note, listNote); explorer.requestSave(listNote); - SmartNotes.instance.setContent(listNote.getNoteBox(explorer)); + SmartNotes.instance.setContent(listNote.getEditBox(explorer)); } }); } diff --git a/SmartNotes/src/com/madeorsk/smartnotes/Utils.java b/SmartNotes/src/com/madeorsk/smartnotes/Utils.java new file mode 100644 index 0000000..bc84e4e --- /dev/null +++ b/SmartNotes/src/com/madeorsk/smartnotes/Utils.java @@ -0,0 +1,47 @@ +package com.madeorsk.smartnotes; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import org.pegdown.Extensions; +import org.pegdown.LinkRenderer; +import org.pegdown.PegDownProcessor; +import org.pegdown.ToHtmlSerializer; +import org.pegdown.ast.RootNode; +import org.pegdown.plugins.PegDownPlugins; +import org.pegdown.plugins.ToHtmlSerializerPlugin; + +public class Utils +{ + public static String loadText(String path) + { + try + { + InputStream is = Utils.class.getResourceAsStream(path); + String result = ""; + byte[] buffer = new byte[1024*8]; + while (is.read(buffer) > 0) + result += new String(buffer); + return result.trim(); + } + catch (IOException e) + { + e.printStackTrace(); + return null; + } + } + + public static String markdownToHtml(String markdown) + { + PegDownPlugins plugins = PegDownPlugins.builder().build(); + PegDownProcessor markdownProcessor = new PegDownProcessor(Extensions.ALL - Extensions.WIKILINKS - Extensions.ANCHORLINKS + Extensions.ATXHEADERSPACE, plugins); + RootNode astRoot = markdownProcessor.parseMarkdown(markdown.toCharArray()); + + //astRoot.accept(Visitors.dump()); + + //List htmlPlugins = configuration.htmlSerializerPlugins(); + ToHtmlSerializer htmlSerializer = new ToHtmlSerializer(new LinkRenderer(), new ArrayList()); + return htmlSerializer.toHtml(astRoot); + } +} diff --git a/SmartNotes/src/com/madeorsk/smartnotes/notes/ListNote.java b/SmartNotes/src/com/madeorsk/smartnotes/notes/ListNote.java index 161e76c..663fac7 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/notes/ListNote.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/notes/ListNote.java @@ -11,6 +11,7 @@ import com.madeorsk.smartnotes.NotesExplorer; import com.madeorsk.smartnotes.SavesManager; import com.madeorsk.smartnotes.SmartNotes; import com.madeorsk.smartnotes.TypeSelector; +import com.madeorsk.smartnotes.Utils; import javafx.application.Platform; import javafx.beans.value.ChangeListener; @@ -19,6 +20,7 @@ import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Cursor; +import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.image.Image; @@ -35,12 +37,153 @@ public class ListNote extends Note public ListNote() { this.setName("Text_" + Calendar.getInstance().get(Calendar.YEAR) + "." + Calendar.getInstance().get(Calendar.MONTH) + "." + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + ":" + Calendar.getInstance().get(Calendar.MINUTE)); - this.listBox = new ListBox(); + this.listBox = new ListBox(false); } @Override - public VBox getNoteBox(final NotesExplorer explorer) + public VBox getViewBox(NotesExplorer explorer) { + Map listBoxMap = this.listBox.getList(); + this.listBox = new ListBox(false); + this.listBox.updateList(listBoxMap); + VBox box = new VBox(); + box.setFillWidth(true); + + Label nameField = new Label(); + + HBox titleBox = new HBox(); + { + titleBox.setPadding(new Insets(10, 0, 0, 0)); + + VBox returnButton = new VBox(); + returnButton.setId("imageButton"); + returnButton.setCursor(Cursor.HAND); + returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png"))); + returnButton.setOnMouseClicked(new EventHandler() + { + @Override + public void handle(MouseEvent event) + { + explorer.updateCurrentFolder(); + SmartNotes.instance.setContent(explorer, true); + } + }); + titleBox.getChildren().add(returnButton); + + VBox editButton = new VBox(); + editButton.setId("imageButton"); + editButton.setCursor(Cursor.HAND); + editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png"))); + editButton.setOnMouseClicked(new EventHandler() + { + @Override + public void handle(MouseEvent event) + { + SmartNotes.instance.setContent(ListNote.this.getEditBox(explorer)); + } + }); + HBox buttonsBox = new HBox(); + buttonsBox.getChildren().add(editButton); + buttonsBox.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2)); + titleBox.getChildren().add(buttonsBox); + + NoteColorSelector colorSelector = new NoteColorSelector(); + colorSelector.setAlignment(Pos.CENTER); + colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2)); + colorSelector.addColor(NoteColor.WHITE); colorSelector.addColor(NoteColor.BLUE); colorSelector.addColor(NoteColor.YELLOW); colorSelector.addColor(NoteColor.RED); colorSelector.addColor(NoteColor.GREEN); + colorSelector.setSelectedColor(this.getNoteColor()); + colorSelector.selectedColorProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, NoteColor oldValue, NoteColor newValue) + { + ListNote.this.setNoteColor(newValue); + nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");"); + explorer.requestSave(ListNote.this); + } + }); + titleBox.getChildren().add(colorSelector); + } + box.getChildren().add(titleBox); + + // NAME FIELD + { + nameField.prefWidthProperty().bind(box.widthProperty()); + nameField.setAlignment(Pos.CENTER); + nameField.setId("nameField"); + nameField.setStyle("-fx-text-fill: rgb(" + this.getNoteColor().getColor().getRed()*255 + "," + this.getNoteColor().getColor().getGreen()*255 + "," + this.getNoteColor().getColor().getBlue()*255 + ");"); + nameField.setText(this.getName()); + nameField.textProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, String oldValue, String newValue) + { + ListNote.this.setName(newValue); + explorer.requestSave(ListNote.this); + } + }); + } + box.getChildren().add(nameField); + + // + + HBox separator = new HBox(); + separator.setId("separator"); + separator.setPrefHeight(5); + + SmartNotes.webView.getEngine().loadContent(Utils.markdownToHtml(this.getTextContent())); + SmartNotes.webView.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2)); + box.getChildren().add(SmartNotes.webView); + /*final TextArea textArea = new TextArea(); + { + textArea.setId("text"); + textArea.setWrapText(true); + textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2)); + textArea.setText(this.getTextContent()); + textArea.textProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, String oldValue, String newValue) + { + ListNote.this.setTextContent(newValue); + explorer.requestSave(ListNote.this); + } + }); + Platform.runLater(new Runnable() + { + @Override + public void run() + { + textArea.requestFocus(); + textArea.positionCaret(textArea.getLength()); + } + }); + } + box.getChildren().add(textArea);*/ + + box.getChildren().add(separator); + + this.listBox.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2)); + this.listBox.setListChangeListener(new Runnable() + { + @Override + public void run() + { + if (!ListNote.this.loading) + explorer.requestSave(ListNote.this); + } + }); + box.getChildren().add(this.listBox); + + return box; + } + + @Override + public VBox getEditBox(final NotesExplorer explorer) + { + Map listBoxMap = this.listBox.getList(); + this.listBox = new ListBox(true); + this.listBox.updateList(listBoxMap); VBox box = new VBox(); box.setFillWidth(true); diff --git a/SmartNotes/src/com/madeorsk/smartnotes/notes/Note.java b/SmartNotes/src/com/madeorsk/smartnotes/notes/Note.java index 9b6a223..ebf6ab7 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/notes/Note.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/notes/Note.java @@ -92,5 +92,6 @@ public abstract class Note implements SavableNote } } - public abstract VBox getNoteBox(NotesExplorer explorer); + public abstract VBox getViewBox(NotesExplorer explorer); + public abstract VBox getEditBox(NotesExplorer explorer); } diff --git a/SmartNotes/src/com/madeorsk/smartnotes/notes/TextNote.java b/SmartNotes/src/com/madeorsk/smartnotes/notes/TextNote.java index f3fdb87..8e8832a 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/notes/TextNote.java +++ b/SmartNotes/src/com/madeorsk/smartnotes/notes/TextNote.java @@ -8,6 +8,7 @@ import com.madeorsk.smartnotes.NotesExplorer; import com.madeorsk.smartnotes.SavesManager; import com.madeorsk.smartnotes.SmartNotes; import com.madeorsk.smartnotes.TypeSelector; +import com.madeorsk.smartnotes.Utils; import javafx.application.Platform; import javafx.beans.value.ChangeListener; @@ -16,6 +17,7 @@ import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Cursor; +import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.image.Image; @@ -32,7 +34,96 @@ public class TextNote extends Note } @Override - public VBox getNoteBox(final NotesExplorer explorer) + public VBox getViewBox(NotesExplorer explorer) + { + VBox box = new VBox(); + box.setFillWidth(true); + + Label nameField = new Label(); + + HBox titleBox = new HBox(); + { + titleBox.setPadding(new Insets(10, 0, 0, 0)); + + VBox returnButton = new VBox(); + returnButton.setId("imageButton"); + returnButton.setCursor(Cursor.HAND); + returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png"))); + returnButton.setOnMouseClicked(new EventHandler() + { + @Override + public void handle(MouseEvent event) + { + explorer.updateCurrentFolder(); + SmartNotes.instance.setContent(explorer, true); + } + }); + titleBox.getChildren().add(returnButton); + + VBox editButton = new VBox(); + editButton.setId("imageButton"); + editButton.setCursor(Cursor.HAND); + editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png"))); + editButton.setOnMouseClicked(new EventHandler() + { + @Override + public void handle(MouseEvent event) + { + SmartNotes.instance.setContent(TextNote.this.getEditBox(explorer)); + } + }); + HBox buttonsBox = new HBox(); + buttonsBox.getChildren().add(editButton); + buttonsBox.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2)); + titleBox.getChildren().add(buttonsBox); + + NoteColorSelector colorSelector = new NoteColorSelector(); + colorSelector.setAlignment(Pos.CENTER); + colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2)); + colorSelector.addColor(NoteColor.WHITE); colorSelector.addColor(NoteColor.BLUE); colorSelector.addColor(NoteColor.YELLOW); colorSelector.addColor(NoteColor.RED); colorSelector.addColor(NoteColor.GREEN); + colorSelector.setSelectedColor(this.getNoteColor()); + colorSelector.selectedColorProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, NoteColor oldValue, NoteColor newValue) + { + TextNote.this.setNoteColor(newValue); + nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");"); + explorer.requestSave(TextNote.this); + } + }); + titleBox.getChildren().add(colorSelector); + } + box.getChildren().add(titleBox); + + // NAME FIELD + { + nameField.prefWidthProperty().bind(box.widthProperty()); + nameField.setAlignment(Pos.CENTER); + nameField.setId("nameField"); + nameField.setStyle("-fx-text-fill: rgb(" + this.getNoteColor().getColor().getRed()*255 + "," + this.getNoteColor().getColor().getGreen()*255 + "," + this.getNoteColor().getColor().getBlue()*255 + ");"); + nameField.setText(this.getName()); + nameField.textProperty().addListener(new ChangeListener() + { + @Override + public void changed(ObservableValue ov, String oldValue, String newValue) + { + TextNote.this.setName(newValue); + explorer.requestSave(TextNote.this); + } + }); + } + box.getChildren().add(nameField); + + SmartNotes.webView.getEngine().loadContent(Utils.markdownToHtml(this.getTextContent())); + SmartNotes.webView.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty())); + box.getChildren().add(SmartNotes.webView); + + return box; + } + + @Override + public VBox getEditBox(final NotesExplorer explorer) { VBox box = new VBox(); box.setFillWidth(true); diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold Italic.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold Italic.ttf new file mode 100644 index 0000000..d4e7186 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold Italic.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold.ttf new file mode 100644 index 0000000..1b0888c Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Bold.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code Italic.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code Italic.ttf new file mode 100644 index 0000000..b1df075 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code Italic.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code.ttf new file mode 100644 index 0000000..5a2cf3c Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Code.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Italic.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Italic.ttf new file mode 100644 index 0000000..75a1343 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Italic.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold Italic.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold Italic.ttf new file mode 100644 index 0000000..fb69098 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold Italic.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold.ttf new file mode 100644 index 0000000..76d2dfc Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Bold.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Italic.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Italic.ttf new file mode 100644 index 0000000..93a7e70 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans Italic.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans.ttf new file mode 100644 index 0000000..32e795a Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime Sans.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime.ttf b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime.ttf new file mode 100644 index 0000000..db4e6c1 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime.ttf differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/res/EditIcon.png b/SmartNotes/src/com/madeorsk/smartnotes/res/EditIcon.png new file mode 100644 index 0000000..de381a8 Binary files /dev/null and b/SmartNotes/src/com/madeorsk/smartnotes/res/EditIcon.png differ diff --git a/SmartNotes/src/com/madeorsk/smartnotes/style.css b/SmartNotes/src/com/madeorsk/smartnotes/style.css index 061037c..4919994 100644 --- a/SmartNotes/src/com/madeorsk/smartnotes/style.css +++ b/SmartNotes/src/com/madeorsk/smartnotes/style.css @@ -24,7 +24,7 @@ #nameField, #text, #noteItemName { -fx-text-fill: white; - -fx-font-family: 'Cutive Mono'; + -fx-font-family: "Courier Prime Sans"; -fx-font-size: 32px; } #noteItemName diff --git a/SmartNotes/src/com/madeorsk/smartnotes/webView.css b/SmartNotes/src/com/madeorsk/smartnotes/webView.css new file mode 100644 index 0000000..ba21b90 --- /dev/null +++ b/SmartNotes/src/com/madeorsk/smartnotes/webView.css @@ -0,0 +1,28 @@ +body +{ + background: #282828; + color: white; + font-family: "Courier Prime Sans"; + font-size: 20px; +} + +code +{ + display: inline-block; + font-family: "Courier Prime Code"; + background: rgba(0, 0, 0, 0.1); + padding: 5px; + border-radius: 5px; +} +pre code +{ + width: 100%; +} + +blockquote +{ + display: block; + font-family: "Courier Prime"; + padding: 0 10px 0 10px; + border-left: solid rgba(0, 0, 0, 0.25) 2px; +} \ No newline at end of file