[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[ptp-dev] Greg, would you test these patches?
|
Greg,
These are the patches resulting from the merge of NG_20060523 to the
HEAD. I would like you to test these before I commit them.
advTHANKSance,
R^2
--
Randy M. Roberts
rsqrd@xxxxxxxx
work: (505)665-4285
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." -- Benjamin Franklin
Index: src/org/eclipse/ptp/internal/core/ModelManager.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/ModelManager.java,v
retrieving revision 1.98
diff -u -r1.98 ModelManager.java
--- src/org/eclipse/ptp/internal/core/ModelManager.java 2 Jun 2006 02:25:51 -0000 1.98
+++ src/org/eclipse/ptp/internal/core/ModelManager.java 6 Jun 2006 17:46:49 -0000
@@ -44,6 +44,10 @@
import org.eclipse.ptp.core.MonitoringSystemChoices;
import org.eclipse.ptp.core.PTPCorePlugin;
import org.eclipse.ptp.core.PreferenceConstants;
+import org.eclipse.ptp.internal.core.elementcontrols.IPJobControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPUniverseControl;
import org.eclipse.ptp.rtsystem.IControlSystem;
import org.eclipse.ptp.rtsystem.IMonitoringSystem;
import org.eclipse.ptp.rtsystem.IRuntimeListener;
@@ -66,7 +70,7 @@
// protected IPMachine machine = null;
protected IPJob processRoot = null;
- protected IPUniverse universe = null;
+ protected IPUniverseControl universe = null;
//protected boolean isPerspectiveOpen = false;
@@ -424,7 +428,7 @@
if (subMonitor.isCanceled()) {
throw new CoreException(Status.CANCEL_STATUS);
}
- IPProcess proc = new PProcess(job, ne[i]+"_process"+j, "" + j + "", "0", j, IPProcess.STARTING, "", "");
+ IPProcessControl proc = new PProcess(job, ne[i]+"_process"+j, "" + j + "", "0", j, IPProcess.STARTING, "", "");
job.addChild(proc);
subMonitor.worked(1);
}
@@ -616,12 +620,12 @@
IProgressMonitor monitor = new NullProgressMonitor();
- IPJob job = universe.findJobByName(ne);
+ IPJobControl job = (IPJobControl) universe.findJobByName(ne);
/* if it already existed, then destroy it first */
if (job != null) {
- IPProcess[] procs = job.getProcesses();
+ IPProcessControl[] procs = (IPProcessControl[]) job.getProcesses();
for (int i = 0; i < procs.length; i++) {
- IPNode node = procs[i].getNode();
+ IPNodeControl node = (IPNodeControl) procs[i].getNode();
node.removeChild(procs[i]);
}
job.removeChildren();
@@ -650,7 +654,7 @@
}
for (int j = 0; j < ne2.length; j++) {
- IPProcess proc;
+ IPProcessControl proc;
proc = new PProcess(pjob, ne+"_process"+j, "" + j + "", "0", j, IPProcess.STARTING, "", "");
pjob.addChild(proc);
@@ -851,7 +855,7 @@
*/
for (int i = 0; i < numProcesses; i++) {
// System.out.println("process name = "+ne[j]);
- IPProcess proc = new PProcess(job, jobName+"_process"+i, "" + i + "", "0", i, IPProcess.STARTING, "", "");
+ IPProcessControl proc = new PProcess(job, jobName+"_process"+i, "" + i + "", "0", i, IPProcess.STARTING, "", "");
job.addChild(proc);
}
Index: src/org/eclipse/ptp/internal/core/PProcess.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PProcess.java,v
retrieving revision 1.22
diff -u -r1.22 PProcess.java
--- src/org/eclipse/ptp/internal/core/PProcess.java 25 May 2006 18:51:22 -0000 1.22
+++ src/org/eclipse/ptp/internal/core/PProcess.java 6 Jun 2006 17:46:50 -0000
@@ -26,7 +26,6 @@
import org.eclipse.core.runtime.Preferences;
import org.eclipse.ptp.core.AttributeConstants;
import org.eclipse.ptp.core.INodeEvent;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
@@ -36,8 +35,12 @@
import org.eclipse.ptp.core.PTPCorePlugin;
import org.eclipse.ptp.core.PreferenceConstants;
import org.eclipse.ptp.core.ProcessEvent;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPJobControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
-public class PProcess extends Parent implements IPProcess {
+public class PProcess extends Parent implements IPProcessControl {
protected String NAME_TAG = "process ";
private String pid = null;
private String status = null;
@@ -52,9 +55,9 @@
/*
* the node that this process is running on, or was scheduled on / will be, etc
*/
- protected IPNode node;
+ protected IPNodeControl node;
- public PProcess(IPElement element, String name, String key, String pid, int taskId, String status, String exitCode, String signalName) {
+ public PProcess(IPElementControl element, String name, String key, String pid, int taskId, String status, String exitCode, String signalName) {
super(element, name, key, P_PROCESS);
this.pid = pid;
this.setAttribute(AttributeConstants.ATTRIB_TASKID, new Integer(taskId));
@@ -77,10 +80,10 @@
outputDirectory.mkdir();
}
public IPJob getJob() {
- IPElement current = this;
+ IPElementControl current = this;
do {
- if (current instanceof IPJob)
- return (IPJob) current;
+ if (current instanceof IPJobControl)
+ return (IPJobControl) current;
} while ((current = current.getParent()) != null);
return null;
}
@@ -127,7 +130,7 @@
return isTerminated;
}
public void removeProcess() {
- ((IPNode) getParent()).removeChild(this);
+ ((IPNodeControl) getParent()).removeChild(this);
}
public void setTerminated(boolean isTerminated) {
this.isTerminated = isTerminated;
@@ -156,9 +159,9 @@
return (getStatus().startsWith(EXITED) || getStatus().startsWith(ERROR));
}
public void setNode(IPNode node) {
- this.node = node;
+ this.node = (IPNodeControl) node;
if (node != null)
- node.addChild(this);
+ this.node.addChild(this);
}
public IPNode getNode() {
return this.node;
@@ -193,5 +196,16 @@
public String[] getAttributeKeys() {
return this.getAttributeKeys(AttributeConstants.ATTRIB_CLASS_PROCESS);
}
-
+
+ public String getName() {
+ return getElementName();
+ }
+
+ public IPProcess getParentProcess() {
+ return (IPProcess) getParent();
+ }
+
+ public int getNumChildProcesses() {
+ return size();
+ }
}
Index: src/org/eclipse/ptp/internal/core/PElementInfo.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PElementInfo.java,v
retrieving revision 1.7
diff -u -r1.7 PElementInfo.java
--- src/org/eclipse/ptp/internal/core/PElementInfo.java 17 Aug 2005 05:26:23 -0000 1.7
+++ src/org/eclipse/ptp/internal/core/PElementInfo.java 6 Jun 2006 17:46:49 -0000
@@ -22,7 +22,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
/**
*
@@ -30,36 +30,36 @@
public class PElementInfo {
private Map fChildren = null;
- protected IPElement element;
+ protected IPElementControl element;
- public PElementInfo(IPElement element) {
+ public PElementInfo(IPElementControl element) {
this.element = element;
// Array list starts with size = 0
fChildren = new HashMap(0);
}
- public IPElement getElement() {
+ public IPElementControl getElement() {
return element;
}
- public void addChild(IPElement member) {
+ public void addChild(IPElementControl member) {
fChildren.put(member.getIDString(), member);
}
- public void removeChild(IPElement member) {
+ public void removeChild(IPElementControl member) {
fChildren.remove(member.getIDString());
}
- public IPElement findChild(String key) {
+ public IPElementControl findChild(String key) {
if (fChildren.containsKey(key))
- return (IPElement) fChildren.get(key);
+ return (IPElementControl) fChildren.get(key);
return null;
}
- public IPElement[] getChildren() {
+ public IPElementControl[] getChildren() {
synchronized (fChildren) {
- return (IPElement[]) fChildren.values().toArray(
- new IPElement[size()]);
+ return (IPElementControl[]) fChildren.values().toArray(
+ new IPElementControl[size()]);
}
}
@@ -69,7 +69,7 @@
}
}
- public boolean includesChild(IPElement child) {
+ public boolean includesChild(IPElementControl child) {
if (fChildren.containsKey(child.getIDString()))
return true;
return false;
Index: src/org/eclipse/ptp/internal/core/Parent.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/Parent.java,v
retrieving revision 1.6
diff -u -r1.6 Parent.java
--- src/org/eclipse/ptp/internal/core/Parent.java 5 Aug 2005 15:59:48 -0000 1.6
+++ src/org/eclipse/ptp/internal/core/Parent.java 6 Jun 2006 17:46:50 -0000
@@ -22,25 +22,25 @@
import java.util.Collection;
import java.util.List;
-import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
/**
*
*/
public abstract class Parent extends PElement {
- public Parent(IPElement parent, String name, String key, int type) {
+ public Parent(IPElementControl parent, String name, String key, int type) {
super(parent, name, key, type);
}
- public void addChild(IPElement member) {
+ public void addChild(IPElementControl member) {
getElementInfo().addChild(member);
}
- public void removeChild(IPElement member) {
+ public void removeChild(IPElementControl member) {
getElementInfo().removeChild(member);
}
- public IPElement findChild(String key) {
+ public IPElementControl findChild(String key) {
return getElementInfo().findChild(key);
}
@@ -56,22 +56,22 @@
return null;
}
- public IPElement[] getChildren() {
+ public IPElementControl[] getChildren() {
PElementInfo info = getElementInfo();
if (info != null)
return info.getChildren();
- return new IPElement[] {};
+ return new IPElementControl[] {};
}
- public IPElement[] getSortedChildren() {
- IPElement[] elements = getChildren();
+ public IPElementControl[] getSortedChildren() {
+ IPElementControl[] elements = getChildren();
sort(elements);
return elements;
}
public List getChildrenOfType(int type) {
- IPElement[] children = getChildren();
+ IPElementControl[] children = getChildren();
int size = children.length;
ArrayList list = new ArrayList(size);
for (int i = 0; i < size; ++i) {
@@ -88,7 +88,7 @@
}
public boolean isAllStop() {
- IPElement[] elements = getChildren();
+ IPElementControl[] elements = getChildren();
for (int i = 0; i < elements.length; i++) {
if (!elements[i].isAllStop())
return false;
@@ -96,7 +96,7 @@
return true;
}
- private void quickSort(IPElement element[], int low, int high) {
+ private void quickSort(IPElementControl element[], int low, int high) {
int lo = low;
int hi = high;
int mid;
@@ -120,14 +120,14 @@
}
}
- private void swap(IPElement element[], int i, int j) {
- IPElement tempElement;
+ private void swap(IPElementControl element[], int i, int j) {
+ IPElementControl tempElement;
tempElement = element[i];
element[i] = element[j];
element[j] = tempElement;
}
- public void sort(IPElement element[]) {
+ public void sort(IPElementControl element[]) {
quickSort(element, 0, element.length - 1);
}
}
\ No newline at end of file
Index: src/org/eclipse/ptp/internal/core/PMachine.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PMachine.java,v
retrieving revision 1.13
diff -u -r1.13 PMachine.java
--- src/org/eclipse/ptp/internal/core/PMachine.java 25 May 2006 18:51:22 -0000 1.13
+++ src/org/eclipse/ptp/internal/core/PMachine.java 6 Jun 2006 17:46:50 -0000
@@ -24,19 +24,22 @@
import java.util.List;
import org.eclipse.ptp.core.AttributeConstants;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPJob;
-import org.eclipse.ptp.core.IPMachine;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPUniverse;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPMachineControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPUniverseControl;
-public class PMachine extends Parent implements IPMachine {
+public class PMachine extends Parent implements IPMachineControl {
protected String NAME_TAG = "machine ";
protected String arch = "undefined";
- public PMachine(IPUniverse uni, String name, int machineID) {
+ public PMachine(IPUniverseControl uni, String name, int machineID) {
super(uni, name, ""+machineID+"", P_MACHINE);
//System.out.println("Name is " + name + ", key is " + machineID);
//System.out.println("NAME_TAG = " + NAME_TAG + ", toString = "
@@ -54,7 +57,7 @@
}
public IPUniverse getUniverse() {
- IPElement current = this;
+ IPElementControl current = this;
do {
if (current instanceof IPUniverse)
return (IPUniverse) current;
@@ -64,21 +67,21 @@
/* returns an array of the nodes that are comprised by this machine */
public synchronized IPNode[] getNodes() {
- return (IPNode[]) getCollection().toArray(new IPNode[size()]);
+ return (IPNodeControl[]) getCollection().toArray(new IPNodeControl[size()]);
}
/* returns a list of the nodes comprised by this machine - but sorted */
public synchronized IPNode[] getSortedNodes() {
- IPNode[] nodes = getNodes();
+ IPNodeControl[] nodes = (IPNodeControl[]) getNodes();
sort(nodes);
return nodes;
}
/* finds a node using a string identifier - returns null if none found */
public synchronized IPNode findNode(String nodeNumber) {
- IPElement element = findChild(nodeNumber);
+ IPElementControl element = findChild(nodeNumber);
if (element != null)
- return (IPNode) element;
+ return (IPNodeControl) element;
return null;
}
@@ -89,7 +92,7 @@
Object ob = it.next();
if (ob instanceof IPNode) {
IPNode node = (IPNode) ob;
- if (node.getElementName().equals(nname))
+ if (node.getName().equals(nname))
return node;
}
}
@@ -103,11 +106,11 @@
*/
public synchronized IPProcess[] getProcesses() {
List array = new ArrayList(0);
- IPNode[] nodes = getNodes();
+ IPNodeControl[] nodes = (IPNodeControl[]) getNodes();
for (int i = 0; i < nodes.length; i++)
array.addAll(nodes[i].getCollection());
- return (IPProcess[]) array.toArray(new IPProcess[array.size()]);
+ return (IPProcessControl[]) array.toArray(new IPProcessControl[array.size()]);
}
/*
@@ -115,7 +118,7 @@
* span multiple jobs)
*/
public synchronized IPProcess[] getSortedProcesses() {
- IPProcess[] processes = getProcesses();
+ IPProcessControl[] processes = (IPProcessControl[]) getProcesses();
sort(processes);
return processes;
}
@@ -150,7 +153,7 @@
int counter = 0;
IPNode[] nodes = getNodes();
for (int i = 0; i < nodes.length; i++)
- counter += nodes[i].size();
+ counter += nodes[i].getNumProcesses();
return counter;
}
@@ -193,4 +196,11 @@
return this.getAttributeKeys(AttributeConstants.ATTRIB_CLASS_MACHINE);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ptp.core.IPMachine#getName()
+ */
+ public String getName() {
+ return getElementName();
+ }
+
}
Index: src/org/eclipse/ptp/internal/core/PUniverse.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PUniverse.java,v
retrieving revision 1.16
diff -u -r1.16 PUniverse.java
--- src/org/eclipse/ptp/internal/core/PUniverse.java 25 May 2006 17:05:48 -0000 1.16
+++ src/org/eclipse/ptp/internal/core/PUniverse.java 6 Jun 2006 17:46:50 -0000
@@ -18,23 +18,23 @@
*******************************************************************************/
package org.eclipse.ptp.internal.core;
-import java.io.File;
import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.ptp.core.AttributeConstants;
-import org.eclipse.ptp.core.PreferenceConstants;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPMachine;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
-import org.eclipse.ptp.core.IPUniverse;
-import org.eclipse.ptp.core.PTPCorePlugin;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPJobControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPMachineControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPUniverseControl;
-public class PUniverse extends Parent implements IPUniverse {
+public class PUniverse extends Parent implements IPUniverseControl {
protected String NAME_TAG = "universe ";
public PUniverse() {
@@ -62,24 +62,17 @@
while (it.hasNext()) {
Object ob = it.next();
- if (ob instanceof IPMachine)
- m.add((IPMachine) ob);
+ if (ob instanceof IPMachineControl)
+ m.add((IPMachineControl) ob);
}
- /* this wouldnt work, oddly enough so have to do a brute force approach */
- // return (IPMachine[])(m.toArray());
- Object[] o = m.toArray();
- IPMachine[] mac = new IPMachine[o.length];
-
- for (int i = 0; i < o.length; i++) {
- mac[i] = (IPMachine) o[i];
- }
+ IPMachineControl[] mac = (IPMachineControl[]) m.toArray(new IPMachineControl[0]);
return mac;
}
public synchronized IPMachine[] getSortedMachines() {
- IPMachine[] macs = getMachines();
+ IPMachineControl[] macs = (IPMachineControl[]) getMachines();
sort(macs);
return macs;
@@ -92,13 +85,21 @@
Object ob = it.next();
if (ob instanceof IPMachine) {
IPMachine mac = (IPMachine) ob;
- if (mac.getElementName().equals(mname))
+ if (mac.getName().equals(mname))
return mac;
}
}
return null;
}
+ public synchronized IPMachine findMachineById(String machine_id) {
+ IPElementControl element = findChild(machine_id);
+ if (element instanceof IPMachineControl) {
+ return (IPMachineControl) element;
+ }
+ return null;
+ }
+
public synchronized IPNode findNodeByName(String nname) {
Collection col = getCollection();
Iterator it = col.iterator();
@@ -150,21 +151,21 @@
while (it.hasNext()) {
Object ob = it.next();
- if (ob instanceof IPJob)
- m.add((IPJob) ob);
+ if (ob instanceof IPJobControl)
+ m.add((IPJobControl) ob);
}
Object[] o = m.toArray();
- IPJob[] job = new IPJob[o.length];
+ IPJobControl[] job = new IPJobControl[o.length];
for (int i = 0; i < o.length; i++) {
- job[i] = (IPJob) o[i];
+ job[i] = (IPJobControl) o[i];
}
return job;
}
public synchronized IPJob[] getSortedJobs() {
- IPJob[] jobs = getJobs();
+ IPJobControl[] jobs = (IPJobControl[]) getJobs();
sort(jobs);
return jobs;
}
@@ -174,14 +175,22 @@
Iterator it = col.iterator();
while (it.hasNext()) {
Object ob = it.next();
- if (ob instanceof IPJob) {
- IPJob job = (IPJob) ob;
+ if (ob instanceof IPJobControl) {
+ IPJobControl job = (IPJobControl) ob;
if (job.getElementName().equals(jname))
return job;
}
}
return null;
}
+
+ public synchronized IPJob findJobById(String job_id) {
+ IPElementControl element = findChild(job_id);
+ if (element instanceof IPJobControl) {
+ return (IPJobControl) element;
+ }
+ return null;
+ }
public synchronized IPProcess findProcessByName(String pname) {
Collection col = getCollection();
@@ -197,12 +206,13 @@
return null;
}
- public void deleteJob(IPJob job) {
+ public void deleteJob(IPJob jobIn) {
+ IPJobControl job = (IPJobControl) jobIn;
for (Iterator i=job.getCollection().iterator(); i.hasNext();) {
- IPProcess process = (IPProcess)i.next();
+ IPProcessControl process = (IPProcessControl)i.next();
if (process == null)
continue;
- IPNode node = process.getNode();
+ IPNodeControl node = (IPNodeControl) process.getNode();
if (node == null)
continue;
node.removeChild(process);
@@ -210,4 +220,4 @@
job.removeAllProcesses();
removeChild(job);
}
-}
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/internal/core/PJob.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PJob.java,v
retrieving revision 1.19
diff -u -r1.19 PJob.java
--- src/org/eclipse/ptp/internal/core/PJob.java 25 May 2006 18:51:22 -0000 1.19
+++ src/org/eclipse/ptp/internal/core/PJob.java 6 Jun 2006 17:46:49 -0000
@@ -20,19 +20,21 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.ptp.core.AttributeConstants;
-import org.eclipse.ptp.core.IPElement;
-import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPMachine;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPUniverse;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPJobControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPUniverseControl;
-public class PJob extends Parent implements IPJob {
+public class PJob extends Parent implements IPJobControl {
protected String NAME_TAG = "root ";
protected boolean isDebugJob = false;
private ArrayList taskIdMap;
@@ -41,7 +43,7 @@
final public static int STATE_NEW = 5000;
- public PJob(IPUniverse uni, String name, String key, int jobNumber) {
+ public PJob(IPUniverseControl uni, String name, String key, int jobNumber) {
super(uni, name, key, P_JOB);
taskIdMap = new ArrayList();
this.setAttribute(AttributeConstants.ATTRIB_JOBID, new Integer(jobNumber));
@@ -92,7 +94,7 @@
}
public synchronized IPNode[] getSortedNodes() {
- IPNode[] nodes = getNodes();
+ IPNodeControl[] nodes = (IPNodeControl[]) getNodes();
sort(nodes);
return nodes;
}
@@ -106,26 +108,26 @@
}
}
- return (IPNode[]) array.toArray(new IPNode[array.size()]);
+ return (IPNodeControl[]) array.toArray(new IPNodeControl[array.size()]);
}
/*
* returns all the processes in this job, which are the children of the job
*/
public synchronized IPProcess[] getProcesses() {
- return (IPProcess[]) getCollection().toArray(new IPProcess[size()]);
+ return (IPProcessControl[]) getCollection().toArray(new IPProcessControl[size()]);
}
public synchronized IPProcess[] getSortedProcesses() {
- IPProcess[] processes = getProcesses();
+ IPProcessControl[] processes = (IPProcessControl[]) getProcesses();
sort(processes);
return processes;
}
public synchronized IPProcess findProcess(String processNumber) {
- IPElement element = findChild(processNumber);
+ IPElementControl element = findChild(processNumber);
if (element != null)
- return (IPProcess) element;
+ return (IPProcessControl) element;
return null;
}
@@ -134,8 +136,8 @@
Iterator it = col.iterator();
while (it.hasNext()) {
Object ob = it.next();
- if (ob instanceof IPProcess) {
- IPProcess proc = (IPProcess) ob;
+ if (ob instanceof IPProcessControl) {
+ IPProcessControl proc = (IPProcessControl) ob;
if (proc.getElementName().equals(pname))
return proc;
}
@@ -164,7 +166,7 @@
}
public IPUniverse getUniverse() {
- IPElement current = this;
+ IPElementControl current = this;
do {
if (current instanceof IPUniverse)
return (IPUniverse) current;
@@ -172,10 +174,10 @@
return null;
}
- public void addChild(IPElement member) {
+ public void addChild(IPElementControl member) {
super.addChild(member);
- if (member instanceof IPProcess) {
- IPProcess p = (IPProcess) member;
+ if (member instanceof IPProcessControl) {
+ IPProcessControl p = (IPProcessControl) member;
taskIdMap.add(p.getTaskId(), "" + p.getID() + "");
}
}
@@ -200,4 +202,7 @@
return this.getAttributeKeys(AttributeConstants.ATTRIB_CLASS_JOB);
}
+ public String getName() {
+ return getElementName();
+ }
}
Index: src/org/eclipse/ptp/internal/core/PElement.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PElement.java,v
retrieving revision 1.16
diff -u -r1.16 PElement.java
--- src/org/eclipse/ptp/internal/core/PElement.java 25 May 2006 18:51:22 -0000 1.16
+++ src/org/eclipse/ptp/internal/core/PElement.java 6 Jun 2006 17:46:49 -0000
@@ -18,15 +18,15 @@
*******************************************************************************/
package org.eclipse.ptp.internal.core;
-import java.util.ArrayList;
import java.util.HashMap;
+
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.ptp.core.AttributeConstants;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.PTPCorePlugin;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
import org.eclipse.search.ui.ISearchPageScoreComputer;
-public abstract class PElement extends PlatformObject implements IPElement, Comparable {
+public abstract class PElement extends PlatformObject implements IPElementControl, Comparable {
protected HashMap[] attribClass = null;
protected HashMap elementAttribs = null;
@@ -34,7 +34,7 @@
private PElementInfo elementInfo = null;
- protected PElement(IPElement parent, String name, String key, int type) {
+ protected PElement(IPElementControl parent, String name, String key, int type) {
attribClass = new HashMap[AttributeConstants.NUM_ATTRIB_CLASSES];
elementAttribs = new HashMap();
ID = PTPCorePlugin.getDefault().getNewID();
@@ -102,15 +102,15 @@
/**
* @return Returns the Parent.
*/
- public IPElement getParent() {
- return (IPElement)elementAttribs.get(AttributeConstants.ATTRIB_PARENT);
+ public IPElementControl getParent() {
+ return (IPElementControl)elementAttribs.get(AttributeConstants.ATTRIB_PARENT);
}
/**
* @param parent
* The Parent to set.
*/
- public void setParent(IPElement parent) {
+ public void setParent(IPElementControl parent) {
elementAttribs.put(AttributeConstants.ATTRIB_PARENT, parent);
}
@@ -140,9 +140,9 @@
}
public int compareTo(Object obj) {
- if (obj instanceof IPElement) {
+ if (obj instanceof IPElementControl) {
int my_rank = getID();
- int his_rank = ((IPElement) obj).getID();
+ int his_rank = ((IPElementControl) obj).getID();
if (my_rank < his_rank)
return -1;
if (my_rank == his_rank)
@@ -158,7 +158,7 @@
//if (!CoreUtils.PTP_SEARCHPAGE_ID.equals(pageId))
//return ISearchPageScoreComputer.UNKNOWN;
- if (element instanceof IPElement)
+ if (element instanceof IPElementControl)
return 90;
return ISearchPageScoreComputer.LOWEST;
Index: src/org/eclipse/ptp/internal/core/PNode.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/internal/core/PNode.java,v
retrieving revision 1.18
diff -u -r1.18 PNode.java
--- src/org/eclipse/ptp/internal/core/PNode.java 25 May 2006 18:51:22 -0000 1.18
+++ src/org/eclipse/ptp/internal/core/PNode.java 6 Jun 2006 17:46:50 -0000
@@ -21,29 +21,31 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
+
import org.eclipse.ptp.core.AttributeConstants;
import org.eclipse.ptp.core.INodeEvent;
import org.eclipse.ptp.core.INodeListener;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPMachine;
-import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPMachineControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
-public class PNode extends Parent implements IPNode {
+public class PNode extends Parent implements IPNodeControl {
protected String NAME_TAG = "node ";
protected List listeners = new ArrayList();
- public PNode(IPElement mac, String name, String key, int nodeNumber) {
+ public PNode(IPElementControl mac, String name, String key, int nodeNumber) {
super(mac, name, key, P_NODE);
this.setAttribute(AttributeConstants.ATTRIB_NODE_NUMBER, new Integer(nodeNumber));
}
public IPMachine getMachine() {
- IPElement current = this;
+ IPElementControl current = this;
do {
- if (current instanceof IPMachine)
- return (IPMachine) current;
+ if (current instanceof IPMachineControl)
+ return (IPMachineControl) current;
} while ((current = current.getParent()) != null);
return null;
}
@@ -55,17 +57,17 @@
return ((Integer) this.getAttribute(AttributeConstants.ATTRIB_NODE_NUMBER)).intValue();
}
public IPProcess[] getProcesses() {
- return (IPProcess[]) getCollection().toArray(new IPProcess[size()]);
+ return (IPProcessControl[]) getCollection().toArray(new IPProcessControl[size()]);
}
public IPProcess[] getSortedProcesses() {
- IPProcess[] processes = getProcesses();
+ IPProcessControl[] processes = (IPProcessControl[]) getProcesses();
sort(processes);
return processes;
}
public IPProcess findProcess(String processNumber) {
- IPElement element = findChild(processNumber);
+ IPElementControl element = findChild(processNumber);
if (element != null)
- return (IPProcess) element;
+ return (IPProcessControl) element;
return null;
}
/*
@@ -108,5 +110,25 @@
public String[] getAttributeKeys() {
return this.getAttributeKeys(AttributeConstants.ATTRIB_CLASS_NODE);
}
-
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ptp.core.IPNode#getName()
+ */
+ public String getName() {
+ return getElementName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ptp.core.IPNode#getNumProcesses()
+ */
+ public int getNumProcesses() {
+ return size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ptp.core.IPNode#hasChildProcesses()
+ */
+ public boolean hasChildProcesses() {
+ return getNumProcesses() > 0;
+ }
}
Index: src/org/eclipse/ptp/rtsystem/ompi/OMPIMonitoringSystem.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/rtsystem/ompi/OMPIMonitoringSystem.java,v
retrieving revision 1.16
diff -u -r1.16 OMPIMonitoringSystem.java
--- src/org/eclipse/ptp/rtsystem/ompi/OMPIMonitoringSystem.java 19 Apr 2006 21:01:05 -0000 1.16
+++ src/org/eclipse/ptp/rtsystem/ompi/OMPIMonitoringSystem.java 6 Jun 2006 17:46:50 -0000
@@ -93,7 +93,7 @@
if(proxyDead) {
throw new CoreException(new Status(IStatus.ERROR, PTPCorePlugin.getUniqueIdentifier(), IStatus.ERROR, "Monitoring system is shut down", null));
}
- System.out.println("OMPIMonitoringSystem: getNodes(" + machine.getElementName() + ") called");
+ System.out.println("OMPIMonitoringSystem: getNodes(" + machine.getName() + ") called");
/* need to check if machineName is a valid machine name */
@@ -119,13 +119,13 @@
/* this is an error, so we'll return 1 empty node */
if(numNodes <= 0) {
String[] ne = new String[1];
- ne[0] = new String(machine.getElementName()+"_node0");
+ ne[0] = new String(machine.getName()+"_node0");
return ne;
}
String[] ne = new String[numNodes];
for(int i=0; i<numNodes; i++) {
- ne[i] = new String(machine.getElementName()+"_node"+i);
+ ne[i] = new String(machine.getName()+"_node"+i);
}
return ne;
@@ -147,7 +147,7 @@
if(proxyDead) {
throw new CoreException(new Status(IStatus.ERROR, PTPCorePlugin.getUniqueIdentifier(), IStatus.ERROR, "Monitoring system is shut down", null));
}
- System.out.println("ORTE Monitoring System: getNodeAttribute(" + node.getElementName() + ", "
+ System.out.println("ORTE Monitoring System: getNodeAttribute(" + node.getName() + ", "
+ attribs + ") called");
IPMachine machine = node.getMachine();
int machID = machine.getMachineNumberInt();
Index: src/org/eclipse/ptp/rtsystem/ompi/OMPIProxyRuntimeClient.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/rtsystem/ompi/OMPIProxyRuntimeClient.java,v
retrieving revision 1.35
diff -u -r1.35 OMPIProxyRuntimeClient.java
--- src/org/eclipse/ptp/rtsystem/ompi/OMPIProxyRuntimeClient.java 28 Apr 2006 18:25:21 -0000 1.35
+++ src/org/eclipse/ptp/rtsystem/ompi/OMPIProxyRuntimeClient.java 6 Jun 2006 17:46:50 -0000
@@ -1,16 +1,11 @@
package org.eclipse.ptp.rtsystem.ompi;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.net.URL;
import java.util.BitSet;
-import java.util.Properties;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.ptp.core.ControlSystemChoices;
import org.eclipse.ptp.core.IModelManager;
Index: src/org/eclipse/ptp/core/IPUniverse.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPUniverse.java,v
retrieving revision 1.13
diff -u -r1.13 IPUniverse.java
--- src/org/eclipse/ptp/core/IPUniverse.java 9 Jan 2006 22:59:12 -0000 1.13
+++ src/org/eclipse/ptp/core/IPUniverse.java 6 Jun 2006 17:46:49 -0000
@@ -29,7 +29,7 @@
* @see IPMachine
* @see IPJob
*/
-public interface IPUniverse extends IPElement {
+public interface IPUniverse /*extends IPElement*/ {
/**
* Returns all the Machines that are visible by this Universe, or null if
* there are none.
@@ -58,6 +58,12 @@
public IPMachine findMachineByName(String mname);
/**
+ * @param machine_id
+ * @return
+ */
+ public IPMachine findMachineById(String machine_id);
+
+ /**
* Returns all the Jobs that are visible by this Universe, or null if there
* are none.
*
@@ -75,6 +81,12 @@
public IPJob[] getSortedJobs();
/**
+ * @param job_id
+ * @return
+ */
+ public IPJob findJobById(String job_id);
+
+ /**
* Given a Job name, returns a Job object if the Job can be found in this
* Universe. Returns null if it cannot be found.
*
Index: src/org/eclipse/ptp/core/IPNode.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPNode.java,v
retrieving revision 1.14
diff -u -r1.14 IPNode.java
--- src/org/eclipse/ptp/core/IPNode.java 25 May 2006 22:03:15 -0000 1.14
+++ src/org/eclipse/ptp/core/IPNode.java 6 Jun 2006 17:46:49 -0000
@@ -31,6 +31,7 @@
* @return All Processes residing on this Node or <code>null</code> if there are none.
*/
public IPProcess[] getProcesses();
+
/**
* Returns a sorted array of all the Processes residing on this Node. May return <code>null</code> if there are none. How the Processes are sorted is left open to the implementer of this interface.
*
@@ -51,6 +52,10 @@
* @return The Process if found, else <code>null</code>
*/
public int getNodeNumberInt();
+ /**
+ * @param processNumber
+ * @return
+ */
public IPProcess findProcess(String processNumber);
/**
* Returns the parent Machine that this Node is contained within.
@@ -67,7 +72,7 @@
public void fireEvent(INodeEvent event);
public void addNodeListener(INodeListener listener);
public void removerNodeListener(INodeListener listener);
-
+
/**
* Searches for an attribute on the Element given a key.
* The resulting attribute Object is returned. The returned may be null if the attribute
@@ -77,7 +82,7 @@
* @return Object of the attribute or null if not found
*/
public Object getAttribute(String key);
-
+
/**
* Sets an attribute given a key and Object.
*
@@ -93,4 +98,28 @@
*/
public String[] getAttributeKeys();
+ /**
+ * @return
+ */
+ public int getNumProcesses();
+
+ /**
+ * @return
+ */
+ public String getName();
+
+ /**
+ * @return
+ */
+ public String getIDString();
+
+ /**
+ * @return
+ */
+ public boolean isAllStop();
+
+ /**
+ * @return
+ */
+ public boolean hasChildProcesses();
}
Index: src/org/eclipse/ptp/core/IModelManager.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IModelManager.java,v
retrieving revision 1.19
diff -u -r1.19 IModelManager.java
--- src/org/eclipse/ptp/core/IModelManager.java 19 Apr 2006 21:01:05 -0000 1.19
+++ src/org/eclipse/ptp/core/IModelManager.java 6 Jun 2006 17:46:49 -0000
@@ -18,17 +18,15 @@
*******************************************************************************/
package org.eclipse.ptp.core;
-import java.io.File;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.ptp.core.IParallelModelListener;
import org.eclipse.ptp.rtsystem.IControlSystem;
import org.eclipse.ptp.rtsystem.IMonitoringSystem;
import org.eclipse.ptp.rtsystem.JobRunConfiguration;
-public interface IModelManager {
+public interface IModelManager extends IModelPresentation {
public static final int STATE_ERROR = -1;
public static final int STATE_RUN = 1;
public static final int STATE_EXIT = 3;
@@ -48,14 +46,8 @@
public int getControlSystemID();
public int getMonitoringSystemID();
//public boolean isParallelPerspectiveOpen();
- public void refreshRuntimeSystems(IProgressMonitor monitor, boolean force) throws CoreException;
- public void refreshRuntimeSystems(int controlSystemID, int monitoringSystemID, IProgressMonitor monitor) throws CoreException;
public void shutdown();
- public IPUniverse getUniverse();
- public void addParallelLaunchListener(IParallelModelListener listener);
- public void removeParallelLaunchListener(IParallelModelListener listener);
public int getCurrentState();
- public void abortJob(String jobName) throws CoreException;
public IPJob run(ILaunch launch, JobRunConfiguration jobRunConfig, IProgressMonitor pm) throws CoreException;
public void setPTPConfiguration(ILaunchConfiguration config);
public ILaunchConfiguration getPTPConfiguration();
Index: src/org/eclipse/ptp/core/IPJob.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPJob.java,v
retrieving revision 1.13
diff -u -r1.13 IPJob.java
--- src/org/eclipse/ptp/core/IPJob.java 25 May 2006 18:51:22 -0000 1.13
+++ src/org/eclipse/ptp/core/IPJob.java 6 Jun 2006 17:46:49 -0000
@@ -141,6 +141,21 @@
public IPUniverse getUniverse();
public IPProcess findProcessByTaskId(int taskId);
+
+ /**
+ * @return
+ */
+ public String getIDString();
+
+ /**
+ * @return
+ */
+ public String getName();
+
+ /**
+ * @return
+ */
+ public boolean isAllStop();
/**
* Searches for an attribute on the Element given a key.
Index: src/org/eclipse/ptp/core/IPMachine.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPMachine.java,v
retrieving revision 1.14
diff -u -r1.14 IPMachine.java
--- src/org/eclipse/ptp/core/IPMachine.java 25 May 2006 18:51:22 -0000 1.14
+++ src/org/eclipse/ptp/core/IPMachine.java 6 Jun 2006 17:46:49 -0000
@@ -146,6 +146,13 @@
public String getArch();
/**
+ * @return
+ */
+ public String getName();
+
+ public String getIDString();
+
+ /**
* Searches for an attribute on the Element given a key.
* The resulting attribute Object is returned. The returned may be null if the attribute
* was not found.
Index: src/org/eclipse/ptp/core/PTPCorePlugin.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/PTPCorePlugin.java,v
retrieving revision 1.17
diff -u -r1.17 PTPCorePlugin.java
--- src/org/eclipse/ptp/core/PTPCorePlugin.java 2 Jun 2006 02:24:50 -0000 1.17
+++ src/org/eclipse/ptp/core/PTPCorePlugin.java 6 Jun 2006 17:46:49 -0000
@@ -20,17 +20,25 @@
import java.io.File;
import java.net.URL;
+import java.util.ArrayList;
import java.util.MissingResourceException;
-import java.util.Properties;
import java.util.ResourceBundle;
+
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ptp.internal.core.ModelManager;
+import org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory;
+import org.eclipse.ptp.rmsystem.IResourceManager;
+import org.eclipse.ptp.rmsystem.IResourceManagerChangedListener;
+import org.eclipse.ptp.rmsystem.IResourceManagerFactory;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
@@ -42,58 +50,63 @@
public class PTPCorePlugin extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.eclipse.ptp.core";
- private IModelManager modelManager = null;
-
// The shared instance.
private static PTPCorePlugin plugin;
- // Resource bundle.
- private ResourceBundle resourceBundle;
-
- private IDGenerator IDGen;
-
- /**
- * The constructor.
- */
- public PTPCorePlugin() {
- super();
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle(PLUGIN_ID
- + ".ParallelPluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- IDGen = new IDGenerator();
+ public static void errorDialog(Shell shell, String title, IStatus s) {
+ errorDialog(shell, title, s.getMessage(), s);
}
- public int getNewID() {
- return IDGen.getNewID();
- }
+ public static void errorDialog(Shell shell, String title, String message, IStatus s) {
+ if (s != null && message != null && message.equals(s.getMessage()))
+ message = null;
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- modelManager = new ModelManager();
+ ErrorDialog.openError(shell, title, message, s);
}
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- modelManager.shutdown();
- super.stop(context);
+ public static void errorDialog(Shell shell, String title, String message, Throwable t) {
+ IStatus status;
+ if (t instanceof CoreException) {
+ status = ((CoreException)t).getStatus();
+ } else {
+ status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, "Error within PTP Core: ", t);
+ log(status);
+ }
+ errorDialog(shell, title, message, status);
}
+ public static void errorDialog(final String title, final String message, final Throwable t) {
+ getDisplay().syncExec(new Runnable() {
+ public void run() {
+ errorDialog(getDisplay().getActiveShell(), title, message, t);
+ }
+ });
+ }
+
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchWindow w = getActiveWorkbenchWindow();
+ if (w != null) {
+ return w.getActivePage();
+ }
+ return null;
+ }
/**
- * @return Returns the modelManager.
+ * Returns the active workbench shell or <code>null</code> if none
+ *
+ * @return the active workbench shell or <code>null</code> if none
*/
- public IModelManager getModelManager() {
- return modelManager;
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
}
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ }
+
/**
* Returns the shared instance.
*/
@@ -101,20 +114,14 @@
return plugin;
}
- public void refreshParallelPluginActions() {
- refreshPluginActions();
- }
-
- public static String getUniqueIdentifier() {
- if (getDefault() == null) {
- // If the default instance is not yet initialized,
- // return a static identifier. This identifier must
- // match the plugin id defined in plugin.xml
- return PLUGIN_ID;
+ public static Display getDisplay() {
+ Display display= Display.getCurrent();
+ if (display == null) {
+ display= Display.getDefault();
}
- return getDefault().getBundle().getSymbolicName();
+ return display;
}
-
+
/**
* Returns the string from the plugin's resource bundle, or 'key' if not
* found.
@@ -128,93 +135,132 @@
}
}
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
+ public static String getUniqueIdentifier() {
+ if (getDefault() == null) {
+ // If the default instance is not yet initialized,
+ // return a static identifier. This identifier must
+ // match the plugin id defined in plugin.xml
+ return PLUGIN_ID;
+ }
+ return getDefault().getBundle().getSymbolicName();
}
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- return getDefault().getWorkbench().getActiveWorkbenchWindow();
+ public static void informationDialog(final String title, final String message) {
+ getDisplay().syncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openInformation(getDisplay().getActiveShell(), title, message);
+ }
+ });
}
- public static IWorkbenchPage getActivePage() {
- IWorkbenchWindow w = getActiveWorkbenchWindow();
- if (w != null) {
- return w.getActivePage();
- }
- return null;
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
}
- /**
- * Returns the active workbench shell or <code>null</code> if none
- *
- * @return the active workbench shell or <code>null</code> if none
- */
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow window = getActiveWorkbenchWindow();
- if (window != null) {
- return window.getShell();
- }
- return null;
- }
public static void log(String msg) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, msg, null));
}
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
+
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, "Internal Error", e));
}
- public static Display getDisplay() {
- Display display= Display.getCurrent();
- if (display == null) {
- display= Display.getDefault();
- }
- return display;
- }
- public static void errorDialog(final String title, final String message, final Throwable t) {
+
+ public static void warningDialog(final String title, final String message) {
getDisplay().syncExec(new Runnable() {
public void run() {
- errorDialog(getDisplay().getActiveShell(), title, message, t);
+ MessageDialog.openWarning(getDisplay().getActiveShell(), title, message);
}
});
}
- public static void errorDialog(Shell shell, String title, String message, Throwable t) {
- IStatus status;
- if (t instanceof CoreException) {
- status = ((CoreException)t).getStatus();
- } else {
- status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, "Error within PTP Core: ", t);
- log(status);
+
+ // Resource bundle.
+ private ResourceBundle resourceBundle;
+
+ private IDGenerator IDGen;
+
+ private IResourceManagerFactory[] resourceManagerFactories;
+ private IResourceManager[] resourceManagers;
+ private IResourceManager currentResourceManager;
+ /**
+ * The constructor.
+ */
+ public PTPCorePlugin() {
+ super();
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle.getBundle(PLUGIN_ID
+ + ".ParallelPluginResources");
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
}
- errorDialog(shell, title, message, status);
+ IDGen = new IDGenerator();
}
- public static void errorDialog(Shell shell, String title, IStatus s) {
- errorDialog(shell, title, s.getMessage(), s);
+ public void addResourceManagerChangedListener(IResourceManagerChangedListener listener) {
+ // TODO
+ }
+ public IResourceManager getCurrentResourceManager() {
+ return currentResourceManager;
}
- public static void errorDialog(Shell shell, String title, String message, IStatus s) {
- if (s != null && message != null && message.equals(s.getMessage()))
- message = null;
-
- ErrorDialog.openError(shell, title, message, s);
+ /**
+ * @return Returns the modelManager.
+ */
+ public IModelPresentation getModelPresentation() {
+ return currentResourceManager.getModelPresentation();
+ }
+
+ public int getNewID() {
+ return IDGen.getNewID();
+ }
+ /**
+ * Returns the plugin's resource bundle,
+ */
+ public ResourceBundle getResourceBundle() {
+ return resourceBundle;
}
- public static void warningDialog(final String title, final String message) {
- getDisplay().syncExec(new Runnable() {
- public void run() {
- MessageDialog.openWarning(getDisplay().getActiveShell(), title, message);
+ public IResourceManagerFactory[] getResourceManagerFactories()
+ {
+ ArrayList configList = new ArrayList();
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint("org.eclipse.ptp.core.resourcemanager");
+ final IExtension[] extensions = extensionPoint.getExtensions();
+
+ for (int iext = 0; iext < extensions.length; ++iext) {
+ final IExtension ext = extensions[iext];
+
+ IConfigurationElement[] elements = ext.getConfigurationElements();
+
+ for (int i=0; i< elements.length; i++)
+ {
+ IConfigurationElement ce = elements[i];
+ try {
+ AbstractResourceManagerFactory factory = (AbstractResourceManagerFactory) ce.createExecutableExtension("class");
+ factory.setName(ce.getAttribute("name"));
+ factory.setId(ce.getAttribute("id"));
+ factory.setSupportLocal(Boolean.valueOf(ce.getAttribute("supportLocal")).booleanValue());
+ factory.setSupportRemote(Boolean.valueOf(ce.getAttribute("supportRemote")).booleanValue());
+ factory.setNeedPort(Boolean.valueOf(ce.getAttribute("needPort")).booleanValue());
+ configList.add(factory);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
- });
+ }
+ return (IResourceManagerFactory[]) configList.toArray(new IResourceManagerFactory[configList.size()]);
}
- public static void informationDialog(final String title, final String message) {
- getDisplay().syncExec(new Runnable() {
- public void run() {
- MessageDialog.openInformation(getDisplay().getActiveShell(), title, message);
- }
- });
+ public IResourceManagerFactory getResourceManagerFactory(String id)
+ {
+ IResourceManagerFactory[] factories = getResourceManagerFactories();
+ for (int i=0; i<factories.length; i++)
+ {
+ if (factories[i].getId().equals(id)) return factories[i];
+ }
+
+ return null;
+ }
+ public IResourceManager[] getResourceManagers() {
+ return resourceManagers;
}
public String locateFragmentFile(String fragment, String file) {
@@ -235,7 +281,7 @@
Bundle frag = frags[i];
URL path = frag.getEntry("/");
try {
- URL local_path = Platform.asLocalURL(path);
+ URL local_path = FileLocator.toFileURL(path);
String str_path = local_path.getPath();
System.out.println("Testing fragment "+(i+1)+" with this OS/arch - path: '"+str_path+"'");
@@ -277,4 +323,58 @@
/* guess we never found it.... */
return null;
}
+
+ public void refreshParallelPluginActions() {
+ refreshPluginActions();
+ }
+
+ public void removeResourceManagerChangedListener(IResourceManagerChangedListener listener) {
+ // TODO
+ }
+
+ public void setCurrentResourceManager(IResourceManager rmManager) {
+ try {
+ currentResourceManager.stop();
+ } catch (CoreException e) {
+ log(e.getMessage());
+ }
+
+ currentResourceManager = rmManager;
+ try {
+ currentResourceManager.start();
+ } catch (CoreException e) {
+ log(e.getMessage());
+ }
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ resourceManagerFactories = getResourceManagerFactories();
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ stopResourceManagers();
+ super.stop(context);
+ }
+
+ /**
+ * stops all of the resource managers.
+ *
+ * @throws CoreException
+ */
+ private void stopResourceManagers() throws CoreException {
+ for (int i = 0; i<resourceManagers.length; ++i) {
+ resourceManagers[i].stop();
+ }
+ }
+
+ public IModelManager getModelManager() {
+ return getCurrentResourceManager().getModelManager();
+ }
}
\ No newline at end of file
Index: src/org/eclipse/ptp/core/IPProcess.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPProcess.java,v
retrieving revision 1.10
diff -u -r1.10 IPProcess.java
--- src/org/eclipse/ptp/core/IPProcess.java 25 May 2006 18:51:22 -0000 1.10
+++ src/org/eclipse/ptp/core/IPProcess.java 6 Jun 2006 17:46:49 -0000
@@ -76,5 +76,24 @@
* @return A string array containing the keys
*/
public String[] getAttributeKeys();
+
+ /**
+ * @return
+ */
+ public String getName();
+
+ /**
+ * @return
+ */
+ public IPProcess getParentProcess();
+
+ /**
+ * @return
+ */
+ public int getNumChildProcesses();
+ /**
+ * @return
+ */
+ public boolean isAllStop();
}
Index: src/org/eclipse/ptp/core/AttributeConstants.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/AttributeConstants.java,v
retrieving revision 1.10
diff -u -r1.10 AttributeConstants.java
--- src/org/eclipse/ptp/core/AttributeConstants.java 30 May 2006 16:44:42 -0000 1.10
+++ src/org/eclipse/ptp/core/AttributeConstants.java 6 Jun 2006 17:46:49 -0000
@@ -40,17 +40,17 @@
public static final String ATTRIB_ISREGISTERED = "ATTRIB_ISREGISTERED";
/* node attributes */
- public static final String ATTRIB_NODE_NAME = "ATTRIB_NODE_NAME";
- public static final String ATTRIB_NODE_NUMBER = "ATTRIB_NODE_NUMBER";
- public static final String ATTRIB_NODE_STATE = "ATTRIB_NODE_STATE";
- public static final String ATTRIB_NODE_GROUP = "ATTRIB_NODE_GROUP";
- public static final String ATTRIB_NODE_USER = "ATTRIB_NODE_USER";
- public static final String ATTRIB_NODE_MODE = "ATTRIB_NODE_MODE";
+ public static final String ATTRIB_NODE_NAME = "Name";
+ public static final String ATTRIB_NODE_NUMBER = "Number";
+ public static final String ATTRIB_NODE_STATE = "State";
+ public static final String ATTRIB_NODE_GROUP = "Group";
+ public static final String ATTRIB_NODE_USER = "User";
+ public static final String ATTRIB_NODE_MODE = "Mode";
/* process attributes */
- public static final String ATTRIB_PROCESS_PID = "ATTRIB_PROCESS_PID";
- public static final String ATTRIB_PROCESS_EXIT_CODE = "ATTRIB_PROCESS_EXIT_CODE";
- public static final String ATTRIB_PROCESS_STATUS = "ATTRIB_PROCESS_STATUS";
- public static final String ATTRIB_PROCESS_SIGNAL = "ATTRIB_PROCESS_SIGNAL";
- public static final String ATTRIB_PROCESS_NODE_NAME = "ATTRIB_PROCESS_NODE_NAME";
-}
+ public static final String ATTRIB_PROCESS_PID = "PID";
+ public static final String ATTRIB_PROCESS_EXIT_CODE = "Exit Code";
+ public static final String ATTRIB_PROCESS_STATUS = "Status";
+ public static final String ATTRIB_PROCESS_SIGNAL = "Signal";
+ public static final String ATTRIB_PROCESS_NODE_NAME = "Node Name";
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/core/IPElement.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/core/IPElement.java,v
retrieving revision 1.14
diff -u -r1.14 IPElement.java
--- src/org/eclipse/ptp/core/IPElement.java 25 May 2006 18:51:22 -0000 1.14
+++ src/org/eclipse/ptp/core/IPElement.java 6 Jun 2006 17:46:49 -0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 The Regents of the University of California.
+ * Copyright (c) 2006 The Regents of the University of California.
* This material was produced under U.S. Government contract W-7405-ENG-36
* for Los Alamos National Laboratory, which is operated by the University
* of California for the U.S. Department of Energy. The U.S. Government has
@@ -18,182 +18,7 @@
*******************************************************************************/
package org.eclipse.ptp.core;
-import java.util.Collection;
-import org.eclipse.search.ui.ISearchPageScoreComputer;
-
-/**
- * This is the generic parallel element class which all the specific classes
- * extend, like Machine, Node, Job, etc. This base class maintains a name for
- * each entity that extends it and handles parent/child operations. A key is
- * also maintained for each parallel element which is used in storing these
- * elements in hash tables and such.
- *
- * @author Nathan DeBardeleben
- */
-public interface IPElement extends ISearchPageScoreComputer {
- // public String NAME_TAG = "";
-
- /**
- * Element tag for an error / undefined type
- */
- public static final int P_TYPE_ERROR = -1;
-
- /**
- * Element tag for Universe Elements
- */
- public static final int P_UNIVERSE = 10;
-
- /**
- * Element tag for Machine Elements
- */
- public static final int P_MACHINE = 11;
-
- /**
- * Element tag for Node Elements
- */
- public static final int P_NODE = 12;
-
- /**
- * Element tag for Job Elements
- */
- public static final int P_JOB = 13;
-
- /**
- * Element tag for Process Elements
- */
- public static final int P_PROCESS = 14;
-
- /**
- * Searches for an attribute on the Element given an attribute class and key.
- * The resulting attribute Object is returned. The returned may be null if the attribute
- * was not found.
- *
- * @param attr_class Class of attribute
- * @param key String key of the attribute to look for
- * @return Object of the attribute or null if not found
- */
- public Object getAttribute(int attr_class, String key);
-
- /**
- * Sets an attribute given a class, key and Object.
- *
- * @param attr_class Class of the attribute
- * @param key String key of the attribute
- * @param Object of the attribute
- */
- public void setAttribute(int attr_class, String key, Object o);
-
- /**
- * Get all the keys of all attributes in a particular class.
- *
- * @param attr_class Class of attribute keys
- * @return A string array containing the keys
- */
- public String[] getAttributeKeys(int attr_class);
-
- /**
- * Returns a name for this Element so it can be distinguished from other
- * Elements as well as printed out easily.
- *
- * @return This Element's name
- */
- public String getElementName();
-
- /**
- * Returns the element type (such as P_UNIVERSE, P_MACHINE, etc.) for this
- * Element. This type is usually set through the constructor of the
- * implementing class of this interface.
- *
- * @return The element type of this Element which can be compared with the
- * public statics of this interface.
- * @see P_UNIVERSE
- * @see P_MACHINE
- * @see P_NODE
- * @see P_JOB
- * @see P_PROCESS
- */
- public int getElementType();
-
- /**
- * Returns an Element array of the children of this Element. If this Element
- * does not yet have any children, then null is returned.
- *
- * @return An Element array of the children of this Element, null if there
- * are none
- */
- public IPElement[] getChildren();
-
- /**
- * If this Element has a parent then this method returns it, else it returns
- * null.
- *
- * @return The parent Element of this Element, null if there is none
- */
- public IPElement getParent();
-
- /*
- * public IPUniverse getPUniverse(); public IPMachine getPMachine(); public
- * IPJob getPRoot();
- */
-
- /**
- * Adds an Element as a child of this Element creating a parent-child
- * relationship between the two.
- *
- * @param member
- * The Element to add as a child to this Element
- */
- public void addChild(IPElement member);
-
- /**
- * Locate a child Element of this Element and remove it as a child, breaking
- * the parent-child relationship between the two. If the proposed child
- * member is not found as a child of this Element then no action is taken.
- *
- * @param member
- * The Element to remove as a child of this Element
- */
- public void removeChild(IPElement member);
-
- /**
- * Remove all children Elements from this Element.
- */
- public void removeChildren();
-
- /**
- * Finds an child Element of this Element by searching by the name of the
- * Element. If found, the Element object is returned, else null is returned.
- *
- * @param elementName
- * The name of the child Element to find
- * @return The Element object if found, else null
- */
- public IPElement findChild(String elementName);
-
- /**
- * Returns the number of children of this Element.
- *
- * @return The number of children of this Element
- */
- public int size();
-
- /**
- * This method really doesn't make sense anymore, it needs to be fixed. <br>
- * TODO: <i>SLATED FOR REMOVAL</i>
- *
- * @return I have no idea, T/F obviously though :)
- */
- public boolean isAllStop();
-
- /**
- * Returns a sorted Element array of this Element's children. Left open to
- * the implementer of this interface as to how the sorting is done and what
- * the sorting is performed on.
- *
- * @return Sorted Element array of the children of this Element, null if
- * there are none
- */
- public IPElement[] getSortedChildren();
+public interface IPElement {
/**
* Returns an int version of the ID for this Element
@@ -201,7 +26,7 @@
* @return The ID for this Element
*/
public int getID();
-
+
/**
* Returns a String version of the ID for this Element
*
@@ -210,17 +35,11 @@
public String getIDString();
/**
- * Returns the children of this Element as a Collection or null if there are
- * no children.
+ * Returns a name for this Element so it can be distinguished from other
+ * Elements as well as printed out easily.
*
- * @return The children of this Element or null if there are none
+ * @return This Element's name
*/
- public Collection getCollection();
+ public String getElementName();
- /**
- * Returns true if this Element has children Elements, else returns false.
- *
- * @return True if this Element has children Elements, else false
- */
- public boolean hasChildren();
}
Index: plugin.xml
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/plugin.xml,v
retrieving revision 1.6
diff -u -r1.6 plugin.xml
--- plugin.xml 7 Apr 2005 16:30:01 -0000 1.6
+++ plugin.xml 6 Jun 2006 17:46:49 -0000
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
+ <extension-point id="resourcemanager" name="Resource Manager" schema="schema/resourcemanager.exsd"/>
</plugin>
Index: src/org/eclipse/ptp/rtsystem/simulation/SimulationControlSystem.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/rtsystem/simulation/SimulationControlSystem.java,v
retrieving revision 1.19
diff -u -r1.19 SimulationControlSystem.java
--- src/org/eclipse/ptp/rtsystem/simulation/SimulationControlSystem.java 19 Apr 2006 21:01:05 -0000 1.19
+++ src/org/eclipse/ptp/rtsystem/simulation/SimulationControlSystem.java 6 Jun 2006 17:46:50 -0000
@@ -29,6 +29,8 @@
import org.eclipse.ptp.core.AttributeConstants;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPProcess;
+import org.eclipse.ptp.internal.core.elementcontrols.IPJobControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPProcessControl;
import org.eclipse.ptp.rtsystem.IControlSystem;
import org.eclipse.ptp.rtsystem.IRuntimeListener;
import org.eclipse.ptp.rtsystem.JobRunConfiguration;
@@ -150,10 +152,11 @@
return numJobs;
}
- public void terminateJob(IPJob jobName) {
- String tname = (String)jobName.getAttribute(AttributeConstants.ATTRIB_NAME);
+ public void terminateJob(IPJob jobIn) {
+ IPJobControl job = (IPJobControl) jobIn;
+ String tname = (String)job.getAttribute(AttributeConstants.ATTRIB_NAME);
- IPProcess[] ps = jobName.getProcesses();
+ IPProcess[] ps = job.getProcesses();
for(int i=0; i<ps.length; i++) {
ps[i].setTerminated(true);
if(ps[i] instanceof SimProcess) {
@@ -291,8 +294,10 @@
return allvals;
}
- public String[] getProcessAttributes(IPProcess proc, String[] attribs)
+ public String[] getProcessAttributes(IPProcess procIn, String[] attribs)
{
+ IPProcessControl proc = (IPProcessControl) procIn;
+
String procName = proc.getElementName();
String[] retstr = new String[attribs.length];
Index: src/org/eclipse/ptp/rtsystem/simulation/SimProcess.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/rtsystem/simulation/SimProcess.java,v
retrieving revision 1.17
diff -u -r1.17 SimProcess.java
--- src/org/eclipse/ptp/rtsystem/simulation/SimProcess.java 25 May 2006 18:51:22 -0000 1.17
+++ src/org/eclipse/ptp/rtsystem/simulation/SimProcess.java 6 Jun 2006 17:46:50 -0000
@@ -30,7 +30,6 @@
import org.eclipse.core.runtime.Preferences;
import org.eclipse.ptp.core.AttributeConstants;
import org.eclipse.ptp.core.INodeEvent;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
@@ -43,9 +42,11 @@
import org.eclipse.ptp.internal.core.OutputTextFile;
import org.eclipse.ptp.internal.core.PElement;
import org.eclipse.ptp.internal.core.PElementInfo;
+import org.eclipse.ptp.internal.core.elementcontrols.IPElementControl;
+import org.eclipse.ptp.internal.core.elementcontrols.IPNodeControl;
import org.eclipse.search.ui.ISearchPageScoreComputer;
-public class SimProcess extends Process implements IPProcess, IPElement, Comparable {
+public class SimProcess extends Process implements IPProcess, IPElementControl, Comparable {
InputStream err;
InputStream in;
OutputStream out;
@@ -68,12 +69,12 @@
/*
* the node that this process is running on, or was scheduled on / will be, etc
*/
- protected IPNode node;
+ protected IPNodeControl node;
Thread procThread;
final int numThreads = 1;
- public SimProcess(IPElement element, String name, String key, String pid, int taskId, String status, String exitCode, String signalName) {
+ public SimProcess(IPElementControl element, String name, String key, String pid, int taskId, String status, String exitCode, String signalName) {
attribs = new HashMap();
ID = PTPCorePlugin.getDefault().getNewID();
attribs.put(AttributeConstants.ATTRIB_PARENT, element);
@@ -155,7 +156,7 @@
outputDirectory.mkdir();
}
public IPJob getJob() {
- IPElement current = this;
+ IPElementControl current = this;
do {
if (current instanceof IPJob)
return (IPJob) current;
@@ -211,7 +212,7 @@
return isTerminated;
}
public void removeProcess() {
- ((IPNode) getParent()).removeChild(this);
+ ((IPNodeControl) getParent()).removeChild(this);
}
public void setTerminated(boolean isTerminated) {
this.isTerminated = isTerminated;
@@ -248,9 +249,9 @@
return getStatus().startsWith(EXITED);
}
public void setNode(IPNode node) {
- this.node = node;
+ this.node = (IPNodeControl) node;
if (node != null)
- node.addChild(this);
+ this.node.addChild(this);
}
public IPNode getNode() {
return this.node;
@@ -258,13 +259,13 @@
public int getTaskId() {
return ((Integer) attribs.get(AttributeConstants.ATTRIB_TASKID)).intValue();
}
- public void addChild(IPElement member) {
+ public void addChild(IPElementControl member) {
getElementInfo().addChild(member);
}
- public void removeChild(IPElement member) {
+ public void removeChild(IPElementControl member) {
getElementInfo().removeChild(member);
}
- public IPElement findChild(String key) {
+ public IPElementControl findChild(String key) {
return getElementInfo().findChild(key);
}
public void removeChildren() {
@@ -276,19 +277,19 @@
return info.getCollection();
return null;
}
- public IPElement[] getChildren() {
+ public IPElementControl[] getChildren() {
PElementInfo info = getElementInfo();
if (info != null)
return info.getChildren();
- return new IPElement[] {};
+ return new IPElementControl[] {};
}
- public IPElement[] getSortedChildren() {
- IPElement[] elements = getChildren();
+ public IPElementControl[] getSortedChildren() {
+ IPElementControl[] elements = getChildren();
sort(elements);
return elements;
}
public List getChildrenOfType(int type) {
- IPElement[] children = getChildren();
+ IPElementControl[] children = getChildren();
int size = children.length;
ArrayList list = new ArrayList(size);
for (int i = 0; i < size; ++i) {
@@ -302,7 +303,7 @@
public boolean hasChildren() {
return getElementInfo().hasChildren();
}
- private void quickSort(IPElement element[], int low, int high) {
+ private void quickSort(IPElementControl element[], int low, int high) {
int lo = low;
int hi = high;
int mid;
@@ -325,13 +326,13 @@
quickSort(element, lo, high);
}
}
- private void swap(IPElement element[], int i, int j) {
- IPElement tempElement;
+ private void swap(IPElementControl element[], int i, int j) {
+ IPElementControl tempElement;
tempElement = element[i];
element[i] = element[j];
element[j] = tempElement;
}
- public void sort(IPElement element[]) {
+ public void sort(IPElementControl element[]) {
quickSort(element, 0, element.length - 1);
}
protected PElementInfo getElementInfo() {
@@ -371,14 +372,14 @@
/**
* @return Returns the Parent.
*/
- public IPElement getParent() {
- return (IPElement) attribs.get(AttributeConstants.ATTRIB_PARENT);
+ public IPElementControl getParent() {
+ return (IPElementControl) attribs.get(AttributeConstants.ATTRIB_PARENT);
}
/**
* @param parent
* The Parent to set.
*/
- public void setParent(IPElement parent) {
+ public void setParent(IPElementControl parent) {
attribs.put(AttributeConstants.ATTRIB_PARENT, parent);
}
/**
@@ -405,9 +406,9 @@
return getElementInfo().size();
}
public int compareTo(Object obj) {
- if (obj instanceof IPElement) {
+ if (obj instanceof IPElementControl) {
int my_rank = getID();
- int his_rank = ((IPElement) obj).getID();
+ int his_rank = ((IPElementControl) obj).getID();
if (my_rank < his_rank)
return -1;
if (my_rank == his_rank)
@@ -421,7 +422,7 @@
//FIXME
//if (!CoreUtils.PTP_SEARCHPAGE_ID.equals(pageId))
//return ISearchPageScoreComputer.UNKNOWN;
- if (element instanceof IPElement)
+ if (element instanceof IPElementControl)
return 90;
return ISearchPageScoreComputer.LOWEST;
}
@@ -484,4 +485,15 @@
public void setAttribute(int attr, String key, Object o) {
attribs.put(key, o);
}
-}
+ public String getName() {
+ return getElementName();
+ }
+
+ public IPProcess getParentProcess() {
+ return (IPProcess) getParent();
+ }
+
+ public int getNumChildProcesses() {
+ return size();
+ }
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/rtsystem/simulation/SimulationMonitoringSystem.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/src/org/eclipse/ptp/rtsystem/simulation/SimulationMonitoringSystem.java,v
retrieving revision 1.21
diff -u -r1.21 SimulationMonitoringSystem.java
--- src/org/eclipse/ptp/rtsystem/simulation/SimulationMonitoringSystem.java 19 Feb 2006 18:02:44 -0000 1.21
+++ src/org/eclipse/ptp/rtsystem/simulation/SimulationMonitoringSystem.java 6 Jun 2006 17:46:50 -0000
@@ -243,7 +243,7 @@
/* get the nodes pertaining to a certain machine */
public String[] getNodes(IPMachine machine) {
- String machineName = machine.getElementName();
+ String machineName = machine.getName();
/* find this machineName in the map - if it's there */
if (!nodeMap.containsKey(machineName))
return null;
@@ -270,7 +270,7 @@
}
public String[] getNodeAttributes(IPNode node, String[] attribs) {
- String nodeName = node.getElementName();
+ String nodeName = node.getName();
String[] retstr = new String[attribs.length];
for(int i=0; i<attribs.length; i++) {
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.core/META-INF/MANIFEST.MF,v
retrieving revision 1.9
diff -u -r1.9 MANIFEST.MF
--- META-INF/MANIFEST.MF 5 Oct 2005 03:48:55 -0000 1.9
+++ META-INF/MANIFEST.MF 6 Jun 2006 17:46:49 -0000
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PTP Core Plug-in
-Bundle-SymbolicName: org.eclipse.ptp.core; singleton:=true
+Bundle-SymbolicName: org.eclipse.ptp.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.ptp.core.PTPCorePlugin
Bundle-Vendor: Eclipse.org
@@ -12,6 +12,7 @@
org.eclipse.ptp.core.util,
org.eclipse.ptp.debug,
org.eclipse.ptp.internal.core,
+ org.eclipse.ptp.rmsystem,
org.eclipse.ptp.rtsystem,
org.eclipse.ptp.rtsystem.simulation
Require-Bundle: org.eclipse.ui,
@@ -27,4 +28,4 @@
org.eclipse.jface.text,
org.eclipse.ui.forms,
org.eclipse.cdt.debug.core
-Eclipse-AutoStart: true
+Eclipse-LazyStart: true
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPJobControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPJobControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPJobControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPJobControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import org.eclipse.ptp.core.IPJob;
+
+public interface IPJobControl extends IPElementControl, IPJob {
+
+}
Index: src/org/eclipse/ptp/rmsystem/ResourceManagerStore.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/ResourceManagerStore.java
diff -N src/org/eclipse/ptp/rmsystem/ResourceManagerStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/ResourceManagerStore.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ptp.rmsystem;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.jface.text.Assert;
+
+/**
+ * A collection of resource managers.
+ */
+public class ResourceManagerStore {
+ /** The stored resource managers. */
+ private final List fResourceManagers= new ArrayList();
+ /** The preference store. */
+ private IPreferenceStore fPreferenceStore;
+ /**
+ * The key into <code>fPreferenceStore</code> the value of which holds custom resource managers
+ * encoded as XML.
+ */
+ private String fKey;
+
+ /**
+ * Set to <code>true</code> if property change events should be ignored (e.g. during writing
+ * to the preference store).
+ *
+ */
+ private boolean fIgnorePreferenceStoreChanges= false;
+
+ /**
+ * The property listener, if any is registered, <code>null</code> otherwise.
+ */
+ private IPropertyChangeListener fPropertyListener;
+
+
+ /**
+ * Creates a new resource manager store.
+ *
+ * @param store the preference store in which to store custom resource managers
+ * under <code>key</code>
+ * @param key the key into <code>store</code> where to store custom
+ * resource managers
+ */
+ public ResourceManagerStore(IPreferenceStore store, String key) {
+ Assert.isNotNull(store);
+ Assert.isNotNull(key);
+ fPreferenceStore= store;
+ fKey= key;
+ }
+
+ /**
+ * Loads the resource managers from contributions and preferences.
+ *
+ * @throws IOException if loading fails.
+ */
+ public void load() throws IOException {
+ fResourceManagers.clear();
+ loadResourceManagers();
+ }
+
+ /**
+ * Starts listening for property changes on the preference store. If the configured preference
+ * key changes, the resource manager store is {@link #load() reloaded}. Call
+ * {@link #stopListeningForPreferenceChanges()} to remove any listener and stop the
+ * auto-updating behavior.
+ *
+ */
+ public final void startListeningForPreferenceChanges() {
+ if (fPropertyListener == null) {
+ fPropertyListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ /*
+ * Don't load if we are in the process of saving ourselves. We are in sync anyway after the
+ * save operation, and clients may trigger reloading by listening to preference store
+ * updates.
+ */
+ if (!fIgnorePreferenceStoreChanges && fKey.equals(event.getProperty()))
+ try {
+ load();
+ } catch (IOException x) {
+ handleException(x);
+ }
+ }
+ };
+ fPreferenceStore.addPropertyChangeListener(fPropertyListener);
+ }
+
+ }
+
+ /**
+ * Stops the auto-updating behavior started by calling
+ * {@link #startListeningForPreferenceChanges()}.
+ *
+ */
+ public final void stopListeningForPreferenceChanges() {
+ if (fPropertyListener != null) {
+ fPreferenceStore.removePropertyChangeListener(fPropertyListener);
+ fPropertyListener= null;
+ }
+ }
+
+ /**
+ * Handles an {@link IOException} thrown during reloading the preferences due to a preference
+ * store update. The default is to write to stderr.
+ *
+ * @param x the exception
+ * @since 3.2
+ */
+ protected void handleException(IOException x) {
+ x.printStackTrace();
+ }
+
+ /**
+ * Saves the resource managers to the preferences.
+ *
+ * @throws IOException if the resource managers cannot be written
+ */
+ public void save() throws IOException {
+
+ StringWriter output= new StringWriter();
+ ResourceManagerReaderWriter writer= new ResourceManagerReaderWriter();
+ writer.save((IResourceManager[]) fResourceManagers.toArray(new IResourceManager[fResourceManagers.size()]), output);
+
+ fIgnorePreferenceStoreChanges= true;
+ try {
+ fPreferenceStore.setValue(fKey, output.toString());
+ if (fPreferenceStore instanceof IPersistentPreferenceStore)
+ ((IPersistentPreferenceStore)fPreferenceStore).save();
+ } finally {
+ fIgnorePreferenceStoreChanges= false;
+ }
+ }
+
+ /**
+ * Adds a resource manager encapsulated in its persistent form.
+ *
+ * @param data the resource manager to add
+ */
+ public void add(IResourceManager rm) {
+
+ if (!validateResourceManager(rm))
+ return;
+
+ fResourceManagers.add(rm);
+ }
+
+ /**
+ * Removes a resource manager from the store.
+ *
+ * @param data the resource manager to remove
+ */
+ public void delete(IResourceManager rm) {
+ fResourceManagers.remove(rm);
+ }
+
+ /**
+ * Returns all resource managers.
+ *
+ * @return all resource managers
+ */
+ public IResourceManager[] getResourceManagers() {
+ return getResourceManagers(null);
+ }
+
+ /**
+ * Returns all resource managers for the given resource manager type.
+ *
+ * @param resourceManagerId the id of the resource manager type, or <code>null</code> if all resource managers should be returned
+ * @return all resource managers for the given type
+ */
+ public IResourceManager[] getResourceManagers(String resourceManagerId) {
+ List rms= new ArrayList();
+ for (Iterator it= fResourceManagers.iterator(); it.hasNext();) {
+ IResourceManager rm= (IResourceManager) it.next();
+ if (resourceManagerId == null || resourceManagerId.equals(rm.getConfiguration().getResourceManagerId()))
+ rms.add(rm);
+ }
+
+ return (IResourceManager[]) rms.toArray(new IResourceManager[rms.size()]);
+ }
+
+ /**
+ * Returns the first resource manager that matches the name.
+ *
+ * @param name the name of the resource manager searched for
+ * @return the first enabled resource manager that matches both name and type, or <code>null</code> if none is found
+ */
+ public IResourceManager findResourceManager(String name) {
+ return findResourceManager(name, null);
+ }
+
+ /**
+ * Returns the first resource manger that matches both name and type id.
+ *
+ * @param name the name of the resource manager searched for
+ * @param typeId the resource manager type, or <code>null</code> if any type is OK
+ * @return the first enabled resource manager that matches both name and type id, or <code>null</code> if none is found
+ */
+ public IResourceManager findResourceManager(String name, String typeId) {
+ Assert.isNotNull(name);
+
+ for (Iterator it= fResourceManagers.iterator(); it.hasNext();) {
+ IResourceManager rm = (IResourceManager) it.next();
+ if (typeId == null || typeId.equals(rm.getConfiguration().getResourceManagerId())
+ && name.equals(rm.getConfiguration().getName()))
+ return rm;
+ }
+
+ return null;
+ }
+
+ private void loadResourceManagers() throws IOException {
+ String pref= fPreferenceStore.getString(fKey);
+ if (pref != null && pref.trim().length() > 0) {
+ Reader input= new StringReader(pref);
+ ResourceManagerReaderWriter reader= new ResourceManagerReaderWriter();
+ IResourceManager[] rms= reader.read(input);
+ for (int i= 0; i < rms.length; i++) {
+ add(rms[i]);
+ }
+ }
+ }
+
+ /**
+ * Validates a resource manager.
+ *
+ * @param resource manager the resource manager to validate
+ * @return <code>true</code> if validation is successful,
+ * <code>false</code> if validation fails
+ */
+ private boolean validateResourceManager(IResourceManager rm) {
+ return true;
+ }
+
+}
+
Index: src/org/eclipse/ptp/rmsystem/IResourceManagerConfiguration.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/IResourceManagerConfiguration.java
diff -N src/org/eclipse/ptp/rmsystem/IResourceManagerConfiguration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/IResourceManagerConfiguration.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.rmsystem;
+
+public interface IResourceManagerConfiguration {
+
+ /**
+ * Returns the name of the resource manager.
+ *
+ * @return the name of the resource manager
+ */
+ public String getName();
+
+ /**
+ * Returns the description of the resource manager.
+ *
+ * @return the description of the resource manager
+ */
+ public String getDescription();
+
+ /**
+ * Returns the id of the resource manager
+ *
+ * @return the id of the resource manager
+ */
+ public String getResourceManagerId();
+
+ /**
+ * Returns the resource manger host.
+ *
+ * @return the resource manger host
+ */
+ public String getHost();
+
+ /**
+ * Returns the resource manger port.
+ *
+ * @return the resource manger port
+ */
+ public int getPort();
+
+}
Index: src/org/eclipse/ptp/rmsystem/AbstractResourceManagerFactory.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/AbstractResourceManagerFactory.java
diff -N src/org/eclipse/ptp/rmsystem/AbstractResourceManagerFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/AbstractResourceManagerFactory.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.ptp.rmsystem;
+
+
+/**
+ * @author rsqrd
+ *
+ */
+public abstract class AbstractResourceManagerFactory implements
+ IResourceManagerFactory {
+
+ private final String name;
+
+ /**
+ * @param name
+ */
+ public AbstractResourceManagerFactory(final String name) {
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManagerFactory#create(org.eclipse.ptp.rm.IRMConfiguration)
+ */
+ public abstract IResourceManager create(IResourceManagerConfiguration configuration);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.internal.rm.IResourceManagerFactory#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+}
Index: src/org/eclipse/ptp/rmsystem/IResourceManagerFactory.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/IResourceManagerFactory.java
diff -N src/org/eclipse/ptp/rmsystem/IResourceManagerFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/IResourceManagerFactory.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.ptp.rmsystem;
+
+
+/**
+ * @author rsqrd
+ *
+ */
+public interface IResourceManagerFactory {
+ /**
+ *
+ */
+ public String getName();
+
+ /**
+ *
+ */
+ public void setName(String name);
+
+ /**
+ *
+ */
+ public String getId();
+
+ /**
+ *
+ */
+ public String setId(String id);
+
+ /**
+ *
+ */
+ public boolean getSupportLocal();
+
+ /**
+ *
+ */
+ public void setSupportLocal(boolean value);
+
+ /**
+ *
+ */
+ public boolean getSupportRemote();
+
+ /**
+ *
+ */
+ public void setSupportRemote(boolean value);
+
+ /**
+ *
+ */
+ public boolean getNeedPort();
+
+ /**
+ *
+ */
+ public void setNeedPort(boolean value);
+
+ /**
+ * @param configuration
+ * @return
+ */
+ IResourceManager create(IResourceManagerConfiguration configuration);
+}
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPUniverseControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPUniverseControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPUniverseControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPUniverseControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import org.eclipse.ptp.core.IPUniverse;
+
+/**
+ * Adds the internal functionality of an IPElement to an IPUniverse
+ *
+ * @author rsqrd
+ *
+ */
+public interface IPUniverseControl extends IPUniverse, IPElementControl {
+ // nothing added
+}
Index: src/org/eclipse/ptp/rmsystem/ResourceManagerStatus.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/ResourceManagerStatus.java
diff -N src/org/eclipse/ptp/rmsystem/ResourceManagerStatus.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/ResourceManagerStatus.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,204 @@
+package org.eclipse.ptp.rmsystem;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ptp.core.PTPCorePlugin;
+
+/**
+ * Resource manager status
+ * </p>
+ */
+public class ResourceManagerStatus implements IStatus {
+
+ /**
+ * A standard OK status with an "ok" message.
+ *
+ */
+ public static final IStatus OK_STATUS = new ResourceManagerStatus(OK, OK, "", null);
+ /**
+ * A standard CANCEL status with no message.
+ *
+ */
+ public static final IStatus CANCEL_STATUS = new ResourceManagerStatus(CANCEL, 1, "", null); //$NON-NLS-1$
+ /**
+ * The severity. One of
+ * <ul>
+ * <li><code>CANCEL</code></li>
+ * <li><code>ERROR</code></li>
+ * <li><code>WARNING</code></li>
+ * <li><code>INFO</code></li>
+ * <li>or <code>OK</code> (0)</li>
+ * </ul>
+ */
+ private int severity = OK;
+
+ /** Plug-in-specific status code.
+ */
+ private int code;
+
+ /** Message, localized to the current locale.
+ */
+ private String message;
+
+ /** Wrapped exception, or <code>null</code> if none.
+ */
+ private Throwable exception = null;
+
+ /** Constant to avoid generating garbage.
+ */
+ private static final IStatus[] theEmptyStatusArray = new IStatus[0];
+
+ /**
+ * Creates a new status object. The created status has no children.
+ *
+ * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
+ * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
+ * @param code the plug-in-specific status code, or <code>OK</code>
+ * @param message a human-readable message, localized to the
+ * current locale
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ */
+ public ResourceManagerStatus(int severity, int code, String message, Throwable exception) {
+ setSeverity(severity);
+ setCode(code);
+ setMessage(message);
+ setException(exception);
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public IStatus[] getChildren() {
+ return theEmptyStatusArray;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public Throwable getException() {
+ return exception;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public String getPlugin() {
+ return PTPCorePlugin.PLUGIN_ID;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public int getSeverity() {
+ return severity;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public boolean isMultiStatus() {
+ return false;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public boolean isOK() {
+ return severity == OK;
+ }
+
+ /* (Intentionally not javadoc'd)
+ * Implements the corresponding method on <code>IStatus</code>.
+ */
+ public boolean matches(int severityMask) {
+ return (severity & severityMask) != 0;
+ }
+
+ /**
+ * Sets the status code.
+ *
+ * @param code the plug-in-specific status code, or <code>OK</code>
+ */
+ protected void setCode(int code) {
+ this.code = code;
+ }
+
+ /**
+ * Sets the exception.
+ *
+ * @param exception a low-level exception, or <code>null</code> if not
+ * applicable
+ */
+ protected void setException(Throwable exception) {
+ this.exception = exception;
+ }
+
+ /**
+ * Sets the message.
+ *
+ * @param message a human-readable message, localized to the
+ * current locale
+ */
+ protected void setMessage(String message) {
+ Assert.isLegal(message != null);
+ this.message = message;
+ }
+
+
+ /**
+ * Sets the severity.
+ *
+ * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
+ * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
+ */
+ protected void setSeverity(int severity) {
+ Assert.isLegal(severity == OK || severity == ERROR || severity == WARNING || severity == INFO || severity == CANCEL);
+ this.severity = severity;
+ }
+
+ /**
+ * Returns a string representation of the status, suitable
+ * for debugging purposes only.
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("Status "); //$NON-NLS-1$
+ if (severity == OK) {
+ buf.append("OK"); //$NON-NLS-1$
+ } else if (severity == ERROR) {
+ buf.append("ERROR"); //$NON-NLS-1$
+ } else if (severity == WARNING) {
+ buf.append("WARNING"); //$NON-NLS-1$
+ } else if (severity == INFO) {
+ buf.append("INFO"); //$NON-NLS-1$
+ } else if (severity == CANCEL) {
+ buf.append("CANCEL"); //$NON-NLS-1$
+ } else {
+ buf.append("severity="); //$NON-NLS-1$
+ buf.append(severity);
+ }
+ buf.append(": "); //$NON-NLS-1$
+ buf.append(" code="); //$NON-NLS-1$
+ buf.append(code);
+ buf.append(' ');
+ buf.append(message);
+ buf.append(' ');
+ buf.append(exception);
+ return buf.toString();
+ }
+}
Index: src/org/eclipse/ptp/core/IModelPresentation.java
===================================================================
RCS file: src/org/eclipse/ptp/core/IModelPresentation.java
diff -N src/org/eclipse/ptp/core/IModelPresentation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/core/IModelPresentation.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author rsqrd
+ *
+ */
+public interface IModelPresentation {
+
+ /**
+ * @param jobName
+ * @throws CoreException
+ */
+ public void abortJob(String jobName) throws CoreException;
+
+ /**
+ * @param listener
+ */
+ public void addParallelLaunchListener(IParallelModelListener listener);
+
+ /**
+ * @return
+ */
+ public IPUniverse getUniverse();
+
+ /**
+ * @param controlSystemID
+ * @param monitoringSystemID
+ * @param monitor
+ * @throws CoreException
+ */
+ public void refreshRuntimeSystems(int controlSystemID,
+ int monitoringSystemID, IProgressMonitor monitor)
+ throws CoreException;
+
+ /**
+ * @param monitor
+ * @param force
+ * @throws CoreException
+ */
+ public void refreshRuntimeSystems(IProgressMonitor monitor, boolean force)
+ throws CoreException;
+
+ /**
+ * @param listener
+ */
+ public void removeParallelLaunchListener(IParallelModelListener listener);
+}
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPElementControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPElementControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPElementControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPElementControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2005 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import java.util.Collection;
+
+import org.eclipse.ptp.core.IPElement;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+
+/**
+ * This is the generic parallel element class which all the specific classes
+ * extend, like Machine, Node, Job, etc. This base class maintains a name for
+ * each entity that extends it and handles parent/child operations. A key is
+ * also maintained for each parallel element which is used in storing these
+ * elements in hash tables and such.
+ *
+ * @author Nathan DeBardeleben
+ */
+public interface IPElementControl extends IPElement, ISearchPageScoreComputer {
+ // public String NAME_TAG = "";
+
+ /**
+ * Element tag for an error / undefined type
+ */
+ public static final int P_TYPE_ERROR = -1;
+
+ /**
+ * Element tag for Universe Elements
+ */
+ public static final int P_UNIVERSE = 10;
+
+ /**
+ * Element tag for Machine Elements
+ */
+ public static final int P_MACHINE = 11;
+
+ /**
+ * Element tag for Node Elements
+ */
+ public static final int P_NODE = 12;
+
+ /**
+ * Element tag for Job Elements
+ */
+ public static final int P_JOB = 13;
+
+ /**
+ * Element tag for Process Elements
+ */
+ public static final int P_PROCESS = 14;
+
+ /**
+ * Searches for an attribute on the Element given an attribute class and key.
+ * The resulting attribute Object is returned. The returned may be null if the attribute
+ * was not found.
+ *
+ * @param attr_class Class of attribute
+ * @param key String key of the attribute to look for
+ * @return Object of the attribute or null if not found
+ */
+ public Object getAttribute(int attr_class, String key);
+
+ /**
+ * Sets an attribute given a class, key and Object.
+ *
+ * @param attr_class Class of the attribute
+ * @param key String key of the attribute
+ * @param Object of the attribute
+ */
+ public void setAttribute(int attr_class, String key, Object o);
+
+ /**
+ * Get all the keys of all attributes in a particular class.
+ *
+ * @param attr_class Class of attribute keys
+ * @return A string array containing the keys
+ */
+ public String[] getAttributeKeys(int attr_class);
+
+ /**
+ * Returns the element type (such as P_UNIVERSE, P_MACHINE, etc.) for this
+ * Element. This type is usually set through the constructor of the
+ * implementing class of this interface.
+ *
+ * @return The element type of this Element which can be compared with the
+ * public statics of this interface.
+ * @see P_UNIVERSE
+ * @see P_MACHINE
+ * @see P_NODE
+ * @see P_JOB
+ * @see P_PROCESS
+ */
+ public int getElementType();
+
+ /**
+ * Returns an Element array of the children of this Element. If this Element
+ * does not yet have any children, then null is returned.
+ *
+ * @return An Element array of the children of this Element, null if there
+ * are none
+ */
+ public IPElementControl[] getChildren();
+
+ /**
+ * If this Element has a parent then this method returns it, else it returns
+ * null.
+ *
+ * @return The parent Element of this Element, null if there is none
+ */
+ public IPElementControl getParent();
+
+ /*
+ * public IPUniverse getPUniverse(); public IPMachine getPMachine(); public
+ * IPJob getPRoot();
+ */
+
+ /**
+ * Adds an Element as a child of this Element creating a parent-child
+ * relationship between the two.
+ *
+ * @param member
+ * The Element to add as a child to this Element
+ */
+ public void addChild(IPElementControl member);
+
+ /**
+ * Locate a child Element of this Element and remove it as a child, breaking
+ * the parent-child relationship between the two. If the proposed child
+ * member is not found as a child of this Element then no action is taken.
+ *
+ * @param member
+ * The Element to remove as a child of this Element
+ */
+ public void removeChild(IPElementControl member);
+
+ /**
+ * Remove all children Elements from this Element.
+ */
+ public void removeChildren();
+
+ /**
+ * Finds an child Element of this Element by searching by the name of the
+ * Element. If found, the Element object is returned, else null is returned.
+ *
+ * @param elementName
+ * The name of the child Element to find
+ * @return The Element object if found, else null
+ */
+ public IPElementControl findChild(String elementName);
+
+ /**
+ * Returns the number of children of this Element.
+ *
+ * @return The number of children of this Element
+ */
+ public int size();
+
+ /**
+ * This method really doesn't make sense anymore, it needs to be fixed. <br>
+ * TODO: <i>SLATED FOR REMOVAL</i>
+ *
+ * @return I have no idea, T/F obviously though :)
+ */
+ public boolean isAllStop();
+
+ /**
+ * Returns a sorted Element array of this Element's children. Left open to
+ * the implementer of this interface as to how the sorting is done and what
+ * the sorting is performed on.
+ *
+ * @return Sorted Element array of the children of this Element, null if
+ * there are none
+ */
+ public IPElementControl[] getSortedChildren();
+
+ /**
+ * Returns the children of this Element as a Collection or null if there are
+ * no children.
+ *
+ * @return The children of this Element or null if there are none
+ */
+ public Collection getCollection();
+
+ /**
+ * Returns true if this Element has children Elements, else returns false.
+ *
+ * @return True if this Element has children Elements, else false
+ */
+ public boolean hasChildren();
+}
Index: src/org/eclipse/ptp/rmsystem/IResourceManagerListener.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/IResourceManagerListener.java
diff -N src/org/eclipse/ptp/rmsystem/IResourceManagerListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/IResourceManagerListener.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.ptp.rmsystem;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author rsqrd
+ *
+ */
+public interface IResourceManagerListener {
+ /**
+ * @param resourceManager
+ */
+ public void handleStarted(IResourceManager resourceManager);
+
+ /**
+ * @param resourceManager
+ */
+ public void handleStopped(IResourceManager resourceManager);
+
+ /**
+ * @param oldStatus
+ * @param manager
+ */
+ public void handleStatusChanged(IStatus oldStatus, IResourceManager manager);
+}
Index: src/org/eclipse/ptp/rmsystem/ResourceManagerReaderWriter.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/ResourceManagerReaderWriter.java
diff -N src/org/eclipse/ptp/rmsystem/ResourceManagerReaderWriter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/ResourceManagerReaderWriter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,298 @@
+package org.eclipse.ptp.rmsystem;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.ptp.core.PTPCorePlugin;
+
+/**
+ * Serializes resource manager as character or byte stream and reads the same format
+ * back.
+ *
+ */
+public class ResourceManagerReaderWriter {
+
+ private static final String RM_ROOT = "resourcemanagers"; //$NON-NLS-1$
+ private static final String RM_ELEMENT = "resourcemanager"; //$NON-NLS-1$
+ private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
+ private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
+ private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
+ private static final String HOST_ATTRIBUTE= "host"; //$NON-NLS-1$
+ private static final String PORT_ATTRIBUTE= "port"; //$NON-NLS-1$
+
+ /**
+ * Create a new instance.
+ */
+ public ResourceManagerReaderWriter() {
+ }
+
+ /**
+ * Reads resource managers from a reader and returns them. The reader must present
+ * a serialized form as produced by the <code>save</code> method.
+ *
+ * @param reader the reader to read resource managers from
+ * @return the read resource managers
+ * @throws IOException if reading from the stream fails
+ */
+ public IResourceManager[] read(Reader reader) throws IOException {
+ return read(reader, null);
+ }
+
+ /**
+ * Reads the resource manager with identifier <code>id</code> from a reader and
+ * returns it. The reader must present a serialized form as produced by the
+ * <code>save</code> method.
+ *
+ * @param reader the reader to read resource managers from
+ * @param id the id of the resource manager to return
+ * @return the read resource manager
+ * @throws IOException if reading from the stream fails
+ */
+ public IResourceManager readSingle(Reader reader, String id) throws IOException {
+ IResourceManager[] datas= read(new InputSource(reader), null, id);
+ if (datas.length > 0)
+ return datas[0];
+ return null;
+ }
+
+ /**
+ * Reads resource managers from a stream and adds them to the resource managers.
+ *
+ * @param reader the reader to read resource managers from
+ * @param bundle a resource bundle to use for translating the read resource managers, or <code>null</code> if no translation should occur
+ * @return the read resource managers
+ * @throws IOException if reading from the stream fails
+ */
+ public IResourceManager[] read(Reader reader, ResourceBundle bundle) throws IOException {
+ return read(new InputSource(reader), bundle, null);
+ }
+
+ /**
+ * Reads resource managers from a stream and adds them to the resource managers.
+ *
+ * @param stream the byte stream to read resource managers from
+ * @param bundle a resource bundle to use for translating the read resource managers, or <code>null</code> if no translation should occur
+ * @return the read resource managers
+ * @throws IOException if reading from the stream fails
+ */
+ public IResourceManager[] read(InputStream stream, ResourceBundle bundle) throws IOException {
+ return read(new InputSource(stream), bundle, null);
+ }
+
+ /**
+ * Reads resource managers from an <code>InputSource</code> and adds them to the resource managers.
+ *
+ * @param source the input source
+ * @param bundle a resource bundle to use for translating the read resource managers, or <code>null</code> if no translation should occur
+ * @param singleId the resource manager id to extract, or <code>null</code> to read in all resource managers
+ * @return the read resource managers
+ * @throws IOException if reading from the stream fails
+ */
+ private IResourceManager[] read(InputSource source, ResourceBundle bundle, String singleId) throws IOException {
+ try {
+ Collection rms = new ArrayList();
+
+ DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+ DocumentBuilder parser= factory.newDocumentBuilder();
+ Document document= parser.parse(source);
+
+ NodeList elements= document.getElementsByTagName(RM_ELEMENT);
+
+ int count= elements.getLength();
+ for (int i= 0; i != count; i++) {
+ Node node= elements.item(i);
+ NamedNodeMap attributes= node.getAttributes();
+
+ if (attributes == null)
+ continue;
+
+ String name= getStringValue(attributes, NAME_ATTRIBUTE);
+
+ String description= getStringValue(attributes, DESCRIPTION_ATTRIBUTE, ""); //$NON-NLS-1$
+
+ String rm= getStringValue(attributes, ID_ATTRIBUTE);
+
+ if (name == null || rm == null)
+ throw new IOException("Missing attribute"); //$NON-NLS-1$
+
+ String host = getStringValue(attributes, HOST_ATTRIBUTE, "");
+ int port = getIntValue(attributes, PORT_ATTRIBUTE, -1);
+
+ IResourceManagerConfiguration config = new ResourceManagerConfiguration(name, description, rm, host, port);
+ IResourceManagerFactory rmFactory = PTPCorePlugin.getDefault().getResourceManagerFactory(rm);
+ if (rmFactory != null)
+ {
+ rms.add(rmFactory.create(config));
+ }
+
+ }
+
+ return (IResourceManager[]) rms.toArray(new IResourceManager[rms.size()]);
+
+ } catch (ParserConfigurationException e) {
+ Assert.isTrue(false);
+ } catch (SAXException e) {
+ Throwable t= e.getCause();
+ if (t instanceof IOException)
+ throw (IOException) t;
+ else if (t != null)
+ throw new IOException(t.getMessage());
+ else
+ throw new IOException(e.getMessage());
+ }
+
+ return null; // dummy
+ }
+
+ /**
+ * Saves the resource managers as XML, encoded as UTF-8 onto the given byte stream.
+ *
+ * @param resource managers the resource managers to save
+ * @param stream the byte output to write the resource managers to in XML
+ * @throws IOException if writing the resource managers fails
+ */
+ public void save(IResourceManager[] rms, OutputStream stream) throws IOException {
+ save(rms, new StreamResult(stream));
+ }
+
+ /**
+ * Saves the resource managers as XML.
+ *
+ * @param rms the resource managers to save
+ * @param writer the writer to write the resource managers to in XML
+ * @throws IOException if writing the resource managers fails
+ */
+ public void save(IResourceManager[] rms, Writer writer) throws IOException {
+ save(rms, new StreamResult(writer));
+ }
+
+ /**
+ * Saves the resource managers as XML.
+ *
+ * @param rms the resource managers to save
+ * @param result the stream result to write to
+ * @throws IOException if writing the targets fails
+ */
+ private void save(IResourceManager[] rms, StreamResult result) throws IOException {
+ try {
+ DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder= factory.newDocumentBuilder();
+ Document document= builder.newDocument();
+
+ Node root= document.createElement(RM_ROOT);
+ document.appendChild(root);
+
+ for (int i= 0; i < rms.length; i++) {
+ IResourceManager target= rms[i];
+
+
+ Node node= document.createElement(RM_ELEMENT);
+ root.appendChild(node);
+
+ NamedNodeMap attributes= node.getAttributes();
+
+ if (target != null) {
+ IResourceManagerConfiguration config = target.getConfiguration();
+
+ Attr name= document.createAttribute(NAME_ATTRIBUTE);
+ name.setValue(config.getName());
+ attributes.setNamedItem(name);
+
+ Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
+ description.setValue(config.getDescription());
+ attributes.setNamedItem(description);
+
+ Attr context= document.createAttribute(ID_ATTRIBUTE);
+ context.setValue(config.getResourceManagerId());
+ attributes.setNamedItem(context);
+
+ if (config.getHost().trim().length()==0) {
+ Attr host= document.createAttribute(HOST_ATTRIBUTE);
+ host.setValue(config.getHost());
+ attributes.setNamedItem(host);
+ }
+
+ if (config.getPort() >=0) {
+ Attr port= document.createAttribute(PORT_ATTRIBUTE);
+ port.setValue(new Integer(config.getPort()).toString());
+ attributes.setNamedItem(port);
+ }
+ }
+ }
+
+ Transformer transformer=TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+ DOMSource source = new DOMSource(document);
+
+ transformer.transform(source, result);
+
+ } catch (ParserConfigurationException e) {
+ Assert.isTrue(false);
+ } catch (TransformerException e) {
+ if (e.getException() instanceof IOException)
+ throw (IOException) e.getException();
+ Assert.isTrue(false);
+ }
+ }
+
+ private boolean getBooleanValue(NamedNodeMap attributes, String attribute, boolean defaultValue) throws SAXException {
+ Node enabledNode= attributes.getNamedItem(attribute);
+ if (enabledNode == null)
+ return defaultValue;
+ else if (enabledNode.getNodeValue().equals(Boolean.toString(true)))
+ return true;
+ else if (enabledNode.getNodeValue().equals(Boolean.toString(false)))
+ return false;
+ else
+ throw new SAXException("Illegal boolean attribute");
+ }
+
+ private int getIntValue(NamedNodeMap attributes, String name, int defaultValue) throws SAXException {
+ Node node= attributes.getNamedItem(name);
+ return node == null ? defaultValue : Integer.parseInt(node.getNodeValue());
+ }
+
+ private String getStringValue(NamedNodeMap attributes, String name) throws SAXException {
+ String val= getStringValue(attributes, name, null);
+ if (val == null)
+ throw new SAXException("Missing attribute");
+ return val;
+ }
+
+ private String getStringValue(NamedNodeMap attributes, String name, String defaultValue) {
+ Node node= attributes.getNamedItem(name);
+ return node == null ? defaultValue : node.getNodeValue();
+ }
+
+}
+
Index: schema/resourcemanager.exsd
===================================================================
RCS file: schema/resourcemanager.exsd
diff -N schema/resourcemanager.exsd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ schema/resourcemanager.exsd 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,140 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ptp.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ptp.core" id="resourcemanager" name="Resource Manager"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="resourcemanager" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="resourcemanager">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="supportLocal" type="boolean" use="default" value="false">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="supportRemote" type="boolean" use="default" value="false">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="needPort" type="boolean" use="default" value="false">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.ptp.rmsystem.AbstractResourceManagerFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Index: src/org/eclipse/ptp/rmsystem/ResourceManagerConfiguration.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/ResourceManagerConfiguration.java
diff -N src/org/eclipse/ptp/rmsystem/ResourceManagerConfiguration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/ResourceManagerConfiguration.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+package org.eclipse.ptp.rmsystem;
+
+import org.eclipse.core.runtime.Assert;
+
+public class ResourceManagerConfiguration implements
+ IResourceManagerConfiguration {
+
+ /** The name of resource manager */
+ private final String name;
+ /** A description of resource manager */
+ private final String description;
+ /** The id of the resource manager*/
+ private final String resourceManagerId;
+ /** The host of resource manager, if any */
+ private final String host;
+ /** The port of resource manager, if any */
+ private final int port;
+
+ /**
+ * Creates a copy of a resource manager configuration
+ *
+ * @param config the configuration to copy
+ */
+ public ResourceManagerConfiguration(IResourceManagerConfiguration config) {
+ this(config.getName(), config.getDescription(), config.getResourceManagerId(), config.getHost(), config.getPort());
+ }
+
+ /**
+ * Creates a resource manager configuration
+ *
+ * @param name the name of the resource manager
+ * @param description the description of the resource manager
+ * @param resourceManagerId the id of the resource manager which resides on the resource manager
+ * @param host the host of the resource manger
+ * @param port the port of the resource manger
+ */
+ public ResourceManagerConfiguration(String name, String description, String resourceManagerId, String host, int port) {
+ Assert.isNotNull(description);
+ this.name = name;
+ this.description= description;
+ Assert.isNotNull(resourceManagerId);
+ this.resourceManagerId= resourceManagerId;
+ this.host = host;
+ this.port = port;
+ }
+
+ /*
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return name.hashCode() ^ host.hashCode() ^ new Integer(port).hashCode();
+ }
+
+ /**
+ * Returns the name of the resource manger.
+ *
+ * @return the name of the resource manger
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the description of the resource manger
+ *
+ *
+ * @return the description of the resource manger
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Returns the id of the resource manager
+ *
+ * @return the id of the resource manager
+ */
+ public String getResourceManagerId() {
+ return this.resourceManagerId;
+ }
+
+ /**
+ * Returns the resource manger host.
+ *
+ * @return the resource manger host
+ */
+ public String getHost() {
+ return this.host;
+ }
+
+ /**
+ * Returns the resource manger port.
+ *
+ * @return the resource manger port
+ */
+ public int getPort() {
+ return this.port;
+ }
+
+ /*
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o) {
+ if (!(o instanceof IResourceManagerConfiguration))
+ return false;
+
+ IResourceManagerConfiguration t= (IResourceManagerConfiguration) o;
+ if (t == this)
+ return true;
+
+ return t.getName().equals(name)
+ && t.getResourceManagerId().equals(resourceManagerId)
+ && t.getHost().equals(host)
+ && t.getPort() == port;
+ }
+
+}
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPMachineControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPMachineControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPMachineControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPMachineControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import org.eclipse.ptp.core.IPMachine;
+
+public interface IPMachineControl extends IPElementControl, IPMachine {
+
+}
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPProcessControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPProcessControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPProcessControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPProcessControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import org.eclipse.ptp.core.IPProcess;
+
+public interface IPProcessControl extends IPProcess, IPElementControl {
+
+}
Index: src/org/eclipse/ptp/internal/core/elementcontrols/IPNodeControl.java
===================================================================
RCS file: src/org/eclipse/ptp/internal/core/elementcontrols/IPNodeControl.java
diff -N src/org/eclipse/ptp/internal/core/elementcontrols/IPNodeControl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/internal/core/elementcontrols/IPNodeControl.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.internal.core.elementcontrols;
+
+import org.eclipse.ptp.core.IPNode;
+
+public interface IPNodeControl extends IPElementControl, IPNode {
+
+}
Index: src/org/eclipse/ptp/rmsystem/AbstractResourceManager.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/AbstractResourceManager.java
diff -N src/org/eclipse/ptp/rmsystem/AbstractResourceManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/AbstractResourceManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.ptp.rmsystem;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ptp.core.IModelPresentation;
+import org.eclipse.ptp.rtsystem.IControlSystem;
+
+/**
+ * @author rsqrd
+ *
+ */
+public abstract class AbstractResourceManager implements IResourceManager {
+
+ private final List listeners = new ArrayList();
+
+ private final IResourceManagerConfiguration config;
+
+ private IStatus status;
+
+ public AbstractResourceManager(IResourceManagerConfiguration config)
+ {
+ this.config = config;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#addResourceManagerListener(org.eclipse.ptp.rm.IResourceManagerListener)
+ */
+ public synchronized void addResourceManagerListener(IResourceManagerListener listener) {
+ if (!listeners.contains(listener))
+ listeners.add(listener);
+ }
+
+ /**
+ * @return
+ */
+ public IResourceManagerConfiguration getConfiguration() {
+ return config;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#getControlSystem()
+ */
+ public abstract IControlSystem getControlSystem();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#getModeManager()
+ */
+ public abstract IModelPresentation getModelPresentation();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#removeResourceManagerListener(org.eclipse.ptp.rm.IResourceManagerListener)
+ */
+ public synchronized void removeResourceManagerListener(IResourceManagerListener listener) {
+ listeners.remove(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#start()
+ */
+ public void start() throws CoreException {
+ doStart();
+ fireStarted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ptp.rm.IResourceManager#stop()
+ */
+ public void stop() throws CoreException {
+ getModelManager().shutdown();
+ doStop();
+ fireStopped();
+ }
+
+ public IStatus getStatus() {
+ return status;
+ }
+
+ protected void setStatus(IStatus status) {
+ final IStatus oldStatus = this.status;
+ this.status = status;
+ fireStatusChanged(oldStatus);
+ }
+
+ private void fireStatusChanged(IStatus oldStatus) {
+ // make a copy of the listener list in case one of the listeners
+ // wants to add or remove a listener
+ List tmpListeners = new ArrayList(listeners);
+
+ for (Iterator tit = tmpListeners.iterator(); tit.hasNext(); ) {
+ IResourceManagerListener listener = (IResourceManagerListener) tit.next();
+ listener.handleStatusChanged(oldStatus, this);
+ }
+ }
+
+ private void fireStarted() {
+ // make a copy of the listener list in case one of the listeners
+ // wants to add or remove a listener
+ List tmpListeners = new ArrayList(listeners);
+
+ for (Iterator tit = tmpListeners.iterator(); tit.hasNext(); ) {
+ IResourceManagerListener listener = (IResourceManagerListener) tit.next();
+ listener.handleStarted(this);
+ }
+ }
+
+ private void fireStopped() {
+ // make a copy of the listener list in case one of the listeners
+ // wants to add or remove a listener
+ List tmpListeners = new ArrayList(listeners);
+
+ for (Iterator tit = tmpListeners.iterator(); tit.hasNext(); ) {
+ IResourceManagerListener listener = (IResourceManagerListener) tit.next();
+ listener.handleStopped(this);
+ }
+ }
+
+ /**
+ * @throws CoreException
+ */
+ protected abstract void doStart() throws CoreException;
+
+ /**
+ * @throws CoreException
+ */
+ protected abstract void doStop() throws CoreException;
+
+}
Index: src/org/eclipse/ptp/rmsystem/IResourceManagerChangedListener.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/IResourceManagerChangedListener.java
diff -N src/org/eclipse/ptp/rmsystem/IResourceManagerChangedListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/IResourceManagerChangedListener.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.rmsystem;
+
+public interface IResourceManagerChangedListener {
+ /**
+ * @param oldRmManager
+ * @param newRmManager
+ */
+ public void handleChanged(IResourceManager oldRmManager, IResourceManager newRmManager);
+}
Index: src/org/eclipse/ptp/rmsystem/IResourceManager.java
===================================================================
RCS file: src/org/eclipse/ptp/rmsystem/IResourceManager.java
diff -N src/org/eclipse/ptp/rmsystem/IResourceManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/rmsystem/IResourceManager.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2006 The Regents of the University of California.
+ * This material was produced under U.S. Government contract W-7405-ENG-36
+ * for Los Alamos National Laboratory, which is operated by the University
+ * of California for the U.S. Department of Energy. The U.S. Government has
+ * rights to use, reproduce, and distribute this software. NEITHER THE
+ * GOVERNMENT NOR THE UNIVERSITY MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
+ * ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified
+ * to produce derivative works, such modified software should be clearly marked,
+ * so as not to confuse it with the version available from LANL.
+ *
+ * Additionally, this program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * LA-CC 04-115
+ *******************************************************************************/
+package org.eclipse.ptp.rmsystem;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ptp.core.IModelManager;
+import org.eclipse.ptp.core.IModelPresentation;
+import org.eclipse.ptp.rtsystem.IControlSystem;
+
+public interface IResourceManager {
+
+ public static final int STATUS_OK = 0;
+ public static final int STATUS_ERROR = -1;
+
+ /**
+ * @param listener
+ */
+ public void addResourceManagerListener(IResourceManagerListener listener);
+
+ /**
+ * @return
+ */
+ public IControlSystem getControlSystem();
+
+ /**
+ * @return
+ */
+ public IModelPresentation getModelPresentation();
+
+ /**
+ * @return
+ */
+ public IModelManager getModelManager();
+
+ /**
+ * @return
+ */
+ public IResourceManagerConfiguration getConfiguration();
+
+ /**
+ * @return
+ */
+ public IStatus getStatus();
+
+ /**
+ * @param listener
+ */
+ public void removeResourceManagerListener(IResourceManagerListener listener);
+
+ /**
+ *
+ */
+ public void start() throws CoreException;
+
+ /**
+ *
+ */
+ public void stop() throws CoreException;
+}
Index: src/org/eclipse/ptp/internal/ui/search/PSearchResultLabelProvider.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/search/PSearchResultLabelProvider.java,v
retrieving revision 1.1
diff -u -r1.1 PSearchResultLabelProvider.java
--- src/org/eclipse/ptp/internal/ui/search/PSearchResultLabelProvider.java 7 Apr 2005 16:24:31 -0000 1.1
+++ src/org/eclipse/ptp/internal/ui/search/PSearchResultLabelProvider.java 6 Jun 2006 17:47:58 -0000
@@ -131,10 +131,4 @@
return "";
}
-
-
- private String getElementText(IPElement element){
- IPElement parent = element.getParent();
- return element.getElementName();
- }
}
Index: src/org/eclipse/ptp/internal/ui/search/PSearchContentProvider.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/search/PSearchContentProvider.java,v
retrieving revision 1.4
diff -u -r1.4 PSearchContentProvider.java
--- src/org/eclipse/ptp/internal/ui/search/PSearchContentProvider.java 28 Jun 2005 16:26:12 -0000 1.4
+++ src/org/eclipse/ptp/internal/ui/search/PSearchContentProvider.java 6 Jun 2006 17:47:58 -0000
@@ -71,11 +71,11 @@
};
public PSearchContentProvider() {
- PTPCorePlugin.getDefault().getModelManager().addParallelLaunchListener(launchAdapter);
+ PTPCorePlugin.getDefault().getModelPresentation().addParallelLaunchListener(launchAdapter);
}
public void dispose() {
- PTPCorePlugin.getDefault().getModelManager().removeParallelLaunchListener(launchAdapter);
+ PTPCorePlugin.getDefault().getModelPresentation().removeParallelLaunchListener(launchAdapter);
}
public Object[] getElements(Object inputElement) {
Index: src/org/eclipse/ptp/internal/ui/search/PSearchPage.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/search/PSearchPage.java,v
retrieving revision 1.4
diff -u -r1.4 PSearchPage.java
--- src/org/eclipse/ptp/internal/ui/search/PSearchPage.java 5 Aug 2005 15:59:52 -0000 1.4
+++ src/org/eclipse/ptp/internal/ui/search/PSearchPage.java 6 Jun 2006 17:47:58 -0000
@@ -20,12 +20,15 @@
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.core.IPNode;
+import org.eclipse.ptp.core.IPProcess;
import org.eclipse.search.ui.ISearchPage;
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.search.ui.NewSearchUI;
@@ -252,14 +255,11 @@
int searchFor = SEARCH_NODE;
int limitTo = LIMIT_NUMBER;
- String pattern = String.valueOf(element.getID());
- switch (element.getElementType()) {
- case IPElement.P_NODE:
- searchFor = SEARCH_NODE;
- break;
- case IPElement.P_PROCESS:
- searchFor = SEARCH_PROCESS;
- break;
+ String pattern = String.valueOf(element.getID());
+ if (element instanceof IPNode) {
+ searchFor = SEARCH_NODE;
+ } else if (element instanceof IPProcess) {
+ searchFor = SEARCH_PROCESS;
}
return new SearchPatternData(searchFor, limitTo, pattern, element);
}
@@ -394,15 +394,15 @@
private String pattern;
private IPElement element;
- public SearchPatternData(int searchFor, int limitTo, String pattern, IPElement element) {
+ public SearchPatternData(int searchFor, int limitTo, String pattern, IPElement element2) {
setSearchFor(searchFor);
setLimitTo(limitTo);
setPattern(pattern);
- setElement(element);
+ setElement(element2);
}
- public void setElement(IPElement element) {
- this.element= element;
+ public void setElement(IPElement element2) {
+ this.element= element2;
}
public IPElement getElement() {
Index: src/org/eclipse/ptp/internal/ui/search/MatchLocator.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/search/MatchLocator.java,v
retrieving revision 1.4
diff -u -r1.4 MatchLocator.java
--- src/org/eclipse/ptp/internal/ui/search/MatchLocator.java 5 Aug 2005 15:59:52 -0000 1.4
+++ src/org/eclipse/ptp/internal/ui/search/MatchLocator.java 6 Jun 2006 17:47:58 -0000
@@ -19,10 +19,10 @@
package org.eclipse.ptp.internal.ui.search;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ptp.core.IModelManager;
+import org.eclipse.ptp.core.IModelPresentation;
import org.eclipse.ptp.core.IPElement;
-import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPJob;
+import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.PTPCorePlugin;
/**
@@ -32,12 +32,12 @@
private PSearchPattern pattern = null;
private PSearchResultCollector collector = null;
private IProgressMonitor progressMonitor;
- private IModelManager launchManager = null;
+ private IModelPresentation launchManager = null;
public MatchLocator(PSearchPattern pattern, PSearchResultCollector collector) {
this.pattern = pattern;
this.collector = collector;
- launchManager = PTPCorePlugin.getDefault().getModelManager();
+ launchManager = PTPCorePlugin.getDefault().getModelPresentation();
}
public void setProgressMonitor(IProgressMonitor progressMonitor) {
Index: src/org/eclipse/ptp/internal/ui/search/PSearchResultPage.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/search/PSearchResultPage.java,v
retrieving revision 1.2
diff -u -r1.2 PSearchResultPage.java
--- src/org/eclipse/ptp/internal/ui/search/PSearchResultPage.java 2 Aug 2005 23:19:48 -0000 1.2
+++ src/org/eclipse/ptp/internal/ui/search/PSearchResultPage.java 6 Jun 2006 17:47:58 -0000
@@ -19,6 +19,7 @@
package org.eclipse.ptp.internal.ui.search;
import java.util.Arrays;
+
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
Index: src/org/eclipse/ptp/ui/views/old/ParallelNodeStatusView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/old/ParallelNodeStatusView.java,v
retrieving revision 1.4
diff -u -r1.4 ParallelNodeStatusView.java
--- src/org/eclipse/ptp/ui/views/old/ParallelNodeStatusView.java 25 May 2006 17:05:44 -0000 1.4
+++ src/org/eclipse/ptp/ui/views/old/ParallelNodeStatusView.java 6 Jun 2006 17:47:59 -0000
@@ -27,7 +27,6 @@
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -46,8 +45,6 @@
import org.eclipse.ptp.ui.actions.old.ShowLegendAction;
import org.eclipse.ptp.ui.actions.old.ShowMyAllocatedNodesAction;
import org.eclipse.ptp.ui.actions.old.ShowMyUsedNodesAction;
-import org.eclipse.ptp.ui.actions.old.ShowProcessesAction;
-import org.eclipse.ptp.ui.actions.old.TerminateAllAction;
import org.eclipse.ptp.ui.old.ParallelImages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
@@ -67,7 +64,6 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
@@ -385,7 +381,7 @@
for (int i = 0; i < displayElements.length; i++) {
IPNode somenode = (IPNode) displayElements[i];
if (filterSelection == USED_NODES) {
- if (somenode != null && somenode.hasChildren()) {
+ if (somenode != null && somenode.hasChildProcesses()) {
IPProcess procs[] = somenode.getProcesses();
if (procs != null && procs.length > 0) {
tmpNodes[copied_elements] = displayElements[i];
@@ -614,7 +610,7 @@
}
public IPProcess[] getSortedProcessList(IPNode node) {
- if (node == null || !node.hasChildren())
+ if (node == null || !node.hasChildProcesses())
return null;
IPProcess tmp[] = node.getProcesses();
@@ -948,7 +944,7 @@
if (mode == PROCESSES) {
IPNode somenode = systemNodeToIPNode("" + node + "");
- if (somenode == null || !somenode.hasChildren()) {
+ if (somenode == null || !somenode.hasChildProcesses()) {
MessageBox mb = new MessageBox(this.getViewSite().getShell(),
SWT.ICON_ERROR | SWT.OK);
mb.setMessage("Unable to find node " + node + " or\n"
@@ -1152,7 +1148,7 @@
* IPNode somenode =
* systemNodeToIPNode(sysDescNodes[index].getNode());
*/
- if (somenode != null && somenode.hasChildren()) {
+ if (somenode != null && somenode.hasChildProcesses()) {
/* so I have jobs on these nodes - are they running? */
IPProcess procs[] = somenode.getProcesses();
if (procs != null && procs.length > 0) {
@@ -1632,7 +1628,7 @@
IPNode somenode = (IPNode) displayElements[selected_node_num];
- if (somenode != null && somenode.hasChildren()) {
+ if (somenode != null && somenode.hasChildProcesses()) {
IPProcess procs[] = getSortedProcessList(somenode);
for (int i = 0; i < procs.length; i++) {
item = new TableItem(BRtable, 0);
@@ -1879,4 +1875,4 @@
selectReveal((IPElement) object);
}
}
-}
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/ui/views/old/ParallelProcessesView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/old/ParallelProcessesView.java,v
retrieving revision 1.2
diff -u -r1.2 ParallelProcessesView.java
--- src/org/eclipse/ptp/ui/views/old/ParallelProcessesView.java 23 Sep 2005 02:58:29 -0000 1.2
+++ src/org/eclipse/ptp/ui/views/old/ParallelProcessesView.java 6 Jun 2006 17:47:59 -0000
@@ -20,7 +20,6 @@
import java.util.ArrayList;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.IOpenListener;
@@ -34,14 +33,12 @@
import org.eclipse.ptp.core.IPMachine;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
-import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPUniverse;
import org.eclipse.ptp.ui.actions.old.ShowAllNodesAction;
import org.eclipse.ptp.ui.actions.old.ShowProcessesAction;
import org.eclipse.ptp.ui.actions.old.TerminateAllAction;
import org.eclipse.ptp.ui.old.ParallelElementContentProvider;
import org.eclipse.ptp.ui.old.ParallelElementLabelProvider;
-import org.eclipse.ptp.ui.old.UIMessage;
import org.eclipse.ptp.ui.old.UIUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
@@ -242,13 +239,13 @@
public Object[] getElements(Object parent) {
if (parent instanceof IPElement) {
- switch (((IPElement) parent).getElementType()) {
- case IPElement.P_UNIVERSE:
+ if (parent instanceof IPUniverse) {
return ((IPUniverse) parent).getSortedMachines();
- case IPElement.P_MACHINE:
+ } else if (parent instanceof IPMachine) {
return ((IPMachine) parent).getSortedNodes();
- case IPElement.P_NODE:
+ } else if (parent instanceof IPNode) {
return ((IPNode) parent).getSortedProcesses();
+ }
/*
* case IPElement.P_ROOT: if (SHOW_PROCESS_ONLY) return
* ((IPJob)parent).getSortedProcesses();
@@ -260,7 +257,6 @@
* case IPElement.P_NODE: return
* ((IPNode)parent).getSortedProcesses();
*/
- }
}
return null;
}
@@ -420,7 +416,7 @@
IPProcess process = launchManager.getUniverse().findProcessByName(
String.valueOf(processNumber));
if (process != null) {
- treeViewer.expandToLevel(process.getParent(), 1);
+ treeViewer.expandToLevel(process.getParentProcess(), 1);
treeViewer.setSelection(new StructuredSelection(process));
found = true;
Index: src/org/eclipse/ptp/ui/views/old/ParallelJobsView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/old/ParallelJobsView.java,v
retrieving revision 1.2
diff -u -r1.2 ParallelJobsView.java
--- src/org/eclipse/ptp/ui/views/old/ParallelJobsView.java 23 Sep 2005 02:58:29 -0000 1.2
+++ src/org/eclipse/ptp/ui/views/old/ParallelJobsView.java 6 Jun 2006 17:47:58 -0000
@@ -18,46 +18,24 @@
*******************************************************************************/
package org.eclipse.ptp.ui.views.old;
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ptp.core.IModelManager;
import org.eclipse.ptp.core.IPElement;
-import org.eclipse.ptp.core.IPMachine;
-import org.eclipse.ptp.core.IPNode;
-import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPJob;
+import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPUniverse;
-import org.eclipse.ptp.ui.actions.old.ShowAllNodesAction;
-import org.eclipse.ptp.ui.actions.old.ShowProcessesAction;
import org.eclipse.ptp.ui.actions.old.TerminateAllAction;
-import org.eclipse.ptp.ui.old.ParallelElementContentProvider;
import org.eclipse.ptp.ui.old.ParallelElementLabelProvider;
-import org.eclipse.ptp.ui.old.UIMessage;
-import org.eclipse.ptp.ui.old.UIUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.part.DrillDownComposite;
public class ParallelJobsView extends AbstractParallelView implements SelectionListener {
public static ParallelJobsView instance = null;
@@ -268,11 +246,11 @@
public Object[] getElements(Object parent) {
if (parent instanceof IPElement) {
- switch (((IPElement) parent).getElementType()) {
- case IPElement.P_UNIVERSE:
+ if (parent instanceof IPUniverse) {
return ((IPUniverse) parent).getSortedJobs();
- case IPElement.P_JOB:
+ } else if (parent instanceof IPJob) {
return ((IPJob) parent).getSortedProcesses();
+ }
/*
* case IPElement.P_UNIVERSE: return
* ((IPUniverse)parent).getSortedMachines(); case
@@ -291,7 +269,6 @@
* case IPElement.P_NODE: return
* ((IPNode)parent).getSortedProcesses();
*/
- }
}
return null;
}
Index: src/org/eclipse/ptp/ui/views/old/ParallelProcessViewer.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/old/ParallelProcessViewer.java,v
retrieving revision 1.2
diff -u -r1.2 ParallelProcessViewer.java
--- src/org/eclipse/ptp/ui/views/old/ParallelProcessViewer.java 8 Sep 2005 12:20:01 -0000 1.2
+++ src/org/eclipse/ptp/ui/views/old/ParallelProcessViewer.java 6 Jun 2006 17:47:59 -0000
@@ -208,7 +208,7 @@
IPProcess process = getProcess();
if (process != null) {
rankLabel.setText("Rank: " + process.getProcessNumber());
- totalLabel.setText("Total: " + process.getParent().size());
+ totalLabel.setText("Total: " + process.getParentProcess().getNumChildProcesses());
nodeLabel.setText("Node: " + ((IPNode) process.getNode()).getNodeNumber());
pidLabel.setText("PID: " + process.getPid());
statusLabel.setText("Status: " + process.getStatus());
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/META-INF/MANIFEST.MF,v
retrieving revision 1.12
diff -u -r1.12 MANIFEST.MF
--- META-INF/MANIFEST.MF 13 Feb 2006 02:48:40 -0000 1.12
+++ META-INF/MANIFEST.MF 6 Jun 2006 17:47:57 -0000
@@ -19,9 +19,9 @@
org.eclipse.ui.editors,
org.eclipse.ui.workbench.texteditor,
org.eclipse.cdt.core,
- org.eclipse.cdt.managedbuilder.core,
org.eclipse.cdt.ui,
- org.eclipse.ptp.core
+ org.eclipse.ptp.core,
+ org.eclipse.cdt.managedbuilder.core
Eclipse-AutoStart: true
Export-Package: org.eclipse.ptp.internal.ui,
org.eclipse.ptp.ui,
Index: plugin.properties
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/plugin.properties,v
retrieving revision 1.10
diff -u -r1.10 plugin.properties
--- plugin.properties 2 Jun 2006 02:25:46 -0000 1.10
+++ plugin.properties 6 Jun 2006 17:47:57 -0000
@@ -18,10 +18,12 @@
#
# Contributors:
# Clement Chu
+# Tianchao Li (Tianchao.Li@xxxxxxxxx)
#################################################################################
ParallelMachinesView.name=Machines
ParallelJobsView.name=Jobs
+ResourceManagersView.name=Resource Managers
TerminateAllAction.label=Terminate &All
TerminateAllAction.tooltip=Terminate All
@@ -36,6 +38,8 @@
OMPIpreferencePage.name=Open RTE
MPICH2preferencePage.name=MPICH2
ViewerpreferencePage.name=Viewer
+RMpreferencePage.name=Resource Manager
+
actionSets.name=PTP
actionSetsMenu.name=Menu name
@@ -46,4 +50,3 @@
legendAction.tooltip=Show status icons of node and process
PSearchPage.label=PTP Search
-
Index: plugin.xml
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/plugin.xml,v
retrieving revision 1.15
diff -u -r1.15 plugin.xml
--- plugin.xml 2 Jun 2006 02:25:46 -0000 1.15
+++ plugin.xml 6 Jun 2006 17:47:57 -0000
@@ -5,24 +5,42 @@
point="org.eclipse.ui.views">
<category
name="%ParallelViewCategory.name"
- id="org.parallel.ptp.ui.views">
+ id="org.eclipse.ptp.ui.views">
</category>
<view
name="%ParallelMachinesView.name"
icon="icons/parallel_perspective.gif"
- category="org.parallel.ptp.ui.views"
+ category="org.eclipse.ptp.ui.views"
class="org.eclipse.ptp.ui.views.ParallelMachineView"
id="org.eclipse.ptp.ui.views.parallelMachineView">
</view>
<view
name="%ParallelJobsView.name"
icon="icons/parallel_perspective.gif"
- category="org.parallel.ptp.ui.views"
+ category="org.eclipse.ptp.ui.views"
class="org.eclipse.ptp.ui.views.ParallelJobView"
id="org.eclipse.ptp.ui.views.parallelJobView">
</view>
+ <view
+ name="%ResourceManagersView.name"
+ icon="icons/rm/rm_view.gif"
+ category="org.eclipse.ptp.ui.views"
+ class="org.eclipse.ptp.ui.views.ResourceManagerView"
+ id="org.eclipse.ptp.ui.views.resourceManagerView">
+ </view>
</extension>
-
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.ptp.ui.PTPRunPerspective">
+ <view
+ ratio="0.4"
+ relative="org.eclipse.ptp.ui.views.ParallelJobView"
+ relationship="top"
+ id="org.eclipse.ptp.ui.views.ResourceManagerView">
+ </view>
+ </perspectiveExtension>
+ </extension>
<extension
point="org.eclipse.ui.editors">
<editor
@@ -71,10 +89,11 @@
category="org.eclipse.ptp.ui.preferences.ptpPreferencesPage">
</page>
<page
- category="org.eclipse.ptp.ui.preferences.ptpPreferencesPage"
- class="org.eclipse.ptp.ui.preferences.MPICH2PreferencesPage"
- id="org.eclipse.ptp.ui.preferences.mpich2PreferencesPage"
- name="%MPICH2preferencePage.name"/>
+ name="%RMpreferencePage.name"
+ class="org.eclipse.ptp.ui.preferences.ResourceManagerPreferencesPage"
+ id="org.eclipse.ptp.ui.preferences.rmPreferencesPage"
+ category="org.eclipse.ptp.ui.preferences.ptpPreferencesPage">
+ </page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
Index: src/org/eclipse/ptp/ui/old/ParallelElementLabelProvider.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/old/ParallelElementLabelProvider.java,v
retrieving revision 1.3
diff -u -r1.3 ParallelElementLabelProvider.java
--- src/org/eclipse/ptp/ui/old/ParallelElementLabelProvider.java 25 May 2006 17:05:44 -0000 1.3
+++ src/org/eclipse/ptp/ui/old/ParallelElementLabelProvider.java 6 Jun 2006 17:47:58 -0000
@@ -112,7 +112,7 @@
if (element instanceof IPNode) {
IPNode node = (IPNode)element;
- if(node.hasChildren()) {
+ if(node.hasChildProcesses()) {
if (!node.isAllStop())
return NODE_RUNNING;
else
@@ -189,4 +189,4 @@
parallelImages = null;
display = null;
}
-}
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/ui/old/SearchDialog.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/old/SearchDialog.java,v
retrieving revision 1.2
diff -u -r1.2 SearchDialog.java
--- src/org/eclipse/ptp/ui/old/SearchDialog.java 5 Aug 2005 15:59:53 -0000 1.2
+++ src/org/eclipse/ptp/ui/old/SearchDialog.java 6 Jun 2006 17:47:58 -0000
@@ -27,12 +27,18 @@
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.core.IPJob;
+import org.eclipse.ptp.core.IPMachine;
+import org.eclipse.ptp.core.IPNode;
+import org.eclipse.ptp.core.IPProcess;
+import org.eclipse.ptp.core.IPUniverse;
import org.eclipse.ptp.internal.ui.search.IPSearchConstants;
import org.eclipse.ptp.internal.ui.search.PSearchQuery;
import org.eclipse.ptp.internal.ui.search.SelectionConverter;
@@ -283,13 +289,10 @@
int limitTo = LIMIT_NUMBER;
String pattern = String.valueOf(element.getID());
- switch (element.getElementType()) {
- case IPElement.P_NODE:
- searchFor = SEARCH_NODE;
- break;
- case IPElement.P_PROCESS:
- searchFor = SEARCH_PROCESS;
- break;
+ if (element instanceof IPNode) {
+ searchFor = SEARCH_NODE;
+ } else if (element instanceof IPProcess) {
+ searchFor = SEARCH_PROCESS;
}
return new SearchPatternData(searchFor, limitTo, pattern, element);
}
Index: src/org/eclipse/ptp/ui/old/ParallelElementContentProvider.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/old/ParallelElementContentProvider.java,v
retrieving revision 1.1
diff -u -r1.1 ParallelElementContentProvider.java
--- src/org/eclipse/ptp/ui/old/ParallelElementContentProvider.java 2 Aug 2005 23:19:46 -0000 1.1
+++ src/org/eclipse/ptp/ui/old/ParallelElementContentProvider.java 6 Jun 2006 17:47:58 -0000
@@ -121,7 +121,7 @@
}
if (element instanceof IPNode) {
- if (((IPNode)element).hasChildren())
+ if (((IPNode)element).hasChildProcesses())
return true;
}
@@ -151,20 +151,18 @@
protected Object internalGetParent(Object element) {
if (element instanceof IPProcess)
- return ((IPProcess)element).getParent();
+ return ((IPProcess)element).getParentProcess();
return null;
}
protected Object[] getPNodes(IPJob root) {
- return root.getSortedChildren();
+ return root.getSortedNodes();
}
protected Object[] getPProcesses(IPNode node) throws ParallelModeException {
- if (node.hasChildren())
- return NO_CHILDREN;
-
- return node.getSortedChildren();
+ final IPProcess[] sortedProcesses = node.getSortedProcesses();
+ return sortedProcesses;
/*
IPProcess[] processes = node.getProcesses();
List list = new ArrayList(processes.length);
Index: src/org/eclipse/ptp/internal/ui/ParallelImages.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/ParallelImages.java,v
retrieving revision 1.7
diff -u -r1.7 ParallelImages.java
--- src/org/eclipse/ptp/internal/ui/ParallelImages.java 11 Apr 2006 02:56:04 -0000 1.7
+++ src/org/eclipse/ptp/internal/ui/ParallelImages.java 6 Jun 2006 17:47:57 -0000
@@ -26,19 +26,25 @@
import org.eclipse.ptp.ui.PTPUIPlugin;
import org.eclipse.swt.graphics.Image;
-public class ParallelImages {
+public class ParallelImages {
+
+ // ==== URLs for Icon Folders ====
+
public final static URL ICONURL = PTPUIPlugin.getDefault().getBundle().getEntry("icons/");
public final static URL TOOLICONURL = PTPUIPlugin.getDefault().getBundle().getEntry("icons/tool/");
public final static URL PROCESSICONURL = PTPUIPlugin.getDefault().getBundle().getEntry("icons/process/");
public final static URL NODEICONURL = PTPUIPlugin.getDefault().getBundle().getEntry("icons/node/");
+ public final static URL RMICONURL = PTPUIPlugin.getDefault().getBundle().getEntry("icons/rm/");
- private static ImageRegistry imageRegistry = null;
-
+ // ===== Icon Files =====
+
+ // CHANGE/DELETE SET
public static final String ICON_CHANGESET_NORMAL = "changeset_normal.gif";
public static final String ICON_CREATESET_NORMAL = "createset_normal.gif";
public static final String ICON_DELETESET_NORMAL = "deleteset_normal.gif";
public static final String ICON_DELETEELEMENT_NORMAL = "deleteelement_normal.gif";
+ // MACHINE
public static final String ICON_MACHINE_NORMAL = "machine_normal.gif";
public static final String ICON_JOB_NORMAL = "job_normal.gif";
public static final String ICON_TERMINATE_ALL_DISABLE = "terminate_all_disable.gif";
@@ -47,10 +53,10 @@
public static final String ICON_DEBUGMODE_NORMAL = "debugmode_normal.gif";
public static final String ICON_REMOVEALLTERMINATED_NORMAL = "remove_all_terminated_normal.gif";
- //SHOW LEGEND ICON
+ // SHOW LEGEND
public static final String ICON_SHOWLEGEND_ACTION_NORMAL = "legend.gif";
- //NODE
+ // NODE
public static final String IMG_NODE_USER_ALLOC_EXCL = "node_user_excl.gif";
public static final String IMG_NODE_USER_ALLOC_EXCL_SEL = "node_user_excl_sel.gif";
public static final String IMG_NODE_USER_ALLOC_SHARED = "node_user_shared.gif";
@@ -72,7 +78,7 @@
public static final String IMG_NODE_UP = "node_up.gif";
public static final String IMG_NODE_UP_SEL = "node_up_sel.gif";
- //PROCESS
+ // PROCESS
public static final String IMG_PROC_ERROR = "proc_error.gif";
public static final String IMG_PROC_ERROR_SEL = "proc_error_sel.gif";
public static final String IMG_PROC_EXITED = "proc_exited.gif";
@@ -86,10 +92,23 @@
public static final String IMG_PROC_STOPPED = "proc_stopped.gif";
public static final String IMG_PROC_STOPPED_SEL = "proc_stopped_sel.gif";
+ // RESOURCE MANAGERS
+ public static final String IMG_RM_OFF = "rm_off.gif";
+ public static final String IMG_RM_ON = "rm_on.gif";
+ public static final String IMG_RM_CURRENT = "rm_current.gif";
+ public static final String IMG_RM_ERROR = "rm_error.gif";
+ public static final String IMG_RM_START = "start.gif";
+ public static final String IMG_RM_STOP = "stop.gif";
+
+ // ==== Image Descriptors ====
+
+ // CHANGE/DELETE SET
public static final ImageDescriptor ID_ICON_CHANGESET_NORMAL = createImageDescriptor(TOOLICONURL, ICON_CHANGESET_NORMAL, ICON_CHANGESET_NORMAL);
public static final ImageDescriptor ID_ICON_CREATESET_NORMAL = createImageDescriptor(TOOLICONURL, ICON_CREATESET_NORMAL, ICON_CREATESET_NORMAL);
public static final ImageDescriptor ID_ICON_DELETESET_NORMAL = createImageDescriptor(TOOLICONURL, ICON_DELETESET_NORMAL, ICON_DELETESET_NORMAL);
public static final ImageDescriptor ID_ICON_DELETEELEMENT_NORMAL = createImageDescriptor(TOOLICONURL, ICON_DELETEELEMENT_NORMAL, ICON_DELETEELEMENT_NORMAL);
+
+ // MACHINE
public static final ImageDescriptor ID_ICON_MACHINE_NORMAL = createImageDescriptor(TOOLICONURL, ICON_MACHINE_NORMAL, ICON_MACHINE_NORMAL);
public static final ImageDescriptor ID_ICON_JOB_NORMAL = createImageDescriptor(TOOLICONURL, ICON_JOB_NORMAL, ICON_JOB_NORMAL);
public static final ImageDescriptor ID_ICON_TERMINATE_ALL_DISABLE = createImageDescriptor(TOOLICONURL, ICON_TERMINATE_ALL_DISABLE, ICON_TERMINATE_ALL_DISABLE);
@@ -98,8 +117,10 @@
public static final ImageDescriptor ID_ICON_DEBUGMODE_NORMAL = createImageDescriptor(TOOLICONURL, ICON_DEBUGMODE_NORMAL, ICON_DEBUGMODE_NORMAL);
public static final ImageDescriptor ID_ICON_REMOVEALLTERMINATED_NORMAL = createImageDescriptor(TOOLICONURL, ICON_REMOVEALLTERMINATED_NORMAL, ICON_REMOVEALLTERMINATED_NORMAL);
+ // SHOW LEGEND
public static final ImageDescriptor ID_ICON_SHOWLEGEND_ACTION_NORMAL = createImageDescriptor(TOOLICONURL, ICON_SHOWLEGEND_ACTION_NORMAL, ICON_SHOWLEGEND_ACTION_NORMAL);
+ // NODE
public static final ImageDescriptor ID_IMG_NODE_USER_ALLOC_EXCL = createImageDescriptor(NODEICONURL, IMG_NODE_USER_ALLOC_EXCL, IMG_NODE_USER_ALLOC_EXCL);
public static final ImageDescriptor ID_IMG_NODE_USER_ALLOC_EXCL_SEL = createImageDescriptor(NODEICONURL, IMG_NODE_USER_ALLOC_EXCL_SEL, IMG_NODE_USER_ALLOC_EXCL_SEL);
public static final ImageDescriptor ID_IMG_NODE_USER_ALLOC_SHARED = createImageDescriptor(NODEICONURL, IMG_NODE_USER_ALLOC_SHARED, IMG_NODE_USER_ALLOC_SHARED);
@@ -121,6 +142,7 @@
public static final ImageDescriptor ID_IMG_NODE_UP = createImageDescriptor(NODEICONURL, IMG_NODE_UP, IMG_NODE_UP);
public static final ImageDescriptor ID_IMG_NODE_UP_SEL = createImageDescriptor(NODEICONURL, IMG_NODE_UP_SEL, IMG_NODE_UP_SEL);
+ // PROCESS
public static final ImageDescriptor ID_IMG_PROC_ERROR = createImageDescriptor(PROCESSICONURL, IMG_PROC_ERROR, IMG_PROC_ERROR);
public static final ImageDescriptor ID_IMG_PROC_ERROR_SEL = createImageDescriptor(PROCESSICONURL, IMG_PROC_ERROR_SEL, IMG_PROC_ERROR_SEL);
public static final ImageDescriptor ID_IMG_PROC_EXITED = createImageDescriptor(PROCESSICONURL, IMG_PROC_EXITED, IMG_PROC_EXITED);
@@ -134,17 +156,57 @@
public static final ImageDescriptor ID_IMG_PROC_STOPPED = createImageDescriptor(PROCESSICONURL, IMG_PROC_STOPPED, IMG_PROC_STOPPED);
public static final ImageDescriptor ID_IMG_PROC_STOPPED_SEL = createImageDescriptor(PROCESSICONURL, IMG_PROC_STOPPED_SEL, IMG_PROC_STOPPED_SEL);
- public static final Image[][] nodeImages = { { getImage(ParallelImages.IMG_NODE_USER_ALLOC_EXCL), getImage(ParallelImages.IMG_NODE_USER_ALLOC_EXCL_SEL) },
- { getImage(ParallelImages.IMG_NODE_USER_ALLOC_SHARED), getImage(ParallelImages.IMG_NODE_USER_ALLOC_SHARED_SEL) }, { getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_EXCL), getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_EXCL_SEL) },
- { getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_SHARED), getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_SHARED_SEL) }, { getImage(ParallelImages.IMG_NODE_DOWN), getImage(ParallelImages.IMG_NODE_DOWN_SEL) },
- { getImage(ParallelImages.IMG_NODE_ERROR), getImage(ParallelImages.IMG_NODE_ERROR_SEL) }, { getImage(ParallelImages.IMG_NODE_EXITED), getImage(ParallelImages.IMG_NODE_EXITED_SEL) },
- { getImage(ParallelImages.IMG_NODE_RUNNING), getImage(ParallelImages.IMG_NODE_RUNNING_SEL) }, { getImage(ParallelImages.IMG_NODE_UNKNOWN), getImage(ParallelImages.IMG_NODE_UNKNOWN_SEL) },
- { getImage(ParallelImages.IMG_NODE_UP), getImage(ParallelImages.IMG_NODE_UP_SEL) } };
- public static final Image[][] procImages = { { getImage(ParallelImages.IMG_PROC_ERROR), getImage(ParallelImages.IMG_PROC_ERROR_SEL) }, { getImage(ParallelImages.IMG_PROC_EXITED), getImage(ParallelImages.IMG_PROC_EXITED_SEL) },
- { getImage(ParallelImages.IMG_PROC_EXITED_SIGNAL), getImage(ParallelImages.IMG_PROC_EXITED_SIGNAL_SEL) }, { getImage(ParallelImages.IMG_PROC_RUNNING), getImage(ParallelImages.IMG_PROC_RUNNING_SEL) },
- { getImage(ParallelImages.IMG_PROC_STARTING), getImage(ParallelImages.IMG_PROC_STARTING_SEL) }, { getImage(ParallelImages.IMG_PROC_STOPPED), getImage(ParallelImages.IMG_PROC_STOPPED_SEL) } };
- public static Image[] jobImages = { getImage(ParallelImages.ICON_RUNMODE_NORMAL), getImage(ParallelImages.ICON_DEBUGMODE_NORMAL), getImage(ParallelImages.ICON_TERMINATE_ALL_NORMAL) };
+ // RESOURCE MANAGERS
+ public static final ImageDescriptor ID_IMG_RM_OFF = createImageDescriptor(RMICONURL, IMG_RM_OFF, IMG_RM_OFF);
+ public static final ImageDescriptor ID_IMG_RM_ON = createImageDescriptor(RMICONURL, IMG_RM_ON, IMG_RM_ON);
+ public static final ImageDescriptor ID_IMG_RM_CURRENT = createImageDescriptor(RMICONURL, IMG_RM_CURRENT, IMG_RM_CURRENT);
+ public static final ImageDescriptor ID_IMG_RM_ERROR = createImageDescriptor(RMICONURL, IMG_RM_ERROR, IMG_RM_ERROR);
+ public static final ImageDescriptor ID_IMG_RM_START= createImageDescriptor(RMICONURL, IMG_RM_START, IMG_RM_START);
+ public static final ImageDescriptor ID_IMG_RM_STOP = createImageDescriptor(RMICONURL, IMG_RM_STOP, IMG_RM_STOP);
+
+ // ==== Image Arrays ====
+
+ // NODE
+ public static final Image[][] nodeImages = {
+ { getImage(ParallelImages.IMG_NODE_USER_ALLOC_EXCL), getImage(ParallelImages.IMG_NODE_USER_ALLOC_EXCL_SEL) },
+ { getImage(ParallelImages.IMG_NODE_USER_ALLOC_SHARED), getImage(ParallelImages.IMG_NODE_USER_ALLOC_SHARED_SEL) },
+ { getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_EXCL), getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_EXCL_SEL) },
+ { getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_SHARED), getImage(ParallelImages.IMG_NODE_OTHER_ALLOC_SHARED_SEL) },
+ { getImage(ParallelImages.IMG_NODE_DOWN), getImage(ParallelImages.IMG_NODE_DOWN_SEL) },
+ { getImage(ParallelImages.IMG_NODE_ERROR), getImage(ParallelImages.IMG_NODE_ERROR_SEL) },
+ { getImage(ParallelImages.IMG_NODE_EXITED), getImage(ParallelImages.IMG_NODE_EXITED_SEL) },
+ { getImage(ParallelImages.IMG_NODE_RUNNING), getImage(ParallelImages.IMG_NODE_RUNNING_SEL) },
+ { getImage(ParallelImages.IMG_NODE_UNKNOWN), getImage(ParallelImages.IMG_NODE_UNKNOWN_SEL) },
+ { getImage(ParallelImages.IMG_NODE_UP), getImage(ParallelImages.IMG_NODE_UP_SEL) }
+ };
+
+ // JOB
+ public static Image[] jobImages = {
+ getImage(ParallelImages.ICON_RUNMODE_NORMAL),
+ getImage(ParallelImages.ICON_DEBUGMODE_NORMAL),
+ getImage(ParallelImages.ICON_TERMINATE_ALL_NORMAL)
+ };
+
+ // PROCESS
+ public static final Image[][] procImages = {
+ { getImage(ParallelImages.IMG_PROC_ERROR), getImage(ParallelImages.IMG_PROC_ERROR_SEL) },
+ { getImage(ParallelImages.IMG_PROC_EXITED), getImage(ParallelImages.IMG_PROC_EXITED_SEL) },
+ { getImage(ParallelImages.IMG_PROC_EXITED_SIGNAL), getImage(ParallelImages.IMG_PROC_EXITED_SIGNAL_SEL) },
+ { getImage(ParallelImages.IMG_PROC_RUNNING), getImage(ParallelImages.IMG_PROC_RUNNING_SEL) },
+ { getImage(ParallelImages.IMG_PROC_STARTING), getImage(ParallelImages.IMG_PROC_STARTING_SEL) },
+ { getImage(ParallelImages.IMG_PROC_STOPPED), getImage(ParallelImages.IMG_PROC_STOPPED_SEL) }
+ };
+
+ // RESOURCE MANAGERS
+ public static Image[] rmImages = {
+ getImage(ParallelImages.IMG_RM_OFF),
+ getImage(ParallelImages.IMG_RM_ON),
+ getImage(ParallelImages.IMG_RM_CURRENT),
+ getImage(ParallelImages.IMG_RM_ERROR)
+ };
+ private static ImageRegistry imageRegistry = null;
+
/** Get image
* @param key
* @return
Index: src/org/eclipse/ptp/internal/ui/AbstractUIManager.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/AbstractUIManager.java,v
retrieving revision 1.18
diff -u -r1.18 AbstractUIManager.java
--- src/org/eclipse/ptp/internal/ui/AbstractUIManager.java 11 Apr 2006 02:56:04 -0000 1.18
+++ src/org/eclipse/ptp/internal/ui/AbstractUIManager.java 6 Jun 2006 17:47:57 -0000
@@ -22,13 +22,13 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.ptp.core.IModelManager;
-import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.core.IModelPresentation;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPUniverse;
import org.eclipse.ptp.core.PTPCorePlugin;
@@ -47,7 +47,7 @@
*
*/
public abstract class AbstractUIManager implements IManager {
- protected IModelManager modelManager = null;
+ protected IModelPresentation modelPresentation = null;
protected String cur_set_id = EMPTY_ID;
protected List pListeners = new ArrayList(0);
protected List setListeners = new ArrayList(0);
@@ -56,7 +56,7 @@
*
*/
public AbstractUIManager() {
- modelManager = PTPCorePlugin.getDefault().getModelManager();
+ modelPresentation = PTPCorePlugin.getDefault().getModelPresentation();
}
protected abstract class SafeNotifier implements ISafeRunnable {
@@ -230,7 +230,7 @@
* @see org.eclipse.ptp.ui.IManager#findJob(java.lang.String)
*/
public IPJob findJob(String job_name) {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe == null)
return null;
return universe.findJobByName(job_name);
@@ -239,19 +239,18 @@
* @see org.eclipse.ptp.ui.IManager#findJobById(java.lang.String)
*/
public IPJob findJobById(String job_id) {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe == null)
return null;
- IPElement element = universe.findChild(job_id);
- if (element instanceof IPJob)
- return (IPJob) element;
- return null;
+ // IPElement element = universe.findChild(job_id);
+ IPJob job = universe.findJobById(job_id);
+ return job;
}
/* (non-Javadoc)
* @see org.eclipse.ptp.ui.IManager#removeJob(org.eclipse.ptp.core.IPJob)
*/
public void removeJob(IPJob job) {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe != null) {
universe.deleteJob(job);
}
@@ -265,7 +264,7 @@
if (pmonitor == null)
pmonitor = new NullProgressMonitor();
try {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe != null) {
IPJob[] jobs = universe.getJobs();
pmonitor.beginTask("Removing stopped jobs...", jobs.length);
@@ -295,7 +294,7 @@
* @see org.eclipse.ptp.ui.IManager#hasStoppedJob()
*/
public boolean hasStoppedJob() {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe == null)
return false;
Index: src/org/eclipse/ptp/internal/ui/PRunPerspectiveFactory.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/PRunPerspectiveFactory.java,v
retrieving revision 1.6
diff -u -r1.6 PRunPerspectiveFactory.java
--- src/org/eclipse/ptp/internal/ui/PRunPerspectiveFactory.java 11 Apr 2006 02:56:04 -0000 1.6
+++ src/org/eclipse/ptp/internal/ui/PRunPerspectiveFactory.java 6 Jun 2006 17:47:57 -0000
@@ -37,6 +37,7 @@
IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea);
folder1.addView(IPTPUIConstants.VIEW_PARALLELMACHINE);
folder1.addView(IPTPUIConstants.VIEW_PARALLELJOB);
+ folder1.addView(IPTPUIConstants.VIEW_RESOURCEMANAGER);
folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
Index: src/org/eclipse/ptp/internal/ui/JobManager.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/JobManager.java,v
retrieving revision 1.24
diff -u -r1.24 JobManager.java
--- src/org/eclipse/ptp/internal/ui/JobManager.java 11 Apr 2006 02:56:04 -0000 1.24
+++ src/org/eclipse/ptp/internal/ui/JobManager.java 6 Jun 2006 17:47:57 -0000
@@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPJob;
import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.core.IPUniverse;
@@ -51,7 +50,7 @@
*/
public void shutdown() {
clear();
- modelManager = null;
+ modelPresentation = null;
jobChangeListeners.clear();
jobChangeListeners = null;
super.shutdown();
@@ -103,7 +102,7 @@
* @return jobs
*/
public IPJob[] getJobs() {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe == null) {
return new IPJob[0];
}
@@ -226,10 +225,10 @@
* @see org.eclipse.ptp.ui.IManager#getName(java.lang.String)
*/
public String getName(String id) {
- IPElement element = findJobById(id);
- if (element == null)
+ IPJob job = findJobById(id);
+ if (job == null)
return "";
- return element.getElementName();
+ return job.getName();
}
/** Add a job
* @param job
@@ -321,7 +320,7 @@
* @throws CoreException
*/
public void terminateAll(String job_id) throws CoreException {
- modelManager.abortJob(getName(job_id));
+ modelPresentation.abortJob(getName(job_id));
}
/* (non-Javadoc)
Index: src/org/eclipse/ptp/internal/ui/MachineManager.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/MachineManager.java,v
retrieving revision 1.30
diff -u -r1.30 MachineManager.java
--- src/org/eclipse/ptp/internal/ui/MachineManager.java 30 May 2006 16:46:00 -0000 1.30
+++ src/org/eclipse/ptp/internal/ui/MachineManager.java 6 Jun 2006 17:47:57 -0000
@@ -23,7 +23,6 @@
import org.eclipse.ptp.core.AttributeConstants;
import org.eclipse.ptp.core.INodeEvent;
import org.eclipse.ptp.core.INodeListener;
-import org.eclipse.ptp.core.IPElement;
import org.eclipse.ptp.core.IPMachine;
import org.eclipse.ptp.core.IPNode;
import org.eclipse.ptp.core.IPProcess;
@@ -33,8 +32,6 @@
import org.eclipse.ptp.ui.IPTPUIConstants;
import org.eclipse.ptp.ui.model.IElementHandler;
import org.eclipse.ptp.ui.model.IElementSet;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.TableItem;
/**
* @author clement chu
@@ -49,7 +46,7 @@
*/
public void shutdown() {
clear();
- modelManager = null;
+ modelPresentation = null;
super.shutdown();
}
/** Is no machine
@@ -89,7 +86,7 @@
* @return machines
*/
public IPMachine[] getMachines() {
- IPUniverse universe = modelManager.getUniverse();
+ IPUniverse universe = modelPresentation.getUniverse();
if (universe == null) {
return new IPMachine[0];
}
@@ -207,7 +204,7 @@
return IPTPUIConstants.NODE_UNKNOWN;
}
if (nodeState.equals(IPNode.NODE_STATE_UP)) {
- if (node.size() > 0)
+ if (node.getNumProcesses() > 0)
return (node.isAllStop() ? IPTPUIConstants.NODE_EXITED : IPTPUIConstants.NODE_RUNNING);
if (node.getAttribute(AttributeConstants.ATTRIB_NODE_USER).equals(System.getProperty("user.name"))) {
String mode = (String) node.getAttribute(AttributeConstants.ATTRIB_NODE_MODE);
@@ -262,26 +259,25 @@
* @return
*/
public IPMachine findMachine(String machine_name) {
- return (IPMachine) modelManager.getUniverse().findMachineByName(machine_name);
+ return (IPMachine) modelPresentation.getUniverse().findMachineByName(machine_name);
}
+
/** find machine by ID
* @param machine_id machine ID
* @return
*/
public IPMachine findMachineById(String machine_id) {
- IPElement element = modelManager.getUniverse().findChild(machine_id);
- if (element instanceof IPMachine)
- return (IPMachine) element;
- return null;
+ return modelPresentation.getUniverse().findMachineById(machine_id);
}
+
/* (non-Javadoc)
* @see org.eclipse.ptp.ui.IManager#getName(java.lang.String)
*/
public String getName(String id) {
- IPElement element = findMachineById(id);
- if (element == null)
+ IPMachine machine = findMachineById(id);
+ if (machine == null)
return "";
- return element.getElementName();
+ return machine.getName();
}
/** Add machine
* @param mac machine
@@ -297,7 +293,7 @@
IElementSet set = elementHandler.getSetRoot();
for (int i = 0; i < total_element; i++) {
pNodes[i].addNodeListener(this);
- set.add(new Element(set, pNodes[i].getIDString(), pNodes[i].getElementName()));
+ set.add(new Element(set, pNodes[i].getIDString(), pNodes[i].getName()));
}
elementHandler.add(set);
machineList.put(mac.getIDString(), elementHandler);
@@ -343,4 +339,4 @@
return false;
return set.contains(nodeID);
}
-}
+}
\ No newline at end of file
Index: src/org/eclipse/ptp/ui/SearchDialog.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/SearchDialog.java,v
retrieving revision 1.4
diff -u -r1.4 SearchDialog.java
--- src/org/eclipse/ptp/ui/SearchDialog.java 5 Aug 2005 15:59:53 -0000 1.4
+++ src/org/eclipse/ptp/ui/SearchDialog.java 6 Jun 2006 17:47:58 -0000
@@ -27,12 +27,15 @@
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ptp.core.IPElement;
+import org.eclipse.ptp.core.IPNode;
+import org.eclipse.ptp.core.IPProcess;
import org.eclipse.ptp.internal.ui.search.IPSearchConstants;
import org.eclipse.ptp.internal.ui.search.PSearchQuery;
import org.eclipse.ptp.internal.ui.search.SelectionConverter;
@@ -282,15 +285,11 @@
int searchFor = SEARCH_NODE;
int limitTo = LIMIT_NUMBER;
- String pattern = String.valueOf(element.getID());
- switch (element.getElementType()) {
- case IPElement.P_NODE:
- searchFor = SEARCH_NODE;
- break;
- case IPElement.P_PROCESS:
- searchFor = SEARCH_PROCESS;
- break;
- }
+ String pattern = String.valueOf(element.getID());
+ if (element instanceof IPNode)
+ searchFor = SEARCH_NODE;
+ else if (element instanceof IPProcess)
+ searchFor = SEARCH_PROCESS;
return new SearchPatternData(searchFor, limitTo, pattern, element);
}
Index: src/org/eclipse/ptp/ui/IPTPUIConstants.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/IPTPUIConstants.java,v
retrieving revision 1.9
diff -u -r1.9 IPTPUIConstants.java
--- src/org/eclipse/ptp/ui/IPTPUIConstants.java 4 Apr 2006 06:54:01 -0000 1.9
+++ src/org/eclipse/ptp/ui/IPTPUIConstants.java 6 Jun 2006 17:47:58 -0000
@@ -29,7 +29,8 @@
public static final String VIEW_PARALLELMACHINE = PREFIX + "views.parallelMachineView";
public static final String VIEW_PARALLELJOB = PREFIX + "views.parallelJobView";
public static final String VIEW_PARALLELProcess = PREFIX + "views.parallelProcessView";
-
+ public static final String VIEW_RESOURCEMANAGER = PREFIX + "views.resourceManagerView";
+
public static final String PERSPECTIVE_RUN = PREFIX + "PTPRunPerspective";
public static final String SEARCH_PAGE = PREFIX + "PSearchPage";
Index: src/org/eclipse/ptp/ui/PTPUIPlugin.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/PTPUIPlugin.java,v
retrieving revision 1.21
diff -u -r1.21 PTPUIPlugin.java
--- src/org/eclipse/ptp/ui/PTPUIPlugin.java 7 Apr 2006 02:39:37 -0000 1.21
+++ src/org/eclipse/ptp/ui/PTPUIPlugin.java 6 Jun 2006 17:47:58 -0000
@@ -245,7 +245,7 @@
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
- PTPCorePlugin.getDefault().getModelManager().refreshRuntimeSystems(monitor, force);
+ PTPCorePlugin.getDefault().getModelPresentation().refreshRuntimeSystems(monitor, force);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
@@ -267,7 +267,7 @@
public IStatus run(final IProgressMonitor monitor) {
if (!monitor.isCanceled()) {
try {
- PTPCorePlugin.getDefault().getModelManager().refreshRuntimeSystems(monitor, force);
+ PTPCorePlugin.getDefault().getModelPresentation().refreshRuntimeSystems(monitor, force);
} catch (CoreException e) {
return e.getStatus();
}
Index: src/org/eclipse/ptp/ui/views/ParallelJobView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/ParallelJobView.java,v
retrieving revision 1.40
diff -u -r1.40 ParallelJobView.java
--- src/org/eclipse/ptp/ui/views/ParallelJobView.java 12 May 2006 19:06:29 -0000 1.40
+++ src/org/eclipse/ptp/ui/views/ParallelJobView.java 6 Jun 2006 17:47:58 -0000
@@ -149,7 +149,7 @@
jobTableViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
if (element instanceof IPJob) {
- return ((IPJob) element).getElementName();
+ return ((IPJob) element).getName();
}
return "";
}
Index: src/org/eclipse/ptp/ui/views/ParallelProcessView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/ParallelProcessView.java,v
retrieving revision 1.5
diff -u -r1.5 ParallelProcessView.java
--- src/org/eclipse/ptp/ui/views/ParallelProcessView.java 2 Feb 2006 15:40:14 -0000 1.5
+++ src/org/eclipse/ptp/ui/views/ParallelProcessView.java 6 Jun 2006 17:47:58 -0000
@@ -70,10 +70,10 @@
public ParallelProcessView() {
super();
setDocumentProvider(new StorageDocumentProvider());
- PTPCorePlugin.getDefault().getModelManager().addParallelLaunchListener(launchAdapter);
+ PTPCorePlugin.getDefault().getModelPresentation().addParallelLaunchListener(launchAdapter);
}
public void dispose() {
- PTPCorePlugin.getDefault().getModelManager().removeParallelLaunchListener(launchAdapter);
+ PTPCorePlugin.getDefault().getModelPresentation().removeParallelLaunchListener(launchAdapter);
getProcess().removerProcessListener(this);
myForm.dispose();
toolkit.dispose();
@@ -168,8 +168,8 @@
IPProcess process = getProcess();
if (process != null) {
rankLabel.setText("Rank: " + process.getProcessNumber());
- totalLabel.setText("Total: " + process.getParent().size());
- nodeLabel.setText("Node: " + ((IPNode) process.getNode()).getNodeNumber());
+ totalLabel.setText("Total: " + process.getNode().getNumProcesses());
+ nodeLabel.setText("Node: " + process.getNode().getNodeNumber());
jobLabel.setText("Job: " + process.getJob().getJobNumber());
pidLabel.setText("PID: " + process.getPid());
statusLabel.setText("Status: " + process.getStatus());
Index: src/org/eclipse/ptp/ui/views/AbstractParallelView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/AbstractParallelView.java,v
retrieving revision 1.10
diff -u -r1.10 AbstractParallelView.java
--- src/org/eclipse/ptp/ui/views/AbstractParallelView.java 11 Apr 2006 02:56:04 -0000 1.10
+++ src/org/eclipse/ptp/ui/views/AbstractParallelView.java 6 Jun 2006 17:47:58 -0000
@@ -43,7 +43,7 @@
*
*/
public AbstractParallelView() {
- PTPCorePlugin.getDefault().getModelManager().addParallelLaunchListener(this);
+ PTPCorePlugin.getDefault().getModelPresentation().addParallelLaunchListener(this);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
@@ -62,7 +62,7 @@
*/
public void dispose() {
listeners.clear();
- PTPCorePlugin.getDefault().getModelManager().removeParallelLaunchListener(this);
+ PTPCorePlugin.getDefault().getModelPresentation().removeParallelLaunchListener(this);
super.dispose();
}
Index: src/org/eclipse/ptp/ui/views/ProcessEditorInput.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/ui/views/ProcessEditorInput.java,v
retrieving revision 1.4
diff -u -r1.4 ProcessEditorInput.java
--- src/org/eclipse/ptp/ui/views/ProcessEditorInput.java 11 Apr 2006 02:56:04 -0000 1.4
+++ src/org/eclipse/ptp/ui/views/ProcessEditorInput.java 6 Jun 2006 17:47:58 -0000
@@ -87,7 +87,7 @@
* @see org.eclipse.ui.IEditorInput#getName()
*/
public String getName() {
- return process.getElementName();
+ return process.getName();
}
/* (non-Javadoc)
Index: src/org/eclipse/ptp/internal/ui/actions/ChangeMachineAction.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.ptp/core/org.eclipse.ptp.ui/src/org/eclipse/ptp/internal/ui/actions/ChangeMachineAction.java,v
retrieving revision 1.7
diff -u -r1.7 ChangeMachineAction.java
--- src/org/eclipse/ptp/internal/ui/actions/ChangeMachineAction.java 11 Apr 2006 02:56:05 -0000 1.7
+++ src/org/eclipse/ptp/internal/ui/actions/ChangeMachineAction.java 6 Jun 2006 17:47:58 -0000
@@ -54,7 +54,7 @@
IPMachine[] macs = ((MachineManager)pmView.getUIManager()).getMachines();
for (int i=0; i<macs.length; i++) {
- addAction(dropDownMenuMgr, macs[i].getElementName(), macs[i].getIDString(), curMachineID);
+ addAction(dropDownMenuMgr, macs[i].getName(), macs[i].getIDString(), curMachineID);
}
}
}
Index: src/org/eclipse/ptp/ui/preferences/ResourceManagerPreferencesPage.java
===================================================================
RCS file: src/org/eclipse/ptp/ui/preferences/ResourceManagerPreferencesPage.java
diff -N src/org/eclipse/ptp/ui/preferences/ResourceManagerPreferencesPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/ui/preferences/ResourceManagerPreferencesPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,501 @@
+package org.eclipse.ptp.ui.preferences;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.Window;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.ptp.core.PTPCorePlugin;
+import org.eclipse.ptp.rmsystem.IResourceManager;
+import org.eclipse.ptp.rmsystem.IResourceManagerConfiguration;
+import org.eclipse.ptp.rmsystem.IResourceManagerFactory;
+import org.eclipse.ptp.rmsystem.ResourceManagerConfiguration;
+import org.eclipse.ptp.rmsystem.ResourceManagerStore;
+import org.eclipse.ptp.ui.PTPUIPlugin;
+
+/**
+ * Resource Manager preference page allows configuration of resource managers.
+ * It provides controls for adding, removing and changing resource managers.
+ *
+ */
+public class ResourceManagerPreferencesPage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ class ResourceManagerContentProvider implements IStructuredContentProvider {
+
+ private ResourceManagerStore store;
+
+ /*
+ * @see IStructuredContentProvider#getElements(Object)
+ */
+ public Object[] getElements(Object input) {
+ return store.getResourceManagers();
+ }
+
+ /*
+ * @see IContentProvider#inputChanged(Viewer, Object, Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ store = (ResourceManagerStore) newInput;
+ }
+
+ /*
+ * @see IContentProvider#dispose()
+ */
+ public void dispose() {
+ store = null;
+ }
+
+ }
+
+ private class ResourceManagerLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ /*
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
+ * int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /*
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
+ * int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ IResourceManager rm = (IResourceManager) element;
+ IResourceManagerConfiguration config = rm.getConfiguration();
+
+ switch (columnIndex) {
+ case 0:
+ return config.getName();
+ case 1:
+ return config.getResourceManagerId();
+ case 2:
+ return config.getHost().trim().length() > 0 ? config.getHost()
+ : ""; //$NON-NLS-1$
+ case 3:
+ return config.getPort() >= 0 ? new Integer(config.getPort())
+ .toString() : ""; //$NON-NLS-1$
+// case 4:
+// return config.getDescription();
+ default:
+ return ""; //$NON-NLS-1$
+ }
+ }
+ }
+
+ private class ResourceManagerViewerSorter extends ViewerSorter {
+
+ /*
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object object1, Object object2) {
+ if ((object1 instanceof IResourceManager)
+ && (object2 instanceof IResourceManager)) {
+ IResourceManager left = ((IResourceManager) object1);
+ IResourceManager right = ((IResourceManager) object2);
+ int result = left
+ .getConfiguration()
+ .getName()
+ .compareToIgnoreCase(right.getConfiguration().getName());
+ if (result != 0)
+ return result;
+ return left.getConfiguration().getDescription()
+ .compareToIgnoreCase(
+ right.getConfiguration().getDescription());
+ }
+ return super.compare(viewer, object1, object2);
+ }
+
+ /*
+ * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object,
+ * java.lang.String)
+ */
+ public boolean isSorterProperty(Object element, String property) {
+ return true;
+ }
+ }
+
+ /**
+ * The store for our resource managers.
+ */
+ private ResourceManagerStore fResourceManagerStore;
+
+ /**
+ * The table presenting the resource managers.
+ */
+ private TableViewer fTableViewer;
+
+ /* buttons */
+ private Button fAddButton;
+
+ private Button fEditButton;
+
+ private Button fRemoveButton;
+
+ /**
+ * Creates a new resource manager preference page.
+ */
+ public ResourceManagerPreferencesPage() {
+ super();
+ setPreferenceStore(PTPUIPlugin.getDefault().getPreferenceStore());
+ setDescription("Create, edit or remote resource managers:");
+ }
+
+ /*
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /*
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(data);
+
+ // Table
+
+ Table table = new Table(composite, SWT.BORDER | SWT.MULTI
+ | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ data = new GridData(GridData.FILL_BOTH);
+ table.setLayoutData(data);
+
+ TableLayout layout2 = new TableLayout();
+ table.setLayout(layout2);
+
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ column1.setText("Name");
+ column1.setWidth(100);
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ column2.setText("Type");
+ column2.setWidth(50);
+ TableColumn column3 = new TableColumn(table, SWT.NONE);
+ column3.setText("Host");
+ column3.setWidth(150);
+ TableColumn column4 = new TableColumn(table, SWT.NONE);
+ column4.setText("Port");
+ column4.setWidth(50);
+// TableColumn column5 = new TableColumn(table, SWT.NONE);
+// column5.setText("Description");
+// column4.setWidth(100);
+
+ fTableViewer = new TableViewer(table);
+ fTableViewer.setLabelProvider(new ResourceManagerLabelProvider());
+ fTableViewer.setContentProvider(new ResourceManagerContentProvider());
+ fTableViewer.setSorter(new ResourceManagerViewerSorter());
+
+ fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ edit();
+ }
+ });
+
+ fTableViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ handleSelectionChange();
+ }
+ });
+
+ // Buttons
+
+ Composite buttonsComposite = new Composite(composite, SWT.NONE);
+ buttonsComposite.setLayoutData(new GridData(
+ GridData.VERTICAL_ALIGN_BEGINNING));
+ layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ buttonsComposite.setLayout(layout);
+
+ fAddButton = new Button(buttonsComposite, SWT.PUSH);
+ fAddButton.setText("New...");
+ fAddButton.setLayoutData(getButtonGridData(fAddButton));
+ fAddButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ add();
+ }
+ });
+
+ fEditButton = new Button(buttonsComposite, SWT.PUSH);
+ fEditButton.setText("Edit...");
+ fEditButton.setLayoutData(getButtonGridData(fEditButton));
+ fEditButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ edit();
+ }
+ });
+
+ fRemoveButton = new Button(buttonsComposite, SWT.PUSH);
+ fRemoveButton.setText("Remote");
+ fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton));
+ fRemoveButton.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ remove();
+ }
+ });
+
+ updateButtons();
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
+
+ /**
+ * Creates a separator between buttons
+ *
+ * @param parent
+ * @return a separator
+ */
+ private Label createSeparator(Composite parent) {
+ Label separator = new Label(parent, SWT.NONE);
+ separator.setVisible(false);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.BEGINNING;
+ gd.heightHint = 4;
+ separator.setLayoutData(gd);
+ return separator;
+ }
+
+ private static GridData getButtonGridData(Button button) {
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ // TODO replace SWTUtil
+ // data.widthHint= SWTUtil.getButtonWidthHint(button);
+ // data.heightHint= SWTUtil.getButtonHeightHint(button);
+
+ return data;
+ }
+
+ private void handleSelectionChange() {
+ updateViewerInput();
+ updateButtons();
+ }
+
+ /**
+ * Updates the pattern viewer.
+ */
+ protected void updateViewerInput() {
+ IStructuredSelection selection = (IStructuredSelection) fTableViewer
+ .getSelection();
+
+ }
+
+ /**
+ * Updates the buttons.
+ */
+ protected void updateButtons() {
+ int selectionCount = 0;
+ IStructuredSelection selection = (IStructuredSelection) fTableViewer
+ .getSelection();
+ if (selection != null) selectionCount = selection.size();
+ int itemCount = fTableViewer.getTable().getItemCount();
+ fEditButton.setEnabled(selectionCount == 1);
+ fRemoveButton.setEnabled(selectionCount > 0
+ && selectionCount <= itemCount);
+ }
+
+ private void add() {
+
+ IResourceManagerFactory[] resourceManagers = PTPCorePlugin.getDefault()
+ .getResourceManagerFactories();
+
+ if (resourceManagers != null && resourceManagers.length > 0) {
+ String id = resourceManagers[0].getId();
+
+ IResourceManagerFactory factory = PTPCorePlugin.getDefault()
+ .getResourceManagerFactory(id);
+ IResourceManagerConfiguration config = new ResourceManagerConfiguration(
+ "", "", id, "", -1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IResourceManager rm = factory.create(config);
+
+ IResourceManager newRm = editResourceManager(rm, false);
+ if (newRm != null) {
+ fResourceManagerStore.add(newRm);
+ }
+ } else {
+ new MessageDialog(
+ getShell(),
+ "No Resource Manager Available",
+ null,
+ "We have not found a resource manager extension. Please verify your installation and make sure that resource manager plug-ins are correctly installed.",
+ MessageDialog.ERROR, new String[] { "OK" }, 0).open();
+ }
+ }
+
+ /**
+ * Creates the edit dialog. Subclasses may override this method to provide a
+ * custom dialog.
+ *
+ * @param rm
+ * the resource manager being edited
+ * @param edit
+ * whether the dialog should be editable
+ * @return the created or modified resource manager , or <code>null</code>
+ * if the edition failed
+ */
+ protected IResourceManager editResourceManager(IResourceManager rm, boolean edit) {
+ IResourceManagerFactory[] factories = PTPCorePlugin.getDefault()
+ .getResourceManagerFactories();
+
+ ResourceManagerEditDialog dialog = new ResourceManagerEditDialog(
+ getShell(), rm, edit, factories);
+ if (dialog.open() == Window.OK) {
+ return dialog.getResourceManager();
+ }
+ return null;
+ }
+
+ private void edit() {
+ IStructuredSelection selection = (IStructuredSelection) fTableViewer
+ .getSelection();
+
+ Object[] objects = selection.toArray();
+ if ((objects == null) || (objects.length != 1))
+ return;
+
+ IResourceManager rm = (IResourceManager) selection
+ .getFirstElement();
+ edit(rm);
+ }
+
+ private void edit(IResourceManager rm) {
+ IResourceManager oldRm = rm;
+ IResourceManager newRm = editResourceManager(oldRm, true);
+ if (newRm != null) {
+
+ if (!newRm.getConfiguration().getName().equals(
+ oldRm.getConfiguration().getName())
+ && MessageDialog.openQuestion(getShell(), "Create New",
+ "Create new resource manager?'")) {
+ rm = newRm;
+ fResourceManagerStore.add(rm);
+ fTableViewer.refresh();
+ } else {
+ oldRm = newRm;
+ fTableViewer.refresh(rm);
+ }
+ handleSelectionChange();
+ fTableViewer.setSelection(new StructuredSelection(rm));
+ }
+ }
+
+ private void remove() {
+ IStructuredSelection selection = (IStructuredSelection) fTableViewer
+ .getSelection();
+
+ Iterator elements = selection.iterator();
+ while (elements.hasNext()) {
+ IResourceManager rm = (IResourceManager) elements.next();
+ fResourceManagerStore.delete(rm);
+ }
+
+ fTableViewer.refresh();
+ }
+
+ /*
+ * @see Control#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible)
+ setTitle("Resource Managers");
+ }
+
+ /*
+ * @see PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ try {
+ fResourceManagerStore.save();
+ } catch (IOException e) {
+ openWriteErrorDialog();
+ }
+
+ return super.performOk();
+ }
+
+ /*
+ * @see PreferencePage#performCancel()
+ */
+ public boolean performCancel() {
+ try {
+ fResourceManagerStore.load();
+ } catch (IOException e) {
+ openReadErrorDialog();
+ return false;
+ }
+ return super.performCancel();
+ }
+
+ private void openReadErrorDialog() {
+ String title = "Error";
+ String message = "Error reading resource managers.";
+ MessageDialog.openError(getShell(), title, message);
+ }
+
+ private void openWriteErrorDialog() {
+ String title = "Error'";
+ String message = "Error saving resource managers";
+ MessageDialog.openError(getShell(), title, message);
+ }
+
+ public void setPreferenceStore(IPreferenceStore store) {
+ if (fResourceManagerStore == null) {
+ fResourceManagerStore = new ResourceManagerStore(store, RMS_KEY);
+ try {
+ fResourceManagerStore.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ super.setPreferenceStore(store);
+ }
+
+ private static final String RMS_KEY = "org.eclipse.ptp.resourcemanagers";
+}
Index: src/org/eclipse/ptp/ui/preferences/ResourceManagerEditDialog.java
===================================================================
RCS file: src/org/eclipse/ptp/ui/preferences/ResourceManagerEditDialog.java
diff -N src/org/eclipse/ptp/ui/preferences/ResourceManagerEditDialog.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/ui/preferences/ResourceManagerEditDialog.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,242 @@
+package org.eclipse.ptp.ui.preferences;
+
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.ptp.core.PTPCorePlugin;
+import org.eclipse.ptp.rmsystem.IResourceManager;
+import org.eclipse.ptp.rmsystem.IResourceManagerConfiguration;
+import org.eclipse.ptp.rmsystem.IResourceManagerFactory;
+import org.eclipse.ptp.rmsystem.ResourceManagerConfiguration;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Dialog to edit a resource manager.
+ *
+ */
+class ResourceManagerEditDialog extends StatusDialog {
+
+ private final IResourceManager fOriginalResourceManager;
+ private IResourceManagerFactory[] fResourceManagerFactories;
+ private IResourceManager fNewResourceManager;
+
+ private Text fNameText;
+ private Text fDescriptionText;
+ private Text fHostText;
+ private Text fPortText;
+ private Combo fRMCombo;
+ private boolean fIsNameModifiable;
+
+// private StatusInfo fValidationStatus;
+
+ /**
+ * Creates a new dialog.
+ *
+ * @param parent the shell parent of the dialog
+ * @param rm the resource manager to edit
+ * @param edit whether this is a new resource manager or an existing being edited
+ * @param factories the resource manager factories to use
+ */
+ public ResourceManagerEditDialog(Shell parent, IResourceManager rm, boolean edit, IResourceManagerFactory[] factories) {
+ super(parent);
+
+ setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
+
+ setTitle(edit ? "Edit ResourceManager" : "New ResourceManager");
+
+ fOriginalResourceManager = rm;
+
+ fResourceManagerFactories = factories;
+// fValidationStatus= new StatusInfo();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.targets.StatusDialog#create()
+ */
+ public void create() {
+ super.create();
+ // update initial OK button to be disabled for new targets
+ boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
+ if (!valid) {
+// StatusInfo status = new StatusInfo();
+// status.setError(TextEditorResourceManagerMessages.EditResourceManagerDialog_error_noname);
+// updateButtonsEnableState(status);
+ }
+ }
+
+ /*
+ * @see Dialog#createDialogArea(Composite)
+ */
+ protected Control createDialogArea(Composite ancestor) {
+ Composite parent= new Composite(ancestor, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 2;
+ parent.setLayout(layout);
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ ModifyListener listener= new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ doTextWidgetChanged(e.widget);
+ }
+ };
+
+ createLabel(parent, "Name:");
+
+ Composite composite= new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ layout= new GridLayout();
+ layout.numColumns= 4;
+ layout.marginWidth= 0;
+ layout.marginHeight= 0;
+ composite.setLayout(layout);
+
+ // Name
+ fNameText= createText(composite);
+ fNameText.addModifyListener(listener);
+ fNameText.addFocusListener(new FocusListener() {
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ public void focusLost(FocusEvent e) {
+// if (fSuppressError) {
+// fSuppressError= false;
+// updateButtons();
+// }
+ }
+ });
+
+ // Resource Manager
+ createLabel(composite, "Resource Manager");
+ fRMCombo= new Combo(composite, SWT.READ_ONLY);
+
+ for (int i= 0; i < fResourceManagerFactories.length; i++) {
+ fRMCombo.add(fResourceManagerFactories[i].getName());
+ }
+ fRMCombo.addModifyListener(listener);
+
+ // Description
+ createLabel(parent, "Description");
+ int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
+ fDescriptionText= new Text(parent, descFlags);
+ fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fDescriptionText.addModifyListener(listener);
+
+ IResourceManagerConfiguration configuration = fOriginalResourceManager.getConfiguration();
+ fDescriptionText.setText(configuration.getDescription());
+ fNameText.setText(configuration.getName());
+ fNameText.addModifyListener(listener);
+ fHostText.setText(configuration.getHost());
+ fPortText.setText(new Integer(configuration.getPort()).toString());
+ fRMCombo.select(getIndex(configuration.getResourceManagerId()));
+
+ applyDialogFont(parent);
+ return composite;
+ }
+
+ private void doTextWidgetChanged(Widget w) {
+// if (w == fNameText) {
+// fSuppressError= false;
+// updateButtons();
+// } else if (w == fRMCombo) {
+// String contextId= getContextId();
+// fResourceManagerProcessor.setContextType(fContextTypeRegistry.getContextType(contextId));
+// } else if (w == fDescriptionText) {
+// // oh, nothing
+// }
+ }
+
+ private String getRMId() {
+ if (fRMCombo != null && !fRMCombo.isDisposed()) {
+ String name= fRMCombo.getText();
+ for (int i= 0; i < fResourceManagerFactories.length; i++) {
+ if (name.equals(fResourceManagerFactories[i].getName())) {
+ return fResourceManagerFactories[i].getId();
+ }
+ }
+ }
+
+ return fOriginalResourceManager.getConfiguration().getResourceManagerId();
+ }
+
+ private static Label createLabel(Composite parent, String name) {
+ Label label= new Label(parent, SWT.NULL);
+ label.setText(name);
+ label.setLayoutData(new GridData());
+
+ return label;
+ }
+
+ private static Text createText(Composite parent) {
+ Text text= new Text(parent, SWT.BORDER);
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ return text;
+ }
+
+ private static Button createCheckbox(Composite parent, String name) {
+ Button button= new Button(parent, SWT.CHECK);
+ button.setText(name);
+ button.setLayoutData(new GridData());
+
+ return button;
+ }
+
+ private int getIndex(String rmId) {
+
+ if (rmId == null)
+ return -1;
+
+ for (int i= 0; i < fResourceManagerFactories.length; i++) {
+ if (rmId.equals(fResourceManagerFactories[i].getId())) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private void updateButtons() {
+// StatusInfo status;
+//
+// boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
+// if (!valid) {
+// status = new StatusInfo();
+// if (!fSuppressError) {
+// status.setError(TextEditorResourceManagerMessages.EditResourceManagerDialog_error_noname);
+// }
+// } else {
+// status= fValidationStatus;
+// }
+// updateStatus(status);
+ }
+
+ protected void okPressed() {
+ String name= fNameText == null ? fOriginalResourceManager.getConfiguration().getName() : fNameText.getText();
+ IResourceManagerFactory factory = PTPCorePlugin.getDefault().getResourceManagerFactory(getRMId());
+ IResourceManagerConfiguration config = new ResourceManagerConfiguration(name, fDescriptionText.getText(), getRMId(), fHostText.getText(), Integer.parseInt(fPortText.getText()));
+ fNewResourceManager= factory.create(config);
+ super.okPressed();
+ }
+
+ /**
+ * Returns the created target.
+ *
+ * @return the created target
+ */
+ public IResourceManager getResourceManager() {
+ return fNewResourceManager;
+ }
+
+}
Index: icons/rm/rm_on.gif
===================================================================
RCS file: icons/rm/rm_on.gif
diff -N icons/rm/rm_on.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/rm_on.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a � �� ��� !� , ,��ǒ�B{0Z�cJ��r�Q(:"�(b�,����&sz��ut ;
Index: icons/rm/rm_view.gif
===================================================================
RCS file: icons/rm/rm_view.gif
diff -N icons/rm/rm_view.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/rm_view.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a � � �� ������ !� , 7H�Ҿ��(E��.���C8@���'i(��h(-��F���IDb�(��4vH ;
Index: icons/rm/stop.gif
===================================================================
RCS file: icons/rm/stop.gif
diff -N icons/rm/stop.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/stop.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a � � ��� !� , (���������!�Y���f�_���(�!,s�;E:��K ;
Index: icons/rm/rm_error.gif
===================================================================
RCS file: icons/rm/rm_error.gif
diff -N icons/rm/rm_error.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/rm_error.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,2 @@
+GIF89a � � ���������!� , :��w0�PQ}aNja�2Uf1�P)�>�y�"-ծ�{�q ��G�d4
+N��$� ;
Index: icons/rm/start.gif
===================================================================
RCS file: icons/rm/start.gif
diff -N icons/rm/start.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/start.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a � � ��� !� , )��y�m ]!D)h����5"#i�(�=k����6{�dc>R ;
Index: icons/rm/rm_off.gif
===================================================================
RCS file: icons/rm/rm_off.gif
diff -N icons/rm/rm_off.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/rm_off.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,1 @@
+GIF89a � ������ !� , ,��ǒ�B{0Z�cJ��r�Q(:"�(b�,����&sz��ut ;
Index: src/org/eclipse/ptp/ui/views/ResourceManagerView.java
===================================================================
RCS file: src/org/eclipse/ptp/ui/views/ResourceManagerView.java
diff -N src/org/eclipse/ptp/ui/views/ResourceManagerView.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ptp/ui/views/ResourceManagerView.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,159 @@
+package org.eclipse.ptp.ui.views;
+
+
+import org.eclipse.ptp.internal.ui.ParallelImages;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.*;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.*;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.SWT;
+
+
+public class ResourceManagerView extends ViewPart {
+ private TableViewer viewer;
+ private Action action1;
+ private Action action2;
+ private Action doubleClickAction;
+
+ class ViewContentProvider implements IStructuredContentProvider {
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public Object[] getElements(Object parent) {
+ return new String[] { "One", "Two", "Three" };
+ }
+ }
+
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+ public Image getImage(Object obj) {
+ // switch ()
+ // {
+ // case:
+ return ParallelImages.rmImages[1];
+ // }
+
+ }
+ }
+
+ class NameSorter extends ViewerSorter {
+ }
+
+ /**
+ * The constructor.
+ */
+ public ResourceManagerView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new ViewContentProvider());
+ viewer.setLabelProvider(new ViewLabelProvider());
+ viewer.setSorter(new NameSorter());
+ viewer.setInput(getViewSite());
+ makeActions();
+ hookContextMenu();
+ hookDoubleClickAction();
+ contributeToActionBars();
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ ResourceManagerView.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, viewer);
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(new Separator());
+ manager.add(action2);
+ }
+
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ // Other plug-ins can contribute there actions here
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(action1);
+ manager.add(action2);
+ }
+
+ private void makeActions() {
+ action1 = new Action() {
+ public void run() {
+ showMessage("Started!");
+ }
+ };
+ action1.setText("Start");
+ action1.setToolTipText("Start this resource manager.");
+ action1.setImageDescriptor(ParallelImages.ID_IMG_RM_START);
+
+ action2 = new Action() {
+ public void run() {
+ showMessage("Stopped!");
+ }
+ };
+ action2.setText("Stop");
+ action2.setToolTipText("Stop this resource manager.");
+ action2.setImageDescriptor(ParallelImages.ID_IMG_RM_STOP);
+
+ doubleClickAction = new Action() {
+ public void run() {
+ ISelection selection = viewer.getSelection();
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ showMessage("Double-click detected on "+obj.toString());
+ }
+ };
+ }
+
+ private void hookDoubleClickAction() {
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ doubleClickAction.run();
+ }
+ });
+ }
+ private void showMessage(String message) {
+ MessageDialog.openInformation(
+ viewer.getControl().getShell(),
+ "Sample View",
+ message);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+}
Index: icons/rm/rm_current.gif
===================================================================
RCS file: icons/rm/rm_current.gif
diff -N icons/rm/rm_current.gif
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ icons/rm/rm_current.gif 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,3 @@
+GIF89a � � �� ���!� , 4���#�d/�z����@
+�9�(Fhr�l��1��͊����o���
+���|~� ;