cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r405109 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne: modeler/ modeler/action/ modeler/util/ swing/control/
Date Mon, 08 May 2006 18:03:37 GMT
Author: aadamchik
Date: Mon May  8 11:03:36 2006
New Revision: 405109

URL: http://svn.apache.org/viewcvs?rev=405109&view=rev
Log:
fixing another long standing problem - recent file menu not refreshing when a project is opened

Added:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/swing/control/FileMenuItem.java
Removed:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenuItem.java
Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/CayenneModelerController.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenu.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/CayenneModelerController.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/CayenneModelerController.java?rev=405109&r1=405108&r2=405109&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/CayenneModelerController.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/CayenneModelerController.java
Mon May  8 11:03:36 2006
@@ -167,10 +167,6 @@
      */
     public void projectClosedAction() {
         // --- update view
-        RecentFileMenu recentFileMenu = frame.getRecentFileMenu();
-        recentFileMenu.rebuildFromPreferences();
-        recentFileMenu.setEnabled(recentFileMenu.getMenuComponentCount() > 0);
-
         frame.setView(null);
 
         // repaint is needed, since sometimes there is a
@@ -214,6 +210,9 @@
         // update preferences
         if (!project.isLocationUndefined()) {
             getLastDirectory().setDirectory(project.getProjectDirectory());
+            RecentFileMenu recentFileMenu = frame.getRecentFileMenu();
+            recentFileMenu.rebuildFromPreferences();
+            recentFileMenu.setEnabled(recentFileMenu.getMenuComponentCount() > 0);
         }
 
         // --- check for load errors

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java?rev=405109&r1=405108&r2=405109&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
Mon May  8 11:03:36 2006
@@ -67,10 +67,10 @@
 import org.objectstyle.cayenne.conf.Configuration;
 import org.objectstyle.cayenne.modeler.Application;
 import org.objectstyle.cayenne.modeler.dialog.ErrorDebugDialog;
-import org.objectstyle.cayenne.modeler.util.RecentFileMenuItem;
 import org.objectstyle.cayenne.project.ApplicationProject;
 import org.objectstyle.cayenne.project.Project;
 import org.objectstyle.cayenne.project.ProjectException;
+import org.objectstyle.cayenne.swing.control.FileMenuItem;
 
 /**
  * @author Andrei Adamchik
@@ -111,8 +111,8 @@
         }
 
         File f = null;
-        if (e.getSource() instanceof RecentFileMenuItem) {
-            RecentFileMenuItem menu = (RecentFileMenuItem) e.getSource();
+        if (e.getSource() instanceof FileMenuItem) {
+            FileMenuItem menu = (FileMenuItem) e.getSource();
             f = menu.getFile();
         }
 

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenu.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenu.java?rev=405109&r1=405108&r2=405109&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenu.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/util/RecentFileMenu.java
Mon May  8 11:03:36 2006
@@ -65,6 +65,7 @@
 import org.objectstyle.cayenne.modeler.Application;
 import org.objectstyle.cayenne.modeler.ModelerPreferences;
 import org.objectstyle.cayenne.modeler.action.OpenProjectAction;
+import org.objectstyle.cayenne.swing.control.FileMenuItem;
 
 /**
  * Menu that contains a list of previously used files. It is built from CayenneModeler
@@ -84,8 +85,8 @@
     /**
      * @see javax.swing.JMenu#add(JMenuItem)
      */
-    public RecentFileMenuItem add(RecentFileMenuItem menuItem) {
-        return (RecentFileMenuItem) super.add(menuItem);
+    public FileMenuItem add(FileMenuItem menuItem) {
+        return (FileMenuItem) super.add(menuItem);
     }
 
     /**
@@ -109,12 +110,12 @@
 
             if (i < curSize) {
                 // update existing one
-                RecentFileMenuItem item = (RecentFileMenuItem) comps[i];
+                FileMenuItem item = (FileMenuItem) comps[i];
                 item.setText(name);
             }
             else {
                 // add a new one
-                RecentFileMenuItem item = new RecentFileMenuItem(name);
+                FileMenuItem item = new FileMenuItem(name);
                 item.setAction(findAction());
                 add(item);
             }

Added: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/swing/control/FileMenuItem.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/swing/control/FileMenuItem.java?rev=405109&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/swing/control/FileMenuItem.java
(added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/swing/control/FileMenuItem.java
Mon May  8 11:03:36 2006
@@ -0,0 +1,97 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.objectstyle.cayenne.swing.control;
+
+import java.io.File;
+
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JMenuItem;
+
+/**
+ * A menu item that points to a file.
+ * 
+ * @author Andrus Adamchik
+ */
+public class FileMenuItem extends JMenuItem {
+
+    /**
+     * Creates a new instance with the specified fileName.
+     */
+    public FileMenuItem(String fileName) {
+        setText(fileName);
+    }
+
+    protected void configurePropertiesFromAction(Action a) {
+        // excludes most generic action keys that are not applicable here...
+        setIcon(a != null ? (Icon) a.getValue(Action.SMALL_ICON) : null);
+        setEnabled(a != null ? a.isEnabled() : true);
+    }
+
+    /**
+     * Returns a file if this menu item points to a readable file or directory, or null
+     * otherwise.
+     */
+    public File getFile() {
+        if (getText() == null) {
+            return null;
+        }
+
+        File f = new File(getText());
+        return f.canRead() ? f : null;
+    }
+
+}



Mime
View raw message