8
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.dialogs.IDialogSettings;
|
|
14
|
|
15 // import java.io.IOException;
|
|
16 // import java.io.Reader;
|
|
17 // import java.io.Writer;
|
|
18
|
|
19 import dwt.dwthelper.utils;
|
|
20
|
19
|
21 static import tango.io.model.IConduit;
|
|
22
|
8
|
23 /**
|
|
24 * An interface to a storage mechanism for making dialog settings persistent.
|
|
25 * The store manages a collection of key/value pairs. The keys must be strings
|
|
26 * and the values can be either, strings or array of strings. Convenience API to
|
|
27 * convert primitive types to strings is provided.
|
|
28 */
|
|
29 public interface IDialogSettings {
|
|
30 /**
|
|
31 * Create a new section in the receiver and return it.
|
|
32 *
|
|
33 * @param name
|
|
34 * the name of the new section
|
|
35 * @return the new section
|
|
36 */
|
|
37 public IDialogSettings addNewSection(String name);
|
|
38
|
|
39 /**
|
|
40 * Add a section in the receiver.
|
|
41 *
|
|
42 * @param section
|
|
43 * the section to be added
|
|
44 */
|
|
45 public void addSection(IDialogSettings section);
|
|
46
|
|
47 /**
|
|
48 * Returns the value of the given key in this dialog settings.
|
|
49 *
|
|
50 * @param key
|
|
51 * the key
|
|
52 * @return the value, or <code>null</code> if none
|
|
53 */
|
|
54 public String get(String key);
|
|
55
|
|
56 /**
|
|
57 * Returns the value, an array of strings, of the given key in this dialog
|
|
58 * settings.
|
|
59 *
|
|
60 * @param key
|
|
61 * the key
|
|
62 * @return the array of string, or <code>null</code> if none
|
|
63 */
|
|
64 public String[] getArray(String key);
|
|
65
|
|
66 /**
|
|
67 * Convenience API. Convert the value of the given key in this dialog
|
|
68 * settings to a bool and return it.
|
|
69 *
|
|
70 * @param key
|
|
71 * the key
|
|
72 * @return the bool value, or <code>false</code> if none
|
|
73 */
|
|
74 public bool getBoolean(String key);
|
|
75
|
|
76 /**
|
|
77 * Convenience API. Convert the value of the given key in this dialog
|
|
78 * settings to a double and return it.
|
|
79 *
|
|
80 * @param key
|
|
81 * the key
|
|
82 * @return the value coverted to double, or throws
|
|
83 * <code>NumberFormatException</code> if none
|
|
84 *
|
|
85 * @exception NumberFormatException
|
|
86 * if the string value does not contain a parsable number.
|
|
87 * @see java.lang.Double#valueOf(java.lang.String)
|
|
88 */
|
|
89 public double getDouble(String key);
|
|
90
|
|
91 /**
|
|
92 * Convenience API. Convert the value of the given key in this dialog
|
|
93 * settings to a float and return it.
|
|
94 *
|
|
95 * @param key
|
|
96 * the key
|
|
97 * @return the value coverted to float, or throws
|
|
98 * <code>NumberFormatException</code> if none
|
|
99 *
|
|
100 * @exception NumberFormatException
|
|
101 * if the string value does not contain a parsable number.
|
|
102 * @see java.lang.Float#valueOf(java.lang.String)
|
|
103 */
|
|
104 public float getFloat(String key);
|
|
105
|
|
106 /**
|
|
107 * Convenience API. Convert the value of the given key in this dialog
|
|
108 * settings to a int and return it.
|
|
109 *
|
|
110 * @param key
|
|
111 * the key
|
|
112 * @return the value coverted to int, or throws
|
|
113 * <code>NumberFormatException</code> if none
|
|
114 *
|
|
115 * @exception NumberFormatException
|
|
116 * if the string value does not contain a parsable number.
|
|
117 * @see java.lang.Integer#valueOf(java.lang.String)
|
|
118 */
|
|
119 public int getInt(String key);
|
|
120
|
|
121 /**
|
|
122 * Convenience API. Convert the value of the given key in this dialog
|
|
123 * settings to a long and return it.
|
|
124 *
|
|
125 * @param key
|
|
126 * the key
|
|
127 * @return the value coverted to long, or throws
|
|
128 * <code>NumberFormatException</code> if none
|
|
129 *
|
|
130 * @exception NumberFormatException
|
|
131 * if the string value does not contain a parsable number.
|
|
132 * @see java.lang.Long#valueOf(java.lang.String)
|
|
133 */
|
|
134 public long getLong(String key);
|
|
135
|
|
136 /**
|
|
137 * Returns the IDialogSettings name.
|
|
138 *
|
|
139 * @return the name
|
|
140 */
|
|
141 public String getName();
|
|
142
|
|
143 /**
|
|
144 * Returns the section with the given name in this dialog settings.
|
|
145 *
|
|
146 * @param sectionName
|
|
147 * the key
|
|
148 * @return IDialogSettings (the section), or <code>null</code> if none
|
|
149 */
|
|
150 public IDialogSettings getSection(String sectionName);
|
|
151
|
|
152 /**
|
|
153 * Returns all the sections in this dialog settings.
|
|
154 *
|
|
155 * @return the section, or <code>null</code> if none
|
|
156 */
|
|
157 public IDialogSettings[] getSections();
|
|
158
|
|
159 /**
|
|
160 * Load a dialog settings from a stream and fill the receiver with its
|
|
161 * content.
|
|
162 *
|
|
163 * @param reader
|
|
164 * a Reader specifying the stream where the settings are read
|
|
165 * from.
|
|
166 * @throws IOException
|
|
167 */
|
19
|
168 public void load(tango.io.model.IConduit.InputStream reader);
|
8
|
169
|
|
170 /**
|
|
171 * Load a dialog settings from a file and fill the receiver with its
|
|
172 * content.
|
|
173 *
|
|
174 * @param fileName
|
|
175 * the name of the file the settings are read from.
|
|
176 * @throws IOException
|
|
177 */
|
|
178 public void load(String fileName);
|
|
179
|
|
180 /**
|
|
181 * Adds the pair <code>key/value</code> to this dialog settings.
|
|
182 *
|
|
183 * @param key
|
|
184 * the key.
|
|
185 * @param value
|
|
186 * the value to be associated with the <code>key</code>
|
|
187 */
|
|
188 public void put(String key, String[] value);
|
|
189
|
|
190 /**
|
|
191 * Convenience API. Converts the double <code>value</code> to a string and
|
|
192 * adds the pair <code>key/value</code> to this dialog settings.
|
|
193 *
|
|
194 * @param key
|
|
195 * the key.
|
|
196 * @param value
|
|
197 * the value to be associated with the <code>key</code>
|
|
198 */
|
|
199 public void put(String key, double value);
|
|
200
|
|
201 /**
|
|
202 * Convenience API. Converts the float <code>value</code> to a string and
|
|
203 * adds the pair <code>key/value</code> to this dialog settings.
|
|
204 *
|
|
205 * @param key
|
|
206 * the key.
|
|
207 * @param value
|
|
208 * the value to be associated with the <code>key</code>
|
|
209 */
|
|
210 public void put(String key, float value);
|
|
211
|
|
212 /**
|
|
213 * Convenience API. Converts the int <code>value</code> to a string and
|
|
214 * adds the pair <code>key/value</code> to this dialog settings.
|
|
215 *
|
|
216 * @param key
|
|
217 * the key.
|
|
218 * @param value
|
|
219 * the value to be associated with the <code>key</code>
|
|
220 */
|
|
221 public void put(String key, int value);
|
|
222
|
|
223 /**
|
|
224 * Convenience API. Converts the long <code>value</code> to a string and
|
|
225 * adds the pair <code>key/value</code> to this dialog settings.
|
|
226 *
|
|
227 * @param key
|
|
228 * the key.
|
|
229 * @param value
|
|
230 * the value to be associated with the <code>key</code>
|
|
231 */
|
|
232 public void put(String key, long value);
|
|
233
|
|
234 /**
|
|
235 * Adds the pair <code>key/value</code> to this dialog settings.
|
|
236 *
|
|
237 * @param key
|
|
238 * the key.
|
|
239 * @param value
|
|
240 * the value to be associated with the <code>key</code>
|
|
241 */
|
|
242 public void put(String key, String value);
|
|
243
|
|
244 /**
|
|
245 * Convenience API. Converts the bool <code>value</code> to a string
|
|
246 * and adds the pair <code>key/value</code> to this dialog settings.
|
|
247 *
|
|
248 * @param key
|
|
249 * the key.
|
|
250 * @param value
|
|
251 * the value to be associated with the <code>key</code>
|
|
252 */
|
|
253 public void put(String key, bool value);
|
|
254
|
|
255 /**
|
|
256 * Save a dialog settings to a stream
|
|
257 *
|
|
258 * @param writer
|
|
259 * a Writer specifying the stream the settings are written in.
|
|
260 * @throws IOException
|
|
261 */
|
19
|
262 public void save(tango.io.model.IConduit.OutputStream writer);
|
8
|
263
|
|
264 /**
|
|
265 * Save a dialog settings to a file.
|
|
266 *
|
|
267 * @param fileName
|
|
268 * the name of the file the settings are written in.
|
|
269 * @throws IOException
|
|
270 */
|
|
271 public void save(String fileName);
|
|
272 }
|