cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmen...@apache.org
Subject svn commit: r679865 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ framework/cayenne-modeler/src/main...
Date Fri, 25 Jul 2008 17:37:55 GMT
Author: kmenard
Date: Fri Jul 25 10:37:54 2008
New Revision: 679865

URL: http://svn.apache.org/viewvc?rev=679865&view=rev
Log:
Fixed CAY-366: Add progress/log view

Added:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ShowLogConsoleAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleWindow.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogFactory.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogger.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/commons-logging.properties
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/WarningDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/CodeGeneratorController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/UIUtil.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Jul 25 10:37:54 2008
@@ -15,6 +15,7 @@
 
 Changes/New Features Since M4:
 
+CAY-366 Add progress/log view
 CAY-436 In modeler, change default object relationship delete rule
 CAY-888 CM Usability: Object Select Query Improvements
 CAY-911 CM Usability: JComboBox Autocompletion

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java Fri Jul 25 10:37:54 2008
@@ -19,63 +19,12 @@
 
 package org.apache.cayenne.modeler;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import javax.swing.Action;
-
-import org.apache.cayenne.modeler.action.AboutAction;
-import org.apache.cayenne.modeler.action.ConfigurePreferencesAction;
-import org.apache.cayenne.modeler.action.CreateAttributeAction;
-import org.apache.cayenne.modeler.action.CreateCallbackMethodAction;
-import org.apache.cayenne.modeler.action.CreateCallbackMethodForDataMapListenerAction;
-import org.apache.cayenne.modeler.action.CreateCallbackMethodForListenerAction;
-import org.apache.cayenne.modeler.action.CreateDataMapAction;
-import org.apache.cayenne.modeler.action.CreateDataMapEntityListenerAction;
-import org.apache.cayenne.modeler.action.CreateDbEntityAction;
-import org.apache.cayenne.modeler.action.CreateDomainAction;
-import org.apache.cayenne.modeler.action.CreateNodeAction;
-import org.apache.cayenne.modeler.action.CreateObjEntityAction;
-import org.apache.cayenne.modeler.action.CreateObjEntityListenerAction;
-import org.apache.cayenne.modeler.action.CreateProcedureAction;
-import org.apache.cayenne.modeler.action.CreateProcedureParameterAction;
-import org.apache.cayenne.modeler.action.CreateQueryAction;
-import org.apache.cayenne.modeler.action.CreateRelationshipAction;
-import org.apache.cayenne.modeler.action.DbEntitySyncAction;
-import org.apache.cayenne.modeler.action.DocumentationAction;
-import org.apache.cayenne.modeler.action.ExitAction;
-import org.apache.cayenne.modeler.action.FindAction;
-import org.apache.cayenne.modeler.action.GenerateCodeAction;
-import org.apache.cayenne.modeler.action.GenerateDBAction;
-import org.apache.cayenne.modeler.action.ImportDBAction;
-import org.apache.cayenne.modeler.action.ImportDataMapAction;
-import org.apache.cayenne.modeler.action.ImportEOModelAction;
-import org.apache.cayenne.modeler.action.MigrateAction;
-import org.apache.cayenne.modeler.action.NavigateBackwardAction;
-import org.apache.cayenne.modeler.action.NavigateForwardAction;
-import org.apache.cayenne.modeler.action.NewProjectAction;
-import org.apache.cayenne.modeler.action.ObjEntitySyncAction;
-import org.apache.cayenne.modeler.action.OpenProjectAction;
-import org.apache.cayenne.modeler.action.ProjectAction;
-import org.apache.cayenne.modeler.action.RemoveAction;
-import org.apache.cayenne.modeler.action.RemoveAttributeAction;
-import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
-import org.apache.cayenne.modeler.action.RemoveCallbackMethodForDataMapListenerAction;
-import org.apache.cayenne.modeler.action.RemoveCallbackMethodForListenerAction;
-import org.apache.cayenne.modeler.action.RemoveEntityListenerAction;
-import org.apache.cayenne.modeler.action.RemoveEntityListenerForDataMapAction;
-import org.apache.cayenne.modeler.action.RemoveProcedureParameterAction;
-import org.apache.cayenne.modeler.action.RemoveRelationshipAction;
-import org.apache.cayenne.modeler.action.RevertAction;
-import org.apache.cayenne.modeler.action.SaveAction;
-import org.apache.cayenne.modeler.action.SaveAsAction;
-import org.apache.cayenne.modeler.action.ValidateAction;
+import org.apache.cayenne.modeler.action.*;
 import org.apache.cayenne.modeler.util.CayenneAction;
 
+import javax.swing.*;
+import java.util.*;
+
 /**
  * An object that manages CayenneModeler actions.
  * 
@@ -201,6 +150,8 @@
         registerAction(new NavigateForwardAction(application)).setAlwaysOn(true);
         // search action registered
         registerAction(new FindAction(application));
+        
+        registerAction(new ShowLogConsoleAction(application)).setAlwaysOn(true);;
     }
 
     private CayenneAction registerAction(CayenneAction action) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java Fri Jul 25 10:37:54 2008
@@ -19,25 +19,11 @@
 
 package org.apache.cayenne.modeler;
 
-import java.awt.Dialog;
-import java.awt.Frame;
-import java.awt.Window;
-import java.io.File;
-import java.util.Collection;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.SwingUtilities;
-
+import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.util.AdapterMapping;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CayenneDialog;
-import org.apache.cayenne.pref.Domain;
-import org.apache.cayenne.pref.DomainPreference;
-import org.apache.cayenne.pref.HSQLEmbeddedPreferenceEditor;
-import org.apache.cayenne.pref.HSQLEmbeddedPreferenceService;
-import org.apache.cayenne.pref.PreferenceService;
+import org.apache.cayenne.pref.*;
 import org.apache.cayenne.project.CayenneUserDir;
 import org.apache.cayenne.project.Project;
 import org.apache.cayenne.swing.BindingFactory;
@@ -49,6 +35,11 @@
 import org.scopemvc.util.UIStrings;
 import org.scopemvc.view.swing.SwingView;
 
+import javax.swing.*;
+import java.awt.*;
+import java.io.File;
+import java.util.Collection;
+
 /**
  * A main modeler application class that provides a number of services to the Modeler
  * components. Configuration properties:
@@ -184,6 +175,12 @@
 
         // open up
         frameController.startupAction();
+        
+        /**
+         * After prefs have been loaded, we can now show the console if needed
+         */
+        LogConsole.getInstance().showConsoleIfNeeded();
+        getFrame().setVisible(true);
     }
 
     public BindingFactory getBindingFactory() {
@@ -297,12 +294,14 @@
             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
@@ -340,6 +339,7 @@
          * 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);
 
@@ -354,6 +354,7 @@
             return frame.getRootPane();
         }
 
+        @Override
         protected Window getDefaultParentWindow() {
             return frame;
         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java Fri Jul 25 10:37:54 2008
@@ -20,70 +20,20 @@
 
 package org.apache.cayenne.modeler;
 
-import java.awt.AWTEvent;
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.KeyEvent;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
-
-import org.apache.cayenne.modeler.action.AboutAction;
-import org.apache.cayenne.modeler.action.ConfigurePreferencesAction;
-import org.apache.cayenne.modeler.action.CreateDataMapAction;
-import org.apache.cayenne.modeler.action.CreateDbEntityAction;
-import org.apache.cayenne.modeler.action.CreateDomainAction;
-import org.apache.cayenne.modeler.action.CreateNodeAction;
-import org.apache.cayenne.modeler.action.CreateObjEntityAction;
-import org.apache.cayenne.modeler.action.CreateProcedureAction;
-import org.apache.cayenne.modeler.action.CreateQueryAction;
-import org.apache.cayenne.modeler.action.DocumentationAction;
-import org.apache.cayenne.modeler.action.ExitAction;
-import org.apache.cayenne.modeler.action.FindAction;
-import org.apache.cayenne.modeler.action.GenerateCodeAction;
-import org.apache.cayenne.modeler.action.GenerateDBAction;
-import org.apache.cayenne.modeler.action.ImportDBAction;
-import org.apache.cayenne.modeler.action.ImportDataMapAction;
-import org.apache.cayenne.modeler.action.ImportEOModelAction;
-import org.apache.cayenne.modeler.action.MigrateAction;
-import org.apache.cayenne.modeler.action.NavigateBackwardAction;
-import org.apache.cayenne.modeler.action.NavigateForwardAction;
-import org.apache.cayenne.modeler.action.NewProjectAction;
-import org.apache.cayenne.modeler.action.ObjEntitySyncAction;
-import org.apache.cayenne.modeler.action.OpenProjectAction;
-import org.apache.cayenne.modeler.action.ProjectAction;
-import org.apache.cayenne.modeler.action.RemoveAction;
-import org.apache.cayenne.modeler.action.RevertAction;
-import org.apache.cayenne.modeler.action.SaveAction;
-import org.apache.cayenne.modeler.action.SaveAsAction;
-import org.apache.cayenne.modeler.action.ValidateAction;
+import org.apache.cayenne.modeler.action.*;
+import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.editor.EditorView;
-import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
-import org.apache.cayenne.modeler.event.DataMapDisplayListener;
-import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
-import org.apache.cayenne.modeler.event.DataNodeDisplayListener;
-import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
-import org.apache.cayenne.modeler.event.EntityDisplayEvent;
-import org.apache.cayenne.modeler.event.MultipleObjectsDisplayEvent;
-import org.apache.cayenne.modeler.event.MultipleObjectsDisplayListener;
-import org.apache.cayenne.modeler.event.ObjEntityDisplayListener;
-import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
-import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
-import org.apache.cayenne.modeler.event.QueryDisplayEvent;
-import org.apache.cayenne.modeler.event.QueryDisplayListener;
+import org.apache.cayenne.modeler.event.*;
+import org.apache.cayenne.modeler.pref.ComponentGeometry;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.OperatingSystem;
 import org.apache.cayenne.modeler.util.RecentFileMenu;
+import org.apache.cayenne.pref.Domain;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.AWTEventListener;
+import java.awt.event.KeyEvent;
 
 /**
  * Main frame of CayenneModeler. Responsibilities include coordination of
@@ -97,7 +47,23 @@
     protected RecentFileMenu recentFileMenu;
     protected ActionManager actionManager;
     protected JLabel status;
-
+    
+    /**
+     * Menu which shows/hides log console
+     */
+    protected JCheckBoxMenuItem logMenu;
+    
+    /**
+     * Split panel, where main project editor and external component, like log console, 
+     * are located 
+     */
+    protected JSplitPane splitPane;
+    
+    /**
+     * Component, plugged into this frame
+     */
+    protected Component dockComponent;
+    
     public CayenneModelerFrame(ActionManager actionManager) {
         super(ModelerConstants.TITLE);
         this.actionManager = actionManager;
@@ -105,6 +71,8 @@
         initMenus();
         initToolbar();
         initStatusBar();
+        
+        setView(null);
     }
 
     /**
@@ -172,6 +140,15 @@
         toolMenu.add(getAction(GenerateDBAction.getActionName()).buildMenu());
         toolMenu.add(getAction(MigrateAction.getActionName()).buildMenu());
         
+        /**
+         * Menu for opening Log console
+         */
+        toolMenu.addSeparator();
+        
+        logMenu = getAction(ShowLogConsoleAction.getActionName()).buildCheckBoxMenu();
+        updateLogConsoleMenu();
+        toolMenu.add(logMenu);
+        
         // Mac OS X has it's own Preferences menu item under the application menu
         if (OperatingSystem.getOS() != OperatingSystem.MAC_OS_X) {
             toolMenu.addSeparator();
@@ -192,18 +169,69 @@
 
         setJMenuBar(menuBar);
     }
+    
+    /**
+     * Selects/deselects menu item, depending on status of log console 
+     */
+    public void updateLogConsoleMenu() {
+        logMenu.setSelected(LogConsole.getInstance().getConsoleProperty(
+                LogConsole.SHOW_CONSOLE_PROPERTY));
+    }
 
     protected void initStatusBar() {
         status = new JLabel();
         status.setFont(status.getFont().deriveFont(Font.PLAIN, 10));
+        
+        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+        splitPane.getInsets().left = 5;
+        splitPane.getInsets().right = 5;
+        
+        splitPane.setResizeWeight(0.7);
+        
+        Domain domain = Application.getInstance().getPreferenceDomain().getSubdomain(
+                this.getClass());
+        ComponentGeometry geometry = (ComponentGeometry) domain.getDetail(
+                "splitPane.divider",
+                ComponentGeometry.class,
+                true);
+        geometry.bindIntProperty(splitPane, JSplitPane.DIVIDER_LOCATION_PROPERTY, 400);
 
         JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
         // add placeholder
         statusBar.add(Box.createVerticalStrut(16));
         statusBar.add(status);
 
+        getContentPane().add(splitPane, BorderLayout.CENTER);
         getContentPane().add(statusBar, BorderLayout.SOUTH);
     }
+    
+    /**
+     * Plugs a component in the frame, between main area and status bar
+     */
+    public void setDockComponent(Component c) {
+        if (dockComponent == c) {
+            return;
+        }
+        
+        if (dockComponent != null) {
+            splitPane.setBottomComponent(null);
+        }
+        
+        dockComponent = c;
+        
+        if (dockComponent != null) {
+            splitPane.setBottomComponent(dockComponent);
+        }
+        
+        splitPane.validate();
+    }
+    
+    /**
+     * @return Dock component
+     */
+    public Component getDockComponent() {
+        return dockComponent;
+    }
 
     /** Initializes main toolbar. */
     protected void initToolbar() {
@@ -313,22 +341,18 @@
      * Adds editor view to the frame.
      */
     public void setView(EditorView view) {
-        boolean change = false;
-
-        if (this.view != null) {
-            getContentPane().remove(this.view);
-            change = true;
-        }
-
+        int oldLocation = splitPane.getDividerLocation();
+        
         this.view = view;
 
         if (view != null) {
-            getContentPane().add(view, BorderLayout.CENTER);
-            change = true;
+            splitPane.setTopComponent(view);
         }
-
-        if (change) {
-            validate();
+        else {
+            splitPane.setTopComponent(new JPanel());
         }
+
+        validate();
+        splitPane.setDividerLocation(oldLocation);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExitAction.java Fri Jul 25 10:37:54 2008
@@ -19,12 +19,13 @@
 
 package org.apache.cayenne.modeler.action;
 
-import java.awt.event.ActionEvent;
-
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ModelerPreferences;
+import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.project.ProjectPath;
 
+import java.awt.event.ActionEvent;
+
 /**
  * @author Andrus Adamchik
  */
@@ -52,6 +53,9 @@
 
 		// write prefs to persistent store
 		ModelerPreferences.getPreferences().storePreferences();
+		
+		//stop logging before JVM shutdown to prevent hanging
+		LogConsole.getInstance().stopLogging();
 
 		// goodbye
         System.exit(0);

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ShowLogConsoleAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ShowLogConsoleAction.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ShowLogConsoleAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ShowLogConsoleAction.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,51 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.action;
+
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.dialog.LogConsole;
+import org.apache.cayenne.modeler.util.CayenneAction;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Action for opening log console window (See CAY-366)
+ * @author Andrey Razumovsky
+ */
+public class ShowLogConsoleAction extends CayenneAction {
+    /**
+     * Readable name for this action
+     */
+    public static final String getActionName() {
+        return "Show log console";
+    }
+    
+    /**
+     * Constructor for ShowLogConsoleAction.
+     */
+    public ShowLogConsoleAction(Application application) {
+        super(getActionName(), application);
+    }
+    
+    @Override
+    public void performAction(ActionEvent e) {
+        LogConsole.getInstance().toggle();
+    }
+
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ErrorDebugDialog.java Fri Jul 25 10:37:54 2008
@@ -20,36 +20,38 @@
 
 package org.apache.cayenne.modeler.dialog;
 
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.HeadlessException;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JEditorPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-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.PanelFactory;
 import org.apache.cayenne.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.scopemvc.util.UIStrings;
 
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
 /**
  * Displays CayenneModeler exceptions and warning messages.
  * 
  * @author Andrus Adamchik
  */
 public class ErrorDebugDialog extends CayenneDialog implements ActionListener {
+    private static Log logObj = LogFactory.getLog(ErrorDebugDialog.class);
+    
+    /**
+     * Sole instance of error/warning dialog to disallow showing of multiple dialogs
+     */
+    private static ErrorDebugDialog instance;
+    
     protected JButton close;
     protected JButton showHide;
     protected JTextArea exText = new JTextArea();
@@ -57,22 +59,40 @@
     protected Throwable throwable;
     protected boolean detailed;
 
+    /**
+     * Shows an error dialog with stack trace
+     */
     public static void guiException(Throwable th) {
         if (th != null) {
-            th.printStackTrace();
+            logObj.error("CayenneModeler Error", th);
         }
 
         ErrorDebugDialog dialog =
-            new ErrorDebugDialog(Application.getFrame(), "CayenneModeler Error", th, true);
-        dialog.setVisible(true);
+            new ErrorDebugDialog(Application.getFrame(), "CayenneModeler Error", th, true, false);
+        showDialog(dialog);
     }
 
+    /**
+     * Shows an warning dialog with stack trace
+     */
     public static void guiWarning(Throwable th, String message) {
         if (th != null) {
-            th.printStackTrace();
+            logObj.warn("CayenneModeler Warning", th);
         }
 
-        WarningDialog dialog = new WarningDialog(Application.getFrame(), message, th, false);
+        WarningDialog dialog = new WarningDialog(Application.getFrame(), message, th, false, false);
+        showDialog(dialog);
+    }
+    
+    /**
+     * Shows an error/warning dialog, closing existing if needed
+     */
+    private static void showDialog(ErrorDebugDialog dialog) {
+        if (instance != null) {
+            instance.dispose();
+        }
+        
+        instance = dialog;
         dialog.setVisible(true);
     }
 
@@ -86,7 +106,21 @@
         boolean detailed)
         throws HeadlessException {
 
-        super(owner, title, true);
+        this(owner, title, throwable, detailed, true);
+    }
+    
+    /**
+     * Constructor for ErrorDebugDialog, allowing to specify 'modal' property
+     */
+    protected ErrorDebugDialog(
+    CayenneModelerFrame owner,
+        String title,
+        Throwable throwable,
+        boolean detailed,
+        boolean modal)
+        throws HeadlessException {
+
+        super(owner, title, modal);
 
         setThrowable(Util.unwindException(throwable));
         setDetailed(detailed);
@@ -144,6 +178,13 @@
         JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close }
         : new JButton[] { close };
         pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH);
+        
+        //add a listener to clear static variables, not to produce garbage
+        addWindowListener(new WindowAdapter() {
+           public void windowClosing(WindowEvent e) {
+               instance = null;
+           }
+        });
 
         // prepare to display
         this.pack();

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,371 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.dialog;
+
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.pref.ComponentGeometry;
+import org.apache.cayenne.modeler.util.CayenneController;
+import org.apache.cayenne.pref.Domain;
+import org.apache.cayenne.util.Util;
+
+import javax.swing.text.*;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.util.Date;
+
+/**
+ * Implementation for modeler log console functionality
+ * @author Andrey Razumovsky
+ */
+public class LogConsole extends CayenneController {
+    /**
+     * How much characters are allowed in console
+     */
+    private static final int TEXT_MAX_LENGTH = 500000;
+    
+    /**
+     * Property to store user preference
+     */
+    public static final String SHOW_CONSOLE_PROPERTY = "show.log.console";
+    
+    /**
+     * Property to store 'is-docked' preference
+     */
+    public static final String DOCKED_PROPERTY = "log.console.docked";
+    
+    /**
+     * Message date format 
+     */
+    private static final DateFormat FORMAT = DateFormat.getDateTimeInstance();
+    
+    /**
+     * Red color style for severe messages
+     */
+    public static final MutableAttributeSet ERROR_STYLE;
+    
+    /**
+     * Red bold color style for fatal messages
+     */
+    public static final MutableAttributeSet FATAL_STYLE;
+    
+    /**
+     * Dark red color style for warn messages
+     */
+    public static final MutableAttributeSet WARN_STYLE;
+    
+    /**
+     * Blue color style for info messages
+     */
+    public static final MutableAttributeSet INFO_STYLE;
+    
+    /**
+     * Style for debug messages
+     */
+    public static final MutableAttributeSet DEBUG_STYLE;
+    
+    static {
+        ERROR_STYLE = new SimpleAttributeSet();
+        StyleConstants.setForeground(ERROR_STYLE, Color.RED);
+        
+        FATAL_STYLE = new SimpleAttributeSet();
+        StyleConstants.setForeground(FATAL_STYLE, Color.RED);
+        StyleConstants.setBold(FATAL_STYLE, true);
+        
+        WARN_STYLE = new SimpleAttributeSet();
+        StyleConstants.setForeground(WARN_STYLE, Color.RED.darker());
+        
+        INFO_STYLE = new SimpleAttributeSet();
+        StyleConstants.setForeground(INFO_STYLE, Color.BLUE);
+        
+        DEBUG_STYLE = null;
+    }
+    
+    /**
+     * Lone log console instance
+     */
+    private static LogConsole instance;
+    
+    /**
+     * Swing console window
+     */
+    private LogConsoleView view;
+    
+    /**
+     * Window, which contains the console. Might be non-visible, if the console is docked
+     */
+    private LogConsoleWindow logWindow;
+        
+    /**
+     * Whether auto-scrolling should be enabled for the console text area.
+     * Currently not included in UI
+     */
+    private boolean autoScroll;
+    
+    /**
+     * Flag, indicating that no more logging to Swing component is appreciated.
+     * This is useful to prevent logging messages when they are no more needed, e.g. on
+     * JVM shutdown 
+     */
+    private boolean loggingStopped;
+    
+    public LogConsole() {
+        super((CayenneController) null);
+        
+        view = new LogConsoleView();
+        autoScroll = true;
+        
+        initBindings();
+    }
+    
+    protected void initBindings() {
+        view.getClearButton().addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                clear();
+            }
+        });
+        
+        view.getCopyButton().addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                copy();
+            }
+        });
+        
+        view.getDockButton().addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                /**
+                 * Log console should be visible
+                 */
+                
+                disappear();
+                setConsoleProperty(DOCKED_PROPERTY, !getConsoleProperty(DOCKED_PROPERTY));
+                appear();
+            }
+        });
+    }
+    
+    /**
+     * Clears the console
+     */
+    public void clear() {
+        view.getLogView().setText("");
+    }
+        
+    /**
+     * Shows the console, in separate window or in main frame 
+     */
+    private void appear() {
+        if (!getConsoleProperty(DOCKED_PROPERTY)) {
+            view.getDockButton().setText("Dock");
+            
+            if (logWindow == null) {
+                logWindow = new LogConsoleWindow(this);
+            
+                Domain prefDomain = getDomain();
+                ComponentGeometry geometry = ComponentGeometry.getPreference(prefDomain);
+                geometry.bind(logWindow, 600, 300, 0);
+            }
+            
+            logWindow.setContentPane(view);
+            
+            logWindow.validate();
+            logWindow.setVisible(true);
+        }
+        else {
+            view.getDockButton().setText("Undock");
+            Application.getFrame().setDockComponent(view);
+        }
+    }
+    
+    /**
+     * Hides the console 
+     */
+    private void disappear() {
+        if (!getConsoleProperty(DOCKED_PROPERTY)) {
+            logWindow.dispose();
+            logWindow = null;
+        }
+        else {
+            Application.getFrame().setDockComponent(null);
+        }
+    }
+    
+    /**
+     * Copies selected text from the console to system buffer
+     */
+    public void copy() {
+        String selectedText = view.getLogView().getSelectedText();
+        
+        /**
+         * If nothing is selected, we copy the whole text
+         */
+        if (Util.isEmptyString(selectedText)) {
+            Document doc = view.getLogView().getDocument();
+            
+            try {
+                selectedText = doc.getText(0, doc.getLength());
+            }
+            catch (BadLocationException e) {
+                return;
+            }
+        }
+        
+       Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
+       StringSelection data = new StringSelection(selectedText); 
+       
+       sysClip.setContents(data, data);
+    }
+    
+    /**
+     * Shows or hides the console window
+     */
+    public void toggle() {
+        boolean needShow = !getConsoleProperty(SHOW_CONSOLE_PROPERTY);
+        setConsoleProperty(SHOW_CONSOLE_PROPERTY, needShow);
+        
+        if (needShow) {
+            appear();
+        }
+        else {
+            disappear();
+        }
+    }
+    
+    /**
+     * Shows the console if the preference 'SHOW_CONSOLE_PROPERTY' is set to true 
+     */
+    public void showConsoleIfNeeded() {
+        if (getConsoleProperty(SHOW_CONSOLE_PROPERTY)) {
+            appear();
+        }
+    }
+    
+    /**
+     * Sets the property, depending on last user's choice
+     */
+    public void setConsoleProperty(String prop, boolean b) {
+        getDomain().getDetail(prop, true).
+            setBooleanProperty(prop, b);
+    }
+    
+    /**
+     * @return a boolean property
+     */
+    public boolean getConsoleProperty(String prop) {
+        return getDomain().getDetail(prop, true).getBooleanProperty(prop);
+    }
+    
+    /**
+     * Appends a message to the console.
+     * @param style Message font, color etc.
+     */
+    public void appendMessage(String level, String message, AttributeSet style) {
+        appendMessage(message, null, style);
+    }
+    
+    /**
+     * Appends a message and (or) an exception
+     * @param style Message font, color etc.
+     */
+    public void appendMessage(String level, String message, Throwable ex, 
+        AttributeSet style) {
+        
+        if (loggingStopped) {
+            return;
+        }
+        
+        Document doc = view.getLogView().getDocument(); 
+            
+        //truncate if needed
+        if (doc.getLength() > TEXT_MAX_LENGTH) {
+            clear();
+        }
+        
+        StringBuffer newText = new StringBuffer(FORMAT.format(new Date()))
+            .append(System.getProperty("line.separator"))
+            .append(level.toUpperCase() + ": ");
+        
+        if (message != null) {
+            /**
+             * Append the message
+             */
+            newText.append(message).append(System.getProperty("line.separator"));
+        }
+        
+        if (ex != null) {
+            /**
+             * Append the stack trace
+             */
+            StringWriter out = new StringWriter();
+            PrintWriter printer = new PrintWriter(out);
+            
+            ex.printStackTrace(printer);
+            printer.flush();
+            
+            newText.append(out.toString()).append(System.getProperty("line.separator"));
+        }
+        
+        try {
+            doc.insertString(doc.getLength(), newText.toString(), style);
+
+            //view.getLogView().setText(view.getLogView().getText() + newText);
+            
+            if (autoScroll) {
+                view.getLogView().setCaretPosition(
+                        doc.getLength() - 1);
+            }
+        }
+        catch (BadLocationException ignored) {
+            //should not happen
+        }
+        
+    }
+
+    @Override
+    public Component getView() {
+        return view;
+    }
+    
+    protected Domain getDomain() {
+        return Application.getInstance().getPreferenceDomain().getSubdomain(getClass());
+    }
+    
+    /**
+     * Stop logging and don't print any more messages to text area
+     */
+    public void stopLogging() {
+        loggingStopped = true;
+    }
+    
+    /**
+     * @return lone log console instance
+     */
+    public static LogConsole getInstance() {
+        if (instance == null) {
+            instance = new LogConsole();
+        }
+        
+        return instance;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,116 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.dialog;
+
+import javax.swing.*;
+import javax.swing.text.JTextComponent;
+import java.awt.*;
+
+/**
+ * LogConsole is a window with text area filled with log messages of the
+ * application. 
+ * @author Andrey Razumovsky
+ */
+public class LogConsoleView extends JPanel {
+    
+    /**
+     * Area to be filled with log messages
+     */
+    JTextComponent logView;
+    
+    /**
+     * Button which performs clearing the console output 
+     */
+    JButton clearButton;
+    
+    /**
+     * Button which performs copying the console output 
+     */
+    JButton copyButton;
+    
+    /**
+     * Button which performs docking the window, i.e. sticking it to parent 
+     */
+    JButton dockButton;
+    
+    /**
+     * Scrollpane containing the text area
+     */
+    JScrollPane scroller;
+    
+    /**
+     * Constructs a new log console view component
+     */
+    public LogConsoleView() {
+        //log console window must be non-modal
+        super();
+        
+        init();
+    }
+    
+    /**
+     * Initializes all lays out subcomponents
+     */
+    protected void init() {
+        setLayout(new BorderLayout(5, 5));
+        
+        logView = new JEditorPane("text/html", "");
+        logView.setEditable(false);
+        
+        scroller = new JScrollPane(logView);
+        add(scroller, BorderLayout.CENTER);
+        
+        JPanel buttonsPane = new JPanel();
+        
+        copyButton = new JButton("Copy");
+        clearButton = new JButton("Clear");
+        dockButton = new JButton("Dock");
+        
+        buttonsPane.add(clearButton);
+        buttonsPane.add(copyButton);
+        buttonsPane.add(dockButton);
+        add(buttonsPane, BorderLayout.SOUTH);
+        
+        //no need to center log window
+        setLocation(100, 100);
+    }
+    
+    /**
+     * @return area to be filled with log messages
+     */
+    protected JTextComponent getLogView() {
+        return logView;
+    }
+    
+    protected AbstractButton getCopyButton() {
+        return copyButton;
+    }
+    
+    protected AbstractButton getClearButton() {
+        return clearButton;
+    }
+    
+    protected AbstractButton getDockButton() {
+        return dockButton;
+    }
+    
+    protected JScrollPane getScroller() {
+        return scroller;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleWindow.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleWindow.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleWindow.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleWindow.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,46 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.dialog;
+
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.util.CayenneDialog;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/**
+ * LogConsoleWindow is used to show log in a separate dialog 
+ * @author Andrey Razumovsky
+ */
+public class LogConsoleWindow extends CayenneDialog {
+
+    /**
+     * Constructs a new log console window
+     */
+    public LogConsoleWindow(final LogConsole controller) {
+        setTitle("Cayenne Modeler Console");
+        
+        addWindowListener(new WindowAdapter() {
+            public void windowClosing(WindowEvent e) {
+                controller.setConsoleProperty(LogConsole.SHOW_CONSOLE_PROPERTY, false);
+                Application.getFrame().updateLogConsoleMenu();
+            }
+        });
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/WarningDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/WarningDialog.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/WarningDialog.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/WarningDialog.java Fri Jul 25 10:37:54 2008
@@ -19,10 +19,10 @@
 
 package org.apache.cayenne.modeler.dialog;
 
-import java.awt.HeadlessException;
-
 import org.apache.cayenne.modeler.CayenneModelerFrame;
 
+import java.awt.*;
+
 /**
  * Dialog for CayenneModeler warnings.
  * 
@@ -30,11 +30,23 @@
  */
 public class WarningDialog extends ErrorDebugDialog {
 
+    /**
+     * Constructor for warning dialog
+     */
     public WarningDialog(CayenneModelerFrame owner, String title, Throwable throwable,
             boolean detailed) throws HeadlessException {
-        super(owner, title, throwable, detailed);
+        this(owner, title, throwable, detailed, true);
+    }
+    
+    /**
+     * Constructor for warning dialog, allowing to specify 'modal' property
+     */
+    public WarningDialog(CayenneModelerFrame owner, String title, Throwable throwable,
+            boolean detailed, boolean modal) throws HeadlessException {
+        super(owner, title, throwable, detailed, modal);
     }
 
+    @Override
     protected String infoHTML() {
         return "<font face='Arial,Helvetica' size='+1' color='blue'>"
                 + getTitle()

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/CodeGeneratorController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/CodeGeneratorController.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/CodeGeneratorController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/codegen/CodeGeneratorController.java Fri Jul 25 10:37:54 2008
@@ -19,16 +19,18 @@
 
 package org.apache.cayenne.modeler.dialog.codegen;
 
-import java.awt.Component;
-
-import javax.swing.JOptionPane;
-
 import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.swing.BindingBuilder;
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.*;
+import java.awt.*;
 
 /**
  * A controller for the class generator dialog.
@@ -36,6 +38,10 @@
  * @author Andrus Adamchik
  */
 public class CodeGeneratorController extends CodeGeneratorControllerBase {
+    /**
+     * Logger to print stack traces
+     */
+    private static Log logObj = LogFactory.getLog(ErrorDebugDialog.class);
 
     protected CodeGeneratorDialog view;
 
@@ -49,6 +55,7 @@
         this.generatorSelector = new GeneratorTabController(this);
     }
 
+    @Override
     public Component getView() {
         return view;
     }
@@ -124,13 +131,13 @@
             try {
                 generator.execute();
                 JOptionPane.showMessageDialog(
-                        (Component) this.getView(),
+                        this.getView(),
                         "Class generation finished");
             }
             catch (Exception e) {
-                e.printStackTrace();
+                logObj.error("Error generating classes", e);
                 JOptionPane.showMessageDialog(
-                        (Component) this.getView(),
+                        this.getView(),
                         "Error generating classes - " + e.getMessage());
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java Fri Jul 25 10:37:54 2008
@@ -19,19 +19,16 @@
 
 package org.apache.cayenne.modeler.pref;
 
-import java.awt.Component;
+import org.apache.cayenne.pref.Domain;
+import org.apache.cayenne.pref.PreferenceException;
+import org.apache.cayenne.reflect.PropertyUtils;
+
+import java.awt.*;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-
-import org.apache.cayenne.pref.Domain;
-import org.apache.cayenne.pref.PreferenceException;
-import org.apache.cayenne.reflect.PropertyUtils;
-
 public class ComponentGeometry extends _ComponentGeometry {
 
     public static final String GEOMETRY_PREF_KEY = "geometry";
@@ -48,24 +45,26 @@
      * allowing to specify an initial offset compared to the stored position.
      */
     public void bind(
-            final JFrame frame,
+            final Window window,
             int initialWidth,
             int initialHeight,
             int maxOffset) {
 
-        updateSize(frame, initialWidth, initialHeight);
-        updateLocation(frame, maxOffset);
+        updateSize(window, initialWidth, initialHeight);
+        updateLocation(window, maxOffset);
 
-        frame.addComponentListener(new ComponentAdapter() {
+        window.addComponentListener(new ComponentAdapter() {
 
+            @Override
             public void componentResized(ComponentEvent e) {
-                setWidth(new Integer(frame.getWidth()));
-                setHeight(new Integer(frame.getHeight()));
+                setWidth(new Integer(window.getWidth()));
+                setHeight(new Integer(window.getHeight()));
             }
 
+            @Override
             public void componentMoved(ComponentEvent e) {
-                setX(new Integer(frame.getX()));
-                setY(new Integer(frame.getY()));
+                setX(new Integer(window.getX()));
+                setY(new Integer(window.getY()));
             }
         });
     }
@@ -74,14 +73,15 @@
      * Binds this preference object to synchronize its state with a given component,
      * allowing to specify an initial offset compared to the stored position.
      */
-    public void bind(final JDialog dialog, int initialWidth, int initialHeight) {
-        updateSize(dialog, initialWidth, initialHeight);
+    public void bindSize(final Window window, int initialWidth, int initialHeight) {
+        updateSize(window, initialWidth, initialHeight);
 
-        dialog.addComponentListener(new ComponentAdapter() {
+        window.addComponentListener(new ComponentAdapter() {
 
+            @Override
             public void componentResized(ComponentEvent e) {
-                setWidth(new Integer(dialog.getWidth()));
-                setHeight(new Integer(dialog.getHeight()));
+                setWidth(new Integer(window.getWidth()));
+                setHeight(new Integer(window.getHeight()));
             }
         });
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java Fri Jul 25 10:37:54 2008
@@ -20,15 +20,6 @@
 
 package org.apache.cayenne.modeler.util;
 
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JMenuItem;
-import javax.swing.KeyStroke;
-
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
@@ -36,6 +27,9 @@
 import org.apache.cayenne.project.ProjectPath;
 import org.apache.cayenne.util.Util;
 
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+
 /**
  * Superclass of CayenneModeler actions that implements support for some common
  * functionality, exception handling, etc.
@@ -173,6 +167,13 @@
     public JMenuItem buildMenu() {
         return new JMenuItem(this);
     }
+    
+    /**
+     * Factory method that creates a checkbox menu item hooked up to this action.
+     */
+    public JCheckBoxMenuItem buildCheckBoxMenu() {
+        return new JCheckBoxMenuItem(this);
+    }
 
     /**
      * Factory method that creates a button hooked up to this action.
@@ -206,6 +207,7 @@
     /**
      * Overrides super implementation to take into account "alwaysOn" flag.
      */
+    @Override
     public void setEnabled(boolean b) {
         if (!isAlwaysOn()) {
             super.setEnabled(b);
@@ -244,6 +246,7 @@
         /**
          * @see javax.swing.AbstractButton#getText()
          */
+        @Override
         public String getText() {
             return (showingText) ? super.getText() : null;
         }
@@ -251,6 +254,7 @@
         /**
          * @see javax.swing.AbstractButton#setText(String)
          */
+        @Override
         public void setText(String text) {
             if (showingText) {
                 super.setText(text);

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogFactory.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogFactory.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogFactory.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,54 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.impl.LogFactoryImpl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Factory for creating ModelerLogger instances. LogFactoryImpl is 
+ * subclassed to save default behavior 
+ * @author Andrey Razumovsky
+ */
+public class ModelerLogFactory extends LogFactoryImpl {
+    /**
+     * Local cache of modeler loggers
+     */
+    protected Map<String, ModelerLogger> localCache;
+    
+    public ModelerLogFactory() {
+        localCache = new HashMap<String, ModelerLogger>();
+    }
+    
+    @Override
+    public Log getInstance(String name) throws LogConfigurationException {
+        ModelerLogger local = localCache.get(name);
+        if (local == null) {
+            Log def = super.getInstance(name);
+            
+            local = new ModelerLogger(name, def);
+            localCache.put(name, local);
+        }
+        return local;
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogger.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogger.java?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogger.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ModelerLogger.java Fri Jul 25 10:37:54 2008
@@ -0,0 +1,142 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.util;
+
+import org.apache.cayenne.modeler.dialog.LogConsole;
+import org.apache.commons.logging.Log;
+
+import javax.swing.text.AttributeSet;
+
+/**
+ * ModelerLogger is a Log implementation, which performs output
+ * to the LogConsole. Default behavior is saved since they are delegated
+ * to default Log instance. 
+ * @author Andrey Razumovsky
+ */
+public class ModelerLogger implements Log {
+    /**
+     * 'Default' Log instance (i.e. Log4jLogger, Jdk14Logger, or other)
+     */
+    Log delegate;
+    
+    /** 
+     * Logger name 
+     */
+    String name;
+    
+    public ModelerLogger(String name, Log delegate) {
+        this.name = name;
+        this.delegate = delegate;
+    }
+    
+    public void debug(Object message) {
+        delegate.debug(message);
+        log("DEBUG", message, null, LogConsole.DEBUG_STYLE);
+    }
+
+    public void debug(Object message, Throwable t) {
+        delegate.debug(message, t);
+        log("DEBUG", message, t, LogConsole.DEBUG_STYLE);
+    }
+
+    public void error(Object message) {
+        delegate.error(message);
+        log("ERROR", message, null, LogConsole.ERROR_STYLE);
+    }
+
+    public void error(Object message, Throwable t) {
+        delegate.error(message, t);
+        log("ERROR", message, t, LogConsole.ERROR_STYLE);
+    }
+
+    public void fatal(Object message) {
+        delegate.fatal(message);
+        log("FATAL", message, null, LogConsole.FATAL_STYLE);
+    }
+
+    public void fatal(Object message, Throwable t) {
+        delegate.fatal(message, t);
+        log("FATAL", message, t, LogConsole.FATAL_STYLE);
+    }
+
+    public void info(Object message) {
+        delegate.info(message);
+        log("INFO", message, null, LogConsole.INFO_STYLE);
+    }
+
+    public void info(Object message, Throwable t) {
+        delegate.info(message);
+        log("INFO", message, t, LogConsole.INFO_STYLE);
+    }
+    
+    public void trace(Object message) {
+        delegate.trace(message);
+        log("TRACE", message, null, LogConsole.DEBUG_STYLE);
+    }
+
+    public void trace(Object message, Throwable t) {
+        delegate.trace(message, t);
+        log("TRACE", message, t, LogConsole.DEBUG_STYLE);
+    }
+
+    public void warn(Object message) {
+        delegate.warn(message);
+        log("WARN", message, null, LogConsole.WARN_STYLE);
+    }
+
+    public void warn(Object message, Throwable t) {
+        delegate.warn(message, t);
+        log("WARN", message, t, LogConsole.WARN_STYLE);
+    }
+
+    public boolean isDebugEnabled() {
+        return delegate.isDebugEnabled();
+    }
+
+    public boolean isErrorEnabled() {
+        return delegate.isErrorEnabled();
+    }
+
+    public boolean isFatalEnabled() {
+        return delegate.isFatalEnabled();
+    }
+
+    public boolean isInfoEnabled() {
+        return delegate.isInfoEnabled();
+    }
+
+    public boolean isTraceEnabled() {
+        return delegate.isTraceEnabled();
+    }
+
+    public boolean isWarnEnabled() {
+        return delegate.isWarnEnabled();
+    }
+
+    /**
+     * Prints common message to the console
+     */
+    private void log(String level, Object message, Throwable t, AttributeSet style) {
+        getLogConsole().appendMessage(level, String.valueOf(message), t, style);
+    }
+
+    private LogConsole getLogConsole() {
+        return LogConsole.getInstance();
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/UIUtil.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/UIUtil.java?rev=679865&r1=679864&r2=679865&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/UIUtil.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/UIUtil.java Fri Jul 25 10:37:54 2008
@@ -20,10 +20,8 @@
 
 package org.apache.cayenne.modeler.util;
 
-import java.awt.Rectangle;
-
-import javax.swing.JTable;
-import javax.swing.JViewport;
+import javax.swing.*;
+import java.awt.*;
 
 /**
  * @author Andrus Adamchik
@@ -80,4 +78,23 @@
         // Scroll the area into view.
         viewport.scrollRectToVisible(rect);
     }
+    
+    /**
+     * "Injects" windows's content to another window
+     */
+    public static void dock(Window window, Window dockTo) {
+        window.setVisible(false);
+        
+        ((RootPaneContainer) dockTo).getContentPane()
+            .add(((RootPaneContainer) window).getContentPane(), BorderLayout.SOUTH);
+        
+        dockTo.setVisible(true);
+    }
+    
+    /**
+     * "Injects" windows's content to parent window
+     */
+    public static void dock(Window window) {
+        dock(window, window.getOwner());
+    }
 }

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/commons-logging.properties
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/commons-logging.properties?rev=679865&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/commons-logging.properties (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/commons-logging.properties Fri Jul 25 10:37:54 2008
@@ -0,0 +1,18 @@
+#   Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+org.apache.commons.logging.LogFactory=org.apache.cayenne.modeler.util.ModelerLogFactory



Mime
View raw message