cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: Resolved CAY-1267 - Some changes to LogDialog
Date Sun, 22 Feb 2015 11:40:00 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master cb17347f7 -> 7096da312


Resolved CAY-1267 - Some changes to LogDialog


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/7096da31
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/7096da31
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/7096da31

Branch: refs/heads/master
Commit: 7096da3125fb37557d8faa456bd52ed8817a4243
Parents: cb17347
Author: laakhbeenor <xhelix.hel@gmail.com>
Authored: Thu Feb 19 21:17:20 2015 +0100
Committer: laakhbeenor <xhelix.hel@gmail.com>
Committed: Thu Feb 19 21:17:20 2015 +0100

----------------------------------------------------------------------
 .../cayenne/modeler/dialog/LogConsole.java      |  23 +++++--
 .../cayenne/modeler/dialog/LogConsoleView.java  |  69 +++++++++++++------
 .../apache/cayenne/modeler/images/popupmenu.gif | Bin 0 -> 285 bytes
 3 files changed, 66 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/7096da31/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
index d08b84b..a7d586b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsole.java
@@ -23,12 +23,15 @@ import org.apache.cayenne.modeler.pref.ComponentGeometry;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.util.Util;
 
+import javax.swing.JToolBar;
 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.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.text.DateFormat;
@@ -138,19 +141,25 @@ public class LogConsole extends CayenneController {
     }
     
     protected void initBindings() {
-        view.getClearButton().addActionListener(new ActionListener() {
+    	view.getMenuButton().addMouseListener(new MouseAdapter() {
+            public void mousePressed(MouseEvent e) {
+            	view.getMenu().show(view, view.getMenuButton().getX(),view.getMenuButton().getY()+view.getMenuButton().getHeight());
+            }
+        });
+    	
+        view.getClearItem().addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 clear();
             }
         });
         
-        view.getCopyButton().addActionListener(new ActionListener() {
+        view.getCopyItem().addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 copy();
             }
         });
         
-        view.getDockButton().addActionListener(new ActionListener() {
+        view.getDockItem().addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 /**
                  * Log console should be visible
@@ -162,7 +171,9 @@ public class LogConsole extends CayenneController {
             }
         });
     }
-    
+    /*public void showMenu(){
+    	view.menu
+    }*/
     /**
      * Clears the console
      */
@@ -175,7 +186,7 @@ public class LogConsole extends CayenneController {
      */
     private void appear() {
         if (!getConsoleProperty(DOCKED_PROPERTY)) {
-            view.getDockButton().setText("Dock");
+            view.getDockItem().setText("Dock");
             
             if (logWindow == null) {
                 logWindow = new LogConsoleWindow(this);
@@ -190,7 +201,7 @@ public class LogConsole extends CayenneController {
             logWindow.setVisible(true);
         }
         else {
-            view.getDockButton().setText("Undock");
+            view.getDockItem().setText("Undock");
             Application.getFrame().setDockComponent(view);
         }
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7096da31/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
index bc7dedf..20b1612 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/LogConsoleView.java
@@ -20,6 +20,9 @@ package org.apache.cayenne.modeler.dialog;
 
 import javax.swing.*;
 import javax.swing.text.JTextComponent;
+
+import org.apache.cayenne.modeler.util.ModelerUtil;
+
 import java.awt.*;
 
 /**
@@ -34,19 +37,19 @@ public class LogConsoleView extends JPanel {
     JTextComponent logView;
     
     /**
-     * Button which performs clearing the console output 
+     * Item which performs clearing the console output 
      */
-    JButton clearButton;
+    JMenuItem clearItem;
     
     /**
-     * Button which performs copying the console output 
+     * Item which performs copying the console output 
      */
-    JButton copyButton;
+    JMenuItem copyItem;
     
     /**
-     * Button which performs docking the window, i.e. sticking it to parent 
+     * Item which performs docking the window, i.e. sticking it to parent 
      */
-    JButton dockButton;
+    JMenuItem dockItem;
     
     /**
      * Scrollpane containing the text area
@@ -54,6 +57,16 @@ public class LogConsoleView extends JPanel {
     JScrollPane scroller;
     
     /**
+     * PopupMenu to choose item 
+     */
+    JPopupMenu menu;
+    
+    /**
+     * Button which performs showing PopupMenu
+     */
+    JButton menuButton;
+    
+    /**
      * Constructs a new log console view component
      */
     public LogConsoleView() {
@@ -75,16 +88,24 @@ public class LogConsoleView extends JPanel {
         scroller = new JScrollPane(logView);
         add(scroller, BorderLayout.CENTER);
         
-        JPanel buttonsPane = new JPanel();
+        JToolBar buttonsBar = new JToolBar();
+        buttonsBar.setFloatable(false);
+        
+        menu = new JPopupMenu();
+        copyItem = new JMenuItem("Copy");
+        menu.add(copyItem);
+        clearItem = new JMenuItem("Clear");
+        menu.add(clearItem);
+        dockItem = new JMenuItem("Dock");
+        menu.add(dockItem);
         
-        copyButton = new JButton("Copy");
-        clearButton = new JButton("Clear");
-        dockButton = new JButton("Dock");
+        menu.setInvoker(this);
+
+        Icon icon = ModelerUtil.buildIcon("popupmenu.gif");
+        menuButton = new JButton(icon);
         
-        buttonsPane.add(clearButton);
-        buttonsPane.add(copyButton);
-        buttonsPane.add(dockButton);
-        add(buttonsPane, BorderLayout.SOUTH);
+        buttonsBar.add(menuButton);
+        add(buttonsBar, BorderLayout.NORTH);
         
         //no need to center log window
         setLocation(100, 100);
@@ -97,19 +118,27 @@ public class LogConsoleView extends JPanel {
         return logView;
     }
     
-    protected AbstractButton getCopyButton() {
-        return copyButton;
+    protected JMenuItem getCopyItem() {
+        return copyItem;
     }
     
-    protected AbstractButton getClearButton() {
-        return clearButton;
+    protected JMenuItem getClearItem() {
+        return clearItem;
     }
     
-    protected AbstractButton getDockButton() {
-        return dockButton;
+    protected JMenuItem getDockItem() {
+        return dockItem;
     }
     
     protected JScrollPane getScroller() {
         return scroller;
     }
+    
+    protected AbstractButton getMenuButton() {
+        return menuButton;
+    }
+    
+    protected JPopupMenu getMenu() {
+        return menu;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7096da31/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/popupmenu.gif
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/popupmenu.gif
b/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/popupmenu.gif
new file mode 100644
index 0000000..c544297
Binary files /dev/null and b/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/popupmenu.gif
differ


Mime
View raw message