Moxkiriyaプロジェクト事前開発用の作業部屋
Révision | 2c20144e0f106515aefef5692fbb3f4313bbf763 (tree) |
---|---|
l'heure | 2018-10-09 14:19:00 |
Auteur | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -493,6 +493,13 @@ public class WikiEngine { | ||
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
496 | + * History clear. | |
497 | + */ | |
498 | + public void clearHistory() { | |
499 | + wikiHistory_.clear(); | |
500 | + } | |
501 | + | |
502 | + /** | |
496 | 503 | * VersionHistory getter. |
497 | 504 | * @return VersionIterator |
498 | 505 | * @throws Exception |
@@ -503,6 +510,19 @@ public class WikiEngine { | ||
503 | 510 | |
504 | 511 | return wikiRepository_.getVersionHistory(uuid); |
505 | 512 | } |
513 | + | |
514 | + public void importSystemView(File outputFile) throws Exception { | |
515 | + wikiRepository_.importSystemView(outputFile); | |
516 | + } | |
517 | + | |
518 | + /** | |
519 | + * Export system view. | |
520 | + * @param outputFile | |
521 | + * @throws Exception | |
522 | + */ | |
523 | + public void exportSystemView(File outputFile) throws Exception { | |
524 | + wikiRepository_.exportSystemView(outputFile); | |
525 | + } | |
506 | 526 | |
507 | 527 | /** |
508 | 528 | * Session closer. |
@@ -120,4 +120,12 @@ public class WikiHistory { | ||
120 | 120 | histories_.add(pageData); |
121 | 121 | position_ = histories_.size() - 1; |
122 | 122 | } |
123 | + | |
124 | + /** | |
125 | + * Clear history. | |
126 | + */ | |
127 | + public void clear() { | |
128 | + histories_.clear(); | |
129 | + position_ = 0; | |
130 | + } | |
123 | 131 | } |
@@ -19,6 +19,8 @@ | ||
19 | 19 | <Menu mnemonicParsing="false" text="%key.Menu.File"> |
20 | 20 | <items> |
21 | 21 | <MenuItem mnemonicParsing="false" onAction="#onActionMenuItemNew" text="%key.MenuItem.New" fx:id="menuItemNew" /> |
22 | + <MenuItem mnemonicParsing="false" onAction="#onActionMenuItemImport" text="%key.MenuItem.Import" fx:id="menuItemImport" /> | |
23 | + <MenuItem mnemonicParsing="false" onAction="#onActionMenuItemExport" text="%key.MenuItem.Export" fx:id="menuItemExport" /> | |
22 | 24 | <MenuItem mnemonicParsing="false" onAction="#onActionMenuItemExit" text="%key.MenuItem.Exit" fx:id="menuItemExit" /> |
23 | 25 | </items> |
24 | 26 | </Menu> |
@@ -65,6 +65,7 @@ import javafx.scene.layout.FlowPane; | ||
65 | 65 | import javafx.scene.web.WebEngine; |
66 | 66 | import javafx.scene.web.WebView; |
67 | 67 | import javafx.stage.FileChooser; |
68 | +import javafx.stage.FileChooser.ExtensionFilter; | |
68 | 69 | import javafx.stage.Modality; |
69 | 70 | import javafx.stage.Stage; |
70 | 71 | import javafx.stage.StageStyle; |
@@ -87,6 +88,8 @@ public class WikiMainWindowController implements Initializable { | ||
87 | 88 | * MenuBar controls. |
88 | 89 | */ |
89 | 90 | @FXML private MenuItem menuItemNew; |
91 | + @FXML private MenuItem menuItemImport; | |
92 | + @FXML private MenuItem menuItemExport; | |
90 | 93 | @FXML private MenuItem menuItemExit; |
91 | 94 | @FXML private MenuItem menuItemSelectParty; |
92 | 95 | @FXML private MenuItem menuItemAboutMoxkiriya; |
@@ -379,8 +382,65 @@ public class WikiMainWindowController implements Initializable { | ||
379 | 382 | textAreaContents.clear(); |
380 | 383 | buildEditView(""); |
381 | 384 | } |
385 | + | |
386 | + @FXML | |
387 | + public void onActionMenuItemImport(ActionEvent event) { | |
388 | + FileChooser fileChooser = new FileChooser(); | |
389 | + | |
390 | + fileChooser.setTitle(resourceBundle_.getString("key.ImportDialog.Title")); | |
391 | + fileChooser.getExtensionFilters().addAll(new ExtensionFilter("XML Files", "*.xml")); | |
392 | + | |
393 | + File selectedFile = fileChooser.showOpenDialog(stage_); | |
394 | + | |
395 | + if(selectedFile != null) { | |
396 | + try { | |
397 | + wikiEngine_.importSystemView(selectedFile); | |
398 | + | |
399 | + AlertDialog dialog = new AlertDialog(AlertDialog.MessageType.SuccessImport); | |
400 | + dialog.showDialog(stage_, resourceBundle_); | |
401 | + stage_.hide(); | |
402 | + stage_.getOwner().hide(); | |
403 | + } catch (Exception e) { | |
404 | + e.printStackTrace(); | |
405 | + try { | |
406 | + AlertDialog dialog = new AlertDialog(AlertDialog.MessageType.FailureImport); | |
407 | + dialog.showDialog(stage_, resourceBundle_); | |
408 | + stage_.hide(); | |
409 | + stage_.getOwner().hide(); | |
410 | + } catch (Exception e1) { | |
411 | + e1.printStackTrace(); | |
412 | + } | |
413 | + } | |
414 | + } | |
415 | + } | |
382 | 416 | |
383 | 417 | @FXML |
418 | + public void onActionMenuItemExport(ActionEvent event) { | |
419 | + FileChooser fileChooser = new FileChooser(); | |
420 | + | |
421 | + fileChooser.setTitle(resourceBundle_.getString("key.ExportDialog.Title")); | |
422 | + fileChooser.getExtensionFilters().addAll(new ExtensionFilter("XML Files", "*.xml")); | |
423 | + | |
424 | + File selectedFile = fileChooser.showSaveDialog(stage_); | |
425 | + | |
426 | + if(selectedFile != null) { | |
427 | + try { | |
428 | + wikiEngine_.exportSystemView(selectedFile); | |
429 | + AlertDialog dialog = new AlertDialog(AlertDialog.MessageType.SuccessExport); | |
430 | + dialog.showDialog(stage_, resourceBundle_); | |
431 | + } catch (Exception e) { | |
432 | + e.printStackTrace(); | |
433 | + try { | |
434 | + AlertDialog dialog = new AlertDialog(AlertDialog.MessageType.FailureExport); | |
435 | + dialog.showDialog(stage_, resourceBundle_); | |
436 | + } catch (Exception e1) { | |
437 | + e1.printStackTrace(); | |
438 | + } | |
439 | + } | |
440 | + } | |
441 | + } | |
442 | + | |
443 | + @FXML | |
384 | 444 | public void onActionMenuItemExit(ActionEvent event) { |
385 | 445 | try { |
386 | 446 | if (AnchorPaneEdit.isVisible() == true) { |
@@ -392,6 +452,7 @@ public class WikiMainWindowController implements Initializable { | ||
392 | 452 | editMode_ = EditMode.NONE; |
393 | 453 | wikiEngine_.cancelCheckout(); |
394 | 454 | stage_.hide(); |
455 | + stage_.getOwner().hide(); | |
395 | 456 | } |
396 | 457 | } |
397 | 458 | else { |
@@ -700,6 +761,7 @@ public class WikiMainWindowController implements Initializable { | ||
700 | 761 | pageData = wikiEngine_.checkin(pageData); |
701 | 762 | } |
702 | 763 | |
764 | + wikiEngine_.clearHistory(); | |
703 | 765 | wikiEngine_.setPageDataMap(WikiEngine.MAINPAGE_TITLE); |
704 | 766 | loadWikiContent(); |
705 | 767 | webViewHyperlinkMain.setId("webViewHyperlinkActive"); |
@@ -911,7 +973,6 @@ public class WikiMainWindowController implements Initializable { | ||
911 | 973 | |
912 | 974 | choiceViewHyperlinkEdit.setDisable(canEdit); |
913 | 975 | |
914 | - | |
915 | 976 | menuItemNew.setDisable(false); |
916 | 977 | AnchorPaneEdit.setVisible(false); |
917 | 978 | AnchorPaneContentList.setVisible(false); |
@@ -9,13 +9,17 @@ | ||
9 | 9 | package com.wiki.standalone.moxkiriya; |
10 | 10 | |
11 | 11 | import java.io.File; |
12 | +import java.io.FileInputStream; | |
13 | +import java.io.FileOutputStream; | |
12 | 14 | import java.net.NetworkInterface; |
13 | 15 | import java.util.ArrayList; |
14 | 16 | import java.util.Enumeration; |
15 | 17 | import java.util.HashMap; |
16 | 18 | import java.util.Hashtable; |
19 | +import java.util.Iterator; | |
17 | 20 | |
18 | 21 | import javax.jcr.Credentials; |
22 | +import javax.jcr.ImportUUIDBehavior; | |
19 | 23 | import javax.jcr.NamespaceException; |
20 | 24 | import javax.jcr.NamespaceRegistry; |
21 | 25 | import javax.jcr.Node; |
@@ -605,4 +609,56 @@ public class WikiRepository { | ||
605 | 609 | |
606 | 610 | return versionHistory.getAllVersions(); |
607 | 611 | } |
612 | + | |
613 | + /** | |
614 | + * Import system view. | |
615 | + * @param outputFile | |
616 | + * @throws Exception | |
617 | + */ | |
618 | + public void importSystemView(File outputFile) throws Exception { | |
619 | + FileInputStream inStream = new FileInputStream(outputFile); | |
620 | + | |
621 | + try { | |
622 | + Node root = session_.getRootNode(); | |
623 | + Node wikiroot = root.getNode(NODE_WIKIROOT); | |
624 | + Node pagesNode = wikiroot.getNode(NODE_PAGES); | |
625 | + | |
626 | + session_.importXML(pagesNode.getPath(), inStream, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING); | |
627 | + session_.save(); | |
628 | + | |
629 | + Node namespaceNode = wikiroot.getNode(NODE_NAMESPACE); | |
630 | + Value[] namespaces = namespaceNode.getProperty(PROPERTY_NAMESPACE).getValues(); | |
631 | + | |
632 | + for(Value namespace: namespaces) { | |
633 | + HashMap<String,PageData> map = queryPageNamespace(namespace.getString()); | |
634 | + Iterator<PageData> iter = map.values().iterator(); | |
635 | + while(iter.hasNext() == true) { | |
636 | + PageData pageData = iter.next(); | |
637 | + checkout(pageData); | |
638 | + checkin(pageData); | |
639 | + } | |
640 | + } | |
641 | + } finally { | |
642 | + inStream.close(); | |
643 | + } | |
644 | + } | |
645 | + | |
646 | + /** | |
647 | + * Export system view. | |
648 | + * @param outputFile | |
649 | + * @throws Exception | |
650 | + */ | |
651 | + public void exportSystemView(File outputFile) throws Exception { | |
652 | + FileOutputStream outStream = new FileOutputStream(outputFile); | |
653 | + | |
654 | + try { | |
655 | + Node root = session_.getRootNode(); | |
656 | + Node wikiroot = root.getNode(NODE_WIKIROOT); | |
657 | + Node pagesNode = wikiroot.getNode(NODE_PAGES); | |
658 | + | |
659 | + session_.exportSystemView(pagesNode.getPath(), outStream, false, false); | |
660 | + } finally { | |
661 | + outStream.close(); | |
662 | + } | |
663 | + } | |
608 | 664 | } |
@@ -19,6 +19,10 @@ public class AlertDialog extends DialogBase { | ||
19 | 19 | public enum MessageType { |
20 | 20 | ConfirmEditCancel, // 編集キャンセル確認ダイアログ |
21 | 21 | AlertTitleEmpty, // Title未入力警告ダイアログ |
22 | + SuccessImport, // Import成功情報ダイアログ | |
23 | + FailureImport, // Import失敗情報ダイアログ | |
24 | + SuccessExport, // Export成功情報ダイアログ | |
25 | + FailureExport, // Export失敗情報ダイアログ | |
22 | 26 | }; |
23 | 27 | |
24 | 28 | /** |
@@ -32,6 +36,14 @@ public class AlertDialog extends DialogBase { | ||
32 | 36 | }; |
33 | 37 | |
34 | 38 | /** |
39 | + * Button種別列挙定数 | |
40 | + */ | |
41 | + public enum ButtoType { | |
42 | + OK, | |
43 | + CANCEL_OK | |
44 | + } | |
45 | + | |
46 | + /** | |
35 | 47 | * メッセージタイプ |
36 | 48 | */ |
37 | 49 | private MessageType msgType_; |
@@ -4,7 +4,6 @@ import java.net.MalformedURLException; | ||
4 | 4 | import java.util.LinkedHashMap; |
5 | 5 | |
6 | 6 | import com.wiki.standalone.moxkiriya.ResourceManager; |
7 | -import com.wiki.standalone.moxkiriya.dialog.AlertDialog.DialogType; | |
8 | 7 | |
9 | 8 | import javafx.event.ActionEvent; |
10 | 9 | import javafx.fxml.FXML; |
@@ -36,15 +35,34 @@ public class AlertDialogController extends DialogControllerBase { | ||
36 | 35 | * Dialogに表示するicon, メッセージ, 詳細を設定する。 |
37 | 36 | */ |
38 | 37 | static class DialogProperty { |
38 | + /** | |
39 | + * Constructor | |
40 | + * @param messageResourceKey | |
41 | + * @param detailResourceKey | |
42 | + * @param dialogType | |
43 | + */ | |
39 | 44 | DialogProperty(String messageResourceKey, String detailResourceKey, AlertDialog.DialogType dialogType) { |
45 | + this(messageResourceKey, detailResourceKey, dialogType, AlertDialog.ButtoType.CANCEL_OK); | |
46 | + }; | |
47 | + | |
48 | + /** | |
49 | + * Constructor. | |
50 | + * @param messageResourceKey | |
51 | + * @param detailResourceKey | |
52 | + * @param dialogType | |
53 | + * @param buttonType | |
54 | + */ | |
55 | + DialogProperty(String messageResourceKey, String detailResourceKey, AlertDialog.DialogType dialogType, AlertDialog.ButtoType buttonType) { | |
40 | 56 | messageResourceKey_ = messageResourceKey; |
41 | 57 | detailResourceKey_ = detailResourceKey; |
42 | 58 | dialogType_ = dialogType; |
59 | + buttonType_ = buttonType; | |
43 | 60 | }; |
44 | 61 | |
45 | 62 | String messageResourceKey_; |
46 | 63 | String detailResourceKey_; |
47 | 64 | AlertDialog.DialogType dialogType_; |
65 | + AlertDialog.ButtoType buttonType_; | |
48 | 66 | }; |
49 | 67 | |
50 | 68 | /** |
@@ -62,7 +80,28 @@ public class AlertDialogController extends DialogControllerBase { | ||
62 | 80 | put(AlertDialog.MessageType.AlertTitleEmpty, |
63 | 81 | new DialogProperty("key.Dialog.Message.Empty.Title", |
64 | 82 | "key.Dialog.Detail.Input.Title", |
65 | - AlertDialog.DialogType.Alert)); | |
83 | + AlertDialog.DialogType.Alert, | |
84 | + AlertDialog.ButtoType.OK)); | |
85 | + put(AlertDialog.MessageType.SuccessImport, | |
86 | + new DialogProperty("key.Dialog.Import.Result.Title", | |
87 | + "key.Dialog.Detail.Import.Success", | |
88 | + AlertDialog.DialogType.Info, | |
89 | + AlertDialog.ButtoType.OK)); | |
90 | + put(AlertDialog.MessageType.FailureImport, | |
91 | + new DialogProperty("key.Dialog.Import.Result.Title", | |
92 | + "key.Dialog.Detail.Import.Failure", | |
93 | + AlertDialog.DialogType.Error, | |
94 | + AlertDialog.ButtoType.OK)); | |
95 | + put(AlertDialog.MessageType.SuccessExport, | |
96 | + new DialogProperty("key.Dialog.Export.Result.Title", | |
97 | + "key.Dialog.Detail.Export.Success", | |
98 | + AlertDialog.DialogType.Info, | |
99 | + AlertDialog.ButtoType.OK)); | |
100 | + put(AlertDialog.MessageType.FailureExport, | |
101 | + new DialogProperty("key.Dialog.Export.Result.Title", | |
102 | + "key.Dialog.Detail.Export.Failure", | |
103 | + AlertDialog.DialogType.Error, | |
104 | + AlertDialog.ButtoType.OK)); | |
66 | 105 | } |
67 | 106 | }; |
68 | 107 |
@@ -90,7 +129,7 @@ public class AlertDialogController extends DialogControllerBase { | ||
90 | 129 | /* |
91 | 130 | * ボタンを設定する。 |
92 | 131 | */ |
93 | - if(dialogProperty.dialogType_ == DialogType.Alert) { | |
132 | + if(dialogProperty.buttonType_ == AlertDialog.ButtoType.OK) { | |
94 | 133 | buttonCancel.setVisible(false); |
95 | 134 | } |
96 | 135 | else { |
@@ -26,6 +26,8 @@ key.Menu.Edit: Edit | ||
26 | 26 | key.Menu.Help: Help |
27 | 27 | |
28 | 28 | key.MenuItem.New: New |
29 | +key.MenuItem.Import: Import | |
30 | +key.MenuItem.Export: Export | |
29 | 31 | key.MenuItem.Exit: Exit |
30 | 32 | key.MenuItem.Select.Party: Select a party |
31 | 33 | key.MenuItem.About.Moxkiriya: About Moxkiriya. |
@@ -87,6 +89,17 @@ key.Dialog.Detail.Cancel.Editing: Discard the editing content when you cancel ed | ||
87 | 89 | key.Dialog.Message.Empty.Title: Title is empty. |
88 | 90 | key.Dialog.Detail.Input.Title: Please input title. |
89 | 91 | |
92 | +key.Dialog.Import.Result.Title: Import result. | |
93 | +key.Dialog.Detail.Import.Success: Succeeded to import.\nExit application to refresh a repository. | |
94 | +key.Dialog.Detail.Import.Failure: Failed to import. | |
95 | + | |
96 | +key.Dialog.Export.Result.Title: Export result. | |
97 | +key.Dialog.Detail.Export.Success: Succeeded to Export. | |
98 | +key.Dialog.Detail.Export.Failure: Failed to Export. | |
99 | + | |
100 | +key.ImportDialog.Title: Select an import file | |
101 | +key.ExportDialog.Title: Select an export file | |
102 | + | |
90 | 103 | key.EditAttachedFileDialog.Title: Edit attach files. |
91 | 104 | key.EditAttachedFileDialog.Button.DeleteCheckedFiles: Delete checked files |
92 | 105 | key.EditAttachedFileDialog.Addfiles.DialogTitle: Select attach files. |