Lines 41-50
Link Here
|
41 |
|
41 |
|
42 |
package org.netbeans.modules.server.ui.node; |
42 |
package org.netbeans.modules.server.ui.node; |
43 |
|
43 |
|
|
|
44 |
import java.awt.EventQueue; |
45 |
import java.awt.event.ActionEvent; |
44 |
import java.io.Serializable; |
46 |
import java.io.Serializable; |
45 |
import java.util.ArrayList; |
47 |
import java.util.ArrayList; |
46 |
import java.util.Collections; |
48 |
import java.util.Collections; |
47 |
import java.util.Comparator; |
49 |
import java.util.Comparator; |
|
|
50 |
import java.util.Enumeration; |
48 |
import java.util.List; |
51 |
import java.util.List; |
49 |
import javax.swing.Action; |
52 |
import javax.swing.Action; |
50 |
import javax.swing.event.ChangeEvent; |
53 |
import javax.swing.event.ChangeEvent; |
Lines 53-66
Link Here
|
53 |
import org.netbeans.api.server.ServerInstance; |
56 |
import org.netbeans.api.server.ServerInstance; |
54 |
import org.netbeans.modules.server.ServerRegistry; |
57 |
import org.netbeans.modules.server.ServerRegistry; |
55 |
import org.netbeans.spi.server.ServerInstanceProvider; |
58 |
import org.netbeans.spi.server.ServerInstanceProvider; |
|
|
59 |
import org.openide.filesystems.FileObject; |
60 |
import org.openide.filesystems.FileUtil; |
56 |
import org.openide.nodes.AbstractNode; |
61 |
import org.openide.nodes.AbstractNode; |
57 |
import org.openide.nodes.Children; |
62 |
import org.openide.nodes.Children; |
58 |
import org.openide.nodes.Node; |
63 |
import org.openide.nodes.Node; |
|
|
64 |
import org.openide.util.Lookup; |
65 |
import org.openide.util.Mutex; |
59 |
import org.openide.util.NbBundle; |
66 |
import org.openide.util.NbBundle; |
60 |
import org.openide.util.RequestProcessor; |
67 |
import org.openide.util.RequestProcessor; |
61 |
import org.openide.util.Utilities; |
68 |
import org.openide.util.Utilities; |
62 |
import org.openide.util.WeakListeners; |
69 |
import org.openide.util.WeakListeners; |
63 |
import org.openide.util.actions.SystemAction; |
|
|
64 |
import org.openide.util.lookup.Lookups; |
70 |
import org.openide.util.lookup.Lookups; |
65 |
|
71 |
|
66 |
public final class RootNode extends AbstractNode { |
72 |
public final class RootNode extends AbstractNode { |
Lines 100-106
Link Here
|
100 |
return Utilities.actionsForPath("Servers/Actions").toArray(new Action[0]); // NOI18N |
106 |
return Utilities.actionsForPath("Servers/Actions").toArray(new Action[0]); // NOI18N |
101 |
} |
107 |
} |
102 |
|
108 |
|
103 |
private static class ChildFactory extends org.openide.nodes.ChildFactory<ServerInstance> implements ChangeListener { |
109 |
|
|
|
110 |
static void enableActionsDueToProperties() { |
111 |
FileObject fo = FileUtil.getConfigFile("Servers/Actions"); // NOI18N |
112 |
Enumeration<String> en; |
113 |
if (fo != null) { |
114 |
for (FileObject o : fo.getChildren()) { |
115 |
en = o.getAttributes(); |
116 |
while (en.hasMoreElements()) { |
117 |
String attr = en.nextElement(); |
118 |
final String prefix = "property-"; // NOI18N |
119 |
if (attr.startsWith(prefix)) { |
120 |
attr = attr.substring(prefix.length()); |
121 |
if (System.getProperty(attr) != null) { |
122 |
Lookup l = Lookups.forPath("Servers/Actions"); // NOI18N |
123 |
for (Lookup.Item<Action> item : l.lookupResult(Action.class).allItems()) { |
124 |
if (item.getId().contains(o.getName())) { |
125 |
Action a = item.getInstance(); |
126 |
a.actionPerformed(new ActionEvent(getInstance(), 0, "noui")); // NOI18N |
127 |
} |
128 |
} |
129 |
} |
130 |
} |
131 |
} |
132 |
} |
133 |
} |
134 |
} |
135 |
|
136 |
private static class ChildFactory extends org.openide.nodes.ChildFactory<ServerInstance> |
137 |
implements ChangeListener, Runnable { |
104 |
|
138 |
|
105 |
private static final Comparator<ServerInstance> COMPARATOR = new InstanceComparator(); |
139 |
private static final Comparator<ServerInstance> COMPARATOR = new InstanceComparator(); |
106 |
|
140 |
|
Lines 154-159
Link Here
|
154 |
protected boolean createKeys(List<ServerInstance> toPopulate) { |
188 |
protected boolean createKeys(List<ServerInstance> toPopulate) { |
155 |
List<ServerInstance> fresh = new ArrayList<ServerInstance>(); |
189 |
List<ServerInstance> fresh = new ArrayList<ServerInstance>(); |
156 |
|
190 |
|
|
|
191 |
Mutex.EVENT.readAccess(this); |
192 |
|
157 |
ServerRegistry registry = ServerRegistry.getInstance(); |
193 |
ServerRegistry registry = ServerRegistry.getInstance(); |
158 |
for (ServerInstanceProvider type : registry.getProviders()) { |
194 |
for (ServerInstanceProvider type : registry.getProviders()) { |
159 |
fresh.addAll(type.getInstances()); |
195 |
fresh.addAll(type.getInstances()); |
Lines 165-171
Link Here
|
165 |
return true; |
201 |
return true; |
166 |
} |
202 |
} |
167 |
|
203 |
|
168 |
} |
204 |
private static boolean actionsPropertiesDone; |
|
|
205 |
public void run() { |
206 |
if (actionsPropertiesDone) { |
207 |
return; |
208 |
} |
209 |
assert EventQueue.isDispatchThread(); |
210 |
actionsPropertiesDone = true; |
211 |
enableActionsDueToProperties(); |
212 |
} |
213 |
} // end of ChildFactory |
169 |
|
214 |
|
170 |
private static class InstanceComparator implements Comparator<ServerInstance>, Serializable { |
215 |
private static class InstanceComparator implements Comparator<ServerInstance>, Serializable { |
171 |
|
216 |
|