cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1142621 - in /cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: Application.java dialog/AboutDialog.java dialog/ErrorDebugDialog.java util/CayenneDialog.java util/ModelerUtil.java util/ProgressDialog.java
Date Mon, 04 Jul 2011 11:05:28 GMT
Author: dkazimirchyk
Date: Mon Jul  4 11:05:27 2011
New Revision: 1142621

URL: http://svn.apache.org/viewvc?rev=1142621&view=rev
Log:
CAY-1461 CayenneModeler: remove ScopeMVC dependencies

removed scopemvc dependencies from the rest of dialogs

Modified:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProgressDialog.java

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
Mon Jul  4 11:05:27 2011
@@ -19,17 +19,12 @@
 
 package org.apache.cayenne.modeler;
 
-import java.awt.Dialog;
-import java.awt.Frame;
-import java.awt.Window;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
 
-import javax.swing.JFrame;
-import javax.swing.JRootPane;
 import javax.swing.SwingUtilities;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
@@ -40,7 +35,6 @@ import org.apache.cayenne.modeler.dialog
 import org.apache.cayenne.modeler.dialog.pref.ClasspathPreferences;
 import org.apache.cayenne.modeler.undo.CayenneUndoManager;
 import org.apache.cayenne.modeler.util.AdapterMapping;
-import org.apache.cayenne.modeler.util.CayenneDialog;
 import org.apache.cayenne.modeler.util.WidgetFactory;
 import org.apache.cayenne.pref.CayennePreference;
 import org.apache.cayenne.pref.CayenneProjectPreferences;
@@ -49,11 +43,6 @@ import org.apache.cayenne.swing.BindingF
 import org.apache.cayenne.util.IDUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Transformer;
-import org.scopemvc.controller.basic.ViewContext;
-import org.scopemvc.controller.swing.SwingContext;
-import org.scopemvc.core.View;
-import org.scopemvc.util.UIStrings;
-import org.scopemvc.view.swing.SwingView;
 
 /**
  * A main modeler application class that provides a number of services to the Modeler
@@ -188,20 +177,10 @@ public class Application {
         this.bindingFactory = new BindingFactory();
         this.adapterMapping = new AdapterMapping();
 
-        // ...Scope
-
-        // TODO: this will go away if switch away from Scope
-        // force Scope to use CayenneModeler properties
-        UIStrings.setPropertiesName(DEFAULT_MESSAGE_BUNDLE);
-        ViewContext.clearThreadContext();
-
         this.undoManager = new CayenneUndoManager(this);
 
         this.frameController = new CayenneModelerController(this);
 
-        // update Scope to work nicely with main frame
-        ViewContext.setGlobalContext(new ModelerContext(frameController.getFrame()));
-
         // open up
         frameController.startupAction();
 
@@ -311,78 +290,4 @@ public class Application {
     protected void initPreferences() {
         this.cayenneProjectPreferences = new CayenneProjectPreferences();
     }
-
-    final class ModelerContext extends SwingContext {
-
-        JFrame frame;
-
-        public ModelerContext(JFrame frame) {
-            this.frame = frame;
-        }
-
-        @Override
-        protected void showViewInPrimaryWindow(SwingView view) {
-        }
-
-        /**
-         * Creates closeable dialogs.
-         */
-        @Override
-        protected void showViewInDialog(SwingView inView) {
-            // NOTE:
-            // copied from superclass, except that JDialog is substituted for
-            // CayenneDialog
-            // Keep in mind when upgrading Scope to the newer versions.
-
-            // Make a JDialog to contain the view.
-            Window parentWindow = getDefaultParentWindow();
-
-            final CayenneDialog dialog;
-            if (parentWindow instanceof Dialog) {
-                dialog = new CayenneDialog((Dialog) parentWindow);
-            }
-            else {
-                dialog = new CayenneDialog((Frame) parentWindow);
-            }
-
-            // Set title, modality, resizability
-            if (inView.getTitle() != null) {
-                dialog.setTitle(inView.getTitle());
-            }
-            if (inView.getDisplayMode() == SwingView.MODAL_DIALOG) {
-                dialog.setModal(true);
-            }
-            else {
-                dialog.setModal(false);
-            }
-            dialog.setResizable(inView.isResizable());
-
-            setupWindow(dialog.getRootPane(), inView, true);
-            dialog.toFront();
-        }
-
-        /**
-         * Overrides super implementation to allow using Scope together with normal Swing
-         * code that CayenneModeler already has.
-         */
-        @Override
-        public JRootPane findRootPaneFor(View view) {
-            JRootPane pane = super.findRootPaneFor(view);
-
-            if (pane != null) {
-                return pane;
-            }
-
-            if (((SwingView) view).getDisplayMode() != SwingView.PRIMARY_WINDOW) {
-                return pane;
-            }
-
-            return frame.getRootPane();
-        }
-
-        @Override
-        protected Window getDefaultParentWindow() {
-            return frame;
-        }
-    }
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
Mon Jul  4 11:05:27 2011
@@ -40,7 +40,6 @@ import javax.swing.WindowConstants;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.util.LocalizedStringsHandler;
 import org.apache.cayenne.util.Util;
-import org.scopemvc.util.UIStrings;
 
 /** 
  * Displays the Cayenne license and build information.
@@ -75,7 +74,7 @@ public class AboutDialog extends JFrame 
             StringBuffer buffer = new StringBuffer();
             buffer.append("<html>");
             buffer.append("<font size='-1' face='Arial,Helvetica'>");
-            buffer.append(UIStrings.get("cayenne.modeler.about.info"));
+            buffer.append(ModelerUtil.getProperty("cayenne.modeler.about.info"));
             buffer.append("</font>");
 
             buffer.append("<font size='-2' face='Arial,Helvetica'>");

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
Mon Jul  4 11:05:27 2011
@@ -42,12 +42,12 @@ import javax.swing.ScrollPaneConstants;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.CayenneModelerFrame;
 import org.apache.cayenne.modeler.util.CayenneDialog;
+import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.PanelFactory;
 import org.apache.cayenne.util.LocalizedStringsHandler;
 import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.scopemvc.util.UIStrings;
 
 /**
  * Displays CayenneModeler exceptions and warning messages.
@@ -201,7 +201,7 @@ public class ErrorDebugDialog extends Ca
     }
 
     protected String infoHTML() {
-        String bugreportURL = UIStrings.get("cayenne.bugreport.url");
+        String bugreportURL = ModelerUtil.getProperty("cayenne.bugreport.url");
         return "<b><font face='Arial,Helvetica' size='+1' color='red'>"
             + getTitle()
             + "</font></b><br>"

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneDialog.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneDialog.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneDialog.java
Mon Jul  4 11:05:27 2011
@@ -37,7 +37,6 @@ import javax.swing.event.HyperlinkListen
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.CayenneModelerFrame;
 import org.apache.cayenne.modeler.ProjectController;
-import org.scopemvc.view.awt.AWTUtilities;
 
 /**
  * Superclass of CayenneModeler dialogs. Adds support for popping hyperlinks 
@@ -138,7 +137,7 @@ public class CayenneDialog extends JDial
      * Centers this dialog relative to the parent Window 
      */
     public void centerWindow() {
-        AWTUtilities.centreOnWindow(getParentEditor(), this);
+        ModelerUtil.centerWindow(getParentEditor(), this);
     }
 
     public CayenneModelerFrame getParentEditor() {

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerUtil.java
Mon Jul  4 11:05:27 2011
@@ -19,6 +19,9 @@
 
 package org.apache.cayenne.modeler.util;
 
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Window;
 import java.io.Serializable;
 import java.math.BigInteger;
 import java.net.URL;
@@ -28,6 +31,7 @@ import java.util.Calendar;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.ResourceBundle;
 import java.util.Set;
 
 import javax.swing.Action;
@@ -175,4 +179,30 @@ public final class ModelerUtil {
             }
         }
     }
+    
+    /**
+     * Retrieves strings from .properties file
+     */
+    public static String getProperty(String key) {
+        ResourceBundle properties = ResourceBundle.getBundle(Application.DEFAULT_MESSAGE_BUNDLE);
+        return properties == null ? "" : properties.getString(key);
+    }
+    
+    /**
+     * Center a window on a parent window
+     */
+    public static void centerWindow(Window parent, Window child) {
+        Dimension parentSize = parent.getSize();
+        Dimension childSize = child.getSize();
+        
+        Point parentLocation = new Point(0, 0);
+        if (parent.isShowing()) {
+            parentLocation = parent.getLocationOnScreen();
+        }
+
+        int x = parentLocation.x + parentSize.width / 2 - childSize.width / 2;
+        int y = parentLocation.y + parentSize.height / 2 - childSize.height / 2;
+
+        child.setLocation(x, y);
+    }
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProgressDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProgressDialog.java?rev=1142621&r1=1142620&r2=1142621&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProgressDialog.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProgressDialog.java
Mon Jul  4 11:05:27 2011
@@ -31,8 +31,6 @@ import javax.swing.JPanel;
 import javax.swing.JProgressBar;
 import javax.swing.SwingConstants;
 
-import org.scopemvc.view.awt.AWTUtilities;
-
 import com.jgoodies.forms.builder.PanelBuilder;
 import com.jgoodies.forms.layout.CellConstraints;
 import com.jgoodies.forms.layout.FormLayout;
@@ -80,7 +78,7 @@ public class ProgressDialog extends JDia
 
         setResizable(false);
         pack();
-        AWTUtilities.centreOnWindow(getOwner(), this);
+        ModelerUtil.centerWindow(getOwner(), this);
     }
 
     public JButton getCancelButton() {



Mime
View raw message