Moxkiriyaプロジェクト事前開発用の作業部屋
Revision | 318d35df6e23b82183ff6a3dd6dc80dc1085a7b5 (tree) |
---|---|
Zeit | 2018-10-20 22:20:54 |
Autor | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -20,6 +20,7 @@ import java.util.ResourceBundle; | ||
20 | 20 | import javax.jcr.Node; |
21 | 21 | import javax.jcr.Property; |
22 | 22 | import javax.jcr.Value; |
23 | +import javax.jcr.version.Version; | |
23 | 24 | import javax.jcr.version.VersionIterator; |
24 | 25 | |
25 | 26 | import com.wiki.standalone.moxkiriya.parser.blockparser.WikiBodyBlockParser; |
@@ -538,6 +539,32 @@ public class WikiEngine { | ||
538 | 539 | return wikiRepository_.getVersionHistory(uuid); |
539 | 540 | } |
540 | 541 | |
542 | + /** | |
543 | + * Base version getter. | |
544 | + * @return Version | |
545 | + * @throws Exception | |
546 | + */ | |
547 | + public Version getBaseVersion() throws Exception { | |
548 | + PageData pageData = pageDataMap_.values().iterator().next(); | |
549 | + | |
550 | + return wikiRepository_.getBaseVersion(pageData.getNode()); | |
551 | + } | |
552 | + | |
553 | + /** | |
554 | + * Restore version. | |
555 | + * @param version | |
556 | + * @throws Exception | |
557 | + */ | |
558 | + public void restoreVersion(Version version) throws Exception { | |
559 | + PageData pageData = pageDataMap_.values().iterator().next(); | |
560 | + wikiRepository_.restoreVersion(version, pageData.getNode()); | |
561 | + } | |
562 | + | |
563 | + /** | |
564 | + * Import system vies. | |
565 | + * @param outputFile | |
566 | + * @throws Exception | |
567 | + */ | |
541 | 568 | public void importSystemView(File outputFile) throws Exception { |
542 | 569 | wikiRepository_.importSystemView(outputFile); |
543 | 570 | } |
@@ -104,7 +104,7 @@ | ||
104 | 104 | </AnchorPane> |
105 | 105 | <AnchorPane id="webViewHistoryAnchorPane" fx:id="webViewAnchorPaneHistory" prefHeight="528.0" prefWidth="843.0" style="" styleClass="webViewMainAnchorPane" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="180.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="85.0"> |
106 | 106 | <children> |
107 | - <AnchorPane fx:id="webViewHistoryBreadcrumbs" prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="5.0"> | |
107 | + <AnchorPane fx:id="webViewHistoryBreadcrumbs" prefHeight="35.0" prefWidth="200.0" visible="true" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="5.0"> | |
108 | 108 | <children> |
109 | 109 | <FlowPane fx:id="webViewHistoryBreadcrumbsPane" prefHeight="40.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> |
110 | 110 | <padding> |
@@ -119,10 +119,11 @@ | ||
119 | 119 | <ListView fx:id="webViewHistoryListView" prefHeight="200.0" prefWidth="200.0" visible="true" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="40.0" /> |
120 | 120 | <AnchorPane fx:id="webViewHistoryAnchorPaneContent" prefHeight="200.0" prefWidth="200.0" styleClass="webViewHistoryContentAnchorPane" visible="false" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="40.0"> |
121 | 121 | <children> |
122 | - <Label font="$x3" prefHeight="30.0" text="%key.History.Content.Title" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="30.0" /> | |
123 | - <TextField fx:id="webViewHistoryTextFieldTitle" alignment="CENTER_LEFT" editable="false" focusTraversable="false" prefHeight="30.0" prefWidth="200.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0" AnchorPane.topAnchor="60.0" /> | |
124 | - <Label prefHeight="30.0" text="%key.Edit.Label.Contents" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="110.0" /> | |
125 | - <TextArea fx:id="webViewHistorytextAreaContents" editable="false" focusTraversable="false" prefWidth="200.0" wrapText="true" AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0" AnchorPane.topAnchor="140.0" /> | |
122 | + <Label font="$x3" prefHeight="30.0" text="%key.History.Content.Title" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="10.0" /> | |
123 | + <TextField fx:id="webViewHistoryTextFieldTitle" alignment="CENTER_LEFT" editable="false" focusTraversable="false" prefHeight="30.0" prefWidth="200.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0" AnchorPane.topAnchor="40.0" /> | |
124 | + <Label prefHeight="30.0" text="%key.Edit.Label.Contents" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="90.0" /> | |
125 | + <TextArea fx:id="webViewHistorytextAreaContents" editable="false" focusTraversable="false" prefWidth="200.0" wrapText="true" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0" AnchorPane.topAnchor="120.0" /> | |
126 | + <Button fx:id="webViewHistoryButtonRestoreVersion" maxHeight="-Infinity" mnemonicParsing="false" onAction="#onActionButtonRestoreVersion" prefHeight="30.0" text="%key.Button.Restore.Version" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="30.0" /> | |
126 | 127 | </children> |
127 | 128 | <stylesheets> |
128 | 129 | <URL value="@application.css" /> |
@@ -132,6 +132,7 @@ public class WikiMainWindowController implements Initializable { | ||
132 | 132 | @FXML private AnchorPane webViewHistoryAnchorPaneContent; |
133 | 133 | @FXML private TextField webViewHistoryTextFieldTitle; |
134 | 134 | @FXML private TextArea webViewHistorytextAreaContents; |
135 | + @FXML private Button webViewHistoryButtonRestoreVersion; | |
135 | 136 | |
136 | 137 | /* |
137 | 138 | * editAnchorPane controls. |
@@ -180,6 +181,9 @@ public class WikiMainWindowController implements Initializable { | ||
180 | 181 | * Version history list item |
181 | 182 | */ |
182 | 183 | public class VersionHistoryListItem { |
184 | + /** version */ | |
185 | + private Version version_; | |
186 | + | |
183 | 187 | /** Created data. */ |
184 | 188 | private Date created_; |
185 | 189 |
@@ -191,12 +195,21 @@ public class WikiMainWindowController implements Initializable { | ||
191 | 195 | * @param created |
192 | 196 | * @param node |
193 | 197 | */ |
194 | - public VersionHistoryListItem(Date created, Node node) { | |
198 | + public VersionHistoryListItem(Version version, Date created, Node node) { | |
199 | + version_ = version; | |
195 | 200 | created_ = created; |
196 | 201 | node_ = node; |
197 | 202 | } |
198 | 203 | |
199 | 204 | /** |
205 | + * Version getter. | |
206 | + * @return Version | |
207 | + */ | |
208 | + public Version getVersion() { | |
209 | + return version_; | |
210 | + } | |
211 | + | |
212 | + /** | |
200 | 213 | * Created getter. |
201 | 214 | * @return Date |
202 | 215 | */ |
@@ -301,47 +314,59 @@ public class WikiMainWindowController implements Initializable { | ||
301 | 314 | return new ListCell<VersionHistoryListItem>() { |
302 | 315 | @Override |
303 | 316 | protected void updateItem(VersionHistoryListItem item, boolean empty) { |
304 | - super.updateItem(item, empty); | |
305 | - if(empty != true) { | |
306 | - Hyperlink hyperlinkCreated = new Hyperlink(item.getCreated().toString()); | |
307 | - | |
308 | - hyperlinkCreated.setUserData(item.getNode()); | |
309 | - hyperlinkCreated.setOnAction(new EventHandler<ActionEvent>() { | |
310 | - @Override | |
311 | - public void handle(ActionEvent event) { | |
312 | - try { | |
313 | - ObservableList<javafx.scene.Node> breadcrumbsList = webViewHistoryBreadcrumbsPane.getChildren(); | |
314 | - | |
315 | - breadcrumbsList.clear(); | |
316 | - breadcrumbsList.add(createBreadcrumbsHyperlink("key.History.Breadcrumbs.List", | |
317 | - new EventHandler<ActionEvent>() { | |
318 | - @Override | |
319 | - public void handle(ActionEvent event) { | |
320 | - ObservableList<javafx.scene.Node> breadcrumbsList = webViewHistoryBreadcrumbsPane.getChildren(); | |
321 | - | |
322 | - breadcrumbsList.clear(); | |
323 | - breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.List")); | |
324 | - webViewHistoryListView.setVisible(true); | |
325 | - webViewHistoryAnchorPaneContent.setVisible(false); | |
326 | - } | |
327 | - })); | |
328 | - breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.Separator")); | |
329 | - breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.Content")); | |
317 | + try { | |
318 | + super.updateItem(item, empty); | |
319 | + if(empty != true) { | |
320 | + Hyperlink hyperlinkCreated = new Hyperlink(item.getCreated().toString()); | |
321 | + Version version = item.getVersion(); | |
322 | + Version baseVersion = wikiEngine_.getBaseVersion(); | |
323 | + | |
324 | + if(version.getIdentifier().equals(baseVersion.getIdentifier()) == true) { | |
325 | + hyperlinkCreated.setId("webViewHistoryBaseVersion"); | |
326 | + } | |
327 | + | |
328 | + hyperlinkCreated.setUserData(item); | |
329 | + hyperlinkCreated.setOnAction(new EventHandler<ActionEvent>() { | |
330 | + @Override | |
331 | + public void handle(ActionEvent event) { | |
332 | + try { | |
333 | + ObservableList<javafx.scene.Node> breadcrumbsList = webViewHistoryBreadcrumbsPane.getChildren(); | |
334 | + | |
335 | + breadcrumbsList.clear(); | |
336 | + breadcrumbsList.add(createBreadcrumbsHyperlink("key.History.Breadcrumbs.List", | |
337 | + new EventHandler<ActionEvent>() { | |
338 | + @Override | |
339 | + public void handle(ActionEvent event) { | |
340 | + ObservableList<javafx.scene.Node> breadcrumbsList = webViewHistoryBreadcrumbsPane.getChildren(); | |
341 | + | |
342 | + breadcrumbsList.clear(); | |
343 | + breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.List")); | |
344 | + webViewHistoryListView.setVisible(true); | |
345 | + webViewHistoryAnchorPaneContent.setVisible(false); | |
346 | + } | |
347 | + })); | |
348 | + breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.Separator")); | |
349 | + breadcrumbsList.add(createBreadcrumbsLabel("key.History.Breadcrumbs.Content")); | |
350 | + | |
351 | + Hyperlink target = (Hyperlink)event.getTarget(); | |
352 | + VersionHistoryListItem item = (VersionHistoryListItem)target.getUserData(); | |
353 | + Node node = item.getNode(); | |
330 | 354 | |
331 | - Hyperlink target = (Hyperlink)event.getTarget(); | |
332 | - Node node = (Node)target.getUserData(); | |
333 | - | |
334 | - webViewHistoryTextFieldTitle.setText(node.getProperty(WikiRepository.PROPERTY_TITLE).getString()); | |
335 | - webViewHistorytextAreaContents.setText((node.getProperty(WikiRepository.PROPERTY_CONTENT).getString())); | |
336 | - | |
337 | - webViewHistoryListView.setVisible(false); | |
338 | - webViewHistoryAnchorPaneContent.setVisible(true); | |
339 | - } catch (Exception e) { | |
340 | - e.printStackTrace(); | |
341 | - } | |
342 | - } | |
343 | - }); | |
344 | - setGraphic(hyperlinkCreated); | |
355 | + webViewHistoryTextFieldTitle.setText(node.getProperty(WikiRepository.PROPERTY_TITLE).getString()); | |
356 | + webViewHistorytextAreaContents.setText((node.getProperty(WikiRepository.PROPERTY_CONTENT).getString())); | |
357 | + webViewHistoryAnchorPaneContent.setUserData(item); | |
358 | + | |
359 | + webViewHistoryListView.setVisible(false); | |
360 | + webViewHistoryAnchorPaneContent.setVisible(true); | |
361 | + } catch (Exception e) { | |
362 | + e.printStackTrace(); | |
363 | + } | |
364 | + } | |
365 | + }); | |
366 | + setGraphic(hyperlinkCreated); | |
367 | + } | |
368 | + } catch (Exception e1) { | |
369 | + e1.printStackTrace(); | |
345 | 370 | } |
346 | 371 | } |
347 | 372 | }; |
@@ -747,7 +772,7 @@ public class WikiMainWindowController implements Initializable { | ||
747 | 772 | while(nodeIter.hasNext() == true) { |
748 | 773 | Node node = nodeIter.nextNode(); |
749 | 774 | |
750 | - list.add(new VersionHistoryListItem(version.getCreated().getTime(), node)); | |
775 | + list.add(new VersionHistoryListItem(version, version.getCreated().getTime(), node)); | |
751 | 776 | } |
752 | 777 | } |
753 | 778 |
@@ -762,6 +787,24 @@ public class WikiMainWindowController implements Initializable { | ||
762 | 787 | e.printStackTrace(); |
763 | 788 | } |
764 | 789 | } |
790 | + | |
791 | + @FXML | |
792 | + public void onActionButtonRestoreVersion(ActionEvent event) { | |
793 | + try { | |
794 | + VersionHistoryListItem item = (VersionHistoryListItem)webViewHistoryAnchorPaneContent.getUserData(); | |
795 | + wikiEngine_.restoreVersion(item.getVersion()); | |
796 | + | |
797 | + wikiEngine_.refreshSession(); | |
798 | + loadWikiContent(); | |
799 | + | |
800 | + webViewHyperlinkMain.setId("webViewMainHyperlinkActive"); | |
801 | + webViewHyperlinkHistory.setId("webViewMainHyperlinkInactive"); | |
802 | + webViewAnchorPaneMain.setVisible(true); | |
803 | + webViewAnchorPaneHistory.setVisible(false); | |
804 | + } catch (Exception e) { | |
805 | + e.printStackTrace(); | |
806 | + } | |
807 | + } | |
765 | 808 | |
766 | 809 | @FXML |
767 | 810 | public void onActionButtonDeletePages(ActionEvent event) { |
@@ -34,6 +34,7 @@ import javax.jcr.Workspace; | ||
34 | 34 | import javax.jcr.nodetype.NodeType; |
35 | 35 | import javax.jcr.query.Query; |
36 | 36 | import javax.jcr.query.QueryManager; |
37 | +import javax.jcr.version.Version; | |
37 | 38 | import javax.jcr.version.VersionHistory; |
38 | 39 | import javax.jcr.version.VersionIterator; |
39 | 40 | import javax.jcr.version.VersionManager; |
@@ -611,6 +612,32 @@ public class WikiRepository { | ||
611 | 612 | } |
612 | 613 | |
613 | 614 | /** |
615 | + * Base version getter. | |
616 | + * @param node | |
617 | + * @return Version | |
618 | + * @throws Exception | |
619 | + */ | |
620 | + public Version getBaseVersion(Node node) throws Exception { | |
621 | + Workspace workspace = session_.getWorkspace(); | |
622 | + VersionManager versionMgr = workspace.getVersionManager(); | |
623 | + | |
624 | + return versionMgr.getBaseVersion(node.getPath()); | |
625 | + } | |
626 | + | |
627 | + /** | |
628 | + * Restore version. | |
629 | + * @param version | |
630 | + * @param node | |
631 | + * @throws Exception | |
632 | + */ | |
633 | + public void restoreVersion(Version version, Node node) throws Exception { | |
634 | + Workspace workspace = session_.getWorkspace(); | |
635 | + VersionManager versionMgr = workspace.getVersionManager(); | |
636 | + | |
637 | + versionMgr.restore(version, true); | |
638 | + } | |
639 | + | |
640 | + /** | |
614 | 641 | * Import system view. |
615 | 642 | * @param outputFile |
616 | 643 | * @throws Exception |
@@ -52,4 +52,9 @@ | ||
52 | 52 | #webViewBreadcrumbs { |
53 | 53 | -fx-alignment: center-left; |
54 | 54 | -fx-padding: 0.0 2.0 0.0 2.0; |
55 | +} | |
56 | + | |
57 | +#webViewHistoryBaseVersion { | |
58 | + -fx-font-weight: bold; | |
59 | + -fx-text-fill: crimson; | |
55 | 60 | } |
\ No newline at end of file |
@@ -22,6 +22,7 @@ key.Button.Add.Category: Add new category | ||
22 | 22 | key.Button.Delete.Pages: Delete selected pages |
23 | 23 | key.Button.Add.Party: Add new party |
24 | 24 | key.Button.Preview: Preview |
25 | +key.Button.Restore.Version: Restore this version | |
25 | 26 | |
26 | 27 | key.Menu.File: File |
27 | 28 | key.Menu.Edit: Edit |