001: /**
002: * Miroslav Popov, Dec 2, 2005
003: * miroslav.popov@gmail.com
004: */package org.enhydra.jawe.base.editor;
005:
006: import java.awt.Color;
007: import java.net.URL;
008: import java.util.List;
009: import java.util.Properties;
010:
011: import javax.swing.ImageIcon;
012:
013: import org.enhydra.jawe.AdditionalResourceManager;
014: import org.enhydra.jawe.JaWEComponent;
015: import org.enhydra.jawe.ResourceManager;
016: import org.enhydra.jawe.Utils;
017: import org.enhydra.jawe.base.controller.JaWEActions;
018: import org.enhydra.jawe.base.panel.PanelSettings;
019:
020: /**
021: * @author Miroslav Popov
022: *
023: */
024: public class StandardXPDLElementEditorSettings extends PanelSettings {
025:
026: public void init(JaWEComponent comp) {
027: loadDefault(comp, new Properties());
028: }
029:
030: public void loadDefault(JaWEComponent comp, Properties properties) {
031: arm = new AdditionalResourceManager(properties);
032:
033: componentSettings.put("UseScrollBar", new Boolean(properties
034: .getProperty("InlinePanel.UseScrollBar", "true")
035: .equals("true")));
036: componentSettings.put("ShowModifiedWarning", new Boolean(
037: properties.getProperty(
038: "InlinePanel.ShowModifiedWarning", "true")
039: .equals("true")));
040: componentSettings.put("DisplayTitle", new Boolean(properties
041: .getProperty("InlinePanel.DisplayTitle", "false")
042: .equals("true")));
043: componentSettings.put("XMLBasicPanel.RightAllignment",
044: new Boolean(properties.getProperty(
045: "XMLBasicPanel.RightAllignment", "false")
046: .equals("true")));
047: componentSettings.put("XMLDataTypesPanel.HasBorder",
048: new Boolean(properties.getProperty(
049: "XMLDataTypesPanel.HasBorder", "false").equals(
050: "true")));
051:
052: componentSettings.put("EmptyBorder.TOP", new Integer(properties
053: .getProperty("XMLBasicPanel.EmptyBorder.TOP", "0")));
054: componentSettings.put("EmptyBorder.LEFT", new Integer(
055: properties.getProperty(
056: "XMLBasicPanel.EmptyBorder.LEFT", "3")));
057: componentSettings.put("EmptyBorder.BOTTOM", new Integer(
058: properties.getProperty(
059: "XMLBasicPanel.EmptyBorder.BOTTOM", "4")));
060: componentSettings.put("EmptyBorder.RIGHT", new Integer(
061: properties.getProperty(
062: "XMLBasicPanel.EmptyBorder.RIGHT", "3")));
063: componentSettings.put("SimplePanelTextWidth", new Integer(
064: properties.getProperty(
065: "XMLBasicPanel.SimplePanelTextWidth", "250")));
066: componentSettings.put("SimplePanelTextHeight", new Integer(
067: properties.getProperty(
068: "XMLBasicPanel.SimplePanelTextHeight", "20")));
069: componentSettings.put("XMLDataTypesPanel.Dimension.WIDTH",
070: new Integer(properties.getProperty(
071: "XMLDataTypesPanel.Dimension.WIDTH", "400")));
072: componentSettings.put("XMLDataTypesPanel.Dimension.HEIGHT",
073: new Integer(properties.getProperty(
074: "XMLDataTypesPanel.Dimension.HEIGHT", "125")));
075:
076: componentSettings.put("XMLComboPanel.DisableCombo", properties
077: .getProperty("XMLComboPanel.DisableCombo", ""));
078:
079: Color color = null;
080: try {
081: color = Utils.getColor(ResourceManager.getResourceString(
082: properties, "BackgroundColor"));
083: } catch (Exception e) {
084: color = Utils.getColor("R=245,G=245,B=245");
085: }
086: componentSettings.put("BackgroundColor", color);
087:
088: ImageIcon hicon;
089: URL iconURL = ResourceManager.getResource(properties,
090: "ArrowRightImage");
091: if (iconURL != null)
092: hicon = new ImageIcon(iconURL);
093: else
094: hicon = new ImageIcon(
095: ResourceManager.class
096: .getClassLoader()
097: .getResource(
098: "org/enhydra/jawe/images/navigate_right.png"));
099: componentSettings.put("ArrowRightImage", hicon);
100:
101: iconURL = ResourceManager.getResource(properties,
102: "ArrowUpImage");
103: if (iconURL != null)
104: hicon = new ImageIcon(iconURL);
105: else
106: hicon = new ImageIcon(ResourceManager.class
107: .getClassLoader().getResource(
108: "org/enhydra/jawe/images/arrowup.gif"));
109: componentSettings.put("ArrowUpImage", hicon);
110:
111: iconURL = ResourceManager.getResource(properties,
112: "ArrowDownImage");
113: if (iconURL != null)
114: hicon = new ImageIcon(iconURL);
115: else
116: hicon = new ImageIcon(ResourceManager.class
117: .getClassLoader().getResource(
118: "org/enhydra/jawe/images/arrowdown.gif"));
119: componentSettings.put("ArrowDownImage", hicon);
120:
121: iconURL = ResourceManager.getResource(properties,
122: "InsertVariableDefault.Icon");
123: if (iconURL != null)
124: hicon = new ImageIcon(iconURL);
125: else
126: hicon = new ImageIcon(
127: ResourceManager.class
128: .getClassLoader()
129: .getResource(
130: "org/enhydra/jawe/images/navigate_right2.png"));
131: componentSettings.put("InsertVariableDefault", hicon);
132:
133: iconURL = ResourceManager.getResource(properties,
134: "InsertVariablePressed.Icon");
135: if (iconURL != null)
136: hicon = new ImageIcon(iconURL);
137: else
138: hicon = new ImageIcon(
139: ResourceManager.class
140: .getClassLoader()
141: .getResource(
142: "org/enhydra/jawe/images/navigate_down2.png"));
143: componentSettings.put("InsertVariablePressed", hicon);
144:
145: iconURL = ResourceManager.getResource(properties,
146: "DefaultAction.Image.New");
147: if (iconURL != null)
148: hicon = new ImageIcon(iconURL);
149: else
150: hicon = new ImageIcon(ResourceManager.class
151: .getClassLoader().getResource(
152: "org/enhydra/jawe/images/new_small.gif"));
153: componentSettings.put("DefaultAction.Icon."
154: + JaWEActions.NEW_ACTION, hicon);
155:
156: iconURL = ResourceManager.getResource(properties,
157: "DefaultAction.Image.EditProperties");
158: if (iconURL != null)
159: hicon = new ImageIcon(iconURL);
160: else
161: hicon = new ImageIcon(ResourceManager.class
162: .getClassLoader().getResource(
163: "org/enhydra/jawe/images/edit_small.gif"));
164: componentSettings.put("DefaultAction.Icon."
165: + JaWEActions.EDIT_PROPERTIES_ACTION, hicon);
166:
167: iconURL = ResourceManager.getResource(properties,
168: "DefaultAction.Image.Delete");
169: if (iconURL != null)
170: hicon = new ImageIcon(iconURL);
171: else
172: hicon = new ImageIcon(ResourceManager.class
173: .getClassLoader().getResource(
174: "org/enhydra/jawe/images/delete_small.gif"));
175: componentSettings.put("DefaultAction.Icon."
176: + JaWEActions.DELETE_ACTION, hicon);
177:
178: iconURL = ResourceManager.getResource(properties,
179: "DefaultAction.Image.Duplicate");
180: if (iconURL != null)
181: hicon = new ImageIcon(iconURL);
182: else
183: hicon = new ImageIcon(
184: ResourceManager.class
185: .getClassLoader()
186: .getResource(
187: "org/enhydra/jawe/images/duplicate_small.gif"));
188: componentSettings.put("DefaultAction.Icon."
189: + JaWEActions.DUPLICATE_ACTION, hicon);
190:
191: iconURL = ResourceManager.getResource(properties,
192: "DefaultAction.Image.References");
193: if (iconURL != null)
194: hicon = new ImageIcon(iconURL);
195: else
196: hicon = new ImageIcon(
197: ResourceManager.class
198: .getClassLoader()
199: .getResource(
200: "org/enhydra/jawe/images/references_small.gif"));
201: componentSettings.put("DefaultAction.Icon."
202: + JaWEActions.REFERENCES, hicon);
203:
204: componentSettings
205: .put("HideSubElements.XMLGroupPanel.Activity",
206: "Deadlines ExtendedAttributes SimulationInformation TransitionRestrictions");
207: componentSettings
208: .put(
209: "HideSubElements.XMLGroupPanel.Package",
210: "PackageHeader RedefinableHeader WorkflowProcesses Applications Participants DataFields TypeDeclarations ExternalPackages Namespaces ExtendedAttributes");
211: componentSettings.put(
212: "HideSubElements.XMLGroupPanel.Transition",
213: "ExtendedAttributes");
214: componentSettings
215: .put(
216: "HideSubElements.XMLGroupPanel.WorkflowProcess",
217: "ProcessHeader RedefinableHeader Applications Participants DataFields FormalParameters ActivitySets Activities Transitions ExtendedAttributes");
218:
219: List hideEls = ResourceManager.getResourceStrings(properties,
220: "HideSubElements.", false);
221: for (int i = 0; i < hideEls.size(); i++) {
222: componentSettings.put("HideSubElements."
223: + (String) hideEls.get(i), ResourceManager
224: .getResourceString(properties, "HideSubElements."
225: + (String) hideEls.get(i)));
226: }
227:
228: componentSettings
229: .put("HideElements.XMLTablePanel.ExtendedAttributes",
230: "Name");
231: componentSettings
232: .put(
233: "HideElements.XMLTablePanel.ExtendedAttributes.Name",
234: "JaWE_CONFIGURATION JaWE_TYPE EDITING_TOOL EDITING_TOOL_VERSION JaWE_GRAPH_WORKFLOW_PARTICIPANT_ORIENTATION JaWE_GRAPH_BLOCK_PARTICIPANT_ORIENTATION JaWE_GRAPH_WORKFLOW_PARTICIPANT_ORDER JaWE_GRAPH_BLOCK_PARTICIPANT_ORDER JaWE_GRAPH_START_OF_WORKFLOW JaWE_GRAPH_END_OF_WORKFLOW JaWE_GRAPH_START_OF_BLOCK JaWE_GRAPH_END_OF_BLOCK JaWE_GRAPH_PARTICIPANT_ID JaWE_GRAPH_OFFSET JaWE_GRAPH_BREAK_POINTS JaWE_GRAPH_TRANSITION_STYLE");
235:
236: List hide = ResourceManager.getResourceStrings(properties,
237: "HideElements.", false);
238: for (int i = 0; i < hide.size(); i++) {
239: String line = (String) hide.get(i);
240: String[] parts = Utils.tokenize(line, ".");
241:
242: if (parts.length != 3)
243: continue;
244:
245: String panelName = parts[0];
246: String elName = parts[1];
247: String flName = parts[2];
248:
249: if ("XMLTablePanel".equals(panelName)
250: && "ExtendedAttributes".equals(elName)
251: && "Name".equals(flName)) {
252: String elHiddenEl = (String) componentSettings
253: .get("HideElements." + panelName + "." + elName);
254: elHiddenEl = elHiddenEl.replaceAll(flName, "");
255: if (elHiddenEl.length() == 0)
256: componentSettings
257: .remove("HideElements.XMLTablePanel.ExtendedAttributes");
258: else
259: componentSettings
260: .put(
261: "HideElements.XMLTablePanel.ExtendedAttributes",
262: elHiddenEl);
263: componentSettings
264: .remove("HideElements.XMLTablePanel.ExtendedAttributes.Name");
265: }
266:
267: String elHiddenEl = (String) componentSettings
268: .get("HideElements." + panelName + "." + elName);
269: if (elHiddenEl == null)
270: elHiddenEl = flName;
271: else
272: elHiddenEl += " " + flName;
273:
274: String hel = ResourceManager.getResourceString(properties,
275: "HideElements." + panelName + "." + elName + "."
276: + flName);
277: componentSettings.put("HideElements." + panelName + "."
278: + elName, elHiddenEl);
279: componentSettings.put("HideElements." + panelName + "."
280: + elName + "." + flName, hel);
281: }
282:
283: componentSettings
284: .put("ShowColumns.XMLTablePanel.Activities",
285: "Id Name Performer Type StartMode FinishMode Deadlines");
286: componentSettings.put("ShowColumns.XMLTablePanel.ActivitySets",
287: "Id Activities Transitions");
288: componentSettings.put("ShowColumns.XMLTablePanel.Applications",
289: "Id Name");
290: componentSettings.put("ShowColumns.XMLTablePanel.DataFields",
291: "Id Name DataType InitialValue");
292: componentSettings.put(
293: "ShowColumns.XMLTablePanel.ExtendedAttributes",
294: "Name Value");
295: componentSettings.put(
296: "ShowColumns.XMLTablePanel.FormalParameters",
297: "Id Mode DataType");
298: componentSettings.put("ShowColumns.XMLTablePanel.Namespaces",
299: "Name location");
300: componentSettings.put("ShowColumns.XMLTablePanel.Participants",
301: "Id Name ParticipantType");
302: componentSettings.put("ShowColumns.XMLTablePanel.Tools",
303: "Id Type ActualParameters");
304: componentSettings.put("ShowColumns.XMLTablePanel.Transitions",
305: "Id From To Condition");
306: componentSettings.put(
307: "ShowColumns.XMLTablePanel.TypeDeclarations",
308: "Id Name DataTypes");
309: componentSettings.put(
310: "ShowColumns.XMLTablePanel.WorkflowProcesses",
311: "Id Name AccessLevel DataFields FormalParameters");
312:
313: List showCols = ResourceManager.getResourceStrings(properties,
314: "ShowColumns.", false);
315: for (int i = 0; i < showCols.size(); i++) {
316: componentSettings.put("ShowColumns."
317: + (String) showCols.get(i), ResourceManager
318: .getResourceString(properties, "ShowColumns."
319: + (String) showCols.get(i)));
320: }
321:
322: loadDefaultMenusToolbarsAndActions(comp);
323:
324: }
325:
326: protected void loadDefaultMenusToolbarsAndActions(JaWEComponent comp) {
327: }
328:
329: public String getToolbarActionOrder(String toolbarName) {
330: return (String) componentSettings.get(toolbarName + "Toolbar");
331: }
332:
333: }
|