• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Révision2c20144e0f106515aefef5692fbb3f4313bbf763 (tree)
l'heure2018-10-09 14:19:00
AuteurHarold_Andoh <andolloyd@gmai...>
CommiterHarold_Andoh

Message de Log

[Moxkiriya7]

  • コンテンツのExport/Import機能を追加
  • Alertダイアログのキャンセルボタンの表示/非表示の制御を修正
    *
    コンテンツを削除した場合、JCRのItemStatus例外が起こる場合があるバグを修正

Change Summary

Modification

--- a/src/com/wiki/standalone/moxkiriya/WikiEngine.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiEngine.java
@@ -493,6 +493,13 @@ public class WikiEngine {
493493 }
494494
495495 /**
496+ * History clear.
497+ */
498+ public void clearHistory() {
499+ wikiHistory_.clear();
500+ }
501+
502+ /**
496503 * VersionHistory getter.
497504 * @return VersionIterator
498505 * @throws Exception
@@ -503,6 +510,19 @@ public class WikiEngine {
503510
504511 return wikiRepository_.getVersionHistory(uuid);
505512 }
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+ }
506526
507527 /**
508528 * Session closer.
--- a/src/com/wiki/standalone/moxkiriya/WikiHistory.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiHistory.java
@@ -120,4 +120,12 @@ public class WikiHistory {
120120 histories_.add(pageData);
121121 position_ = histories_.size() - 1;
122122 }
123+
124+ /**
125+ * Clear history.
126+ */
127+ public void clear() {
128+ histories_.clear();
129+ position_ = 0;
130+ }
123131 }
--- a/src/com/wiki/standalone/moxkiriya/WikiMainWindow.fxml
+++ b/src/com/wiki/standalone/moxkiriya/WikiMainWindow.fxml
@@ -19,6 +19,8 @@
1919 <Menu mnemonicParsing="false" text="%key.Menu.File">
2020 <items>
2121 <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" />
2224 <MenuItem mnemonicParsing="false" onAction="#onActionMenuItemExit" text="%key.MenuItem.Exit" fx:id="menuItemExit" />
2325 </items>
2426 </Menu>
--- a/src/com/wiki/standalone/moxkiriya/WikiMainWindowController.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiMainWindowController.java
@@ -65,6 +65,7 @@ import javafx.scene.layout.FlowPane;
6565 import javafx.scene.web.WebEngine;
6666 import javafx.scene.web.WebView;
6767 import javafx.stage.FileChooser;
68+import javafx.stage.FileChooser.ExtensionFilter;
6869 import javafx.stage.Modality;
6970 import javafx.stage.Stage;
7071 import javafx.stage.StageStyle;
@@ -87,6 +88,8 @@ public class WikiMainWindowController implements Initializable {
8788 * MenuBar controls.
8889 */
8990 @FXML private MenuItem menuItemNew;
91+ @FXML private MenuItem menuItemImport;
92+ @FXML private MenuItem menuItemExport;
9093 @FXML private MenuItem menuItemExit;
9194 @FXML private MenuItem menuItemSelectParty;
9295 @FXML private MenuItem menuItemAboutMoxkiriya;
@@ -379,8 +382,65 @@ public class WikiMainWindowController implements Initializable {
379382 textAreaContents.clear();
380383 buildEditView("");
381384 }
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+ }
382416
383417 @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
384444 public void onActionMenuItemExit(ActionEvent event) {
385445 try {
386446 if (AnchorPaneEdit.isVisible() == true) {
@@ -392,6 +452,7 @@ public class WikiMainWindowController implements Initializable {
392452 editMode_ = EditMode.NONE;
393453 wikiEngine_.cancelCheckout();
394454 stage_.hide();
455+ stage_.getOwner().hide();
395456 }
396457 }
397458 else {
@@ -700,6 +761,7 @@ public class WikiMainWindowController implements Initializable {
700761 pageData = wikiEngine_.checkin(pageData);
701762 }
702763
764+ wikiEngine_.clearHistory();
703765 wikiEngine_.setPageDataMap(WikiEngine.MAINPAGE_TITLE);
704766 loadWikiContent();
705767 webViewHyperlinkMain.setId("webViewHyperlinkActive");
@@ -911,7 +973,6 @@ public class WikiMainWindowController implements Initializable {
911973
912974 choiceViewHyperlinkEdit.setDisable(canEdit);
913975
914-
915976 menuItemNew.setDisable(false);
916977 AnchorPaneEdit.setVisible(false);
917978 AnchorPaneContentList.setVisible(false);
--- a/src/com/wiki/standalone/moxkiriya/WikiRepository.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiRepository.java
@@ -9,13 +9,17 @@
99 package com.wiki.standalone.moxkiriya;
1010
1111 import java.io.File;
12+import java.io.FileInputStream;
13+import java.io.FileOutputStream;
1214 import java.net.NetworkInterface;
1315 import java.util.ArrayList;
1416 import java.util.Enumeration;
1517 import java.util.HashMap;
1618 import java.util.Hashtable;
19+import java.util.Iterator;
1720
1821 import javax.jcr.Credentials;
22+import javax.jcr.ImportUUIDBehavior;
1923 import javax.jcr.NamespaceException;
2024 import javax.jcr.NamespaceRegistry;
2125 import javax.jcr.Node;
@@ -605,4 +609,56 @@ public class WikiRepository {
605609
606610 return versionHistory.getAllVersions();
607611 }
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+ }
608664 }
--- a/src/com/wiki/standalone/moxkiriya/dialog/AlertDialog.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/AlertDialog.java
@@ -19,6 +19,10 @@ public class AlertDialog extends DialogBase {
1919 public enum MessageType {
2020 ConfirmEditCancel, // 編集キャンセル確認ダイアログ
2121 AlertTitleEmpty, // Title未入力警告ダイアログ
22+ SuccessImport, // Import成功情報ダイアログ
23+ FailureImport, // Import失敗情報ダイアログ
24+ SuccessExport, // Export成功情報ダイアログ
25+ FailureExport, // Export失敗情報ダイアログ
2226 };
2327
2428 /**
@@ -32,6 +36,14 @@ public class AlertDialog extends DialogBase {
3236 };
3337
3438 /**
39+ * Button種別列挙定数
40+ */
41+ public enum ButtoType {
42+ OK,
43+ CANCEL_OK
44+ }
45+
46+ /**
3547 * メッセージタイプ
3648 */
3749 private MessageType msgType_;
--- a/src/com/wiki/standalone/moxkiriya/dialog/AlertDialogController.java
+++ b/src/com/wiki/standalone/moxkiriya/dialog/AlertDialogController.java
@@ -4,7 +4,6 @@ import java.net.MalformedURLException;
44 import java.util.LinkedHashMap;
55
66 import com.wiki.standalone.moxkiriya.ResourceManager;
7-import com.wiki.standalone.moxkiriya.dialog.AlertDialog.DialogType;
87
98 import javafx.event.ActionEvent;
109 import javafx.fxml.FXML;
@@ -36,15 +35,34 @@ public class AlertDialogController extends DialogControllerBase {
3635 * Dialogに表示するicon, メッセージ, 詳細を設定する。
3736 */
3837 static class DialogProperty {
38+ /**
39+ * Constructor
40+ * @param messageResourceKey
41+ * @param detailResourceKey
42+ * @param dialogType
43+ */
3944 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) {
4056 messageResourceKey_ = messageResourceKey;
4157 detailResourceKey_ = detailResourceKey;
4258 dialogType_ = dialogType;
59+ buttonType_ = buttonType;
4360 };
4461
4562 String messageResourceKey_;
4663 String detailResourceKey_;
4764 AlertDialog.DialogType dialogType_;
65+ AlertDialog.ButtoType buttonType_;
4866 };
4967
5068 /**
@@ -62,7 +80,28 @@ public class AlertDialogController extends DialogControllerBase {
6280 put(AlertDialog.MessageType.AlertTitleEmpty,
6381 new DialogProperty("key.Dialog.Message.Empty.Title",
6482 "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));
66105 }
67106 };
68107
@@ -90,7 +129,7 @@ public class AlertDialogController extends DialogControllerBase {
90129 /*
91130 * ボタンを設定する。
92131 */
93- if(dialogProperty.dialogType_ == DialogType.Alert) {
132+ if(dialogProperty.buttonType_ == AlertDialog.ButtoType.OK) {
94133 buttonCancel.setVisible(false);
95134 }
96135 else {
--- a/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
+++ b/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
@@ -26,6 +26,8 @@ key.Menu.Edit: Edit
2626 key.Menu.Help: Help
2727
2828 key.MenuItem.New: New
29+key.MenuItem.Import: Import
30+key.MenuItem.Export: Export
2931 key.MenuItem.Exit: Exit
3032 key.MenuItem.Select.Party: Select a party
3133 key.MenuItem.About.Moxkiriya: About Moxkiriya.
@@ -87,6 +89,17 @@ key.Dialog.Detail.Cancel.Editing: Discard the editing content when you cancel ed
8789 key.Dialog.Message.Empty.Title: Title is empty.
8890 key.Dialog.Detail.Input.Title: Please input title.
8991
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+
90103 key.EditAttachedFileDialog.Title: Edit attach files.
91104 key.EditAttachedFileDialog.Button.DeleteCheckedFiles: Delete checked files
92105 key.EditAttachedFileDialog.Addfiles.DialogTitle: Select attach files.