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>
|
<groupId>com.madeorsk</groupId>
|
||||||
<artifactId>smartnotes</artifactId>
|
<artifactId>smartnotes</artifactId>
|
||||||
<version>1.0</version>
|
<version>0.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SmartNotes</name>
|
<name>SmartNotes</name>
|
||||||
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<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>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -3,7 +3,6 @@ package com.madeorsk.smartnotes;
|
|||||||
import com.madeorsk.smartnotes.notes.Note;
|
import com.madeorsk.smartnotes.notes.Note;
|
||||||
import com.madeorsk.smartnotes.paths.FolderPath;
|
import com.madeorsk.smartnotes.paths.FolderPath;
|
||||||
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
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.Label;
|
||||||
@ -23,11 +22,7 @@ public class ExplorerItem extends HBox
|
|||||||
this.item = item;
|
this.item = item;
|
||||||
|
|
||||||
this.setCursor(Cursor.HAND);
|
this.setCursor(Cursor.HAND);
|
||||||
this.setOnMouseClicked(new EventHandler<MouseEvent>()
|
this.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
if (ExplorerItem.this.folder)
|
if (ExplorerItem.this.folder)
|
||||||
explorer.goToFolder((FolderPath) ExplorerItem.this.item);
|
explorer.goToFolder((FolderPath) ExplorerItem.this.item);
|
||||||
else
|
else
|
||||||
@ -35,7 +30,6 @@ public class ExplorerItem extends HBox
|
|||||||
explorer.requestLoad((Note) ExplorerItem.this.item);
|
explorer.requestLoad((Note) ExplorerItem.this.item);
|
||||||
SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getViewBox(explorer));
|
SmartNotes.instance.setContent(((Note) ExplorerItem.this.item).getViewBox(explorer));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setAlignment(Pos.CENTER_LEFT);
|
this.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
@ -9,7 +9,6 @@ import javafx.beans.property.SimpleBooleanProperty;
|
|||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableBooleanValue;
|
import javafx.beans.value.ObservableBooleanValue;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
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;
|
||||||
@ -58,35 +57,20 @@ public class ListBox extends ScrollPane
|
|||||||
addListItemBox.setCursor(Cursor.HAND);
|
addListItemBox.setCursor(Cursor.HAND);
|
||||||
// Fade and opacity
|
// Fade and opacity
|
||||||
addListItemBox.setOpacity(0.4);
|
addListItemBox.setOpacity(0.4);
|
||||||
addListItemBox.setOnMouseEntered(new EventHandler<MouseEvent>()
|
addListItemBox.setOnMouseEntered((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||||
transition.setFromValue(0.4);
|
transition.setFromValue(0.4);
|
||||||
transition.setToValue(1.0);
|
transition.setToValue(1.0);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
addListItemBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
addListItemBox.setOnMouseExited((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addListItemBox);
|
||||||
transition.setFromValue(1.0);
|
transition.setFromValue(1.0);
|
||||||
transition.setToValue(0.4);
|
transition.setToValue(0.4);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
addListItemBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
addListItemBox.setOnMouseClicked((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
ListBox.this.listContainer.getChildren().add(new ListBoxItem("", ListBox.this.editable));
|
ListBox.this.listContainer.getChildren().add(new ListBoxItem("", ListBox.this.editable));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.main.getChildren().add(addListItemBox);
|
this.main.getChildren().add(addListItemBox);
|
||||||
@ -98,7 +82,7 @@ public class ListBox extends ScrollPane
|
|||||||
public void updateList(Map<String, Boolean> content)
|
public void updateList(Map<String, Boolean> content)
|
||||||
{
|
{
|
||||||
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, this.editable).setChecked(content.get(item).booleanValue()));
|
this.listContainer.getChildren().add(new ListBoxItem(item, this.editable).setChecked(content.get(item).booleanValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +94,7 @@ public class ListBox extends ScrollPane
|
|||||||
public Map<String, Boolean> getList()
|
public Map<String, Boolean> getList()
|
||||||
{
|
{
|
||||||
Map<String, Boolean> list = new HashMap<String, Boolean>();
|
Map<String, Boolean> list = new HashMap<String, Boolean>();
|
||||||
for(Node child : this.listContainer.getChildren())
|
for (Node child : this.listContainer.getChildren())
|
||||||
{
|
{
|
||||||
ListBoxItem item = (ListBoxItem) child;
|
ListBoxItem item = (ListBoxItem) child;
|
||||||
if (item.getText() != null && !item.getText().isEmpty())
|
if (item.getText() != null && !item.getText().isEmpty())
|
||||||
@ -126,14 +110,9 @@ public class ListBox extends ScrollPane
|
|||||||
|
|
||||||
public ListBoxItem(String text, boolean editable)
|
public ListBoxItem(String text, boolean editable)
|
||||||
{
|
{
|
||||||
ChangeListener<Object> change = new ChangeListener<Object>()
|
ChangeListener<Object> change = (ObservableValue<? extends Object> ov, Object oldValue, Object newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends Object> ov, Object oldValue, Object newValue)
|
|
||||||
{
|
|
||||||
if (ListBox.this.listChangeListener != null)
|
if (ListBox.this.listChangeListener != null)
|
||||||
ListBox.this.listChangeListener.run();
|
ListBox.this.listChangeListener.run();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
this.checkbox = new ListCheckbox();
|
this.checkbox = new ListCheckbox();
|
||||||
this.checkbox.checkedProperty().addListener(change);
|
this.checkbox.checkedProperty().addListener(change);
|
||||||
@ -147,13 +126,8 @@ public class ListBox extends ScrollPane
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.field.setCursor(Cursor.HAND);
|
this.field.setCursor(Cursor.HAND);
|
||||||
this.field.setOnMouseClicked(new EventHandler<MouseEvent>()
|
this.field.setOnMouseClicked((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
ListBoxItem.this.setChecked(!ListBoxItem.this.isChecked());
|
ListBoxItem.this.setChecked(!ListBoxItem.this.isChecked());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.getChildren().add(this.field);
|
this.getChildren().add(this.field);
|
||||||
@ -169,6 +143,7 @@ public class ListBox extends ScrollPane
|
|||||||
this.checkbox.setChecked(checked);
|
this.checkbox.setChecked(checked);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChecked()
|
public boolean isChecked()
|
||||||
{
|
{
|
||||||
return this.checkbox.isChecked();
|
return this.checkbox.isChecked();
|
||||||
@ -185,46 +160,11 @@ public class ListBox extends ScrollPane
|
|||||||
this.setCursor(Cursor.HAND);
|
this.setCursor(Cursor.HAND);
|
||||||
this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
||||||
|
|
||||||
/*this.setOpacity(0.4);
|
this.setOnMouseClicked((MouseEvent e) -> {
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (ListCheckbox.this.isChecked())
|
if (ListCheckbox.this.isChecked())
|
||||||
ListCheckbox.this.setChecked(false);
|
ListCheckbox.this.setChecked(false);
|
||||||
else
|
else
|
||||||
ListCheckbox.this.setChecked(true);
|
ListCheckbox.this.setChecked(true);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,10 +177,12 @@ public class ListBox extends ScrollPane
|
|||||||
else
|
else
|
||||||
ListCheckbox.this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
ListCheckbox.this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/Checkbox-unchecked.png")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableBooleanValue checkedProperty()
|
public ObservableBooleanValue checkedProperty()
|
||||||
{
|
{
|
||||||
return this.checked;
|
return this.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChecked()
|
public boolean isChecked()
|
||||||
{
|
{
|
||||||
return this.checked.get();
|
return this.checked.get();
|
||||||
|
@ -8,7 +8,6 @@ import com.madeorsk.smartnotes.notes.Note.NoteColor;
|
|||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
@ -40,10 +39,12 @@ public class NoteColorSelector extends HBox
|
|||||||
this.selectedColor.set(color);
|
this.selectedColor.set(color);
|
||||||
this.updateBox();
|
this.updateBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoteColor getSelectedColor()
|
public NoteColor getSelectedColor()
|
||||||
{
|
{
|
||||||
return this.selectedColor.getValue();
|
return this.selectedColor.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableValue<NoteColor> selectedColorProperty()
|
public ObservableValue<NoteColor> selectedColorProperty()
|
||||||
{
|
{
|
||||||
return this.selectedColor;
|
return this.selectedColor;
|
||||||
@ -52,11 +53,12 @@ public class NoteColorSelector extends HBox
|
|||||||
private void updateBox()
|
private void updateBox()
|
||||||
{
|
{
|
||||||
this.getChildren().clear();
|
this.getChildren().clear();
|
||||||
for(final NoteColor color : this.noteColors)
|
for (final NoteColor color : this.noteColors)
|
||||||
{
|
{
|
||||||
Canvas canvas = new Canvas();
|
Canvas canvas = new Canvas();
|
||||||
canvas.setCursor(Cursor.HAND);
|
canvas.setCursor(Cursor.HAND);
|
||||||
canvas.setHeight(50); canvas.setWidth(50);
|
canvas.setHeight(50);
|
||||||
|
canvas.setWidth(50);
|
||||||
GraphicsContext gc = canvas.getGraphicsContext2D();
|
GraphicsContext gc = canvas.getGraphicsContext2D();
|
||||||
if (color.equals(this.getSelectedColor()))
|
if (color.equals(this.getSelectedColor()))
|
||||||
{
|
{
|
||||||
@ -66,13 +68,8 @@ public class NoteColorSelector extends HBox
|
|||||||
gc.setFill(color.getColor());
|
gc.setFill(color.getColor());
|
||||||
gc.fillOval(3, 3, 44, 44);
|
gc.fillOval(3, 3, 44, 44);
|
||||||
|
|
||||||
canvas.setOnMouseClicked(new EventHandler<MouseEvent>()
|
canvas.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
NoteColorSelector.this.setSelectedColor(color);
|
NoteColorSelector.this.setSelectedColor(color);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getChildren().add(canvas);
|
this.getChildren().add(canvas);
|
||||||
|
@ -10,7 +10,6 @@ import com.madeorsk.smartnotes.paths.NotePath;
|
|||||||
import com.madeorsk.smartnotes.paths.Path;
|
import com.madeorsk.smartnotes.paths.Path;
|
||||||
|
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
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;
|
||||||
@ -25,8 +24,6 @@ import javafx.util.Duration;
|
|||||||
public class NotesExplorer extends VBox
|
public class NotesExplorer extends VBox
|
||||||
{
|
{
|
||||||
private SavesManager saves;
|
private SavesManager saves;
|
||||||
/*private Thread saveThread;
|
|
||||||
private Thread nextSaveThread;*/
|
|
||||||
private Map<Integer, Note> notes;
|
private Map<Integer, Note> notes;
|
||||||
|
|
||||||
private HBox titleBox;
|
private HBox titleBox;
|
||||||
@ -78,33 +75,19 @@ public class NotesExplorer extends VBox
|
|||||||
{
|
{
|
||||||
addNoteBox.setCursor(Cursor.HAND);
|
addNoteBox.setCursor(Cursor.HAND);
|
||||||
addNoteBox.setOpacity(0.4);
|
addNoteBox.setOpacity(0.4);
|
||||||
addNoteBox.setOnMouseEntered(new EventHandler<MouseEvent>()
|
addNoteBox.setOnMouseEntered((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
||||||
transition.setFromValue(0.4);
|
transition.setFromValue(0.4);
|
||||||
transition.setToValue(1.0);
|
transition.setToValue(1.0);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
addNoteBox.setOnMouseExited(new EventHandler<MouseEvent>()
|
addNoteBox.setOnMouseExited((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), addNoteBox);
|
||||||
transition.setFromValue(1.0);
|
transition.setFromValue(1.0);
|
||||||
transition.setToValue(0.4);
|
transition.setToValue(0.4);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
addNoteBox.setOnMouseClicked(new EventHandler<MouseEvent>()
|
addNoteBox.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
TextNote note = new TextNote();
|
TextNote note = new TextNote();
|
||||||
SmartNotes.instance.setContent(note.getEditBox(NotesExplorer.this));
|
SmartNotes.instance.setContent(note.getEditBox(NotesExplorer.this));
|
||||||
int id = NotesExplorer.this.getNextId();
|
int id = NotesExplorer.this.getNextId();
|
||||||
@ -112,7 +95,6 @@ public class NotesExplorer extends VBox
|
|||||||
|
|
||||||
NotesExplorer.this.saves.saveIndex(NotesExplorer.this.notes);
|
NotesExplorer.this.saves.saveIndex(NotesExplorer.this.notes);
|
||||||
note.save(NotesExplorer.this.saves, id);
|
note.save(NotesExplorer.this.saves, id);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addNoteBox.setAlignment(Pos.CENTER_LEFT);
|
addNoteBox.setAlignment(Pos.CENTER_LEFT);
|
||||||
@ -128,18 +110,18 @@ public class NotesExplorer extends VBox
|
|||||||
private FolderPath genRoot()
|
private FolderPath genRoot()
|
||||||
{
|
{
|
||||||
FolderPath root = new FolderPath("/", null);
|
FolderPath root = new FolderPath("/", null);
|
||||||
for(int key : this.notes.keySet())
|
for (int key : this.notes.keySet())
|
||||||
{
|
{
|
||||||
Note note = this.notes.get(key);
|
Note note = this.notes.get(key);
|
||||||
if (note.getPaths().isEmpty())
|
if (note.getPaths().isEmpty())
|
||||||
root.addPath(new NotePath(key));
|
root.addPath(new NotePath(key));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(String path : note.getPaths())
|
for (String path : note.getPaths())
|
||||||
{
|
{
|
||||||
FolderPath putIn = root;
|
FolderPath putIn = root;
|
||||||
String[] foldersString = (path.substring(1).contains("#")) ? path.substring(1).split("#") : Arrays.asList(path.substring(1)).toArray(new String[1]);
|
String[] foldersString = (path.substring(1).contains("#")) ? path.substring(1).split("#") : Arrays.asList(path.substring(1)).toArray(new String[1]);
|
||||||
for(String folderString : foldersString)
|
for (String folderString : foldersString)
|
||||||
{
|
{
|
||||||
if (putIn.containsFolder(folderString))
|
if (putIn.containsFolder(folderString))
|
||||||
putIn = putIn.getFolder(folderString);
|
putIn = putIn.getFolder(folderString);
|
||||||
@ -161,10 +143,12 @@ public class NotesExplorer extends VBox
|
|||||||
{
|
{
|
||||||
this.updateList(this.getUpdatedFolder(path));
|
this.updateList(this.getUpdatedFolder(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCurrentFolder()
|
public void updateCurrentFolder()
|
||||||
{
|
{
|
||||||
this.updateList(this.getUpdatedFolder(this.currentFolder));
|
this.updateList(this.getUpdatedFolder(this.currentFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
private FolderPath getUpdatedFolder(FolderPath path)
|
private FolderPath getUpdatedFolder(FolderPath path)
|
||||||
{
|
{
|
||||||
if (path.getParent() == null)
|
if (path.getParent() == null)
|
||||||
@ -181,7 +165,7 @@ public class NotesExplorer extends VBox
|
|||||||
|
|
||||||
public void replaceNote(Note oldNote, Note newNote)
|
public void replaceNote(Note oldNote, Note newNote)
|
||||||
{
|
{
|
||||||
for(int key : this.notes.keySet())
|
for (int key : this.notes.keySet())
|
||||||
{
|
{
|
||||||
if (this.notes.get(key).equals(oldNote))
|
if (this.notes.get(key).equals(oldNote))
|
||||||
{
|
{
|
||||||
@ -193,31 +177,11 @@ public class NotesExplorer extends VBox
|
|||||||
|
|
||||||
public void requestSave(final Note note)
|
public void requestSave(final Note note)
|
||||||
{
|
{
|
||||||
/*Thread currentThread = new Thread(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{*/
|
|
||||||
for (int key : NotesExplorer.this.notes.keySet())
|
for (int key : NotesExplorer.this.notes.keySet())
|
||||||
if (NotesExplorer.this.notes.get(key).equals(note))
|
if (NotesExplorer.this.notes.get(key).equals(note))
|
||||||
note.save(NotesExplorer.this.saves, key);
|
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)
|
public void requestLoad(Note note)
|
||||||
{
|
{
|
||||||
for (int key : this.notes.keySet())
|
for (int key : this.notes.keySet())
|
||||||
@ -228,7 +192,7 @@ public class NotesExplorer extends VBox
|
|||||||
private int getNextId()
|
private int getNextId()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(int key : notes.keySet())
|
for (int key : notes.keySet())
|
||||||
{
|
{
|
||||||
if (key != i)
|
if (key != i)
|
||||||
return i;
|
return i;
|
||||||
|
@ -33,13 +33,14 @@ public class SavesManager
|
|||||||
if (!notes.isEmpty())
|
if (!notes.isEmpty())
|
||||||
{
|
{
|
||||||
String indexString = "";
|
String indexString = "";
|
||||||
for(int key : notes.keySet())
|
for (int key : notes.keySet())
|
||||||
indexString += key + ":" + notes.get(key).getClass().getName() + "\n";
|
indexString += key + ":" + notes.get(key).getClass().getName() + "\n";
|
||||||
|
|
||||||
indexString = indexString.substring(0, indexString.length() - 1);
|
indexString = indexString.substring(0, indexString.length() - 1);
|
||||||
this.writeFile(indexFile, indexString);
|
this.writeFile(indexFile, indexString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Note> loadIndex()
|
public Map<Integer, Note> loadIndex()
|
||||||
{
|
{
|
||||||
File indexFile = new File(SAVE_FOLDER, "index");
|
File indexFile = new File(SAVE_FOLDER, "index");
|
||||||
@ -48,7 +49,7 @@ public class SavesManager
|
|||||||
Map<Integer, Note> notes = new HashMap<Integer, Note>();
|
Map<Integer, Note> notes = new HashMap<Integer, Note>();
|
||||||
String indexString = this.readFile(indexFile);
|
String indexString = this.readFile(indexFile);
|
||||||
String[] notesString = indexString.split("\n");
|
String[] notesString = indexString.split("\n");
|
||||||
for(String noteString : notesString)
|
for (String noteString : notesString)
|
||||||
{
|
{
|
||||||
String[] decomposed = noteString.split(":");
|
String[] decomposed = noteString.split(":");
|
||||||
if (decomposed.length == 2)
|
if (decomposed.length == 2)
|
||||||
@ -75,7 +76,6 @@ public class SavesManager
|
|||||||
{
|
{
|
||||||
return new File(SAVE_FOLDER, id + "");
|
return new File(SAVE_FOLDER, id + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readFile(File file)
|
public String readFile(File file)
|
||||||
{
|
{
|
||||||
try
|
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 = "";
|
String cipher = "";
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (cipher.getBytes().length < bytes.length)
|
while (cipher.getBytes().length < bytesLength)
|
||||||
{
|
{
|
||||||
cipher += key.getBytes()[i];
|
cipher += key.getBytes()[i];
|
||||||
i++;
|
i++;
|
||||||
if (i >= key.getBytes().length)
|
if (i >= key.getBytes().length)
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
return cipher;
|
||||||
|
}
|
||||||
|
private byte[] byteFpeEncryption(byte[] bytes, String key)
|
||||||
|
{
|
||||||
|
String cipher = createCipherFromKey(key, bytes.length);
|
||||||
|
|
||||||
byte[] encryptedBytes = new byte[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]);
|
encryptedBytes[i] = (byte) (bytes[i] + cipher.getBytes()[i]);
|
||||||
|
|
||||||
return encryptedBytes;
|
return encryptedBytes;
|
||||||
}
|
}
|
||||||
private byte[] byteFpeDecryption(byte[] bytes, String key)
|
private byte[] byteFpeDecryption(byte[] bytes, String key)
|
||||||
{
|
{
|
||||||
String cipher = "";
|
String cipher = createCipherFromKey(key, bytes.length);
|
||||||
int i = 0;
|
|
||||||
while (cipher.getBytes().length < bytes.length)
|
|
||||||
{
|
|
||||||
cipher += key.getBytes()[i];
|
|
||||||
i++;
|
|
||||||
if (i >= key.getBytes().length)
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] decryptedBytes = new byte[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]);
|
decryptedBytes[i] = (byte) (bytes[i] - cipher.getBytes()[i]);
|
||||||
|
|
||||||
return decryptedBytes;
|
return decryptedBytes;
|
||||||
|
@ -13,10 +13,8 @@ import org.w3c.dom.Text;
|
|||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.concurrent.Worker.State;
|
import javafx.concurrent.Worker.State;
|
||||||
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;
|
||||||
@ -28,7 +26,7 @@ import javafx.stage.WindowEvent;
|
|||||||
|
|
||||||
public class SmartNotes extends Application
|
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)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
@ -64,11 +62,7 @@ public class SmartNotes extends Application
|
|||||||
instance = this;
|
instance = this;
|
||||||
webView = new WebView();
|
webView = new WebView();
|
||||||
final String css = Utils.loadText("/com/madeorsk/smartnotes/webView.css");
|
final String css = Utils.loadText("/com/madeorsk/smartnotes/webView.css");
|
||||||
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>()
|
webView.getEngine().getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldValue, State newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends State> ov, State oldValue, State newValue)
|
|
||||||
{
|
|
||||||
if (newValue == State.SUCCEEDED)
|
if (newValue == State.SUCCEEDED)
|
||||||
{
|
{
|
||||||
Document doc = webView.getEngine().getDocument();
|
Document doc = webView.getEngine().getDocument();
|
||||||
@ -76,11 +70,10 @@ public class SmartNotes extends Application
|
|||||||
Text styleContent = doc.createTextNode(css);
|
Text styleContent = doc.createTextNode(css);
|
||||||
styleNode.appendChild(styleContent);
|
styleNode.appendChild(styleContent);
|
||||||
doc.getDocumentElement().getElementsByTagName("head").item(0).appendChild(styleNode);
|
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.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 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 Italic.ttf"), 10);
|
||||||
@ -97,30 +90,21 @@ public class SmartNotes extends Application
|
|||||||
|
|
||||||
this.explorer = new NotesExplorer();
|
this.explorer = new NotesExplorer();
|
||||||
ScrollPane scrollPane = new ScrollPane(this.explorer);
|
ScrollPane scrollPane = new ScrollPane(this.explorer);
|
||||||
scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true);
|
scrollPane.setFitToHeight(true);
|
||||||
|
scrollPane.setFitToWidth(true);
|
||||||
this.root.getChildren().add(scrollPane);
|
this.root.getChildren().add(scrollPane);
|
||||||
|
|
||||||
this.scene = new Scene(this.root, 800, 600);
|
this.scene = new Scene(this.root, 800, 600);
|
||||||
this.scene.getStylesheets().add("/com/madeorsk/smartnotes/style.css");
|
this.scene.getStylesheets().add("/com/madeorsk/smartnotes/style.css");
|
||||||
|
|
||||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>()
|
stage.setOnCloseRequest((WindowEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(WindowEvent e)
|
|
||||||
{
|
|
||||||
SmartNotes.this.explorer.close();
|
SmartNotes.this.explorer.close();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
stage.setScene(this.scene);
|
stage.setScene(this.scene);
|
||||||
stage.setTitle("SmartNotes " + version);
|
stage.setTitle("SmartNotes " + version);
|
||||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>()
|
stage.setOnCloseRequest((WindowEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(WindowEvent event)
|
|
||||||
{
|
|
||||||
SmartNotes.this.onStop();
|
SmartNotes.this.onStop();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
@ -129,13 +113,15 @@ public class SmartNotes extends Application
|
|||||||
{
|
{
|
||||||
this.setContent(region, false);
|
this.setContent(region, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContent(Region region, boolean useScrollPane)
|
public void setContent(Region region, boolean useScrollPane)
|
||||||
{
|
{
|
||||||
this.root.getChildren().clear();
|
this.root.getChildren().clear();
|
||||||
if (useScrollPane)
|
if (useScrollPane)
|
||||||
{
|
{
|
||||||
ScrollPane scrollPane = new ScrollPane(region);
|
ScrollPane scrollPane = new ScrollPane(region);
|
||||||
scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true);
|
scrollPane.setFitToHeight(true);
|
||||||
|
scrollPane.setFitToWidth(true);
|
||||||
this.root.getChildren().add(scrollPane);
|
this.root.getChildren().add(scrollPane);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -165,13 +151,16 @@ public class SmartNotes extends Application
|
|||||||
{
|
{
|
||||||
//System.out.println("P == " + e.getKeyCode() + ":" + e.getKeyChar());
|
//System.out.println("P == " + e.getKeyCode() + ":" + e.getKeyChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nativeKeyReleased(NativeKeyEvent e)
|
public void nativeKeyReleased(NativeKeyEvent e)
|
||||||
{
|
{
|
||||||
//System.out.println("R == " + e.getKeyCode() + ":" + e.getKeyChar());
|
//System.out.println("R == " + e.getKeyCode() + ":" + e.getKeyChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nativeKeyTyped(NativeKeyEvent e)
|
public void nativeKeyTyped(NativeKeyEvent e)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.madeorsk.smartnotes.notes.Note;
|
|||||||
import com.madeorsk.smartnotes.notes.TextNote;
|
import com.madeorsk.smartnotes.notes.TextNote;
|
||||||
|
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
@ -25,10 +24,7 @@ public class TypeSelector extends HBox
|
|||||||
textNoteItem.setSelected(true);
|
textNoteItem.setSelected(true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
textNoteItem.setOnMouseClicked(new EventHandler<MouseEvent>()
|
textNoteItem.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
Note textNote = new TextNote();
|
Note textNote = new TextNote();
|
||||||
textNote.setName(note.getName());
|
textNote.setName(note.getName());
|
||||||
textNote.setTextContent(note.getTextContent());
|
textNote.setTextContent(note.getTextContent());
|
||||||
@ -36,7 +32,6 @@ public class TypeSelector extends HBox
|
|||||||
explorer.replaceNote(note, textNote);
|
explorer.replaceNote(note, textNote);
|
||||||
explorer.requestSave(textNote);
|
explorer.requestSave(textNote);
|
||||||
SmartNotes.instance.setContent(textNote.getEditBox(explorer));
|
SmartNotes.instance.setContent(textNote.getEditBox(explorer));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,11 +42,7 @@ public class TypeSelector extends HBox
|
|||||||
listNoteItem.setSelected(true);
|
listNoteItem.setSelected(true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
listNoteItem.setOnMouseClicked(new EventHandler<MouseEvent>()
|
listNoteItem.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
Note listNote = new ListNote();
|
Note listNote = new ListNote();
|
||||||
listNote.setName(note.getName());
|
listNote.setName(note.getName());
|
||||||
listNote.setTextContent(note.getTextContent());
|
listNote.setTextContent(note.getTextContent());
|
||||||
@ -59,30 +50,25 @@ public class TypeSelector extends HBox
|
|||||||
explorer.replaceNote(note, listNote);
|
explorer.replaceNote(note, listNote);
|
||||||
explorer.requestSave(listNote);
|
explorer.requestSave(listNote);
|
||||||
SmartNotes.instance.setContent(listNote.getEditBox(explorer));
|
SmartNotes.instance.setContent(listNote.getEditBox(explorer));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getChildren().add(listNoteItem);
|
this.getChildren().add(listNoteItem);
|
||||||
TypeItem imageNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/ImageNoteChoice.png");
|
TypeItem imageNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/ImageNoteChoice.png");
|
||||||
{
|
{
|
||||||
|
} //TODO Next versions.
|
||||||
}
|
|
||||||
this.getChildren().add(imageNoteItem);
|
this.getChildren().add(imageNoteItem);
|
||||||
TypeItem soundNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/SoundNoteChoice.png");
|
TypeItem soundNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/SoundNoteChoice.png");
|
||||||
{
|
{
|
||||||
|
} //TODO Next versions.
|
||||||
}
|
|
||||||
this.getChildren().add(soundNoteItem);
|
this.getChildren().add(soundNoteItem);
|
||||||
TypeItem videoNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/VideoNoteChoice.png");
|
TypeItem videoNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/VideoNoteChoice.png");
|
||||||
{
|
{
|
||||||
|
} //TODO Next versions.
|
||||||
}
|
|
||||||
this.getChildren().add(videoNoteItem);
|
this.getChildren().add(videoNoteItem);
|
||||||
TypeItem positionNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/PositionNoteChoice.png");
|
TypeItem positionNoteItem = new TypeItem("/com/madeorsk/smartnotes/res/PositionNoteChoice.png");
|
||||||
{
|
{
|
||||||
|
} //TODO Next versions.
|
||||||
}
|
|
||||||
this.getChildren().add(positionNoteItem);
|
this.getChildren().add(positionNoteItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,11 +83,7 @@ public class TypeSelector extends HBox
|
|||||||
this.getChildren().add(new ImageView(new Image(typeIconPath)));
|
this.getChildren().add(new ImageView(new Image(typeIconPath)));
|
||||||
|
|
||||||
this.setOpacity(0.4);
|
this.setOpacity(0.4);
|
||||||
this.setOnMouseEntered(new EventHandler<MouseEvent>()
|
this.setOnMouseEntered((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
if (!TypeItem.this.isSelected())
|
if (!TypeItem.this.isSelected())
|
||||||
{
|
{
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
||||||
@ -109,13 +91,8 @@ public class TypeSelector extends HBox
|
|||||||
transition.setToValue(1.0);
|
transition.setToValue(1.0);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.setOnMouseExited(new EventHandler<MouseEvent>()
|
this.setOnMouseExited((MouseEvent e) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent e)
|
|
||||||
{
|
|
||||||
if (!TypeItem.this.isSelected())
|
if (!TypeItem.this.isSelected())
|
||||||
{
|
{
|
||||||
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
FadeTransition transition = new FadeTransition(Duration.millis(200), TypeItem.this);
|
||||||
@ -123,7 +100,6 @@ public class TypeSelector extends HBox
|
|||||||
transition.setToValue(0.4);
|
transition.setToValue(0.4);
|
||||||
transition.play();
|
transition.play();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,6 +116,7 @@ public class TypeSelector extends HBox
|
|||||||
transition.play();
|
transition.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelected()
|
public boolean isSelected()
|
||||||
{
|
{
|
||||||
return this.selected;
|
return this.selected;
|
||||||
|
@ -17,7 +17,7 @@ public class Utils
|
|||||||
{
|
{
|
||||||
InputStream is = Utils.class.getResourceAsStream(path);
|
InputStream is = Utils.class.getResourceAsStream(path);
|
||||||
String result = "";
|
String result = "";
|
||||||
byte[] buffer = new byte[1024*8];
|
byte[] buffer = new byte[1024 * 8];
|
||||||
while (is.read(buffer) > 0)
|
while (is.read(buffer) > 0)
|
||||||
result += new String(buffer);
|
result += new String(buffer);
|
||||||
return result.trim();
|
return result.trim();
|
||||||
|
@ -59,14 +59,9 @@ public class ListNote extends Note
|
|||||||
returnButton.setId("imageButton");
|
returnButton.setId("imageButton");
|
||||||
returnButton.setCursor(Cursor.HAND);
|
returnButton.setCursor(Cursor.HAND);
|
||||||
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
||||||
returnButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
explorer.updateCurrentFolder();
|
explorer.updateCurrentFolder();
|
||||||
SmartNotes.instance.setContent(explorer, true);
|
SmartNotes.instance.setContent(explorer, true);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(returnButton);
|
titleBox.getChildren().add(returnButton);
|
||||||
|
|
||||||
@ -74,13 +69,8 @@ public class ListNote extends Note
|
|||||||
editButton.setId("imageButton");
|
editButton.setId("imageButton");
|
||||||
editButton.setCursor(Cursor.HAND);
|
editButton.setCursor(Cursor.HAND);
|
||||||
editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png")));
|
editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png")));
|
||||||
editButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
editButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
SmartNotes.instance.setContent(ListNote.this.getEditBox(explorer));
|
SmartNotes.instance.setContent(ListNote.this.getEditBox(explorer));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
HBox buttonsBox = new HBox();
|
HBox buttonsBox = new HBox();
|
||||||
buttonsBox.getChildren().add(editButton);
|
buttonsBox.getChildren().add(editButton);
|
||||||
@ -90,17 +80,16 @@ public class ListNote extends Note
|
|||||||
NoteColorSelector colorSelector = new NoteColorSelector();
|
NoteColorSelector colorSelector = new NoteColorSelector();
|
||||||
colorSelector.setAlignment(Pos.CENTER);
|
colorSelector.setAlignment(Pos.CENTER);
|
||||||
colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2));
|
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.setSelectedColor(this.getNoteColor());
|
||||||
colorSelector.selectedColorProperty().addListener(new ChangeListener<NoteColor>()
|
colorSelector.selectedColorProperty().addListener((ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue)
|
|
||||||
{
|
|
||||||
ListNote.this.setNoteColor(newValue);
|
ListNote.this.setNoteColor(newValue);
|
||||||
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");");
|
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed() * 255 + "," + newValue.getColor().getGreen() * 255 + "," + newValue.getColor().getBlue() * 255 + ");");
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(colorSelector);
|
titleBox.getChildren().add(colorSelector);
|
||||||
}
|
}
|
||||||
@ -111,22 +100,15 @@ public class ListNote extends Note
|
|||||||
nameField.prefWidthProperty().bind(box.widthProperty());
|
nameField.prefWidthProperty().bind(box.widthProperty());
|
||||||
nameField.setAlignment(Pos.CENTER);
|
nameField.setAlignment(Pos.CENTER);
|
||||||
nameField.setId("nameField");
|
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.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.setText(this.getName());
|
||||||
nameField.textProperty().addListener(new ChangeListener<String>()
|
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
ListNote.this.setName(newValue);
|
ListNote.this.setName(newValue);
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(nameField);
|
box.getChildren().add(nameField);
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
HBox separator = new HBox();
|
HBox separator = new HBox();
|
||||||
separator.setId("separator");
|
separator.setId("separator");
|
||||||
separator.setPrefHeight(5);
|
separator.setPrefHeight(5);
|
||||||
@ -134,44 +116,13 @@ public class ListNote extends Note
|
|||||||
SmartNotes.webView.getEngine().loadContent(Utils.markdownToHtml(this.getTextContent()));
|
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));
|
SmartNotes.webView.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
||||||
box.getChildren().add(SmartNotes.webView);
|
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);
|
box.getChildren().add(separator);
|
||||||
|
|
||||||
this.listBox.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
this.listBox.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
||||||
this.listBox.setListChangeListener(new Runnable()
|
this.listBox.setListChangeListener(() -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (!ListNote.this.loading)
|
if (!ListNote.this.loading)
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
box.getChildren().add(this.listBox);
|
box.getChildren().add(this.listBox);
|
||||||
|
|
||||||
@ -197,14 +148,9 @@ public class ListNote extends Note
|
|||||||
returnButton.setId("imageButton");
|
returnButton.setId("imageButton");
|
||||||
returnButton.setCursor(Cursor.HAND);
|
returnButton.setCursor(Cursor.HAND);
|
||||||
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
||||||
returnButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
explorer.updateCurrentFolder();
|
explorer.updateCurrentFolder();
|
||||||
SmartNotes.instance.setContent(explorer, true);
|
SmartNotes.instance.setContent(explorer, true);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(returnButton);
|
titleBox.getChildren().add(returnButton);
|
||||||
|
|
||||||
@ -216,17 +162,16 @@ public class ListNote extends Note
|
|||||||
NoteColorSelector colorSelector = new NoteColorSelector();
|
NoteColorSelector colorSelector = new NoteColorSelector();
|
||||||
colorSelector.setAlignment(Pos.CENTER);
|
colorSelector.setAlignment(Pos.CENTER);
|
||||||
colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2));
|
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.setSelectedColor(this.getNoteColor());
|
||||||
colorSelector.selectedColorProperty().addListener(new ChangeListener<NoteColor>()
|
colorSelector.selectedColorProperty().addListener((ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue)
|
|
||||||
{
|
|
||||||
ListNote.this.setNoteColor(newValue);
|
ListNote.this.setNoteColor(newValue);
|
||||||
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");");
|
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed() * 255 + "," + newValue.getColor().getGreen() * 255 + "," + newValue.getColor().getBlue() * 255 + ");");
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(colorSelector);
|
titleBox.getChildren().add(colorSelector);
|
||||||
}
|
}
|
||||||
@ -236,16 +181,11 @@ public class ListNote extends Note
|
|||||||
{
|
{
|
||||||
nameField.setAlignment(Pos.CENTER);
|
nameField.setAlignment(Pos.CENTER);
|
||||||
nameField.setId("nameField");
|
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.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.setText(this.getName());
|
||||||
nameField.textProperty().addListener(new ChangeListener<String>()
|
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
ListNote.this.setName(newValue);
|
ListNote.this.setName(newValue);
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(nameField);
|
box.getChildren().add(nameField);
|
||||||
@ -262,23 +202,13 @@ public class ListNote extends Note
|
|||||||
textArea.setWrapText(true);
|
textArea.setWrapText(true);
|
||||||
textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
||||||
textArea.setText(this.getTextContent());
|
textArea.setText(this.getTextContent());
|
||||||
textArea.textProperty().addListener(new ChangeListener<String>()
|
textArea.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
ListNote.this.setTextContent(newValue);
|
ListNote.this.setTextContent(newValue);
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Platform.runLater(new Runnable()
|
Platform.runLater(() -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
textArea.requestFocus();
|
textArea.requestFocus();
|
||||||
textArea.positionCaret(textArea.getLength());
|
textArea.positionCaret(textArea.getLength());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(textArea);
|
box.getChildren().add(textArea);
|
||||||
@ -286,14 +216,9 @@ public class ListNote extends Note
|
|||||||
box.getChildren().add(separator);
|
box.getChildren().add(separator);
|
||||||
|
|
||||||
this.listBox.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
this.listBox.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()).subtract(separator.heightProperty()).divide(2));
|
||||||
this.listBox.setListChangeListener(new Runnable()
|
this.listBox.setListChangeListener(() -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (!ListNote.this.loading)
|
if (!ListNote.this.loading)
|
||||||
explorer.requestSave(ListNote.this);
|
explorer.requestSave(ListNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
box.getChildren().add(this.listBox);
|
box.getChildren().add(this.listBox);
|
||||||
|
|
||||||
@ -306,10 +231,11 @@ public class ListNote extends Note
|
|||||||
String fileContent = this.getName() + "\n" + this.getNoteColor().name() + "\n";
|
String fileContent = this.getName() + "\n" + this.getNoteColor().name() + "\n";
|
||||||
Map<String, Boolean> list = this.listBox.getList();
|
Map<String, Boolean> list = this.listBox.getList();
|
||||||
fileContent += Integer.toUnsignedString(list.keySet().size(), 16) + "\n";
|
fileContent += Integer.toUnsignedString(list.keySet().size(), 16) + "\n";
|
||||||
for(String key : list.keySet())
|
for (String key : list.keySet())
|
||||||
fileContent += key + ":" + list.get(key).toString() + "\n";
|
fileContent += key + ":" + list.get(key).toString() + "\n";
|
||||||
saves.writeFile(saves.getSaveFile(id), fileContent + this.getTextContent());
|
saves.writeFile(saves.getSaveFile(id), fileContent + this.getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean load(SavesManager saves, int id)
|
public boolean load(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
@ -330,7 +256,7 @@ public class ListNote extends Note
|
|||||||
separatorIndex = saved.indexOf('\n');
|
separatorIndex = saved.indexOf('\n');
|
||||||
int listSize = Integer.parseUnsignedInt(saved.substring(0, separatorIndex), 16);
|
int listSize = Integer.parseUnsignedInt(saved.substring(0, separatorIndex), 16);
|
||||||
Map<String, Boolean> list = new HashMap<String, Boolean>();
|
Map<String, Boolean> list = new HashMap<String, Boolean>();
|
||||||
for(int i = 0; i < listSize; i++)
|
for (int i = 0; i < listSize; i++)
|
||||||
{
|
{
|
||||||
saved = saved.substring(separatorIndex + 1);
|
saved = saved.substring(separatorIndex + 1);
|
||||||
separatorIndex = saved.indexOf('\n');
|
separatorIndex = saved.indexOf('\n');
|
||||||
@ -351,6 +277,7 @@ public class ListNote extends Note
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(SavesManager saves, int id)
|
public void delete(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
|
@ -21,15 +21,17 @@ public abstract class Note implements SavableNote
|
|||||||
private double r;
|
private double r;
|
||||||
private double g;
|
private double g;
|
||||||
private double b;
|
private double b;
|
||||||
|
|
||||||
NoteColor(double red, double green, double blue)
|
NoteColor(double red, double green, double blue)
|
||||||
{
|
{
|
||||||
this.r = red;
|
this.r = red;
|
||||||
this.g = green;
|
this.g = green;
|
||||||
this.b = blue;
|
this.b = blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor()
|
public Color getColor()
|
||||||
{
|
{
|
||||||
return new Color(this.r/255, this.g/255, this.b/255, 1);
|
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;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return this.name;
|
return this.name;
|
||||||
@ -51,10 +54,12 @@ public abstract class Note implements SavableNote
|
|||||||
{
|
{
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoteColor getNoteColor()
|
public NoteColor getNoteColor()
|
||||||
{
|
{
|
||||||
return this.color;
|
return this.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getPaths()
|
public List<String> getPaths()
|
||||||
{
|
{
|
||||||
return this.paths;
|
return this.paths;
|
||||||
@ -65,10 +70,12 @@ public abstract class Note implements SavableNote
|
|||||||
this.textContent = content;
|
this.textContent = content;
|
||||||
this.updatePaths();
|
this.updatePaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextContent()
|
public String getTextContent()
|
||||||
{
|
{
|
||||||
return this.textContent;
|
return this.textContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePaths()
|
private void updatePaths()
|
||||||
{
|
{
|
||||||
this.paths.clear();
|
this.paths.clear();
|
||||||
@ -79,13 +86,13 @@ public abstract class Note implements SavableNote
|
|||||||
{
|
{
|
||||||
String[] lines = text.split("\n");
|
String[] lines = text.split("\n");
|
||||||
String lastLine = lines[lines.length - 1];
|
String lastLine = lines[lines.length - 1];
|
||||||
for(String word : lastLine.split(" "))
|
for (String word : lastLine.split(" "))
|
||||||
if (word.startsWith("#") && !word.equals("#"))
|
if (word.startsWith("#") && !word.equals("#"))
|
||||||
this.paths.add(word);
|
this.paths.add(word);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(String word : text.split(" "))
|
for (String word : text.split(" "))
|
||||||
if (word.startsWith("#") && !word.equals("#"))
|
if (word.startsWith("#") && !word.equals("#"))
|
||||||
this.paths.add(word);
|
this.paths.add(word);
|
||||||
}
|
}
|
||||||
@ -93,5 +100,6 @@ public abstract class Note implements SavableNote
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract VBox getViewBox(NotesExplorer explorer);
|
public abstract VBox getViewBox(NotesExplorer explorer);
|
||||||
|
|
||||||
public abstract VBox getEditBox(NotesExplorer explorer);
|
public abstract VBox getEditBox(NotesExplorer explorer);
|
||||||
}
|
}
|
||||||
|
@ -49,14 +49,9 @@ public class TextNote extends Note
|
|||||||
returnButton.setId("imageButton");
|
returnButton.setId("imageButton");
|
||||||
returnButton.setCursor(Cursor.HAND);
|
returnButton.setCursor(Cursor.HAND);
|
||||||
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
||||||
returnButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
explorer.updateCurrentFolder();
|
explorer.updateCurrentFolder();
|
||||||
SmartNotes.instance.setContent(explorer, true);
|
SmartNotes.instance.setContent(explorer, true);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(returnButton);
|
titleBox.getChildren().add(returnButton);
|
||||||
|
|
||||||
@ -64,13 +59,8 @@ public class TextNote extends Note
|
|||||||
editButton.setId("imageButton");
|
editButton.setId("imageButton");
|
||||||
editButton.setCursor(Cursor.HAND);
|
editButton.setCursor(Cursor.HAND);
|
||||||
editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png")));
|
editButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/EditIcon.png")));
|
||||||
editButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
editButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
SmartNotes.instance.setContent(TextNote.this.getEditBox(explorer));
|
SmartNotes.instance.setContent(TextNote.this.getEditBox(explorer));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
HBox buttonsBox = new HBox();
|
HBox buttonsBox = new HBox();
|
||||||
buttonsBox.getChildren().add(editButton);
|
buttonsBox.getChildren().add(editButton);
|
||||||
@ -80,17 +70,16 @@ public class TextNote extends Note
|
|||||||
NoteColorSelector colorSelector = new NoteColorSelector();
|
NoteColorSelector colorSelector = new NoteColorSelector();
|
||||||
colorSelector.setAlignment(Pos.CENTER);
|
colorSelector.setAlignment(Pos.CENTER);
|
||||||
colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2));
|
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.setSelectedColor(this.getNoteColor());
|
||||||
colorSelector.selectedColorProperty().addListener(new ChangeListener<NoteColor>()
|
colorSelector.selectedColorProperty().addListener((ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue)
|
|
||||||
{
|
|
||||||
TextNote.this.setNoteColor(newValue);
|
TextNote.this.setNoteColor(newValue);
|
||||||
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");");
|
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed() * 255 + "," + newValue.getColor().getGreen() * 255 + "," + newValue.getColor().getBlue() * 255 + ");");
|
||||||
explorer.requestSave(TextNote.this);
|
explorer.requestSave(TextNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(colorSelector);
|
titleBox.getChildren().add(colorSelector);
|
||||||
}
|
}
|
||||||
@ -101,16 +90,11 @@ public class TextNote extends Note
|
|||||||
nameField.prefWidthProperty().bind(box.widthProperty());
|
nameField.prefWidthProperty().bind(box.widthProperty());
|
||||||
nameField.setAlignment(Pos.CENTER);
|
nameField.setAlignment(Pos.CENTER);
|
||||||
nameField.setId("nameField");
|
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.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.setText(this.getName());
|
||||||
nameField.textProperty().addListener(new ChangeListener<String>()
|
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
TextNote.this.setName(newValue);
|
TextNote.this.setName(newValue);
|
||||||
explorer.requestSave(TextNote.this);
|
explorer.requestSave(TextNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(nameField);
|
box.getChildren().add(nameField);
|
||||||
@ -138,14 +122,9 @@ public class TextNote extends Note
|
|||||||
returnButton.setId("imageButton");
|
returnButton.setId("imageButton");
|
||||||
returnButton.setCursor(Cursor.HAND);
|
returnButton.setCursor(Cursor.HAND);
|
||||||
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
||||||
returnButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
returnButton.setOnMouseClicked((MouseEvent event) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
explorer.updateCurrentFolder();
|
explorer.updateCurrentFolder();
|
||||||
SmartNotes.instance.setContent(explorer, true);
|
SmartNotes.instance.setContent(explorer, true);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(returnButton);
|
titleBox.getChildren().add(returnButton);
|
||||||
|
|
||||||
@ -157,17 +136,16 @@ public class TextNote extends Note
|
|||||||
NoteColorSelector colorSelector = new NoteColorSelector();
|
NoteColorSelector colorSelector = new NoteColorSelector();
|
||||||
colorSelector.setAlignment(Pos.CENTER);
|
colorSelector.setAlignment(Pos.CENTER);
|
||||||
colorSelector.prefWidthProperty().bind(titleBox.widthProperty().subtract(returnButton.widthProperty()).divide(2));
|
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.setSelectedColor(this.getNoteColor());
|
||||||
colorSelector.selectedColorProperty().addListener(new ChangeListener<NoteColor>()
|
colorSelector.selectedColorProperty().addListener((ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue)
|
|
||||||
{
|
|
||||||
TextNote.this.setNoteColor(newValue);
|
TextNote.this.setNoteColor(newValue);
|
||||||
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed()*255 + "," + newValue.getColor().getGreen()*255 + "," + newValue.getColor().getBlue()*255 + ");");
|
nameField.setStyle("-fx-text-fill: rgb(" + newValue.getColor().getRed() * 255 + "," + newValue.getColor().getGreen() * 255 + "," + newValue.getColor().getBlue() * 255 + ");");
|
||||||
explorer.requestSave(TextNote.this);
|
explorer.requestSave(TextNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
titleBox.getChildren().add(colorSelector);
|
titleBox.getChildren().add(colorSelector);
|
||||||
}
|
}
|
||||||
@ -177,16 +155,11 @@ public class TextNote extends Note
|
|||||||
{
|
{
|
||||||
nameField.setAlignment(Pos.CENTER);
|
nameField.setAlignment(Pos.CENTER);
|
||||||
nameField.setId("nameField");
|
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.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.setText(this.getName());
|
||||||
nameField.textProperty().addListener(new ChangeListener<String>()
|
nameField.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
TextNote.this.setName(newValue);
|
TextNote.this.setName(newValue);
|
||||||
explorer.requestSave(TextNote.this);
|
explorer.requestSave(TextNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(nameField);
|
box.getChildren().add(nameField);
|
||||||
@ -197,23 +170,13 @@ public class TextNote extends Note
|
|||||||
textArea.setWrapText(true);
|
textArea.setWrapText(true);
|
||||||
textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()));
|
textArea.prefHeightProperty().bind(box.heightProperty().subtract(nameField.heightProperty()).subtract(titleBox.heightProperty()));
|
||||||
textArea.setText(this.getTextContent());
|
textArea.setText(this.getTextContent());
|
||||||
textArea.textProperty().addListener(new ChangeListener<String>()
|
textArea.textProperty().addListener((ObservableValue<? extends String> ov, String oldValue, String newValue) -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
|
||||||
{
|
|
||||||
TextNote.this.setTextContent(newValue);
|
TextNote.this.setTextContent(newValue);
|
||||||
explorer.requestSave(TextNote.this);
|
explorer.requestSave(TextNote.this);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Platform.runLater(new Runnable()
|
Platform.runLater(() -> {
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
textArea.requestFocus();
|
textArea.requestFocus();
|
||||||
textArea.positionCaret(textArea.getLength());
|
textArea.positionCaret(textArea.getLength());
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(textArea);
|
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());
|
saves.writeFile(saves.getSaveFile(id), this.getName() + "\n" + this.getNoteColor().name() + "\n" + this.getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean load(SavesManager saves, int id)
|
public boolean load(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
@ -246,6 +210,7 @@ public class TextNote extends Note
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(SavesManager saves, int id)
|
public void delete(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
|
@ -22,15 +22,16 @@ public class FolderPath implements Path
|
|||||||
|
|
||||||
public FolderPath getFolder(String folderName)
|
public FolderPath getFolder(String folderName)
|
||||||
{
|
{
|
||||||
for(Path path : this.content)
|
for (Path path : this.content)
|
||||||
if (path.isFolder())
|
if (path.isFolder())
|
||||||
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
||||||
return (FolderPath) path;
|
return (FolderPath) path;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsFolder(String folderName)
|
public boolean containsFolder(String folderName)
|
||||||
{
|
{
|
||||||
for(Path path : this.content)
|
for (Path path : this.content)
|
||||||
if (path.isFolder())
|
if (path.isFolder())
|
||||||
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
||||||
return true;
|
return true;
|
||||||
@ -42,14 +43,17 @@ public class FolderPath implements Path
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FolderPath getParent()
|
public FolderPath getParent()
|
||||||
{
|
{
|
||||||
return this.parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Path> getContent()
|
public List<Path> getContent()
|
||||||
{
|
{
|
||||||
return this.content;
|
return this.content;
|
||||||
|
@ -2,15 +2,18 @@
|
|||||||
{
|
{
|
||||||
-fx-background-color: #282828;
|
-fx-background-color: #282828;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-bar .increment-button, .scroll-bar .decrement-button, .scroll-bar .increment-button .increment-arrow, .scroll-bar .decrement-button .decrement-arrow
|
.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-font-size: 0;
|
||||||
-fx-padding: 0;
|
-fx-padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-bar .track
|
.scroll-bar .track
|
||||||
{
|
{
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-bar .thumb
|
.scroll-bar .thumb
|
||||||
{
|
{
|
||||||
-fx-background-color: rgba(0, 0, 0, 0.15);
|
-fx-background-color: rgba(0, 0, 0, 0.15);
|
||||||
@ -21,20 +24,24 @@
|
|||||||
{
|
{
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nameField, #text, #noteItemName
|
#nameField, #text, #noteItemName
|
||||||
{
|
{
|
||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-font-family: "Courier Prime Sans";
|
-fx-font-family: "Courier Prime Sans", monospace;
|
||||||
-fx-font-size: 32px;
|
-fx-font-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#noteItemName
|
#noteItemName
|
||||||
{
|
{
|
||||||
-fx-font-size: 24px;
|
-fx-font-size: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#text
|
#text
|
||||||
{
|
{
|
||||||
-fx-font-size: 20px;
|
-fx-font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#separator
|
#separator
|
||||||
{
|
{
|
||||||
-fx-background-color: rgba(0, 0, 0, 0.15);
|
-fx-background-color: rgba(0, 0, 0, 0.15);
|
||||||
|
@ -2,18 +2,19 @@ body
|
|||||||
{
|
{
|
||||||
background: #282828;
|
background: #282828;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Courier Prime Sans";
|
font-family: "Courier Prime Sans", monospace;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
code
|
code
|
||||||
{
|
{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-family: "Courier Prime Code";
|
font-family: "Courier Prime Code", monospace;
|
||||||
background: rgba(0, 0, 0, 0.1);
|
background: rgba(0, 0, 0, 0.1);
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre code
|
pre code
|
||||||
{
|
{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -22,7 +23,7 @@ pre code
|
|||||||
blockquote
|
blockquote
|
||||||
{
|
{
|
||||||
display: block;
|
display: block;
|
||||||
font-family: "Courier Prime";
|
font-family: "Courier Prime", monospace;
|
||||||
padding: 0 10px 0 10px;
|
padding: 0 10px 0 10px;
|
||||||
border-left: solid rgba(0, 0, 0, 0.25) 2px;
|
border-left: solid rgba(0, 0, 0, 0.25) 2px;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user