Completed markdown support
- Markdown support in text for TextNote - Markdown support in text for ListNote - Added ViewBox for TextNote and ListNote - Changed main font for Bold and Italic support - Added some style for markdown text in webView.css
This commit is contained in:
parent
e7092799b6
commit
7513178073
BIN
SmartNotes/lib/asm-4.0.jar
Normal file
BIN
SmartNotes/lib/asm-4.0.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/asm-analysis-4.0.jar
Normal file
BIN
SmartNotes/lib/asm-analysis-4.0.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/asm-tree-4.0.jar
Normal file
BIN
SmartNotes/lib/asm-tree-4.0.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/asm-util-4.0.jar
Normal file
BIN
SmartNotes/lib/asm-util-4.0.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/parboiled-core-1.1.7.jar
Normal file
BIN
SmartNotes/lib/parboiled-core-1.1.7.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/parboiled-java-1.1.7.jar
Normal file
BIN
SmartNotes/lib/parboiled-java-1.1.7.jar
Normal file
Binary file not shown.
BIN
SmartNotes/lib/pegdown-1.6.0.jar
Normal file
BIN
SmartNotes/lib/pegdown-1.6.0.jar
Normal file
Binary file not shown.
@ -33,7 +33,7 @@ public class ExplorerItem extends HBox
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
explorer.requestLoad((Note) ExplorerItem.this.item);
|
explorer.requestLoad((Note) ExplorerItem.this.item);
|
||||||
SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getNoteBox(explorer));
|
SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getViewBox(explorer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,13 +26,17 @@ import javafx.util.Duration;
|
|||||||
|
|
||||||
public class ListBox extends ScrollPane
|
public class ListBox extends ScrollPane
|
||||||
{
|
{
|
||||||
|
private boolean editable;
|
||||||
|
|
||||||
private VBox main;
|
private VBox main;
|
||||||
private VBox listContainer;
|
private VBox listContainer;
|
||||||
|
|
||||||
private Runnable listChangeListener;
|
private Runnable listChangeListener;
|
||||||
|
|
||||||
public ListBox()
|
public ListBox(boolean editable)
|
||||||
{
|
{
|
||||||
|
this.editable = editable;
|
||||||
|
|
||||||
this.setFitToHeight(true);
|
this.setFitToHeight(true);
|
||||||
this.setFitToWidth(true);
|
this.setFitToWidth(true);
|
||||||
|
|
||||||
@ -41,49 +45,52 @@ public class ListBox extends ScrollPane
|
|||||||
this.listContainer = new VBox();
|
this.listContainer = new VBox();
|
||||||
this.main.getChildren().add(this.listContainer);
|
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")));
|
final HBox addListItemBox = new HBox();
|
||||||
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<MouseEvent>()
|
|
||||||
{
|
{
|
||||||
@Override
|
addListItemBox.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/AddCheckbox.png")));
|
||||||
public void handle(MouseEvent e)
|
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<MouseEvent>()
|
||||||
{
|
{
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
@Override
|
||||||
transition.setFromValue(0.4);
|
public void handle(MouseEvent e)
|
||||||
transition.setToValue(1.0);
|
{
|
||||||
transition.play();
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||||
}
|
transition.setFromValue(0.4);
|
||||||
});
|
transition.setToValue(1.0);
|
||||||
addListItemBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
transition.play();
|
||||||
{
|
}
|
||||||
@Override
|
});
|
||||||
public void handle(MouseEvent e)
|
addListItemBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
||||||
{
|
{
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
@Override
|
||||||
transition.setFromValue(1.0);
|
public void handle(MouseEvent e)
|
||||||
transition.setToValue(0.4);
|
{
|
||||||
transition.play();
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||||
}
|
transition.setFromValue(1.0);
|
||||||
});
|
transition.setToValue(0.4);
|
||||||
addListItemBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
transition.play();
|
||||||
{
|
}
|
||||||
@Override
|
});
|
||||||
public void handle(MouseEvent e)
|
addListItemBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||||
{
|
{
|
||||||
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);
|
this.setContent(this.main);
|
||||||
}
|
}
|
||||||
@ -92,7 +99,7 @@ public class ListBox extends ScrollPane
|
|||||||
{
|
{
|
||||||
this.listContainer.getChildren().clear();
|
this.listContainer.getChildren().clear();
|
||||||
for(String item : content.keySet())
|
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)
|
public void setListChangeListener(Runnable listener)
|
||||||
@ -117,7 +124,7 @@ public class ListBox extends ScrollPane
|
|||||||
private ListCheckbox checkbox;
|
private ListCheckbox checkbox;
|
||||||
private TextField field;
|
private TextField field;
|
||||||
|
|
||||||
public ListBoxItem(String text)
|
public ListBoxItem(String text, boolean editable)
|
||||||
{
|
{
|
||||||
ChangeListener<Object> change = new ChangeListener<Object>()
|
ChangeListener<Object> change = new ChangeListener<Object>()
|
||||||
{
|
{
|
||||||
@ -133,8 +140,22 @@ public class ListBox extends ScrollPane
|
|||||||
this.getChildren().add(this.checkbox);
|
this.getChildren().add(this.checkbox);
|
||||||
this.field = new TextField(text);
|
this.field = new TextField(text);
|
||||||
this.field.setId("text");
|
this.field.setId("text");
|
||||||
|
this.field.setEditable(editable);
|
||||||
this.field.prefWidthProperty().bind(ListBox.this.listContainer.widthProperty().subtract(this.checkbox.widthProperty()));
|
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<MouseEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent e)
|
||||||
|
{
|
||||||
|
ListBoxItem.this.setChecked(!ListBoxItem.this.isChecked());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
this.getChildren().add(this.field);
|
this.getChildren().add(this.field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class NotesExplorer extends VBox
|
|||||||
public void handle(MouseEvent event)
|
public void handle(MouseEvent event)
|
||||||
{
|
{
|
||||||
TextNote note = new TextNote();
|
TextNote note = new TextNote();
|
||||||
SmartNotes.instance.setContent(note.getNoteBox(NotesExplorer.this));
|
SmartNotes.instance.setContent(note.getEditBox(NotesExplorer.this));
|
||||||
int id = NotesExplorer.this.getNextId();
|
int id = NotesExplorer.this.getNextId();
|
||||||
NotesExplorer.this.notes.put(id, note);
|
NotesExplorer.this.notes.put(id, note);
|
||||||
|
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package com.madeorsk.smartnotes;
|
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.application.Application;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.concurrent.Worker.State;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.ScrollPane;
|
import javafx.scene.control.ScrollPane;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.WindowEvent;
|
import javafx.stage.WindowEvent;
|
||||||
|
|
||||||
@ -23,6 +31,7 @@ public class SmartNotes extends Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SmartNotes instance;
|
public static SmartNotes instance;
|
||||||
|
public static WebView webView;
|
||||||
private Scene scene;
|
private Scene scene;
|
||||||
private VBox root;
|
private VBox root;
|
||||||
private NotesExplorer explorer;
|
private NotesExplorer explorer;
|
||||||
@ -31,8 +40,35 @@ public class SmartNotes extends Application
|
|||||||
public void start(Stage stage) throws Exception
|
public void start(Stage stage) throws Exception
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
webView = new WebView();
|
||||||
|
final String css = Utils.loadText("/com/madeorsk/smartnotes/webView.css");
|
||||||
|
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends State> 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 = new VBox();
|
||||||
this.root.setStyle("-fx-background-color: #282828;");
|
this.root.setStyle("-fx-background-color: #282828;");
|
||||||
|
@ -36,7 +36,7 @@ public class TypeSelector extends HBox
|
|||||||
textNote.setNoteColor(note.getNoteColor());
|
textNote.setNoteColor(note.getNoteColor());
|
||||||
explorer.replaceNote(note, textNote);
|
explorer.replaceNote(note, textNote);
|
||||||
explorer.requestSave(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());
|
listNote.setNoteColor(note.getNoteColor());
|
||||||
explorer.replaceNote(note, listNote);
|
explorer.replaceNote(note, listNote);
|
||||||
explorer.requestSave(listNote);
|
explorer.requestSave(listNote);
|
||||||
SmartNotes.instance.setContent(listNote.getNoteBox(explorer));
|
SmartNotes.instance.setContent(listNote.getEditBox(explorer));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
47
SmartNotes/src/com/madeorsk/smartnotes/Utils.java
Normal file
47
SmartNotes/src/com/madeorsk/smartnotes/Utils.java
Normal file
@ -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<ToHtmlSerializerPlugin> htmlPlugins = configuration.htmlSerializerPlugins();
|
||||||
|
ToHtmlSerializer htmlSerializer = new ToHtmlSerializer(new LinkRenderer(), new ArrayList<ToHtmlSerializerPlugin>());
|
||||||
|
return htmlSerializer.toHtml(astRoot);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import com.madeorsk.smartnotes.NotesExplorer;
|
|||||||
import com.madeorsk.smartnotes.SavesManager;
|
import com.madeorsk.smartnotes.SavesManager;
|
||||||
import com.madeorsk.smartnotes.SmartNotes;
|
import com.madeorsk.smartnotes.SmartNotes;
|
||||||
import com.madeorsk.smartnotes.TypeSelector;
|
import com.madeorsk.smartnotes.TypeSelector;
|
||||||
|
import com.madeorsk.smartnotes.Utils;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@ -19,6 +20,7 @@ import javafx.event.EventHandler;
|
|||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
@ -35,12 +37,153 @@ public class ListNote extends Note
|
|||||||
public ListNote()
|
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.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
|
@Override
|
||||||
public VBox getNoteBox(final NotesExplorer explorer)
|
public VBox getViewBox(NotesExplorer explorer)
|
||||||
{
|
{
|
||||||
|
Map<String, Boolean> 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<MouseEvent>()
|
||||||
|
{
|
||||||
|
@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<MouseEvent>()
|
||||||
|
{
|
||||||
|
@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<NoteColor>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends NoteColor> 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<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> 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<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> 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<String, Boolean> listBoxMap = this.listBox.getList();
|
||||||
|
this.listBox = new ListBox(true);
|
||||||
|
this.listBox.updateList(listBoxMap);
|
||||||
VBox box = new VBox();
|
VBox box = new VBox();
|
||||||
box.setFillWidth(true);
|
box.setFillWidth(true);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.madeorsk.smartnotes.NotesExplorer;
|
|||||||
import com.madeorsk.smartnotes.SavesManager;
|
import com.madeorsk.smartnotes.SavesManager;
|
||||||
import com.madeorsk.smartnotes.SmartNotes;
|
import com.madeorsk.smartnotes.SmartNotes;
|
||||||
import com.madeorsk.smartnotes.TypeSelector;
|
import com.madeorsk.smartnotes.TypeSelector;
|
||||||
|
import com.madeorsk.smartnotes.Utils;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@ -16,6 +17,7 @@ import javafx.event.EventHandler;
|
|||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
@ -32,7 +34,96 @@ public class TextNote extends Note
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<MouseEvent>()
|
||||||
|
{
|
||||||
|
@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<MouseEvent>()
|
||||||
|
{
|
||||||
|
@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<NoteColor>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends NoteColor> 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<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> 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();
|
VBox box = new VBox();
|
||||||
box.setFillWidth(true);
|
box.setFillWidth(true);
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime.ttf
Normal file
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/Courier Prime.ttf
Normal file
Binary file not shown.
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/EditIcon.png
Normal file
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/EditIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@ -24,7 +24,7 @@
|
|||||||
#nameField, #text, #noteItemName
|
#nameField, #text, #noteItemName
|
||||||
{
|
{
|
||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-font-family: 'Cutive Mono';
|
-fx-font-family: "Courier Prime Sans";
|
||||||
-fx-font-size: 32px;
|
-fx-font-size: 32px;
|
||||||
}
|
}
|
||||||
#noteItemName
|
#noteItemName
|
||||||
|
28
SmartNotes/src/com/madeorsk/smartnotes/webView.css
Normal file
28
SmartNotes/src/com/madeorsk/smartnotes/webView.css
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user