Search in sources :

Example 1 with RegistrySearchResult

use of org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult in project airavata by apache.

the class WorkflowImportWindow method initGUI.

/**
 * Initializes the GUI
 */
private void initGUI() {
    this.list = new XbayaEnhancedList<RegistrySearchResult>();
    this.list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                // double click is same as cliking the OK button.
                WorkflowImportWindow.this.okButton.doClick();
            }
            if (WorkflowImportWindow.this.list.getSelectedIndex() == -1) {
                WorkflowImportWindow.this.okButton.setEnabled(false);
                WorkflowImportWindow.this.deleteButton.setEnabled(false);
            } else {
                WorkflowImportWindow.this.okButton.setEnabled(true);
                WorkflowImportWindow.this.deleteButton.setEnabled(true);
            }
        // if (WorkflowImportWindow.this.list.getSelectedIndex() == 2) {
        // WorkflowImportWindow.this.okButton.setEnabled(false);
        // WorkflowImportWindow.this.deleteButton.setEnabled(true);
        // } else if (WorkflowImportWindow.this.list.getSelectedIndex() != 1) {
        // WorkflowImportWindow.this.okButton.setEnabled(true);
        // WorkflowImportWindow.this.deleteButton.setEnabled(true);
        // } else {
        // WorkflowImportWindow.this.okButton.setEnabled(false);
        // WorkflowImportWindow.this.deleteButton.setEnabled(false);
        // }
        }
    });
    GridPanel mainPanel = new GridPanel();
    TitledBorder border = new TitledBorder(new EtchedBorder(), "Select a workflow to load");
    mainPanel.getSwingComponent().setBorder(border);
    mainPanel.add(this.list);
    mainPanel.layout(1, 1, 0, 0);
    JPanel buttonPanel = new JPanel();
    this.okButton = new JButton("Load");
    this.okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    });
    buttonPanel.add(this.okButton);
    this.deleteButton = new JButton("Delete");
    this.deleteButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            delete();
        }
    });
    buttonPanel.add(this.deleteButton);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    buttonPanel.add(cancelButton);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Load a Workflow from the Registry", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(this.okButton);
}
Also used : JPanel(javax.swing.JPanel) RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) MouseEvent(java.awt.event.MouseEvent) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) JButton(javax.swing.JButton) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) AbstractAction(javax.swing.AbstractAction)

Example 2 with RegistrySearchResult

use of org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult in project airavata by apache.

the class WorkflowImportWindow method delete.

private void delete() {
    for (RegistrySearchResult i : this.list.getSelectedValues()) {
        try {
            getClient().deleteWorkflow(i.getResourceName());
        } catch (Exception e) {
            engine.getGUI().getErrorWindow().error(e);
        }
    }
    this.list.removeSelectedRows();
    hide();
}
Also used : RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 3 with RegistrySearchResult

use of org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult in project airavata by apache.

the class WorkflowImportWindow method show.

/**
 * Shows the window.
 */
public void show() {
    /*
         * this.list.getList().setListData( new String[]{ "Loading the workflow list from the Registry.",
         * "Please wait for a moment."});
         */
    this.list.setEnabled(false);
    this.okButton.setEnabled(false);
    this.deleteButton.setEnabled(false);
    new Thread() {

        @Override
        public void run() {
            try {
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        try {
                            // FIXME: Update the gateway id fetched from UI
                            List<String> resultList = getClient().getAllWorkflows(engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId());
                            if (resultList == null || resultList.size() == 0) {
                            /*
								     * OGCEXRegistryLoaderWindow.this.list.getList(). setListData( new
								     * String[]{"No workflow"});
								     */
                            } else {
                                Vector<RegistrySearchResult> results = new Vector<RegistrySearchResult>();
                                String val = null;
                                for (String key : resultList) {
                                    results.add(new RegistrySearchResult(new QName(key), key, key));
                                }
                                WorkflowImportWindow.this.list.setListData(results);
                                WorkflowImportWindow.this.list.setEnabled(true);
                            }
                        } catch (InvalidRequestException e) {
                            log.error(e.getMessage(), e);
                        } catch (AiravataClientException e) {
                            log.error(e.getMessage(), e);
                        } catch (AiravataSystemException e) {
                            log.error(e.getMessage(), e);
                        } catch (TException e) {
                            log.error(e.getMessage(), e);
                        }
                    }
                });
            } catch (RuntimeException e) {
                WorkflowImportWindow.this.engine.getGUI().getErrorWindow().error(ErrorMessages.REGISTRY_WORKFLOW_LIST_LOAD_ERROR, e);
                hide();
            } catch (Error e) {
                WorkflowImportWindow.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
                hide();
            }
        }
    }.start();
    // This has to be the last because it blocks when the dialog is modal.
    this.dialog.show();
}
Also used : TException(org.apache.thrift.TException) RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) QName(javax.xml.namespace.QName) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) Vector(java.util.Vector)

Example 4 with RegistrySearchResult

use of org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult in project airavata by apache.

the class WorkflowImportWindow method ok.

private void ok() {
    List<RegistrySearchResult> selectedValues = this.list.getSelectedValues();
    try {
        for (RegistrySearchResult result : selectedValues) {
            org.apache.airavata.model.Workflow workflow = getClient().getWorkflow(result.getResourceName());
            XmlElement workflowElement = XMLUtil.stringToXmlElement(workflow.getGraph());
            Workflow w = new Workflow(workflowElement);
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(w);
            engine.getGUI().getGraphCanvas().setWorkflowFile(null);
        }
        hide();
    } catch (Exception e) {
        engine.getGUI().getErrorWindow().error(e);
    }
}
Also used : RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) XmlElement(org.xmlpull.infoset.XmlElement) Workflow(org.apache.airavata.workflow.model.wf.Workflow) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Aggregations

RegistrySearchResult (org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult)4 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)3 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)3 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)3 TException (org.apache.thrift.TException)3 ActionEvent (java.awt.event.ActionEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 Vector (java.util.Vector)1 AbstractAction (javax.swing.AbstractAction)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 EtchedBorder (javax.swing.border.EtchedBorder)1 TitledBorder (javax.swing.border.TitledBorder)1 QName (javax.xml.namespace.QName)1 Workflow (org.apache.airavata.workflow.model.wf.Workflow)1 XBayaDialog (org.apache.airavata.xbaya.ui.dialogs.XBayaDialog)1 GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)1 GridPanel (org.apache.airavata.xbaya.ui.widgets.GridPanel)1 XmlElement (org.xmlpull.infoset.XmlElement)1