1 | /**
|
---|
2 | * FolderSettings.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.settings.folders;
|
---|
20 |
|
---|
21 | import java.io.File;
|
---|
22 | import java.util.ArrayList;
|
---|
23 | import java.util.List;
|
---|
24 |
|
---|
25 | import org.expeditee.gui.AttributeValuePair;
|
---|
26 | import org.expeditee.gui.FrameIO;
|
---|
27 | import org.expeditee.gui.FrameUtils;
|
---|
28 | import org.expeditee.items.Text;
|
---|
29 | import org.expeditee.setting.DirectoryListSetting;
|
---|
30 | import org.expeditee.setting.ListSetting;
|
---|
31 | import org.expeditee.setting.Setting;
|
---|
32 |
|
---|
33 | public class FolderSettings {
|
---|
34 |
|
---|
35 | public static final DirectoryListSetting FrameDirs = new DirectoryListSetting("Directories to look in for frames", "FrameDirs");
|
---|
36 |
|
---|
37 | public static final Setting FramesetDir = new Setting("Adds a directory to look in for frames", "FramesetDir") {
|
---|
38 | @Override
|
---|
39 | public boolean setSetting(Text text) {
|
---|
40 | if(text.getText().indexOf(':') == -1) {
|
---|
41 | return false;
|
---|
42 | }
|
---|
43 | AttributeValuePair avp = new AttributeValuePair(text.getText());
|
---|
44 | if(avp.getValue().trim().length() != 0) {
|
---|
45 | String dir = FrameUtils.getDir(avp.getValue());
|
---|
46 | if (dir != null) {
|
---|
47 | FolderSettings.FrameDirs.get().add(dir);
|
---|
48 | return true;
|
---|
49 | }
|
---|
50 | }
|
---|
51 | return false;
|
---|
52 | }
|
---|
53 |
|
---|
54 | @Override
|
---|
55 | public Text generateRepresentation(String label, String frameset) {
|
---|
56 | Text t = new Text(label);
|
---|
57 | return t;
|
---|
58 | }
|
---|
59 | };
|
---|
60 |
|
---|
61 | public static DirectoryListSetting ImageDirs = new DirectoryListSetting("Directories to look in for images", "ImageDirs");
|
---|
62 |
|
---|
63 | public static final Setting ImageDir = new Setting("Adds a directory to look in for images", "ImageDir") {
|
---|
64 | @Override
|
---|
65 | public boolean setSetting(Text text) {
|
---|
66 | if(text.getText().indexOf(':') == -1) {
|
---|
67 | return false;
|
---|
68 | }
|
---|
69 | AttributeValuePair avp = new AttributeValuePair(text.getText());
|
---|
70 | if(avp.getValue().trim().length() != 0) {
|
---|
71 | String dir = FrameUtils.getDir(avp.getValue());
|
---|
72 | if(dir != null) {
|
---|
73 | FolderSettings.ImageDirs.get().add(0, dir);
|
---|
74 | return true;
|
---|
75 | }
|
---|
76 | }
|
---|
77 | return false;
|
---|
78 | }
|
---|
79 |
|
---|
80 | @Override
|
---|
81 | public Text generateRepresentation(String label, String frameset) {
|
---|
82 | Text t = new Text(label);
|
---|
83 | return t;
|
---|
84 | }
|
---|
85 | };
|
---|
86 |
|
---|
87 |
|
---|
88 | public static DirectoryListSetting AudioDirs = new DirectoryListSetting("Directories to look in for audio", "AudioDirs");
|
---|
89 |
|
---|
90 | public static final Setting AudioDir = new Setting("Adds a directory to look in for audio", "AudioDir") {
|
---|
91 | @Override
|
---|
92 | public boolean setSetting(Text text) {
|
---|
93 | if(text.getText().indexOf(':') == -1) {
|
---|
94 | return false;
|
---|
95 | }
|
---|
96 | AttributeValuePair avp = new AttributeValuePair(text.getText());
|
---|
97 | if(avp.getValue().trim().length() != 0) {
|
---|
98 | String dir = FrameUtils.getDir(avp.getValue());
|
---|
99 | if(dir != null) {
|
---|
100 | FolderSettings.AudioDirs.get().add(0, dir);
|
---|
101 | return true;
|
---|
102 | }
|
---|
103 | }
|
---|
104 | return false;
|
---|
105 | }
|
---|
106 |
|
---|
107 | @Override
|
---|
108 | public Text generateRepresentation(String label, String frameset) {
|
---|
109 | Text t = new Text(label);
|
---|
110 | return t;
|
---|
111 | }
|
---|
112 | };
|
---|
113 |
|
---|
114 |
|
---|
115 | public static final Setting LogDir = new Setting("Set the directory to save logs", "LogDir") {
|
---|
116 | @Override
|
---|
117 | public boolean setSetting(Text text) {
|
---|
118 | if(text.getText().indexOf(':') == -1) {
|
---|
119 | return false;
|
---|
120 | }
|
---|
121 | AttributeValuePair avp = new AttributeValuePair(text.getText());
|
---|
122 | if(avp.getValue().trim().length() != 0) {
|
---|
123 | FrameIO.LOGS_DIR = FrameUtils.getDir(avp.getValue());
|
---|
124 | }
|
---|
125 | return true;
|
---|
126 | }
|
---|
127 |
|
---|
128 | @Override
|
---|
129 | public Text generateRepresentation(String label, String frameset) {
|
---|
130 | Text t = new Text(label);
|
---|
131 | return t;
|
---|
132 | }
|
---|
133 | };
|
---|
134 | }
|
---|