Mercurial > projects > dwt-addons
annotate dwtx/jface/text/formatter/FormattingContext.d @ 200:eb3414669eb0 default tip
fix for dmd 1.041 and tango 0.99.8
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 28 Mar 2009 03:09:57 +0100 |
parents | 1a5b8f8129df |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 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 | |
131 | 14 |
151 | 15 module dwtx.jface.text.formatter.FormattingContext; |
16 | |
131 | 17 import dwtx.jface.text.formatter.MultiPassContentFormatter; // packageimport |
18 import dwtx.jface.text.formatter.ContextBasedFormattingStrategy; // packageimport | |
19 import dwtx.jface.text.formatter.IFormattingStrategy; // packageimport | |
20 import dwtx.jface.text.formatter.IContentFormatterExtension; // packageimport | |
21 import dwtx.jface.text.formatter.IFormattingStrategyExtension; // packageimport | |
22 import dwtx.jface.text.formatter.IContentFormatter; // packageimport | |
23 import dwtx.jface.text.formatter.FormattingContextProperties; // packageimport | |
24 import dwtx.jface.text.formatter.ContentFormatter; // packageimport | |
25 import dwtx.jface.text.formatter.IFormattingContext; // packageimport | |
26 | |
129 | 27 import dwt.dwthelper.utils; |
28 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
29 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
151
diff
changeset
|
30 |
129 | 31 |
32 import dwtx.jface.preference.IPreferenceStore; | |
33 | |
34 /** | |
35 * Default implementation of <code>IFormattingContext</code>. | |
36 * | |
37 * @since 3.0 | |
38 */ | |
39 public class FormattingContext : IFormattingContext { | |
40 | |
41 /** Map to store the properties */ | |
162 | 42 private const Map fMap; |
43 | |
44 this(){ | |
45 fMap= new HashMap(); | |
46 } | |
129 | 47 |
48 /* | |
49 * @see dwtx.jface.text.formatter.IFormattingContext#dispose() | |
50 */ | |
51 public void dispose() { | |
52 fMap.clear(); | |
53 } | |
54 | |
55 /* | |
56 * @see dwtx.jface.text.formatter.IFormattingContext#getPreferenceKeys() | |
57 */ | |
58 public String[] getPreferenceKeys() { | |
145 | 59 return null; |
129 | 60 } |
61 | |
62 /* | |
63 * @see dwtx.jface.text.formatter.IFormattingContext#getProperty(java.lang.Object) | |
64 */ | |
65 public Object getProperty(Object key) { | |
66 return fMap.get(key); | |
67 } | |
68 | |
69 /* | |
70 * @see dwtx.jface.text.formatter.IFormattingContext#isBooleanPreference(java.lang.String) | |
71 */ | |
72 public bool isBooleanPreference(String key) { | |
73 return false; | |
74 } | |
75 | |
76 /* | |
77 * @see dwtx.jface.text.formatter.IFormattingContext#isDoublePreference(java.lang.String) | |
78 */ | |
79 public bool isDoublePreference(String key) { | |
80 return false; | |
81 } | |
82 | |
83 /* | |
84 * @see dwtx.jface.text.formatter.IFormattingContext#isFloatPreference(java.lang.String) | |
85 */ | |
86 public bool isFloatPreference(String key) { | |
87 return false; | |
88 } | |
89 | |
90 /* | |
91 * @see dwtx.jface.text.formatter.IFormattingContext#isIntegerPreference(java.lang.String) | |
92 */ | |
93 public bool isIntegerPreference(String key) { | |
94 return false; | |
95 } | |
96 | |
97 /* | |
98 * @see dwtx.jface.text.formatter.IFormattingContext#isLongPreference(java.lang.String) | |
99 */ | |
100 public bool isLongPreference(String key) { | |
101 return false; | |
102 } | |
103 | |
104 /* | |
105 * @see dwtx.jface.text.formatter.IFormattingContext#isStringPreference(java.lang.String) | |
106 */ | |
107 public bool isStringPreference(String key) { | |
108 return false; | |
109 } | |
110 | |
111 /* | |
112 * @see dwtx.jface.text.formatter.IFormattingContext#mapToStore(java.util.Map, dwtx.jface.preference.IPreferenceStore) | |
113 */ | |
114 public void mapToStore(Map map, IPreferenceStore store) { | |
115 | |
116 final String[] preferences= getPreferenceKeys(); | |
117 | |
118 String result= null; | |
119 String preference= null; | |
120 | |
121 for (int index= 0; index < preferences.length; index++) { | |
122 | |
123 preference= preferences[index]; | |
162 | 124 result= stringcast(map.get(preference)); |
129 | 125 |
126 if (result !is null) { | |
127 | |
128 try { | |
129 if (isBooleanPreference(preference)) { | |
130 store.setValue(preference, result.equals(IPreferenceStore.TRUE)); | |
131 } else if (isIntegerPreference(preference)) { | |
132 store.setValue(preference, Integer.parseInt(result)); | |
133 } else if (isStringPreference(preference)) { | |
134 store.setValue(preference, result); | |
135 } else if (isDoublePreference(preference)) { | |
136 store.setValue(preference, Double.parseDouble(result)); | |
137 } else if (isFloatPreference(preference)) { | |
138 store.setValue(preference, Float.parseFloat(result)); | |
139 } else if (isLongPreference(preference)) { | |
140 store.setValue(preference, Long.parseLong(result)); | |
141 } | |
142 } catch (NumberFormatException exception) { | |
143 // Do nothing | |
144 } | |
145 } | |
146 } | |
147 } | |
148 | |
149 /* | |
150 * @see dwtx.jface.text.formatter.IFormattingContext#setProperty(java.lang.Object, java.lang.Object) | |
151 */ | |
152 public void setProperty(Object key, Object property) { | |
153 fMap.put(key, property); | |
154 } | |
155 | |
156 /* | |
157 * @see dwtx.jface.text.formatter.IFormattingContext#storeToMap(dwtx.jface.preference.IPreferenceStore, java.util.Map, bool) | |
158 */ | |
159 public void storeToMap(IPreferenceStore store, Map map, bool useDefault) { | |
160 | |
161 final String[] preferences= getPreferenceKeys(); | |
162 | |
163 String preference= null; | |
164 for (int index= 0; index < preferences.length; index++) { | |
165 | |
166 preference= preferences[index]; | |
167 | |
168 if (isBooleanPreference(preference)) { | |
169 map.put(preference, (useDefault ? store.getDefaultBoolean(preference) : store.getBoolean(preference)) ? IPreferenceStore.TRUE : IPreferenceStore.FALSE); | |
170 } else if (isIntegerPreference(preference)) { | |
162 | 171 map.put(preference, String_valueOf(useDefault ? store.getDefaultInt(preference) : store.getInt(preference))); |
129 | 172 } else if (isStringPreference(preference)) { |
173 map.put(preference, useDefault ? store.getDefaultString(preference) : store.getString(preference)); | |
174 } else if (isDoublePreference(preference)) { | |
162 | 175 map.put(preference, String_valueOf(useDefault ? store.getDefaultDouble(preference) : store.getDouble(preference))); |
129 | 176 } else if (isFloatPreference(preference)) { |
162 | 177 map.put(preference, String_valueOf(useDefault ? store.getDefaultFloat(preference) : store.getFloat(preference))); |
129 | 178 } else if (isLongPreference(preference)) { |
162 | 179 map.put(preference, String_valueOf(useDefault ? store.getDefaultLong(preference) : store.getLong(preference))); |
129 | 180 } |
181 } | |
182 } | |
183 } |