• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Moxkiriyaプロジェクト事前開発用の作業部屋


Commit MetaInfo

修订版1eca5bde109e935aacaa39fe7b674a548d4ea528 (tree)
时间2018-10-08 12:46:23
作者Harold_Andoh <andolloyd@gmai...>
CommiterHarold_Andoh

Log Message

[Moxkiriya7]

  • SelectPartyダイアログからPartyを追加する機能を追加
    *
    resourceファイルのパスの指定間違いでNullPointerExceptionとなっていたバグを修正

更改概述

差异

--- a/src/com/wiki/standalone/moxkiriya/Main.java
+++ b/src/com/wiki/standalone/moxkiriya/Main.java
@@ -114,7 +114,7 @@ public class Main extends Application {
114114 /*
115115 * 外部リンクアイコン画像をApprootにアップロードする。
116116 */
117- wikiMainWindow_.uploadResourcefile(appRoot + "/" + "icon/Icon_External_Link.png");
117+ wikiMainWindow_.uploadResourcefile(appRoot + "/", "icon/Icon_External_Link.png");
118118
119119 closeType = wikiMainWindow_.show();
120120 }
--- a/src/com/wiki/standalone/moxkiriya/SettingManager.java
+++ b/src/com/wiki/standalone/moxkiriya/SettingManager.java
@@ -189,9 +189,14 @@ public class SettingManager {
189189 */
190190 public Hashtable<String, String> loadConfigSettings(String path, String partyName) throws Exception {
191191 Hashtable<String, String> settingsTable = new Hashtable<String, String>();
192+
193+ File partyDir = new File(path + "/" + partyName);
194+ if( (partyDir.exists() != true)
195+ && (partyDir.isDirectory() != true)) {
196+ partyDir.mkdirs();
197+ }
192198
193- File inifile = new File(path
194- + "/" + partyName
199+ File inifile = new File(partyDir.getAbsolutePath()
195200 + "/" + SettingManager.CONFIG_FILENAME);
196201 if (inifile.exists() != true) {
197202 /*
--- a/src/com/wiki/standalone/moxkiriya/WikiMainWindow.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiMainWindow.java
@@ -101,9 +101,11 @@ public class WikiMainWindow {
101101 public void buildWikiMainTree(File wikirootPath) throws Exception {
102102 createCssFiles();
103103
104- uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.FIXED_STYLESHEET_FILENAME));
104+ uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.FIXED_STYLESHEET_FILENAME),
105+ WikiEngine.FIXED_STYLESHEET_FILENAME);
105106
106- uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.DEFAULT_STYLESHEET_FILENAME));
107+ uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.DEFAULT_STYLESHEET_FILENAME),
108+ WikiEngine.DEFAULT_STYLESHEET_FILENAME);
107109
108110 createRepositoryConfig();
109111 wikiEngine_ = new WikiEngine();
@@ -116,12 +118,11 @@ public class WikiMainWindow {
116118 * @param filename
117119 * @throws IOException
118120 */
119- public void uploadResourcefile(String absolutePath) throws IOException {
121+ public void uploadResourcefile(String absolutePath, String filename) throws IOException {
120122 File destFile = new File(absolutePath);
121- String filename = destFile.getName();
122123
123124 if (destFile.exists() != true) {
124- InputStream in = getClass().getResourceAsStream("resources/icon/" + filename);
125+ InputStream in = getClass().getResourceAsStream("resources/" + filename);
125126 Path destPath = Paths.get(absolutePath);
126127 Files.createDirectories(destPath.getParent());
127128 Files.copy(in, destPath);
--- a/src/com/wiki/standalone/moxkiriya/dialog/ConfigSettingsDialog.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/ConfigSettingsDialog.java
@@ -77,4 +77,12 @@ public class ConfigSettingsDialog extends DialogBase {
7777 return ((ConfigSettingsDialogController)controller_).getDefaultPartyCheckValue();
7878 }
7979
80+ /**
81+ * Party name getter.
82+ * @return String
83+ */
84+ public String getPartyName() {
85+ return ((ConfigSettingsDialogController)controller_).getPartyName();
86+ }
87+
8088 }
\ No newline at end of file
--- a/src/com/wiki/standalone/moxkiriya/dialog/ConfigSettingsDialogController.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/ConfigSettingsDialogController.java
@@ -265,4 +265,12 @@ public class ConfigSettingsDialogController extends DialogControllerBase {
265265 public boolean getDefaultPartyCheckValue() {
266266 return checkBoxDefaultParty.isSelected();
267267 }
268+
269+ /**
270+ * Party name getter.
271+ * @return String
272+ */
273+ public String getPartyName() {
274+ return textFieldPartyName.getText();
275+ }
268276 }
--- a/src/com/wiki/standalone/moxkiriya/dialog/DialogBase.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/DialogBase.java
@@ -35,6 +35,10 @@ public abstract class DialogBase {
3535 protected Stage parentStage_;
3636
3737 /**
38+ * My stage.
39+ */
40+ protected Stage stage_;
41+ /**
3842 * シーン
3943 */
4044 Scene scene_;
@@ -107,13 +111,13 @@ public abstract class DialogBase {
107111 * @return CloseTypeダイアログの終了種別
108112 */
109113 protected CloseType show() {
110- Stage stage = new Stage();
114+ stage_ = new Stage();
111115
112- stage.initOwner(parentStage_);
113- stage.initModality(Modality.APPLICATION_MODAL);
114- stage.setScene(scene_);
115- stage.setResizable(false);
116- stage.showAndWait();
116+ stage_.initOwner(parentStage_);
117+ stage_.initModality(Modality.APPLICATION_MODAL);
118+ stage_.setScene(scene_);
119+ stage_.setResizable(false);
120+ stage_.showAndWait();
117121
118122 return getCloseType();
119123 }
--- a/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialog.fxml
+++ b/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialog.fxml
@@ -18,5 +18,6 @@
1818 </TableView>
1919 <Button fx:id="buttonOK" mnemonicParsing="false" onAction="#onActionButtonOK" prefHeight="30.0" prefWidth="100.0" text="%key.Button.OK" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="40.0" />
2020 <Button fx:id="buttonCancel" mnemonicParsing="false" onAction="#onActionButtonCancel" prefHeight="30.0" prefWidth="100.0" text="%key.Button.Cancel" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="150.0" />
21+ <Button fx:id="buttonAddNewParty" mnemonicParsing="false" onAction="#onActionButtonAddNewParty" prefHeight="30.0" prefWidth="120.0" text="%key.Button.Add.Party" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="40.0" />
2122 </children>
2223 </AnchorPane>
--- a/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialog.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialog.java
@@ -7,8 +7,6 @@
77 */
88 package com.wiki.standalone.moxkiriya.dialog;
99
10-import com.wiki.standalone.moxkiriya.dialog.DialogBase.CloseType;
11-
1210 /**
1311 * SelectPartyDialog
1412 */
--- a/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialogController.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/SelectPartyDialogController.java
@@ -47,7 +47,7 @@ public class SelectPartyDialogController extends DialogControllerBase {
4747
4848 /** Party name. */
4949 private SimpleStringProperty partyName_;
50-
50+
5151 /**
5252 * Constructor.
5353 * @param aSelect
@@ -80,6 +80,7 @@ public class SelectPartyDialogController extends DialogControllerBase {
8080 @FXML private TableColumn<PartyProperty, String> tableColumnPartyName;
8181 @FXML private Button buttonCancel;
8282 @FXML private Button buttonOK;
83+ @FXML private Button buttonAddNewParty;
8384
8485 /** Selected party name. */
8586 private String selectedParty_;
@@ -90,9 +91,9 @@ public class SelectPartyDialogController extends DialogControllerBase {
9091 /** Close type. */
9192 private DialogBase.CloseType closeType_;
9293
93- /** Parent stage */
94- private Stage parentStage_;
95-
94+ /** My stage */
95+ private Stage stage_;
96+
9697 @Override
9798 public void initialize(URL url, ResourceBundle resource) {
9899 super.initialize(url, resource);
@@ -120,17 +121,12 @@ public class SelectPartyDialogController extends DialogControllerBase {
120121 public void handle(ActionEvent event) {
121122 Hyperlink target = (Hyperlink)event.getTarget();
122123 PartyProperty partyProperty = (PartyProperty)target.getUserData();
123- ConfigSettingsDialog dialog = new ConfigSettingsDialog(partyProperty.partyName_.get());
124+ String partyName = partyProperty.partyName_.get();
124125
125126 try {
126- if(dialog.showDialog(parentStage_, SelectPartyDialogController.super.resource_) == DialogBase.CloseType.OK) {
127- SettingManager settingMgr = SettingManager.getInstance();
128- Hashtable<String, String> settingsTable = dialog.getSettingsTable();
129- String path = settingMgr.get(SettingManager.SETTINGSKEY_MOXKIRIYA_USER_DIR);
130-
131- settingMgr.putParty(partyProperty.partyName_.get(), dialog.getDefaultPartyCheckValue());
132- settingMgr.savePartyConfig(path);
133- settingMgr.saveSettingConfig(path, partyProperty.partyName_.get(), settingsTable);
127+ if(showConfigSettingsDialog(stage_, partyName) == DialogBase.CloseType.OK) {
128+ SettingManager settingMgr = SettingManager.getInstance();
129+ String path = settingMgr.get(SettingManager.SETTINGSKEY_MOXKIRIYA_USER_DIR);
134130 settingMgr.loadSettingFiles(path);
135131 }
136132 } catch (Exception e) {
@@ -154,7 +150,7 @@ public class SelectPartyDialogController extends DialogControllerBase {
154150 * @param stage
155151 */
156152 public void setStage(Stage stage) {
157- parentStage_ = stage;
153+ stage_ = stage;
158154 }
159155
160156 /**
@@ -184,6 +180,28 @@ public class SelectPartyDialogController extends DialogControllerBase {
184180 ((Node)event.getSource()).getScene().getWindow().hide();
185181 }
186182
183+ @FXML
184+ public void onActionButtonAddNewParty(ActionEvent event) {
185+ try {
186+ showConfigSettingsDialog(stage_, null);
187+
188+ SettingManager settingMgr = SettingManager.getInstance();
189+ Hashtable<String, Boolean> partyTable = settingMgr.getPartyTable();
190+ Set<String> keys = partyTable.keySet();
191+ ObservableList<PartyProperty> observableList = FXCollections.observableArrayList();
192+
193+ for(String key: keys) {
194+ boolean isDefault = partyTable.get(key);
195+ PartyProperty partyProperty = new PartyProperty(isDefault, key);
196+ observableList.add(partyProperty);
197+ }
198+ tableViewPartyList.getItems().clear();
199+ tableViewPartyList.setItems(observableList);
200+ } catch (Exception e) {
201+ e.printStackTrace();
202+ }
203+ }
204+
187205 /**
188206 * Cell factory setter.
189207 * @param tableColumn
@@ -266,4 +284,31 @@ public class SelectPartyDialogController extends DialogControllerBase {
266284 }
267285 tableViewPartyList.setItems(observableList);
268286 }
287+
288+ /**
289+ * WikiConfigSettingDialogを表示する。
290+ * @param primaryStage
291+ * @param selectedParty
292+ * @return DialogBase.CloseType
293+ * @throws Exception
294+ */
295+ private DialogBase.CloseType showConfigSettingsDialog(Stage stage, String partyName) throws Exception {
296+ SettingManager settingMgr_ = SettingManager.getInstance();
297+
298+ ConfigSettingsDialog dialog = new ConfigSettingsDialog(partyName);
299+
300+ DialogBase.CloseType closeType = dialog.showDialog(stage, resource_);
301+ if(closeType == DialogBase.CloseType.OK) {
302+
303+ Hashtable<String, String> settingsTable = dialog.getSettingsTable();
304+ String path = settingMgr_.get(SettingManager.SETTINGSKEY_MOXKIRIYA_USER_DIR);
305+
306+ partyName = dialog.getPartyName();
307+ settingMgr_.putParty(partyName, dialog.getDefaultPartyCheckValue());
308+ settingMgr_.savePartyConfig(path);
309+ settingMgr_.saveSettingConfig(path, partyName, settingsTable);
310+ }
311+
312+ return closeType;
313+ }
269314 }
--- a/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
+++ b/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
@@ -19,6 +19,7 @@ key.Button.Upload: Upload
1919 key.Button.DeleteCheckedFiles: Delete checked files
2020 key.Button.Add.Category: Add new category
2121 key.Button.Delete.Pages: Delete selected pages
22+key.Button.Add.Party: Add new party
2223
2324 key.Menu.File: File
2425 key.Menu.Edit: Edit