Finished NotesExplorer and TextNote editor update
- Finished NotesExplorer system, should be ready for the next updates - Added color selector in TextNote editor - Added button to get back to the explorer from TextNote editor - Added color in TextNote save file - Added Parent to FolderPath
@ -1,9 +1,16 @@
|
|||||||
package com.madeorsk.smartnotes;
|
package com.madeorsk.smartnotes;
|
||||||
|
|
||||||
import com.madeorsk.smartnotes.notes.Note;
|
import com.madeorsk.smartnotes.notes.Note;
|
||||||
|
import com.madeorsk.smartnotes.notes.TextNote;
|
||||||
import com.madeorsk.smartnotes.paths.FolderPath;
|
import com.madeorsk.smartnotes.paths.FolderPath;
|
||||||
|
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
|
|
||||||
public class ExplorerItem extends HBox
|
public class ExplorerItem extends HBox
|
||||||
@ -11,24 +18,58 @@ public class ExplorerItem extends HBox
|
|||||||
private boolean folder;
|
private boolean folder;
|
||||||
private Object item;
|
private Object item;
|
||||||
|
|
||||||
public ExplorerItem(boolean folder, Object item)
|
public ExplorerItem(boolean folder, Object item, final NotesExplorer explorer)
|
||||||
{
|
{
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
|
||||||
|
this.setCursor(Cursor.HAND);
|
||||||
|
this.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent event)
|
||||||
|
{
|
||||||
|
if (ExplorerItem.this.folder)
|
||||||
|
explorer.goToFolder((FolderPath) ExplorerItem.this.item);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
explorer.requestLoad((Note) ExplorerItem.this.item);
|
||||||
|
SmartNotes.instance.setContent(((TextNote) ExplorerItem.this.item).getNoteBox(explorer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
this.setSpacing(10);
|
||||||
|
|
||||||
if (this.folder)
|
if (this.folder)
|
||||||
{
|
{
|
||||||
FolderPath folderPath = (FolderPath) this.item;
|
FolderPath folderPath = (FolderPath) this.item;
|
||||||
this.getChildren().add(new Label("FOLDER"));
|
this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/FolderIcon.png")));
|
||||||
this.getChildren().add(new Label(folderPath.getName()));
|
Label folderNameLabel = new Label(folderPath.getName());
|
||||||
|
folderNameLabel.setId("noteItemName");
|
||||||
|
this.getChildren().add(folderNameLabel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Note note = (Note) this.item;
|
Note note = (Note) this.item;
|
||||||
Label img = new Label("NOTE");
|
this.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/TextNoteIcon-" + note.getNoteColor().name() + ".png")));
|
||||||
img.setTextFill(note.getNoteColor().getColor());
|
Label noteNameLabel = new Label(note.getName());
|
||||||
this.getChildren().add(img);
|
noteNameLabel.setId("noteItemName");
|
||||||
this.getChildren().add(new Label(note.getName()));
|
this.getChildren().add(noteNameLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExplorerItem setFolderIcon(String path)
|
||||||
|
{
|
||||||
|
this.getChildren().clear();
|
||||||
|
|
||||||
|
FolderPath folderPath = (FolderPath) this.item;
|
||||||
|
this.getChildren().add(new ImageView(new Image(path)));
|
||||||
|
Label folderNameLabel = new Label(folderPath.getName());
|
||||||
|
folderNameLabel.setId("noteItemName");
|
||||||
|
this.getChildren().add(folderNameLabel);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.madeorsk.smartnotes;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
|
public class NoteColorSelector extends HBox
|
||||||
|
{
|
||||||
|
private List<NoteColor> noteColors = new ArrayList<NoteColor>();
|
||||||
|
private ObjectProperty<NoteColor> selectedColor = new SimpleObjectProperty<NoteColor>();
|
||||||
|
|
||||||
|
public NoteColorSelector()
|
||||||
|
{
|
||||||
|
this.setSpacing(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addColor(NoteColor color)
|
||||||
|
{
|
||||||
|
this.noteColors.add(color);
|
||||||
|
if (this.noteColors.size() == 1)
|
||||||
|
this.setSelectedColor(color);
|
||||||
|
else
|
||||||
|
this.updateBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedColor(NoteColor color)
|
||||||
|
{
|
||||||
|
this.selectedColor.set(color);
|
||||||
|
this.updateBox();
|
||||||
|
}
|
||||||
|
public NoteColor getSelectedColor()
|
||||||
|
{
|
||||||
|
return this.selectedColor.getValue();
|
||||||
|
}
|
||||||
|
public ObservableValue<NoteColor> selectedColorProperty()
|
||||||
|
{
|
||||||
|
return this.selectedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBox()
|
||||||
|
{
|
||||||
|
this.getChildren().clear();
|
||||||
|
for(final NoteColor color : this.noteColors)
|
||||||
|
{
|
||||||
|
Canvas canvas = new Canvas();
|
||||||
|
canvas.setCursor(Cursor.HAND);
|
||||||
|
canvas.setHeight(50); canvas.setWidth(50);
|
||||||
|
GraphicsContext gc = canvas.getGraphicsContext2D();
|
||||||
|
if (color.equals(this.getSelectedColor()))
|
||||||
|
{
|
||||||
|
gc.setFill(new Color(color.getColor().getRed(), color.getColor().getGreen(), color.getColor().getBlue(), 0.5));
|
||||||
|
gc.fillOval(0, 0, 50, 50);
|
||||||
|
}
|
||||||
|
gc.setFill(color.getColor());
|
||||||
|
gc.fillOval(3, 3, 44, 44);
|
||||||
|
|
||||||
|
canvas.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent event)
|
||||||
|
{
|
||||||
|
NoteColorSelector.this.setSelectedColor(color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.getChildren().add(canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,14 +4,23 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.madeorsk.smartnotes.notes.Note;
|
import com.madeorsk.smartnotes.notes.Note;
|
||||||
|
import com.madeorsk.smartnotes.notes.TextNote;
|
||||||
import com.madeorsk.smartnotes.paths.FolderPath;
|
import com.madeorsk.smartnotes.paths.FolderPath;
|
||||||
import com.madeorsk.smartnotes.paths.NotePath;
|
import com.madeorsk.smartnotes.paths.NotePath;
|
||||||
import com.madeorsk.smartnotes.paths.Path;
|
import com.madeorsk.smartnotes.paths.Path;
|
||||||
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.animation.FadeTransition;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
|
||||||
public class NotesExplorer extends VBox
|
public class NotesExplorer extends VBox
|
||||||
{
|
{
|
||||||
@ -19,6 +28,7 @@ public class NotesExplorer extends VBox
|
|||||||
private Map<Integer, Note> notes;
|
private Map<Integer, Note> notes;
|
||||||
|
|
||||||
private HBox titleBox;
|
private HBox titleBox;
|
||||||
|
private FolderPath currentFolder;
|
||||||
|
|
||||||
public NotesExplorer()
|
public NotesExplorer()
|
||||||
{
|
{
|
||||||
@ -26,59 +36,160 @@ public class NotesExplorer extends VBox
|
|||||||
this.notes = this.saves.loadIndex();
|
this.notes = this.saves.loadIndex();
|
||||||
this.titleBox = new HBox();
|
this.titleBox = new HBox();
|
||||||
{
|
{
|
||||||
this.titleBox.getChildren().add(new Label("SmartNotes"));
|
this.titleBox.setPadding(new Insets(10, 0, 0, 0));
|
||||||
|
ImageView logoView = new ImageView(new Image("/com/madeorsk/smartnotes/res/Logo.png"));
|
||||||
|
this.titleBox.setAlignment(Pos.CENTER);
|
||||||
|
this.titleBox.getChildren().add(logoView);
|
||||||
}
|
}
|
||||||
this.updateList();
|
this.updateList(this.genRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateList()
|
private void updateList(FolderPath folder)
|
||||||
{
|
{
|
||||||
this.getChildren().clear();
|
this.getChildren().clear();
|
||||||
this.getChildren().add(this.titleBox);
|
this.getChildren().add(this.titleBox);
|
||||||
|
|
||||||
FolderPath root = this.genRoot();
|
this.setSpacing(50);
|
||||||
for (Path p : root.getContent())
|
|
||||||
|
this.currentFolder = folder;
|
||||||
|
|
||||||
|
VBox notesList = new VBox();
|
||||||
|
notesList.setPadding(new Insets(0, 20, 0, 20));
|
||||||
|
notesList.setSpacing(15);
|
||||||
|
this.getChildren().add(notesList);
|
||||||
|
|
||||||
|
if (folder.getParent() != null)
|
||||||
|
notesList.getChildren().add(new ExplorerItem(true, folder.getParent().setName("Previous folder"), this).setFolderIcon("/com/madeorsk/smartnotes/res/ReturnIcon.png"));
|
||||||
|
|
||||||
|
for (Path p : folder.getContent())
|
||||||
{
|
{
|
||||||
if (p.isFolder())
|
if (p.isFolder())
|
||||||
{
|
notesList.getChildren().add(new ExplorerItem(true, p, this));
|
||||||
System.out.println("Folder : " + ((FolderPath) p).getName());
|
|
||||||
this.getChildren().add(new ExplorerItem(true, p));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println("Note : " + ((NotePath) p).getNoteId());
|
this.notes.get(((NotePath) p).getNoteId()).load(this.saves, ((NotePath) p).getNoteId());
|
||||||
this.getChildren().add(new ExplorerItem(false, this.notes.get(((NotePath) p).getNoteId())));
|
notesList.getChildren().add(new ExplorerItem(false, this.notes.get(((NotePath) p).getNoteId()), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final HBox addNoteBox = new HBox();
|
||||||
|
{
|
||||||
|
addNoteBox.setCursor(Cursor.HAND);
|
||||||
|
addNoteBox.setOpacity(0.4);
|
||||||
|
addNoteBox.setOnMouseEntered(new EventHandler<MouseEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
TextNote note = new TextNote();
|
||||||
|
SmartNotes.instance.setContent(note.getNoteBox(NotesExplorer.this));
|
||||||
|
int id = NotesExplorer.this.getNextId();
|
||||||
|
NotesExplorer.this.notes.put(id, note);
|
||||||
|
|
||||||
|
NotesExplorer.this.saves.saveIndex(NotesExplorer.this.notes);
|
||||||
|
note.save(NotesExplorer.this.saves, id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addNoteBox.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
addNoteBox.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/AddIcon.png")));
|
||||||
|
addNoteBox.setSpacing(10);
|
||||||
|
Label newNoteLabel = new Label("New note...");
|
||||||
|
newNoteLabel.setId("noteItemName");
|
||||||
|
addNoteBox.getChildren().add(newNoteLabel);
|
||||||
|
}
|
||||||
|
notesList.getChildren().add(addNoteBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FolderPath genRoot()
|
private FolderPath genRoot()
|
||||||
{
|
{
|
||||||
FolderPath root = new FolderPath("/");
|
FolderPath root = new FolderPath("/", null);
|
||||||
for(int key : notes.keySet())
|
for(int key : this.notes.keySet())
|
||||||
{
|
{
|
||||||
Note note = notes.get(key);
|
Note note = this.notes.get(key);
|
||||||
for(String path : note.getPaths())
|
if (note.getPaths().isEmpty())
|
||||||
|
root.addPath(new NotePath(key));
|
||||||
|
else
|
||||||
{
|
{
|
||||||
FolderPath putIn = root;
|
for(String path : note.getPaths())
|
||||||
String[] foldersString = (path.substring(1).contains("#")) ? path.substring(1).split("#") : Arrays.asList(path.substring(1)).toArray(new String[1]);
|
|
||||||
for(String folderString : foldersString)
|
|
||||||
{
|
{
|
||||||
if (putIn.containsFolder(folderString))
|
FolderPath putIn = root;
|
||||||
putIn = putIn.getFolder(folderString);
|
String[] foldersString = (path.substring(1).contains("#")) ? path.substring(1).split("#") : Arrays.asList(path.substring(1)).toArray(new String[1]);
|
||||||
else
|
for(String folderString : foldersString)
|
||||||
{
|
{
|
||||||
FolderPath newFolder = new FolderPath(folderString);
|
if (putIn.containsFolder(folderString))
|
||||||
putIn.addPath(newFolder);
|
putIn = putIn.getFolder(folderString);
|
||||||
putIn = newFolder;
|
else
|
||||||
|
{
|
||||||
|
FolderPath newFolder = new FolderPath(folderString, putIn);
|
||||||
|
putIn.addPath(newFolder);
|
||||||
|
putIn = newFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
putIn.addPath(new NotePath(key));
|
||||||
}
|
}
|
||||||
putIn.addPath(new NotePath(key));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void goToFolder(FolderPath path)
|
||||||
|
{
|
||||||
|
this.updateList(this.getUpdatedFolder(path));
|
||||||
|
}
|
||||||
|
public void updateCurrentFolder()
|
||||||
|
{
|
||||||
|
this.updateList(this.getUpdatedFolder(this.currentFolder));
|
||||||
|
}
|
||||||
|
private FolderPath getUpdatedFolder(FolderPath path)
|
||||||
|
{
|
||||||
|
if (path.getParent() == null)
|
||||||
|
return this.genRoot();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FolderPath updatedFolder = this.getUpdatedFolder(path.getParent()).getFolder(path.getName());
|
||||||
|
if (updatedFolder == null)
|
||||||
|
return this.getUpdatedFolder(path.getParent());
|
||||||
|
else
|
||||||
|
return updatedFolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestSave(Note note)
|
||||||
|
{
|
||||||
|
for (int key : this.notes.keySet())
|
||||||
|
if (this.notes.get(key).equals(note))
|
||||||
|
note.save(this.saves, key);
|
||||||
|
}
|
||||||
|
public void requestLoad(Note note)
|
||||||
|
{
|
||||||
|
for (int key : this.notes.keySet())
|
||||||
|
if (this.notes.get(key).equals(note))
|
||||||
|
note.load(this.saves, key);
|
||||||
|
}
|
||||||
|
|
||||||
private int getNextId()
|
private int getNextId()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -56,7 +56,8 @@ public class SavesManager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Note note = (Note) this.getClass().getClassLoader().loadClass(decomposed[1]).newInstance();
|
Note note = (Note) this.getClass().getClassLoader().loadClass(decomposed[1]).newInstance();
|
||||||
notes.put(Integer.parseInt(decomposed[0]), note);
|
if (note.load(this, Integer.parseInt(decomposed[0])))
|
||||||
|
notes.put(Integer.parseInt(decomposed[0]), note);
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException | ClassNotFoundException e)
|
catch (InstantiationException | IllegalAccessException | ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,8 @@ package com.madeorsk.smartnotes;
|
|||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
@ -20,19 +22,25 @@ public class SmartNotes extends Application
|
|||||||
System.out.println("SmartNotes closed.");
|
System.out.println("SmartNotes closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SmartNotes instance;
|
||||||
private Scene scene;
|
private Scene scene;
|
||||||
private VBox root;
|
private VBox root;
|
||||||
|
private NotesExplorer explorer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws Exception
|
public void start(Stage stage) throws Exception
|
||||||
{
|
{
|
||||||
|
instance = this;
|
||||||
|
|
||||||
Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/CutiveMono-Regular.ttf"), 10);
|
Font.loadFont(this.getClass().getResourceAsStream("/com/madeorsk/smartnotes/res/CutiveMono-Regular.ttf"), 10);
|
||||||
|
|
||||||
this.root = new VBox();
|
this.root = new VBox();
|
||||||
this.root.setStyle("-fx-background-color: #282828;");
|
this.root.setStyle("-fx-background-color: #282828;");
|
||||||
|
|
||||||
NotesExplorer explorer = new NotesExplorer();
|
this.explorer = new NotesExplorer();
|
||||||
this.root.getChildren().add(explorer);
|
ScrollPane scrollPane = new ScrollPane(this.explorer);
|
||||||
|
scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true);
|
||||||
|
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");
|
||||||
@ -42,7 +50,7 @@ public class SmartNotes extends Application
|
|||||||
@Override
|
@Override
|
||||||
public void handle(WindowEvent e)
|
public void handle(WindowEvent e)
|
||||||
{
|
{
|
||||||
explorer.close();
|
SmartNotes.this.explorer.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,4 +58,24 @@ public class SmartNotes extends Application
|
|||||||
stage.setTitle("SmartNotes " + version);
|
stage.setTitle("SmartNotes " + version);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContent(Region region)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
this.root.getChildren().add(scrollPane);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
region.prefHeightProperty().bind(this.root.heightProperty());
|
||||||
|
this.root.getChildren().add(region);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
package com.madeorsk.smartnotes.notes;
|
package com.madeorsk.smartnotes.notes;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.madeorsk.smartnotes.NotesExplorer;
|
||||||
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public abstract class Note
|
public abstract class Note implements SavableNote
|
||||||
{
|
{
|
||||||
public enum NoteColor
|
public enum NoteColor
|
||||||
{
|
{
|
||||||
WHITE(255, 255, 255),
|
WHITE(255, 255, 255),
|
||||||
BLUE(0, 0, 0),
|
BLUE(109, 140, 169),
|
||||||
YELLOW(0, 0, 0),
|
YELLOW(212, 208, 97),
|
||||||
RED(0, 0, 0),
|
RED(214, 102, 90),
|
||||||
GREEN(0, 0, 0);
|
GREEN(100, 181, 106);
|
||||||
|
|
||||||
private double r;
|
private double r;
|
||||||
private double g;
|
private double g;
|
||||||
@ -26,13 +29,13 @@ public abstract class Note
|
|||||||
}
|
}
|
||||||
public Color getColor()
|
public Color getColor()
|
||||||
{
|
{
|
||||||
return new Color(this.r, this.g, this.b, 1);
|
return new Color(this.r/255, this.g/255, this.b/255, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private NoteColor color = NoteColor.WHITE;
|
private NoteColor color = NoteColor.WHITE;
|
||||||
protected List<String> paths;
|
protected List<String> paths = new ArrayList<String>();
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
@ -56,5 +59,5 @@ public abstract class Note
|
|||||||
return this.paths;
|
return this.paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract VBox getNoteBox();
|
public abstract VBox getNoteBox(NotesExplorer explorer);
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,5 @@ import com.madeorsk.smartnotes.SavesManager;
|
|||||||
public interface SavableNote
|
public interface SavableNote
|
||||||
{
|
{
|
||||||
public void save(SavesManager saves, int id);
|
public void save(SavesManager saves, int id);
|
||||||
public void load(SavesManager saves, int id);
|
public boolean load(SavesManager saves, int id);
|
||||||
}
|
}
|
||||||
|
@ -2,32 +2,74 @@ package com.madeorsk.smartnotes.notes;
|
|||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import com.madeorsk.smartnotes.NoteColorSelector;
|
||||||
|
import com.madeorsk.smartnotes.NotesExplorer;
|
||||||
import com.madeorsk.smartnotes.SavesManager;
|
import com.madeorsk.smartnotes.SavesManager;
|
||||||
|
import com.madeorsk.smartnotes.SmartNotes;
|
||||||
|
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
public class TextNote extends Note implements SavableNote
|
public class TextNote extends Note
|
||||||
{
|
{
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
public TextNote()
|
public TextNote()
|
||||||
{
|
{
|
||||||
this.setName("Text_" + Calendar.YEAR + "." + Calendar.MONTH + "." + Calendar.DAY_OF_MONTH + "-" + Calendar.HOUR_OF_DAY + ":" + Calendar.MINUTE);
|
this.setName("Text_" + Calendar.getInstance().get(Calendar.YEAR) + "." + Calendar.getInstance().get(Calendar.MONTH) + "." + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + Calendar.getInstance().get(Calendar.HOUR_OF_DAY) + ":" + Calendar.getInstance().get(Calendar.MINUTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VBox getNoteBox()
|
public VBox getNoteBox(final NotesExplorer explorer)
|
||||||
{
|
{
|
||||||
VBox box = new VBox();
|
VBox box = new VBox();
|
||||||
box.setFillWidth(true);
|
box.setFillWidth(true);
|
||||||
|
|
||||||
HBox titleBox = new HBox();
|
HBox titleBox = new HBox();
|
||||||
{
|
{
|
||||||
// TODO Title box
|
titleBox.setPadding(new Insets(10, 0, 0, 0));
|
||||||
|
|
||||||
|
VBox returnButton = new VBox();
|
||||||
|
returnButton.setId("imageButton");
|
||||||
|
returnButton.setCursor(Cursor.HAND);
|
||||||
|
returnButton.getChildren().add(new ImageView(new Image("/com/madeorsk/smartnotes/res/ReturnIcon.png")));
|
||||||
|
returnButton.setOnMouseClicked(new EventHandler<MouseEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void handle(MouseEvent event)
|
||||||
|
{
|
||||||
|
explorer.updateCurrentFolder();
|
||||||
|
SmartNotes.instance.setContent(explorer, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
titleBox.getChildren().add(returnButton);
|
||||||
|
|
||||||
|
//TODO Type selector
|
||||||
|
|
||||||
|
NoteColorSelector colorSelector = new NoteColorSelector();
|
||||||
|
colorSelector.addColor(NoteColor.WHITE); colorSelector.addColor(NoteColor.BLUE); colorSelector.addColor(NoteColor.YELLOW); colorSelector.addColor(NoteColor.RED); colorSelector.addColor(NoteColor.GREEN);
|
||||||
|
colorSelector.setSelectedColor(this.getNoteColor());
|
||||||
|
colorSelector.selectedColorProperty().addListener(new ChangeListener<NoteColor>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends NoteColor> ov, NoteColor oldValue, NoteColor newValue)
|
||||||
|
{
|
||||||
|
TextNote.this.setNoteColor(newValue);
|
||||||
|
explorer.requestSave(TextNote.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
titleBox.getChildren().add(colorSelector);
|
||||||
}
|
}
|
||||||
box.getChildren().add(titleBox);
|
box.getChildren().add(titleBox);
|
||||||
|
|
||||||
@ -36,6 +78,15 @@ public class TextNote extends Note implements SavableNote
|
|||||||
nameField.setAlignment(Pos.CENTER);
|
nameField.setAlignment(Pos.CENTER);
|
||||||
nameField.setId("nameField");
|
nameField.setId("nameField");
|
||||||
nameField.setText(this.getName());
|
nameField.setText(this.getName());
|
||||||
|
nameField.textProperty().addListener(new ChangeListener<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
||||||
|
{
|
||||||
|
TextNote.this.setName(newValue);
|
||||||
|
explorer.requestSave(TextNote.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(nameField);
|
box.getChildren().add(nameField);
|
||||||
|
|
||||||
@ -45,6 +96,15 @@ public class TextNote extends Note implements SavableNote
|
|||||||
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.getContent());
|
textArea.setText(this.getContent());
|
||||||
|
textArea.textProperty().addListener(new ChangeListener<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue)
|
||||||
|
{
|
||||||
|
TextNote.this.setContent(newValue);
|
||||||
|
explorer.requestSave(TextNote.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
box.getChildren().add(textArea);
|
box.getChildren().add(textArea);
|
||||||
|
|
||||||
@ -63,6 +123,7 @@ public class TextNote extends Note implements SavableNote
|
|||||||
|
|
||||||
private void updatePaths()
|
private void updatePaths()
|
||||||
{
|
{
|
||||||
|
this.paths.clear();
|
||||||
String text = this.getContent();
|
String text = this.getContent();
|
||||||
if (text.contains("\n"))
|
if (text.contains("\n"))
|
||||||
{
|
{
|
||||||
@ -83,11 +144,26 @@ public class TextNote extends Note implements SavableNote
|
|||||||
@Override
|
@Override
|
||||||
public void save(SavesManager saves, int id)
|
public void save(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
saves.writeFile(saves.getSaveFile(id), this.getContent());
|
saves.writeFile(saves.getSaveFile(id), this.getName() + "\n" + this.getNoteColor().name() + "\n" + this.getContent());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void load(SavesManager saves, int id)
|
public boolean load(SavesManager saves, int id)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
if (saves.getSaveFile(id).exists())
|
||||||
|
{
|
||||||
|
String saved = saves.readFile(saves.getSaveFile(id));
|
||||||
|
int separatorIndex = saved.indexOf('\n');
|
||||||
|
this.setName(saved.substring(0, separatorIndex));
|
||||||
|
saved = saved.substring(separatorIndex + 1);
|
||||||
|
separatorIndex = saved.indexOf('\n');
|
||||||
|
this.setNoteColor(NoteColor.valueOf(saved.substring(0, separatorIndex)));
|
||||||
|
if (separatorIndex < saved.length() - 1)
|
||||||
|
this.setContent(saved.substring(separatorIndex + 1));
|
||||||
|
else
|
||||||
|
this.setContent("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,13 @@ import java.util.List;
|
|||||||
public class FolderPath implements Path
|
public class FolderPath implements Path
|
||||||
{
|
{
|
||||||
private String name;
|
private String name;
|
||||||
|
private FolderPath parent;
|
||||||
private List<Path> content = new ArrayList<Path>();
|
private List<Path> content = new ArrayList<Path>();
|
||||||
|
|
||||||
public FolderPath(String name)
|
public FolderPath(String name, FolderPath parent)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPath(Path path)
|
public void addPath(Path path)
|
||||||
@ -35,10 +37,19 @@ public class FolderPath implements Path
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FolderPath setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
public FolderPath getParent()
|
||||||
|
{
|
||||||
|
return this.parent;
|
||||||
|
}
|
||||||
public List<Path> getContent()
|
public List<Path> getContent()
|
||||||
{
|
{
|
||||||
return this.content;
|
return this.content;
|
||||||
|
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/AddIcon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/DeleteIcon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/FolderIcon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ImageNoteChoice.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ImageNoteIcon-RED.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ListNoteChoice.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ListNoteIcon-BLUE.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ListNoteIcon-RED.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/Logo.png
Normal file
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 19 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/ReturnIcon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/SoundNoteChoice.png
Normal file
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/SoundNoteIcon-RED.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/TextNoteChoice.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/TextNoteIcon-BLUE.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/TextNoteIcon-RED.png
Normal file
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/VideoNoteChoice.png
Normal file
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
BIN
SmartNotes/src/com/madeorsk/smartnotes/res/VideoNoteIcon-RED.png
Normal file
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 17 KiB |
@ -17,16 +17,20 @@
|
|||||||
-fx-border-radius: 0;
|
-fx-border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nameField, .scroll-pane, .scroll-pane .viewport, #textArea, #textArea .content
|
#nameField, .scroll-pane, .scroll-pane .viewport, #textArea, #textArea .content, #imageButton
|
||||||
{
|
{
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
#nameField, #textArea
|
#nameField, #textArea, #noteItemName
|
||||||
{
|
{
|
||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-font-family: 'Cutive Mono';
|
-fx-font-family: 'Cutive Mono';
|
||||||
-fx-font-size: 32px;
|
-fx-font-size: 32px;
|
||||||
}
|
}
|
||||||
|
#noteItemName
|
||||||
|
{
|
||||||
|
-fx-font-size: 24px;
|
||||||
|
}
|
||||||
#textArea
|
#textArea
|
||||||
{
|
{
|
||||||
-fx-font-size: 20px;
|
-fx-font-size: 20px;
|
||||||
|