perfsonar-dev - perfsonar: r3851 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model
Subject: perfsonar development work
List archive
perfsonar: r3851 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3851 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model
- Date: Tue, 20 May 2008 04:35:02 -0400
Author: melis
Date: 2008-05-20 04:35:01 -0400 (Tue, 20 May 2008)
New Revision: 3851
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGShowEndpointsAction.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LGEndpoint.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesModel.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassTab.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebserviceComboboxModel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesTableModel.java
Log:
Updated psUI with latest work for integration of the Looking Glass
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -1,8 +1,6 @@
/*
Copyright (C) 2005-2006
-
Contact:
-
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1
@@ -11,22 +9,21 @@
- but is not limited to - adding the above copyright notice to the beginning
of your source code files, and to any copyright notice that you may
distribute
with programs based on this work.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-
package org.perfsonar.perfsonarui.lookingglass;
import java.io.StringWriter;
import java.util.StringTokenizer;
+import javax.xml.soap.SOAPEnvelope;
+import org.apache.axis.Message;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
@@ -46,98 +43,85 @@
* @author Nina Jeliazkova (skeleton framework)
*/
public class LGRequest extends AbstractMARequest {
-
+
private static String NMWG2TOPO = "http://ggf.org/ns/nmwg/topology/2.0/";
-
+
/**
* uData.getEndpoint is the service address to be queried, use
messagetype if necessary to distinguish between different types of messages
(metadatarequest, setupdatarequest)
*/
@Override
public org.w3c.dom.Document createRequest(IUserData uData, String
messageType)
- throws Exception {
+ throws Exception {
+
+ System.out.println("*** createRequest(" + uData + ", " + messageType
+ ") called");
org.w3c.dom.Document doc = null;
-
+
org.jdom.Document jdoc = null;
-
+
if (IPerfsonarRequest.MA_MetadataKeyRequest.equals(messageType)) {
-
+
//System.out.println("MetadataKeyRequest is being made...");
-
+
jdoc = new Document();
- //DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- //factory.setNamespaceAware(true);
- //DocumentBuilder builder = factory.newDocumentBuilder();
-
- Element msg = new
Element("message",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element msg = new Element("message",
Namespace.getNamespace("nmwg", NMWG2));
msg.setAttribute("id", "msg1");
msg.setAttribute("type", messageType);
-
- Element metadata = new
Element("metadata",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element metadata = new Element("metadata",
Namespace.getNamespace("nmwg", NMWG2));
metadata.setAttribute("id", "meta1");
msg.addContent(metadata);
-
- Element subject = new
Element("subject",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element subject = new Element("subject",
Namespace.getNamespace("nmwg", NMWG2));
subject.setAttribute("id", "server");
metadata.addContent(subject);
-
- Element params = new
Element("parameters",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element params = new Element("parameters",
Namespace.getNamespace("nmwg", NMWG2));
params.setAttribute("id", "params1");
subject.addContent(params);
-
- Element param = new
Element("parameter",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element param = new Element("parameter",
Namespace.getNamespace("nmwg", NMWG2));
param.setAttribute("id", "param1");
param.setText("SES");
params.addContent(param);
-
+
Element data = new Element("data", Namespace.getNamespace("nmwg",
NMWG2));
data.setAttribute("id", "data1");
data.setAttribute("metadataIdRef", "meta1");
-
+
msg.addContent(data);
-
+
jdoc.setRootElement(msg);
-
- DOMOutputter domout = new DOMOutputter ();
-
+
+ DOMOutputter domout = new DOMOutputter();
+
doc = domout.output(jdoc);
-
- /*StringWriter sw = new StringWriter();
- XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(doc));
- ser.serialize(doc.getDocumentElement());
-
- String XMLStr = sw.toString();
-
- System.out.println("MetadataKeyRequest (DOM): " + XMLStr);*/
+
} else if (IPerfsonarRequest.MA_SetupDataRequest.equals(messageType))
{
-
+
System.out.println("SetupDataRequest is being made...");
-
- //DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- //factory.setNamespaceAware(true);
- //DocumentBuilder builder = factory.newDocumentBuilder();
- //doc = builder.newDocument();
-
+
jdoc = new Document();
-
- Element msg = new
Element("message",Namespace.getNamespace("nmwg",NMWG2));
+
+ Element msg = new Element("message",
Namespace.getNamespace("nmwg", NMWG2));
msg.setAttribute("id", "msg1");
msg.setAttribute("type", messageType);
-
+
String devices = uData.getQuery("endpoint");
StringTokenizer tok = new StringTokenizer(devices, "@@@");
-
+
String device;
int i = 1;
- while (tok.hasMoreTokens()){
-
+ while (tok.hasMoreTokens()) {
+
device = tok.nextToken();
-
- Element metadata = new
Element("metadata",Namespace.getNamespace("nmwg",NMWG2));
- metadata.setAttribute("id", "meta"+i);
- Element subject = new
Element("subject",Namespace.getNamespace("nmwg",NMWG2));
- subject.setAttribute("id", "subject"+i);
+ Element metadata = new Element("metadata",
Namespace.getNamespace("nmwg", NMWG2));
+ metadata.setAttribute("id", "meta" + i);
+ Element subject = new Element("subject",
Namespace.getNamespace("nmwg", NMWG2));
+ subject.setAttribute("id", "subject" + i);
+
Element endpoint = new Element("endPoint",
Namespace.getNamespace("nmwgtopo", NMWG2TOPO));
endpoint.setAttribute("type", "hostname");
endpoint.setText(device);
@@ -145,19 +129,19 @@
metadata.addContent(subject);
- Element params = new
Element("parameters",Namespace.getNamespace("nmwg",NMWG2));
- params.setAttribute("id", "params1");
+ Element params = new Element("parameters",
Namespace.getNamespace("nmwg", NMWG2));
+ params.setAttribute("id", "params" + i);
// add parameters to parameters element
- if (uData.getQuery("parameters")!=null &&
!uData.getQuery("parameters").equals("")) {
- Element param = new
Element("parameter",Namespace.getNamespace("nmwg",NMWG2));
- param.setAttribute("id", "param1");
+ if (uData.getQuery("parameters") != null &&
!uData.getQuery("parameters").equals("")) {
+ Element param = new Element("parameter",
Namespace.getNamespace("nmwg", NMWG2));
+ param.setAttribute("id", "param" + i);
param.setText(uData.getQuery("parameters"));
- params.addContent(param);
+ params.addContent(param);
}
metadata.addContent(params);
- Element eventType = new Element ("eventType",
Namespace.getNamespace("nmwg", NMWG2));
+ Element eventType = new Element("eventType",
Namespace.getNamespace("nmwg", NMWG2));
eventType.setText(uData.getQuery("command")); //there is only
one eventType, so we pick the first one
metadata.addContent(eventType);
@@ -166,97 +150,128 @@
//create the relevant Document, get parameters from udata
- /*
- <nmwg:message type="SetupDataRequest" id="msg1"
xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/"
xmlns:nmwgtopo="http://ggf.org/ns/nmwg/topology/2.0/">
- <nmwg:metadata id="meta1">
- <nmwg:subject id="subject1">
- <nmwgtopo:endpoint
type="hostname">cisco1</nmwgtopo:endpoint>
- </nmwg:subject>
- <nmwg:eventType>IP_ROUTE</nmwg:eventType>
- <nmwg:parameters id="params1">
- <nmwg:parameter
name="param1">157.193.214.0</nmwg:parameter>
- </nmwg:parameters>
- </nmwg:metadata>
- <nmwg:data id="data1" metadataIdRef="meta1" />
- </nmwg:message>
+ Element data = new Element("data",
Namespace.getNamespace("nmwg", NMWG2));
+ data.setAttribute("id", "data" + i);
+ data.setAttribute("metadataIdRef", "meta" + i);
+ i++;
- */
+ msg.addContent(metadata);
+ msg.addContent(data);
+ }
+ jdoc.setRootElement(msg);
- Element data = new Element("data",
Namespace.getNamespace("nmwg", NMWG2));
- data.setAttribute("id", "data"+i);
- data.setAttribute("metadataIdRef", "meta"+i);
-
- i++;
-
- msg.addContent(metadata);
- msg.addContent(data);
-
- }
-
-
- jdoc.setRootElement(msg);
-
- DOMOutputter domout = new DOMOutputter ();
-
+ DOMOutputter domout = new DOMOutputter();
+
doc = domout.output(jdoc);
-
- StringWriter sw = new StringWriter();
- XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(doc));
- ser.serialize(doc.getDocumentElement());
-
- String XMLStr = sw.toString();
-
- System.out.println("SetupDataRequest (DOM): " + XMLStr);
+
}
return doc;
}
-
+
@Override
public org.w3c.dom.Document createRequest(MAEndpoint endpoint,
MetaDataList query,
String messageType) throws Exception {
- // endpoint is the service address to be queried, query is a list of
IUserData entries
- // This is if you need to send several simultaneous request for each
entries in query - not sure if relevant for LG
- System.out.println(query);
+ // endpoint is the service address to be queried, query is a list of
+ // IUserData entries
+ // This is if you need to send several simultaneous request for each
+ // entries in query - not sure if relevant for LG
+ System.out.println("createRequest (" + endpoint + ", " + query + ", "
+ messageType + ") called");
return null;
}
-
+
@Override
public String getMessageNamespace() {
// TODO Auto-generated method stub
+ System.out.println("getMessageNamespace() called");
return null;
}
-
+
public String[] getNamespaces() {
// TODO Auto-generated method stub
+ System.out.println("getNamespace() called");
return null;
}
-
+
public String getRequestType() {
+ System.out.println("getRequestType(() called");
return "lg";
}
-
+
/**
* This is normally invoked after response is received
*/
public void process(IUserData uData, org.w3c.dom.Document response,
IPerfsonarResponse listener) throws Exception {
// TODO Auto-generated method stub
-
+
System.out.println("The response is:");
-
+
StringWriter sw = new StringWriter();
XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(response));
ser.serialize(response.getDocumentElement());
-
+
String XMLStr = sw.toString();
-
+
System.out.println("" + XMLStr);
-
+
}
+
+ /**
+ * Runs the Axis call in a thread.
+ * TODO option to set the timeout
+ */
+ @Override
+ public void run() {
+ long startTime = System.currentTimeMillis();
+ setInterrupted(false);
+ //setRunning(true);
+ // call on the end point
+ Object resultObject = null;
+ try {
+ //logger.debug("Sending request to\t" + query.getEndpoint());
+ //logger.debug(requestMessage);
+ //call.setTimeout(new Integer(1800000)); //30 min
+
+ call.setTimeout(new Integer(timeout)); //5 min
+ //logger.debug("Timeout set to " + call.getTimeout());
+
+ SOAPEnvelope envelope = prepareEnvelope(requestMessage);
+
+ System.out.println("**** requestMessage: " + requestMessage);
+
+ if (envelope != null) {
+ resultObject = call.invoke(new Message(envelope));
+ //throw new Exception("AA not implemented! Have to figure out why
resultObject = call.invoke((SOAPEnvelope)envelope); does not compile");
+ } else {
+ Object[] array = new Object[1];
+ array[0] = requestMessage;
+ resultObject = call.invoke(array);
+ }
+
+ if (!isInterrupted()) {
+ logger.debug("request completed");
+ fireAxisCallCompleted(query);
+ fireAxisCallResult(query, resultObject);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (!isInterrupted()) {
+ logger.error("request exception");
+ if (queries != null) {
+ fireAxisCallException(queries, e);
+ } else {
+ fireAxisCallException(query, e);
+ }
+ }
+ }
+ query.setServiceTime(System.currentTimeMillis() - startTime);
+ queries = null;
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGSetupDataRequestAction.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -6,15 +6,18 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.perfsonar.perfsonarui.lookingglass;
import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import org.perfsonar.perfsonarui.MetadataListResponseListener;
import org.perfsonar.perfsonarui.PerfsonarResponseEvent;
import org.perfsonar.perfsonarui.SmartMARequest;
+import org.perfsonar.perfsonarui.lookingglass.model.LGEndpoint;
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
import org.perfsonar.perfsonarui.plugins.IUserData;
@@ -28,179 +31,208 @@
*
* @author smelis
*/
-public class LGSetupDataRequestAction extends PerfsonarRequestAction{
-
+public class LGSetupDataRequestAction extends PerfsonarRequestAction {
+
protected MetaDataList dataList;
protected MAEndpointList endpoints;
-
protected LookingGlassMainPanel parent;
-
/**
*
*/
private static final long serialVersionUID = 269024097063853042L;
-
+
public LGSetupDataRequestAction(IPerfsonarRequest request,
IUserData userData, MetaDataList dataList, MAEndpointList
endpoints) {
- this(request,userData,dataList,endpoints, "Refresh nodes");
+ this(request, userData, dataList, endpoints, "Refresh nodes");
}
-
+
public LGSetupDataRequestAction(IPerfsonarRequest request,
IUserData userData,
MetaDataList dataList, MAEndpointList endpoints, String arg0) {
- this(request,userData,dataList,endpoints, arg0,null);
+ this(request, userData, dataList, endpoints, arg0, null);
}
-
+
public LGSetupDataRequestAction(IPerfsonarRequest request,
IUserData userData,
MetaDataList dataList, MAEndpointList endpoints, String arg0,
Icon arg1) {
- super(request,userData,arg0,arg1,IPerfsonarTab.defaultGroupQuery);
+ super(request, userData, arg0, arg1, IPerfsonarTab.defaultGroupQuery);
setDataList(dataList);
setEndpoints(endpoints);
- putValue(SHORT_DESCRIPTION,"Sends the requested command to the
selected devices.");
- putValue(DEFAULT,"SetupDataRequestAction");
+ putValue(SHORT_DESCRIPTION, "Sends the requested command to the
selected devices.");
+ putValue(DEFAULT, "SetupDataRequestAction");
}
-
+
@Override
public Object run(ActionEvent arg0) {
- //System.out.println("Selected item:
"+parent.getWebserviceComboBox().getSelectedItem());
-
- //System.out.println("Number of endpoints: " + endpoints.size());
-
- if (request == null) return null; //TODO check if this should
silently fail
+ if (request == null) {
+ return null;
+ } //TODO check if this should silently fail
try {
enableActions(true);
-
+
dataList.clear();
dataList.setNotificationEnabled(false);
+
+ List eps =
parent.getLookingGlassClientModel().getSelectedEndpoints();
+ endpoints = new MAEndpointList();
+ endpoints.setMultipleEndpoints(true);
+
+ List templist = new ArrayList();
+ //Add all selected Endpoints to the MAEndpointList
+ //Use temporary list to only have one instance of each MP as an
endpoint
+ Iterator it = eps.iterator();
+ while (it.hasNext()) {
+ //add LGEndpoint if it is not already in the templist
+ LGEndpoint endpoint = ((MPDevicePair)it.next()).getMp();
+ if (!templist.contains(endpoint))
+ templist.add(endpoint);
+ }
+
+ it = templist.iterator();
+ while (it.hasNext()){
+ endpoints.add((LGEndpoint)it.next());
+ }
+
//datePanel = null;
enableActions(false);
//endpointsPanel = null;
+
+ boolean ok = false;
+ //For each endpoint
- boolean ok = false;
- for (int i=0; i < endpoints.size();i++) {
- if (isInterrupted()) break;
- MAEndpoint mae = endpoints.get(i);
- //System.out.println("Endpoint : " + mae.getTitle());
- if (mae.isEnabled() &&
parent.getWebserviceComboBox().getSelectedItem() != null
- &&
mae.getTitle().equalsIgnoreCase(parent.getWebserviceComboBox()
- .getSelectedItem().toString())) {
+ System.out.println("\n\nThere are " + endpoints.size() + " MPs to
be contacted.");
+
+ for (int i = 0; i < endpoints.size(); i++) {
+ if (isInterrupted()) {
+ break;
+ }
+ LGEndpoint mae = (LGEndpoint) endpoints.get(i);
+
//if (mae.isEnabled()){
- ok = true;
- dataList.setNotificationEnabled(false);
-
- parent.addCurrentDeviceToDevicesList();
- userData.setEndpoint(mae);
- //System.out.println("Sending request to " +
userData.getEndpoint());
- request.fireStatusMessage("Sending request to " +
userData.getEndpoint());
-
-
- try {
- MetadataListResponseListener listener = new
MetadataListResponseListener(dataList) {
- @Override
- public synchronized void
callException(PerfsonarResponseEvent e) {
- super.callException(e);
-
- //System.out.println("callException called");
-
- getDataList().clear();
- logger.error(e.getException());
-
handleException(e.getException(),userData.getEndpoint());
- getDataList().setSelectedItem(null);
- //request.removePropertyChangeListener(this);
- }
- @Override
- public synchronized void
callCompleted(IPerfsonarRequest request) {
- super.callCompleted(request);
- //request.removePropertyChangeListener(this);
-
- //System.out.println("callCompleted called");
- }
- @Override
- public void process(IPerfsonarRequest request,
IUserData uData, Document response) throws Exception {
- super.process(request, uData, response);
- //getDataList().setSelectedItem(null);
-
//parent.webserviceComboboxActionperformedHandler(response);
- parent.setResponse(response);
- }
- @Override
- public synchronized void
processingCompleted(IPerfsonarRequest request) {
- super.processingCompleted(request);
- getDataList().setSelectedItem(null);
-
- //System.out.println("processingCompleted
called");
- }
-
- };
-
-
userData.setQuery("endpoint",parent.getSelectedDevices());
-
- userData.setQuery("command",
parent.getSelectedCommand());
- userData.setQuery("parameters",
parent.getParameters());
-
- request.makeRequest(userData,
IPerfsonarRequest.MA_SetupDataRequest, listener, false);
- mae.setStatus("OK");
- mae.setStatusExplanation("OK");
- mae.setAlive(true );
-
- break;
- //PerfsonarResponseEvent.COMMAND_CALLEXCEPTION
-
//request.addPropertyChangeListener(PerfsonarResponseEvent);
- } catch (Exception x) {
- logger.error(x);
- handleException(x,mae);
- }
-
+ ok = true;
+ dataList.setNotificationEnabled(false);
+
+ // Add current device to the list, if it is not already in
the list of selected devices
+ // --> no longer supported, because it is possible for
another MP to be added to the list this way
+ //parent.addCurrentDeviceToDevicesList();
+ userData.setEndpoint(mae);
+ System.out.println("Sending request " + (i+1) + " to " +
userData.getEndpoint());
+ request.fireStatusMessage("Sending request to " +
userData.getEndpoint());
+
+ try {
+ MetadataListResponseListener listener = new
MetadataListResponseListener(dataList) {
+
+ @Override
+ public synchronized void
callException(PerfsonarResponseEvent e) {
+ super.callException(e);
+
+ //System.out.println("callException called");
+
+ getDataList().clear();
+ logger.error(e.getException());
+ handleException(e.getException(),
userData.getEndpoint());
+ e.getException().printStackTrace();
+ getDataList().setSelectedItem(null);
+ //request.removePropertyChangeListener(this);
+ }
+
+ @Override
+ public synchronized void
callCompleted(IPerfsonarRequest request) {
+ super.callCompleted(request);
+ //request.removePropertyChangeListener(this);
+
+ //System.out.println("callCompleted called");
+ }
+
+ @Override
+ public void process(IPerfsonarRequest request,
IUserData uData, Document response) throws Exception {
+ super.process(request, uData, response);
+ //getDataList().setSelectedItem(null);
+
//parent.webserviceComboboxActionperformedHandler(response);
+ parent.setResponse(response);
+ }
+
+ @Override
+ public synchronized void
processingCompleted(IPerfsonarRequest request) {
+ super.processingCompleted(request);
+ getDataList().setSelectedItem(null);
+
+ //System.out.println("processingCompleted called");
+ }
+ };
+
+ //adds all devices to the request (as one @@@ separated
string)
+ userData.setQuery("endpoint",
parent.getSelectedDevices(mae));
+
+ userData.setQuery("command", parent.getSelectedCommand());
+ userData.setQuery("parameters", parent.getParameters());
+
+ request.makeRequest(userData,
IPerfsonarRequest.MA_SetupDataRequest, listener, false);
+ mae.setStatus("OK");
+ mae.setStatusExplanation("OK");
+ mae.setAlive(true);
+
+ //break;
+ //PerfsonarResponseEvent.COMMAND_CALLEXCEPTION
+
//request.addPropertyChangeListener(PerfsonarResponseEvent);
+ } catch (Exception x) {
+ x.printStackTrace();
+ logger.error(x);
+ handleException(x, mae);
}
+
}
-
- if (request instanceof SmartMARequest)
+
+ if (request instanceof SmartMARequest) {
((SmartMARequest) request).isReady();
-
+ }
+
dataList.setNotificationEnabled(true);
- if (!ok && parent.getWebserviceComboBox().getSelectedItem() !=
null)
- JOptionPane.showMessageDialog(frame,"No IPPM service
selected!","Error",JOptionPane.ERROR_MESSAGE);
+ if (!ok && endpoints.size() > 0) {
+ JOptionPane.showMessageDialog(frame, "No IPPM service
selected!", "Error", JOptionPane.ERROR_MESSAGE);
+ }
} catch (Exception x) {
-
JOptionPane.showMessageDialog(frame,x,"Error",JOptionPane.ERROR_MESSAGE);
x.printStackTrace();
+ JOptionPane.showMessageDialog(frame, x, "Error",
JOptionPane.ERROR_MESSAGE);
logger.error(x);
}
return null;
}
+
@Override
public void done(Object result) {
}
-
+
public MetaDataList getDataList() {
return dataList;
}
-
+
public void setDataList(MetaDataList dataList) {
this.dataList = dataList;
}
-
+
public synchronized MAEndpointList getEndpoints() {
return endpoints;
}
+
public synchronized void setEndpoints(MAEndpointList endpoints) {
this.endpoints = endpoints;
}
+
protected void handleException(Exception x, MAEndpoint endpoint) {
endpoint.setStatus(x.getMessage());
endpoint.setStatusExplanation(x);
endpoint.setAlive(false);
- parent.disableComboboxes();
+ //parent.disableComboboxes();
JOptionPane.showMessageDialog(frame,
x.getMessage() + "\nThere seems to be a problem with the
connection\n" +
- "to the device. Please check if the URL is valid."
- ,"Error",JOptionPane.ERROR_MESSAGE);
+ "to the device. Please check if the URL is valid.", "Error",
JOptionPane.ERROR_MESSAGE);
}
-
- public void setParent (LookingGlassMainPanel parent) {
- this.parent = parent;
+
+ public void setParent(LookingGlassMainPanel parent) {
+ this.parent = parent;
}
-
}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGShowEndpointsAction.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -1,8 +1,6 @@
/*
Copyright (C) 2005-2006
-
Contact:
-
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1
@@ -11,49 +9,48 @@
- but is not limited to - adding the above copyright notice to the beginning
of your source code files, and to any copyright notice that you may
distribute
with programs based on this work.
-
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
-
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-
package org.perfsonar.perfsonarui.lookingglass;
import java.awt.Component;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.Action;
-import javax.swing.JButton;
import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JList;
+import javax.swing.JFileChooser;
import javax.swing.JPanel;
-import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
-import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import javax.swing.text.DefaultCaret;
import org.perfsonar.perfsonarui.lookingglass.model.Command;
import org.perfsonar.perfsonarui.lookingglass.model.DeviceComboboxModel;
import org.perfsonar.perfsonarui.lookingglass.model.DeviceListModel;
import org.perfsonar.perfsonarui.lookingglass.model.FunctionComboboxModel;
+import org.perfsonar.perfsonarui.lookingglass.model.LGEndpoint;
import org.perfsonar.perfsonarui.lookingglass.model.LatestResultListModel;
import org.perfsonar.perfsonarui.lookingglass.model.LookingGlassClientModel;
import
org.perfsonar.perfsonarui.lookingglass.model.QueriedDeviceComboboxModel;
import org.perfsonar.perfsonarui.lookingglass.model.WebserviceComboboxModel;
-import org.perfsonar.perfsonarui.lookingglass.model.WebservicesTableModel;
-import
org.perfsonar.perfsonarui.lookingglass.support.CommandComboboxRenderer;
+import org.perfsonar.perfsonarui.lookingglass.model.WebservicesModel;
import org.perfsonar.perfsonarui.lookingglass.support.TextHighlighter;
import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
@@ -61,53 +58,55 @@
import org.perfsonar.perfsonarui.ui.actions.PSActionMap;
import org.w3c.dom.Document;
-
/**
* @author Stijn Melis
* @author Nina Jeliazkova (skeleton framework)
*/
public class LookingGlassMainPanel extends PluginMainPanel
- implements ChangeListener, ListSelectionListener{
+ implements ChangeListener, ListSelectionListener {
+
protected JTextArea demo;
/**
*
*/
private static final long serialVersionUID = -9200520537475864945L;
-
-
- private JPanel jPanel2;
- private JScrollPane jScrollPane2;
- private JTextArea resultTextArea;
- private JLabel jLabel32;
- private JTextField statusTextField;
- private JLabel jLabel35;
- private JTextField searchTextField;
- private JButton highlightButton;
-
- private JPanel jPanel1;
- private JLabel jLabel1;
- private JComboBox webserviceCombobox;
- private JLabel jLabel2;
- private JComboBox deviceCombobox;
- private JLabel jLabel3;
- private JComboBox functionCombobox;
- //private JLabel jLabel27;
- //private JProgressBar progressBar;
- private JList deviceList;
- private JScrollPane jScrollPane8;
- private JButton addDeviceButton;
- private JButton removeDeviceButton;
- private JLabel jLabel28;
- private JPanel jPanel3;
- private JLabel jLabel29;
- private JLabel jLabel30;
- private JLabel jLabel31;
- private JTextField descriptionTextField;
- private JTextField syntaxTextField;
- private JTextField commandTextField;
- private JLabel parameterLabel;
- private JTextField parameterStringTextField;
-
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.JButton addDeviceButton;
+ private javax.swing.JButton removeDeviceButton;
+ private javax.swing.JButton exportButton;
+ private javax.swing.JButton highlightButton;
+ private javax.swing.JButton importButton;
+ private javax.swing.JButton clearButton;
+ private javax.swing.JButton addAllButton;
+ private javax.swing.JButton addAllDevicesButton;
+ private javax.swing.JCheckBox jCheckBox1;
+ private javax.swing.JComboBox functionCombobox;
+ private javax.swing.JComboBox webserviceCombobox;
+ private javax.swing.JComboBox deviceCombobox;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel6;
+ private javax.swing.JLabel jLabel7;
+ private javax.swing.JLabel jLabel8;
+ private javax.swing.JList deviceList;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanel5;
+ private javax.swing.JRadioButton jRadioButton1;
+ private javax.swing.JRadioButton jRadioButton2;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JScrollPane jScrollPane2;
+ private javax.swing.JTabbedPane jTabbedPane1;
+ private javax.swing.JTextArea resultTextArea;
+ private javax.swing.JTextField parameterStringTextField;
+ private javax.swing.JTextField descriptionTextField;
+ private javax.swing.JTextField syntaxTextField;
+ private javax.swing.JTextField commandTextField;
+ private javax.swing.JTextField searchTextField;
private LookingGlassClientModel model;
private WebserviceComboboxModel webserviceComboboxModel;
private boolean busy = false;
@@ -117,767 +116,785 @@
private FunctionComboboxModel functionComboboxModel;
//private ParameterListModel parameterListModel;
private DeviceListModel deviceListModel;
- private WebservicesTableModel webservicesTableModel;
private LatestResultListModel latestResultListModel;
private QueriedDeviceComboboxModel queriedDeviceComboboxModel1;
private QueriedDeviceComboboxModel queriedDeviceComboboxModel2;
-
private IPerfsonarTab iperftab;
-
+
+
public LookingGlassMainPanel(Component parentFrame, IPerfsonarTab
iperftab) {
super(parentFrame, iperftab);
this.iperftab = iperftab;
+
+ WebservicesModel.initWebservicesModel();
}
-
+
@Override
protected void addWidgets() {
model = new LookingGlassClientModel();
model.addChangeListener(this);
-
+
infiniteProgressPanel = new InfiniteProgressPanel();
-
+
listenerList = new EventListenerList();
changeEvent = new ChangeEvent("webservicesAlteration");
- webserviceComboboxModel = new WebserviceComboboxModel(model);
+ webserviceComboboxModel = new WebserviceComboboxModel();
deviceComboboxModel = new DeviceComboboxModel(model);
functionComboboxModel = new FunctionComboboxModel(model);
-
+
//parameterListModel = new ParameterListModel(model);
deviceListModel = new DeviceListModel(model);
-
- webservicesTableModel = new WebservicesTableModel();
+
latestResultListModel = new LatestResultListModel(model);
-
+
queriedDeviceComboboxModel1 = new QueriedDeviceComboboxModel();
queriedDeviceComboboxModel2 = new QueriedDeviceComboboxModel();
-
+
addChangeListener(webserviceComboboxModel);
-
+
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
addTopPane(), addBottomPane());
-
+
add(split);
+
}
-
+
private JPanel addTopPane() {
- jPanel1 = new JPanel();
- jLabel1 = new javax.swing.JLabel();
+ buttonGroup1 = new javax.swing.ButtonGroup();
+ jPanel1 = new javax.swing.JPanel();
+ jPanel4 = new javax.swing.JPanel();
+ jLabel6 = new javax.swing.JLabel();
webserviceCombobox = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
+ jLabel7 = new javax.swing.JLabel();
deviceCombobox = new javax.swing.JComboBox();
- deviceCombobox.setEnabled(false);
- jLabel3 = new javax.swing.JLabel();
- functionCombobox = new javax.swing.JComboBox();
- functionCombobox.setEnabled(false);
- //jLabel27 = new javax.swing.JLabel();
- //progressBar = new javax.swing.JProgressBar();
- jScrollPane8 = new javax.swing.JScrollPane();
- deviceList = new javax.swing.JList();
addDeviceButton = new javax.swing.JButton();
removeDeviceButton = new javax.swing.JButton();
- jLabel28 = new javax.swing.JLabel();
- jPanel3 = new javax.swing.JPanel();
- jLabel29 = new javax.swing.JLabel();
- jLabel30 = new javax.swing.JLabel();
- jLabel31 = new javax.swing.JLabel();
+ jLabel8 = new javax.swing.JLabel();
+ jScrollPane2 = new javax.swing.JScrollPane();
+ deviceList = new javax.swing.JList();
+ exportButton = new javax.swing.JButton();
+ importButton = new javax.swing.JButton();
+ clearButton = new javax.swing.JButton();
+ addAllButton = new javax.swing.JButton();
+ addAllDevicesButton = new javax.swing.JButton();
+ jPanel5 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ functionCombobox = new javax.swing.JComboBox();
+ jLabel2 = new javax.swing.JLabel();
+ parameterStringTextField = new javax.swing.JTextField();
+ jLabel3 = new javax.swing.JLabel();
descriptionTextField = new javax.swing.JTextField();
+ jLabel4 = new javax.swing.JLabel();
syntaxTextField = new javax.swing.JTextField();
commandTextField = new javax.swing.JTextField();
- parameterLabel = new javax.swing.JLabel();
- parameterStringTextField = new javax.swing.JTextField();
-
-
+ jLabel5 = new javax.swing.JLabel();
+ jRadioButton1 = new javax.swing.JRadioButton();
+ jRadioButton2 = new javax.swing.JRadioButton();
+ jPanel2 = new javax.swing.JPanel();
+ searchTextField = new javax.swing.JTextField();
+ highlightButton = new javax.swing.JButton();
+ jCheckBox1 = new javax.swing.JCheckBox();
+ jTabbedPane1 = new javax.swing.JTabbedPane();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ resultTextArea = new javax.swing.JTextArea();
+
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Request"));
- jLabel1.setText("Telnet / SSH Measurement Point:");
-
-
+
+
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Device
Information"));
+
+ jLabel6.setText("Telnet/SSH MP:");
+
+ jLabel7.setText("Device:");
+
+ addDeviceButton.setText("Add");
+ addDeviceButton.setEnabled(false);
+ addDeviceButton.addActionListener(new java.awt.event.ActionListener()
{
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addDeviceButtonActionPerformed(evt);
+ }
+ });
+
+ removeDeviceButton.setText("Remove");
+ removeDeviceButton.setEnabled(false);
+ removeDeviceButton.addActionListener(new
java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ removeDeviceButtonActionPerformed(evt);
+ }
+ });
+
+ jLabel8.setText("Device List:");
+
+ deviceList.setModel(deviceListModel);
+ deviceList.addListSelectionListener(this);
+ jScrollPane2.setViewportView(deviceList);
+
+ exportButton.setText("Export");
+ exportButton.setEnabled(false);
+ exportButton.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ exportDeviceListActionPerformed(evt);
+ }
+ });
+
+ importButton.setText("Import");
+ importButton.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ importDeviceListActionPerformed(evt);
+ }
+ });
+
+ clearButton.setText("Clear");
+ clearButton.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ clearDeviceListActionPerformed(evt);
+ }
+ });
+
+ addAllButton.setText("Add All MP's/Devices");
+ addAllButton.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addAllDevicesAndMPsActionPerformed(evt);
+ }
+ });
+
+ addAllDevicesButton.setText("Add All Devices");
+ addAllDevicesButton.setEnabled(false);
+ addAllDevicesButton.addActionListener(new
java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addAllDevicesActionPerformed(evt);
+ }
+ });
+
+ parameterStringTextField.setEnabled(false);
+
webserviceCombobox.setModel(webserviceComboboxModel);
webserviceCombobox.setToolTipText("Select the desired configured
webserver");
- //webserviceCombobox.addActionListener(new
java.awt.event.ActionListener() {
- // public void actionPerformed(java.awt.event.ActionEvent evt) {
- // webserviceComboboxActionperformedHandler(evt);
- // }
- //});
- //System.out.println("model (in addTopPane): "+super.model);
- //System.out.println("Action :" + super.model.getActions().get("0"));
webserviceCombobox.setAction(super.model.getActions().get("0")); //
this should be the LGMetadataKeyRequestAction
-
((MetadataKeyRequestAction)super.model.getActions().get("0")).setParent(this);
-
+ ((MetadataKeyRequestAction)
super.model.getActions().get("0")).setParent(this);
+
//also add this class to the SetupDataRequestAction as parent
PSActionMap map = super.model.getActions();
Object[] keys = map.allKeys();
LGSetupDataRequestAction sdra = null;
- for (int i = 0; i < keys.length; i++){
- if (map.get(keys[i]).getValue(Action.DEFAULT)!= null &&
-
map.get(keys[i]).getValue(Action.DEFAULT).equals("SetupDataRequestAction")){
- sdra = (LGSetupDataRequestAction)map.get(keys[i]);
+ for (int i = 0; i < keys.length; i++) {
+ if (map.get(keys[i]).getValue(Action.DEFAULT) != null &&
+
map.get(keys[i]).getValue(Action.DEFAULT).equals("SetupDataRequestAction")) {
+ sdra = (LGSetupDataRequestAction) map.get(keys[i]);
break;
}
}
sdra.setParent(this);
-
- jLabel2.setText("Device:");
-
+
deviceCombobox.setModel(deviceComboboxModel);
- deviceCombobox.setToolTipText("Select the device the earlier selected
webserver supports");
+ deviceCombobox.setEnabled(false);
deviceCombobox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deviceComboboxHandler(evt);
}
});
-
- jLabel3.setText("Command:");
-
functionCombobox.setModel(functionComboboxModel);
- functionCombobox.setToolTipText("Select the requested function");
- functionCombobox.setRenderer(new CommandComboboxRenderer(this));
+ functionCombobox.setEnabled(false);
functionCombobox.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
functionComboboxActionPerformed(evt);
}
});
- //jLabel27.setText("Working");
- //progressBar.setForeground(new java.awt.Color(0, 153, 153));
- //progressBar.setEnabled(false);
- //progressBar.setString("");
-
- deviceList.setModel(deviceListModel);
-
deviceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
- deviceList.setToolTipText("This list represents a set of devices to
which the same command will be sent. It can also be used to select the
appropriate result to be displayed in the large box below.");
-
- deviceList.addListSelectionListener(this);
-
- jScrollPane8.setViewportView(deviceList);
-
- addDeviceButton.setText("Add Device");
- addDeviceButton.setEnabled(false);
- addDeviceButton.addActionListener(new java.awt.event.ActionListener()
{
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addDeviceButtonActionPerformed(evt);
- }
- });
-
- removeDeviceButton.setText("Remove Selected Device");
- removeDeviceButton.setEnabled(false);
- removeDeviceButton.addActionListener(new
java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- removeDeviceButtonActionPerformed(evt);
- }
- });
-
- jLabel28.setText("Devices to be contacted:");
-
-
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Command
Information"));
- jLabel29.setText("Description:");
-
- jLabel30.setText("Syntax:");
-
- jLabel31.setText("Device OS Command:");
-
+ org.jdesktop.layout.GroupLayout jPanel4Layout = new
org.jdesktop.layout.GroupLayout(jPanel4);
+ jPanel4.setLayout(jPanel4Layout);
+ jPanel4Layout.setHorizontalGroup(
+
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel4Layout.createSequentialGroup().addContainerGap().add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING,
false).add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).add(jLabel6,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).add(jLabel8,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE).add(clearButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE).add(importButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE).add(exportButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 100,
Short.MAX_VALUE)).addContainerGap().add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING).add(j
ScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 473,
Short.MAX_VALUE).add(webserviceCombobox, 0, 473,
Short.MAX_VALUE).add(deviceCombobox, 0, 473,
Short.MAX_VALUE).add(org.jdesktop.layout.GroupLayout.LEADING,
jPanel4Layout.createSequentialGroup().add(addDeviceButton,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(removeDeviceButton).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(addAllButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 183,
Short.MAX_VALUE).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(addAllDevicesButton,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 122,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))).addContainerGap()));
+ jPanel4Layout.setVerticalGroup(
+
jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel4Layout.createSequentialGroup().addContainerGap().add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel6).add(webserviceCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel7).add(deviceCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(addDeviceButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).add(removeDe
viceButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE).add(addAllDevicesButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE).add(addAllButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING).add(jPanel4Layout.createSequentialGroup().add(jLabel8).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE).add(clearButton).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(importButton).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(exportButton)).add(jScrollPane2,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 111,
Short.MAX_VALUE)).addContainerGap()));
+
+
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Command
Information"));
+
+ jLabel1.setText("Command:");
+ jLabel2.setText("Parameters:");
+ jLabel3.setText("Description:");
descriptionTextField.setEditable(false);
- descriptionTextField.setFont(new java.awt.Font("Tahoma", 1, 11));
- descriptionTextField.setForeground(new java.awt.Color(0, 153, 51));
- descriptionTextField.setToolTipText("Gives a tectual description of
the selected command");
-
+ jLabel4.setText("Syntax:");
syntaxTextField.setEditable(false);
- syntaxTextField.setFont(new java.awt.Font("Tahoma", 1, 11));
- syntaxTextField.setForeground(new java.awt.Color(0, 153, 51));
- syntaxTextField.setToolTipText("Gives the syntax of the parameters
(if applicable)");
-
commandTextField.setEditable(false);
- commandTextField.setFont(new java.awt.Font("Tahoma", 1, 11));
- commandTextField.setForeground(new java.awt.Color(204, 102, 0));
- commandTextField.setToolTipText("Gives as information the
device-specific command that will be executed");
-
- org.jdesktop.layout.GroupLayout jPanel3Layout = new
org.jdesktop.layout.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
-
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel3Layout.createSequentialGroup()
- .addContainerGap()
-
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel3Layout.createSequentialGroup()
- .add(jLabel31)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(commandTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
- .add(jPanel3Layout.createSequentialGroup()
- .add(jLabel29)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(descriptionTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE))
- .add(jPanel3Layout.createSequentialGroup()
- .add(jLabel30)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(syntaxTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)))
- .addContainerGap())
- );
- jPanel3Layout.setVerticalGroup(
-
jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel3Layout.createSequentialGroup()
- .addContainerGap()
-
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel29)
- .add(descriptionTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel30)
- .add(syntaxTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel31)
- .add(commandTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(0, 0, Short.MAX_VALUE))
- );
-
-
-
- parameterLabel.setText("Parameterstring:");
-
- parameterStringTextField.setEnabled(false);
-
+ jLabel5.setText("<html>Device OS<br>Command:</html>");
+
+ buttonGroup1.add(jRadioButton1);
+ jRadioButton1.setSelected(true);
+ jRadioButton1.setText("AND");
+
+ buttonGroup1.add(jRadioButton2);
+ jRadioButton2.setText("OR");
+
+ org.jdesktop.layout.GroupLayout jPanel5Layout = new
org.jdesktop.layout.GroupLayout(jPanel5);
+ jPanel5.setLayout(jPanel5Layout);
+ jPanel5Layout.setHorizontalGroup(
+
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel5Layout.createSequentialGroup().addContainerGap().add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel2).add(jLabel3).add(jLabel4).add(jPanel5Layout.createSequentialGroup().add(jLabel1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(functionCombobox,
0, 266, Short.MAX_VALUE).add(parameterStringTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266,
Short.MAX_VALUE).add(descriptionTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266,
Short.MAX_VALUE).add(syntaxTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266,
Short.MAX_VALUE).add(commandTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 266,
Short.MAX_VALUE)).addContainerGap()).add(j
Panel5Layout.createSequentialGroup().add(jRadioButton1).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(jRadioButton2).addContainerGap(268,
Short.MAX_VALUE)).add(jPanel5Layout.createSequentialGroup().add(jLabel5).addContainerGap(307,
Short.MAX_VALUE)))));
+ jPanel5Layout.setVerticalGroup(
+
jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel5Layout.createSequentialGroup().addContainerGap().add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel1).add(functionCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel2).add(parameterStringTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel3).add(descriptionTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZ
E,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jLabel4).add(syntaxTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING).add(jLabel5).add(commandTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 34,
Short.MAX_VALUE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED).add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(jRadioButton1).add(jRadioButton2)).addContainerGap(25,
Short.MAX_VALUE)));
+
org.jdesktop.layout.GroupLayout jPanel1Layout = new
org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
-
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel1Layout.createSequentialGroup()
- .add(jLabel3)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(functionCombobox, 0, 320, Short.MAX_VALUE))
- .add(jPanel1Layout.createSequentialGroup()
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(org.jdesktop.layout.GroupLayout.LEADING,
jPanel1Layout.createSequentialGroup()
- .add(jLabel1)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(webserviceCombobox, 0, 213, Short.MAX_VALUE))
- .add(org.jdesktop.layout.GroupLayout.LEADING,
jPanel1Layout.createSequentialGroup()
- .add(jLabel2)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(deviceCombobox, 0, 335, Short.MAX_VALUE)))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
- .add(jPanel1Layout.createSequentialGroup()
- .add(parameterLabel)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(parameterStringTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE))
- .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(jPanel1Layout.createSequentialGroup()
- .add(12, 12, 12)
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(org.jdesktop.layout.GroupLayout.TRAILING,
jPanel1Layout.createSequentialGroup()
- .add(addDeviceButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(removeDeviceButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
- .add(jLabel28)))
- .add(jPanel1Layout.createSequentialGroup()
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jScrollPane8,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 498,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap())
- );
+
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel1Layout.createSequentialGroup().add(jPanel4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel5,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE).addContainerGap()));
jPanel1Layout.setVerticalGroup(
-
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(jPanel1Layout.createSequentialGroup()
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel1)
- .add(webserviceCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel28))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel2)
- .add(deviceCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
- .add(jPanel1Layout.createSequentialGroup()
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(removeDeviceButton)
- .add(addDeviceButton))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel1Layout.createSequentialGroup()
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel3)
- .add(functionCombobox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(parameterLabel)
- .add(parameterStringTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
109, Short.MAX_VALUE))
- .add(jPanel1Layout.createSequentialGroup()
- .add(5, 5, 5)
- .add(jScrollPane8,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)))
- .addContainerGap())
- );
-
+
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jPanel1Layout.createSequentialGroup().add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING).add(jPanel5,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).add(jPanel4,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).addContainerGap()));
+
+
return jPanel1;
}
-
-
+
private JPanel addBottomPane() {
- jPanel2 = new JPanel();
- jScrollPane2 = new JScrollPane();
- resultTextArea = new JTextArea();
- jLabel32 = new JLabel();
- statusTextField = new JTextField();
- jLabel35 = new JLabel();
- searchTextField = new JTextField();
- highlightButton = new JButton();
-
+ jPanel2 = new javax.swing.JPanel();
+
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Response"));
-
jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- resultTextArea.setColumns(10);
- resultTextArea.setEditable(false);
- resultTextArea.setLineWrap(true);
- resultTextArea.setRows(5);
- resultTextArea.setToolTipText("Response of the webserver to the given
request");
- resultTextArea.setAutoscrolls(false);
- DefaultCaret caret = new DefaultCaret();
- caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
- resultTextArea.setCaret(caret);
- jScrollPane2.setViewportView(resultTextArea);
-
- jLabel32.setText("Status Result String:");
-
- statusTextField.setEditable(false);
- statusTextField.setFont(new java.awt.Font("Tahoma", 3, 11));
- statusTextField.setForeground(new java.awt.Color(0, 0, 255));
- statusTextField.setToolTipText("Displays the resultstring containing
status information concerning you request");
-
- jLabel35.setText("Search:");
-
- searchTextField.setToolTipText("Enter a search string here");
- searchTextField.setEnabled(false);
-
- highlightButton.setText("Highlight");
- highlightButton.setToolTipText("Highlight the search string from the
textfield to the left into the textarea above.");
- highlightButton.setEnabled(false);
+
+ searchTextField.setText("");
+
+ highlightButton.setText("Search");
highlightButton.addActionListener(new java.awt.event.ActionListener()
{
+
public void actionPerformed(java.awt.event.ActionEvent evt) {
highlightButtonActionPerformed(evt);
}
});
-
+
+ jCheckBox1.setText("Append Output");
+ jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ appendOutputActionPerformed(evt);
+ }
+ });
+
+ resultTextArea.setColumns(20);
+ resultTextArea.setRows(5);
+ resultTextArea.setEditable(false);
+ jScrollPane1.setViewportView(resultTextArea);
+
+ jTabbedPane1.addTab("", jScrollPane1);
+
org.jdesktop.layout.GroupLayout jPanel2Layout = new
org.jdesktop.layout.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap()
-
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE)
+
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2Layout.createSequentialGroup()
- .add(jLabel32)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(statusTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE))
- .add(org.jdesktop.layout.GroupLayout.LEADING,
jPanel2Layout.createSequentialGroup()
- .add(jLabel35)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(searchTextField,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(highlightButton)))
+ .add(jTabbedPane1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1004, Short.MAX_VALUE)
.addContainerGap())
- );
+ .add(org.jdesktop.layout.GroupLayout.TRAILING,
jPanel2Layout.createSequentialGroup()
+ .add(searchTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 834,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(highlightButton)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(jCheckBox1)))));
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(jPanel2Layout.createSequentialGroup()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING,
jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .add(jTabbedPane1,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 223, Short.MAX_VALUE)
+ .addContainerGap()
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel32)
- .add(statusTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jScrollPane2,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel35)
+ .add(searchTextField)
.add(highlightButton)
- .add(searchTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
- );
-
-
- jPanel2.add(new JLabel("bottom"));
-
+ .add(jCheckBox1))
+ .addContainerGap()));
+
return jPanel2;
}
-
+
private void highlightButtonActionPerformed(java.awt.event.ActionEvent
evt) {
-
+
String toBeHighlighted = searchTextField.getText();
-
+
if (toBeHighlighted != null &&
!toBeHighlighted.equalsIgnoreCase("")) {
-
+
TextHighlighter textHighlighter = new TextHighlighter();
textHighlighter.highlight(resultTextArea, toBeHighlighted, false,
false);
-
- //goto highlighted area
- // -> done in the TextHighlighter class
+
+ //goto highlighted area
+ // -> done in the TextHighlighter class
}
-
+
}
-
+
public void valueChanged(ListSelectionEvent e) {
-
- String command = model.getCommand
- ((String)functionCombobox.getSelectedItem(),
- (String)deviceList.getSelectedValue());
-
- String syntax = model.getSyntax
- ((String)functionCombobox.getSelectedItem(),
- (String)deviceList.getSelectedValue());
-
- String description = model.getDescription
- ((String)functionCombobox.getSelectedItem(),
- (String)deviceList.getSelectedValue());
-
+
+ /*String command = model.getCommand((String)
functionCombobox.getSelectedItem(),
+ (MPDevicePair) deviceList.getSelectedValue());
+
+ String syntax = model.getSyntax((String)
functionCombobox.getSelectedItem(),
+ (MPDevicePair) deviceList.getSelectedValue());
+
+ String description = model.getDescription((String)
functionCombobox.getSelectedItem(),
+ (MPDevicePair) deviceList.getSelectedValue());
+
this.commandTextField.setText(command);
this.syntaxTextField.setText(syntax);
this.descriptionTextField.setText(description);
-
+ */
try {
- String result = model.getResult((String)deviceList.
- getSelectedValue());
+ String result = model.getResult((MPDevicePair)
deviceList.getSelectedValue());
resultTextArea.setText(result.replaceAll("@@@", "\n"));
-
+
resultTextArea.setCaretPosition(0);
-
- String status = model.getStatus((String)deviceList.
- getSelectedValue());
- statusTextField.setText(status);
+
+ //String status = model.getStatus((String)deviceList.
+ // getSelectedValue());
+ //statusTextField.setText(status);
} catch (Exception ex) {
ex.printStackTrace();
}
-
+
}
-
+
public void stateChanged(ChangeEvent event) {
-
+
//System.out.println(System.currentTimeMillis());
busy = false;
if (deviceList.getSelectedIndex() > -1) {
-
- String result = model.getResult((String)deviceList.
- getSelectedValue());
+
+ String result = model.getResult((MPDevicePair)
deviceList.getSelectedValue());
resultTextArea.setText(result.replaceAll("@@@", "\n"));
-
- String status = model.getStatus((String)deviceList.
- getSelectedValue());
- statusTextField.setText(status);
-
- //parameterListModel.removeAllElements();
-
-
-
+
+ //String status = model.getStatus((String)deviceList.
+ // getSelectedValue());
+ //statusTextField.setText(status);
+
+ //parameterListModel.removeAllElements();
+
+
+
} else {
String result = "Please select the device in the list above " +
- "of which the result has to be displayed.";
- resultTextArea.setText(result.replaceAll("@@@","\n"));
-
- statusTextField.setText("Please select the device in the list " +
- "above of which the result has to be displayed.");
-
+ "for which the result has to be displayed.";
+ resultTextArea.setText(result.replaceAll("@@@", "\n"));
+
//parameterListModel.removeAllElements();
-
-
+
+
commandTextField.setText(model.getCommand(
- (String)functionCombobox.getSelectedItem(),
- (String)deviceCombobox.getSelectedItem()));
-
- //Iterator it = parameterListModel.getAllElements().iterator();
- //while (it.hasNext())
- // commandTextField.setText(commandTextField.getText()
- // + " " + (String)it.next());
+ (String) functionCombobox.getSelectedItem(),
+ (String) deviceCombobox.getSelectedItem()));
+
+ //Iterator it = parameterListModel.getAllElements().iterator();
+ //while (it.hasNext())
+ // commandTextField.setText(commandTextField.getText()
+ // + " " + (String)it.next());
}
-
+
searchTextField.setEnabled(true);
highlightButton.setEnabled(true);
-
- queriedDeviceComboboxModel1.initComboBox
- (deviceListModel.getAllElements());
-
- queriedDeviceComboboxModel2.initComboBox
- (deviceListModel.getAllElements());
+
+
queriedDeviceComboboxModel1.initComboBox(deviceListModel.getAllElements());
+
+
queriedDeviceComboboxModel2.initComboBox(deviceListModel.getAllElements());
}
-
+
public JComboBox getWebserviceComboBox() {
return webserviceCombobox;
}
-
+
/**
* Code for the handling when a MP has been chosen from the
* Combobox
**/
public void webserviceComboboxActionperformedHandler(Document response) {
-
+
parameterStringTextField.setText("");
this.parameterStringTextField.setEnabled(false);
-
+
this.deviceCombobox.removeAllItems();
this.deviceCombobox.setEnabled(true);
this.deviceComboboxModel.removeAllElements();
this.functionCombobox.removeAllItems();
- this.functionCombobox.setEnabled(false);
+ this.functionCombobox.setEnabled(true);
this.functionComboboxModel.removeAllElements();
-
+
+
+
try {
model.clearMetadata();
model.addMetadataForCurrentMP(response);
this.deviceComboboxModel.initComboBox(this.webserviceCombobox.getSelectedItem());
} catch (Exception ex) {
- //JOptionPane.showMessageDialog(this,"An error occured while
getting\n" +
- // "the metadata from the Measurement Point","Error!",
JOptionPane.ERROR_MESSAGE);
-
+ javax.swing.JOptionPane.showMessageDialog(this, "An error occured
while getting\n" +
+ "the metadata from the Measurement Point", "Error!",
javax.swing.JOptionPane.ERROR_MESSAGE);
+
ex.printStackTrace();
}
+
+ if (deviceCombobox.getItemCount() != 0) {
+ addAllDevicesButton.setEnabled(true);
+ }
}
-
-
+
public void disableComboboxes() {
deviceCombobox.setEnabled(false);
deviceCombobox.setSelectedItem(null);
functionCombobox.setEnabled(false);
functionCombobox.setSelectedItem(null);
}
-
+
/**
* Code for the handling when a device has been chosen from the
* Combobox
**/
private void deviceComboboxHandler(java.awt.event.ActionEvent evt) {
-
+
parameterStringTextField.setText("");
-
-
+
+
if (deviceComboboxModel.getSelectedItem() != null) {
this.parameterStringTextField.setEnabled(true);
- functionComboboxModel.initComboBox
- ((String)deviceCombobox.getSelectedItem());
+ functionComboboxModel.initComboBox((String)
deviceCombobox.getSelectedItem());
functionCombobox.setEnabled(true);
+ functionCombobox.setSelectedIndex(0);
addDeviceButton.setEnabled(true);
-
+
} else {
this.parameterStringTextField.setEnabled(false);
- functionComboboxModel.initComboBox
- ((String)deviceCombobox.getSelectedItem());
+ functionComboboxModel.removeAllElements();
functionCombobox.setEnabled(false);
addDeviceButton.setEnabled(false);
-
+
}
-
+
}
-
+
/**
* Code to be executed when a specific function has been selected
**/
private void functionComboboxActionPerformed(java.awt.event.ActionEvent
evt) {
-
+
if (functionCombobox.isEnabled() &&
functionCombobox.getSelectedIndex() > -1) {
-
model.setSelectedCommand((String)functionCombobox.getSelectedItem());
-
+ model.setSelectedCommand(FunctionComboboxModel.COMMANDPREFIX + ""
+ functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION);
+
this.parameterStringTextField.setEnabled(true);
-
+
descriptionTextField.setText(model.getDescription(
- (String)functionCombobox.getSelectedItem(),
- (String)deviceCombobox.getSelectedItem()));
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
+ (String) deviceCombobox.getSelectedItem()));
syntaxTextField.setText(model.getSyntax(
- (String)functionCombobox.getSelectedItem(),
- (String)deviceCombobox.getSelectedItem()));
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
+ (String) deviceCombobox.getSelectedItem()));
commandTextField.setText(model.getCommand(
- (String)functionCombobox.getSelectedItem(),
- (String)deviceCombobox.getSelectedItem()));
-
-
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
+ (String) deviceCombobox.getSelectedItem()));
+
+
} else {
-
+
//this.parameterStringTextField.setEnabled(false);
-
+
descriptionTextField.setText("N/A");
syntaxTextField.setText("N/A");
commandTextField.setText("N/A");
parameterStringTextField.setText("");
-
+
}
deviceList.repaint();
}
-
+
private void addDeviceButtonActionPerformed(java.awt.event.ActionEvent
evt) {
-
+
if (deviceCombobox.getSelectedIndex() > -1) {
-
- if (!deviceListModel.getAllElements().contains
- ((String)deviceCombobox.getSelectedItem())) {
-
- deviceListModel.addElement
- ((String)deviceCombobox.getSelectedItem());
-
+
+ if (!deviceListModel.getAllElements().contains( new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
(String)deviceCombobox.getSelectedItem()))) {
+ MPDevicePair endpoint = new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
(String)deviceCombobox.getSelectedItem());
+ deviceListModel.addElement(endpoint);
+ //model.addSelectedEndpoint(endpoint);
+
resultTextArea.setText(null);
- statusTextField.setText(null);
-
+ //statusTextField.setText(null);
+
}
}
-
+
if (deviceListModel.getSize() > 0) {
-
+ exportButton.setEnabled(true);
removeDeviceButton.setEnabled(true);
-
+
}
}
-
+
private void
removeDeviceButtonActionPerformed(java.awt.event.ActionEvent evt) {
-
+
if (deviceList.getSelectedIndex() > -1) {
-
- deviceListModel.remove(deviceList.getSelectedIndex());
-
+
+ deviceListModel.removeElement(deviceList.getSelectedValue());
+
//model.removeSelectedEndpoint((MPDevicePair)deviceList.getSelectedValue());
}
-
+
if (deviceListModel.getSize() <= 0) {
-
+ exportButton.setEnabled(false);
removeDeviceButton.setEnabled(false);
resultTextArea.setText(null);
- statusTextField.setText(null);
-
+ //statusTextField.setText(null);
+
}
}
-
+
public boolean selectedCommandIsSupportedBySelectedDevices(String value)
{
-
+
boolean supported = true;
-
+
// selected devices
List selectedDevices = deviceListModel.getAllElements();
Iterator it = selectedDevices.iterator();
-
+
// all devices which are supported by the MP
List devices = model.getDevices();
-
+
Vector functions = null;
Iterator commands = null;
Command comm = null;
-
- if (!selectedDevices.isEmpty()){
- while (it.hasNext() && supported){
+
+ if (!selectedDevices.isEmpty()) {
+ while (it.hasNext() && supported) {
// the functions supported by one of the selected devices
String device = (String) it.next();
functions = model.getFunctions(device);
commands = functions.iterator();
-
+
boolean supportedByDevice = false;
- while (commands.hasNext() && !supportedByDevice){
+ while (commands.hasNext() && !supportedByDevice) {
comm = (Command) commands.next();
//System.out.println("Description: " +
comm.getDescription() + " and value: "+value);
//System.out.println("Function: " + comm.getFunction() +
" and value: "+value);
- if (value.startsWith(comm.getFunction()) ||
value.equals(comm.getDescription()))
+ if (value.startsWith(comm.getFunction()) ||
value.equals(comm.getDescription())) {
supportedByDevice = true;
+ }
}
- if (!supportedByDevice)
+ if (!supportedByDevice) {
supported = false;
+ }
}
-
+
}
-
+
return supported;
-
+
}
-
-
+
public String getSelectedCommand() {
- String res = (String)functionCombobox.getSelectedItem();
- if (res.equals("N/A"))
+ String res = (String) functionCombobox.getSelectedItem();
+ if (res.equals("N/A")) {
return "";
- else return res;
-
+ } else {
+ return FunctionComboboxModel.COMMANDPREFIX + "" + res +
FunctionComboboxModel.COMMANDVERSION;
+ }
+
}
-
+
public String getParameters() {
String res = parameterStringTextField.getText();
- if(res.equals("N/A"))
+ if (res.equals("N/A")) {
return "";
- else return res;
+ } else {
+ return res;
+ }
}
-
- public String getSelectedDevices() {
+
+ public String getSelectedDevices(LGEndpoint mp) {
String devices = "";
- Iterator it = deviceListModel.getAllElements().iterator();
- while (it.hasNext()){
- devices+=(String)it.next()+"@@@";
+ Iterator<String> it = model.getAllDevicesForMp(mp).iterator();
+ while (it.hasNext()) {
+ devices += it.next() + "@@@";
}
-
- return devices.substring(0,devices.length()-"@@@".length());
+
+ return devices.substring(0, devices.length() - "@@@".length());
}
+
+ public LookingGlassClientModel getLookingGlassClientModel(){
+ return model;
+ }
public void addCurrentDeviceToDevicesList() {
- if
(!deviceListModel.contains((String)deviceCombobox.getSelectedItem()))
-
deviceListModel.addElement((String)deviceCombobox.getSelectedItem());
-
+ if (!deviceListModel.contains( new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),(String)
deviceCombobox.getSelectedItem()))) {
+ MPDevicePair mp = new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(), (String)
deviceCombobox.getSelectedItem());
+ deviceListModel.addElement(mp);
+ //model.addSelectedEndpoint(mp);
+ }
+
}
-
-
- public void setResponse(Document response){
- try{
+
+ public void setResponse(Document response) {
+ try {
model.setQueryResult(response);
- } catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}
-
+
public void clear() {
- deviceListModel.removeAllElements();
-
- functionCombobox.setEnabled(false);
- functionCombobox.setSelectedItem(null);
+ deviceListModel.clear();
+ //model.clearSelectedEndpoints();
+
+ functionCombobox.setEnabled(false);
+ functionCombobox.setSelectedItem(null);
functionComboboxModel.removeAllElements();
-
- deviceCombobox.setEnabled(false);
- deviceComboboxModel.removeAllElements();
-
- webserviceComboboxModel.setSelectedItem(null);
-
- resultTextArea.setText(null);
-
- statusTextField.setText(null);
-
- addDeviceButton.setEnabled(false);
- removeDeviceButton.setEnabled(false);
-
- parameterStringTextField.setEnabled(false);
- parameterStringTextField.setText("");
-
- searchTextField.setEnabled(false);
- highlightButton.setEnabled(false);
+
+ deviceCombobox.setEnabled(false);
+ deviceComboboxModel.removeAllElements();
+
+ webserviceComboboxModel.setSelectedItem(null);
+
+ resultTextArea.setText(null);
+
+ //statusTextField.setText(null);
+
+ addDeviceButton.setEnabled(false);
+ removeDeviceButton.setEnabled(false);
+
+ parameterStringTextField.setEnabled(false);
+ parameterStringTextField.setText("");
+
+ searchTextField.setEnabled(false);
+ highlightButton.setEnabled(false);
}
-
-
+ public void exportDeviceListActionPerformed(java.awt.event.ActionEvent
evt) {
+ System.out.println("Exporting devicelist");
+
+ JFileChooser fc = new JFileChooser();
+
+ int returnVal = fc.showOpenDialog(this);
+ File destination = null;
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ destination = fc.getSelectedFile();
+ }
+
+ FileOutputStream fos = null;
+ ObjectOutputStream out = null;
+ try {
+ fos = new FileOutputStream(destination);
+ out = new ObjectOutputStream(fos);
+ out.writeObject(deviceListModel.getAllElements());
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } finally {
+ try {
+ out.close();
+ } catch(IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+
+ public void importDeviceListActionPerformed(java.awt.event.ActionEvent
evt) {
+ System.out.println("Importing devicelist");
+
+ JFileChooser fc = new JFileChooser();
+
+ int returnVal = fc.showOpenDialog(this);
+ File source = null;
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ source = fc.getSelectedFile();
+ System.out.println("Selected source file: "+
source.getAbsolutePath());
+ }
+
+ FileInputStream fis = null;
+ ObjectInputStream in = null;
+ try {
+ fis = new FileInputStream(source);
+ System.out.println("FileInputStream: " + fis);
+ in = new ObjectInputStream(fis);
+ System.out.println("ObjectInputStream: " + in);
+
+ deviceListModel.clear();
+ //model.clearSelectedEndpoints();
+ System.out.println("deviceListModel cleared");
+
+ List endpoints = (List)in.readObject();
+
+ deviceListModel.addAllElements(endpoints);
+ //model.addSelectedEndpoints(endpoints);
+ System.out.println("deviceListModel filled with data");
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } catch (ClassNotFoundException cnfe) {
+ cnfe.printStackTrace();
+ } finally {
+
+ try {
+ in.close();
+ } catch(IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ removeDeviceButton.setEnabled(true);
+ exportButton.setEnabled(true);
+ }
+
+ public void
addAllDevicesAndMPsActionPerformed(java.awt.event.ActionEvent evt) {
+
+ }
+
+ public void addAllDevicesActionPerformed(java.awt.event.ActionEvent evt)
{
+ for (int i = 0; i < deviceCombobox.getItemCount(); i++){
+ if (!deviceListModel.contains(new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(), (String)
deviceCombobox.getItemAt(i)))) {
+ MPDevicePair endpoint = new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(), (String)
deviceCombobox.getItemAt(i));
+ deviceListModel.addElement(endpoint);
+ //model.addSelectedEndpoint(endpoint);
+ }
+ }
+ deviceCombobox.setSelectedIndex(0);
+ removeDeviceButton.setEnabled(true);
+ exportButton.setEnabled(true);
+ }
+
+ public void appendOutputActionPerformed(java.awt.event.ActionEvent evt) {
+
+ }
+
+ public void clearDeviceListActionPerformed(java.awt.event.ActionEvent
evt) {
+ deviceListModel.clear();
+ //model.clearSelectedEndpoints();
+
+ removeDeviceButton.setEnabled(false);
+ exportButton.setEnabled(false);
+ }
+
/**
* Housekeeping code for ChangeListeners
**/
public void addChangeListener(ChangeListener l) {
-
+
listenerList.add(ChangeListener.class, l);
-
+
}
-
+
public void removeChangeListener(ChangeListener l) {
-
+
listenerList.remove(ChangeListener.class, l);
-
+
}
-
+
public void fireStateChanged() {
-
+
Object[] listeners = listenerList.getListenerList();
- for (int i=listeners.length-2; i >= 0; i-=2) {
-
- if (listeners[i] == ChangeListener.class)
- ((ChangeListener)listeners[i+1])
- .stateChanged(changeEvent);
-
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+
+ if (listeners[i] == ChangeListener.class) {
+ ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
+ }
+
}
-
+
}
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassTab.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassTab.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassTab.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -39,7 +39,8 @@
import org.perfsonar.perfsonarui.ui.PerfsonarModel;
import org.perfsonar.perfsonarui.ui.PluginMainPanel;
import org.perfsonar.perfsonarui.ui.actions.PerfsonarRequestAction;
-import org.perfsonar.perfsonarui.lookingglass.LGSetupDataRequestAction;
+import org.perfsonar.perfsonarui.plugins.MAEndpointList;
+import org.perfsonar.perfsonarui.ui.actions.PSUIAction;
/**
@@ -53,7 +54,10 @@
@Override
protected PerfsonarRequestAction createMetadataRequestAction() {
//the idea is to fill in dataList with entries coming from the
response. MetadataListResponseListener is responsible for processing the
request
- metadataRequestAction = new
MetadataKeyRequestAction(request,userData,dataList,endpointList,"Meta data
request");
+
+ System.out.println("Endpoints: " + endpointList);
+
+ metadataRequestAction = new
MetadataKeyRequestAction(request,userData,dataList,null,"Meta data request");
metadataRequestAction.setGroup(IPerfsonarTab.defaultGroupHidden);
return metadataRequestAction;
//return null
@@ -62,11 +66,17 @@
@Override
public PerfsonarRequestAction createDataRequestAction() {
- dataRequestAction = new LGSetupDataRequestAction(request, userData,
dataList, endpointList, "Query");
+ dataRequestAction = new LGSetupDataRequestAction(request, userData,
dataList, null, "Query");
return dataRequestAction;
}
@Override
+ public PSUIAction createEndpointsAction(MAEndpointList endpointList) {
+
+ return new LGShowEndpointsAction(endpointList, this);
+ }
+
+ @Override
protected SmartMARequest createSmartRequest() {
return new SmartMARequest() {
@Override
@@ -91,7 +101,7 @@
}
public PluginMainPanel createMainComponent(Component parentComponent) {
- panel = new LookingGlassMainPanel(parentComponent,this);
+ panel = new LookingGlassMainPanel(parentComponent, this);
return panel;
}
@@ -109,6 +119,10 @@
return super.createTimeValueResponseListener();
}
+
+ public LookingGlassMainPanel getMainPanel(){
+ return panel;
+ }
}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MetadataKeyRequestAction.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -6,7 +6,6 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.perfsonar.perfsonarui.lookingglass;
import java.awt.event.ActionEvent;
@@ -28,152 +27,156 @@
*
* @author smelis
*/
-public class MetadataKeyRequestAction extends PerfsonarRequestAction{
-
+public class MetadataKeyRequestAction extends PerfsonarRequestAction {
+
protected MetaDataList dataList;
protected MAEndpointList endpoints;
-
protected LookingGlassMainPanel parent;
-
/**
*
*/
private static final long serialVersionUID = 269024097063853042L;
-
+
public MetadataKeyRequestAction(IPerfsonarRequest request,
IUserData userData, MetaDataList dataList, MAEndpointList
endpoints) {
- this(request,userData,dataList,endpoints, "Refresh nodes");
+ this(request, userData, dataList, endpoints, "Refresh nodes");
}
-
+
public MetadataKeyRequestAction(IPerfsonarRequest request,
IUserData userData,
MetaDataList dataList, MAEndpointList endpoints, String arg0) {
- this(request,userData,dataList,endpoints, arg0,null);
+ this(request, userData, dataList, endpoints, arg0, null);
}
-
+
public MetadataKeyRequestAction(IPerfsonarRequest request,
IUserData userData,
MetaDataList dataList, MAEndpointList endpoints, String arg0,
Icon arg1) {
- super(request,userData,arg0,arg1,IPerfsonarTab.defaultGroupQuery);
+ super(request, userData, arg0, arg1, IPerfsonarTab.defaultGroupQuery);
setDataList(dataList);
setEndpoints(endpoints);
- putValue(SHORT_DESCRIPTION,"Retrieves metadata of all defined
interfaces for given URL.");
+ putValue(SHORT_DESCRIPTION, "Retrieves metadata of all defined
interfaces for given URL.");
}
-
+
@Override
public Object run(ActionEvent arg0) {
- //System.out.println("Selected item:
"+parent.getWebserviceComboBox().getSelectedItem());
-
- //System.out.println("Number of endpoints: " + endpoints.size());
-
- if (request == null) return null; //TODO check if this should
silently fail
- try {
- enableActions(true);
-
- dataList.clear();
- dataList.setNotificationEnabled(false);
-
- //datePanel = null;
- enableActions(false);
- //endpointsPanel = null;
-
- boolean ok = false;
- for (int i=0; i < endpoints.size();i++) {
- if (isInterrupted()) break;
- MAEndpoint mae = endpoints.get(i);
+ if (parent.getWebserviceComboBox().getSelectedItem() != null) {
+ //System.out.println("Selected item: " +
parent.getWebserviceComboBox().getSelectedItem());
+
+
+ if (request == null) {
+ return null;
+ } //TODO check if this should silently fail
+ try {
+ enableActions(true);
+
+ dataList.clear();
+ dataList.setNotificationEnabled(false);
+
+ //datePanel = null;
+ enableActions(false);
+ //endpointsPanel = null;
+
+ boolean ok = false;
+
+ MAEndpoint mae = (MAEndpoint)
parent.getWebserviceComboBox().getSelectedItem();
//System.out.println("Endpoint : " + mae.getTitle());
- if (mae.isEnabled() &&
parent.getWebserviceComboBox().getSelectedItem() != null &&
-
mae.getTitle().equalsIgnoreCase(parent.getWebserviceComboBox()
- .getSelectedItem().toString())) {
//if (mae.isEnabled()){
+
+ dataList.setNotificationEnabled(false);
+ userData.setEndpoint(mae);
+ //System.out.println("Retrieving metadata from " +
userData.getEndpoint());
+ request.fireStatusMessage("Retrieving metadata from " +
mae.getEndpoint());
+ //System.out.println("Retrieving metadata from " +
mae.getEndpoint());
+ try {
+ MetadataListResponseListener listener = new
MetadataListResponseListener(dataList) {
+
+ @Override
+ public synchronized void
callException(PerfsonarResponseEvent e) {
+ super.callException(e);
+
+ //System.out.println("callException called");
+
+ getDataList().clear();
+ logger.error(e.getException());
+ handleException(e.getException(),
userData.getEndpoint());
+ getDataList().setSelectedItem(null);
+ //request.removePropertyChangeListener(this);
+ }
+
+ @Override
+ public synchronized void
callCompleted(IPerfsonarRequest request) {
+ super.callCompleted(request);
+ //request.removePropertyChangeListener(this);
+
+ //System.out.println("callCompleted called");
+ }
+
+ @Override
+ public void process(IPerfsonarRequest request,
IUserData uData, Document response) throws Exception {
+ super.process(request, uData, response);
+ getDataList().setSelectedItem(null);
+
parent.webserviceComboboxActionperformedHandler(response);
+ }
+
+ @Override
+ public synchronized void
processingCompleted(IPerfsonarRequest request) {
+ super.processingCompleted(request);
+ getDataList().setSelectedItem(null);
+
+ //System.out.println("processingCompleted called");
+ }
+ };
+ request.makeRequest(userData,
IPerfsonarRequest.MA_MetadataKeyRequest, listener, false);
+ mae.setStatus("OK");
+ mae.setStatusExplanation("OK");
+ mae.setAlive(true);
+
ok = true;
- dataList.setNotificationEnabled(false);
- userData.setEndpoint(mae);
- //System.out.println("Retrieving metadata from " +
userData.getEndpoint());
- request.fireStatusMessage("Retrieving metadata from " +
userData.getEndpoint());
- try {
- MetadataListResponseListener listener = new
MetadataListResponseListener(dataList) {
- @Override
- public synchronized void
callException(PerfsonarResponseEvent e) {
- super.callException(e);
-
- //System.out.println("callException called");
-
- getDataList().clear();
- logger.error(e.getException());
-
handleException(e.getException(),userData.getEndpoint());
- getDataList().setSelectedItem(null);
- //request.removePropertyChangeListener(this);
- }
- @Override
- public synchronized void
callCompleted(IPerfsonarRequest request) {
- super.callCompleted(request);
- //request.removePropertyChangeListener(this);
-
- //System.out.println("callCompleted called");
- }
- @Override
- public void process(IPerfsonarRequest request,
IUserData uData, Document response) throws Exception {
- super.process(request, uData, response);
- getDataList().setSelectedItem(null);
-
parent.webserviceComboboxActionperformedHandler(response);
- }
- @Override
- public synchronized void
processingCompleted(IPerfsonarRequest request) {
- super.processingCompleted(request);
- getDataList().setSelectedItem(null);
-
- //System.out.println("processingCompleted
called");
- }
-
- };
- request.makeRequest(userData,
IPerfsonarRequest.MA_MetadataKeyRequest, listener, false);
- mae.setStatus("OK");
- mae.setStatusExplanation("OK");
- mae.setAlive(true );
-
- break;
- //PerfsonarResponseEvent.COMMAND_CALLEXCEPTION
-
//request.addPropertyChangeListener(PerfsonarResponseEvent);
- } catch (Exception x) {
- logger.error(x);
- handleException(x,mae);
- }
-
+
+ //PerfsonarResponseEvent.COMMAND_CALLEXCEPTION
+ //request.addPropertyChangeListener(PerfsonarResponseEvent);
+ } catch (Exception x) {
+ logger.error(x);
+ handleException(x, mae);
}
+
+ if (request instanceof SmartMARequest) {
+ ((SmartMARequest) request).isReady();
+ }
+
+ dataList.setNotificationEnabled(true);
+ if (!ok && parent.getWebserviceComboBox().getSelectedItem()
!= null) {
+ JOptionPane.showMessageDialog(frame, "No IPPM service
selected!", "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ } catch (Exception x) {
+ JOptionPane.showMessageDialog(frame, "Exception: " + x,
"Error", JOptionPane.ERROR_MESSAGE);
+ x.printStackTrace();
+ logger.error(x);
}
-
- if (request instanceof SmartMARequest)
- ((SmartMARequest) request).isReady();
-
- dataList.setNotificationEnabled(true);
- if (!ok && parent.getWebserviceComboBox().getSelectedItem() !=
null)
- JOptionPane.showMessageDialog(frame,"No IPPM service
selected!","Error",JOptionPane.ERROR_MESSAGE);
- } catch (Exception x) {
-
JOptionPane.showMessageDialog(frame,x,"Error",JOptionPane.ERROR_MESSAGE);
- x.printStackTrace();
- logger.error(x);
}
return null;
}
+
@Override
public void done(Object result) {
}
-
+
public MetaDataList getDataList() {
return dataList;
}
-
+
public void setDataList(MetaDataList dataList) {
this.dataList = dataList;
}
-
+
public synchronized MAEndpointList getEndpoints() {
return endpoints;
}
+
public synchronized void setEndpoints(MAEndpointList endpoints) {
this.endpoints = endpoints;
}
+
protected void handleException(Exception x, MAEndpoint endpoint) {
endpoint.setStatus(x.getMessage());
endpoint.setStatusExplanation(x);
@@ -181,13 +184,11 @@
parent.disableComboboxes();
JOptionPane.showMessageDialog(frame,
x.getMessage() + "\nThere seems to be a problem with the
connection\n" +
- "to the device. Please check if the URL is valid."
- ,"Error",JOptionPane.ERROR_MESSAGE);
+ "to the device. Please check if the URL is valid.", "Error",
JOptionPane.ERROR_MESSAGE);
}
-
- public void setParent (LookingGlassMainPanel parent) {
- this.parent = parent;
+
+ public void setParent(LookingGlassMainPanel parent) {
+ this.parent = parent;
}
-
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceListModel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -11,33 +11,96 @@
import java.util.ArrayList;
import java.util.List;
-import javax.swing.DefaultListModel;
+import javax.swing.AbstractListModel;
+import org.perfsonar.perfsonarui.lookingglass.MPDevicePair;
/**
*
* @author svrstich
()
*/
-public class DeviceListModel extends DefaultListModel {
+public class DeviceListModel extends AbstractListModel {
//Main application model
private LookingGlassClientModel model = null;
- /** Creates a new instance of ParameterListModel */
+ private List<MPDevicePair> list;
+
+ /** Creates a new instance of DeviceListModel */
public DeviceListModel(LookingGlassClientModel model) {
this.model = model;
+ list = new ArrayList<MPDevicePair>();
}
public List getAllElements() {
- List result = new ArrayList();
+ //List result = new ArrayList();
- for (int i = 0; i < this.getSize(); i++)
- result.add(this.getElementAt(i));
+ //for (int i = 0; i < this.getSize(); i++)
+ // result.add(this.getElementAt(i));
- return result;
-
+ //return result;
+ return model.getSelectedEndpoints();
}
+ public int getSize(){
+ return model.getSelectedEndpoints().size();
+ }
+
+
+ public Object getElementAt(int i) {
+ return model.getSelectedEndpoints().get(i);
+ }
+
+
+ public void addElement(Object obj){
+ int index = model.getSelectedEndpoints().size();
+
+ //list.add((MPDevicePair)obj);
+ model.addSelectedEndpoint((MPDevicePair) obj);
+
+ System.out.println("Element added: " + obj);
+
+ fireIntervalAdded(this, index, index);
+ }
+
+
+ public boolean removeElement(Object obj){
+ boolean success = false;
+ int index = model.getSelectedEndpoints().size();
+ success = model.getSelectedEndpoints().remove(obj);
+
+ System.out.println("Element removed: " + obj);
+
+ fireIntervalRemoved(this, 0, index);
+
+ return success;
+ }
+
+ public void remove (int i){
+ int index = model.getSelectedEndpoints().size();
+ model.getSelectedEndpoints().remove(i);
+ fireIntervalRemoved(this, 0, index);
+
+ }
+
+ public void clear (){
+ int index = model.getSelectedEndpoints().size();
+ model.clearSelectedEndpoints();
+
+ fireContentsChanged(this, 0, index);
+ }
+
+ public boolean contains (Object obj){
+ return model.getSelectedEndpoints().contains(obj);
+ }
+
+ public void addAllElements(List l){
+ int index = model.getSelectedEndpoints().size();
+
+ model.getSelectedEndpoints().addAll(l);
+
+ fireContentsChanged(this, 0, index);
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -6,7 +6,6 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.perfsonar.perfsonarui.lookingglass.model;
import java.util.Collections;
@@ -20,101 +19,103 @@
* @author svrstich
()
*/
public class FunctionComboboxModel extends DefaultComboBoxModel {
-
+
+ public static final String COMMANDPREFIX =
"http://schemas.perfsonar.net/tools/sshtelnet/";
+ public static final String COMMANDVERSION = "/1.0";
//Application General model
private LookingGlassClientModel model = null;
-
//Indicated whether to use the symbolic command or
//the description in the combobox
private boolean symbolic = true;
-
private String selectedDevice = null;
-
+
/** Creates a new instance of webserviceComboboxModel */
public FunctionComboboxModel(LookingGlassClientModel model) {
-
- this.model = model;
-
+
+ this.model = model;
+
}
-
+
/**
* Fill up the combobox with some usefuls tuff
**/
public void initComboBox(String selectedDevice) {
-
- this.selectedDevice = selectedDevice;
-
- if (selectedDevice != null) {
-
- this.removeAllElements();
- Vector functions;
-
- if (symbolic) {
- functions = model.getFunctions(selectedDevice);
- }
- else {
- functions = model.getDescriptions(selectedDevice);
- }
-
- Vector functions2 = new Vector();
- Iterator itf = functions.iterator();
- while (itf.hasNext()) {
- Command command = (Command)itf.next();
- if (symbolic) {
- functions2.add(command.getFunction());
- } else {
- if (command.getDescription() == null) {
- functions2.add(command.getFunction() +
- " :: No description available");
- } else {
- functions2.add(command.getDescription());
- }
- }
- }
-
- Collections.sort(functions2, new StringComparator());
- Iterator it = functions2.iterator();
-
- while (it.hasNext()) {
-
- this.addElement((String)it.next().toString());
-
- }
-
- this.setSelectedItem(functions2.firstElement());
-
- }
-
+
+ this.selectedDevice = selectedDevice;
+
+ if (selectedDevice != null) {
+
+ this.removeAllElements();
+ Vector functions;
+
+ if (symbolic) {
+ functions = model.getFunctions(selectedDevice);
+ } else {
+ functions = model.getDescriptions(selectedDevice);
+ }
+
+ Vector functions2 = new Vector();
+ Iterator itf = functions.iterator();
+ while (itf.hasNext()) {
+ Command command = (Command) itf.next();
+ if (symbolic) {
+ String s = command.getFunction();
+ s = s.substring(COMMANDPREFIX.length(), s.length());
+ s = s.substring(0, s.length() - COMMANDVERSION.length());
+ functions2.add(s);
+ } else {
+ if (command.getDescription() == null) {
+ functions2.add(command.getFunction() +
+ " :: No description available");
+ } else {
+ functions2.add(command.getDescription());
+ }
+ }
+ }
+
+ Collections.sort(functions2, new StringComparator());
+ Iterator it = functions2.iterator();
+
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ this.addElement(s);
+ }
+
+ this.setSelectedItem(functions2.firstElement());
+
+ }
+
}
-
+
public void changeSymbolic() {
-
- symbolic = !symbolic;
- initComboBox(selectedDevice);
-
+
+ symbolic = !symbolic;
+ initComboBox(selectedDevice);
+
}
-
+
public boolean isSymbolic() {
-
- return symbolic;
-
+
+ return symbolic;
+
}
-
+
public String getSymbolic(String description, String selectedDevice) {
-
- if (description.contains(" :: No description available")) {
- return description.substring(0, description.indexOf(" :: No
description available"));
- } else {
- Vector descriptions = model.getDescriptions(selectedDevice);
- Iterator it = descriptions.iterator();
- while (it.hasNext()) {
- Command command = (Command)it.next();
- if (command.getDescription().equalsIgnoreCase(description))
- return command.getFunction();
- }
-
- return null;
- }
+ if (description.contains(" :: No description available")) {
+ return description.substring(0, description.indexOf(" :: No
description available"));
+ } else {
+ Vector descriptions = model.getDescriptions(selectedDevice);
+
+ Iterator it = descriptions.iterator();
+ while (it.hasNext()) {
+ Command command = (Command) it.next();
+ if (command.getDescription().equalsIgnoreCase(description)) {
+ return command.getFunction();
+ }
+ }
+
+ return null;
+ }
}
-}
\ No newline at end of file
+}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LGEndpoint.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -24,6 +24,7 @@
import org.jdom.Namespace;
import org.jdom.input.DOMBuilder;
import org.perfsonar.perfsonarui.AbstractMARequest;
+import org.perfsonar.perfsonarui.lookingglass.MPDevicePair;
import org.w3c.dom.Document;
@@ -52,6 +53,8 @@
private List functions = null;
private List urls = null;
+ private List<MPDevicePair> selectedEndpoints = null;
+
private String selectedCommand = null;
/* feature ids */
@@ -75,6 +78,7 @@
functions = new ArrayList();
urls = new ArrayList();
+ selectedEndpoints = new ArrayList<MPDevicePair>();
}
/**
@@ -403,7 +407,7 @@
/**
* Return the result from the MP to the requestor
**/
- public String getResult(String device) {
+ public String getResult(MPDevicePair device) {
int place = getDevicePlace(device);
String result = resultStringTable[place];
@@ -424,14 +428,14 @@
/**
* Return the status from the MP to the requestor
**/
- public String getStatus(String device) {
+ public String getStatus(MPDevicePair device) {
int place = getDevicePlace(device);
return statusStringTable[place];
}
- private int getDevicePlace(String device) {
+ private int getDevicePlace(MPDevicePair device) {
//for (int i = 0; i < devicesTable.length; i++) {
@@ -441,10 +445,10 @@
//System.out.println();
//}
- for (int i = 0; i < devicesTable.length; i++) {
+ for (int i = 0; i < selectedEndpoints.size(); i++) {
//System.out.println("i:" + i);
//System.out.println("devicesTable[" +i+ "] = " +
devicesTable[i]);
- if (devicesTable[i] != null &&
devicesTable[i].equalsIgnoreCase(device))
+ if (selectedEndpoints.get(i) != null &&
selectedEndpoints.get(i).equals(device))
return i;
}
return 0;
@@ -567,7 +571,9 @@
command.getCommand() == null)
return "N/A";
else
- return command.getCommand();
+ return command.getCommand() +
+ ((command.getSyntax() != null &&
+ !command.getSyntax().equals(""))? " " +
command.getSyntax() : "");
}
}
}
@@ -596,7 +602,7 @@
}
- public String getValue(String device) {
+ public String getValue(MPDevicePair device) {
int index = this.getDevicePlace(device);
return resultStringTable[index];
@@ -618,4 +624,45 @@
public void setSelectedCommand(String selectedCommand) {
this.selectedCommand = selectedCommand;
}
+
+ public void addSelectedEndpoint(MPDevicePair endpoint){
+ selectedEndpoints.add(endpoint);
+ }
+
+ public void addSelectedEndpoints(List endpoints){
+ selectedEndpoints.addAll(endpoints);
+ }
+
+ public boolean removeSelectedEndpoint(MPDevicePair endpoint){
+ return selectedEndpoints.remove(endpoint);
+ }
+
+ public boolean removeSelectedEndpoint(int index){
+ if (index < selectedEndpoints.size()){
+ selectedEndpoints.remove(index);
+ return true;
+ }
+ else return false;
+ }
+
+ public void clearSelectedEndpoints(){
+ selectedEndpoints.clear();
+ }
+
+ public List<MPDevicePair> getSelectedEndpoints(){
+ return selectedEndpoints;
+ }
+
+ public List<String> getAllDevicesForMp(LGEndpoint mp){
+ List<String> result = new ArrayList<String>();
+
+ Iterator<MPDevicePair> it = selectedEndpoints.iterator();
+ while (it.hasNext()){
+ MPDevicePair pair = it.next();
+ if (pair.getMp() == mp)
+ result.add(pair.getDevice());
+ }
+
+ return result;
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebserviceComboboxModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebserviceComboboxModel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebserviceComboboxModel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -9,246 +9,59 @@
package org.perfsonar.perfsonarui.lookingglass.model;
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
-import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
- * Slightly modigied ComboboxModel to cater for the mapping
+ * Slightly modified ComboboxModel to cater for the mapping
* between de MP description and the URL
*
- * @author svrstich
()
- * @author smelis (Stijn Melis): Migration to perfsonarUI
+ * @author smelis (Stijn Melis)
*/
public class WebserviceComboboxModel extends DefaultComboBoxModel
implements ChangeListener {
- private boolean busy = false;
- private boolean first = true;
+ //private Map webservicesMap = null;
+ //private WebservicesModel webservicesModel;
- private LookingGlassClientModel model = null;
- private Map webservicesMap = null;
-
/** Creates a new instance of webserviceComboboxModel */
- public WebserviceComboboxModel(LookingGlassClientModel model) {
-
- this.model = model;
- initComboBox();
-
- }
-
- /**
- * Fill up the combobox with some useful stuff
- **/
- public void initComboBox() {
-
- try {
-
- webservicesMap = new HashMap();
-
- FileInputStream in = new
FileInputStream("org/perfsonar/perfsonarui/config/MA.conf");
- BufferedReader br = new BufferedReader(new
InputStreamReader(in));
-
- String line = br.readLine();
- StringTokenizer tok;
-
- String title;
- String endpoint;
- String type;
-
- while (line != null) {
- if (line.charAt(0) != ';') { //endpoint is enabled
- line.substring(1); //remove the first character (';')
- tok = new StringTokenizer (line, ",");
- title = tok.nextToken();
- endpoint = tok.nextToken();
- type = tok.nextToken();
- if (type.equals("lg"))
- webservicesMap.put(title, endpoint);
- }
- line = br.readLine();
- }
+ public WebserviceComboboxModel() {
+ //System.out.println("WebserviceComboboxModel created");
-
- } catch (FileNotFoundException ex) {
-
- ex.printStackTrace();
-
- } catch (IOException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The configuration file could not be read!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- }
+ //this.webservicesModel = webservicesModel;
}
-
-
/**
* Listens to changes in configured MPs
**/
public void stateChanged(ChangeEvent event) {
-
- busy = true;
- this.setSelectedItem(null);
-
- try {
-
- webservicesMap = new HashMap();
-
- FileInputStream in = new
FileInputStream("org/perfsonar/perfsonarui/config/MA.conf");
- BufferedReader br = new BufferedReader(new
InputStreamReader(in));
-
- String line = br.readLine();
- StringTokenizer tok;
-
- String title;
- String endpoint;
- String type;
-
- while (line != null) {
- if (line.charAt(0) != ';') { //endpoint is enabled
- line.substring(1); //remove the first character (';')
- tok = new StringTokenizer (line, ",");
- title = tok.nextToken();
- endpoint = tok.nextToken();
- type = tok.nextToken();
- if (type.equals("lg"))
- webservicesMap.put(title, endpoint);
- }
- line = br.readLine();
- }
- } catch (FileNotFoundException ex) {
-
- /*
- JOptionPane.showMessageDialog(null,
- "The configuration file could not be found!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- **/
- ex.printStackTrace();
-
- } catch (IOException ex) {
-
- JOptionPane.showMessageDialog(null,
- "The configuration file could not be read!",
- "Configruration Error",
- JOptionPane.ERROR_MESSAGE);
- ex.printStackTrace();
-
- }
-
- busy = false;
- this.fireContentsChanged(this,0,this.getSize()-1);
-
+ fireContentsChanged(this,0, WebservicesModel.getNumberOfMPs());
}
+ @Override
public Object getElementAt(int index) {
-
- while (busy) {
-
- try {
-
- Thread.sleep(250);
-
- } catch (InterruptedException ex) {
-
- ex.printStackTrace();
-
- }
-
- }
-
//System.out.println(webservicesMap);
- //System.out.println("returning: " +
webservicesMap.keySet().toArray()[index]);
-
- return webservicesMap.keySet().toArray()[index];
-
+ if (WebservicesModel.getEndpoint(index) != null)
+ return WebservicesModel.getEndpoint(index);
+ else return null;
}
+ @Override
public int getIndexOf(Object anObject) {
+ return WebservicesModel.getIndexOf(anObject);
- while (busy) {
-
- try {
-
- Thread.sleep(250);
-
- } catch (InterruptedException ex) {
-
- ex.printStackTrace();
-
- }
-
- }
-
- Object[] table = webservicesMap.keySet().toArray();
-
- for (int i = 0; i < table.length; i++) {
-
- if (anObject.toString().equalsIgnoreCase(table[i].toString()))
-
- return i;
-
- }
-
- return -1;
-
}
+ @Override
public int getSize() {
-
- while (busy) {
-
- try {
-
- Thread.sleep(250);
-
- } catch (InterruptedException ex) {
-
- ex.printStackTrace();
-
- }
-
- }
-
- return webservicesMap.size();
-
+ return WebservicesModel.getNumberOfMPs();
}
- public String getUrl(String description) {
+ /*public String getUrl(String name) {
- while (busy) {
-
- try {
-
- Thread.sleep(250);
-
- } catch (InterruptedException ex) {
-
- ex.printStackTrace();
-
- }
-
- }
- //System.out.println(webservicesMap.get(description));
+ return WebservicesModel.getURL(name);
- return webservicesMap.get(description).toString();
-
- }
+ }*/
}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesModel.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesTableModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesTableModel.java
2008-05-19 14:13:14 UTC (rev 3850)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/WebservicesTableModel.java
2008-05-20 08:35:01 UTC (rev 3851)
@@ -6,46 +6,91 @@
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
-
package org.perfsonar.perfsonarui.lookingglass.model;
import java.io.Serializable;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
+import org.perfsonar.perfsonarui.lookingglass.LookingGlassTab;
/**
*
* @author svrstich
*/
public class WebservicesTableModel extends DefaultTableModel
- implements Serializable{
+ implements Serializable {
+
+ LookingGlassTab parentFrame;
- boolean first = true;
-
+ //WebservicesModel model;
/** Creates a new instance of WebservicesTableModel */
- public WebservicesTableModel() {
-
- super(new Object[] {"Description", "url"}, 0);
-
-
- if (first) {
-
- this.addRow(new Object[]
- {"chaos169",
-
"http://chaos169.test.atlantis.ugent.be:8080/TelnetSSHMP/services/TelnetSSHMP"
});
- first = false;
-
- }
-
-
+ public WebservicesTableModel(LookingGlassTab parentFrame) {
+ this.parentFrame = parentFrame;
+
+ //this.model = model;
}
+
+ @Override
+ public void addRow(Vector rowData) {
+ WebservicesModel.addMP(rowData);
+
+ fireTableDataChanged();
+ parentFrame.getMainPanel().fireStateChanged();
+ }
+
+ @Override
+ public void addRow(Object[] rowData) {
+ WebservicesModel.addMP(rowData);
+
+ fireTableDataChanged();
+ parentFrame.getMainPanel().fireStateChanged();
+ }
+
+ @Override
+ public void removeRow(int row) {
+ WebservicesModel.removeMP(row);
+
+ fireTableDataChanged();
+ parentFrame.getMainPanel().fireStateChanged();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ if (column == 0) {
+ return WebservicesModel.getName(row);
+ } else if (column == 1) {
+ String key = WebservicesModel.getName(row);
+ return WebservicesModel.getURL(key);
+ } else {
+ return null; //should never happen
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+ //if (WebservicesModel != null)
+ return WebservicesModel.getNumberOfMPs();
+ //else return 0;
+ }
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ public String getColumnName(int col) {
+ if (col == 0)
+ return "Name";
+ else if (col == 1)
+ return "URL";
+ else return ""; //Should not happen
+ }
+
public Vector getColumnIdentifiers() {
-
- Vector result = new Vector();
- result.add("Description");
- result.add("url");
- return result;
-
+
+ Vector result = new Vector();
+ result.add("Name");
+ result.add("URL");
+ return result;
}
}
- perfsonar: r3851 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model, svnlog, 05/20/2008
Archive powered by MHonArc 2.6.16.