• R/O
  • SSH
  • HTTPS

chaplet: Commit


Commit MetaInfo

Revision29 (tree)
Time2007-06-22 00:44:34
Authorkoe

Log Message

LocalStorageに未登録時に、自動的に登録するように修正
ダイスプラグインを削除

Change Summary

Incremental Difference

--- chaplet/trunk/src/dice/jp/sf/chaplet/dice/server/DiceServerPlugin.java (revision 28)
+++ chaplet/trunk/src/dice/jp/sf/chaplet/dice/server/DiceServerPlugin.java (nonexistent)
@@ -1,33 +0,0 @@
1-/* DiceServerPlugin.java
2- * 作成日: 2004/09/20
3- */
4-package jp.sf.chaplet.dice.server;
5-
6-import jp.sf.chaplet.core.server.RollAction;
7-import jp.sf.chaplet.core.server.ServerPlugin;
8-
9-/**
10- * ダイス機能を提供するサーバ側プラグイン。<br>
11- *
12- * @author koe
13- * @version $Id$
14- */
15-public class DiceServerPlugin extends ServerPlugin {
16- /**
17- * @see jp.sourceforge.chaplet.core.server.ServerPlugin#getPluginId()
18- */
19- public String getPluginId() {
20- return "jp.sourceforge.chaplet.dice";
21- }
22-
23- /**
24- * @see jp.sourceforge.chaplet.core.server.ServerPlugin#init()
25- */
26- public void init() throws Exception {
27- {
28- RollAction action = new RollAction();
29- action.init(server, this);
30- addAction("dice:roll", action);
31- }
32- }
33-}
Deleted: svn:keywords
## -1 +0,0 ##
-" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/dice/jp/sf/chaplet/dice/ui/DiceView.java (revision 28)
+++ chaplet/trunk/src/dice/jp/sf/chaplet/dice/ui/DiceView.java (nonexistent)
@@ -1,387 +0,0 @@
1-/**
2- *
3- */
4-package jp.sf.chaplet.dice.ui;
5-
6-import java.awt.Color;
7-import java.awt.Font;
8-import java.awt.GridBagConstraints;
9-import java.awt.GridBagLayout;
10-import java.awt.Insets;
11-
12-import javax.swing.BorderFactory;
13-import javax.swing.JButton;
14-import javax.swing.JComboBox;
15-import javax.swing.JLabel;
16-import javax.swing.JPanel;
17-import javax.swing.JRadioButton;
18-import javax.swing.JScrollPane;
19-import javax.swing.JSpinner;
20-import javax.swing.JTextField;
21-import javax.swing.border.TitledBorder;
22-import javax.swing.ButtonGroup;
23-
24-import jp.sf.chaplet.core.client.ClientPlugin;
25-import jp.sf.chaplet.core.ui.IPluginView;
26-import javax.swing.JList;
27-import javax.swing.JToggleButton;
28-
29-/**
30- * DiceView<br>
31- * @version $Id$
32- */
33-public class DiceView extends JPanel implements IPluginView{
34-
35- private static final long serialVersionUID = 1L;
36- private JTextField formulaText = null;
37- private JSpinner bonusSpinner = null;
38- private JScrollPane scroll2Pane = null;
39- private JButton rollButton = null;
40- private JButton addFormulaButton = null;
41- private JButton removeFormulaButton = null;
42- private JPanel evalRulePanel = null;
43- private JRadioButton addRuleButton = null;
44- private JRadioButton countRuleButton = null;
45- private JSpinner countRuleSpinner = null;
46- private JComboBox countRuleComboBox = null;
47- private ButtonGroup diceRuleGroup = null; // @jve:decl-index=0:visual-constraint="371,20"
48- private JLabel jLabel = null;
49- private JList historyList = null;
50- private JToggleButton hideButton = null;
51- /**
52- * This is the default constructor
53- */
54- public DiceView() {
55- super();
56- initialize();
57- getDiceRuleGroup();
58- }
59-
60- /**
61- * This method initializes this
62- *
63- * @return void
64- */
65- private void initialize() {
66- GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
67- gridBagConstraints2.gridx = 1;
68- gridBagConstraints2.gridwidth = 2;
69- gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
70- gridBagConstraints2.insets = new Insets(2, 5, 2, 5);
71- gridBagConstraints2.gridy = 2;
72- GridBagConstraints gridBagConstraints110 = new GridBagConstraints();
73- gridBagConstraints110.gridx = 1;
74- gridBagConstraints110.gridy = 0;
75- jLabel = new JLabel();
76- jLabel.setText("+");
77- GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
78- gridBagConstraints10.gridx = 0;
79- gridBagConstraints10.gridwidth = 5;
80- gridBagConstraints10.fill = GridBagConstraints.BOTH;
81- gridBagConstraints10.gridy = 7;
82- GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
83- gridBagConstraints9.gridx = 1;
84- gridBagConstraints9.gridwidth = 2;
85- gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
86- gridBagConstraints9.insets = new Insets(2, 5, 2, 5);
87- gridBagConstraints9.gridy = 4;
88- GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
89- gridBagConstraints8.gridx = 1;
90- gridBagConstraints8.gridwidth = 2;
91- gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL;
92- gridBagConstraints8.insets = new Insets(2, 5, 2, 5);
93- gridBagConstraints8.gridy = 3;
94- GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
95- gridBagConstraints6.gridx = 1;
96- gridBagConstraints6.gridwidth = 2;
97- gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
98- gridBagConstraints6.insets = new Insets(2, 5, 2, 5);
99- gridBagConstraints6.gridy = 1;
100- GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
101- gridBagConstraints5.fill = GridBagConstraints.BOTH;
102- gridBagConstraints5.gridy = 1;
103- gridBagConstraints5.weightx = 1.0;
104- gridBagConstraints5.weighty = 1.0;
105- gridBagConstraints5.gridheight = 6;
106- gridBagConstraints5.gridx = 0;
107- GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
108- gridBagConstraints1.gridx = 2;
109- gridBagConstraints1.weightx = 1.0;
110- gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
111- gridBagConstraints1.insets = new Insets(0, 2, 2, 2);
112- gridBagConstraints1.gridy = 0;
113- GridBagConstraints gridBagConstraints = new GridBagConstraints();
114- gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
115- gridBagConstraints.gridy = 0;
116- gridBagConstraints.weightx = 40.0;
117- gridBagConstraints.insets = new Insets(0, 0, 2, 2);
118- gridBagConstraints.gridx = 0;
119- this.setSize(352, 304);
120- this.setLayout(new GridBagLayout());
121- this.add(getFormulaText(), gridBagConstraints);
122- this.add(getBonusSpinner(), gridBagConstraints1);
123- this.add(getScroll2Pane(), gridBagConstraints5);
124- this.add(getRollButton(), gridBagConstraints6);
125- this.add(getAddFormulaButton(), gridBagConstraints8);
126- this.add(getRemoveFormulaButton(), gridBagConstraints9);
127- this.add(getEvalRulePanel(), gridBagConstraints10);
128- this.add(jLabel, gridBagConstraints110);
129- this.add(getHideButton(), gridBagConstraints2);
130- }
131-
132- /**
133- * This method initializes formulaText
134- *
135- * @return javax.swing.JTextField
136- */
137- private JTextField getFormulaText() {
138- if (formulaText == null) {
139- formulaText = new JTextField();
140- }
141- return formulaText;
142- }
143-
144- /**
145- * This method initializes bonusSpinner
146- *
147- * @return javax.swing.JSpinner
148- */
149- private JSpinner getBonusSpinner() {
150- if (bonusSpinner == null) {
151- bonusSpinner = new JSpinner();
152- }
153- return bonusSpinner;
154- }
155-
156- /**
157- * This method initializes scroll2Pane
158- *
159- * @return javax.swing.JScrollPane
160- */
161- private JScrollPane getScroll2Pane() {
162- if (scroll2Pane == null) {
163- scroll2Pane = new JScrollPane();
164- scroll2Pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
165- scroll2Pane.setViewportView(getHistoryList());
166- }
167- return scroll2Pane;
168- }
169-
170- /**
171- * This method initializes rollButton
172- *
173- * @return javax.swing.JButton
174- */
175- private JButton getRollButton() {
176- if (rollButton == null) {
177- rollButton = new JButton();
178- rollButton.setText("振る");
179- }
180- return rollButton;
181- }
182-
183- /**
184- * This method initializes addFormulaButton
185- *
186- * @return javax.swing.JButton
187- */
188- private JButton getAddFormulaButton() {
189- if (addFormulaButton == null) {
190- addFormulaButton = new JButton();
191- addFormulaButton.setText("登録");
192- }
193- return addFormulaButton;
194- }
195-
196- /**
197- * This method initializes removeFormulaButton
198- *
199- * @return javax.swing.JButton
200- */
201- private JButton getRemoveFormulaButton() {
202- if (removeFormulaButton == null) {
203- removeFormulaButton = new JButton();
204- removeFormulaButton.setText("削除");
205- }
206- return removeFormulaButton;
207- }
208-
209- /**
210- * This method initializes evalRulePanel
211- *
212- * @return javax.swing.JPanel
213- */
214- private JPanel getEvalRulePanel() {
215- if (evalRulePanel == null) {
216- GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
217- gridBagConstraints23.fill = GridBagConstraints.HORIZONTAL;
218- gridBagConstraints23.gridy = 0;
219- gridBagConstraints23.weightx = 10.0;
220- gridBagConstraints23.gridx = 3;
221- GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
222- gridBagConstraints22.gridx = 2;
223- gridBagConstraints22.weightx = 5.0;
224- gridBagConstraints22.fill = GridBagConstraints.HORIZONTAL;
225- gridBagConstraints22.gridy = 0;
226- GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
227- gridBagConstraints20.gridx = 1;
228- gridBagConstraints20.weightx = 20.0;
229- gridBagConstraints20.anchor = GridBagConstraints.WEST;
230- gridBagConstraints20.gridy = 0;
231- GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
232- gridBagConstraints19.gridx = 0;
233- gridBagConstraints19.weightx = 20.0;
234- gridBagConstraints19.anchor = GridBagConstraints.WEST;
235- gridBagConstraints19.gridy = 0;
236- evalRulePanel = new JPanel();
237- evalRulePanel.setLayout(new GridBagLayout());
238- evalRulePanel.setBorder(BorderFactory.createTitledBorder(null, "\u30c0\u30a4\u30b9\u306e\u76ee", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("MS UI Gothic", Font.PLAIN, 12), Color.black));
239- evalRulePanel.add(getAddRuleButton(), gridBagConstraints19);
240- evalRulePanel.add(getCountRuleButton(), gridBagConstraints20);
241- evalRulePanel.add(getCountRuleSpinner(), gridBagConstraints22);
242- evalRulePanel.add(getCountRuleComboBox(), gridBagConstraints23);
243- }
244- return evalRulePanel;
245- }
246-
247- /**
248- * This method initializes addRuleButton
249- *
250- * @return javax.swing.JRadioButton
251- */
252- private JRadioButton getAddRuleButton() {
253- if (addRuleButton == null) {
254- addRuleButton = new JRadioButton();
255- addRuleButton.setText("合計する");
256- }
257- return addRuleButton;
258- }
259-
260- /**
261- * This method initializes countRuleButton
262- *
263- * @return javax.swing.JRadioButton
264- */
265- private JRadioButton getCountRuleButton() {
266- if (countRuleButton == null) {
267- countRuleButton = new JRadioButton();
268- countRuleButton.setText("カウントする");
269- }
270- return countRuleButton;
271- }
272-
273- /**
274- * This method initializes countRuleSpinner
275- *
276- * @return javax.swing.JSpinner
277- */
278- private JSpinner getCountRuleSpinner() {
279- if (countRuleSpinner == null) {
280- countRuleSpinner = new JSpinner();
281- countRuleSpinner.setValue(6);
282- }
283- return countRuleSpinner;
284- }
285-
286- /**
287- * This method initializes countRuleComboBox
288- *
289- * @return javax.swing.JComboBox
290- */
291- private JComboBox getCountRuleComboBox() {
292- if (countRuleComboBox == null) {
293- countRuleComboBox = new JComboBox();
294- countRuleComboBox.addItem("以上");
295- countRuleComboBox.addItem("以下");
296- }
297- return countRuleComboBox;
298- }
299-
300- /**
301- * This method initializes diceRuleGroup
302- *
303- * @return javax.swing.ButtonGroup
304- */
305- private ButtonGroup getDiceRuleGroup() {
306- if (diceRuleGroup == null) {
307- diceRuleGroup = new ButtonGroup();
308- diceRuleGroup.add(getAddRuleButton());
309- diceRuleGroup.add(getCountRuleButton());
310- }
311- return diceRuleGroup;
312- }
313-
314- /**
315- * @see jp.sf.chaplet.core.ui.IPluginView#getPluginId()
316- */
317- public String getPluginId() {
318- // TODO 自動生成されたメソッド・スタブ
319- return null;
320- }
321-
322- /**
323- * @see jp.sf.chaplet.core.ui.IPluginView#getPluginName()
324- */
325- public String getPluginName() {
326- // TODO 自動生成されたメソッド・スタブ
327- return null;
328- }
329-
330- /**
331- * @see jp.sf.chaplet.core.ui.IPluginView#getSwingComponent()
332- */
333- public JPanel getSwingComponent() {
334- // TODO 自動生成されたメソッド・スタブ
335- return null;
336- }
337-
338- /**
339- * @see jp.sf.chaplet.core.ui.IPluginView#setController(jp.sf.chaplet.core.client.ClientPlugin)
340- */
341- public void setController(ClientPlugin ctl) {
342- // TODO 自動生成されたメソッド・スタブ
343-
344- }
345-
346- /**
347- * @see jp.sf.chaplet.core.ui.IPluginView#setGM(boolean)
348- */
349- public void setGM(boolean gm) {
350- // TODO 自動生成されたメソッド・スタブ
351-
352- }
353-
354- /**
355- * @see jp.sf.chaplet.core.ui.IPluginView#setLoginOK(boolean)
356- */
357- public void setLoginOK(boolean ok) {
358- // TODO 自動生成されたメソッド・スタブ
359-
360- }
361-
362- /**
363- * This method initializes historyList
364- *
365- * @return javax.swing.JList
366- */
367- private JList getHistoryList() {
368- if (historyList == null) {
369- historyList = new JList();
370- }
371- return historyList;
372- }
373-
374- /**
375- * This method initializes hideButton
376- *
377- * @return javax.swing.JToggleButton
378- */
379- private JToggleButton getHideButton() {
380- if (hideButton == null) {
381- hideButton = new JToggleButton();
382- hideButton.setText("非表示");
383- }
384- return hideButton;
385- }
386-
387-} // @jve:decl-index=0:visual-constraint="10,10"
Deleted: svn:keywords
## -1 +0,0 ##
-" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/dice/jp/sf/chaplet/dice/ui/IDiceView.java (revision 28)
+++ chaplet/trunk/src/dice/jp/sf/chaplet/dice/ui/IDiceView.java (nonexistent)
@@ -1,34 +0,0 @@
1-/* IDiceView.java
2- * 作成日: 2004/09/20
3- */
4-package jp.sf.chaplet.dice.ui;
5-
6-import jp.sf.chaplet.core.ui.IPluginView;
7-
8-/**
9- * IDiceView<br>
10- *
11- * @author koe
12- * @version $Id$
13- */
14-public interface IDiceView extends IPluginView{
15-
16- /**
17- * ダイスを振った結果をセットする。
18- * @param result 結果 result[0]は今回の合計、result[1]は前回の数値、それ以降は個々のダイスの値
19- * @param isRerole 振り足しした場合true
20- */
21- void setRoleResult(String[] result, boolean isRerole);
22-
23- /**
24- * 初期状態で表示されるダイスの規則を設定する。
25- * @param rules 規則
26- */
27- void setDiceRule(String[] rules);
28-
29- /**
30- * 現在表示中のダイスの規則を返す。
31- * @param rules 規則
32- */
33- String[] getDiceRule();
34-}
Deleted: svn:keywords
## -1 +0,0 ##
-" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/dice/jp/sf/chaplet/dice/client/DiceClientPlugin.java (revision 28)
+++ chaplet/trunk/src/dice/jp/sf/chaplet/dice/client/DiceClientPlugin.java (nonexistent)
@@ -1,181 +0,0 @@
1-/* DiceClientPlugin.java
2- * 作成日: 2004/09/20
3- */
4-package jp.sf.chaplet.dice.client;
5-
6-import java.text.ParseException;
7-import java.util.ArrayList;
8-import java.util.Iterator;
9-import java.util.Properties;
10-
11-import javax.swing.JPanel;
12-
13-import application.Action;
14-
15-import jp.sf.chaplet.ConfigLoader;
16-import jp.sf.chaplet.DiceManager;
17-import jp.sf.chaplet.StorageUtils;
18-import jp.sf.chaplet.core.client.ClientPlugin;
19-import jp.sf.chaplet.core.client.Handle;
20-import jp.sf.chaplet.core.client.RollAction;
21-import jp.sf.chaplet.core.ui.IPluginView;
22-import jp.sf.chaplet.dice.ui.DiceView;
23-
24-/**
25- * DiceClientPlugin<br>
26- *
27- * @author koe
28- * @version $Id$
29- */
30-public class DiceClientPlugin extends ClientPlugin {
31- private DiceView form;
32-
33- /**
34- * @see application.Application#startup()
35- */
36- @Override
37- protected void startup() {
38- {
39- RollAction action = new RollAction();
40- action.init(getController(), this);
41- addAction("dice:roll", action);
42- }
43- }
44-
45- /**
46- * @see jp.sf.chaplet.core.client.ClientPlugin#initSWT(org.eclipse.swt.widgets.Composite)
47- */
48- public JPanel initSwing(JPanel parent) {
49- form = new DiceView();
50- form.setVisible(false);
51- parent.add(form);
52-// form.setController(this);
53- ArrayList<String> ruleList = new ArrayList<String>();
54- String ruleKey = getPluginId() + ".rule";
55- Properties properties = ConfigLoader.getInstance().load().getProperties();
56- for(Iterator iter = properties.keySet().iterator(); iter.hasNext();){
57- String key = (String) iter.next();
58- if(key.startsWith(ruleKey)){
59- String rule = properties.getProperty(key);
60- ruleList.add(rule);
61- }
62- }
63-// form.setDiceRule((String[]) ruleList.toArray(new String[ruleList.size()]));
64- return form;
65- }
66-
67- /**
68- * @see jp.sf.chaplet.core.client.ClientPlugin#destroy()
69- */
70- public void destroy() {
71-// String[] rules = form.getDiceRule();
72-// String ruleKey = getPluginId() + ".rule";
73-// Configuration conf = ConfigLoader.getInstance().load();
74-// Properties properties = conf.getProperties();
75-// for (int i = 0; i < rules.length; i++) {
76-// properties.setProperty(ruleKey + "." + i, rules[i]);
77-// }
78- }
79-//
80-// /**
81-// * @see jp.sf.chaplet.core.client.ClientPlugin#getPluginView()
82-// */
83-// public IPluginView getPluginView() {
84-// return form;
85-// }
86-
87- public JPanel getSwingComponent(){
88- return form;
89- }
90-
91- /**
92- * @see jp.sf.chaplet.core.client.ClientPlugin#getPluginId()
93- */
94- public String getPluginId() {
95- return "jp.sf.chaplet.dice";
96- }
97-
98- @Action
99- public void rollSum(String rule, int bonus, int prevValue, int numRerole, boolean hidden){
100- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
101- int[] result = null;
102- try {
103- result = DiceManager.getInstance().rollSum(rule, bonus, numRerole);
104- } catch (ParseException e) {
105- getConnection().sendMessage(new String[]{"dice:role",
106- rule + "=評価できません", handle.getName()});
107- return;
108- }
109-
110- StringBuilder sb = new StringBuilder(rule);
111- if(bonus != 0){
112- if(bonus > 0){
113- sb.append('+');
114- }
115- sb.append(bonus);
116- }
117- sb.append('=');
118- sb.append('(');
119- int sum = bonus;
120- for (int i = 0; i < result.length; i++) {
121- sb.append(result[i]);
122- sb.append('+');
123- sum += result[i];
124- }
125- if(result.length > 0){
126- sb.deleteCharAt(sb.length() - 1);
127- }
128- sb.append(')');
129- if(bonus != 0){
130- if(bonus > 0){
131- sb.append('+');
132- }
133- sb.append(bonus);
134- }
135- sb.append('=');
136- sb.append(sum);
137-
138- String exp = sb.toString();
139- getController().getView().appendFunctionLog("ダイス", handle.getName(), exp);
140- getConnection().sendMessage(new String[]{"dice:role", exp, handle.getName()});
141- }
142-
143- @Action
144- public void rollCount(String rule, int target, boolean upperRole, int prevValue, int numRerole, boolean hidden){
145- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
146- int[] result = null;
147- try {
148- result = DiceManager.getInstance().roleCount(rule, target, upperRole, numRerole);
149- } catch (ParseException e) {
150- getConnection().sendMessage(new String[]{"dice:roll",
151- rule + "=評価できません", handle.getName()});
152- return;
153- }
154-
155- StringBuilder sb = new StringBuilder(rule);
156- sb.append('=');
157- sb.append('[');
158- int sum = 0;
159- for (int i = 0; i < result.length; i++) {
160- sb.append(result[i]);
161- sb.append(',');
162- if(result[i] >= target){
163- sum ++;
164- }
165- }
166- if(result.length > 0){
167- sb.deleteCharAt(sb.length() - 1);
168- }
169- sb.append(']');
170- sb.append('=');
171- sb.append(sum);
172-
173- String exp = sb.toString();
174- getController().getView().appendFunctionLog("ダイス", handle.getName(), exp);
175- getConnection().sendMessage(new String[]{"dice:roll", exp, handle.getName()});
176- }
177-
178- public IPluginView getPluginView(){
179- return form;
180- }
181-}
Deleted: svn:keywords
## -1 +0,0 ##
-" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/NovaServerPlugin.java (revision 28)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/server/NovaServerPlugin.java (revision 29)
@@ -7,6 +7,7 @@
77 import java.util.Map;
88 import java.util.logging.Level;
99
10+import jp.sf.chaplet.StorageUtils;
1011 import jp.sf.chaplet.core.server.ClientProxy;
1112 import jp.sf.chaplet.core.server.ServerAction;
1213 import jp.sf.chaplet.core.server.ServerPlugin;
@@ -42,7 +43,7 @@
4243 * @see jp.sf.chaplet.core.server.ServerPlugin#reload()
4344 */
4445 public void reload() throws Exception{
45- NovaConfig config = NovaConfig.getInstance();
46+ NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class);
4647 tarotManager.setConfig(config);
4748 cardManager.setNumDeck(config.getNumDeck());
4849 cardManager.setNumJoker(config.getNumJoker());
@@ -90,7 +91,7 @@
9091 addAction("nova:exchange", actions[12]);
9192 addAction("nova:init", actions[13]);
9293
93- NovaConfig config = NovaConfig.getInstance();
94+ NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class);
9495 tarotManager.setConfig(config);
9596 cardManager.setNumDeck(config.getNumDeck());
9697 cardManager.setNumJoker(config.getNumJoker());
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/NovaConfig.java (revision 28)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/NovaConfig.java (revision 29)
@@ -3,7 +3,6 @@
33 */
44 package jp.sf.chaplet.nova;
55
6-import jp.sf.chaplet.StorageUtils;
76
87 /**
98 * NovaConfig<br>
@@ -25,15 +24,6 @@
2524
2625 private boolean ayakashiEnabled;
2726
28- public static NovaConfig getInstance(){
29- NovaConfig config = (NovaConfig) StorageUtils.load(NAME);
30- if(config == null){
31- config = new NovaConfig();
32- StorageUtils.save(config, NAME);
33- }
34- return config;
35- }
36-
3727 public boolean isArashiEnabled() {
3828 return arashiEnabled;
3929 }
--- chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/BasicPrefPanel.java (revision 28)
+++ chaplet/trunk/src/nova/jp/sf/chaplet/nova/ui/BasicPrefPanel.java (revision 29)
@@ -45,7 +45,7 @@
4545 public BasicPrefPanel() {
4646 super();
4747 initialize();
48- NovaConfig config = NovaConfig.getInstance();
48+ NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class);
4949 getNumDeckModel().setValue(config.getNumDeck());
5050 getNumJokerModel().setValue(config.getNumJoker());
5151 getHirukoRadio().setSelected(config.isHirukoEnabled());
@@ -269,7 +269,7 @@
269269 * @see jp.sf.chaplet.core.ui.IPrefView#save()
270270 */
271271 public void save() {
272- NovaConfig config = NovaConfig.getInstance();
272+ NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class);
273273 config.setNumDeck((Integer) getNumDeckModel().getValue());
274274 config.setNumJoker((Integer) getNumJokerModel().getValue());
275275 config.setHirukoEnabled(getHirukoRadio().isSelected());
--- chaplet/trunk/src/core/jp/sf/chaplet/StorageUtils.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/StorageUtils.java (revision 29)
@@ -3,6 +3,7 @@
33 */
44 package jp.sf.chaplet;
55
6+import java.beans.Beans;
67 import java.io.File;
78 import java.io.IOException;
89 import java.util.HashMap;
@@ -31,7 +32,20 @@
3132 }
3233 }
3334
34- public static final Object load(String name){
35+ public static final Object load(String name, Class theClass){
36+ Object obj = load(name);
37+ if(obj == null){
38+ try {
39+ obj = Beans.instantiate(StorageUtils.class.getClassLoader(), theClass.getName());
40+ } catch (Exception e) {
41+ Logger.getLogger(StorageUtils.class.getName()).log(Level.SEVERE, e.getMessage(), e);
42+ return null;
43+ }
44+ }
45+ return obj;
46+ }
47+
48+ static final Object load(String name){
3549 LocalStorage localStorage = ApplicationContext.getInstance().getLocalStorage();
3650 try {
3751 return localStorage.load(prefix == null ? name : prefix + "-" + name);
--- chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/server/ChatServer.java (revision 29)
@@ -413,7 +413,7 @@
413413 */
414414 @SuppressWarnings("unchecked")
415415 public void load(String fileName){
416- HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) StorageUtils.load(StorageUtils.SERVER);
416+ HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) StorageUtils.load(StorageUtils.SERVER, HashMap.class);
417417 HashMap<String, Object> coreMap = map.get("core");
418418 userManager.setAllUsers((User[])coreMap.get("users"));
419419 for (String key : pluginMap.keySet()) {
--- chaplet/trunk/src/core/jp/sf/chaplet/core/ui/ConnectDialog.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/ui/ConnectDialog.java (revision 29)
@@ -88,20 +88,20 @@
8888 this.setSize(335, 200);
8989 this.setTitle("接続設定");
9090 this.setContentPane(getJContentPane());
91- addressList = (List<ServerAddress>) StorageUtils.load("server.xml");
92- if(addressList == null){
91+ addressList = (List<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class);
92+ if(addressList == null || addressList.size() == 0){
9393 addressList = new ArrayList<ServerAddress>();
94- } else {
95- for (ServerAddress address : addressList) {
96- getHistoryListModel().addElement(address);
97- }
98- if(addressList.size() > 0){
99- ServerAddress address = addressList.get(0);
100- getServerText().setText(address.getHost());
101- getPortText().setText(String.valueOf(address.getPort()));
102- getPortText().setValue(address.getPort());
103- }
94+ addressList.add(new ServerAddress("127.0.0.1", 10001));
10495 }
96+ for (ServerAddress address : addressList) {
97+ getHistoryListModel().addElement(address);
98+ }
99+ if(addressList.size() > 0){
100+ ServerAddress address = addressList.get(0);
101+ getServerText().setText(address.getHost());
102+ getPortText().setText(String.valueOf(address.getPort()));
103+ getPortText().setValue(address.getPort());
104+ }
105105 }
106106
107107 /**
--- chaplet/trunk/src/core/jp/sf/chaplet/core/ui/SelectFontDialog.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/ui/SelectFontDialog.java (revision 29)
@@ -94,12 +94,7 @@
9494 this.setTitle("フォント");
9595 this.setContentPane(getJContentPane());
9696 HashMap<String, Object> fontMap = null;
97- fontMap = (HashMap<String, Object>) StorageUtils.load("font.xml");
98- if(fontMap == null){
99- fontMap = new HashMap<String, Object>();
100- fontMap.put("fontName", "MS ゴシック");
101- fontMap.put("fontSize", Integer.valueOf(10));
102- }
97+ fontMap = (HashMap<String, Object>) StorageUtils.getFontMap();
10398 fontNameList.setSelectedValue(fontMap.get("fontName"), true);
10499 fontSizeList.setSelectedValue(fontMap.get("fontSize"), true);
105100 }
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/LoginAction.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/LoginAction.java (revision 29)
@@ -23,10 +23,10 @@
2323 @SuppressWarnings("unchecked")
2424 public ActionResult responseRecieved(String[] response) {
2525 ConfigLoader.getInstance().load().setGM(response.length > 3);
26- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
26+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
2727 appendSystemLog(handle.getName() + " さんがログインしました。");
2828 ArrayList<ServerAddress> serverList =
29- (ArrayList<ServerAddress>) StorageUtils.load("server.xml");
29+ (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class);
3030 if(serverList.size() > 0){
3131 ServerAddress address = serverList.get(0);
3232 address.setSessionId(response[1]);
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/ServerAddress.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/ServerAddress.java (revision 29)
@@ -14,6 +14,14 @@
1414 /** ポート番号 */
1515 private int port;
1616
17+ public ServerAddress(){}
18+
19+ public ServerAddress(String host, int port) {
20+ super();
21+ this.host = host;
22+ this.port = port;
23+ }
24+
1725 private String sessionId;
1826 /**
1927 * @return host
--- chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 28)
+++ chaplet/trunk/src/core/jp/sf/chaplet/core/client/ChatClient.java (revision 29)
@@ -152,7 +152,7 @@
152152 view.setVisible(true);
153153 view.setLoginOK(false);
154154
155- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
155+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
156156 if(handle != null){
157157 view.getHandleText().setText(handle.getName());
158158 view.getAliasComboModel().addAll(handle.getAliasList());
@@ -455,7 +455,7 @@
455455 @Action
456456 synchronized public void login() {
457457 ArrayList<ServerAddress> serverList = null;
458- serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml");
458+ serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class);
459459 if (serverList.size() == 0) {
460460 view.setMessage("接続失敗です。先にサーバのアドレスを指定してください。");
461461 return;
@@ -573,7 +573,7 @@
573573 public void startServer() {
574574 ArrayList<ServerAddress> serverList = null;
575575 ServerAddress address = null;
576- serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml");
576+ serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class);
577577 if(serverList == null){
578578 return;
579579 }
@@ -666,7 +666,7 @@
666666 public void rollSum(){
667667 String rule = view.getDiceCombo().getSelectedItem().toString();
668668 int bonus = (Integer) view.getDiceBonusSpinner().getValue();
669- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
669+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
670670 int[] result = null;
671671 try {
672672 result = DiceManager.getInstance().rollSum(rule, bonus, -1);
--- chaplet/trunk/src/dx/jp/sf/chaplet/dx/client/DxClientPlugin.java (revision 28)
+++ chaplet/trunk/src/dx/jp/sf/chaplet/dx/client/DxClientPlugin.java (revision 29)
@@ -70,12 +70,12 @@
7070 view = new DxView();
7171 view.setController(this);
7272
73- ArrayList<Lois> loisList = (ArrayList<Lois>) StorageUtils.load(STRAGE_LOIS);
73+ ArrayList<Lois> loisList = (ArrayList<Lois>) StorageUtils.load(STRAGE_LOIS, ArrayList.class);
7474 if(loisList != null && loisList.size() > 0){
7575 view.getLoisTableModel().setAll(loisList);
7676 }
7777
78- DxCharacter character = (DxCharacter) StorageUtils.load(STRAGE_CHARA);
78+ DxCharacter character = (DxCharacter) StorageUtils.load(STRAGE_CHARA, DxCharacter.class);
7979 if(character != null){
8080 view.getHpSpinner().setValue(character.getHp());
8181 view.getInvasionSpinner().setValue(character.getInvasion());
@@ -97,7 +97,7 @@
9797
9898 @Action
9999 public void rollSum(){
100- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
100+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
101101 int numDice = (Integer)view.getDiceSpinner().getValue();
102102 int bonus = (Integer)view.getBonusSpinner().getValue();
103103 int critical = (Integer) view.getCriticalSpinner().getValue();
@@ -117,7 +117,7 @@
117117
118118 @Action
119119 public void rollDamage(){
120- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
120+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
121121 int numDice = (Integer)view.getDiceSpinner().getValue();
122122 int bonus = (Integer)view.getBonusSpinner().getValue();
123123 DiceRoll roll = new DiceRoll(numDice, bonus, 0);
@@ -148,7 +148,7 @@
148148
149149 @Action
150150 public void roll1d(){
151- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
151+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
152152 DiceRoll roll = new DiceRoll(1, 0, 0);
153153 DiceResult result = DiceRoller.getInstance().rollDamage(roll);
154154 view.getHistoryComboModel().add(roll);
@@ -164,7 +164,7 @@
164164
165165 @Action
166166 public void roll2d(){
167- Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE);
167+ Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class);
168168 DiceRoll roll = new DiceRoll(2, 0, 0);
169169 DiceResult result = DiceRoller.getInstance().rollDamage(roll);
170170 view.getHistoryComboModel().add(roll);
Show on old repository browser