1
1
// **********************************************************************
3
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
8
8
// **********************************************************************
9
10
package IceGridGUI.Application;
11
12
import java.awt.event.ActionEvent;
28
29
CommunicatorSubEditor(Editor mainEditor)
30
31
_mainEditor = mainEditor;
32
_description.getDocument().addDocumentListener(
33
_mainEditor.getUpdateListener());
33
_description.getDocument().addDocumentListener(_mainEditor.getUpdateListener());
34
34
_description.setToolTipText("An optional description");
36
_propertySets.getDocument().addDocumentListener(
37
_mainEditor.getUpdateListener());
36
_propertySets.getDocument().addDocumentListener(_mainEditor.getUpdateListener());
38
37
_propertySets.setToolTipText("Property Set References");
40
39
_properties = new PropertiesField(mainEditor);
41
_logFiles = new MapField(mainEditor, "Path", "Property",
40
_logFiles = new SimpleMapField(mainEditor, true, "Path", "Property");
43
41
_logFiles.setToolTipText("Log files used by this server or service");
47
44
void appendProperties(DefaultFormBuilder builder)
49
46
builder.append("Description");
52
49
builder.nextRow(-2);
53
50
CellConstraints cc = new CellConstraints();
54
51
JScrollPane scrollPane = new JScrollPane(_description);
55
builder.add(scrollPane,
56
cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
52
builder.add(scrollPane, cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
57
53
builder.nextRow(2);
58
54
builder.nextLine();
60
56
builder.append("Property Sets");
61
57
builder.append(_propertySets, 3);
62
58
builder.nextLine();
83
78
builder.append("");
84
79
builder.nextRow(-4);
85
80
scrollPane = new JScrollPane(_logFiles);
86
builder.add(scrollPane,
87
cc.xywh(builder.getColumn(), builder.getRow(), 3, 5));
81
builder.add(scrollPane, cc.xywh(builder.getColumn(), builder.getRow(), 3, 5));
88
82
builder.nextRow(4);
89
83
builder.nextLine();
92
86
void writeDescriptor(CommunicatorDescriptor descriptor)
94
descriptor.propertySet.references =
95
(String[])_propertySets.getList().toArray(new String[0]);
88
descriptor.propertySet.references = _propertySets.getList().toArray(new String[0]);
96
89
descriptor.propertySet.properties = _properties.getProperties();
97
90
descriptor.description = _description.getText();
99
java.util.TreeMap tm = _logFiles.get();
100
java.util.Iterator p = tm.entrySet().iterator();
92
java.util.TreeMap<String, String> tm = _logFiles.get();
101
93
descriptor.logs = new String[tm.size()];
96
for(java.util.Map.Entry<String, String> p : tm.entrySet())
106
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
107
String path = (String)entry.getKey();
108
String prop = ((String)entry.getValue()).trim();
98
String path = p.getKey();
99
String prop = p.getValue().trim();
110
101
descriptor.logs[i++] = path;
111
102
if(!prop.equals(""))
113
setProperty((java.util.LinkedList)descriptor.propertySet.properties, prop, path);
104
setProperty((java.util.LinkedList<PropertyDescriptor>)descriptor.propertySet.properties, prop, path);
124
115
// Note that we don't substitute in the lookup
126
java.util.Map map = new java.util.TreeMap();
127
for(int i = 0; i < descriptor.logs.length; ++i)
117
java.util.Map<String, String> map = new java.util.TreeMap<String, String>();
118
for(String log : descriptor.logs)
129
String prop = lookupKey(descriptor.propertySet.properties,
131
map.put(descriptor.logs[i], prop);
120
String prop = lookupKey(descriptor.propertySet.properties, log);
133
123
_logFiles.set(map, detailResolver, isEditable);
135
_propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
125
_propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references), detailResolver);
137
126
_propertySets.setEditable(isEditable);
138
127
_properties.setProperties(descriptor.propertySet.properties,
139
128
descriptor.adapters,
141
130
detailResolver, isEditable);
143
_description.setText(
144
Utils.substitute(descriptor.description, detailResolver));
132
_description.setText(Utils.substitute(descriptor.description, detailResolver));
145
133
_description.setEditable(isEditable);
146
134
_description.setOpaque(isEditable);
151
138
// Returns first key matching this value, if there is one
153
private String lookupKey(java.util.List props, String value)
140
private String lookupKey(java.util.List<PropertyDescriptor> props, String value)
155
java.util.Iterator p = props.iterator();
142
for(PropertyDescriptor p : props)
158
PropertyDescriptor pd = (PropertyDescriptor)p.next();
159
if(pd.value.equals(value))
144
if(p.value.equals(value))
167
private void setProperty(java.util.LinkedList props, String key, String newValue)
152
private void setProperty(java.util.LinkedList<PropertyDescriptor> props, String key, String newValue)
169
154
removeProperty(props, key);
170
155
props.addFirst(new PropertyDescriptor(key, newValue));
173
private void removeProperty(java.util.List props, String key)
158
private void removeProperty(java.util.List<PropertyDescriptor> props, String key)
175
java.util.Iterator p = props.iterator();
160
java.util.Iterator<PropertyDescriptor> p = props.iterator();
176
161
while(p.hasNext())
178
PropertyDescriptor pd = (PropertyDescriptor)p.next();
163
PropertyDescriptor pd = p.next();
179
164
if(pd.name.equals(key))
187
171
protected Editor _mainEditor;
189
173
private JTextArea _description = new JTextArea(3, 20);
190
private ListTextField _propertySets = new ListTextField(20);
174
private ListTextField _propertySets = new ListTextField(20);
191
175
private PropertiesField _properties;
192
private MapField _logFiles;
176
private SimpleMapField _logFiles;