• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

修订版391cde6c9d96bc1ee9a2c09e3f7e28e1b78bdcac (tree)
时间2018-09-22 14:05:05
作者Harold_Andoh <andolloyd@gmai...>
CommiterHarold_Andoh

Log Message

[Moxkiriya7]

  • Page一覧の仕様を刷新(JavaFX#TableView)に変更

更改概述

差异

--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
11 bin
2+derby.log
--- a/src/com/wiki/standalone/moxkiriya/Main.java
+++ b/src/com/wiki/standalone/moxkiriya/Main.java
@@ -133,7 +133,7 @@ public class Main extends Application {
133133 Scene scene = new Scene((Parent)loader.getRoot());
134134 scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
135135
136- wikiEngine_.setPageTitle(WikiEngine.MAINPAGE_TITLE);
136+ wikiEngine_.setCurrentPage(WikiEngine.MAINPAGE_TITLE);
137137 controller_.loadWikiContent();
138138
139139 primaryStage_.setScene(scene);
--- a/src/com/wiki/standalone/moxkiriya/PageData.java
+++ b/src/com/wiki/standalone/moxkiriya/PageData.java
@@ -7,18 +7,26 @@
77 */
88 package com.wiki.standalone.moxkiriya;
99
10+import java.io.BufferedReader;
1011 import java.io.File;
1112 import java.io.FileInputStream;
1213 import java.io.InputStream;
14+import java.io.StringReader;
1315 import java.util.ArrayList;
1416 import java.util.Calendar;
17+import java.util.regex.Pattern;
1518
1619 import javax.activation.FileTypeMap;
1720 import javax.jcr.Node;
1821 import javax.jcr.PathNotFoundException;
1922 import javax.jcr.Property;
23+import javax.jcr.RepositoryException;
2024 import javax.jcr.Value;
2125
26+import com.wiki.standalone.moxkiriya.util.FileIO;
27+
28+import javafx.beans.property.SimpleStringProperty;
29+import javafx.beans.property.StringProperty;
2230
2331 /**
2432 * Page data structure.
@@ -91,6 +99,22 @@ public class PageData {
9199 // Ignore exception.
92100 }
93101 }
102+
103+ /**
104+ * UUID property getter.
105+ * @return StringProperty
106+ */
107+ public StringProperty uuidProperty() {
108+ SimpleStringProperty property = new SimpleStringProperty();
109+
110+ try {
111+ property.setValue(node_.getProperty(Property.JCR_UUID).getString());
112+ } catch (RepositoryException e) {
113+ e.printStackTrace();
114+ }
115+
116+ return property;
117+ }
94118
95119 /**
96120 * Namespace getter.
@@ -125,6 +149,14 @@ public class PageData {
125149 }
126150
127151 /**
152+ * titleProperty getter.
153+ * @return StringProperty
154+ */
155+ public StringProperty titleProperty() {
156+ return new SimpleStringProperty(title_);
157+ }
158+
159+ /**
128160 * Content getter.
129161 * @return String
130162 */
@@ -142,6 +174,64 @@ public class PageData {
142174 }
143175
144176 /**
177+ * Introduction getter.
178+ * Introduction is the first part of the page.
179+ * The part is extracted until the following conditions are satisfied.
180+ * <ul>
181+ * <li>Up to the first heading.</li>
182+ * <li>255 characters</li>
183+ * <li>3 lines</li>
184+ * </ul>
185+ * @return String
186+ * @throws Exception
187+ */
188+ public String getIntroduction() throws Exception {
189+ BufferedReader buffreader = FileIO.bufferedReader(new StringReader(content_));
190+ String line;
191+ StringBuffer buf = new StringBuffer("");
192+ int lineCount = 0;
193+ int charCount = 0;
194+ Pattern hnPattern = Pattern.compile("^={2,6}[^=]+={2,6}$");
195+
196+ while((line = buffreader.readLine()) != null) {
197+ if(hnPattern.matcher(line).matches() == true) {
198+ break;
199+ }
200+ else if(charCount + line.length() > 255) {
201+ buf.append(line.substring(0, 255 - charCount));
202+ charCount = 255;
203+ break;
204+ }
205+ else {
206+ buf.append(line + "\n");
207+ charCount += line.length() + 1;
208+ lineCount++;
209+
210+ if(lineCount >= 3) {
211+ break;
212+ }
213+ }
214+ }
215+
216+ return buf.toString();
217+ }
218+
219+ /**
220+ * contentProperty getter.
221+ * @return StringProperty
222+ */
223+ public StringProperty introductionProperty() {
224+ String introduction = "";
225+ try {
226+ introduction = getIntroduction();
227+ } catch (Exception e) {
228+ e.printStackTrace();
229+ }
230+
231+ return new SimpleStringProperty(introduction);
232+ }
233+
234+ /**
145235 * Categories getter.
146236 * @return ArrayList<String>
147237 */
--- a/src/com/wiki/standalone/moxkiriya/WikiEngine.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiEngine.java
@@ -6,12 +6,14 @@ import java.io.FileInputStream;
66 import java.io.IOException;
77 import java.io.InputStream;
88 import java.io.StringReader;
9+import java.util.ArrayList;
910 import java.util.HashMap;
1011 import java.util.ResourceBundle;
1112 import java.util.Set;
1213
14+import javax.jcr.Value;
15+
1316 import com.wiki.standalone.moxkiriya.parser.blockparser.WikiBodyBlockParser;
14-import com.wiki.standalone.moxkiriya.parser.inlineparser.WikiInternalLinkInlineParser;
1517 import com.wiki.standalone.moxkiriya.util.FileIO;
1618
1719 public class WikiEngine {
@@ -24,15 +26,12 @@ public class WikiEngine {
2426 /** template file HTML<head>section. */
2527 public static final String TEMPLATE_HTMLHEADER_FILE = "templateHtmlHead.txt";
2628
29+ /** jcr_uuid 独自属性 */
30+ public static final String ATTRIBUTE_JCR_UUID = "data-jcr_uuid";
31+
2732 /** Wiki Repository. */
2833 private WikiRepository wikiRepository_;
2934
30- /** Now page title */
31- private String pageTitle_;
32-
33- /** List of PageData */
34- private HashMap<String, PageData> pageDataMap_;
35-
3635 /** Current page data. */
3736 private PageData currentPageData_ = null;
3837
@@ -45,34 +44,29 @@ public class WikiEngine {
4544 }
4645
4746 /**
48- * pageTitle setter.
47+ * Current page setter.
4948 * @param pageTitle
5049 * @param pageDataMap
5150 * @throws Exception
5251 */
53- public void setPageTitle(String pageTitle, String identifier, HashMap<String, PageData> pageDataMap) throws Exception {
54- pageTitle_ = pageTitle;
55- pageDataMap_ = pageDataMap != null
56- ? pageDataMap
57- : wikiRepository_.queryNodePageTitle(pageTitle);
58- currentPageData_ = pageDataMap_.get(identifier);
52+ public void setCurrentPage(PageData pageData) {
53+ currentPageData_ = pageData;
5954 }
6055
6156 /**
62- * pageTitle setter.
57+ * Current page setter.
6358 * @param pageTitle
6459 * @param pageDataMap
6560 * @throws Exception
6661 */
67- public void setPageTitle(String pageTitle, HashMap<String, PageData> pageDataMap) throws Exception {
68- pageTitle_ = pageTitle;
69- pageDataMap_ = pageDataMap != null
70- ? pageDataMap
71- : wikiRepository_.queryNodePageTitle(pageTitle);
72-
73- if(pageDataMap_.size() == 1) {
74- Set<String> key = pageDataMap_.keySet();
75- currentPageData_ = pageDataMap_.get(key.iterator().next());
62+ public void setCurrentPage(String pageTitle, HashMap<String, PageData> pageDataMap) throws Exception {
63+ if(pageDataMap == null) {
64+ pageDataMap = wikiRepository_.queryPageTitle(pageTitle);
65+ }
66+
67+ if(pageDataMap.size() == 1) {
68+ Set<String> key = pageDataMap.keySet();
69+ currentPageData_ = pageDataMap.get(key.iterator().next());
7670 }
7771 else {
7872 currentPageData_ = null;
@@ -80,19 +74,12 @@ public class WikiEngine {
8074 }
8175
8276 /**
83- * pageTitle setter.
77+ * Current page setter.
8478 * @param pageTitle
8579 * @throws Exception
8680 */
87- public void setPageTitle(String pageTitle) throws Exception {
88- setPageTitle(pageTitle, null);
89- }
90-
91- /**
92- * pageTitle getter.
93- */
94- public String getPageTitle() {
95- return pageTitle_;
81+ public void setCurrentPage(String pageTitle) throws Exception {
82+ setCurrentPage(pageTitle, null);
9683 }
9784
9885 /**
@@ -104,13 +91,22 @@ public class WikiEngine {
10491 }
10592
10693 /**
94+ * pageTitle getter.
95+ */
96+ public String getPageTitle() {
97+ return currentPageData_ != null
98+ ? currentPageData_.getTitle()
99+ : null;
100+ }
101+
102+ /**
107103 * Execute query node by namespace.
108104 * @param namespace
109105 * @return HashMap<String, PageData>
110106 * @throws Exception
111107 */
112- public HashMap<String, PageData> queryNodeNamespace(String namespace) throws Exception {
113- return wikiRepository_.queryNodeNamespace(namespace);
108+ public HashMap<String, PageData> queryPageNamespace(String namespace) throws Exception {
109+ return wikiRepository_.queryPageNamespace(namespace);
114110 }
115111
116112 /**
@@ -119,8 +115,8 @@ public class WikiEngine {
119115 * @return HashMap<String, PageData>
120116 * @throws Exception
121117 */
122- public HashMap<String, PageData> queryNodePageUUID(String uuid) throws Exception {
123- return wikiRepository_.queryNodePageUUID(uuid);
118+ public HashMap<String, PageData> queryPageUUID(String uuid) throws Exception {
119+ return wikiRepository_.queryPageUUID(uuid);
124120 }
125121
126122 /**
@@ -129,8 +125,8 @@ public class WikiEngine {
129125 * @return HashMap<String, PageData>
130126 * @throws Exception
131127 */
132- public HashMap<String, PageData> queryNodePageTitle(String pageTitle) throws Exception {
133- return wikiRepository_.queryNodePageTitle(pageTitle);
128+ public HashMap<String, PageData> queryPageTitle(String pageTitle) throws Exception {
129+ return wikiRepository_.queryPageTitle(pageTitle);
134130 }
135131
136132 /**
@@ -139,8 +135,24 @@ public class WikiEngine {
139135 * @return HashMap<String, PageData>
140136 * @throws Exception
141137 */
142- public HashMap<String, PageData> queryFullTextSearch(String searchKey) throws Exception {
143- return wikiRepository_.queryFullTextSearch(searchKey);
138+ public HashMap<String, PageData> queryPageFullTextSearch(String searchKey) throws Exception {
139+ return wikiRepository_.queryPageFullTextSearch(searchKey);
140+ }
141+
142+ /**
143+ * NamespaceList getter.
144+ * @return ArrayList<String>
145+ * @throws Exception
146+ */
147+ public ArrayList<String> getNamespaceList() throws Exception {
148+ ArrayList<String> namespaceList = new ArrayList<String>();
149+ Value[] namespaces = wikiRepository_.getNamespaceList();
150+
151+ for(Value value: namespaces) {
152+ namespaceList.add(value.getString());
153+ }
154+
155+ return namespaceList;
144156 }
145157
146158 /**
@@ -271,7 +283,7 @@ public class WikiEngine {
271283 */
272284 public String fullTextSearch(String key) throws Exception {
273285 StringBuffer htmlBuffer = new StringBuffer("");
274- HashMap<String, PageData> pageDataMap = wikiRepository_.queryFullTextSearch(key);
286+ HashMap<String, PageData> pageDataMap = wikiRepository_.queryPageFullTextSearch(key);
275287 Set<String> uuids = pageDataMap.keySet();
276288 ResourceBundle resources = ResourceBundle.getBundle("com.wiki.standalone.moxkiriya.resources.moxkiriya");
277289
@@ -279,7 +291,7 @@ public class WikiEngine {
279291 if(pageDataMap.size() == 1) {
280292 Set<String> identifier = pageDataMap.keySet();
281293 PageData pagaData = pageDataMap.get(identifier.iterator().next());
282- setPageTitle(pagaData.getTitle(), pageDataMap);
294+ setCurrentPage(pagaData.getTitle(), pageDataMap);
283295 htmlBuffer.append(parse());
284296 }
285297 else {
@@ -295,14 +307,14 @@ public class WikiEngine {
295307 htmlBuffer.append("<h3>"
296308 + "<a href="
297309 + "\"" + pageData.getTitle() + "\" "
298- + WikiInternalLinkInlineParser.JCR_UUID + "="
310+ + ATTRIBUTE_JCR_UUID + "="
299311 + "\"" + uuid + "\">"
300312 + pageData.getTitle()
301313 + "</h3>\\n");
302314 /*
303315 * 冒頭の256文字を表示する
304316 */
305- String content = pageData.getContent().substring(0, 255);
317+ String content = pageData.getIntroduction();
306318 htmlBuffer.append(content);
307319 }
308320 }
--- a/src/com/wiki/standalone/moxkiriya/WikiMainWindow.fxml
+++ b/src/com/wiki/standalone/moxkiriya/WikiMainWindow.fxml
@@ -44,7 +44,7 @@
4444 </AnchorPane>
4545 <AnchorPane id="AnchorPane" fx:id="AnchorPaneWebView" prefHeight="380.0" prefWidth="590.0" visible="true" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="75.0">
4646 <children>
47- <AnchorPane id="AnchorPane" fx:id="webViewMenuAnchorPane" prefHeight="45.0" prefWidth="590.0" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
47+ <AnchorPane id="AnchorPane" fx:id="webViewMenuAnchorPane" prefHeight="45.0" prefWidth="590.0" visible="true" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
4848 <children>
4949 <Button id="webViewMenuAn" fx:id="webViewMenuAnchorPaneButtonBack" disable="true" maxHeight="-Infinity" maxWidth="-Infinity" mnemonicParsing="false" onAction="#onActionButtonBack" prefHeight="35.0" prefWidth="45.0" style="" text="⇦" AnchorPane.leftAnchor="150.0" AnchorPane.topAnchor="4.0">
5050 <font>
@@ -79,7 +79,25 @@
7979 </AnchorPane>
8080 <AnchorPane fx:id="AnchorPaneContentList" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="535.0" prefWidth="590.0" visible="false" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="73.0">
8181 <children>
82- <TreeView id="treeView" fx:id="TreeViewContentList" prefHeight="487.0" prefWidth="414.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="50.0" />
82+ <Label maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="30.0" prefWidth="100.0" text="%key.PageList.Label.Namespace" AnchorPane.leftAnchor="150.0" AnchorPane.topAnchor="80.0" />
83+ <ComboBox fx:id="comboBoxNamespace" prefHeight="25.0" prefWidth="150.0" AnchorPane.leftAnchor="250.0" AnchorPane.topAnchor="82.0">
84+ <items>
85+ <FXCollections fx:factory="observableArrayList">
86+ <String fx:value="アイテム1" />
87+ <String fx:value="アイテム2" />
88+ <String fx:value="アイテム3" />
89+ </FXCollections>
90+ </items>
91+ </ComboBox>
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">
94+ <columns>
95+ <TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="45.0" styleClass="-fx-alignment: center;" text="" fx:id="tableColumnCheck" />
96+ <TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="190.0" text="%key.Table.Row.Title" fx:id="tableColumnTitle" />
97+ <TableColumn maxWidth="5000.0" minWidth="10.0" prefWidth="540.0" text="%key.Table.Row.Content" fx:id="tableColumnContent" />
98+ <TableColumn prefWidth="50.0" text="%key.Table.Row.Refs" fx:id="tableColumnRefs" />
99+ </columns>
100+ </TableView>
83101 </children>
84102 </AnchorPane>
85103 <AnchorPane id="EditAnchorPane" fx:id="AnchorPaneEdit" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="450.0" prefWidth="590.0" visible="false" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="75.0">
@@ -92,7 +110,7 @@
92110 <Button fx:id="buttonCancel" mnemonicParsing="false" onAction="#onActionButtonCancel" prefWidth="90.0" text="%key.Button.Cancel" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="10.0" />
93111 <TextField disable="true" prefHeight="30.0" prefWidth="716.0" promptText="%key.Edit.TextField.InputPathname" AnchorPane.bottomAnchor="37.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="120.0" AnchorPane.topAnchor="470.0" />
94112 <Label disable="true" prefHeight="30.0" prefWidth="166.0" text="%key.Edit.Label.AttachFile" AnchorPane.bottomAnchor="65.0" AnchorPane.leftAnchor="152.0" AnchorPane.topAnchor="440.0" />
95- <Button disable="true" mnemonicParsing="false" prefHeight="30.0" prefWidth="45.0" text="..." AnchorPane.bottomAnchor="35.0" AnchorPane.leftAnchor="874.0" AnchorPane.rightAnchor="55.0" AnchorPane.topAnchor="470.0" />
113+ <Button disable="true" mnemonicParsing="false" prefHeight="30.0" prefWidth="45.0" text="..." AnchorPane.bottomAnchor="35.0" AnchorPane.rightAnchor="55.0" />
96114 </children>
97115 </AnchorPane>
98116 </children>
--- a/src/com/wiki/standalone/moxkiriya/WikiMainWindowController.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiMainWindowController.java
@@ -12,8 +12,6 @@ import java.net.URLDecoder;
1212 import java.util.ArrayList;
1313 import java.util.HashMap;
1414 import java.util.ResourceBundle;
15-import java.util.Set;
16-
1715
1816 import org.w3c.dom.Document;
1917 import org.w3c.dom.NodeList;
@@ -26,7 +24,6 @@ import com.wiki.standalone.moxkiriya.dialog.AboutMoxkiriyaDialog;
2624 import com.wiki.standalone.moxkiriya.dialog.AlertDialog;
2725 import com.wiki.standalone.moxkiriya.dialog.DialogBase;
2826 import com.wiki.standalone.moxkiriya.dialog.EditAttachFilesDialog;
29-import com.wiki.standalone.moxkiriya.parser.inlineparser.WikiInternalLinkInlineParser;
3027
3128 import javafx.beans.value.ChangeListener;
3229 import javafx.beans.value.ObservableValue;
@@ -38,13 +35,19 @@ import javafx.event.Event;
3835 import javafx.event.EventHandler;
3936 import javafx.fxml.FXML;
4037 import javafx.fxml.Initializable;
38+import javafx.geometry.Pos;
4139 import javafx.scene.control.Button;
40+import javafx.scene.control.CheckBox;
41+import javafx.scene.control.ComboBox;
4242 import javafx.scene.control.Hyperlink;
4343 import javafx.scene.control.MenuItem;
44+import javafx.scene.control.TableCell;
45+import javafx.scene.control.TableColumn;
46+import javafx.scene.control.TableView;
4447 import javafx.scene.control.TextArea;
4548 import javafx.scene.control.TextField;
46-import javafx.scene.control.TreeItem;
47-import javafx.scene.control.TreeView;
49+import javafx.scene.control.cell.CheckBoxTableCell;
50+import javafx.scene.control.cell.PropertyValueFactory;
4851 import javafx.scene.image.ImageView;
4952 import javafx.scene.layout.AnchorPane;
5053 import javafx.scene.web.WebEngine;
@@ -53,6 +56,7 @@ import javafx.stage.FileChooser;
5356 import javafx.stage.Modality;
5457 import javafx.stage.Stage;
5558 import javafx.stage.StageStyle;
59+import javafx.util.Callback;
5660
5761 /**
5862 * MainWindowコントローラ
@@ -110,7 +114,13 @@ public class WikiMainWindowController implements Initializable {
110114 * AnchorPaneContentList controls.
111115 */
112116 @FXML private AnchorPane AnchorPaneContentList;
113- @FXML private TreeView<String> TreeViewContentList;
117+ @FXML private ComboBox<String> comboBoxNamespace;
118+ @FXML private Hyperlink hyperlinkRedraw;
119+ @FXML private TableView<PageData> tableViewContentList;
120+ @FXML private TableColumn<PageData, String> tableColumnCheck;
121+ @FXML private TableColumn<PageData, String> tableColumnTitle;
122+ @FXML private TableColumn<PageData, String> tableColumnContent;
123+ @FXML private TableColumn<PageData, String> tableColumnRefs;
114124
115125 /*
116126 * その他
@@ -131,30 +141,64 @@ public class WikiMainWindowController implements Initializable {
131141 /** edit mode.*/
132142 private EditMode editMode_ = EditMode.NONE;
133143
134- /**
135- * カテゴリーコンボボックスのアイテム
136- */
137- public class ComboBoxCategoryItem extends File {
138- private static final long serialVersionUID = 1L;
139-
140- /**
141- * コンストラクタ
142- * @param pathname
143- */
144- public ComboBoxCategoryItem(String pathname) {
145- super(pathname);
146- }
147-
148- @Override
149- public String toString() {
150- return super.getName();
151- }
152- }
153-
154144 @Override
155145 public void initialize(URL url, ResourceBundle resourceBundle) {
156146 resourceBundle_ = resourceBundle;
157147 setLinkClickListner(webView.getEngine());
148+
149+ tableColumnCheck.setCellFactory(new Callback<TableColumn<PageData, String>, TableCell<PageData, String>>() {
150+ @Override
151+ public TableCell<PageData, String> call(TableColumn<PageData, String> arg0) {
152+ CheckBoxTableCell<PageData, String> tableCell = new CheckBoxTableCell<PageData, String>();
153+
154+ tableCell.setAlignment(Pos.CENTER);
155+
156+ return tableCell;
157+ }
158+ });
159+
160+ tableColumnTitle.setCellFactory(new Callback<TableColumn<PageData, String>, TableCell<PageData, String>>() {
161+ @Override
162+ public TableCell<PageData, String> call(TableColumn<PageData, String> param) {
163+ TableCell<PageData, String>
164+ tableCell = new TableCell<PageData, String>() {
165+ @Override
166+ public void updateItem(String uuid, boolean empty) {
167+ super.updateItem(uuid, empty);
168+ if(empty != true) {
169+ try {
170+ HashMap<String, PageData> pageMap = wikiEngine_.queryPageUUID(uuid);
171+ PageData pageData = pageMap.get(uuid);
172+ Hyperlink hyperlink = new Hyperlink(pageData.getTitle());
173+
174+ hyperlink.setUserData(pageData);
175+ hyperlink.setOnMouseClicked(new EventHandler<Event>() {
176+ @Override
177+ public void handle(Event event) {
178+ Hyperlink source = (Hyperlink)event.getSource();
179+ PageData pageData = (PageData)source.getUserData();
180+
181+ menuItemNew.setDisable(false);
182+ wikiEngine_.setCurrentPage(pageData);
183+ loadWikiContent();
184+
185+ AnchorPaneEdit.setVisible(false);
186+ AnchorPaneContentList.setVisible(false);
187+ AnchorPaneWebView.setVisible(true);
188+ }
189+ });
190+
191+ setGraphic(hyperlink);
192+ } catch (Exception e) {
193+ e.printStackTrace();
194+ }
195+ }
196+ }
197+ };
198+
199+ return tableCell;
200+ }
201+ });
158202 }
159203
160204 /**
@@ -271,7 +315,7 @@ public class WikiMainWindowController implements Initializable {
271315 if(pageTitle != null) {
272316 menuItemNew.setDisable(false);
273317
274- wikiEngine_.setPageTitle(pageTitle);
318+ wikiEngine_.setCurrentPage(pageTitle);
275319 loadWikiContent();
276320
277321 AnchorPaneEdit.setVisible(false);
@@ -306,15 +350,9 @@ public class WikiMainWindowController implements Initializable {
306350 editMode_ = EditMode.NONE;
307351 wikiEngine_.cancelCheckout();
308352
309- TreeItem<String> root = new TreeItem<String>("Main", null);
310- root.setExpanded(true);
311- ObservableList<TreeItem<String>> children = buildContentsTree(WikiRepository.PROPERTY_MAIN);
312- if(children != null) {
313- root.getChildren().addAll(children);
314- }
315-
316- TreeViewContentList.rootProperty().setValue(root);
317-
353+ buildComboBoxNamespace();
354+
355+ buildTableViewPageList();
318356 AnchorPaneWebView.setVisible(false);
319357 AnchorPaneEdit.setVisible(false);
320358 AnchorPaneContentList.setVisible(true);
@@ -346,13 +384,21 @@ public class WikiMainWindowController implements Initializable {
346384 @FXML
347385 public void onActionButtonHome(ActionEvent event) {
348386 try {
349- wikiEngine_.setPageTitle(WikiEngine.MAINPAGE_TITLE);
387+ wikiEngine_.setCurrentPage(WikiEngine.MAINPAGE_TITLE);
350388 loadWikiContent();
351389 } catch (Exception e) {
352390 e.printStackTrace();
353391 }
354392 }
355393
394+ @FXML
395+ public void onMouseClickedHyperlinkRedraw() {
396+ try {
397+ buildTableViewPageList();
398+ } catch (Exception e) {
399+ e.printStackTrace();
400+ }
401+ }
356402
357403 @FXML
358404 public void onMouseClickedHyperlinkEditAttachFiles() {
@@ -514,59 +560,6 @@ public class WikiMainWindowController implements Initializable {
514560 }
515561
516562 /**
517- * Contents treeを構築する。
518- * param namespace
519- * @return ObservableLis
520- * @throws Exception
521- */
522- private ObservableList<TreeItem<String>> buildContentsTree(String namespace)
523- throws Exception {
524- ObservableList<TreeItem<String>> list = FXCollections.observableArrayList();
525- HashMap<String, PageData> pageDataMap = wikiEngine_.queryNodeNamespace(namespace);
526- Set<String> keys = pageDataMap.keySet();
527-
528- for(String key: keys) {
529- PageData pageData = pageDataMap.get(key);
530- Hyperlink hyperlink = new Hyperlink(pageData.getTitle());
531-
532- hyperlink.setPrefWidth(128);
533- hyperlink.setUserData(key);
534- hyperlink.setOnMouseClicked(new EventHandler<Event>() {
535- public void handle(Event event) {
536- try {
537- Hyperlink source = (Hyperlink)event.getSource();
538- String title = source.getText();
539- String identifier = (String)source.getUserData();
540-
541- wikiEngine_.setPageTitle(title, identifier, null);
542- menuItemNew.setDisable(false);
543- loadWikiContent();
544-
545- /*
546- * PaneをWebViewAnchorPaneに切り替える。
547- */
548- AnchorPaneContentList.setVisible(false);
549- AnchorPaneWebView.setVisible(true);
550- } catch (Exception e) {
551- e.printStackTrace();
552- }
553- }
554- });
555-
556- String content = pageData.getContent();
557- int length = Math.min(content.length() - 1, 255);
558-
559- TreeItem<String> treeItem = new TreeItem<String>();
560- treeItem.setGraphic(hyperlink);
561- treeItem.setValue(content.substring(0, length));
562-
563- list.add(treeItem);
564- }
565-
566- return list;
567- }
568-
569- /**
570563 * webViewを取得する。
571564 * @return webView
572565 */
@@ -588,6 +581,7 @@ public class WikiMainWindowController implements Initializable {
588581 */
589582 private String getSelectingPageTitle() {
590583 String title = wikiEngine_.getPageTitle();
584+ /*
591585 if(AnchorPaneContentList.isVisible() == true) {
592586 TreeItem<String> item = TreeViewContentList.getFocusModel().getFocusedItem();
593587 if(item != null) {
@@ -597,146 +591,187 @@ public class WikiMainWindowController implements Initializable {
597591 else if(AnchorPaneEdit.isVisible() == true) {
598592 title = textFieldTitle.getText();
599593 }
594+ */
600595
601596 return title;
602597 }
603-
598+
599+ /**
600+ * Build a namespace comboBox.
601+ * @throws Exception
602+ */
603+ private void buildComboBoxNamespace() throws Exception {
604+ ArrayList<String> namespaceList = wikiEngine_.getNamespaceList();
605+ ObservableList<String> items = comboBoxNamespace.getItems();
606+
607+ items.clear();
608+ for(int index = 0; index < namespaceList.size(); index++) {
609+ String item = namespaceList.get(index);
610+ items.add(item);
611+
612+ if(item.equals(WikiRepository.PROPERTY_MAIN) == true) {
613+ comboBoxNamespace.getSelectionModel().select(index);
614+ }
615+ }
616+ }
617+
618+ /*
619+ @FXML private TableColumn tableColumnCheck;
620+ @FXML private TableColumn tableColumnTitle;
621+ @FXML private TableColumn tableColumnContent;
622+ @FXML private TableColumn tableColumnRefs;
623+ */
624+
625+ private void buildTableViewPageList() throws Exception {
626+ String namespace = comboBoxNamespace.getSelectionModel().getSelectedItem();
627+ HashMap<String, PageData> pageMap = wikiEngine_.queryPageNamespace(namespace);
628+ ObservableList<PageData> observableList = FXCollections.observableArrayList();
629+
630+ tableColumnCheck.setGraphic(new CheckBox());
631+ tableColumnCheck.setCellValueFactory(new PropertyValueFactory<PageData, String>("uuid"));
632+ tableColumnTitle.setCellValueFactory(new PropertyValueFactory<PageData, String>("uuid"));
633+ tableColumnContent.setCellValueFactory(new PropertyValueFactory<PageData, String>("introduction"));
634+
635+ for(String key: pageMap.keySet()) {
636+ observableList.add(pageMap.get(key));
637+ }
638+ tableViewContentList.setItems(observableList);
639+ }
640+
604641 /**
605642 * A要素のクリックリスナーを登録する。
606643 * @param webEngine
607644 */
608645 private void setLinkClickListner(WebEngine webEngine) {
609- webEngine.getLoadWorker().stateProperty().addListener(
610- new ChangeListener<State>() {
611-
612- @Override
613- public void changed(ObservableValue<? extends State> arg0, State oldState, State newState) {
614- WebView webView = getWebView();
615- EventListener listener = new EventListener() {
616- @Override
617- public void handleEvent(org.w3c.dom.events.Event event) {
618- try {
619- MouseEvent mouseEvent = (MouseEvent)event;
620- EventTarget target = mouseEvent.getCurrentTarget();
621- if(isExternalLink(target) == true) {
622- /*
623- * WebEngineのデフォルトの動作(リンク先ページをロード)をキャンセル
624- */
625- event.preventDefault();
626- externalLinkHandle(target);
627- }
628- else {
629- internalLinkHandle(target);
630- }
631- } catch (Exception e) {
632- e.printStackTrace();
646+ webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
647+ @Override
648+ public void changed(ObservableValue<? extends State> arg0, State oldState, State newState) {
649+ WebView webView = getWebView();
650+ EventListener listener = new EventListener() {
651+ @Override
652+ public void handleEvent(org.w3c.dom.events.Event event) {
653+ try {
654+ MouseEvent mouseEvent = (MouseEvent)event;
655+ EventTarget target = mouseEvent.getCurrentTarget();
656+ if(isExternalLink(target) == true) {
657+ /*
658+ * WebEngineのデフォルトの動作(リンク先ページをロード)をキャンセル
659+ */
660+ event.preventDefault();
661+ externalLinkHandle(target);
633662 }
663+ else {
664+ internalLinkHandle(target);
665+ }
666+ } catch (Exception e) {
667+ e.printStackTrace();
634668 }
669+ }
635670
636- /**
637- * targetが外部リンクか判定する。
638- * @param target
639- * @return
640- */
641- private boolean isExternalLink(EventTarget target) {
642- final ArrayList<String> schemeList = new ArrayList<String>() {
643- private static final long serialVersionUID = 1L;
644- { add("http://"); }
645- { add("https://"); }
646- { add("file://"); }
647- };
648-
649- boolean isExternal = false;
650-
651- for(String scheme: schemeList) {
652- if(target.toString().startsWith(scheme) == true) {
653- isExternal = true;
654- break;
655- }
671+ /**
672+ * targetが外部リンクか判定する。
673+ * @param target
674+ * @return
675+ */
676+ private boolean isExternalLink(EventTarget target) {
677+ final ArrayList<String> schemeList = new ArrayList<String>() {
678+ private static final long serialVersionUID = 1L;
679+ { add("http://"); }
680+ { add("https://"); }
681+ { add("file://"); }
682+ };
683+
684+ boolean isExternal = false;
685+
686+ for(String scheme: schemeList) {
687+ if(target.toString().startsWith(scheme) == true) {
688+ isExternal = true;
689+ break;
656690 }
657-
658- return isExternal;
659691 }
660692
661- /**
662- * ExternalLinkを処理する。
663- * @param target
664- * @throws Exception
693+ return isExternal;
694+ }
695+
696+ /**
697+ * ExternalLinkを処理する。
698+ * @param target
699+ * @throws Exception
700+ */
701+ private void externalLinkHandle(EventTarget target) throws Exception {
702+ String targetpath = target.toString();
703+ if(targetpath.startsWith("file:///") == true) {
704+ targetpath = URLDecoder.decode(targetpath, "UTF-8");
705+ }
706+ /*
707+ * 既定のブラウザを起動してリンク先ページを開く
665708 */
666- private void externalLinkHandle(EventTarget target) throws Exception {
667- String targetpath = target.toString();
668- if(targetpath.startsWith("file:///") == true) {
669- targetpath = URLDecoder.decode(targetpath, "UTF-8");
670- }
709+ Desktop.getDesktop().browse(new URI(targetpath));
710+ }
711+
712+ /**
713+ * InternalLinkを処理する。
714+ * @param target
715+ * @throws Exception
716+ */
717+ private void internalLinkHandle(EventTarget target) throws Exception {
718+ String pageTitle = URLDecoder.decode(target.toString(), "UTF-8");
719+
720+ HTMLAnchorElement anchor = (HTMLAnchorElement)target;
721+ String uuid = anchor.getAttribute(WikiEngine.ATTRIBUTE_JCR_UUID);
722+ HashMap<String, PageData> pageDataMap;
723+ if(uuid != null) {
724+ pageDataMap = wikiEngine_.queryPageUUID(uuid);
725+ }
726+ else {
727+ pageDataMap = wikiEngine_.queryPageTitle(pageTitle);
728+ }
729+ if(pageDataMap.size() == 1) {
730+ wikiEngine_.setCurrentPage(pageTitle, pageDataMap);
731+ loadWikiContent();
732+ }
733+ else {
734+ File linkpath = new File(pageTitle);
735+
671736 /*
672- * 既定のブラウザを起動してリンク先ページを開く
737+ * リンク先にファイルが存在しない場合
738+ * 編集画面へ遷移
673739 */
674- Desktop.getDesktop().browse(new URI(targetpath));
675- }
740+ String absoluteLinkpath = linkpath.getAbsolutePath();
676741
677- /**
678- * InternalLinkを処理する。
679- * @param target
680- * @throws Exception
681- */
682- private void internalLinkHandle(EventTarget target) throws Exception {
683- String pageTitle = URLDecoder.decode(target.toString(), "UTF-8");
684-
685- HTMLAnchorElement anchor = (HTMLAnchorElement)target;
686- String uuid = anchor.getAttribute(WikiInternalLinkInlineParser.JCR_UUID);
687- HashMap<String, PageData> pageDataMap;
688- if(uuid != null) {
689- pageDataMap = wikiEngine_.queryNodePageUUID(uuid);
690- }
691- else {
692- pageDataMap = wikiEngine_.queryNodePageTitle(pageTitle);
693- }
694- if(pageDataMap.size() == 1) {
695- wikiEngine_.setPageTitle(pageTitle, pageDataMap);
696- loadWikiContent();
742+ if(absoluteLinkpath.contains("\\attaches")) {
743+ /*
744+ * 添付ファイルのパス名の場合
745+ */
746+ String contentDir = absoluteLinkpath.substring(0, absoluteLinkpath.lastIndexOf("\\attaches"));
747+ EditAttachFilesDialog dialog = new EditAttachFilesDialog(new File(contentDir));
748+ dialog.showDialog(primaryStage_, resourceBundle_);
697749 }
698- else {
699- File linkpath = new File(pageTitle);
700-
750+ else if(target.toString().contains("#")) {
701751 /*
702- * リンク先にファイルが存在しない場合
703- * 編集画面へ遷移
752+ * ページ内セクションリンク
704753 */
705- String absoluteLinkpath = linkpath.getAbsolutePath();
706-
707- if(absoluteLinkpath.contains("\\attaches")) {
708- /*
709- * 添付ファイルのパス名の場合
710- */
711- String contentDir = absoluteLinkpath.substring(0, absoluteLinkpath.lastIndexOf("\\attaches"));
712- EditAttachFilesDialog dialog = new EditAttachFilesDialog(new File(contentDir));
713- dialog.showDialog(primaryStage_, resourceBundle_);
714- }
715- else if(target.toString().contains("#")) {
716- /*
717- * ページ内セクションリンク
718- */
719- jumpToSectionLink(target);
720- }
721- else {
722- buildEditView(target.toString());
723- }
754+ jumpToSectionLink(target);
755+ }
756+ else {
757+ buildEditView(target.toString());
724758 }
725-
726759 }
727- };
728-
729- if(newState == State.SUCCEEDED) {
730- Document doc = webView.getEngine().getDocument();
731- NodeList listA = doc.getElementsByTagName("a");
732-
733- for(int index = 0; index < listA.getLength(); index++) {
734- ((EventTarget)listA.item(index)).addEventListener("click", listener, false);
735- }
736- getImageViewLoading().setVisible(false);
737- webView.setVisible(true);
760+
738761 }
762+ };
763+
764+ if(newState == State.SUCCEEDED) {
765+ Document doc = webView.getEngine().getDocument();
766+ NodeList listA = doc.getElementsByTagName("a");
767+
768+ for(int index = 0; index < listA.getLength(); index++) {
769+ ((EventTarget)listA.item(index)).addEventListener("click", listener, false);
770+ }
771+ getImageViewLoading().setVisible(false);
772+ webView.setVisible(true);
739773 }
740- });
774+ }
775+ });
741776 }
742777 }
--- a/src/com/wiki/standalone/moxkiriya/WikiRepository.java
+++ b/src/com/wiki/standalone/moxkiriya/WikiRepository.java
@@ -231,7 +231,7 @@ public class WikiRepository {
231231 * @return HashMap<String, PageData>
232232 * @throws Exception
233233 */
234- public HashMap<String, PageData> queryNodeNamespace(String namespace) throws Exception {
234+ public HashMap<String, PageData> queryPageNamespace(String namespace) throws Exception {
235235 Query query = queryMgr_.createQuery(
236236 "SELECT * "
237237 + " FROM [nt:unstructured]"
@@ -253,7 +253,7 @@ public class WikiRepository {
253253 * @return HashMap<String, PageData>
254254 * @throws Exception
255255 */
256- public HashMap<String, PageData> queryNodePageUUID(String uuid) throws Exception {
256+ public HashMap<String, PageData> queryPageUUID(String uuid) throws Exception {
257257 Query query = queryMgr_.createQuery(
258258 "SELECT * "
259259 + " FROM [nt:unstructured]"
@@ -276,7 +276,7 @@ public class WikiRepository {
276276 * @return HashMap<String, PageData>
277277 * @throws Exception
278278 */
279- public HashMap<String, PageData> queryNodePageTitle(String pageTitle) throws Exception {
279+ public HashMap<String, PageData> queryPageTitle(String pageTitle) throws Exception {
280280 String namespace = PROPERTY_MAIN;
281281 String title = pageTitle;
282282
@@ -309,7 +309,7 @@ public class WikiRepository {
309309 * @return String
310310 * @throws Exception
311311 */
312- public HashMap<String, PageData> queryFullTextSearch(String searchKey) throws Exception {
312+ public HashMap<String, PageData> queryPageFullTextSearch(String searchKey) throws Exception {
313313 Query query = queryMgr_.createQuery(
314314 "SELECT * "
315315 + " FROM [nt:unstructured]"
@@ -341,6 +341,17 @@ public class WikiRepository {
341341
342342 return pageDataMap;
343343 }
344+
345+ /**
346+ * NamespaceList getter
347+ * @return Value[]
348+ * @throws Exception
349+ */
350+ public Value[] getNamespaceList() throws Exception {
351+ Node namespace = session_.getNode("/" + NODE_WIKIROOT + "/" + NODE_NAMESPACE);
352+
353+ return namespace.getProperty(PROPERTY_NAMESPACE).getValues();
354+ }
344355
345356 /**
346357 * Now node setter.
--- a/src/com/wiki/standalone/moxkiriya/parser/inlineparser/WikiInternalLinkInlineParser.java
+++ b/src/com/wiki/standalone/moxkiriya/parser/inlineparser/WikiInternalLinkInlineParser.java
@@ -13,6 +13,7 @@ import javax.jcr.Property;
1313 import org.apache.xerces.impl.dv.util.Base64;
1414
1515 import com.wiki.standalone.moxkiriya.PageData;
16+import com.wiki.standalone.moxkiriya.WikiEngine;
1617 import com.wiki.standalone.moxkiriya.WikiRepository;
1718 import com.wiki.standalone.moxkiriya.util.FileTypeDeterminator;
1819
@@ -40,8 +41,8 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase {
4041 private static final String END_TAG = "</a>\n";
4142
4243 /** jcr_uuid 独自属性 */
43- public static final String JCR_UUID = "data-jcr_uuid";
44-
44+ public static final String ATTRIBUTE_JCR_UUID = WikiEngine.ATTRIBUTE_JCR_UUID;
45+
4546 /** img開始タグ */
4647 private static final String IMAGE_START_TAG = "<img src=";
4748
@@ -115,7 +116,7 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase {
115116 String mediaType = null;
116117 StringBuffer databuf = new StringBuffer("");
117118
118- HashMap<String, PageData> pageDataMap = wikiRepository_.queryNodePageTitle(linkpath_);
119+ HashMap<String, PageData> pageDataMap = wikiRepository_.queryPageTitle(linkpath_);
119120 PageData.FileData fileData = null;
120121
121122 if(pageDataMap.size() > 0) {
@@ -291,7 +292,7 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase {
291292 buf.append("\"");
292293 buf.append(linkpath_ + "\" ");
293294
294- HashMap<String, PageData> pageDataMap = wikiRepository_.queryNodePageTitle(linkpath_);
295+ HashMap<String, PageData> pageDataMap = wikiRepository_.queryPageTitle(linkpath_);
295296 if(pageDataMap.size() == 0) {
296297 buf.append(STYLE_CLASS_NOEXIST);
297298 }
@@ -299,7 +300,7 @@ public class WikiInternalLinkInlineParser extends WikiInlineParserBase {
299300 Set<String> key = pageDataMap.keySet();
300301 PageData pageData = pageDataMap.get(key.iterator().next());
301302 Node node = pageData.getNode();
302- buf.append(" " + JCR_UUID + "=\"");
303+ buf.append(" " + ATTRIBUTE_JCR_UUID + "=\"");
303304 buf.append(node.getProperty(Property.JCR_UUID).getString());
304305 buf.append("\"");
305306 }
--- a/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
+++ b/src/com/wiki/standalone/moxkiriya/resources/moxkiriya.properties
@@ -44,6 +44,13 @@ key.Edit.TextField.InputPathname: - Input pathname -
4444 key.Edit.ComboBox.Category.PromptText: - Select a category. -
4545 key.Edit.ComboBox.Category.Item.None: None
4646
47+key.PageList.Label.Namespace: Namespace:
48+key.PageList.Label.Redraw: Redraw
49+key.Table.Row.Select: Sel
50+key.Table.Row.Title: Title
51+key.Table.Row.Content: Content
52+key.Table.Row.Refs: Refs
53+
4754 key.webView.Hyperlink.Reload: Reload
4855
4956 key.Dialog.Message.Cancel.Editing: Cancel editing?