Moxkiriyaプロジェクト事前開発用の作業部屋
修订版 | 1eca5bde109e935aacaa39fe7b674a548d4ea528 (tree) |
---|---|
时间 | 2018-10-08 12:46:23 |
作者 | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -114,7 +114,7 @@ public class Main extends Application { | ||
114 | 114 | /* |
115 | 115 | * 外部リンクアイコン画像をApprootにアップロードする。 |
116 | 116 | */ |
117 | - wikiMainWindow_.uploadResourcefile(appRoot + "/" + "icon/Icon_External_Link.png"); | |
117 | + wikiMainWindow_.uploadResourcefile(appRoot + "/", "icon/Icon_External_Link.png"); | |
118 | 118 | |
119 | 119 | closeType = wikiMainWindow_.show(); |
120 | 120 | } |
@@ -189,9 +189,14 @@ public class SettingManager { | ||
189 | 189 | */ |
190 | 190 | public Hashtable<String, String> loadConfigSettings(String path, String partyName) throws Exception { |
191 | 191 | 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 | + } | |
192 | 198 | |
193 | - File inifile = new File(path | |
194 | - + "/" + partyName | |
199 | + File inifile = new File(partyDir.getAbsolutePath() | |
195 | 200 | + "/" + SettingManager.CONFIG_FILENAME); |
196 | 201 | if (inifile.exists() != true) { |
197 | 202 | /* |
@@ -101,9 +101,11 @@ public class WikiMainWindow { | ||
101 | 101 | public void buildWikiMainTree(File wikirootPath) throws Exception { |
102 | 102 | createCssFiles(); |
103 | 103 | |
104 | - uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.FIXED_STYLESHEET_FILENAME)); | |
104 | + uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.FIXED_STYLESHEET_FILENAME), | |
105 | + WikiEngine.FIXED_STYLESHEET_FILENAME); | |
105 | 106 | |
106 | - uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.DEFAULT_STYLESHEET_FILENAME)); | |
107 | + uploadResourcefile(settingManager_.getAbsolutePath(WikiEngine.DEFAULT_STYLESHEET_FILENAME), | |
108 | + WikiEngine.DEFAULT_STYLESHEET_FILENAME); | |
107 | 109 | |
108 | 110 | createRepositoryConfig(); |
109 | 111 | wikiEngine_ = new WikiEngine(); |
@@ -116,12 +118,11 @@ public class WikiMainWindow { | ||
116 | 118 | * @param filename |
117 | 119 | * @throws IOException |
118 | 120 | */ |
119 | - public void uploadResourcefile(String absolutePath) throws IOException { | |
121 | + public void uploadResourcefile(String absolutePath, String filename) throws IOException { | |
120 | 122 | File destFile = new File(absolutePath); |
121 | - String filename = destFile.getName(); | |
122 | 123 | |
123 | 124 | if (destFile.exists() != true) { |
124 | - InputStream in = getClass().getResourceAsStream("resources/icon/" + filename); | |
125 | + InputStream in = getClass().getResourceAsStream("resources/" + filename); | |
125 | 126 | Path destPath = Paths.get(absolutePath); |
126 | 127 | Files.createDirectories(destPath.getParent()); |
127 | 128 | Files.copy(in, destPath); |
@@ -77,4 +77,12 @@ public class ConfigSettingsDialog extends DialogBase { | ||
77 | 77 | return ((ConfigSettingsDialogController)controller_).getDefaultPartyCheckValue(); |
78 | 78 | } |
79 | 79 | |
80 | + /** | |
81 | + * Party name getter. | |
82 | + * @return String | |
83 | + */ | |
84 | + public String getPartyName() { | |
85 | + return ((ConfigSettingsDialogController)controller_).getPartyName(); | |
86 | + } | |
87 | + | |
80 | 88 | } |
\ No newline at end of file |
@@ -265,4 +265,12 @@ public class ConfigSettingsDialogController extends DialogControllerBase { | ||
265 | 265 | public boolean getDefaultPartyCheckValue() { |
266 | 266 | return checkBoxDefaultParty.isSelected(); |
267 | 267 | } |
268 | + | |
269 | + /** | |
270 | + * Party name getter. | |
271 | + * @return String | |
272 | + */ | |
273 | + public String getPartyName() { | |
274 | + return textFieldPartyName.getText(); | |
275 | + } | |
268 | 276 | } |
@@ -35,6 +35,10 @@ public abstract class DialogBase { | ||
35 | 35 | protected Stage parentStage_; |
36 | 36 | |
37 | 37 | /** |
38 | + * My stage. | |
39 | + */ | |
40 | + protected Stage stage_; | |
41 | + /** | |
38 | 42 | * シーン |
39 | 43 | */ |
40 | 44 | Scene scene_; |
@@ -107,13 +111,13 @@ public abstract class DialogBase { | ||
107 | 111 | * @return CloseTypeダイアログの終了種別 |
108 | 112 | */ |
109 | 113 | protected CloseType show() { |
110 | - Stage stage = new Stage(); | |
114 | + stage_ = new Stage(); | |
111 | 115 | |
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(); | |
117 | 121 | |
118 | 122 | return getCloseType(); |
119 | 123 | } |
@@ -18,5 +18,6 @@ | ||
18 | 18 | </TableView> |
19 | 19 | <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" /> |
20 | 20 | <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" /> | |
21 | 22 | </children> |
22 | 23 | </AnchorPane> |
@@ -7,8 +7,6 @@ | ||
7 | 7 | */ |
8 | 8 | package com.wiki.standalone.moxkiriya.dialog; |
9 | 9 | |
10 | -import com.wiki.standalone.moxkiriya.dialog.DialogBase.CloseType; | |
11 | - | |
12 | 10 | /** |
13 | 11 | * SelectPartyDialog |
14 | 12 | */ |
@@ -47,7 +47,7 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
47 | 47 | |
48 | 48 | /** Party name. */ |
49 | 49 | private SimpleStringProperty partyName_; |
50 | - | |
50 | + | |
51 | 51 | /** |
52 | 52 | * Constructor. |
53 | 53 | * @param aSelect |
@@ -80,6 +80,7 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
80 | 80 | @FXML private TableColumn<PartyProperty, String> tableColumnPartyName; |
81 | 81 | @FXML private Button buttonCancel; |
82 | 82 | @FXML private Button buttonOK; |
83 | + @FXML private Button buttonAddNewParty; | |
83 | 84 | |
84 | 85 | /** Selected party name. */ |
85 | 86 | private String selectedParty_; |
@@ -90,9 +91,9 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
90 | 91 | /** Close type. */ |
91 | 92 | private DialogBase.CloseType closeType_; |
92 | 93 | |
93 | - /** Parent stage */ | |
94 | - private Stage parentStage_; | |
95 | - | |
94 | + /** My stage */ | |
95 | + private Stage stage_; | |
96 | + | |
96 | 97 | @Override |
97 | 98 | public void initialize(URL url, ResourceBundle resource) { |
98 | 99 | super.initialize(url, resource); |
@@ -120,17 +121,12 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
120 | 121 | public void handle(ActionEvent event) { |
121 | 122 | Hyperlink target = (Hyperlink)event.getTarget(); |
122 | 123 | PartyProperty partyProperty = (PartyProperty)target.getUserData(); |
123 | - ConfigSettingsDialog dialog = new ConfigSettingsDialog(partyProperty.partyName_.get()); | |
124 | + String partyName = partyProperty.partyName_.get(); | |
124 | 125 | |
125 | 126 | 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); | |
134 | 130 | settingMgr.loadSettingFiles(path); |
135 | 131 | } |
136 | 132 | } catch (Exception e) { |
@@ -154,7 +150,7 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
154 | 150 | * @param stage |
155 | 151 | */ |
156 | 152 | public void setStage(Stage stage) { |
157 | - parentStage_ = stage; | |
153 | + stage_ = stage; | |
158 | 154 | } |
159 | 155 | |
160 | 156 | /** |
@@ -184,6 +180,28 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
184 | 180 | ((Node)event.getSource()).getScene().getWindow().hide(); |
185 | 181 | } |
186 | 182 | |
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 | + | |
187 | 205 | /** |
188 | 206 | * Cell factory setter. |
189 | 207 | * @param tableColumn |
@@ -266,4 +284,31 @@ public class SelectPartyDialogController extends DialogControllerBase { | ||
266 | 284 | } |
267 | 285 | tableViewPartyList.setItems(observableList); |
268 | 286 | } |
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 | + } | |
269 | 314 | } |
@@ -19,6 +19,7 @@ key.Button.Upload: Upload | ||
19 | 19 | key.Button.DeleteCheckedFiles: Delete checked files |
20 | 20 | key.Button.Add.Category: Add new category |
21 | 21 | key.Button.Delete.Pages: Delete selected pages |
22 | +key.Button.Add.Party: Add new party | |
22 | 23 | |
23 | 24 | key.Menu.File: File |
24 | 25 | key.Menu.Edit: Edit |