cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [2/3] cayenne git commit: Modeler new Welcome screen
Date Tue, 06 Dec 2016 07:23:06 GMT
Modeler new Welcome screen


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

Branch: refs/heads/master
Commit: 32399f9a26ae46e8afcf7ae63fa4613f36578f84
Parents: 0ce3fdf
Author: stariy <stariy95@gmail.com>
Authored: Fri Dec 2 21:53:44 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Tue Dec 6 10:22:46 2016 +0300

----------------------------------------------------------------------
 .../modeler/CayenneModelerController.java       |   2 +-
 .../modeler/dialog/welcome/WelcomeScreen.java   | 109 ++++++-------------
 .../cayenne/modeler/util/BackgroundPanel.java   |  47 ++++++++
 3 files changed, 84 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/32399f9a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
index 30fdebc..bda0504 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
@@ -137,7 +137,7 @@ public class CayenneModelerController extends CayenneController {
         });
 
         ComponentGeometry geometry = new ComponentGeometry(frame.getClass(), null);
-        geometry.bind(frame, 650, 550, 0);
+        geometry.bind(frame, 1200, 720, 0);
     }
 
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/32399f9a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/welcome/WelcomeScreen.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/welcome/WelcomeScreen.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/welcome/WelcomeScreen.java
index f51e3d4..21793a6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/welcome/WelcomeScreen.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/welcome/WelcomeScreen.java
@@ -19,14 +19,12 @@
 
 package org.apache.cayenne.modeler.dialog.welcome;
 
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Graphics;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.io.File;
 import java.util.List;
 
+import javax.swing.Action;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
@@ -38,6 +36,7 @@ import org.apache.cayenne.modeler.ModelerPreferences;
 import org.apache.cayenne.modeler.action.NewProjectAction;
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.event.RecentFileListListener;
+import org.apache.cayenne.modeler.util.BackgroundPanel;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 
 /**
@@ -49,18 +48,16 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
     /**
      * List of recent projects
      */
-    private JList<String> recentsList;
+    private JList<String> recentProjectsList;
 
-    private JPanel buttonsPane;
-
-    private JPanel fileListPane;
+    private JPanel buttonsPanel;
 
     public WelcomeScreen() {
         initView();
     }
 
     /**
-     * Creates all neccesary components
+     * Creates all necessary components
      */
     protected void initView() {
         setLayout(new GridBagLayout());
@@ -69,78 +66,45 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
     }
 
     private void initFileListPane() {
-        final ImageIcon rightPaneImg = ModelerUtil.buildIcon("welcome/welcome-screen-right-bg.jpg");
-        fileListPane = new JPanel(null) {
-            @Override
-            protected void paintComponent(Graphics g) {
-                super.paintComponent(g);
-                g.drawImage(rightPaneImg.getImage(), 0, 0, null);
-            }
-        };
-        fileListPane.setPreferredSize(new Dimension(902, 592));
-        fileListPane.setOpaque(false);
-
-        initRecentList();
-
-        add(fileListPane);
+        JPanel fileListPanel = new BackgroundPanel("welcome/welcome-screen-right-bg.jpg");
+
+        final int padding = 20;
+        recentProjectsList = new JList<>();
+        recentProjectsList.setOpaque(false);
+        recentProjectsList.setLocation(padding, padding);
+        recentProjectsList.setSize(
+                fileListPanel.getWidth() - 2 * padding,
+                fileListPanel.getHeight() - 2 * padding
+        );
+        recentProjectsList.setCellRenderer(new RecentFileListRenderer(recentProjectsList,
this));
+
+        fileListPanel.add(recentProjectsList);
+        add(fileListPanel);
     }
 
     private void initButtonsPane() {
-        final ImageIcon leftPaneImg = ModelerUtil.buildIcon("welcome/welcome-screen-left-bg.jpg");
-        buttonsPane = new JPanel(null) {
-            @Override
-            protected void paintComponent(Graphics g) {
-                super.paintComponent(g);
-                g.drawImage(leftPaneImg.getImage(), 0, 0, null);
-            }
-        };
-        buttonsPane.setPreferredSize(new Dimension(198, 592));
-        buttonsPane.setOpaque(false);
-
-        initNewButton();
-        initOpenButton();
-
-        add(buttonsPane);
-    }
+        final int padding = 24; // bottom padding for buttons
+        final int buttonHeight = 36;
 
+        buttonsPanel = new BackgroundPanel("welcome/welcome-screen-left-bg.jpg");
+        int openButtonY = buttonsPanel.getHeight() - padding - buttonHeight; // buttons layout
from bottom
+        int newButtonY = openButtonY - 10 - buttonHeight; // 10px - space between buttons
+        initButton("open", openButtonY, OpenProjectAction.class);
+        initButton("new", newButtonY, NewProjectAction.class);
 
-    private void initNewButton() {
-        ImageIcon newIcon = ModelerUtil.buildIcon("welcome/welcome-screen-new-btn.png");
-        ImageIcon newHoverIcon = ModelerUtil.buildIcon("welcome/welcome-screen-new-btn-hover.png");
-        JButton newButton = createButton(newIcon, newHoverIcon);
-        newButton.setLocation(24, 488);
-        newButton.addActionListener(Application
-                .getInstance()
-                .getActionManager()
-                .getAction(NewProjectAction.class));
-        buttonsPane.add(newButton);
+        add(buttonsPanel);
     }
 
-    private void initOpenButton() {
-        ImageIcon newIcon = ModelerUtil.buildIcon("welcome/welcome-screen-open-btn.png");
-        ImageIcon newHoverIcon = ModelerUtil.buildIcon("welcome/welcome-screen-open-btn-hover.png");
-        JButton openButton = createButton(newIcon, newHoverIcon);
-        openButton.setLocation(24, 532);
-        openButton.addActionListener(Application
+    private void initButton(String name, int y,  Class<? extends Action> actionClass)
{
+        ImageIcon icon = ModelerUtil.buildIcon("welcome/welcome-screen-"+name+"-btn.png");
+        ImageIcon hoverIcon = ModelerUtil.buildIcon("welcome/welcome-screen-"+name+"-btn-hover.png");
+        JButton button = createButton(icon, hoverIcon);
+        button.setLocation(24, y); // 24px - button left & right padding
+        button.addActionListener(Application
                 .getInstance()
                 .getActionManager()
-                .getAction(NewProjectAction.class));
-        buttonsPane.add(openButton);
-    }
-
-    private void initRecentList() {
-        recentsList = new JList<>();
-        recentsList.setOpaque(false);
-        int padding = 20;
-        recentsList.setLocation(padding, padding);
-        recentsList.setSize(902 - 2 * padding, 592 - 2 * padding);
-        Font fontOld = recentsList.getFont();
-        Font font = new Font(fontOld.getFontName(), Font.PLAIN, 12);
-        recentsList.setFont(font);
-//        recentsList.setFixedCellHeight(24);
-        RecentFileListRenderer cellRenderer = new RecentFileListRenderer(recentsList, this);
-        recentsList.setCellRenderer(cellRenderer);
-        fileListPane.add(recentsList);
+                .getAction(actionClass));
+        buttonsPanel.add(button);
     }
 
     @Override
@@ -178,7 +142,6 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
     @Override
     public void recentFileListChanged() {
         List<String> arr = ModelerPreferences.getLastProjFiles();
-        recentsList.setModel(new RecentFileListModel(arr));
+        recentProjectsList.setModel(new RecentFileListModel(arr));
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/32399f9a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/BackgroundPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/BackgroundPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/BackgroundPanel.java
new file mode 100644
index 0000000..fe14b84
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/BackgroundPanel.java
@@ -0,0 +1,47 @@
+/*****************************************************************
+ *   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 javax.swing.ImageIcon;
+import javax.swing.JPanel;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+public class BackgroundPanel extends JPanel {
+
+    private Image backgroundImage;
+
+    public BackgroundPanel(String imagePath) {
+        super(null);
+        ImageIcon imageIcon = ModelerUtil.buildIcon(imagePath);
+        backgroundImage = imageIcon.getImage();
+        Dimension dimension = new Dimension(imageIcon.getIconWidth(), imageIcon.getIconHeight());
+        setSize(dimension);
+        setPreferredSize(dimension);
+        setOpaque(false);
+    }
+
+    @Override
+    protected void paintComponent(Graphics g) {
+        super.paintComponent(g);
+        g.drawImage(backgroundImage, 0, 0, null);
+    }
+}


Mime
View raw message