Moxkiriyaプロジェクト事前開発用の作業部屋
修订版 | a5aa3188af7ce071817add77b4c5dfbf35bc0d81 (tree) |
---|---|
时间 | 2018-09-30 13:13:55 |
作者 | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -64,6 +64,7 @@ public class Main extends Application { | ||
64 | 64 | @Override |
65 | 65 | public void start(Stage primaryStage) { |
66 | 66 | primaryStage_ = primaryStage; |
67 | + | |
67 | 68 | settingManager_ = SettingManager.getInstance(); |
68 | 69 | |
69 | 70 | try { |
@@ -81,7 +82,7 @@ public class Main extends Application { | ||
81 | 82 | */ |
82 | 83 | Stage stage = new Stage(StageStyle.UNDECORATED); |
83 | 84 | stage.initOwner(primaryStage); |
84 | - showInitialSettingsDialog(stage); | |
85 | + showConfigSettingsDialog(stage); | |
85 | 86 | AppRoot = settingManager_.get(SettingManager.SETINGKEY_MOXKIRIYAROOT); |
86 | 87 | } |
87 | 88 |
@@ -108,11 +109,11 @@ public class Main extends Application { | ||
108 | 109 | } |
109 | 110 | |
110 | 111 | /** |
111 | - * WikirootInputDialogを表示する。 | |
112 | + * WikiConfigSettingDialogを表示する。 | |
112 | 113 | * @param primaryStage |
113 | 114 | * @throws Exception |
114 | 115 | */ |
115 | - private void showInitialSettingsDialog(Stage stage) throws Exception { | |
116 | + private void showConfigSettingsDialog(Stage stage) throws Exception { | |
116 | 117 | ConfigSettingsDialog dialog = new ConfigSettingsDialog(); |
117 | 118 | dialog.showDialog(stage, resources_); |
118 | 119 | } |
@@ -42,10 +42,14 @@ public class WikiEngine { | ||
42 | 42 | /** Page data map. */ |
43 | 43 | private HashMap<String, PageData> pageDataMap_ = null; |
44 | 44 | |
45 | + /** Wiki history manager. */ | |
46 | + private WikiHistory wikiHistory_ = null; | |
47 | + | |
45 | 48 | /** |
46 | 49 | * Constructor. |
47 | 50 | */ |
48 | 51 | public WikiEngine() { |
52 | + wikiHistory_ = new WikiHistory(); | |
49 | 53 | } |
50 | 54 | |
51 | 55 | /** |
@@ -161,68 +165,39 @@ public class WikiEngine { | ||
161 | 165 | * @throws Exception |
162 | 166 | */ |
163 | 167 | public String parse() throws Exception { |
164 | - WikiBodyBlockParser bodyBlockParser = new WikiBodyBlockParser(wikiRepository_); | |
165 | - String bodyHtml = ""; | |
166 | - | |
167 | - PageData currentPageData = null; | |
168 | + PageData pageData = null; | |
169 | + String bodyHtml = ""; | |
168 | 170 | |
169 | 171 | if(pageDataMap_.size() == 1) { |
170 | - currentPageData = pageDataMap_.values().iterator().next(); | |
171 | - | |
172 | - /* | |
173 | - * Contentsのparse & Body部の構築. | |
174 | - */ | |
175 | - if(currentPageData != null) { | |
176 | - /* | |
177 | - * ページタイトルのparse. | |
178 | - */ | |
179 | - bodyBlockParser.parsePageTitle(currentPageData.getTitle()); | |
180 | - BufferedReader buffreader = FileIO.bufferedReader(new StringReader(currentPageData.getContent())); | |
181 | - | |
182 | - bodyHtml = bodyBlockParser.parse(buffreader) | |
183 | - + buildCategoryList(currentPageData); | |
184 | - | |
185 | - buffreader.close(); | |
186 | - } | |
172 | + pageData = pageDataMap_.values().iterator().next(); | |
173 | + wikiHistory_.add(pageData); | |
174 | + bodyHtml = markupContents(pageData); | |
187 | 175 | } |
188 | 176 | else { |
189 | - StringBuffer bodybuf = new StringBuffer(); | |
190 | - ResourceBundle resources_ = ResourceBundle.getBundle("com.wiki.standalone.moxkiriya.resources.moxkiriya"); | |
177 | + bodyHtml = markupContentsList(); | |
178 | + } | |
191 | 179 | |
192 | - bodybuf.append("<h1>" + resources_.getString("key.Search.Result") + "</h1>\n"); | |
193 | - if(pageDataMap_.size() > 1) { | |
194 | - bodybuf.append("<div>\n"); | |
195 | - bodybuf.append(resources_.getString("key.Message.found.pages") + "\n"); | |
196 | - bodybuf.append("</div>\n"); | |
197 | - | |
198 | - for(String uuid: pageDataMap_.keySet()) { | |
199 | - PageData pageData = pageDataMap_.get(uuid); | |
200 | - | |
201 | - bodybuf.append("<h3>\n"); | |
202 | - bodybuf.append("<a href=" | |
203 | - + "\"" + pageData.getTitle() + "\" " | |
204 | - + ATTRIBUTE_JCR_UUID + "=" | |
205 | - + pageData.getNode().getProperty(Property.JCR_UUID).getString() | |
206 | - + ">"); | |
207 | - bodybuf.append(pageData.getTitle()); | |
208 | - bodybuf.append("</a>\n"); | |
209 | - bodybuf.append("</h3>\n"); | |
210 | - bodybuf.append("<div>\n"); | |
211 | - bodybuf.append(pageData.getIntroduction()); | |
212 | - bodybuf.append("</div>\n"); | |
213 | - } | |
214 | - } | |
215 | - else { | |
216 | - /* | |
217 | - * No page was found. | |
218 | - */ | |
219 | - bodybuf.append("<div>\n"); | |
220 | - bodybuf.append(resources_.getString("key.search.result.message.nopage") + "\n"); | |
221 | - bodybuf.append("</div>\n"); | |
222 | - } | |
180 | + /* | |
181 | + * Header部の構築 | |
182 | + */ | |
183 | + String headerHtml = buildHtmlHeader(); | |
184 | + StringBuffer buf = new StringBuffer(); | |
223 | 185 | |
224 | - bodyHtml = bodybuf.toString(); | |
225 | - } | |
186 | + buf.append(headerHtml); | |
187 | + buf.append(bodyHtml); | |
188 | + buf.append("</html>"); | |
189 | + | |
190 | + return buf.toString(); | |
191 | + } | |
192 | + | |
193 | + /** | |
194 | + * Wikiシンタックスの文字列をHTML形式に変換する。 | |
195 | + * @param pageData | |
196 | + * @return HTMLコンテンツ | |
197 | + * @throws Exception | |
198 | + */ | |
199 | + public String parse(PageData pageData) throws Exception { | |
200 | + String bodyHtml = markupContents(pageData); | |
226 | 201 | |
227 | 202 | /* |
228 | 203 | * Header部の構築 |
@@ -233,9 +208,76 @@ public class WikiEngine { | ||
233 | 208 | buf.append(headerHtml); |
234 | 209 | buf.append(bodyHtml); |
235 | 210 | buf.append("</html>"); |
236 | - | |
211 | + | |
237 | 212 | return buf.toString(); |
238 | 213 | } |
214 | + | |
215 | + /** | |
216 | + * Wikiシンタックスの文字列をHTML形式に変換する。 | |
217 | + * @return HTMLコンテンツ | |
218 | + * @throws Exception | |
219 | + */ | |
220 | + public String markupContents(PageData pageData) throws Exception { | |
221 | + WikiBodyBlockParser bodyBlockParser = new WikiBodyBlockParser(wikiRepository_); | |
222 | + String bodyHtml = ""; | |
223 | + | |
224 | + /* | |
225 | + * Contentsのparse & Body部の構築. | |
226 | + */ | |
227 | + bodyBlockParser.parsePageTitle(pageData.getTitle()); | |
228 | + BufferedReader buffreader = FileIO.bufferedReader(new StringReader(pageData.getContent())); | |
229 | + | |
230 | + bodyHtml = bodyBlockParser.parse(buffreader) | |
231 | + + buildCategoryList(pageData); | |
232 | + | |
233 | + buffreader.close(); | |
234 | + | |
235 | + return bodyHtml; | |
236 | + } | |
237 | + | |
238 | + /** | |
239 | + * PageリストをHTML形式で生成する。 | |
240 | + * @return HTMLコンテンツ | |
241 | + * @throws Exception | |
242 | + */ | |
243 | + public String markupContentsList() throws Exception { | |
244 | + StringBuffer bodybuf = new StringBuffer(); | |
245 | + ResourceBundle resources_ = ResourceBundle.getBundle("com.wiki.standalone.moxkiriya.resources.moxkiriya"); | |
246 | + | |
247 | + bodybuf.append("<h1>" + resources_.getString("key.Search.Result") + "</h1>\n"); | |
248 | + if(pageDataMap_.size() > 1) { | |
249 | + bodybuf.append("<div>\n"); | |
250 | + bodybuf.append(resources_.getString("key.Message.found.pages") + "\n"); | |
251 | + bodybuf.append("</div>\n"); | |
252 | + | |
253 | + for(String uuid: pageDataMap_.keySet()) { | |
254 | + PageData pageData = pageDataMap_.get(uuid); | |
255 | + | |
256 | + bodybuf.append("<h3>\n"); | |
257 | + bodybuf.append("<a href=" | |
258 | + + "\"" + pageData.getTitle() + "\" " | |
259 | + + ATTRIBUTE_JCR_UUID + "=" | |
260 | + + pageData.getNode().getProperty(Property.JCR_UUID).getString() | |
261 | + + ">"); | |
262 | + bodybuf.append(pageData.getTitle()); | |
263 | + bodybuf.append("</a>\n"); | |
264 | + bodybuf.append("</h3>\n"); | |
265 | + bodybuf.append("<div>\n"); | |
266 | + bodybuf.append(pageData.getIntroduction()); | |
267 | + bodybuf.append("</div>\n"); | |
268 | + } | |
269 | + } | |
270 | + else { | |
271 | + /* | |
272 | + * No page was found. | |
273 | + */ | |
274 | + bodybuf.append("<div>\n"); | |
275 | + bodybuf.append(resources_.getString("key.search.result.message.nopage") + "\n"); | |
276 | + bodybuf.append("</div>\n"); | |
277 | + } | |
278 | + | |
279 | + return bodybuf.toString(); | |
280 | + } | |
239 | 281 | |
240 | 282 | /** |
241 | 283 | * HTMLヘッダ部を構築する。 |
@@ -405,8 +447,45 @@ public class WikiEngine { | ||
405 | 447 | PageData pageData = pageDataMap_.values().iterator().next(); |
406 | 448 | String uuid = pageData.getNode().getProperty(Property.JCR_UUID).getString(); |
407 | 449 | |
408 | - pageDataMap_ = wikiRepository_.queryPageUUID(uuid); | |
450 | + pageDataMap_ = wikiRepository_.queryPageUUID(uuid); | |
409 | 451 | } |
410 | 452 | } |
411 | 453 | } |
454 | + | |
455 | + /** | |
456 | + * Is there an older node on a history list. | |
457 | + * @return boolean | |
458 | + */ | |
459 | + public boolean canBack() { | |
460 | + return wikiHistory_.canBack(); | |
461 | + } | |
462 | + | |
463 | + /** | |
464 | + * Is there an newer node on a history list. | |
465 | + * @return boolean | |
466 | + */ | |
467 | + public boolean canForward() { | |
468 | + return wikiHistory_.canForward(); | |
469 | + } | |
470 | + | |
471 | + /** | |
472 | + * Execute history back. | |
473 | + * @throws Exception | |
474 | + */ | |
475 | + public String back() throws Exception { | |
476 | + PageData pageData = wikiHistory_.back(); | |
477 | + setPageDataMap(pageData); | |
478 | + return parse(pageData); | |
479 | + } | |
480 | + | |
481 | + /** | |
482 | + * Execute history forward. | |
483 | + * @return PageData | |
484 | + * @throws Exception | |
485 | + */ | |
486 | + public String forward() throws Exception { | |
487 | + PageData pageData = wikiHistory_.forward(); | |
488 | + setPageDataMap(pageData); | |
489 | + return parse(pageData); | |
490 | + } | |
412 | 491 | } |
@@ -0,0 +1,123 @@ | ||
1 | +/** | |
2 | + * Moxkiriya standalone Wiki. | |
3 | + * WikiHistory. | |
4 | + * | |
5 | + * @author Ryuhei Terada | |
6 | + * See the '<a href="{@docRoot}/copyright.html">Copyright</a>' | |
7 | + */ | |
8 | +package com.wiki.standalone.moxkiriya; | |
9 | + | |
10 | +import java.util.ArrayList; | |
11 | + | |
12 | +import javax.jcr.Property; | |
13 | + | |
14 | +/** | |
15 | + * Manage wiki history. | |
16 | + * | |
17 | + * | |
18 | + */ | |
19 | +public class WikiHistory { | |
20 | + /** History list*/ | |
21 | + private ArrayList<PageData> histories_ = new ArrayList<PageData>(); | |
22 | + | |
23 | + /** Position on history list. */ | |
24 | + private int position_ = 0; | |
25 | + | |
26 | + /** | |
27 | + * Constructor. | |
28 | + */ | |
29 | + public WikiHistory() { | |
30 | + histories_.clear(); | |
31 | + } | |
32 | + | |
33 | + /** | |
34 | + * Is there an older node on a history list. | |
35 | + * @return boolean | |
36 | + */ | |
37 | + public boolean canBack() { | |
38 | + boolean canBack = false; | |
39 | + | |
40 | + if(histories_.size() > 1) { | |
41 | + if(position_ > 0) { | |
42 | + canBack = true; | |
43 | + } | |
44 | + } | |
45 | + | |
46 | + return canBack; | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * Is there an newer node on a history list. | |
51 | + * @return boolean | |
52 | + */ | |
53 | + public boolean canForward() { | |
54 | + boolean canForward = false; | |
55 | + | |
56 | + if(histories_.size() > 0) { | |
57 | + if(position_ < histories_.size() - 1) { | |
58 | + canForward = true; | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + return canForward; | |
63 | + } | |
64 | + | |
65 | + /** | |
66 | + * Execute history back. | |
67 | + * @return PageData | |
68 | + */ | |
69 | + public PageData back() { | |
70 | + PageData pageData = null; | |
71 | + | |
72 | + if(canBack() == true) { | |
73 | + position_--; | |
74 | + pageData = histories_.get(position_); | |
75 | + } | |
76 | + | |
77 | + return pageData; | |
78 | + } | |
79 | + | |
80 | + /** | |
81 | + * Execute history forward. | |
82 | + * @return PageData | |
83 | + */ | |
84 | + public PageData forward() { | |
85 | + PageData pageData = null; | |
86 | + | |
87 | + if(canForward() == true) { | |
88 | + position_++; | |
89 | + pageData = histories_.get(position_); | |
90 | + } | |
91 | + | |
92 | + return pageData; | |
93 | + } | |
94 | + | |
95 | + /** | |
96 | + * Add PageData to history list. | |
97 | + * @param pageData | |
98 | + * @throws Exception | |
99 | + */ | |
100 | + public void add(PageData pageData) throws Exception { | |
101 | + if(histories_.size() > 0) { | |
102 | + PageData latestPage = histories_.get(position_); | |
103 | + String uuid = latestPage.getNode().getProperty(Property.JCR_UUID).getString(); | |
104 | + | |
105 | + if(pageData.getNode().getProperty(Property.JCR_UUID).getString().equals(uuid) == true) { | |
106 | + /* | |
107 | + * History中に同じページを連続登録しようとした場合、 | |
108 | + */ | |
109 | + histories_.remove(position_); | |
110 | + } | |
111 | + else { | |
112 | + position_++; | |
113 | + } | |
114 | + } | |
115 | + | |
116 | + for(int count = position_; count < histories_.size(); count++) { | |
117 | + histories_.remove(count); | |
118 | + } | |
119 | + | |
120 | + histories_.add(pageData); | |
121 | + position_ = histories_.size() - 1; | |
122 | + } | |
123 | +} |
@@ -51,7 +51,7 @@ | ||
51 | 51 | <Font size="17.0" fx:id="x1" /> |
52 | 52 | </font> |
53 | 53 | </Button> |
54 | - <Button fx:id="webViewMenuAnchorPaneButtonForward" disable="true" font="$x1" maxHeight="-Infinity" maxWidth="-Infinity" mnemonicParsing="false" prefHeight="35.0" prefWidth="45.0" text="⇨" AnchorPane.leftAnchor="200.0" AnchorPane.topAnchor="4.0" /> | |
54 | + <Button fx:id="webViewMenuAnchorPaneButtonForward" disable="true" font="$x1" maxHeight="-Infinity" maxWidth="-Infinity" mnemonicParsing="false" onAction="#onActionButtonForward" prefHeight="35.0" prefWidth="45.0" text="⇨" AnchorPane.leftAnchor="200.0" AnchorPane.topAnchor="4.0" /> | |
55 | 55 | <Button fx:id="webViewMenuAnchorPaneButtonReload" maxHeight="-Infinity" maxWidth="-Infinity" mnemonicParsing="false" onAction="#onActionButtonReload" prefHeight="35.0" prefWidth="45.0" text="↻" AnchorPane.leftAnchor="250.0" AnchorPane.topAnchor="4.0"> |
56 | 56 | <font> |
57 | 57 | <Font size="20.0" fx:id="x2" /> |
@@ -90,7 +90,7 @@ | ||
90 | 90 | </items> |
91 | 91 | </ComboBox> |
92 | 92 | <Hyperlink fx:id="hyperlinkRedraw" onMouseClicked="#onMouseClickedHyperlinkRedraw" prefHeight="30.0" prefWidth="-1.0" text="%key.PageList.Label.Redraw" AnchorPane.leftAnchor="410.0" AnchorPane.topAnchor="80.0" /> |
93 | - <TableView id="TableViewContentList" fx:id="tableViewContentList" editable="true" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="400.0" prefWidth="825.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="110.0"> | |
93 | + <TableView id="TableViewContentList" fx:id="tableViewContentList" editable="true" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="400.0" prefWidth="825.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="150.0" AnchorPane.topAnchor="110.0"> | |
94 | 94 | <columns> |
95 | 95 | <TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="45.0" text="" fx:id="tableColumnCheck" /> |
96 | 96 | <TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="190.0" text="%key.Table.Row.Title" fx:id="tableColumnTitle" /> |
@@ -110,7 +110,7 @@ | ||
110 | 110 | <Button fx:id="buttonSave" mnemonicParsing="false" onAction="#onActionButtonSave" prefWidth="90.0" text="%key.Button.Save" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="120.0" /> |
111 | 111 | <Button fx:id="buttonCancel" mnemonicParsing="false" onAction="#onActionButtonCancel" prefWidth="90.0" text="%key.Button.Cancel" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="10.0" /> |
112 | 112 | <TextField fx:id="textFieldAttachFile" disable="true" prefHeight="30.0" prefWidth="716.0" promptText="%key.Edit.TextField.InputPathname" AnchorPane.bottomAnchor="37.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="108.0" /> |
113 | - <Label disable="true" prefHeight="30.0" prefWidth="166.0" text="%key.Edit.Label.AttachFile" AnchorPane.bottomAnchor="65.0" AnchorPane.leftAnchor="150.0" /> | |
113 | + <Label id="textLabelAttacheFile" fx:id="labelAttacheFile" disable="true" prefHeight="30.0" prefWidth="166.0" text="%key.Edit.Label.AttachFile" AnchorPane.bottomAnchor="65.0" AnchorPane.leftAnchor="150.0" /> | |
114 | 114 | <Button fx:id="buttonChoiceFile" disable="true" mnemonicParsing="false" onAction="#onActionButtonChoiceFile" prefHeight="30.0" prefWidth="45.0" text="..." AnchorPane.bottomAnchor="35.0" AnchorPane.rightAnchor="55.0" /> |
115 | 115 | </children> |
116 | 116 | </AnchorPane> |
@@ -39,6 +39,7 @@ import javafx.scene.control.Button; | ||
39 | 39 | import javafx.scene.control.CheckBox; |
40 | 40 | import javafx.scene.control.ComboBox; |
41 | 41 | import javafx.scene.control.Hyperlink; |
42 | +import javafx.scene.control.Label; | |
42 | 43 | import javafx.scene.control.MenuItem; |
43 | 44 | import javafx.scene.control.TableCell; |
44 | 45 | import javafx.scene.control.TableColumn; |
@@ -109,6 +110,7 @@ public class WikiMainWindowController implements Initializable { | ||
109 | 110 | @FXML private AnchorPane AnchorPaneEdit; |
110 | 111 | @FXML private TextField textFieldTitle; |
111 | 112 | @FXML private TextArea textAreaContents; |
113 | + @FXML private Label labelAttacheFile; | |
112 | 114 | @FXML private TextField textFieldAttachFile; |
113 | 115 | @FXML private Button buttonChoiceFile; |
114 | 116 |
@@ -373,16 +375,51 @@ public class WikiMainWindowController implements Initializable { | ||
373 | 375 | |
374 | 376 | @FXML |
375 | 377 | public void onActionButtonBack(ActionEvent event) { |
376 | - /* | |
377 | - * TODO implement. | |
378 | - */ | |
378 | + try { | |
379 | + String content = wikiEngine_.back(); | |
380 | + WebEngine webEngine = webView.getEngine(); | |
381 | + webEngine.loadContent(content); | |
382 | + | |
383 | + HashMap<String, PageData> map = wikiEngine_.getPageDataMap(); | |
384 | + boolean canEdit = (map.size() != 1) ? true : false; | |
385 | + | |
386 | + choiceViewHyperlinkEdit.setDisable(canEdit); | |
387 | + menuItemNew.setDisable(false); | |
388 | + | |
389 | + AnchorPaneEdit.setVisible(false); | |
390 | + AnchorPaneContentList.setVisible(false); | |
391 | + AnchorPaneWebView.setVisible(true); | |
392 | + | |
393 | + webViewMenuAnchorPaneButtonBack.setDisable(!wikiEngine_.canBack()); | |
394 | + webViewMenuAnchorPaneButtonForward.setDisable(!wikiEngine_.canForward()); | |
395 | + } catch (Exception e) { | |
396 | + e.printStackTrace(); | |
397 | + } | |
398 | + | |
379 | 399 | } |
380 | 400 | |
381 | 401 | @FXML |
382 | 402 | public void onActionButtonForward(ActionEvent event) { |
383 | - /* | |
384 | - * TODO implement. | |
385 | - */ | |
403 | + try { | |
404 | + String content = wikiEngine_.forward(); | |
405 | + WebEngine webEngine = webView.getEngine(); | |
406 | + webEngine.loadContent(content); | |
407 | + | |
408 | + HashMap<String, PageData> map = wikiEngine_.getPageDataMap(); | |
409 | + boolean canEdit = (map.size() != 1) ? true : false; | |
410 | + | |
411 | + choiceViewHyperlinkEdit.setDisable(canEdit); | |
412 | + menuItemNew.setDisable(false); | |
413 | + | |
414 | + AnchorPaneEdit.setVisible(false); | |
415 | + AnchorPaneContentList.setVisible(false); | |
416 | + AnchorPaneWebView.setVisible(true); | |
417 | + | |
418 | + webViewMenuAnchorPaneButtonBack.setDisable(!wikiEngine_.canBack()); | |
419 | + webViewMenuAnchorPaneButtonForward.setDisable(!wikiEngine_.canForward()); | |
420 | + } catch (Exception e) { | |
421 | + e.printStackTrace(); | |
422 | + } | |
386 | 423 | } |
387 | 424 | |
388 | 425 | @FXML |
@@ -577,10 +614,12 @@ public class WikiMainWindowController implements Initializable { | ||
577 | 614 | PageData pageData = new PageData(); |
578 | 615 | String pageTitle = title; |
579 | 616 | |
580 | - namespace = title.substring(0, title.indexOf(":")); | |
581 | - | |
582 | 617 | pageData.setNamespace(WikiRepository.PROPERTY_MAIN); |
583 | 618 | |
619 | + if(title.contains(":")) { | |
620 | + namespace = title.substring(0, title.indexOf(":")); | |
621 | + } | |
622 | + | |
584 | 623 | if(namespace.isEmpty() != true) { |
585 | 624 | pageTitle = title.substring(namespace.length() + ":".length(), title.length()); |
586 | 625 | if(wikiEngine_.isContainsNamespaceList(namespace) == true) { |
@@ -597,14 +636,12 @@ public class WikiMainWindowController implements Initializable { | ||
597 | 636 | } |
598 | 637 | } |
599 | 638 | |
600 | - if(namespace.equals(WikiEngine.NAMESPACE_FILE) == true) { | |
601 | - textFieldAttachFile.setDisable(false); | |
602 | - buttonChoiceFile.setDisable(false); | |
603 | - } | |
604 | - else { | |
605 | - textFieldAttachFile.setDisable(true); | |
606 | - buttonChoiceFile.setDisable(true); | |
607 | - } | |
639 | + boolean cannotAttacheFile = namespace.equals(WikiEngine.NAMESPACE_FILE) == true | |
640 | + ? false | |
641 | + : true; | |
642 | + textFieldAttachFile.setDisable(cannotAttacheFile); | |
643 | + labelAttacheFile.setDisable(cannotAttacheFile); | |
644 | + buttonChoiceFile.setDisable(cannotAttacheFile); | |
608 | 645 | |
609 | 646 | /* |
610 | 647 | * 各コントロールの初期値を入力する。 |
@@ -632,19 +669,22 @@ public class WikiMainWindowController implements Initializable { | ||
632 | 669 | */ |
633 | 670 | public void loadWikiContent() { |
634 | 671 | try { |
672 | + WebEngine webEngine = webView.getEngine(); | |
673 | + webEngine.loadContent(wikiEngine_.parse()); | |
674 | + | |
635 | 675 | HashMap<String, PageData> map = wikiEngine_.getPageDataMap(); |
636 | 676 | boolean canEdit = (map.size() != 1) ? true : false; |
637 | 677 | |
638 | 678 | choiceViewHyperlinkEdit.setDisable(canEdit); |
639 | 679 | |
640 | - WebEngine webEngine = webView.getEngine(); | |
641 | - | |
642 | - webEngine.loadContent(wikiEngine_.parse()); | |
643 | - | |
680 | + | |
644 | 681 | menuItemNew.setDisable(false); |
645 | 682 | AnchorPaneEdit.setVisible(false); |
646 | 683 | AnchorPaneContentList.setVisible(false); |
647 | 684 | AnchorPaneWebView.setVisible(true); |
685 | + | |
686 | + webViewMenuAnchorPaneButtonBack.setDisable(!wikiEngine_.canBack()); | |
687 | + webViewMenuAnchorPaneButtonForward.setDisable(!wikiEngine_.canForward()); | |
648 | 688 | } catch (Exception e) { |
649 | 689 | e.printStackTrace(); |
650 | 690 | } |
@@ -20,14 +20,12 @@ import javax.jcr.NamespaceException; | ||
20 | 20 | import javax.jcr.NamespaceRegistry; |
21 | 21 | import javax.jcr.Node; |
22 | 22 | import javax.jcr.NodeIterator; |
23 | -import javax.jcr.PathNotFoundException; | |
24 | 23 | import javax.jcr.Property; |
25 | 24 | import javax.jcr.Repository; |
26 | 25 | import javax.jcr.RepositoryException; |
27 | 26 | import javax.jcr.Session; |
28 | 27 | import javax.jcr.Value; |
29 | 28 | import javax.jcr.ValueFactory; |
30 | -import javax.jcr.ValueFormatException; | |
31 | 29 | import javax.jcr.Workspace; |
32 | 30 | import javax.jcr.nodetype.NodeType; |
33 | 31 | import javax.jcr.query.Query; |
@@ -215,18 +213,18 @@ public class WikiRepository { | ||
215 | 213 | FileData fileData = pageData.getFileData(); |
216 | 214 | |
217 | 215 | if(fileData != null) { |
218 | - Node fileNode = node.getNode(WikiRepository.NODE_FILE); | |
219 | - | |
220 | - if(fileNode == null) { | |
216 | + Node fileNode; | |
217 | + if(node.hasNode(WikiRepository.NODE_FILE) == true) { | |
218 | + fileNode = node.getNode(WikiRepository.NODE_FILE); | |
219 | + } | |
220 | + else { | |
221 | 221 | fileNode = node.addNode(WikiRepository.NODE_FILE, NodeType.NT_FILE); |
222 | 222 | fileNode.addNode(Property.JCR_CONTENT, NodeType.NT_RESOURCE); |
223 | 223 | } |
224 | 224 | |
225 | - Node nodeResource = fileNode.getNode(Property.JCR_CONTENT); | |
226 | - | |
225 | + Node nodeResource = fileNode.getNode(Property.JCR_CONTENT); | |
227 | 226 | ValueFactory valueFactory = session_.getValueFactory(); |
228 | 227 | |
229 | - | |
230 | 228 | nodeResource.setProperty(Property.JCR_DATA, valueFactory.createBinary(fileData.getInputStream())); |
231 | 229 | nodeResource.setProperty(Property.JCR_MIMETYPE, new StringValue(fileData.getMimeType())); |
232 | 230 | nodeResource.setProperty(Property.JCR_LAST_MODIFIED, valueFactory.createValue(fileData.getLastModified())); |
@@ -419,7 +417,7 @@ public class WikiRepository { | ||
419 | 417 | createCategoryPages(node); |
420 | 418 | |
421 | 419 | String uuid = node.getProperty(Property.JCR_UUID).getString(); |
422 | - | |
420 | + | |
423 | 421 | return new PageData(session_.getNodeByIdentifier(uuid)); |
424 | 422 | } |
425 | 423 |