refactor some swing references

This commit is contained in:
bancika
2011-01-23 19:58:47 +00:00
parent 72ae295a09
commit 726f17aa7f
5 changed files with 40 additions and 17 deletions
@@ -1,4 +1,4 @@
package org.diylc.gui;
package org.diylc.core;
import javax.swing.Action;
import javax.swing.Icon;
@@ -14,6 +14,20 @@ import org.diylc.common.IPlugInPort;
*/
public interface IView {
public static final int ERROR_MESSAGE = 0;
public static final int INFORMATION_MESSAGE = 1;
public static final int WARNING_MESSAGE = 2;
public static final int QUESTION_MESSAGE = 3;
public static final int PLAIN_MESSAGE = -1;
public static final int DEFAULT_OPTION = -1;
public static final int YES_NO_OPTION = 0;
public static final int YES_NO_CANCEL_OPTION = 1;
public static final int OK_CANCEL_OPTION = 2;
public static final int YES_OPTION = 0;
public static final int NO_OPTION = 1;
public static final int CANCEL_OPTION = 2;
public static final int OK_OPTION = 0;
/**
* Adds a component to the view.
*
@@ -29,6 +29,7 @@ import org.diylc.common.BadPositionException;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.core.IView;
import org.diylc.images.IconLoader;
import org.diylc.plugins.canvas.CanvasPlugin;
import org.diylc.plugins.clipboard.EditMenuPlugin;
@@ -21,8 +21,8 @@ import javax.swing.JPanel;
import org.diylc.common.BadPositionException;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.core.IView;
import org.diylc.core.Project;
import org.diylc.gui.IView;
import org.diylc.presenter.Presenter;
import com.diyfever.gui.IFileChooserAccessory;
@@ -22,7 +22,6 @@ import java.util.Set;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import org.apache.log4j.Logger;
import org.diylc.common.BadPositionException;
@@ -35,9 +34,9 @@ import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IView;
import org.diylc.core.Project;
import org.diylc.core.measures.SizeUnit;
import org.diylc.gui.IView;
import org.diylc.utils.Constants;
import com.diyfever.gui.miscutils.ConfigurationManager;
@@ -203,7 +202,7 @@ public class Presenter implements IPlugInPort {
} catch (Exception e) {
LOG.error("Could not create new file", e);
view.showMessage("Could not create a new file. Check the log for details.", "Error",
JOptionPane.ERROR_MESSAGE);
IView.ERROR_MESSAGE);
}
}
@@ -217,7 +216,7 @@ public class Presenter implements IPlugInPort {
} catch (Exception ex) {
LOG.error("Could not load file", ex);
view.showMessage("Could not open file " + fileName + ". Check the log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
"Error", IView.ERROR_MESSAGE);
}
}
@@ -226,8 +225,8 @@ public class Presenter implements IPlugInPort {
if (projectFileManager.isModified()) {
int response = view.showConfirmDialog(
"There are unsaved changes. Are you sure you want to abandon these changes?",
"Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
return response == JOptionPane.YES_OPTION;
"Warning", IView.YES_NO_OPTION, IView.WARNING_MESSAGE);
return response == IView.YES_OPTION;
}
return true;
}
@@ -240,7 +239,7 @@ public class Presenter implements IPlugInPort {
} catch (Exception ex) {
LOG.error("Could not save file", ex);
view.showMessage("Could not save file " + fileName + ". Check the log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
"Error", IView.ERROR_MESSAGE);
}
}
@@ -390,7 +389,7 @@ public class Presenter implements IPlugInPort {
instantiationManager.instatiatePointByPoint(scaledPoint, currentProject);
} catch (Exception e) {
view.showMessage("Could not create component. Check log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
"Error", IView.ERROR_MESSAGE);
LOG.error("Could not create component", e);
}
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentTypeSlot,
@@ -1040,7 +1039,7 @@ public class Presenter implements IPlugInPort {
LOG.error("Could not apply selection properties", e);
view.showMessage(
"Could not apply changes to the selection. Check the log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
"Error", IView.ERROR_MESSAGE);
} finally {
// Notify the listeners.
if (!oldProject.equals(currentProject)) {
@@ -1081,7 +1080,7 @@ public class Presenter implements IPlugInPort {
} catch (Exception e) {
LOG.error("Could not apply project properties", e);
view.showMessage("Could not apply changes to the project. Check the log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
"Error", IView.ERROR_MESSAGE);
} finally {
// Notify the listeners.
if (!oldProject.equals(currentProject)) {
@@ -1112,7 +1111,7 @@ public class Presenter implements IPlugInPort {
} catch (Exception e) {
LOG.error("Could not set component type slot", e);
view.showMessage("Could not set component type slot. Check log for details.", "Error",
JOptionPane.ERROR_MESSAGE);
IView.ERROR_MESSAGE);
}
}