浏览代码

Add addaccount dialog

Make all path references absolute so they work from a jar
master
Chris Smith 15 年前
父节点
当前提交
66e682b952

+ 15
- 0
build.xml 查看文件

78
             <arg value="git-describe --tags >build/classes/uk/co/md87/evetool/version.txt"/>
78
             <arg value="git-describe --tags >build/classes/uk/co/md87/evetool/version.txt"/>
79
         </exec>
79
         </exec>
80
     </target>
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
 </project>
96
 </project>

+ 2
- 3
nbproject/project.properties 查看文件

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

+ 0
- 7
src/uk/co/md87/evetool/Main.java 查看文件

57
         initTables();
57
         initTables();
58
 
58
 
59
         final AccountManager manager = new AccountManager(ApiFactory.getConnection());
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
         new MainWindow(manager, new ApiFactory()).setVisible(true);
61
         new MainWindow(manager, new ApiFactory()).setVisible(true);
69
     }
62
     }

+ 1
- 1
src/uk/co/md87/evetool/api/EveApi.java 查看文件

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

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

57
         setForeground(Color.WHITE);
57
         setForeground(Color.WHITE);
58
 
58
 
59
         try {
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
         } catch (IOException ex) {
62
         } catch (IOException ex) {
62
             // TODO: Do something with ex
63
             // TODO: Do something with ex
63
         }
64
         }

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

57
         setForeground(Color.WHITE);
57
         setForeground(Color.WHITE);
58
 
58
 
59
         try {
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
         } catch (IOException ex) {
62
         } catch (IOException ex) {
62
             // TODO: Do something with ex
63
             // TODO: Do something with ex
63
         }
64
         }

+ 8
- 4
src/uk/co/md87/evetool/ui/components/SkillPanel.java 查看文件

54
 
54
 
55
     static {
55
     static {
56
         try {
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
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
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
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
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
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
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
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
68
                     .getScaledInstance(48, 48, Image.SCALE_SMOOTH);
65
         } catch (IOException ex) {
69
         } catch (IOException ex) {
66
             // Do nothing
70
             // Do nothing

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

79
             this.balance.setText(String.format("%,.2f", sheet.getResult().getBalance()));
79
             this.balance.setText(String.format("%,.2f", sheet.getResult().getBalance()));
80
 
80
 
81
             if (sheet.getResult().getSkillPoints() > sheet.getResult().getClone().getSpLimit()) {
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
                 name.setToolTipText(
84
                 name.setToolTipText(
84
                         String.format("Character's clone is %,d SP too low",
85
                         String.format("Character's clone is %,d SP too low",
85
                         sheet.getResult().getSkillPoints()
86
                         sheet.getResult().getSkillPoints()

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

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

+ 99
- 0
src/uk/co/md87/evetool/ui/dialogs/addaccount/AddAccountDialog.java 查看文件

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 查看文件

55
 import uk.co.md87.evetool.ui.components.AddButton;
55
 import uk.co.md87.evetool.ui.components.AddButton;
56
 import uk.co.md87.evetool.ui.components.FilterButton;
56
 import uk.co.md87.evetool.ui.components.FilterButton;
57
 import uk.co.md87.evetool.ui.data.AccountChar;
57
 import uk.co.md87.evetool.ui.data.AccountChar;
58
+import uk.co.md87.evetool.ui.dialogs.addaccount.AddAccountDialog;
58
 import uk.co.md87.evetool.ui.workers.AccountUpdateWorker;
59
 import uk.co.md87.evetool.ui.workers.AccountUpdateWorker;
59
 
60
 
60
 /**
61
 /**
74
 
75
 
75
     private final MainWindow window;
76
     private final MainWindow window;
76
     private final ApiFactory factory;
77
     private final ApiFactory factory;
78
+    private final AccountManager manager;
77
     private final Map<Account, EveApi> apis = new HashMap<Account, EveApi>();
79
     private final Map<Account, EveApi> apis = new HashMap<Account, EveApi>();
78
     private final Map<Account, JPanel> panels = new HashMap<Account, JPanel>();
80
     private final Map<Account, JPanel> panels = new HashMap<Account, JPanel>();
79
     private final List<AccountChar> chars = new ArrayList<AccountChar>();
81
     private final List<AccountChar> chars = new ArrayList<AccountChar>();
82
             final ApiFactory factory) {
84
             final ApiFactory factory) {
83
         this.window = window;
85
         this.window = window;
84
         this.factory = factory;
86
         this.factory = factory;
87
+        this.manager = manager;
85
 
88
 
86
         setLayout(new MigLayout("fillx"));
89
         setLayout(new MigLayout("fillx"));
87
 
90
 
118
         headerP.add(header, "growx");
121
         headerP.add(header, "growx");
119
 
122
 
120
         try {
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
             editButton.setRolloverIcon(new ImageIcon(ImageIO
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
             editButton.setBorder(BorderFactory.createEmptyBorder());
128
             editButton.setBorder(BorderFactory.createEmptyBorder());
126
             editButton.setOpaque(false);
129
             editButton.setOpaque(false);
127
             editButton.setContentAreaFilled(false);
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
             delButton.setBorder(BorderFactory.createEmptyBorder());
136
             delButton.setBorder(BorderFactory.createEmptyBorder());
134
             delButton.setOpaque(false);
137
             delButton.setOpaque(false);
135
             delButton.setContentAreaFilled(false);
138
             delButton.setContentAreaFilled(false);
169
     /** {@inheritDoc} */
172
     /** {@inheritDoc} */
170
     @Override
173
     @Override
171
     public void actionPerformed(final ActionEvent e) {
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
     @Override
182
     @Override
179
 
186
 
180
     @Override
187
     @Override
181
     public void activated(final ContextPanel context) {
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
         context.add(new FilterButton(), "growy, al right");
193
         context.add(new FilterButton(), "growy, al right");
184
     }
194
     }
185
 
195
 

正在加载...
取消
保存