Code update and cleanup
This commit is contained in:
parent
686b4bf228
commit
21b2e2fc4a
2
SmartNotes/smartnotes/.gitignore
vendored
Normal file
2
SmartNotes/smartnotes/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
\.idea
|
||||
*\.iml
|
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.madeorsk</groupId>
|
||||
<artifactId>smartnotes</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>0.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SmartNotes</name>
|
||||
@ -12,6 +12,8 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -3,7 +3,6 @@ package com.madeorsk.smartnotes;
|
||||
import com.madeorsk.smartnotes.notes.Note;
|
||||
import com.madeorsk.smartnotes.paths.FolderPath;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Label;
|
||||
@ -23,11 +22,7 @@ public class ExplorerItem extends HBox
|
||||
this.item = item;
|
||||
|
||||
this.setCursor(Cursor.HAND);
|
||||
this.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent event)
|
||||
{
|
||||
this.setOnMouseClicked((MouseEvent event) -> {
|
||||
if (ExplorerItem.this.folder)
|
||||
explorer.goToFolder((FolderPath) ExplorerItem.this.item);
|
||||
else
|
||||
@ -35,7 +30,6 @@ public class ExplorerItem extends HBox
|
||||
explorer.requestLoad((Note) ExplorerItem.this.item);
|
||||
SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getViewBox(explorer));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.setAlignment(Pos.CENTER_LEFT);
|
||||
|
@ -9,7 +9,6 @@ import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableBooleanValue;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
@ -58,35 +57,20 @@ public class ListBox extends ScrollPane
|
||||
addListItemBox.setCursor(Cursor.HAND);
|
||||
// Fade and opacity
|
||||
addListItemBox.setOpacity(0.4);
|
||||
addListItemBox.setOnMouseEntered(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
addListItemBox.setOnMouseEntered((MouseEvent e) -> {
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||
transition.setFromValue(0.4);
|
||||
transition.setToValue(1.0);
|
||||
transition.play();
|
||||
}
|
||||
});
|
||||
addListItemBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
addListItemBox.setOnMouseExited((MouseEvent e) -> {
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||
transition.setFromValue(1.0);
|
||||
transition.setToValue(0.4);
|
||||
transition.play();
|
||||
}
|
||||
});
|
||||
addListItemBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
addListItemBox.setOnMouseClicked((MouseEvent e) -> {
|
||||
ListBox.this.listContainer.getChildren().add(new ListBoxItem("", ListBox.this.editable));
|
||||
}
|
||||
});
|
||||
}
|
||||
this.main.getChildren().add(addListItemBox);
|
||||
@ -126,14 +110,9 @@ public class ListBox extends ScrollPane
|
||||
|
||||
public ListBoxItem(String text, boolean editable)
|
||||
{
|
||||
ChangeListener<Object> change = new ChangeListener<Object>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Object> ov, Object oldValue, Object newValue)
|
||||
{
|
||||
ChangeListener<Object> change = (ObservableValue<? extends Object> ov, Object oldValue, Object newValue) -> {
|
||||
if (ListBox.this.listChangeListener != null)
|
||||
ListBox.this.listChangeListener.run();
|
||||
}
|
||||
};
|
||||
this.checkbox = new ListCheckbox();
|
||||
this.checkbox.checkedProperty().addListener(change);
|
||||
@ -147,13 +126,8 @@ public class ListBox extends ScrollPane
|
||||
else
|
||||
{
|
||||
this.field.setCursor(Cursor.HAND);
|
||||
this.field.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
this.field.setOnMouseClicked((MouseEvent e) -> {
|
||||
ListBoxItem.this.setChecked(!ListBoxItem.this.isChecked());
|
||||
}
|
||||
});
|
||||
}
|
||||
this.getChildren().add(this.field);
|
||||
@ -169,6 +143,7 @@ public class ListBox extends ScrollPane
|
||||
this.checkbox.setChecked(checked);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
return this.checkbox.isChecked();
|
||||
@ -185,46 +160,11 @@ public class ListBox extends ScrollPane
|
||||
this.setCursor(Cursor.HAND);
|
||||
this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
||||
|
||||
/*this.setOpacity(0.4);
|
||||
this.setOnMouseEntered(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
if (!ListCheckbox.this.isChecked())
|
||||
{
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), ListCheckbox.this);
|
||||
transition.setFromValue(0.4);
|
||||
transition.setToValue(1.0);
|
||||
transition.play();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.setOnMouseExited(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
if (!ListCheckbox.this.isChecked())
|
||||
{
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), ListCheckbox.this);
|
||||
transition.setFromValue(1.0);
|
||||
transition.setToValue(0.4);
|
||||
transition.play();
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
this.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
this.setOnMouseClicked((MouseEvent e) -> {
|
||||
if (ListCheckbox.this.isChecked())
|
||||
ListCheckbox.this.setChecked(false);
|
||||
else
|
||||
ListCheckbox.this.setChecked(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -237,10 +177,12 @@ public class ListBox extends ScrollPane
|
||||
else
|
||||
ListCheckbox.this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
||||
}
|
||||
|
||||
public ObservableBooleanValue checkedProperty()
|
||||
{
|
||||
return this.checked;
|
||||
}
|
||||
|
||||
public boolean isChecked()
|
||||
{
|
||||
return this.checked.get();
|
||||
|
@ -8,7 +8,6 @@ import com.madeorsk.smartnotes.notes.Note.NoteColor;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
@ -40,10 +39,12 @@ public class NoteColorSelector extends HBox
|
||||
this.selectedColor.set(color);
|
||||
this.updateBox();
|
||||
}
|
||||
|
||||
public NoteColor getSelectedColor()
|
||||
{
|
||||
return this.selectedColor.getValue();
|
||||
}
|
||||
|
||||
public ObservableValue<NoteColor> selectedColorProperty()
|
||||
{
|
||||
return this.selectedColor;
|
||||
@ -56,7 +57,8 @@ public class NoteColorSelector extends HBox
|
||||
{
|
||||
Canvas canvas = new Canvas();
|
||||
canvas.setCursor(Cursor.HAND);
|
||||
canvas.setHeight(50); canvas.setWidth(50);
|
||||
canvas.setHeight(50);
|
||||
canvas.setWidth(50);
|
||||
GraphicsContext gc = canvas.getGraphicsContext2D();
|
||||
if (color.equals(this.getSelectedColor()))
|
||||
{
|
||||
@ -66,13 +68,8 @@ public class NoteColorSelector extends HBox
|
||||
gc.setFill(color.getColor());
|
||||
gc.fillOval(3, 3, 44, 44);
|
||||
|
||||
canvas.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent event)
|
||||
{
|
||||
canvas.setOnMouseClicked((MouseEvent event) -> {
|
||||
NoteColorSelector.this.setSelectedColor(color);
|
||||
}
|
||||
});
|
||||
|
||||
this.getChildren().add(canvas);
|
||||
|
@ -10,7 +10,6 @@ import com.madeorsk.smartnotes.paths.NotePath;
|
||||
import com.madeorsk.smartnotes.paths.Path;
|
||||
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
@ -25,8 +24,6 @@ import javafx.util.Duration;
|
||||
public class NotesExplorer extends VBox
|
||||
{
|
||||
private SavesManager saves;
|
||||
/*private Thread saveThread;
|
||||
private Thread nextSaveThread;*/
|
||||
private Map<Integer, Note> notes;
|
||||
|
||||
private HBox titleBox;
|
||||
@ -78,33 +75,19 @@ public class NotesExplorer extends VBox
|
||||
{
|
||||
addNoteBox.setCursor(Cursor.HAND);
|
||||
addNoteBox.setOpacity(0.4);
|
||||
addNoteBox.setOnMouseEntered(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
addNoteBox.setOnMouseEntered((MouseEvent e) -> {
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
||||
transition.setFromValue(0.4);
|
||||
transition.setToValue(1.0);
|
||||
transition.play();
|
||||
}
|
||||
});
|
||||
addNoteBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
addNoteBox.setOnMouseExited((MouseEvent e) -> {
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
||||
transition.setFromValue(1.0);
|
||||
transition.setToValue(0.4);
|
||||
transition.play();
|
||||
}
|
||||
});
|
||||
addNoteBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent event)
|
||||
{
|
||||
addNoteBox.setOnMouseClicked((MouseEvent event) -> {
|
||||
TextNote note = new TextNote();
|
||||
SmartNotes.instance.setContent(note.getEditBox(NotesExplorer.this));
|
||||
int id = NotesExplorer.this.getNextId();
|
||||
@ -112,7 +95,6 @@ public class NotesExplorer extends VBox
|
||||
|
||||
NotesExplorer.this.saves.saveIndex(NotesExplorer.this.notes);
|
||||
note.save(NotesExplorer.this.saves, id);
|
||||
}
|
||||
});
|
||||
|
||||
addNoteBox.setAlignment(Pos.CENTER_LEFT);
|
||||
@ -161,10 +143,12 @@ public class NotesExplorer extends VBox
|
||||
{
|
||||
this.updateList(this.getUpdatedFolder(path));
|
||||
}
|
||||
|
||||
public void updateCurrentFolder()
|
||||
{
|
||||
this.updateList(this.getUpdatedFolder(this.currentFolder));
|
||||
}
|
||||
|
||||
private FolderPath getUpdatedFolder(FolderPath path)
|
||||
{
|
||||
if (path.getParent() == null)
|
||||
@ -193,31 +177,11 @@ public class NotesExplorer extends VBox
|
||||
|
||||
public void requestSave(final Note note)
|
||||
{
|
||||
/*Thread currentThread = new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{*/
|
||||
for (int key : NotesExplorer.this.notes.keySet())
|
||||
if (NotesExplorer.this.notes.get(key).equals(note))
|
||||
note.save(NotesExplorer.this.saves, key);
|
||||
/*
|
||||
if (NotesExplorer.this.nextSaveThread != null && !NotesExplorer.this.nextSaveThread.equals(this))
|
||||
{
|
||||
NotesExplorer.this.saveThread = NotesExplorer.this.nextSaveThread;
|
||||
NotesExplorer.this.saveThread.start();
|
||||
}
|
||||
}
|
||||
}, "Save Thread");
|
||||
|
||||
if (this.saveThread != null && this.saveThread.isAlive())
|
||||
this.nextSaveThread = currentThread;
|
||||
else
|
||||
{
|
||||
this.saveThread = currentThread;
|
||||
this.saveThread.start();
|
||||
}*/
|
||||
}
|
||||
public void requestLoad(Note note)
|
||||
{
|
||||
for (int key : this.notes.keySet())
|
||||
|
@ -40,6 +40,7 @@ public class SavesManager
|
||||
this.writeFile(indexFile, indexString);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Note> loadIndex()
|
||||
{
|
||||
File indexFile = new File(SAVE_FOLDER, "index");
|
||||
@ -75,7 +76,6 @@ public class SavesManager
|
||||
{
|
||||
return new File(SAVE_FOLDER, id + "");
|
||||
}
|
||||
|
||||
public String readFile(File file)
|
||||
{
|
||||
try
|
||||
@ -122,38 +122,35 @@ public class SavesManager
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] byteFpeEncryption(byte[] bytes, String key)
|
||||
private static String createCipherFromKey(String key, int bytesLength)
|
||||
{
|
||||
String cipher = "";
|
||||
int i = 0;
|
||||
while (cipher.getBytes().length < bytes.length)
|
||||
while (cipher.getBytes().length < bytesLength)
|
||||
{
|
||||
cipher += key.getBytes()[i];
|
||||
i++;
|
||||
if (i >= key.getBytes().length)
|
||||
i = 0;
|
||||
}
|
||||
return cipher;
|
||||
}
|
||||
private byte[] byteFpeEncryption(byte[] bytes, String key)
|
||||
{
|
||||
String cipher = createCipherFromKey(key, bytes.length);
|
||||
|
||||
byte[] encryptedBytes = new byte[bytes.length];
|
||||
for(i = 0; i < bytes.length; i++)
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
encryptedBytes[i] = (byte) (bytes[i] + cipher.getBytes()[i]);
|
||||
|
||||
return encryptedBytes;
|
||||
}
|
||||
private byte[] byteFpeDecryption(byte[] bytes, String key)
|
||||
{
|
||||
String cipher = "";
|
||||
int i = 0;
|
||||
while (cipher.getBytes().length < bytes.length)
|
||||
{
|
||||
cipher += key.getBytes()[i];
|
||||
i++;
|
||||
if (i >= key.getBytes().length)
|
||||
i = 0;
|
||||
}
|
||||
String cipher = createCipherFromKey(key, bytes.length);
|
||||
|
||||
byte[] decryptedBytes = new byte[bytes.length];
|
||||
for(i = 0; i < bytes.length; i++)
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
decryptedBytes[i] = (byte) (bytes[i] - cipher.getBytes()[i]);
|
||||
|
||||
return decryptedBytes;
|
||||
|
@ -13,10 +13,8 @@ import org.w3c.dom.Text;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
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;
|
||||
@ -28,7 +26,7 @@ import javafx.stage.WindowEvent;
|
||||
|
||||
public class SmartNotes extends Application
|
||||
{
|
||||
public static final String version = "alpha0.1";
|
||||
public static final String version = "0.5";
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
@ -64,11 +62,7 @@ public class SmartNotes extends Application
|
||||
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)
|
||||
{
|
||||
webView.getEngine().getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldValue, State newValue) -> {
|
||||
if (newValue == State.SUCCEEDED)
|
||||
{
|
||||
Document doc = webView.getEngine().getDocument();
|
||||
@ -76,11 +70,10 @@ public class SmartNotes extends Application
|
||||
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"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Registering font files.
|
||||
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);
|
||||
@ -97,30 +90,21 @@ public class SmartNotes extends Application
|
||||
|
||||
this.explorer = new NotesExplorer();
|
||||
ScrollPane scrollPane = new ScrollPane(this.explorer);
|
||||
scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setFitToWidth(true);
|
||||
this.root.getChildren().add(scrollPane);
|
||||
|
||||
this.scene = new Scene(this.root, 800, 600);
|
||||
this.scene.getStylesheets().add("/com/madeorsk/smartnotes/style.css");
|
||||
|
||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(WindowEvent e)
|
||||
{
|
||||
stage.setOnCloseRequest((WindowEvent e) -> {
|
||||
SmartNotes.this.explorer.close();
|
||||
}
|
||||
});
|
||||
|
||||
stage.setScene(this.scene);
|
||||
stage.setTitle("SmartNotes " + version);
|
||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(WindowEvent event)
|
||||
{
|
||||
stage.setOnCloseRequest((WindowEvent event) -> {
|
||||
SmartNotes.this.onStop();
|
||||
}
|
||||
});
|
||||
stage.show();
|
||||
}
|
||||
@ -129,13 +113,15 @@ public class SmartNotes extends Application
|
||||
{
|
||||
this.setContent(region, false);
|
||||
}
|
||||
|
||||
public void setContent(Region region, boolean useScrollPane)
|
||||
{
|
||||
this.root.getChildren().clear();
|
||||
if (useScrollPane)
|
||||
{
|
||||
ScrollPane scrollPane = new ScrollPane(region);
|
||||
scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setFitToWidth(true);
|
||||
this.root.getChildren().add(scrollPane);
|
||||
}
|
||||
else
|
||||
@ -165,13 +151,16 @@ public class SmartNotes extends Application
|
||||
{
|
||||
//System.out.println("P == " + e.getKeyCode() + ":" + e.getKeyChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nativeKeyReleased(NativeKeyEvent e)
|
||||
{
|
||||
//System.out.println("R == " + e.getKeyCode() + ":" + e.getKeyChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nativeKeyTyped(NativeKeyEvent e)
|
||||
{}
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.madeorsk.smartnotes.notes.Note;
|
||||
import com.madeorsk.smartnotes.notes.TextNote;
|
||||
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
@ -25,10 +24,7 @@ public class TypeSelector extends HBox
|
||||
textNoteItem.setSelected(true);
|
||||
else
|
||||
{
|
||||
textNoteItem.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
public void handle(MouseEvent event)
|
||||
{
|
||||
textNoteItem.setOnMouseClicked((MouseEvent event) -> {
|
||||
Note textNote = new TextNote();
|
||||
textNote.setName(note.getName());
|
||||
textNote.setTextContent(note.getTextContent());
|
||||
@ -36,7 +32,6 @@ public class TypeSelector extends HBox
|
||||
explorer.replaceNote(note, textNote);
|
||||
explorer.requestSave(textNote);
|
||||
SmartNotes.instance.setContent(textNote.getEditBox(explorer));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -47,11 +42,7 @@ public class TypeSelector extends HBox
|
||||
listNoteItem.setSelected(true);
|
||||
else
|
||||
{
|
||||
listNoteItem.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent event)
|
||||
{
|
||||
listNoteItem.setOnMouseClicked((MouseEvent event) -> {
|
||||
Note listNote = new ListNote();
|
||||
listNote.setName(note.getName());
|
||||
listNote.setTextContent(note.getTextContent());
|
||||
@ -59,30 +50,25 @@ public class TypeSelector extends HBox
|
||||
explorer.replaceNote(note, listNote);
|
||||
explorer.requestSave(listNote);
|
||||
SmartNotes.instance.setContent(listNote.getEditBox(explorer));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
this.getChildren().add(listNoteItem);
|
||||
TypeItem imageNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/ImageNoteChoice.png");
|
||||
{
|
||||
|
||||
}
|
||||
} //TODO Next versions.
|
||||
this.getChildren().add(imageNoteItem);
|
||||
TypeItem soundNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/SoundNoteChoice.png");
|
||||
{
|
||||
|
||||
}
|
||||
} //TODO Next versions.
|
||||
this.getChildren().add(soundNoteItem);
|
||||
TypeItem videoNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/VideoNoteChoice.png");
|
||||
{
|
||||
|
||||
}
|
||||
} //TODO Next versions.
|
||||
this.getChildren().add(videoNoteItem);
|
||||
TypeItem positionNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/PositionNoteChoice.png");
|
||||
{
|
||||
|
||||
}
|
||||
} //TODO Next versions.
|
||||
this.getChildren().add(positionNoteItem);
|
||||
}
|
||||
|
||||
@ -97,11 +83,7 @@ public class TypeSelector extends HBox
|
||||
this.getChildren().add(new ImageView(new Image(typeIconPath)));
|
||||
|
||||
this.setOpacity(0.4);
|
||||
this.setOnMouseEntered(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
this.setOnMouseEntered((MouseEvent e) -> {
|
||||
if (!TypeItem.this.isSelected())
|
||||
{
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
||||
@ -109,13 +91,8 @@ public class TypeSelector extends HBox
|
||||
transition.setToValue(1.0);
|
||||
transition.play();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.setOnMouseExited(new EventHandler<MouseEvent>()
|
||||
{
|
||||
@Override
|
||||
public void handle(MouseEvent e)
|
||||
{
|
||||
this.setOnMouseExited((MouseEvent e) -> {
|
||||
if (!TypeItem.this.isSelected())
|
||||
{
|
||||
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
||||
@ -123,7 +100,6 @@ public class TypeSelector extends HBox
|
||||
transition.setToValue(0.4);
|
||||
transition.play();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -140,6 +116,7 @@ public class TypeSelector extends HBox
|
||||
transition.play();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSelected()
|
||||
{
|
||||
return this.selected;
|
||||
|
@ -59,14 +59,9 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
explorer.updateCurrentFolder();
|
||||
SmartNotes.instance.setContent(explorer, true);
|
||||
}
|
||||
});
|
||||
titleBox.getChildren().add(returnButton);
|
||||
|
||||
@ -74,13 +69,8 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
editButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
SmartNotes.instance.setContent(ListNote.this.getEditBox(explorer));
|
||||
}
|
||||
});
|
||||
HBox buttonsBox = new HBox();
|
||||
buttonsBox.getChildren().add(editButton);
|
||||
@ -90,17 +80,16 @@ public class ListNote extends Note
|
||||
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.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)
|
||||
{
|
||||
colorSelector.selectedColorProperty().addListener((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);
|
||||
}
|
||||
@ -113,20 +102,13 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
nameField.textProperty().addListener((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);
|
||||
@ -134,44 +116,13 @@ public class ListNote extends Note
|
||||
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()
|
||||
{
|
||||
this.listBox.setListChangeListener(() -> {
|
||||
if (!ListNote.this.loading)
|
||||
explorer.requestSave(ListNote.this);
|
||||
}
|
||||
});
|
||||
box.getChildren().add(this.listBox);
|
||||
|
||||
@ -197,14 +148,9 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
explorer.updateCurrentFolder();
|
||||
SmartNotes.instance.setContent(explorer, true);
|
||||
}
|
||||
});
|
||||
titleBox.getChildren().add(returnButton);
|
||||
|
||||
@ -216,17 +162,16 @@ public class ListNote extends Note
|
||||
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.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)
|
||||
{
|
||||
colorSelector.selectedColorProperty().addListener((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);
|
||||
}
|
||||
@ -238,14 +183,9 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||
ListNote.this.setName(newValue);
|
||||
explorer.requestSave(ListNote.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
box.getChildren().add(nameField);
|
||||
@ -262,23 +202,13 @@ public class ListNote extends Note
|
||||
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)
|
||||
{
|
||||
textArea.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||
ListNote.this.setTextContent(newValue);
|
||||
explorer.requestSave(ListNote.this);
|
||||
}
|
||||
});
|
||||
Platform.runLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Platform.runLater(() -> {
|
||||
textArea.requestFocus();
|
||||
textArea.positionCaret(textArea.getLength());
|
||||
}
|
||||
});
|
||||
}
|
||||
box.getChildren().add(textArea);
|
||||
@ -286,14 +216,9 @@ public class ListNote extends Note
|
||||
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()
|
||||
{
|
||||
this.listBox.setListChangeListener(() -> {
|
||||
if (!ListNote.this.loading)
|
||||
explorer.requestSave(ListNote.this);
|
||||
}
|
||||
});
|
||||
box.getChildren().add(this.listBox);
|
||||
|
||||
@ -310,6 +235,7 @@ public class ListNote extends Note
|
||||
fileContent += key + ":" + list.get(key).toString() + "\n";
|
||||
saves.writeFile(saves.getSaveFile(id), fileContent + this.getTextContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(SavesManager saves, int id)
|
||||
{
|
||||
@ -351,6 +277,7 @@ public class ListNote extends Note
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SavesManager saves, int id)
|
||||
{
|
||||
|
@ -21,12 +21,14 @@ public abstract class Note implements SavableNote
|
||||
private double r;
|
||||
private double g;
|
||||
private double b;
|
||||
|
||||
NoteColor(double red, double green, double blue)
|
||||
{
|
||||
this.r = red;
|
||||
this.g = green;
|
||||
this.b = blue;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return new Color(this.r / 255, this.g / 255, this.b / 255, 1);
|
||||
@ -42,6 +44,7 @@ public abstract class Note implements SavableNote
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
@ -51,10 +54,12 @@ public abstract class Note implements SavableNote
|
||||
{
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public NoteColor getNoteColor()
|
||||
{
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public List<String> getPaths()
|
||||
{
|
||||
return this.paths;
|
||||
@ -65,10 +70,12 @@ public abstract class Note implements SavableNote
|
||||
this.textContent = content;
|
||||
this.updatePaths();
|
||||
}
|
||||
|
||||
public String getTextContent()
|
||||
{
|
||||
return this.textContent;
|
||||
}
|
||||
|
||||
private void updatePaths()
|
||||
{
|
||||
this.paths.clear();
|
||||
@ -93,5 +100,6 @@ public abstract class Note implements SavableNote
|
||||
}
|
||||
|
||||
public abstract VBox getViewBox(NotesExplorer explorer);
|
||||
|
||||
public abstract VBox getEditBox(NotesExplorer explorer);
|
||||
}
|
||||
|
@ -49,14 +49,9 @@ public class TextNote extends Note
|
||||
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)
|
||||
{
|
||||
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
explorer.updateCurrentFolder();
|
||||
SmartNotes.instance.setContent(explorer, true);
|
||||
}
|
||||
});
|
||||
titleBox.getChildren().add(returnButton);
|
||||
|
||||
@ -64,13 +59,8 @@ public class TextNote extends Note
|
||||
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)
|
||||
{
|
||||
editButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
SmartNotes.instance.setContent(TextNote.this.getEditBox(explorer));
|
||||
}
|
||||
});
|
||||
HBox buttonsBox = new HBox();
|
||||
buttonsBox.getChildren().add(editButton);
|
||||
@ -80,17 +70,16 @@ public class TextNote extends Note
|
||||
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.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)
|
||||
{
|
||||
colorSelector.selectedColorProperty().addListener((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);
|
||||
}
|
||||
@ -103,14 +92,9 @@ public class TextNote extends Note
|
||||
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)
|
||||
{
|
||||
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||
TextNote.this.setName(newValue);
|
||||
explorer.requestSave(TextNote.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
box.getChildren().add(nameField);
|
||||
@ -138,14 +122,9 @@ public class TextNote extends Note
|
||||
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)
|
||||
{
|
||||
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||
explorer.updateCurrentFolder();
|
||||
SmartNotes.instance.setContent(explorer, true);
|
||||
}
|
||||
});
|
||||
titleBox.getChildren().add(returnButton);
|
||||
|
||||
@ -157,17 +136,16 @@ public class TextNote extends Note
|
||||
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.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)
|
||||
{
|
||||
colorSelector.selectedColorProperty().addListener((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);
|
||||
}
|
||||
@ -179,14 +157,9 @@ public class TextNote extends Note
|
||||
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)
|
||||
{
|
||||
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||
TextNote.this.setName(newValue);
|
||||
explorer.requestSave(TextNote.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
box.getChildren().add(nameField);
|
||||
@ -197,23 +170,13 @@ public class TextNote extends Note
|
||||
textArea.setWrapText(true);
|
||||
textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()));
|
||||
textArea.setText(this.getTextContent());
|
||||
textArea.textProperty().addListener(new ChangeListener<String>()
|
||||
{
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
||||
{
|
||||
textArea.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||
TextNote.this.setTextContent(newValue);
|
||||
explorer.requestSave(TextNote.this);
|
||||
}
|
||||
});
|
||||
Platform.runLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Platform.runLater(() -> {
|
||||
textArea.requestFocus();
|
||||
textArea.positionCaret(textArea.getLength());
|
||||
}
|
||||
});
|
||||
}
|
||||
box.getChildren().add(textArea);
|
||||
@ -226,6 +189,7 @@ public class TextNote extends Note
|
||||
{
|
||||
saves.writeFile(saves.getSaveFile(id), this.getName() + "\n" + this.getNoteColor().name() + "\n" + this.getTextContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean load(SavesManager saves, int id)
|
||||
{
|
||||
@ -246,6 +210,7 @@ public class TextNote extends Note
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SavesManager saves, int id)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ public class FolderPath implements Path
|
||||
return (FolderPath) path;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean containsFolder(String folderName)
|
||||
{
|
||||
for (Path path : this.content)
|
||||
@ -42,14 +43,17 @@ public class FolderPath implements Path
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public FolderPath getParent()
|
||||
{
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public List<Path> getContent()
|
||||
{
|
||||
return this.content;
|
||||
|
@ -2,15 +2,18 @@
|
||||
{
|
||||
-fx-background-color: #282828;
|
||||
}
|
||||
|
||||
.scroll-bar .increment-button, .scroll-bar .decrement-button, .scroll-bar .increment-button .increment-arrow, .scroll-bar .decrement-button .decrement-arrow
|
||||
{
|
||||
-fx-font-size: 0;
|
||||
-fx-padding: 0;
|
||||
}
|
||||
|
||||
.scroll-bar .track
|
||||
{
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
.scroll-bar .thumb
|
||||
{
|
||||
-fx-background-color: rgba(0, 0, 0, 0.15);
|
||||
@ -21,20 +24,24 @@
|
||||
{
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
#nameField, #text, #noteItemName
|
||||
{
|
||||
-fx-text-fill: white;
|
||||
-fx-font-family: "Courier Prime Sans";
|
||||
-fx-font-family: "Courier Prime Sans", monospace;
|
||||
-fx-font-size: 32px;
|
||||
}
|
||||
|
||||
#noteItemName
|
||||
{
|
||||
-fx-font-size: 24px;
|
||||
}
|
||||
|
||||
#text
|
||||
{
|
||||
-fx-font-size: 20px;
|
||||
}
|
||||
|
||||
#separator
|
||||
{
|
||||
-fx-background-color: rgba(0, 0, 0, 0.15);
|
||||
|
@ -2,18 +2,19 @@ body
|
||||
{
|
||||
background: #282828;
|
||||
color: white;
|
||||
font-family: "Courier Prime Sans";
|
||||
font-family: "Courier Prime Sans", monospace;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
code
|
||||
{
|
||||
display: inline-block;
|
||||
font-family: "Courier Prime Code";
|
||||
font-family: "Courier Prime Code", monospace;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
pre code
|
||||
{
|
||||
width: 100%;
|
||||
@ -22,7 +23,7 @@ pre code
|
||||
blockquote
|
||||
{
|
||||
display: block;
|
||||
font-family: "Courier Prime";
|
||||
font-family: "Courier Prime", monospace;
|
||||
padding: 0 10px 0 10px;
|
||||
border-left: solid rgba(0, 0, 0, 0.25) 2px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user