From f27df3c466d293bfb69eaeba0519a055be86efb5 Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Sun, 21 Nov 2010 18:59:44 +0000 Subject: [PATCH] Allow different components --- .../motorsim/visual/MultiObjectEditor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gui/com/billkuker/rocketry/motorsim/visual/MultiObjectEditor.java b/gui/com/billkuker/rocketry/motorsim/visual/MultiObjectEditor.java index 133c0c4..da90603 100644 --- a/gui/com/billkuker/rocketry/motorsim/visual/MultiObjectEditor.java +++ b/gui/com/billkuker/rocketry/motorsim/visual/MultiObjectEditor.java @@ -43,6 +43,7 @@ public abstract class MultiObjectEditor extend private final Map fileToEditor = new HashMap(); private final Map editorToFile = new HashMap(); + private final Set dirty = new HashSet(); public MultiObjectEditor(final Frame frame, final String noun){ @@ -82,13 +83,16 @@ public abstract class MultiObjectEditor extend } @SuppressWarnings("unchecked") - @Override - public EDITOR getSelectedComponent(){ - return (EDITOR)super.getSelectedComponent(); + public EDITOR getSelectedEditor(){ + try { + return (EDITOR)super.getSelectedComponent(); + } catch ( ClassCastException e ){ + return null; + } } private void close(){ - EDITOR e = getSelectedComponent(); + EDITOR e = getSelectedEditor(); OBJECT o = editorToObject.get(e); File f = editorToFile.get(e); @@ -109,7 +113,7 @@ public abstract class MultiObjectEditor extend } private void saveDialog(){ - EDITOR e = getSelectedComponent(); + EDITOR e = getSelectedEditor(); if ( !editorToFile.containsKey(e) ){ log.debug("Editor has no file, saving as..."); saveAsDialog(); @@ -125,7 +129,7 @@ public abstract class MultiObjectEditor extend } } private void saveAsDialog(){ - EDITOR e = getSelectedComponent(); + EDITOR e = getSelectedEditor(); final FileDialog fd = new FileDialog(frame, "Save" + noun + " As", FileDialog.SAVE); fd.setVisible(true); if (fd.getFile() != null ) { -- 2.30.2