瀏覽代碼

Add context panel and add button

master
Chris Smith 15 年之前
父節點
當前提交
5108f0c814

+ 9
- 2
src/uk/co/md87/evetool/ui/ContentPanel.java 查看文件

@@ -36,12 +36,19 @@ import uk.co.md87.evetool.ui.pages.OverviewPage;
36 36
  */
37 37
 public class ContentPanel extends JPanel {
38 38
 
39
-    public ContentPanel(final AccountManager manager, final ApiFactory factory) {
39
+    public ContentPanel(final MainWindow window, final AccountManager manager,
40
+            final ApiFactory factory) {
40 41
         super(new CardLayout());
41 42
 
42 43
         //setBackground(Color.BLUE);
43
-        add(new OverviewPage(manager, factory), "push, grow");
44
+        add(new OverviewPage(window.getContextPanel(), manager, factory), "push, grow");
44 45
         add(new JLabel("Main content2", JLabel.CENTER), "push, grow");
45 46
     }
46 47
 
48
+    public static abstract class Page extends JPanel {
49
+
50
+        // TODO: Add method for activation
51
+
52
+    }
53
+
47 54
 }

+ 43
- 0
src/uk/co/md87/evetool/ui/ContextPanel.java 查看文件

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.ui;
24
+
25
+import java.awt.Color;
26
+import javax.swing.BorderFactory;
27
+import javax.swing.JPanel;
28
+import net.miginfocom.swing.MigLayout;
29
+
30
+/**
31
+ *
32
+ * @author chris
33
+ */
34
+public class ContextPanel extends JPanel {
35
+
36
+    public ContextPanel() {
37
+        super(new MigLayout("ins 2, fill"));
38
+
39
+        setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.DARK_GRAY));
40
+        setBackground(Color.LIGHT_GRAY);
41
+    }
42
+
43
+}

+ 13
- 4
src/uk/co/md87/evetool/ui/MainWindow.java 查看文件

@@ -28,9 +28,10 @@ import java.util.logging.Level;
28 28
 import java.util.logging.Logger;
29 29
 import javax.imageio.ImageIO;
30 30
 import javax.swing.JFrame;
31
-
32 31
 import javax.swing.UIManager;
32
+
33 33
 import net.miginfocom.swing.MigLayout;
34
+
34 35
 import uk.co.md87.evetool.AccountManager;
35 36
 import uk.co.md87.evetool.ApiFactory;
36 37
 
@@ -43,6 +44,7 @@ public class MainWindow extends JFrame {
43 44
 
44 45
     private final AccountManager manager;
45 46
     private final ApiFactory factory;
47
+    private final ContextPanel contextPanel;
46 48
 
47 49
     public MainWindow(final AccountManager manager, final ApiFactory factory) {
48 50
         super("EVE Tool - Initialising...");
@@ -51,6 +53,8 @@ public class MainWindow extends JFrame {
51 53
 
52 54
         this.factory = factory;
53 55
         this.manager = manager;
56
+
57
+        this.contextPanel = new ContextPanel();
54 58
         
55 59
         setLayout(new MigLayout("insets 0, fill, wrap 2", "[]0[fill,grow]",
56 60
                 "[fill,grow]0[]"));
@@ -66,10 +70,15 @@ public class MainWindow extends JFrame {
66 70
         }
67 71
     }
68 72
 
73
+    public ContextPanel getContextPanel() {
74
+        return contextPanel;
75
+    }
76
+
69 77
     protected void addComponents() {
70
-        add(new MenuPanel(), "width 201!");
71
-        add(new ContentPanel(manager, factory));
72
-        add(new StatusPanel(), "growx, span, height 30!");
78
+        add(new MenuPanel(this), "width 201!, spany2");
79
+        add(new ContentPanel(this, manager, factory));
80
+        add(contextPanel, "growx, height 30!");
81
+        add(new StatusPanel(this), "growx, span, height 30!");
73 82
     }
74 83
 
75 84
 }

+ 1
- 1
src/uk/co/md87/evetool/ui/MenuPanel.java 查看文件

@@ -40,7 +40,7 @@ import uk.co.md87.evetool.ui.workers.PortraitLoaderWorker;
40 40
  */
41 41
 public class MenuPanel extends JPanel {
42 42
 
43
-    public MenuPanel() {
43
+    public MenuPanel(final MainWindow window) {
44 44
         super(new MigLayout("wrap 1, fillx, ins 4"));
45 45
 
46 46
         setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.DARK_GRAY));

+ 3
- 1
src/uk/co/md87/evetool/ui/StatusPanel.java 查看文件

@@ -31,6 +31,8 @@ import uk.co.md87.evetool.Main;
31 31
 
32 32
 /**
33 33
  *
34
+ * TODO: Document StatusPanel
35
+ * TODO: Annoying serialVersionUID things
34 36
  * @author chris
35 37
  */
36 38
 public class StatusPanel extends JPanel {
@@ -38,7 +40,7 @@ public class StatusPanel extends JPanel {
38 40
     private final JLabel leftLabel;
39 41
     private final JLabel rightLabel;
40 42
 
41
-    public StatusPanel() {
43
+    public StatusPanel(final MainWindow window) {
42 44
         super(new MigLayout());
43 45
 
44 46
         leftLabel = new JLabel("Welcome to EVE Tool", JLabel.LEFT);

+ 58
- 0
src/uk/co/md87/evetool/ui/components/AddButton.java 查看文件

@@ -0,0 +1,58 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package uk.co.md87.evetool.ui.components;
24
+
25
+import java.awt.Color;
26
+import java.awt.Font;
27
+import java.awt.Insets;
28
+import java.io.IOException;
29
+import javax.imageio.ImageIO;
30
+import javax.swing.BorderFactory;
31
+import javax.swing.ImageIcon;
32
+import javax.swing.JButton;
33
+
34
+/**
35
+ *
36
+ * @author chris
37
+ */
38
+public class AddButton extends JButton {
39
+
40
+    public AddButton(final String text) {
41
+        super(text);
42
+
43
+        setBorder(BorderFactory.createCompoundBorder(
44
+                BorderFactory.createLineBorder(Color.DARK_GRAY),
45
+                BorderFactory.createEmptyBorder(0, 0, 0, 5)));
46
+        setBackground(Color.GREEN.darker().darker());
47
+        setForeground(Color.WHITE);
48
+        setIconTextGap(2);
49
+        //setFont(getFont().deriveFont(Font.BOLD));
50
+
51
+        try {
52
+            setIcon(new ImageIcon(ImageIO.read(getClass().getResource("../res/icon25_11.png"))));
53
+        } catch (IOException ex) {
54
+            // TODO: Do something with ex
55
+        }
56
+    }
57
+
58
+}

+ 8
- 2
src/uk/co/md87/evetool/ui/pages/OverviewPage.java 查看文件

@@ -35,6 +35,9 @@ import uk.co.md87.evetool.Account;
35 35
 import uk.co.md87.evetool.AccountManager;
36 36
 import uk.co.md87.evetool.ApiFactory;
37 37
 import uk.co.md87.evetool.api.EveApi;
38
+import uk.co.md87.evetool.ui.ContentPanel.Page;
39
+import uk.co.md87.evetool.ui.ContextPanel;
40
+import uk.co.md87.evetool.ui.components.AddButton;
38 41
 import uk.co.md87.evetool.ui.workers.AccountUpdateWorker;
39 42
 
40 43
 /**
@@ -42,13 +45,14 @@ import uk.co.md87.evetool.ui.workers.AccountUpdateWorker;
42 45
  * TODO: Document OverviewPage
43 46
  * @author chris
44 47
  */
45
-public class OverviewPage extends JPanel implements AccountManager.AccountListener {
48
+public class OverviewPage extends Page implements AccountManager.AccountListener {
46 49
 
47 50
     private final ApiFactory factory;
48 51
     private final Map<Account, EveApi> apis = new HashMap<Account, EveApi>();
49 52
     private final Map<Account, JPanel> panels = new HashMap<Account, JPanel>();
50 53
 
51
-    public OverviewPage(final AccountManager manager, final ApiFactory factory) {
54
+    public OverviewPage(final ContextPanel context, final AccountManager manager,
55
+            final ApiFactory factory) {
52 56
         this.factory = factory;
53 57
 
54 58
         setLayout(new MigLayout("fillx"));
@@ -56,6 +60,8 @@ public class OverviewPage extends JPanel implements AccountManager.AccountListen
56 60
         for (Account account : manager.getAccounts(this)) {
57 61
             addAccount(account);
58 62
         }
63
+
64
+        context.add(new AddButton("Add account"), "growy");
59 65
     }
60 66
 
61 67
     protected void addAccount(final Account account) {

二進制
src/uk/co/md87/evetool/ui/res/icon25_11.png 查看文件


Loading…
取消
儲存