|
Lines 13-54
Link Here
|
| 13 |
package org.eclipse.hyades.perfmon.common.internal.launch; |
13 |
package org.eclipse.hyades.perfmon.common.internal.launch; |
| 14 |
|
14 |
|
| 15 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
|
|
16 |
import java.util.List; |
| 16 |
|
17 |
|
|
|
18 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 19 |
import org.eclipse.core.runtime.IExtension; |
| 20 |
import org.eclipse.core.runtime.Platform; |
| 17 |
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; |
21 |
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; |
| 18 |
import org.eclipse.debug.ui.CommonTab; |
22 |
import org.eclipse.debug.ui.CommonTab; |
| 19 |
import org.eclipse.debug.ui.ILaunchConfigurationDialog; |
23 |
import org.eclipse.debug.ui.ILaunchConfigurationDialog; |
| 20 |
import org.eclipse.debug.ui.ILaunchConfigurationTab; |
24 |
import org.eclipse.debug.ui.ILaunchConfigurationTab; |
| 21 |
import org.eclipse.hyades.perfmon.apache.internal.launchconfig.ApacheTabInterface; |
25 |
import org.eclipse.hyades.perfmon.ImageManager; |
| 22 |
import org.eclipse.hyades.perfmon.jboss.internal.launchconfig.JBossTabInterface; |
26 |
import org.eclipse.hyades.perfmon.PerfmonPlugin; |
| 23 |
import org.eclipse.hyades.perfmon.jonas.internal.launchconfig.JonasTabInterface; |
27 |
import org.eclipse.hyades.ui.internal.util.UIUtil; |
| 24 |
import org.eclipse.hyades.perfmon.linux.internal.launchconfig.LinuxTabInterface; |
28 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 25 |
import org.eclipse.hyades.perfmon.mysql.internal.launchconfig.MySQLTabInterface; |
29 |
import org.eclipse.jface.resource.ImageRegistry; |
| 26 |
import org.eclipse.hyades.perfmon.perfmon.internal.launchconfig.PerfmonTabInterface; |
30 |
import org.eclipse.swt.graphics.Image; |
| 27 |
|
31 |
|
| 28 |
public class StatisticalAgentTabGroup extends AbstractLaunchConfigurationTabGroup |
32 |
public class StatisticalAgentTabGroup extends AbstractLaunchConfigurationTabGroup |
| 29 |
{ |
33 |
{ |
| 30 |
public static ArrayList agentTabList = new ArrayList(); |
34 |
|
| 31 |
|
35 |
public StatisticalAgentTabGroup() { |
| 32 |
static |
36 |
super(); |
| 33 |
{ |
37 |
loadStatAgentInterfaceList(); |
| 34 |
agentTabList.add(new PerfmonTabInterface()); |
38 |
} |
| 35 |
agentTabList.add(new LinuxTabInterface()); |
39 |
|
| 36 |
agentTabList.add(new JBossTabInterface()); |
|
|
| 37 |
agentTabList.add(new JonasTabInterface()); |
| 38 |
agentTabList.add(new ApacheTabInterface()); |
| 39 |
agentTabList.add(new MySQLTabInterface()); |
| 40 |
} |
| 41 |
|
| 42 |
public static AgentInterface getInterface(String UIName) |
40 |
public static AgentInterface getInterface(String UIName) |
| 43 |
{ |
41 |
{ |
| 44 |
for (int i=0; i<agentTabList.size(); i++) |
42 |
for (int i=0; i<agents.length; i++) |
| 45 |
{ |
43 |
{ |
| 46 |
AgentInterface inter = (AgentInterface) agentTabList.get(i); |
44 |
AgentInterface inter = agents[i]; |
| 47 |
if (inter.getUIAgentName().equals(UIName)) |
45 |
if (agentNames[i].equals(UIName)) |
| 48 |
return inter; |
46 |
return inter; |
| 49 |
} |
47 |
} |
| 50 |
return null; |
48 |
return null; |
| 51 |
} |
49 |
} |
|
|
50 |
|
| 51 |
private static AgentInterface[] agents = null; |
| 52 |
private static String[] agentNames = null; |
| 53 |
private static Image[] agentImages = null; |
| 54 |
|
| 55 |
public void loadStatAgentInterfaceList() { |
| 56 |
IExtension[] exts = Platform.getExtensionRegistry().getExtensionPoint(PerfmonPlugin.getID(), PerfmonPlugin.EP_STATISTICAL_AGENTS_GUI).getExtensions(); |
| 57 |
List agentList = new ArrayList(); |
| 58 |
List agentNamesList = new ArrayList(); |
| 59 |
List agentIconsList = new ArrayList(); |
| 60 |
ImageRegistry reg = PerfmonPlugin.getInstance().getImageRegistry(); |
| 61 |
for (int i=0;i<exts.length;++i) { |
| 62 |
IConfigurationElement[] elements = exts[i].getConfigurationElements(); |
| 63 |
for (int j=0;j<elements.length;++j) { |
| 64 |
if ("statAgentInterfaceContribution".equals(elements[j].getName())) { |
| 65 |
//String id = elements[j].getAttribute("id"); |
| 66 |
try { |
| 67 |
String className = elements[j].getAttribute("class"); |
| 68 |
String name = elements[j].getAttribute("name"); |
| 69 |
String iconKey = elements[j].getAttribute("icon"); |
| 70 |
Class classObj = Platform.getBundle(exts[i].getNamespace()).loadClass(className); |
| 71 |
agentList.add(classObj.newInstance()); |
| 72 |
agentNamesList.add(name); |
| 73 |
Image icon = null; |
| 74 |
if (iconKey == null) |
| 75 |
icon = PerfmonPlugin.img.getImage(ImageManager.IMG_PERFMON_SERVER); |
| 76 |
else { |
| 77 |
icon = reg.get(iconKey); |
| 78 |
if (icon == null){ |
| 79 |
ImageDescriptor imageDescriptor = ImageManager.getImageDescriptorFromPlugin(Platform.getBundle(elements[j].getDeclaringExtension().getNamespace()), iconKey); |
| 80 |
if(imageDescriptor != null) |
| 81 |
reg.put(iconKey, imageDescriptor); |
| 82 |
icon = reg.get(iconKey); |
| 83 |
|
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
agentIconsList.add(icon); |
| 88 |
} |
| 89 |
catch (Exception e) { |
| 90 |
PerfmonPlugin.logError(e); |
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
agents = new AgentInterface[agentList.size()]; |
| 97 |
agentList.toArray(agents); |
| 98 |
agentNames = new String[agentList.size()]; |
| 99 |
agentNamesList.toArray(agentNames); |
| 100 |
agentImages = new Image[agentList.size()]; |
| 101 |
agentIconsList.toArray(agentImages); |
| 102 |
} |
| 103 |
|
| 52 |
|
104 |
|
| 53 |
public void createTabs(ILaunchConfigurationDialog dialog, String mode) |
105 |
public void createTabs(ILaunchConfigurationDialog dialog, String mode) |
| 54 |
{ |
106 |
{ |
|
Lines 56-67
Link Here
|
| 56 |
|
108 |
|
| 57 |
tabs.add(new HostTab()); |
109 |
tabs.add(new HostTab()); |
| 58 |
|
110 |
|
| 59 |
AgentsTab agentstab = new AgentsTab(); |
111 |
AgentsTab agentstab = new AgentsTab(this); |
| 60 |
AgentInfoTab agentInfoTab = new AgentInfoTab(); |
112 |
AgentInfoTab agentInfoTab = new AgentInfoTab(); |
| 61 |
for (int i=0; i<agentTabList.size(); i++) |
|
|
| 62 |
{ |
| 63 |
agentstab.addAgent((AgentInterface) agentTabList.get(i)); |
| 64 |
} |
| 65 |
|
113 |
|
| 66 |
tabs.add(agentstab); |
114 |
tabs.add(agentstab); |
| 67 |
tabs.add(agentInfoTab); |
115 |
tabs.add(agentInfoTab); |
|
Lines 77-80
Link Here
|
| 77 |
public void dispose() |
125 |
public void dispose() |
| 78 |
{ |
126 |
{ |
| 79 |
} |
127 |
} |
|
|
128 |
|
| 129 |
|
| 130 |
public String[] getAgentNames() { |
| 131 |
return agentNames; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
public AgentInterface[] getAgents() { |
| 136 |
if (agents == null) loadStatAgentInterfaceList(); |
| 137 |
return agents; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
public Image getAgentImage(int i) { |
| 142 |
return agentImages[i]; |
| 143 |
} |
| 80 |
} |
144 |
} |