Search in sources :

Example 1 with XBayaTextField

use of org.apache.airavata.xbaya.ui.widgets.XBayaTextField in project airavata by apache.

the class WorkflowInterpreterLaunchWindow method initGUI.

private void initGUI() {
    this.parameterPanel = new GridPanel(true);
    GridPanel infoPanel = new GridPanel();
    this.instanceNameTextField = new XBayaTextField();
    XBayaLabel instanceNameLabel = new XBayaLabel("Experiment name", this.instanceNameTextField);
    infoPanel.add(instanceNameLabel);
    infoPanel.add(this.instanceNameTextField);
    token = new XBayaTextField("");
    JLabel tokenLabel = new JLabel("Token Id: ");
    infoPanel.add(tokenLabel);
    infoPanel.add(token);
    infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    GridPanel mainPanel = new GridPanel();
    mainPanel.getContentPanel().setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    mainPanel.add(infoPanel);
    mainPanel.add(this.parameterPanel);
    mainPanel.layout(2, 1, 0, 0);
    JButton okButton = new JButton("Run");
    okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            try {
                execute();
            } catch (AiravataClientConnectException e1) {
                e1.printStackTrace();
            } catch (InvalidRequestException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (AiravataClientException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (AiravataSystemException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (TException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    buttonPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Launch  workflow", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : TException(org.apache.thrift.TException) JPanel(javax.swing.JPanel) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) AiravataClientConnectException(org.apache.airavata.model.error.AiravataClientConnectException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 2 with XBayaTextField

use of org.apache.airavata.xbaya.ui.widgets.XBayaTextField in project airavata by apache.

the class WorkflowInterpreterLaunchWindow method show.

/**
 * Shows the dialog.
 */
public void show() {
    this.workflow = this.engine.getGUI().getWorkflow();
    // Create input fields
    Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    for (InputNode node : inputNodes) {
        String id = node.getID();
        DataType parameterType = node.getParameterType();
        JLabel nameLabel = new JLabel(id);
        JLabel typeField = new JLabel(parameterType.toString());
        XBayaTextField paramField = new XBayaTextField();
        Object value = node.getDefaultValue();
        String valueString;
        if (value == null) {
            valueString = "";
        } else {
            if (value instanceof XmlElement) {
                XmlElement valueElement = (XmlElement) value;
                valueString = XMLUtil.xmlElementToString(valueElement);
            } else {
                // Only string comes here for now.
                valueString = value.toString();
            }
        }
        paramField.setText(valueString);
        this.parameterPanel.add(nameLabel);
        this.parameterPanel.add(typeField);
        this.parameterPanel.add(paramField);
        this.parameterTextFields.add(paramField);
    }
    Map<String, String> hosts = null;
    try {
        hosts = airavataClient.getAllComputeResourceNames();
        if (hosts.isEmpty()) {
            JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "No Compute Resources found", "Compute Resources", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } catch (InvalidRequestException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (AiravataClientException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (AiravataSystemException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    } catch (TException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }
    hostNames = new HashMap<String, String>();
    Iterator it = hosts.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        String value = (String) pairs.getValue();
        if (!hostNames.containsKey(value)) {
            hostNames.put(value, key);
        }
    }
    host = new JComboBox();
    it = hostNames.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        host.addItem(key);
    }
    host.setSelectedIndex(0);
    XBayaLabel hostLabel = new XBayaLabel("Host", host);
    this.parameterPanel.add(hostLabel);
    this.parameterPanel.add(host);
    this.parameterPanel.layout(inputNodes.size(), 3, GridPanel.WEIGHT_NONE, 2);
    this.dialog.show();
}
Also used : TException(org.apache.thrift.TException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) Iterator(java.util.Iterator) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) XmlElement(org.xmlpull.infoset.XmlElement) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) Map(java.util.Map) HashMap(java.util.HashMap) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 3 with XBayaTextField

use of org.apache.airavata.xbaya.ui.widgets.XBayaTextField in project airavata by apache.

the class NewRegistryUserDialog method initGUI.

/**
 * Initializes the GUI.
 */
private void initGUI() {
    // this.urlTextField = new XBayaTextField();
    this.usernameTextField = new XBayaTextField();
    this.passwordTextField = new JPasswordField();
    this.confirmPasswordTextField = new JPasswordField();
    // XBayaLabel urlLabel = new XBayaLabel("URL", this.urlTextField);
    XBayaLabel userLabel = new XBayaLabel("Username", this.usernameTextField);
    XBayaLabel passLabel = new XBayaLabel("Password", this.passwordTextField);
    XBayaLabel confirmPassLabel = new XBayaLabel("Confirm Password", this.confirmPasswordTextField);
    GridPanel infoPanel = new GridPanel();
    // infoPanel.add(urlLabel);
    // infoPanel.add(this.urlTextField);
    infoPanel.add(userLabel);
    infoPanel.add(this.usernameTextField);
    infoPanel.add(passLabel);
    infoPanel.add(this.passwordTextField);
    infoPanel.add(confirmPassLabel);
    infoPanel.add(this.confirmPasswordTextField);
    // infoPanel.layout(4, 2, GridPanel.WEIGHT_NONE, 1);
    infoPanel.layout(3, 2, GridPanel.WEIGHT_NONE, 1);
    // urlTextField.getSwingComponent().addActionListener(new ActionListener() {
    // public void actionPerformed(ActionEvent event) {
    // updateURL();
    // updateStatus();
    // }
    // 
    // });
    usernameTextField.getSwingComponent().addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            updateUsername();
            updateStatus();
        }
    });
    passwordTextField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            updatePassword();
            updateStatus();
        }
    });
    confirmPasswordTextField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            updatePassword();
            updateStatus();
        }
    });
    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Registry New User", infoPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
    updateControlData();
}
Also used : XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionListener(java.awt.event.ActionListener) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) ActionEvent(java.awt.event.ActionEvent) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 4 with XBayaTextField

use of org.apache.airavata.xbaya.ui.widgets.XBayaTextField in project airavata by apache.

the class WorkflowPropertyWindow method initGui.

private void initGui() {
    this.nameTextField = new XBayaTextField();
    XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
    this.descriptionTextArea = new XBayaTextArea();
    XBayaLabel descriptionLabel = new XBayaLabel("Description", this.descriptionTextArea);
    GridPanel mainPanel = new GridPanel();
    mainPanel.add(nameLabel);
    mainPanel.add(this.nameTextField);
    mainPanel.add(descriptionLabel);
    mainPanel.add(this.descriptionTextArea);
    mainPanel.layout(new double[] { 0, 0.5 }, new double[] { 0, 1 });
    this.okButton = new JButton("OK");
    this.okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            setToWorkflow();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(this.okButton);
    buttonPanel.add(cancelButton);
    this.dialog = new XBayaDialog(this.xbayaGUI, "Workflow Properties", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(this.okButton);
}
Also used : JPanel(javax.swing.JPanel) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) XBayaTextArea(org.apache.airavata.xbaya.ui.widgets.XBayaTextArea) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 5 with XBayaTextField

use of org.apache.airavata.xbaya.ui.widgets.XBayaTextField in project airavata by apache.

the class LaunchApplicationWindow method execute.

private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
    List<NodeImpl> nodes = workflow.getGraph().getNodes();
    String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
    String appId = null;
    NodeImpl node = null;
    for (int i = 0; i < nodes.size(); i++) {
        node = nodes.get(i);
        String html = node.getComponent().toHTML();
        String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
        if (nodeType.equals("Application")) {
            appId = html.substring(html.indexOf("</h2>") + 6, html.indexOf("<br")).trim();
            break;
        }
    }
    String hostId = null;
    String hostName = (String) host.getSelectedItem();
    hostId = hostNames.get(hostName);
    String instanceName = this.instanceNameTextField.getText();
    if (instanceName.trim().equals("")) {
        JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Experiment name cannot be empty", "Experiment Name", JOptionPane.ERROR_MESSAGE);
        return;
    }
    // previous instance name
    if (!instanceNameTextField.getText().equals("")) {
        this.instanceNameTextField.setText("");
    }
    Project project = new Project();
    project.setName("project1");
    String owner = this.thriftClientData.getUsername();
    if (owner.equals(""))
        owner = "NotKnown";
    project.setOwner(owner);
    project.setProjectID(airavataClient.createProject(gatewayId, project));
    // final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    final List<DataPort> inputPorts = node.getInputPorts();
    final Experiment experiment = new Experiment();
    experiment.setApplicationId(appId);
    ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
    scheduling.setResourceHostId(hostId);
    if (hostName.trim().equals("trestles.sdsc.xsede.org")) {
        scheduling.setComputationalProjectAccount("sds128");
    } else if (hostName.trim().equals("stampede.tacc.xsede.org")) {
        scheduling.setComputationalProjectAccount("TG-STA110014S");
    }
    scheduling.setNodeCount(1);
    scheduling.setTotalCPUCount(1);
    scheduling.setWallTimeLimit(15);
    scheduling.setQueueName("normal");
    UserConfigurationData userConfigurationData = new UserConfigurationData();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    experiment.setUserConfigurationData(userConfigurationData);
    experiment.setName(instanceName);
    experiment.setProjectID(project.getProjectID());
    experiment.setUserName(thriftClientData.getUsername());
    for (int i = 0; i < inputPorts.size(); i++) {
        DataPort inputPort = inputPorts.get(i);
        XBayaTextField parameterTextField = this.parameterTextFields.get(i);
        String value = parameterTextField.getText();
        InputDataObjectType elem = new InputDataObjectType();
        elem.setName(inputPort.getName());
        elem.setType(elem.getType());
        elem.setValue(value);
        experiment.addToExperimentInputs(elem);
    }
    final List<DataPort> outputPorts = node.getOutputPorts();
    for (int i = 0; i < outputPorts.size(); i++) {
        DataPort outputPort = outputPorts.get(i);
        OutputDataObjectType elem = new OutputDataObjectType();
        elem.setName(outputPort.getName());
        elem.setType(elem.getType());
        elem.setValue("");
        experiment.addToExperimentOutputs(elem);
    }
    experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
    airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
    hide();
    JOptionPane.showMessageDialog(null, "Experiment Launched. You will be alerted on completion.");
    String status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
    while (!status.equals("COMPLETED") && !status.equals("FAILED")) {
        try {
            Thread.sleep(1000);
            status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }
    if (status.equals("COMPLETED")) {
        String output = "";
        ;
        String fullOutput = "";
        while (output.equals("")) {
            output = "";
            fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
            List<OutputDataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
            for (int i1 = 0; i1 < outputs.size(); i1++) {
                output = outputs.get(i1).getValue();
                fullOutput += outputs.get(i1).getName() + ": " + output + "\n";
            }
        }
        JOptionPane.showMessageDialog(null, fullOutput);
    } else {
        JOptionPane.showMessageDialog(null, "Experiment Failed");
        return;
    }
    new Thread() {

        @Override
        public void run() {
        }
    }.start();
    hide();
}
Also used : ComputationalResourceScheduling(org.apache.airavata.model.experiment.ComputationalResourceScheduling) UserConfigurationData(org.apache.airavata.model.experiment.UserConfigurationData) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) InputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField)

Aggregations

XBayaTextField (org.apache.airavata.xbaya.ui.widgets.XBayaTextField)35 XBayaLabel (org.apache.airavata.xbaya.ui.widgets.XBayaLabel)32 ActionEvent (java.awt.event.ActionEvent)31 GridPanel (org.apache.airavata.xbaya.ui.widgets.GridPanel)31 XBayaDialog (org.apache.airavata.xbaya.ui.dialogs.XBayaDialog)30 AbstractAction (javax.swing.AbstractAction)26 JButton (javax.swing.JButton)26 JPanel (javax.swing.JPanel)25 JSpinner (javax.swing.JSpinner)8 SpinnerNumberModel (javax.swing.SpinnerNumberModel)8 XBayaTextArea (org.apache.airavata.xbaya.ui.widgets.XBayaTextArea)8 JLabel (javax.swing.JLabel)5 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)4 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)4 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)4 TException (org.apache.thrift.TException)4 ActionListener (java.awt.event.ActionListener)3 XBayaComboBox (org.apache.airavata.xbaya.ui.widgets.XBayaComboBox)3 StringSelection (java.awt.datatransfer.StringSelection)2 URL (java.net.URL)2