Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r3750 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: plugins ui/panels

Subject: perfsonar development work

List archive

perfsonar: r3750 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: plugins ui/panels


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r3750 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: plugins ui/panels
  • Date: Mon, 21 Apr 2008 06:15:38 -0400

Author: nina
Date: 2008-04-21 06:15:38 -0400 (Mon, 21 Apr 2008)
New Revision: 3750

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/MAEndpoint.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/MAEndpointsPanel.java
Log:
New feature: Copy status information into clipboard
https://bugzilla.perfsonar.net/show_bug.cgi?id=312

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/MAEndpoint.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/MAEndpoint.java
2008-04-21 10:14:40 UTC (rev 3749)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/MAEndpoint.java
2008-04-21 10:15:38 UTC (rev 3750)
@@ -21,11 +21,15 @@

import java.util.Observable;

+import org.apache.axis.AxisFault;
+import org.apache.axis.utils.XMLUtils;
import org.perfsonar.perfsonarui.AbstractUserData;
import org.perfsonar.perfsonarui.IPerfsonarSchema;
import org.perfsonar.perfsonarui.PerfsonarSchema;
+import org.perfsonar.perfsonarui.RequestInterruptedException;
import org.perfsonar.perfsonarui.SmartMARequest;
import org.perfsonar.perfsonarui.ui.PerfsonarModel;
+import org.w3c.dom.Element;


/**
@@ -173,6 +177,65 @@
b.append(event[1]);
return b.toString();
}
+ public static String status2String(Object o, String lineDelimiter) {
+ StringBuffer b = new StringBuffer();
+ if (o instanceof AxisFault) {
+ b.append(o.toString());
+ b.append(lineDelimiter);
+ //b.append("<hr>");
+ b.append("Fault string: ");
+ b.append(((AxisFault)o).getFaultString());
+ b.append(lineDelimiter);
+ b.append("Fault code: ");
+ b.append(((AxisFault)o).getFaultCode());
+ b.append(lineDelimiter);
+ if (((AxisFault)o).getFaultSubCodes()!=null) {
+ b.append("Fault subcode: ");
+ b.append(((AxisFault)o).getFaultSubCodes());
+ b.append(lineDelimiter);
+ }
+ if (((AxisFault)o).getFaultActor() != null) {
+ b.append("Fault actor: ");
+ b.append(((AxisFault)o).getFaultActor());
+ b.append(lineDelimiter);
+ }
+ if (((AxisFault)o).getFaultNode() != null) {
+ b.append("Fault node: ");
+ b.append(((AxisFault)o).getFaultNode());
+ b.append(lineDelimiter);
+ }
+

+ Element[] e = ((AxisFault)o).getFaultDetails();
+ b.append("Fault details: ");
+ for (int i=0;i < e.length; i++) {
+ b.append(lineDelimiter);
+ b.append("{");
+ b.append(null == e[i].getNamespaceURI() ? "" :
e[i].getNamespaceURI());
+ b.append("}");
+ b.append(lineDelimiter);
+ b.append(null == e[i].getLocalName() ? "" :
e[i].getLocalName());
+ b.append(":");
+ b.append(XMLUtils.getInnerXMLString(e[i]));
+ b.append(e[i].toString());
+ }
+ } else if (o instanceof RequestInterruptedException) {
+ Exception x = ((Exception)o);
+ b.append(x.toString());
+ } else if (o instanceof Exception) {
+
+ Exception x = ((Exception)o);
+ b.append(x.toString());
+ b.append(lineDelimiter);
+ //b.append("<hr>");
+ StackTraceElement[] trace =
((Exception)o).getStackTrace();
+ for (int i=0; i < trace.length; i++) {
+ b.append(trace[i].toString());
+ b.append(lineDelimiter);
+ }
+
+ } else b.append(o.toString());
+ return b.toString();
+ }
public synchronized String getTitle() {
return title;
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/MAEndpointsPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/MAEndpointsPanel.java
2008-04-21 10:14:40 UTC (rev 3749)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/MAEndpointsPanel.java
2008-04-21 10:15:38 UTC (rev 3750)
@@ -31,6 +31,10 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -38,9 +42,9 @@
import java.beans.PropertyChangeListener;
import java.util.List;

+import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
-import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
@@ -58,14 +62,10 @@
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

-import org.apache.axis.AxisFault;
-import org.apache.axis.utils.XMLUtils;
import org.perfsonar.perfsonarui.IPerfsonarSchema;
-import org.perfsonar.perfsonarui.RequestInterruptedException;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.perfsonar.perfsonarui.ui.actions.PSUIAction;
-import org.w3c.dom.Element;

/**
* Displays
{@link
MAEndpointList}.
@@ -78,6 +78,7 @@
JComponent toolbar;

MAEndpointPanel detailsPanel;
+ protected CopyStatusAction copyStatusAction;
/**
* Comment for <code>serialVersionUID</code>
*/
@@ -135,6 +136,9 @@
((JToolBar)toolbar).setFloatable(false);
final JPopupMenu menu = new JPopupMenu();
String type = null;
+ copyStatusAction = new CopyStatusAction(model);
+ menu.add(copyStatusAction);
+ menu.addSeparator();
for (int i=0; i < actions.length; i++) {
if (type == null) type =
actions[i].getClass().getName();
else {
@@ -153,18 +157,13 @@
// Add a listener to display pop-up
dataTable.addMouseListener(new MouseAdapter() {
@Override
- public void mousePressed(MouseEvent evt) {
-
- if (evt.isPopupTrigger())
- menu.show(evt.getComponent(), evt.getX(),
evt.getY());
-
- }
- @Override
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
+
copyStatusAction.setRow(dataTable.rowAtPoint(evt.getPoint()));
menu.show(evt.getComponent(), evt.getX(),
evt.getY());
}
}
+
});
}

@@ -239,6 +238,11 @@
((JComponent)c).setBorder(border);
Object o = table.getValueAt(row,column);
StringBuffer b = new StringBuffer();
+ b.append("<html>");
+ b.append(MAEndpoint.status2String(o, "<br>"));
+ b.append("</html>");
+ setToolTipText(b.toString());
+ /*
if (o instanceof AxisFault) {
b.append("<html>");
b.append(o.toString());
@@ -304,6 +308,7 @@
b.append("</html>");
setToolTipText(b.toString());
} else setToolTipText(o.toString());
+ */
}
else {
if ((row % 2) == 0)
c.setBackground(Color.white);
@@ -313,6 +318,8 @@

return c;
}
+
+
}

class MAEndpointPanel extends JPanel implements PropertyChangeListener {
@@ -449,5 +456,49 @@
// TODO Auto-generated method stub

}
+
}

+class CopyStatusAction extends AbstractAction {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4859556164152749413L;
+ protected int row = -1;
+ protected MAEndpointListTableModel endpointsTable;
+ public CopyStatusAction(MAEndpointListTableModel endpointsTable) {
+ super("Copy");
+ setEndpointsTable(endpointsTable);
+ putValue(AbstractAction.SHORT_DESCRIPTION, "Copy status
information to clipboard");
+ }
+ public void actionPerformed(ActionEvent e) {
+
+ if (row == -1) return;
+ StringBuffer b = new StringBuffer();
+ //skip first (checkbox) column
+ for (int i=1; i < endpointsTable.getColumnCount(); i++) {
+ Object o = endpointsTable.getValueAt(row, i);
+ b.append(endpointsTable.getColumnName(i));
+ b.append(":\t");
+ b.append(MAEndpoint.status2String(o, "\n"));
+ b.append("\n");
+ }
+ StringSelection ss = new StringSelection(b.toString());
+ Clipboard clipboard =
Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(ss,ss);
+
+ }
+ public int getRow() {
+ return row;
+ }
+ public void setRow(int row) {
+ this.row = row;
+ }
+
+ public MAEndpointListTableModel getEndpointsTable() {
+ return endpointsTable;
+ }
+ public void setEndpointsTable(MAEndpointListTableModel
endpointsTable) {
+ this.endpointsTable = endpointsTable;
+ }
+}



  • perfsonar: r3750 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: plugins ui/panels, svnlog, 04/21/2008

Archive powered by MHonArc 2.6.16.

Top of Page