private void initGUI() { BasicTypeMapping.reset(); this.javaCodeTxtArea = new XBayaTextArea(); XBayaLabel operationLabel = new XBayaLabel("Operation", this.javaCodeTxtArea); GridPanel infoPanel = new GridPanel(); infoPanel.add(operationLabel); infoPanel.add(this.javaCodeTxtArea); checkBox = new JCheckBox("Export as webservice"); infoPanel.add(new XBayaLabel("", checkBox)); infoPanel.add(checkBox); infoPanel.layout(2, 2, 0, 0); JButton okButton = new JButton("OK"); okButton.addActionListener( new AbstractAction() { public void actionPerformed(ActionEvent e) { hide(); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(okButton); this.dialog = new XBayaDialog(this.engine.getGUI(), this.node.getName(), infoPanel, buttonPanel); this.dialog.setDefaultButton(okButton); }
private String generateClass() { String ret = "package org.apache.airavata.xbaya;"; ret += LINE + LINE; ret += "public class DefaultClassName{"; ret += LINE + LINE + TAB + "public"; String function = ""; List<Port> toNodes = this.node.getOutputPort(0).getToPorts(); XmlElement returnElement = null; QName returnType = null; if (toNodes.size() == 0) { function += SPACE + "void"; } else { if (toNodes.size() == 1 && toNodes.get(0) instanceof WSPort) { WSPort outPort = (WSPort) toNodes.get(0); returnElement = outPort.getComponentPort().getElement(); returnType = outPort.getType(); } else { throw new WorkflowRuntimeException( "Unhandled port type for Dynamic component or to many outputs"); } for (Port port : toNodes) { if (toNodes.get(0) instanceof DataPort) { if (!returnType.equals(((DataPort) toNodes.get(0)).getType())) { throw new WorkflowRuntimeException( "Dynamic output port connected to input ports of different types."); } } else { throw new WorkflowRuntimeException("Unhandled port type for Dynamic component"); } } int index = BasicTypeMapping.getSimpleTypeIndex(returnElement); if (-1 != index) { function += SPACE + BasicTypeMapping.getTypeName(index); } else { throw new WorkflowRuntimeException("WIll be fixed with complex type mappign"); } } function += SPACE + "operationName("; List<DataPort> inputPorts = this.node.getInputPorts(); boolean first = true; // variable list in function prototype for (DataPort inPort : inputPorts) { Port fromPort = inPort.getFromPort(); if (fromPort instanceof WSPort) { WSPort wsPort = (WSPort) fromPort; XmlElement element = wsPort.getComponentPort().getElement(); // QName inType = ((DataPort) fromPort).getType(); int typeIndex = BasicTypeMapping.getSimpleTypeIndex(element); if (-1 != typeIndex) { if (first) { first = false; } else { function += SPACE + ","; } function += BasicTypeMapping.getTypeName(typeIndex) + SPACE + BasicTypeMapping.getTypeVariableName(typeIndex); } else { throw new WorkflowRuntimeException("Complex Type occured:This will be fixed!!!!!"); } } else { throw new WorkflowRuntimeException("Dynamic Node connected to non data port"); } } function += ")"; ret += function; this.functionStr = function; // body ret += "{" + LINE + LINE; if (null != returnElement) { ret += TAB + TAB + "return" + SPACE + BasicTypeMapping.getTypeDefault(BasicTypeMapping.getSimpleTypeIndex(returnElement)) + ";"; } ret += LINE; ret += TAB + "}"; ret += LINE + "}"; return ret; }