From 184ecb821bcfb46eb86f92747e892544969cb1d1 Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Sat, 7 Jan 2017 22:47:34 +0100 Subject: [PATCH] Fixed duplicate naming bug, rename property in ProjectReference --- .../dialog/DuplicateProjectDialog.java | 11 -------- .../dialog/ProjectManagerDialog.java | 4 +-- .../playpad/project/ref/ProjectReference.java | 25 ++++++++----------- .../ref/ProjectReferenceSerializer.java | 2 +- .../project/ref/ProjectReferences.java | 2 +- 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java index efc0f104..facbfdac 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java @@ -29,17 +29,6 @@ public class DuplicateProjectDialog extends TextInputDialog { Stage dialog = (Stage) getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); - setResultConverter(button -> - { - String param = getEditor().getText(); - if (!param.endsWith(PlayPadMain.projectType.substring(1))) { - param += PlayPadMain.projectType.substring(1); - } - - ButtonData data = button == null ? null : button.getButtonData(); - return data == ButtonData.OK_DONE ? param : null; - }); - Button button = (Button) getDialogPane().lookupButton(ButtonType.OK); getEditor().textProperty().addListener((a, b, c) -> { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java index 7d45a9b2..b12131ab 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java @@ -19,7 +19,6 @@ import de.tobias.playpad.project.ref.ProjectReferences; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.cell.ProjectCell; import de.tobias.utils.ui.NotificationHandler; -import de.tobias.utils.ui.ViewController; import de.tobias.utils.ui.scene.NotificationPane; import de.tobias.utils.util.Localization; import de.tobias.utils.util.TimeUtils; @@ -115,7 +114,7 @@ public class ProjectManagerDialog extends NVC implements NotificationHandler { try { ProfileReference profileRef = ref.getProfileReference(); profileLabel.setText(profileRef.getName()); - dateLabel.setText(TimeUtils.getDfmLong().format(ref.getLastMofied())); + dateLabel.setText(TimeUtils.getDfmLong().format(ref.getLastModified())); } catch (Exception e) { profileLabel.setText("-"); dateLabel.setText("-"); @@ -235,6 +234,7 @@ public class ProjectManagerDialog extends NVC implements NotificationHandler { if (getSelecteItem() != null) { DuplicateProjectDialog dialog = new DuplicateProjectDialog(this, getSelectedProject()); + dialog.getName().ifPresent(ref -> { projectList.getItems().add(ref); diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java index 1d0a3877..ad4ebafb 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java @@ -19,21 +19,18 @@ import javafx.beans.property.StringProperty; public class ProjectReference implements Displayable { - /** - * Name + XML - */ private UUID uuid; private String name; private ProfileReference profileReference; private Set<Module> requestedModules; - private long lastMofied; + private long lastModified; public ProjectReference(UUID uuid, String name, ProfileReference profileReference) { this.uuid = uuid; this.name = name; - this.lastMofied = System.currentTimeMillis(); + this.lastModified = System.currentTimeMillis(); this.profileReference = profileReference; requestedModules = new HashSet<>(); @@ -43,27 +40,27 @@ public class ProjectReference implements Displayable { public ProjectReference(UUID uuid, String name, ProfileReference profileReference, Set<Module> modules) { this.uuid = uuid; this.name = name; - this.lastMofied = System.currentTimeMillis(); + this.lastModified = System.currentTimeMillis(); this.profileReference = profileReference; requestedModules = modules; updateDisplayProperty(); } - public ProjectReference(UUID uuid, String name, long lastMofied, ProfileReference profileReference) { + public ProjectReference(UUID uuid, String name, long lastModified, ProfileReference profileReference) { this.uuid = uuid; this.name = name; - this.lastMofied = lastMofied; + this.lastModified = lastModified; this.profileReference = profileReference; requestedModules = new HashSet<>(); updateDisplayProperty(); } - public ProjectReference(UUID uuid, String name, long lastMofied, ProfileReference profileReference, Set<Module> requestedModules) { + public ProjectReference(UUID uuid, String name, long lastModified, ProfileReference profileReference, Set<Module> requestedModules) { this.uuid = uuid; this.name = name; - this.lastMofied = lastMofied; + this.lastModified = lastModified; this.profileReference = profileReference; this.requestedModules = requestedModules; @@ -78,12 +75,12 @@ public class ProjectReference implements Displayable { return name; } - public void setLastMofied(long lastMofied) { - this.lastMofied = lastMofied; + public void setLastModified(long lastModified) { + this.lastModified = lastModified; } - public long getLastMofied() { - return lastMofied; + public long getLastModified() { + return lastModified; } public void setName(String name) { diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java index 448e3693..8fe853f3 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java @@ -41,7 +41,7 @@ public class ProjectReferenceSerializer implements XMLDeserializer<ProjectRefere Path projectPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, ref.getFileName()); if (Files.exists(projectPath)) { try { - ref.setLastMofied(Files.getLastModifiedTime(projectPath).toMillis()); + ref.setLastModified(Files.getLastModifiedTime(projectPath).toMillis()); } catch (IOException e) { e.printStackTrace(); } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferences.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferences.java index feabcc44..785c9ad6 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferences.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferences.java @@ -115,7 +115,7 @@ public final class ProjectReferences { List<ProjectReference> items = new ArrayList<>(); projects.forEach(item -> items.add(item)); - items.sort((o1, o2) -> Long.compare(o2.getLastMofied(), o1.getLastMofied())); + items.sort((o1, o2) -> Long.compare(o2.getLastModified(), o1.getLastModified())); return items; } } -- GitLab