perfsonar-dev - perfsonar: r4739 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: playground ui
Subject: perfsonar development work
List archive
perfsonar: r4739 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: playground ui
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4739 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: playground ui
- Date: Fri, 5 Dec 2008 10:14:33 -0500
Author: nemanja.zutic
Date: 2008-12-05 10:14:33 -0500 (Fri, 05 Dec 2008)
New Revision: 4739
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPredefined.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_error.png
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_success.png
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_unknown.png
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_warn.png
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PerfsonarPlaygroundModel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPanel.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
Log:
Modification of the Playground tab. Added pre-defined request for service
testing
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PerfsonarPlaygroundModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PerfsonarPlaygroundModel.java
2008-12-04 14:30:45 UTC (rev 4738)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PerfsonarPlaygroundModel.java
2008-12-05 15:14:33 UTC (rev 4739)
@@ -22,14 +22,22 @@
import java.awt.Component;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingConstants;
+
import org.perfsonar.perfsonarui.AbstractUserData;
+import org.perfsonar.perfsonarui.EchoSmartRequest;
import org.perfsonar.perfsonarui.IPerfsonarSchema;
+import org.perfsonar.perfsonarui.PerfsonarSchema;
import org.perfsonar.perfsonarui.SmartMARequest;
import org.perfsonar.perfsonarui.aa.ICredentialsListener;
import org.perfsonar.perfsonarui.aa.SwingCredentialListener;
+import org.perfsonar.perfsonarui.ls.LSEndpointsPanel;
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
import org.perfsonar.perfsonarui.plugins.ITimeValueResponse;
@@ -38,10 +46,14 @@
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.perfsonar.perfsonarui.ui.PerfsonarModel;
+import org.perfsonar.perfsonarui.ui.actions.EchoAction;
+import org.perfsonar.perfsonarui.ui.actions.FileEndpointsAction;
+import org.perfsonar.perfsonarui.ui.actions.NewEndpointAction;
import org.perfsonar.perfsonarui.ui.actions.PSUIAction;
import org.perfsonar.perfsonarui.ui.actions.PerfsonarRequestAction;
import org.perfsonar.perfsonarui.ui.actions.SelectOneEndpointAction;
import org.perfsonar.perfsonarui.ui.actions.ShowEndpointsAction;
+import org.perfsonar.perfsonarui.ui.panels.MAEndpointsPanel;
/**
* Simple instance of
{@link
IPerfsonarTab}.
@@ -49,6 +61,9 @@
*
*/
public class PerfsonarPlaygroundModel extends PerfsonarModel {
+
+ public MAEndpointList myEndpoints;
+
/**
* Constructor.
*
@@ -76,8 +91,91 @@
}
@Override
public PSUIAction createEndpointsAction(MAEndpointList endpointList) {
- SelectOneEndpointAction action = new
SelectOneEndpointAction(endpointList);
+ SelectOneEndpointAction action = new
SelectOneEndpointAction(endpointList){
+
+ protected JComponent createEndpointsPanel() {
+ boolean selected = false;
+ if(myEndpoints==null){
+ for (int i=0; i < endpoints.size();i++)
+ if (endpoints.get(i).isEnabled()) {
+ if (selected)
endpoints.get(i).setEnabled(false);
+ selected = true;
+ }
+ return super.createEndpointsPanel();
+ }
+ else{
+ for (int i=0; i < myEndpoints.size();i++)
+ if (myEndpoints.get(i).isEnabled()) {
+ if (selected)
myEndpoints.get(i).setEnabled(false);
+ selected = true;
+ }
+ actions = createActions();
+ JTabbedPane pane = new
JTabbedPane(SwingConstants.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT);
+ pane.addTab(".conf file", new
MAEndpointsPanel(myEndpoints,actions));
+ pane.addTab("Lookup Service", new
LSEndpointsPanel(!myEndpoints.isMultipleEndpoints()));
+
+ for (int i=0; i < actions.length;i++) {
+ actions[i].setActions(allActions);
+ actions[i].setFrame(pane);
+ allActions.put(Integer.toString(i+1),
actions[i]);
+ }
+
+ return pane;
+ }
+ }
+
+ protected PSUIAction[] createActions() {
+ PSUIAction[] actions = new PSUIAction[4];
+ EchoSmartRequest echoRequest = new EchoSmartRequest();
+ echoRequest.setTimeout(10000);
+
+ if(myEndpoints==null){
+ actions[0] = new EchoAction(echoRequest, new
AbstractUserData() {
+ @Override
+ public void
makeQueryFromResponse() {}
+ },endpoints);
+ actions[1] = new
FileEndpointsAction(endpoints,true);
+ actions[2] = new
FileEndpointsAction(endpoints,false);
+ actions[3] = new NewEndpointAction(endpoints);
+ //actions[4] = new
LSRetrieveEndpointsAction(endpoints);
+ return actions;
+ }
+ else {
+ actions[0] = new EchoAction(echoRequest, new
AbstractUserData() {
+ @Override
+ public void
makeQueryFromResponse() {}
+ },myEndpoints);
+ actions[1] = new
FileEndpointsAction(myEndpoints,true);
+ actions[2] = new
FileEndpointsAction(myEndpoints,false);
+ actions[3] = new
NewEndpointAction(myEndpoints);
+ //actions[4] = new
LSRetrieveEndpointsAction(endpoints);
+ return actions;
+ }
+ }
+
+ protected Collection<MAEndpoint>
getSelectedEndpoints() {
+ List<MAEndpoint> points = new
ArrayList<MAEndpoint>();
+ if(myEndpoints==null){
+ for(MAEndpoint point : endpoints) {
+ if(point.isEnabled()) {
+ points.add(point);
+ }
+ }
+ return points;
+ }
+ else{
+ for(MAEndpoint point : myEndpoints) {
+ if(point.isEnabled()) {
+ points.add(point);
+ }
+ }
+ return points;
+ }
+ }
+
+ };
action.addListener(new ShowEndpointsAction.Listener() {
+
public void actionFinished(Collection<MAEndpoint>
selected) {
for(MAEndpoint point : selected) {
if(point.isEnabled()) {
@@ -96,12 +194,6 @@
@Override
public ITimeValueResponse createTimeValueResponseListener() {
return null;
- /*
- PerfsonarTimeSeriesDataset ifDataset = new
PerfsonarTimeSeriesDataset();
- ifDataset.addSeries("inbound",new
InterfaceUtilizationSeries("inbound",true));
- ifDataset.addSeries("outbound",new
InterfaceUtilizationSeries("outbound",false));
- return ifDataset;
- */
}
/**
@@ -110,7 +202,7 @@
*/
public MAEndpointList createEndpoints() {
try {
- MAEndpointList list = new MAEndpointList(new
File("MA.conf"),null);
+ MAEndpointList list = new MAEndpointList(new
File("MA.conf"),getSupportedRequests());
list.setMultipleEndpoints(false);
return list;
} catch (Exception x) {
@@ -151,10 +243,30 @@
}
@Override
public List<IPerfsonarSchema> getSupportedRequests() {
- // TODO Auto-generated method stub
- return null;
+ String selected =
PlaygroundPredefined.getInstance().getCurrentSchema();
+ if(selected==null) return null;
+ ArrayList<IPerfsonarSchema> supported = new
ArrayList<IPerfsonarSchema>();
+ supported.add(PerfsonarSchema.getInstance(selected));
+ return supported;
}
-
+
+ public void activateSpecific(){
+ String specific =
PlaygroundPredefined.getInstance().getCurrentSchema();
+ if(specific==null){
+ endpointList.setEnabled(0, true);
+ userData.setEndpoint(endpointList.get(0));
+ return;
+ }
+ for(int i = 0; i<=endpointList.size();i++){
+ if(endpointList.get(i).getSchema().equals(specific)){
+ endpointList.setEnabled(i, true);
+ userData.setEndpoint(endpointList.get(i));
+ return;
+ }
+ }
+ endpointList.setEnabled(0, true);
+ userData.setEndpoint(endpointList.get(0));
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPanel.java
2008-12-04 14:30:45 UTC (rev 4738)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPanel.java
2008-12-05 15:14:33 UTC (rev 4739)
@@ -25,18 +25,23 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
@@ -45,7 +50,9 @@
import org.perfsonar.perfsonarui.plugins.IPerfsonarTab;
import org.perfsonar.perfsonarui.plugins.IUserData;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
+import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.perfsonar.perfsonarui.ui.PluginMainPanel;
+import org.perfsonar.perfsonarui.ui.panels.ActionPanel;
import org.perfsonar.perfsonarui.ui.panels.TextPanel;
/**
@@ -53,10 +60,12 @@
* @author Nina Jeliazkova
*
*/
-public class PlaygroundPanel extends PluginMainPanel implements Observer,
DocumentListener, FocusListener {
+public class PlaygroundPanel extends PluginMainPanel implements Observer,
DocumentListener, FocusListener, ActionListener {
protected TextPanel query;
protected TextPanel response;
+ protected JComboBox querySelection;
+ protected JLabel queryStatus;
protected JFormattedTextField urlField;
protected MAEndpoint active_endpoint;
@@ -112,6 +121,12 @@
JToolBar t = new JToolBar();
t.setFloatable(false);
+
+ t.add(new JLabel("Select pre-defined query"));
+ querySelection = new
JComboBox(PlaygroundPredefined.getInstance().getPredefinedRequests());
+ querySelection.addActionListener(this);
+ t.add(querySelection);
+
t.add(new JLabel("Service address"));
urlField = new JFormattedTextField();
for (MAEndpoint e: data.getEndpoints()) {
@@ -120,7 +135,11 @@
}
urlField.addFocusListener(this);
t.add(urlField);
+
add(t,BorderLayout.NORTH);
+ queryStatus = new JLabel("Response status:
unknown",ActionPanel.createImageIcon(PlaygroundPredefined.UNK_ICO),SwingConstants.LEFT);
+ PlaygroundPredefined.getInstance().setStatusLabel(queryStatus);
+ add(queryStatus,BorderLayout.SOUTH);
}
@Override
@@ -187,6 +206,31 @@
}
}
+ public void actionPerformed(ActionEvent e) {
+ JComboBox active = (JComboBox)e.getSource();
+ if(active.equals(querySelection)){
+ String contens = (String)active.getSelectedItem();
+ if(!contens.equals("none - I'll write my own")){
+
PlaygroundPredefined.getInstance().setSelectedItem(contens);
+ String queryString =
PlaygroundPredefined.getInstance().getPredefinedRequest();
+ query.getTextArea().setText(queryString);
+ MAEndpointList filteredEndpoints =
((PerfsonarPlaygroundModel)model).createEndpoints();
+ ((PerfsonarPlaygroundModel)model).myEndpoints
= filteredEndpoints;
+
((PerfsonarPlaygroundModel)model).activateSpecific();
+ if(filteredEndpoints.size()!=0){
+
filteredEndpoints.get(0).setEnabled(true);
+ active_endpoint =
filteredEndpoints.get(0);
+
urlField.setText(active_endpoint.getEndpoint());
+ }
+ }
+ else {
+
PlaygroundPredefined.getInstance().setSelectedItem(null);
+ ((PerfsonarPlaygroundModel)model).myEndpoints
= null;
+
((PerfsonarPlaygroundModel)model).activateSpecific();
+ query.getTextArea().setText("");
+ }
+ }
+ }
}
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
2008-12-04 14:30:45 UTC (rev 4738)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPerfsonarResponse.java
2008-12-05 15:14:33 UTC (rev 4739)
@@ -27,6 +27,8 @@
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.IUserData;
import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
/**
* Response listener for
{@link
PlaygroundRequest}.
@@ -47,7 +49,36 @@
* inherited method only does logging of Document if
debugging is enabled, otherwse does nothing
*/
super.process(request, uData, response);
-
+
+
+ uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
AbstractMARequest.document2string(response));
+
+ boolean certain = false;
+ int success = 0;
+ int warn = 0;
+ int error = 0;
+ NodeList events =
response.getElementsByTagName("nmwg:eventType");
+ for(int i=0; i<events.getLength(); i++){
+ Node event = events.item(i);
+
if(event.getTextContent().contains(PlaygroundPredefined.getInstance().getCurrentSuccMsg())){
+ success++;
+ certain = true;
+ }
+ else
if(event.getTextContent().contains(PlaygroundPredefined.getInstance().getCurrentErrMsg())){
+ error++;
+ certain = true;
+ }
+ else
if(event.getTextContent().contains(PlaygroundPredefined.getInstance().getCurrentWarnMsg())){
+ warn++;
+ certain = true;
+ }
+ }
+
if(!certain)PlaygroundPredefined.getInstance().setStatus("Response status
uncertain",0);
+ else{
+
if(error>0)PlaygroundPredefined.getInstance().setStatus("Error(s) in
response",2);
+ else
if(warn>0)PlaygroundPredefined.getInstance().setStatus("Warning(s) in
response",3);
+ else
if(success>0)PlaygroundPredefined.getInstance().setStatus("Response seems
successfull",1);
+ }
/*
* This is a simple request, so we can do processing right
here. Otherwise call
*
@@ -58,7 +89,7 @@
//uData.setResponse(response);
- uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
AbstractMARequest.document2string(response));
+// uData.setResponse(AbstractUserData.DOCUMENT_RESPONSE,
AbstractMARequest.document2string(response));
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundPredefined.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
2008-12-04 14:30:45 UTC (rev 4738)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/playground/PlaygroundRequest.java
2008-12-05 15:14:33 UTC (rev 4739)
@@ -77,6 +77,7 @@
@Override
public Document createRequest(IUserData uData, String messageType)
throws Exception {
+ PlaygroundPredefined.getInstance().setStatus("unknown", 0);
uData.setResponse(null);
Object o = uData.getQuery(AbstractUserData.DOCUMENT_QUERY);
if ((o==null) || (AbstractUserData.NULL_DATA.equals(o))) {
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_error.png
Property changes on:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_error.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_success.png
Property changes on:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_success.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_unknown.png
Property changes on:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_unknown.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_warn.png
Property changes on:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/playground_warn.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
- perfsonar: r4739 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: playground ui, svnlog, 12/05/2008
Archive powered by MHonArc 2.6.16.