cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/3] cayenne git commit: New welcome screen design
Date Tue, 06 Dec 2016 07:23:05 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 263ac1c9e -> 77c59c75e


New welcome screen design


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

Branch: refs/heads/master
Commit: 77c59c75e018715bbc7594a71e3dc22b936d978e
Parents: 32399f9
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Mon Dec 5 11:16:24 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Tue Dec 6 10:22:46 2016 +0300

----------------------------------------------------------------------
 .../modeler/dialog/welcome/WelcomeScreen.java   | 37 +++++++++++++++++---
 .../cayenne/modeler/pref/ComponentGeometry.java | 18 +++++-----
 2 files changed, 42 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/77c59c75/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 21793a6..b9598b7 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,7 +19,12 @@
 
 package org.apache.cayenne.modeler.dialog.welcome;
 
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
 import java.awt.GridBagLayout;
+import java.awt.Paint;
 import java.awt.event.ActionEvent;
 import java.io.File;
 import java.util.List;
@@ -30,6 +35,7 @@ import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JList;
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
 
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ModelerPreferences;
@@ -43,7 +49,17 @@ import org.apache.cayenne.modeler.util.ModelerUtil;
  * Welcome screen (CAY-894) is a panel shown when no project is open. User can quickly
  * create new project or open an existing one.
  */
-public class WelcomeScreen extends JPanel implements RecentFileListListener, RecentFileListRenderer.OnFileClickListener
{
+public class WelcomeScreen extends JScrollPane implements RecentFileListListener, RecentFileListRenderer.OnFileClickListener
{
+
+    /**
+     * Top color of gradient background
+     */
+    private static final Color TOP_GRADIENT = new Color(153, 153, 153);
+
+    /**
+     * Bottom color of gradient background
+     */
+    private static final Color BOTTOM_GRADIENT = new Color(230, 230, 230);
 
     /**
      * List of recent projects
@@ -52,6 +68,8 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
 
     private JPanel buttonsPanel;
 
+    private JPanel mainPanel;
+
     public WelcomeScreen() {
         initView();
     }
@@ -60,9 +78,20 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
      * Creates all necessary components
      */
     protected void initView() {
-        setLayout(new GridBagLayout());
+        mainPanel = new JPanel(new GridBagLayout()) {
+            @Override
+            public void paintComponent(Graphics g) {
+                // paint gradient background
+                Graphics2D g2 = (Graphics2D) g.create();
+                Paint paint = new GradientPaint(0, 0, TOP_GRADIENT, 0, getHeight(), BOTTOM_GRADIENT);
+                g2.setPaint(paint);
+                g2.fillRect(0, 0, getWidth(), getHeight());
+                g2.dispose();
+            }
+        };
         initButtonsPane();
         initFileListPane();
+        setViewportView(mainPanel);
     }
 
     private void initFileListPane() {
@@ -79,7 +108,7 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
         recentProjectsList.setCellRenderer(new RecentFileListRenderer(recentProjectsList,
this));
 
         fileListPanel.add(recentProjectsList);
-        add(fileListPanel);
+        mainPanel.add(fileListPanel);
     }
 
     private void initButtonsPane() {
@@ -92,7 +121,7 @@ public class WelcomeScreen extends JPanel implements RecentFileListListener,
Rec
         initButton("open", openButtonY, OpenProjectAction.class);
         initButton("new", newButtonY, NewProjectAction.class);
 
-        add(buttonsPanel);
+        mainPanel.add(buttonsPanel);
     }
 
     private void initButton(String name, int y,  Class<? extends Action> actionClass)
{

http://git-wip-us.apache.org/repos/asf/cayenne/blob/77c59c75/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
index 0f24f16..78b1b5a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ComponentGeometry.java
@@ -67,14 +67,14 @@ public class ComponentGeometry extends CayennePreference {
 
             @Override
             public void componentResized(ComponentEvent e) {
-                setWidth(new Integer(window.getWidth()));
-                setHeight(new Integer(window.getHeight()));
+                setWidth(window.getWidth());
+                setHeight(window.getHeight());
             }
 
             @Override
             public void componentMoved(ComponentEvent e) {
-                setX(new Integer(window.getX()));
-                setY(new Integer(window.getY()));
+                setX(window.getX());
+                setY(window.getY());
             }
         });
     }
@@ -90,8 +90,8 @@ public class ComponentGeometry extends CayennePreference {
 
             @Override
             public void componentResized(ComponentEvent e) {
-                setWidth(new Integer(window.getWidth()));
-                setHeight(new Integer(window.getHeight()));
+                setWidth(window.getWidth());
+                setHeight(window.getHeight());
             }
         });
     }
@@ -119,7 +119,7 @@ public class ComponentGeometry extends CayennePreference {
     void updateIntProperty(Component c, String property, int defaultValue) {
         int i = getPreference().getInt(property, defaultValue);
         try {
-            PropertyUtils.setProperty(c, property, new Integer(i));
+            PropertyUtils.setProperty(c, property, i);
         }
         catch (Throwable th) {
             throw new PreferenceException("Error setting property: " + property, th);
@@ -153,13 +153,13 @@ public class ComponentGeometry extends CayennePreference {
 
     public void changeX(int xOffset) {
         if (xOffset != 0) {
-            setX(new Integer(getX(0) + xOffset));
+            setX(getX(0) + xOffset);
         }
     }
 
     public void changeY(int yOffset) {
         if (yOffset != 0) {
-            setY(new Integer(getY(0) + yOffset));
+            setY(getY(0) + yOffset);
         }
     }
 


Mime
View raw message