mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
Better unsaved warning message
This commit is contained in:
+3
@@ -1,5 +1,6 @@
|
||||
package org.diylc.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,4 +36,6 @@ public interface IView {
|
||||
int showConfirmDialog(String message, String title, int optionType, int messageType);
|
||||
|
||||
boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties);
|
||||
|
||||
File promptFileSave();
|
||||
}
|
||||
|
||||
+21
-8
@@ -8,6 +8,7 @@ import java.awt.Rectangle;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -246,12 +247,22 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public boolean allowFileAction() {
|
||||
if (projectFileManager.isModified()) {
|
||||
int response = view
|
||||
.showConfirmDialog(
|
||||
"There are unsaved changes. Are you sure you want to abandon these changes?",
|
||||
"Warning", IView.YES_NO_OPTION,
|
||||
IView.WARNING_MESSAGE);
|
||||
return response == IView.YES_OPTION;
|
||||
int response = view.showConfirmDialog(
|
||||
"There are unsaved changes. Would you like to save them?",
|
||||
"Warning", IView.YES_NO_CANCEL_OPTION,
|
||||
IView.WARNING_MESSAGE);
|
||||
if (response == IView.YES_OPTION) {
|
||||
if (this.getCurrentFileName() == null) {
|
||||
File file = view.promptFileSave();
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
saveProjectToFile(file.getAbsolutePath(), false);
|
||||
} else {
|
||||
saveProjectToFile(this.getCurrentFileName(), false);
|
||||
}
|
||||
}
|
||||
return response != IView.CANCEL_OPTION;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -912,7 +923,8 @@ public class Presenter implements IPlugInPort {
|
||||
int dx = (scaledPoint.x - previousDragPoint.x);
|
||||
int dy = (scaledPoint.y - previousDragPoint.y);
|
||||
|
||||
Point actualD = moveSelectedComponents(this.controlPointMap, dx, dy, isSnapToGrid());
|
||||
Point actualD = moveSelectedComponents(this.controlPointMap, dx,
|
||||
dy, isSnapToGrid());
|
||||
if (actualD == null)
|
||||
return true;
|
||||
|
||||
@@ -936,7 +948,8 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
private Point moveSelectedComponents(
|
||||
Map<IDIYComponent<?>, Set<Integer>> controlPointMap, int dx, int dy, boolean snapToGrid) {
|
||||
Map<IDIYComponent<?>, Set<Integer>> controlPointMap, int dx,
|
||||
int dy, boolean snapToGrid) {
|
||||
// After we make the transfer and snap to grid, calculate actual dx
|
||||
// and dy. We'll use them to translate the previous drag point.
|
||||
int actualDx = 0;
|
||||
|
||||
Reference in New Issue
Block a user