use of org.xmlpull.infoset.XmlElement in project airavata by apache.
the class DifferedInputNode method addConfigurationElement.
@Override
protected XmlElement addConfigurationElement(XmlElement nodeElement) {
XmlElement configElement = super.addConfigurationElement(nodeElement);
if (this.defaultValue != null) {
XmlElement element = configElement.addElement(GraphSchema.NS, VALUE_TAG_NAME);
element.addChild(this.defaultValue);
}
return configElement;
}
use of org.xmlpull.infoset.XmlElement in project airavata by apache.
the class DifferedInputNode method toXML.
@Override
public XmlElement toXML() {
XmlElement nodeElement = super.toXML();
nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_DIFFERED_INPUT);
return nodeElement;
}
use of org.xmlpull.infoset.XmlElement in project airavata by apache.
the class MonitorPanel method init.
private void init() {
this.table = new JTable(this.tableSliderModel) {
@Override
public String getToolTipText(MouseEvent event) {
String tip = null;
Point point = event.getPoint();
int colIndex = columnAtPoint(point);
if (colIndex == EventDataRepository.Column.MESSAGE.ordinal()) {
tip = "Double click here to see the full message.";
}
return tip;
}
};
this.table.getTableHeader().setReorderingAllowed(false);
this.table.addMouseListener(new MouseInputAdapter() {
private MonitorWindow window;
@Override
public void mouseClicked(MouseEvent event) {
Point point = event.getPoint();
int row = MonitorPanel.this.table.rowAtPoint(point);
if (row >= 0 && row < MonitorPanel.this.table.getRowCount()) {
EventData message = MonitorPanel.this.tableSliderModel.getEvent(row);
int clickCount = event.getClickCount();
if (clickCount == 1) {
/* if (MonitorUtil.getType(message) == MonitorUtil.EventType.PUBLISH_URL) {
int column = MonitorPanel.this.table.columnAtPoint(point);
if (column == EventDataRepository.Column.MESSAGE.ordinal()) {
String url = MonitorUtil.getLocation(message);
try {
BrowserLauncher.openURL(url);
} catch (Exception e) {
MonitorPanel.this.xbayaGUI.getErrorWindow().error(e.getMessage(), e);
}
}
} else if (MonitorUtil.getType(message) == MonitorUtil.EventType.SENDING_RESULT) {
if (null != message && null != message.element("result")
&& null != message.element("result").element("body")
&& null != message.element("result").element("body").element("Body")) {
XmlElement body = message.element("result").element("body").element("Body");
Iterator bodyItr = body.children().iterator();
// find the first body Element
findAndLaunchBrowser(bodyItr);
// XmlElement output = message.element("result").element("body").
// element("Body").element("Visualize_OutputParams").element("Visualized_Output");
// Iterator children = output.children().iterator();
// while (children.hasNext()) {
// Object object = (Object) children.next();
// if(object instanceof String){
// try {
// new URL(((String)object).trim());
// try {
// BrowserLauncher.openURL(((String)object).trim());
// } catch (Throwable e) {
// //do nothing
// }
// } catch (MalformedURLException e) {
// //do nothing
// }
// }
//
// }
}
}*/
} else if (clickCount >= 2) {
// Handle double clicks to pop up a window.
if (this.window == null) {
this.window = new MonitorWindow(MonitorPanel.this.xbayaGUI);
}
this.window.show(message);
}
}
}
/**
* @param bodyItr
*/
private void findAndLaunchBrowser(Iterator bodyItr) {
if (bodyItr.hasNext()) {
Object firstElement = bodyItr.next();
if (firstElement instanceof XmlElement) {
findAndLuanchBrowser((XmlElement) firstElement);
}
}
}
/**
* @param firstElement
*/
private void findAndLuanchBrowser(XmlElement firstElement) {
Iterator children = ((XmlElement) firstElement).children().iterator();
while (children.hasNext()) {
Object object = (Object) children.next();
if (object instanceof String) {
try {
new URL(((String) object).trim());
try {
BrowserLauncher.openURL(((String) object).trim());
} catch (Throwable e) {
// do nothing
}
} catch (MalformedURLException e) {
// do nothing
}
} else if (object instanceof XmlElement) {
findAndLuanchBrowser((XmlElement) object);
}
}
}
});
// Adjust size of columns
TableColumnModel columnModel = this.table.getColumnModel();
int columnCount = columnModel.getColumnCount();
for (int i = 0; i < columnCount; i++) {
TableColumn column = columnModel.getColumn(i);
if (i == columnCount - 1) {
column.setPreferredWidth(500);
} else {
column.setPreferredWidth(50);
}
}
this.table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
this.scrollPane = new JScrollPane(this.table);
this.scrollPane.setMinimumSize(SwingUtil.MINIMUM_SIZE);
this.scrollPane.setDoubleBuffered(true);
this.slider = new JSlider(this.tableSliderModel);
this.slider.setSnapToTicks(true);
this.slider.setEnabled(false);
this.panel = new JPanel();
this.panel.setLayout(new BorderLayout());
this.panel.add(this.scrollPane, BorderLayout.CENTER);
this.panel.add(this.slider, BorderLayout.SOUTH);
}
use of org.xmlpull.infoset.XmlElement in project airavata by apache.
the class InstanceNode method addConfigurationElement.
/**
* @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#addConfigurationElement(org.xmlpull.infoset.XmlElement)
*/
@Override
protected XmlElement addConfigurationElement(XmlElement nodeElement) {
XmlElement configElement = super.addConfigurationElement(nodeElement);
// save start new instance
XmlElement element = configElement.addElement(GraphSchema.NS, NEW_TAG_NAME);
element.addChild(String.valueOf(this.startNewInstance));
if (this.startNewInstance) {
// save ami id
if (this.amiId != null) {
XmlElement element2 = configElement.addElement(GraphSchema.NS, AMI_ID_TAG_NAME);
element2.addChild(this.amiId);
}
// save instance type
if (this.instanceType != null) {
XmlElement element3 = configElement.addElement(GraphSchema.NS, INSTANCE_TYPE_TAG_NAME);
element3.addChild(this.instanceType);
}
} else {
// save instance id
if (this.instanceId != null) {
XmlElement element2 = configElement.addElement(GraphSchema.NS, INSTANCE_ID_TAG_NAME);
element2.addChild(this.instanceId);
}
}
// save username
if (this.username != null) {
XmlElement element2 = configElement.addElement(GraphSchema.NS, USERNAME_TAG_NAME);
element2.addChild(this.username);
}
return configElement;
}
use of org.xmlpull.infoset.XmlElement in project airavata by apache.
the class BasicTypeMapping method getOutputArray.
public static Object getOutputArray(XmlElement element, String name, int simpleIndex) throws WorkflowException {
try {
// This code doesn't work when the output is a complex type.
// Object output = this.outputMessage.getObjectPart(name);
// return output;
XmlElement outputElement = (XmlElement) element;
Iterator valueElementItr = outputElement.elements(null, name).iterator();
LinkedList<String> ret = new LinkedList<String>();
while (valueElementItr.hasNext()) {
XmlElement valueElement = (XmlElement) valueElementItr.next();
Iterator childIt = valueElement.children().iterator();
int numberOfChildren = 0;
while (childIt.hasNext()) {
childIt.next();
numberOfChildren++;
}
if (numberOfChildren == 1) {
Object child = valueElement.children().iterator().next();
if (child instanceof String) {
// Value is a simple type. Return the string.
String value = (String) child;
ret.add(value);
}
}
}
switch(simpleIndex) {
case 0:
Integer[] intRet = new Integer[ret.size()];
for (int i = 0; i < ret.size(); i++) {
intRet[i] = Integer.parseInt(ret.get(i));
}
return intRet;
case 1:
String[] strRet = new String[ret.size()];
for (int i = 0; i < ret.size(); i++) {
strRet[i] = ret.get(i);
}
return strRet;
}
throw new WorkflowException("Unknown type");
} catch (RuntimeException e) {
String message = "Error in getting output. name: " + name;
throw new WorkflowException(message, e);
}
}
Aggregations