Browse Source

Add addaccount dialog

Make all path references absolute so they work from a jar
master
Chris Smith 15 years ago
parent
commit
66e682b952

+ 15
- 0
build.xml View File

@@ -78,4 +78,19 @@
78 78
             <arg value="git-describe --tags >build/classes/uk/co/md87/evetool/version.txt"/>
79 79
         </exec>
80 80
     </target>
81
+
82
+    <target name="-post-jar">
83
+        <jar destfile="dist/evetool.jar" compress="${jar.compress}" update="true">
84
+<!-- derby.jar  jaxen-core.jar  jaxen-jdom.jar  jdom.jar  miglayout-3.6.2.jar  saxpath.jar  xalan.jar  xerces.jar  xml-apis.jar -->
85
+            <zipfileset src="dist/lib/derby.jar" includes="**/*.class,META-INF/services/**,**/*.properties"/>
86
+            <zipfileset src="dist/lib/jaxen-core.jar" includes="**/*.class,**/*.properties"/>
87
+            <zipfileset src="dist/lib/jaxen-jdom.jar" includes="**/*.class,**/*.properties"/>
88
+            <zipfileset src="dist/lib/jdom.jar" includes="**/*.class,**/*.properties"/>
89
+            <zipfileset src="dist/lib/miglayout-3.6.2.jar" includes="**/*.class,**/*.properties"/>
90
+            <zipfileset src="dist/lib/saxpath.jar" includes="**/*.class,**/*.properties"/>
91
+            <zipfileset src="dist/lib/xalan.jar" includes="**/*.class,**/*.properties"/>
92
+            <zipfileset src="dist/lib/xerces.jar" includes="**/*.class,**/*.properties"/>
93
+            <zipfileset src="dist/lib/xml-apis.jar" includes="**/*.class,**/*.properties"/>
94
+        </jar>
95
+    </target>
81 96
 </project>

+ 2
- 3
nbproject/project.properties View File

@@ -30,7 +30,7 @@ file.reference.xalan.jar=lib/xalan.jar
30 30
 file.reference.xerces.jar=lib/xerces.jar
31 31
 file.reference.xml-apis.jar=lib/xml-apis.jar
32 32
 includes=**
33
-jar.compress=false
33
+jar.compress=true
34 34
 javac.classpath=\
35 35
     ${file.reference.jaxen-core.jar}:\
36 36
     ${file.reference.jaxen-jdom.jar}:\
@@ -74,8 +74,7 @@ run.classpath=\
74 74
 run.jvmargs=
75 75
 run.test.classpath=\
76 76
     ${javac.test.classpath}:\
77
-    ${build.test.classes.dir}:\
78
-    
77
+    ${build.test.classes.dir}
79 78
 source.encoding=UTF-8
80 79
 src.dir=src
81 80
 test.src.dir=test

+ 0
- 7
src/uk/co/md87/evetool/Main.java View File

@@ -57,13 +57,6 @@ public class Main {
57 57
         initTables();
58 58
 
59 59
         final AccountManager manager = new AccountManager(ApiFactory.getConnection());
60
-
61
-        if (manager.getAccounts().isEmpty()) {
62
-            // TODO: Remove me before release!
63
-
64
-            manager.addAccount(403848,
65
-                    "yaISaqXrSnaQPnRSFi4ODeWjSzWu2gNq1h6F0tVevtSGr5dzoEkZ6YrzHeBzzgNg");
66
-        }
67 60
         
68 61
         new MainWindow(manager, new ApiFactory()).setVisible(true);
69 62
     }

+ 1
- 1
src/uk/co/md87/evetool/api/EveApi.java View File

@@ -85,7 +85,7 @@ public class EveApi implements Cloneable {
85 85
         this.conn = sqlConnection;
86 86
 
87 87
         if (!checkedTables) {
88
-            new TableCreator(conn, "../db/", TABLES).checkTables();
88
+            new TableCreator(conn, "/uk/co/md87/evetool/api/db/", TABLES).checkTables();
89 89
             checkedTables = true;
90 90
         }
91 91
 

+ 2
- 1
src/uk/co/md87/evetool/ui/components/AddButton.java View File

@@ -57,7 +57,8 @@ public class AddButton extends JButton {
57 57
         setForeground(Color.WHITE);
58 58
 
59 59
         try {
60
-            setIcon(new ImageIcon(ImageIO.read(getClass().getResource("../res/plus.png"))));
60
+            setIcon(new ImageIcon(ImageIO.read(getClass()
61
+                    .getResource("/uk/co/md87/evetool/ui/res/plus.png"))));
61 62
         } catch (IOException ex) {
62 63
             // TODO: Do something with ex
63 64
         }

+ 2
- 1
src/uk/co/md87/evetool/ui/components/FilterButton.java View File

@@ -57,7 +57,8 @@ public class FilterButton extends JButton {
57 57
         setForeground(Color.WHITE);
58 58
 
59 59
         try {
60
-            setIcon(new ImageIcon(ImageIO.read(getClass().getResource("../res/filter.png"))));
60
+            setIcon(new ImageIcon(ImageIO.read(getClass()
61
+                    .getResource("/uk/co/md87/evetool/ui/res/filter.png"))));
61 62
         } catch (IOException ex) {
62 63
             // TODO: Do something with ex
63 64
         }

+ 8
- 4
src/uk/co/md87/evetool/ui/components/SkillPanel.java View File

@@ -54,13 +54,17 @@ public class SkillPanel extends JPanel {
54 54
 
55 55
     static {
56 56
         try {
57
-            completeImage = ImageIO.read(SkillPanel.class.getResource("../res/icon50_14.png"))
57
+            completeImage = ImageIO.read(SkillPanel.class
58
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_14.png"))
58 59
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
59
-            trainingImage = ImageIO.read(SkillPanel.class.getResource("../res/icon50_12.png"))
60
+            trainingImage = ImageIO.read(SkillPanel.class
61
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_12.png"))
60 62
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
61
-            normalImage = ImageIO.read(SkillPanel.class.getResource("../res/icon50_13.png"))
63
+            normalImage = ImageIO.read(SkillPanel.class
64
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_13.png"))
62 65
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
63
-            untrainedImage = ImageIO.read(SkillPanel.class.getResource("../res/icon50_11.png"))
66
+            untrainedImage = ImageIO.read(SkillPanel.class
67
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_11.png"))
64 68
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
65 69
         } catch (IOException ex) {
66 70
             // Do nothing

+ 2
- 1
src/uk/co/md87/evetool/ui/data/AccountChar.java View File

@@ -79,7 +79,8 @@ public class AccountChar extends ListableImpl {
79 79
             this.balance.setText(String.format("%,.2f", sheet.getResult().getBalance()));
80 80
 
81 81
             if (sheet.getResult().getSkillPoints() > sheet.getResult().getClone().getSpLimit()) {
82
-                name.setIcon(new ImageIcon(getClass().getResource("../res/error.png")));
82
+                name.setIcon(new ImageIcon(getClass()
83
+                        .getResource("/uk/co/md87/evetool/ui/res/error.png")));
83 84
                 name.setToolTipText(
84 85
                         String.format("Character's clone is %,d SP too low",
85 86
                         sheet.getResult().getSkillPoints()

+ 4
- 4
src/uk/co/md87/evetool/ui/data/TrainedSkillInfoSurrogate.java View File

@@ -27,16 +27,16 @@ public class TrainedSkillInfoSurrogate extends ListableImpl {
27 27
     static {
28 28
         try {
29 29
             completeImage = ImageIO.read(TrainedSkillInfoSurrogate.class
30
-                    .getResource("../res/icon50_14.png"))
30
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_14.png"))
31 31
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
32 32
             trainingImage = ImageIO.read(TrainedSkillInfoSurrogate.class
33
-                    .getResource("../res/icon50_12.png"))
33
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_12.png"))
34 34
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
35 35
             normalImage = ImageIO.read(TrainedSkillInfoSurrogate.class
36
-                    .getResource("../res/icon50_13.png"))
36
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_13.png"))
37 37
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
38 38
             untrainedImage = ImageIO.read(TrainedSkillInfoSurrogate.class
39
-                    .getResource("../res/icon50_11.png"))
39
+                    .getResource("/uk/co/md87/evetool/ui/res/icon50_11.png"))
40 40
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
41 41
         } catch (IOException ex) {
42 42
             // Do nothing

+ 99
- 0
src/uk/co/md87/evetool/ui/dialogs/addaccount/AddAccountDialog.java View File

@@ -0,0 +1,99 @@
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.dialogs.addaccount;
24
+
25
+import java.awt.Window;
26
+import java.awt.event.ActionEvent;
27
+import java.awt.event.ActionListener;
28
+import javax.swing.JButton;
29
+import javax.swing.JDialog;
30
+import javax.swing.JLabel;
31
+import javax.swing.JTextField;
32
+import net.miginfocom.swing.MigLayout;
33
+import uk.co.md87.evetool.AccountManager;
34
+
35
+/**
36
+ * Allows the user to add a new account.
37
+ * 
38
+ * @author chris
39
+ */
40
+public class AddAccountDialog extends JDialog implements ActionListener {
41
+
42
+    /**
43
+     * A version number for this class. It should be changed whenever the class
44
+     * structure is changed (or anything else that would prevent serialized
45
+     * objects being unserialized with the new class).
46
+     */
47
+    private static final long serialVersionUID = 10;
48
+
49
+    private final JTextField userID, apiKey;
50
+
51
+    private final JButton addButton, cancelButton;
52
+
53
+    private final AccountManager manager;
54
+
55
+    public AddAccountDialog(final Window owner, final AccountManager manager) {
56
+        super(owner, "Add new account", ModalityType.APPLICATION_MODAL);
57
+
58
+        this.manager = manager;
59
+
60
+        setLayout(new MigLayout("wrap 2, fill", "[fill,grow 10|fill,grow 30,200]", "[fill]"));
61
+
62
+        userID = new JTextField();
63
+        apiKey = new JTextField();
64
+
65
+        add(new JLabel("User ID:", JLabel.RIGHT));
66
+        add(userID);
67
+
68
+        add(new JLabel("API Key:", JLabel.RIGHT));
69
+        add(apiKey);
70
+
71
+        addButton = new JButton("Add");
72
+        cancelButton = new JButton("Cancel");
73
+
74
+        addButton.addActionListener(this);
75
+        cancelButton.addActionListener(this);
76
+
77
+        add(addButton, "span, split");
78
+        add(cancelButton);
79
+
80
+        setResizable(false);
81
+        pack();
82
+
83
+        setLocationRelativeTo(owner);
84
+    }
85
+
86
+    public void actionPerformed(final ActionEvent e) {
87
+        if (e.getSource() == addButton) {
88
+            final int enteredUserID = Integer.parseInt(userID.getText());
89
+            final String enteredKey = apiKey.getText();
90
+
91
+            manager.addAccount(enteredUserID, enteredKey);
92
+
93
+            dispose();
94
+        } else if (e.getSource() == cancelButton) {
95
+            dispose();
96
+        }
97
+    }
98
+
99
+}

+ 19
- 9
src/uk/co/md87/evetool/ui/pages/OverviewPage.java View File

@@ -55,6 +55,7 @@ import uk.co.md87.evetool.ui.MainWindow;
55 55
 import uk.co.md87.evetool.ui.components.AddButton;
56 56
 import uk.co.md87.evetool.ui.components.FilterButton;
57 57
 import uk.co.md87.evetool.ui.data.AccountChar;
58
+import uk.co.md87.evetool.ui.dialogs.addaccount.AddAccountDialog;
58 59
 import uk.co.md87.evetool.ui.workers.AccountUpdateWorker;
59 60
 
60 61
 /**
@@ -74,6 +75,7 @@ public class OverviewPage extends Page implements AccountManager.AccountListener
74 75
 
75 76
     private final MainWindow window;
76 77
     private final ApiFactory factory;
78
+    private final AccountManager manager;
77 79
     private final Map<Account, EveApi> apis = new HashMap<Account, EveApi>();
78 80
     private final Map<Account, JPanel> panels = new HashMap<Account, JPanel>();
79 81
     private final List<AccountChar> chars = new ArrayList<AccountChar>();
@@ -82,6 +84,7 @@ public class OverviewPage extends Page implements AccountManager.AccountListener
82 84
             final ApiFactory factory) {
83 85
         this.window = window;
84 86
         this.factory = factory;
87
+        this.manager = manager;
85 88
 
86 89
         setLayout(new MigLayout("fillx"));
87 90
 
@@ -118,18 +121,18 @@ public class OverviewPage extends Page implements AccountManager.AccountListener
118 121
         headerP.add(header, "growx");
119 122
 
120 123
         try {
121
-            final JButton editButton = new JButton(new ImageIcon(ImageIO
122
-                    .read(getClass().getResource("../res/edit-inactive.png"))));
124
+            final JButton editButton = new JButton(new ImageIcon(ImageIO.read(
125
+                    getClass().getResource("/uk/co/md87/evetool/ui/res/edit-inactive.png"))));
123 126
             editButton.setRolloverIcon(new ImageIcon(ImageIO
124
-                    .read(getClass().getResource("../res/edit.png"))));
127
+                    .read(getClass().getResource("/uk/co/md87/evetool/ui/res/edit.png"))));
125 128
             editButton.setBorder(BorderFactory.createEmptyBorder());
126 129
             editButton.setOpaque(false);
127 130
             editButton.setContentAreaFilled(false);
128 131
 
129
-            final JButton delButton = new JButton(new ImageIcon(ImageIO
130
-                    .read(getClass().getResource("../res/close-inactive.png"))));
131
-            delButton.setRolloverIcon(new ImageIcon(ImageIO
132
-                    .read(getClass().getResource("../res/close-active.png"))));
132
+            final JButton delButton = new JButton(new ImageIcon(ImageIO.read(
133
+                    getClass().getResource("/uk/co/md87/evetool/ui/res/close-inactive.png"))));
134
+            delButton.setRolloverIcon(new ImageIcon(ImageIO.read(
135
+                    getClass().getResource("/uk/co/md87/evetool/ui/res/close-active.png"))));
133 136
             delButton.setBorder(BorderFactory.createEmptyBorder());
134 137
             delButton.setOpaque(false);
135 138
             delButton.setContentAreaFilled(false);
@@ -169,7 +172,11 @@ public class OverviewPage extends Page implements AccountManager.AccountListener
169 172
     /** {@inheritDoc} */
170 173
     @Override
171 174
     public void actionPerformed(final ActionEvent e) {
172
-        updateCharacters();
175
+        if (e.getSource() instanceof AddButton) {
176
+            new AddAccountDialog(window, manager).setVisible(true);
177
+        } else {
178
+            updateCharacters();
179
+        }
173 180
     }
174 181
 
175 182
     @Override
@@ -179,7 +186,10 @@ public class OverviewPage extends Page implements AccountManager.AccountListener
179 186
 
180 187
     @Override
181 188
     public void activated(final ContextPanel context) {
182
-        context.add(new AddButton("Add account"), "growy");
189
+        final AddButton addButton = new AddButton("Add account");
190
+        addButton.addActionListener(this);
191
+        
192
+        context.add(addButton, "growy");
183 193
         context.add(new FilterButton(), "growy, al right");
184 194
     }
185 195
 

Loading…
Cancel
Save