Moxkiriyaプロジェクト事前開発用の作業部屋
Revision | 1c8b2368ca17659eef1c022e08551c5747831a57 (tree) |
---|---|
Time | 2018-10-20 08:49:31 |
Author | Harold_Andoh <andolloyd@gmai...> |
Commiter | Harold_Andoh |
[Moxkiriya7]
@@ -1,57 +0,0 @@ | ||
1 | -/** | |
2 | - * CategoryFilenameFilter | |
3 | - * @author Ryuhei Terada | |
4 | - */ | |
5 | -package com.wiki.standalone.moxkiriya; | |
6 | - | |
7 | -import java.io.File; | |
8 | -import java.io.FilenameFilter; | |
9 | -import java.util.ArrayList; | |
10 | - | |
11 | -/** | |
12 | - * Categoryファイル名フィルター | |
13 | - * | |
14 | - */ | |
15 | -public class CategoryFilenameFilter implements FilenameFilter { | |
16 | - /** | |
17 | - * フィルターするファイル/ディレクトリのリスト | |
18 | - */ | |
19 | - private ArrayList<String> denyList = new ArrayList<String>(); | |
20 | - | |
21 | - @Override | |
22 | - public boolean accept(File dir, String name) { | |
23 | - boolean isAccept = true; | |
24 | - String absolutePath = dir.getAbsolutePath() + "\\" + name; | |
25 | - File absoluteFile = new File(absolutePath); | |
26 | - | |
27 | - isAccept = absoluteFile.isFile() == false; | |
28 | - | |
29 | - if(isAccept == true) { | |
30 | - File file = new File(absolutePath | |
31 | - + "\\" | |
32 | - + "Contents.wiki"); | |
33 | - | |
34 | - isAccept = file.exists() == false; | |
35 | - } | |
36 | - | |
37 | - if(isAccept == true) { | |
38 | - File file = new File(absolutePath | |
39 | - + "\\" | |
40 | - + "Summary.wiki"); | |
41 | - isAccept = file.exists() == false; | |
42 | - } | |
43 | - if(isAccept == true) { | |
44 | - isAccept = denyList.contains(absolutePath) != true; | |
45 | - } | |
46 | - | |
47 | - return isAccept; | |
48 | - } | |
49 | - | |
50 | - /** | |
51 | - * 拒否リストに要素を追加する。 | |
52 | - * @param path | |
53 | - */ | |
54 | - public void denyListAdd(String path) { | |
55 | - denyList.add(path); | |
56 | - } | |
57 | -} |
@@ -1,22 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | - | |
3 | -<?import java.lang.*?> | |
4 | -<?import java.util.*?> | |
5 | -<?import javafx.scene.control.*?> | |
6 | -<?import javafx.scene.layout.*?> | |
7 | -<?import javafx.scene.paint.*?> | |
8 | -<?scenebuilder-preview-i18n-resource ../resources/moxkiriya.properties?> | |
9 | - | |
10 | -<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.wiki.standalone.moxkiriya.dialog.AddCategoryDialogController"> | |
11 | - <children> | |
12 | - <AnchorPane prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | |
13 | - <children> | |
14 | - <TreeView fx:id="treeViewMotherCategory" prefHeight="225.0" prefWidth="465.0" AnchorPane.bottomAnchor="115.0" AnchorPane.leftAnchor="90.0" AnchorPane.rightAnchor="45.0" AnchorPane.topAnchor="60.0" /> | |
15 | - <TextField fx:id="textFieldNewCategory" maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="30.0" prefWidth="465.0" promptText="%key.AddCategoryDialog.TextField.Prompt.input.new.category.name" AnchorPane.leftAnchor="90.0" AnchorPane.rightAnchor="45.0" AnchorPane.topAnchor="300.0" /> | |
16 | - <Label layoutX="90.0" prefHeight="30.0" prefWidth="465.0" text="%key.AddCategoryDialog.Label.Select.parent" AnchorPane.topAnchor="30.0" /> | |
17 | - <Button fx:id="buttonCancel" maxHeight="-Infinity" maxWidth="-1.0" mnemonicParsing="false" onAction="#onActionButtonCancel" prefHeight="25.0" prefWidth="60.0" text="%key.AddCategoryDialg.Button.Cancel" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="120.0" /> | |
18 | - <Button fx:id="buttonOK" maxHeight="-Infinity" maxWidth="-Infinity" mnemonicParsing="false" onAction="#onActionButtonOK" prefHeight="25.0" prefWidth="60.0" text="%key.AddCategoryDialg.Button.OK" AnchorPane.bottomAnchor="15.0" AnchorPane.rightAnchor="45.0" /> | |
19 | - </children> | |
20 | - </AnchorPane> | |
21 | - </children> | |
22 | -</AnchorPane> |
@@ -1,38 +0,0 @@ | ||
1 | -/** | |
2 | - * AddNewCategoryDialog | |
3 | - * @author Ryuhei Terada | |
4 | - */ | |
5 | -package com.wiki.standalone.moxkiriya.dialog; | |
6 | - | |
7 | -import java.util.ResourceBundle; | |
8 | - | |
9 | -import javafx.stage.Stage; | |
10 | - | |
11 | -/** | |
12 | - * カテゴリ追加ダイアログクラス | |
13 | - * | |
14 | - */ | |
15 | -public class AddCategoryDialog extends DialogBase { | |
16 | - /** | |
17 | - * コンストラクタ | |
18 | - */ | |
19 | - public AddCategoryDialog() { | |
20 | - } | |
21 | - | |
22 | - @Override | |
23 | - protected String getFXML() { | |
24 | - return "AddCategoryDialog.fxml"; | |
25 | - } | |
26 | - | |
27 | - @Override | |
28 | - protected DialogController getController() { | |
29 | - return loader_.getController(); | |
30 | - } | |
31 | - | |
32 | - @Override | |
33 | - public CloseType showDialog(Stage stage, ResourceBundle resource) throws Exception { | |
34 | - CloseType closeType = super.showDialog(stage, resource); | |
35 | - | |
36 | - return closeType; | |
37 | - } | |
38 | -} |
@@ -1,147 +0,0 @@ | ||
1 | -/** | |
2 | - * EditAttacheFilesDialog | |
3 | - * @author Ryuhei Terada | |
4 | - */ | |
5 | -package com.wiki.standalone.moxkiriya.dialog; | |
6 | - | |
7 | -import java.io.File; | |
8 | -import java.net.URL; | |
9 | -import java.util.ResourceBundle; | |
10 | - | |
11 | -import com.wiki.standalone.moxkiriya.CategoryFilenameFilter; | |
12 | -import com.wiki.standalone.moxkiriya.SettingManager; | |
13 | - | |
14 | -import javafx.beans.value.ChangeListener; | |
15 | -import javafx.beans.value.ObservableValue; | |
16 | -import javafx.event.ActionEvent; | |
17 | -import javafx.fxml.FXML; | |
18 | -import javafx.scene.Node; | |
19 | -import javafx.scene.control.Button; | |
20 | -import javafx.scene.control.TextField; | |
21 | -import javafx.scene.control.TreeItem; | |
22 | -import javafx.scene.control.TreeView; | |
23 | - | |
24 | -/** | |
25 | - * カテゴリ追加ダイアログコントローラ | |
26 | - */ | |
27 | -public class AddCategoryDialogController extends DialogControllerBase { | |
28 | - /** | |
29 | - * カテゴリーアイテム | |
30 | - */ | |
31 | - public class CategoryItem extends File { | |
32 | - private static final long serialVersionUID = 1L; | |
33 | - | |
34 | - /** | |
35 | - * コンストラクタ | |
36 | - * @param pathname | |
37 | - */ | |
38 | - public CategoryItem(String pathname) { | |
39 | - super(pathname); | |
40 | - } | |
41 | - | |
42 | - @Override | |
43 | - public String toString() { | |
44 | - return super.getName(); | |
45 | - } | |
46 | - } | |
47 | - | |
48 | - @FXML | |
49 | - private TreeView<CategoryItem> treeViewMotherCategory; | |
50 | - | |
51 | - @FXML | |
52 | - private TextField textFieldNewCategory; | |
53 | - | |
54 | - @FXML | |
55 | - private Button buttonCancel; | |
56 | - | |
57 | - @FXML | |
58 | - private Button buttonOK; | |
59 | - | |
60 | - @Override | |
61 | - public void initialize(URL url, ResourceBundle resource) { | |
62 | - super.initialize(url, resource); | |
63 | - buildMotherCategoryTreeView(); | |
64 | - buttonOK.setDisable(true); | |
65 | - | |
66 | - textFieldNewCategory.textProperty().addListener(new ChangeListener<String>() { | |
67 | - @Override | |
68 | - public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) { | |
69 | - if(newValue.length() > 0) { | |
70 | - buttonOK.setDisable(false); | |
71 | - } | |
72 | - else { | |
73 | - buttonOK.setDisable(true); | |
74 | - } | |
75 | - } | |
76 | - }); | |
77 | - } | |
78 | - | |
79 | - /** | |
80 | - * カテゴリーツリーViewを構築する。 | |
81 | - */ | |
82 | - private void buildMotherCategoryTreeView() { | |
83 | - SettingManager settingMgr = SettingManager.getInstance(); | |
84 | - String wikirootPath = settingMgr.get(SettingManager.SETTINGSKEY_WIKIROOT); | |
85 | - File wikirootFile = new File(wikirootPath); | |
86 | - TreeItem<CategoryItem> rootTreeItem | |
87 | - = new TreeItem<>(new CategoryItem(wikirootPath)); | |
88 | - | |
89 | - rootTreeItem.setExpanded(true); | |
90 | - treeViewMotherCategory.setRoot(rootTreeItem); | |
91 | - | |
92 | - buildCategoryTree(wikirootFile, rootTreeItem); | |
93 | - } | |
94 | - | |
95 | - /** | |
96 | - * カテゴリーツリーを構築する。 | |
97 | - * @param parentFile | |
98 | - * @param parentTreeItem | |
99 | - */ | |
100 | - private void buildCategoryTree(File parentFile, TreeItem<CategoryItem> parentTreeItem) { | |
101 | - SettingManager settingMgr = SettingManager.getInstance(); | |
102 | - String wikirootPath = settingMgr.get(SettingManager.SETTINGSKEY_WIKIROOT); | |
103 | - CategoryFilenameFilter filter | |
104 | - = new CategoryFilenameFilter(); | |
105 | - filter.denyListAdd(wikirootPath + "\\" + "None"); | |
106 | - | |
107 | - File[] subDirList = parentFile.listFiles(filter); | |
108 | - for(File subDir : subDirList) { | |
109 | - if(subDir.isDirectory() == true) { | |
110 | - TreeItem<CategoryItem> treeItem = new TreeItem<>(new CategoryItem(subDir.getAbsolutePath())); | |
111 | - parentTreeItem.getChildren().add(treeItem); | |
112 | - buildCategoryTree(subDir, treeItem); | |
113 | - } | |
114 | - } | |
115 | - } | |
116 | - | |
117 | - @FXML | |
118 | - public void onActionButtonOK(ActionEvent event) { | |
119 | - CategoryItem item; | |
120 | - TreeItem<CategoryItem> focusedItem = treeViewMotherCategory.getFocusModel().getFocusedItem(); | |
121 | - | |
122 | - if(focusedItem == null) { | |
123 | - /* | |
124 | - * 親カテゴリが選択されていない場合、 | |
125 | - * Wikirootを親カテゴリとして扱う。 | |
126 | - */ | |
127 | - SettingManager settingMgr = SettingManager.getInstance(); | |
128 | - String wikirootPath = settingMgr.get(SettingManager.SETTINGSKEY_WIKIROOT); | |
129 | - item = new CategoryItem(wikirootPath); | |
130 | - } | |
131 | - else { | |
132 | - item = focusedItem.getValue(); | |
133 | - } | |
134 | - | |
135 | - String newCategory = textFieldNewCategory.getText(); | |
136 | - File newDir = new File(item.getAbsoluteFile() + "\\" + newCategory); | |
137 | - | |
138 | - newDir.mkdirs(); | |
139 | - ((Node)event.getSource()).getScene().getWindow().hide(); | |
140 | - } | |
141 | - | |
142 | - | |
143 | - @FXML | |
144 | - public void onActionButtonCancel(ActionEvent event) { | |
145 | - ((Node)event.getSource()).getScene().getWindow().hide(); | |
146 | - } | |
147 | -} |
@@ -1,29 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | - | |
3 | -<?import java.lang.*?> | |
4 | -<?import java.util.*?> | |
5 | -<?import javafx.scene.control.*?> | |
6 | -<?import javafx.scene.layout.*?> | |
7 | -<?import javafx.scene.paint.*?> | |
8 | -<?import javafx.scene.text.*?> | |
9 | -<?scenebuilder-preview-i18n-resource ../resources/moxkiriya.properties?> | |
10 | - | |
11 | -<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="640.0" prefHeight="400.0" prefWidth="640.0" snapToPixel="true" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.wiki.standalone.moxkiriya.dialog.EditAttachFilesDialogController"> | |
12 | - <children> | |
13 | - <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="356.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> | |
14 | - <children> | |
15 | - <ListView id="ListViewAttacheFiles" fx:id="listViewAttacheFiles" maxHeight="-Infinity" prefHeight="245.0" prefWidth="475.0" AnchorPane.bottomAnchor="100.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="55.0" /> | |
16 | - <Label minHeight="28.0" prefHeight="28.0" prefWidth="626.0" text="%key.EditAttachedFileDialog.Title" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="0.0"> | |
17 | - <font> | |
18 | - <Font size="15.0" /> | |
19 | - </font> | |
20 | - </Label> | |
21 | - <Button fx:id="buttonDeleteCheckedFiles" maxHeight="-Infinity" mnemonicParsing="false" onAction="#onActionButtonDeleteCheckedFiles" prefHeight="27.0" text="%key.Button.DeleteCheckedFiles" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="150.0" /> | |
22 | - <Button id="buttonCommit" fx:id="buttonClose" maxHeight="-Infinity" mnemonicParsing="false" onAction="#onActionButtonClose" prefHeight="27.0" text="%key.Button.Close" AnchorPane.bottomAnchor="25.0" AnchorPane.rightAnchor="15.0" /> | |
23 | - <CheckBox fx:id="checkBoxSelectAll" maxHeight="-Infinity" mnemonicParsing="false" prefHeight="20.0" text="%key.Checkbox.Select.all" AnchorPane.bottomAnchor="73.0" AnchorPane.leftAnchor="155.0" /> | |
24 | - <Button fx:id="buttonAdd" layoutX="327.0" maxHeight="-Infinity" mnemonicParsing="false" onAction="#onActionButtonUpload" prefHeight="27.0" text="%key.Button.Upload" AnchorPane.bottomAnchor="25.0" /> | |
25 | - <Label id="Label" fx:id="labelCurrentContents" prefWidth="475.0" text="%key.EditAttachedFileDialog.Current.contents" AnchorPane.leftAnchor="150.0" AnchorPane.topAnchor="35.0" /> | |
26 | - </children> | |
27 | - </AnchorPane> | |
28 | - </children> | |
29 | -</VBox> |
@@ -1,58 +0,0 @@ | ||
1 | -/** | |
2 | - * EditAttachFilesDialog | |
3 | - * @author Ryuhei Terada | |
4 | - */ | |
5 | -package com.wiki.standalone.moxkiriya.dialog; | |
6 | - | |
7 | -import java.io.File; | |
8 | -import java.util.ResourceBundle; | |
9 | - | |
10 | -import javafx.scene.Scene; | |
11 | -import javafx.scene.web.WebView; | |
12 | -import javafx.stage.Stage; | |
13 | -import javafx.stage.Window; | |
14 | - | |
15 | -/** | |
16 | - * EditAttachFilesDialog | |
17 | - * | |
18 | - */ | |
19 | -public class EditAttachFilesDialog extends DialogBase { | |
20 | - private File contentDir_; | |
21 | - | |
22 | - /** | |
23 | - * コンストラクタ | |
24 | - * @param file コンテンツのディレクトリ | |
25 | - */ | |
26 | - public EditAttachFilesDialog(File file) { | |
27 | - contentDir_ = file; | |
28 | - } | |
29 | - | |
30 | - @Override | |
31 | - protected String getFXML() { | |
32 | - return "EditAttachFilesDialog.fxml"; | |
33 | - } | |
34 | - | |
35 | - @Override | |
36 | - protected DialogController getController() { | |
37 | - EditAttachFilesDialogController controller = loader_.getController(); | |
38 | - controller.setOwner(scene_.getWindow()); | |
39 | - controller.setContentDir(contentDir_); | |
40 | - controller.buildListView(); | |
41 | - | |
42 | - return controller; | |
43 | - } | |
44 | - | |
45 | - @Override | |
46 | - public CloseType showDialog(Stage stage, ResourceBundle resource) throws Exception { | |
47 | - CloseType closeType = super.showDialog(stage, resource); | |
48 | - Window owner = scene_.getWindow(); | |
49 | - Scene ownerScene = owner.getScene(); | |
50 | - WebView webView = (WebView)ownerScene.lookup("webView"); | |
51 | - | |
52 | - if(webView != null) { | |
53 | - webView.getEngine().reload(); | |
54 | - } | |
55 | - | |
56 | - return closeType; | |
57 | - } | |
58 | -} |
@@ -1,225 +0,0 @@ | ||
1 | -/** | |
2 | - * EditAttacheFilesDialog | |
3 | - * @author Ryuhei Terada | |
4 | - */ | |
5 | -package com.wiki.standalone.moxkiriya.dialog; | |
6 | - | |
7 | -import java.io.File; | |
8 | -import java.io.FileInputStream; | |
9 | -import java.io.InputStream; | |
10 | -import java.net.URI; | |
11 | -import java.net.URL; | |
12 | -import java.nio.file.Files; | |
13 | -import java.nio.file.Path; | |
14 | -import java.nio.file.Paths; | |
15 | -import java.util.List; | |
16 | -import java.util.ResourceBundle; | |
17 | - | |
18 | -import javafx.beans.value.ChangeListener; | |
19 | -import javafx.beans.value.ObservableValue; | |
20 | -import javafx.collections.ObservableList; | |
21 | -import javafx.event.ActionEvent; | |
22 | -import javafx.fxml.FXML; | |
23 | -import javafx.scene.Node; | |
24 | -import javafx.scene.control.Button; | |
25 | -import javafx.scene.control.CheckBox; | |
26 | -import javafx.scene.control.Label; | |
27 | -import javafx.scene.control.ListView; | |
28 | -import javafx.scene.control.cell.CheckBoxListCell; | |
29 | -import javafx.stage.FileChooser; | |
30 | -import javafx.stage.Window; | |
31 | -import javafx.util.Callback; | |
32 | - | |
33 | -public class EditAttachFilesDialogController extends DialogControllerBase { | |
34 | - @FXML | |
35 | - private Label labelCurrentContents; | |
36 | - | |
37 | - @FXML | |
38 | - private ListView<EditAttachFilesListViewItem> listViewAttacheFiles; | |
39 | - | |
40 | - @FXML | |
41 | - private CheckBox checkBoxSelectAll; | |
42 | - | |
43 | - @FXML | |
44 | - private Button buttonDeleteCheckedFiles; | |
45 | - | |
46 | - @FXML | |
47 | - private Button buttonAdd; | |
48 | - | |
49 | - @FXML | |
50 | - private Button buttonClose; | |
51 | - | |
52 | - /** 親Window */ | |
53 | - private Window parentWindow_; | |
54 | - | |
55 | - /** コンテンツのディレクトリ */ | |
56 | - private File contentDir_; | |
57 | - | |
58 | - /** 添付ファイルディレクトリ */ | |
59 | - private File attachesDir_; | |
60 | - | |
61 | - @Override | |
62 | - public void initialize(URL url, ResourceBundle resource) { | |
63 | - super.initialize(url, resource); | |
64 | - | |
65 | - checkBoxSelectAll.selectedProperty().addListener(new ChangeListener<Boolean>() { | |
66 | - @Override | |
67 | - public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { | |
68 | - ObservableList<EditAttachFilesListViewItem> items = listViewAttacheFiles.getItems(); | |
69 | - | |
70 | - for(EditAttachFilesListViewItem item: items) { | |
71 | - item.setSelected(newValue.booleanValue()); | |
72 | - } | |
73 | - } | |
74 | - }); | |
75 | - } | |
76 | - | |
77 | - /** | |
78 | - * オーナーを設定する。 | |
79 | - * @param window | |
80 | - */ | |
81 | - public void setOwner(Window window) { | |
82 | - parentWindow_ = window; | |
83 | - } | |
84 | - /** | |
85 | - * "Delete checked files"Button Action. | |
86 | - * @param event | |
87 | - */ | |
88 | - @FXML | |
89 | - public void onActionButtonDeleteCheckedFiles(ActionEvent event) { | |
90 | - ObservableList<EditAttachFilesListViewItem> items = listViewAttacheFiles.getItems(); | |
91 | - | |
92 | - for(EditAttachFilesListViewItem item: items) { | |
93 | - if(item.isSelected() == true) { | |
94 | - File file = new File(attachesDir_.getAbsoluteFile() | |
95 | - + "\\" | |
96 | - + item.getText()); | |
97 | - deleteFileSync(file); | |
98 | - } | |
99 | - break; | |
100 | - } | |
101 | - buildListView(); | |
102 | - } | |
103 | - | |
104 | - @FXML | |
105 | - public void onActionButtonUpload(ActionEvent event) { | |
106 | - try { | |
107 | - FileChooser fileChooser = new FileChooser(); | |
108 | - | |
109 | - fileChooser.setTitle(this.resource_.getString("key.EditAttachedFileDialog.Addfiles.DialogTitle")); | |
110 | - List<File> fileList = fileChooser.showOpenMultipleDialog(parentWindow_); | |
111 | - | |
112 | - if(fileList != null) { | |
113 | - if(attachesDir_.exists() == false) { | |
114 | - attachesDir_.mkdirs(); | |
115 | - } | |
116 | - | |
117 | - for(File file: fileList) { | |
118 | - String srcPath = file.getAbsolutePath(); | |
119 | - String filename = srcPath.substring(srcPath.lastIndexOf("\\") + "\\".length()); | |
120 | - | |
121 | - InputStream in = new FileInputStream(file); | |
122 | - URI uri = new File(attachesDir_.getAbsolutePath() + "\\" + filename).toURI(); | |
123 | - Path path = Paths.get(uri); | |
124 | - Files.copy(in, path); | |
125 | - } | |
126 | - buildListView(); | |
127 | - } | |
128 | - } catch (Exception e) { | |
129 | - e.printStackTrace(); | |
130 | - } | |
131 | - } | |
132 | - | |
133 | - @FXML | |
134 | - public void onActionButtonClose(ActionEvent event) { | |
135 | - ((Node)event.getSource()).getScene().getWindow().hide(); | |
136 | - } | |
137 | - | |
138 | - private void deleteFileSync(File file) { | |
139 | - try { | |
140 | - if(file.exists() == true) { | |
141 | - file.delete(); | |
142 | - } | |
143 | - | |
144 | - while(file.exists() == true) { | |
145 | - Thread.sleep(100); | |
146 | - } | |
147 | - } catch(Exception e) { | |
148 | - e.printStackTrace(); | |
149 | - } | |
150 | - } | |
151 | - | |
152 | - public void setContentDir(File contentDir) { | |
153 | - contentDir_ = contentDir; | |
154 | - String absolutePath = contentDir_.getAbsolutePath(); | |
155 | - StringBuffer buf = new StringBuffer(resource_.getString("key.EditAttachedFileDialog.Current.contents")); | |
156 | - | |
157 | - buf.append(" "); | |
158 | - buf.append(absolutePath.substring(absolutePath.lastIndexOf("\\") + "\\".length())); | |
159 | - labelCurrentContents.setText(buf.toString()); | |
160 | - } | |
161 | - | |
162 | - /** | |
163 | - * コンテンツのディレクトリを設定する。 | |
164 | - * @param contentDir | |
165 | - */ | |
166 | - public void buildListView() { | |
167 | - listViewAttacheFiles.getItems().clear(); | |
168 | - | |
169 | - attachesDir_ = new File(contentDir_.getAbsolutePath() + "\\attaches"); | |
170 | - | |
171 | - File[] files = attachesDir_.listFiles(); | |
172 | - | |
173 | - if(files != null) { | |
174 | - checkBoxSelectAll.setDisable(false); | |
175 | - buttonDeleteCheckedFiles.setDisable(false); | |
176 | - | |
177 | - for(File file: files) { | |
178 | - String path = file.getAbsolutePath(); | |
179 | - String filename = path.substring(path.lastIndexOf("\\") + "\\".length()); | |
180 | - | |
181 | - EditAttachFilesListViewItem item = createListViewItem(filename); | |
182 | - listViewAttacheFiles.getItems().add(item); | |
183 | - } | |
184 | - | |
185 | - listViewAttacheFiles.setCellFactory(CheckBoxListCell.forListView(new Callback<EditAttachFilesListViewItem, ObservableValue<Boolean>>() { | |
186 | - @Override | |
187 | - public ObservableValue<Boolean> call(EditAttachFilesListViewItem item) { | |
188 | - return item.selectedProperty(); | |
189 | - } | |
190 | - })); | |
191 | - } | |
192 | - else { | |
193 | - checkBoxSelectAll.setDisable(true); | |
194 | - buttonDeleteCheckedFiles.setDisable(true); | |
195 | - } | |
196 | - } | |
197 | - | |
198 | - private EditAttachFilesListViewItem createListViewItem(String filename) { | |
199 | - EditAttachFilesListViewItem item = new EditAttachFilesListViewItem(filename, false); | |
200 | - | |
201 | - item.selectedProperty().addListener(new ChangeListener<Boolean>() { | |
202 | - @Override | |
203 | - public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { | |
204 | - ObservableList<EditAttachFilesListViewItem> items = listViewAttacheFiles.getItems(); | |
205 | - boolean allSelected = false; | |
206 | - | |
207 | - for(EditAttachFilesListViewItem item: items) { | |
208 | - if(item.isSelected() == true) { | |
209 | - allSelected = true; | |
210 | - break; | |
211 | - } | |
212 | - } | |
213 | - | |
214 | - if(allSelected == false) { | |
215 | - /* | |
216 | - * すべてfalseの場合 | |
217 | - */ | |
218 | - checkBoxSelectAll.setSelected(false); | |
219 | - } | |
220 | - } | |
221 | - }); | |
222 | - | |
223 | - return item; | |
224 | - } | |
225 | -} |
@@ -1,49 +0,0 @@ | ||
1 | -package com.wiki.standalone.moxkiriya.dialog; | |
2 | - | |
3 | -import javafx.beans.property.BooleanProperty; | |
4 | -import javafx.beans.property.SimpleBooleanProperty; | |
5 | -import javafx.beans.property.SimpleStringProperty; | |
6 | -import javafx.beans.property.StringProperty; | |
7 | - | |
8 | -public class EditAttachFilesListViewItem { | |
9 | - private final StringProperty text_ = new SimpleStringProperty(); | |
10 | - private final BooleanProperty selected_ = new SimpleBooleanProperty(); | |
11 | - | |
12 | - public EditAttachFilesListViewItem(String text, boolean selected) { | |
13 | - setText(text); | |
14 | - setSelected(selected); | |
15 | - } | |
16 | - | |
17 | - public final StringProperty textProperty() { | |
18 | - return text_; | |
19 | - } | |
20 | - | |
21 | - public final void setText(String text) { | |
22 | - text_.set(text); | |
23 | - } | |
24 | - | |
25 | - public final String getText() { | |
26 | - return text_.getValue(); | |
27 | - } | |
28 | - | |
29 | - public final BooleanProperty selectedProperty() { | |
30 | - return selected_; | |
31 | - } | |
32 | - | |
33 | - public final void setSelected(boolean selected) { | |
34 | - selected_.setValue(selected); | |
35 | - } | |
36 | - | |
37 | - public final boolean getSelected() { | |
38 | - return selected_.getValue(); | |
39 | - } | |
40 | - | |
41 | - public final boolean isSelected() { | |
42 | - return getSelected(); | |
43 | - } | |
44 | - | |
45 | - @Override | |
46 | - public String toString() { | |
47 | - return getText(); | |
48 | - } | |
49 | -} |