Search in sources :

Example 21 with XBayaDialog

use of org.apache.airavata.xbaya.ui.dialogs.XBayaDialog in project airavata by apache.

the class RegistryWindow method initGUI.

/**
 * Initializes the GUI.
 */
private void initGUI() {
    this.serverTextField = new XBayaTextField();
    this.portTextField = new XBayaTextField();
    this.gatewayIdTextField = new XBayaTextField();
    this.usernameTextField = new XBayaTextField();
    this.serverTextField.setText("localhost");
    this.portTextField.setText("8930");
    this.gatewayIdTextField.setText("sample");
    this.usernameTextField.setText("airavata");
    ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
    if (thriftClientData != null) {
        this.serverTextField.setText(thriftClientData.getServerAddress());
        this.gatewayIdTextField.setText(thriftClientData.getGatewayId());
        this.portTextField.setText(String.valueOf(thriftClientData.getServerPort()));
        this.usernameTextField.setText(thriftClientData.getUsername());
    }
    try {
        ClientSettings.initializeTrustStore();
    } catch (ApplicationSettingsException e) {
        throw new RuntimeException("An error occurred while initializing client configurations");
    }
    XBayaLabel serverAddressLabel = new XBayaLabel("Server Address", this.serverTextField);
    XBayaLabel serverPortLabel = new XBayaLabel("Server Port", this.portTextField);
    XBayaLabel gatewayNameLabel = new XBayaLabel("Gateway ID", this.gatewayIdTextField);
    XBayaLabel gatewayUserLabel = new XBayaLabel("Gateway User", this.usernameTextField);
    serviceTypeModel = new DefaultComboBoxModel(ThriftServiceType.values());
    serviceTypeModel.setSelectedItem(getServiceType());
    this.serviceTypeCombo = new XBayaComboBox(serviceTypeModel);
    JLabel serviceTypeLabel = new JLabel("Airavata Service");
    // serviceTypeCombo.addActionListener(new AbstractAction() {
    // public void actionPerformed(ActionEvent e) {
    // //                createNewUser();
    // }
    // });
    GridPanel infoPanel = new GridPanel();
    infoPanel.add(serviceTypeLabel);
    infoPanel.add(this.serviceTypeCombo);
    infoPanel.add(serverAddressLabel);
    infoPanel.add(this.serverTextField);
    infoPanel.add(serverPortLabel);
    infoPanel.add(this.portTextField);
    infoPanel.add(gatewayNameLabel);
    infoPanel.add(this.gatewayIdTextField);
    infoPanel.add(gatewayUserLabel);
    infoPanel.add(this.usernameTextField);
    infoPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1);
    // infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    infoPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new AbstractAction() {

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

        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    GridPanel buttonPanel = new GridPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    buttonPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Configure Airavata Thrift Service", infoPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) XBayaComboBox(org.apache.airavata.xbaya.ui.widgets.XBayaComboBox) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 22 with XBayaDialog

use of org.apache.airavata.xbaya.ui.dialogs.XBayaDialog in project airavata by apache.

the class ParameterPropertyWindow method initGui.

private void initGui() {
    this.inputPanel = new ParameterPropertyPanel("Inputs");
    this.outputPanel = new ParameterPropertyPanel("Outputs");
    JPanel mainPanel = new JPanel();
    // To have the same size.
    mainPanel.setLayout(new GridLayout(1, 2));
    mainPanel.add(this.inputPanel.getSwingComponent());
    mainPanel.add(this.outputPanel.getSwingComponent());
    JPanel buttonPanel = new JPanel();
    this.okButton = new JButton("OK");
    this.okButton.setDefaultCapable(true);
    this.okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            ok();
        }
    });
    buttonPanel.add(this.okButton);
    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(), "Workflow Paremeter Properties", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(this.okButton);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ParameterPropertyPanel(org.apache.airavata.xbaya.ui.views.ParameterPropertyPanel) AbstractAction(javax.swing.AbstractAction)

Example 23 with XBayaDialog

use of org.apache.airavata.xbaya.ui.dialogs.XBayaDialog in project airavata by apache.

the class LaunchApplicationWindow method initGUI.

private void initGUI() {
    this.parameterPanel = new GridPanel(true);
    this.instanceNameTextField = new XBayaTextField();
    XBayaLabel instanceNameLabel = new XBayaLabel("Experiment name", this.instanceNameTextField);
    GridPanel infoPanel = new GridPanel();
    infoPanel.add(instanceNameLabel);
    infoPanel.add(this.instanceNameTextField);
    infoPanel.layout(1, 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 event) {
            try {
                execute();
            } catch (AiravataClientConnectException e) {
                logger.error(e.getMessage(), e);
            } catch (InvalidRequestException e) {
                logger.error(e.getMessage(), e);
            } catch (AiravataClientException e) {
                logger.error(e.getMessage(), e);
            } catch (AiravataSystemException e) {
                logger.error(e.getMessage(), e);
            } catch (TException e) {
                logger.error(e.getMessage(), e);
            }
        }
    });
    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) 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 24 with XBayaDialog

use of org.apache.airavata.xbaya.ui.dialogs.XBayaDialog in project airavata by apache.

the class ChangeCredentialWindow method initGUI.

protected void initGUI() {
    this.accessKeyIDTextField = new XBayaTextField();
    XBayaLabel accessKeyIDLabel = new XBayaLabel("Access Key", this.accessKeyIDTextField);
    this.secretAccessKeyTextField = new XBayaTextField();
    XBayaLabel secretAccessKeyLabel = new XBayaLabel("Secret Key", this.secretAccessKeyTextField);
    GridPanel infoPanel = new GridPanel();
    infoPanel.add(accessKeyIDLabel);
    infoPanel.add(this.accessKeyIDTextField);
    infoPanel.add(secretAccessKeyLabel);
    infoPanel.add(this.secretAccessKeyTextField);
    infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    GridPanel mainPanel = new GridPanel();
    mainPanel.add(infoPanel);
    mainPanel.layout(1, 1, GridPanel.WEIGHT_EQUALLY, GridPanel.WEIGHT_EQUALLY);
    JButton okButton = new JButton("Ok");
    okButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String accessID = ChangeCredentialWindow.this.accessKeyIDTextField.getText();
            if (!"".equals(accessID)) {
                String secretID = ChangeCredentialWindow.this.secretAccessKeyTextField.getText();
                if (!"".equals(secretID)) {
                    AmazonCredential.getInstance().setAwsAccessKeyId(accessID);
                    AmazonCredential.getInstance().setAwsSecretAccessKey(secretID);
                    hide();
                    return;
                }
            }
            JOptionPane.showMessageDialog(dialog.getDialog(), "SecretKey and AccessKey can not be empty!");
        }
    });
    JButton generateButton = new JButton("Generate Key Pair");
    generateButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            /* String accessID = ChangeCredentialWindow.this.accessKeyIDTextField.getText();
                if (!"".equals(accessID)) {
                    String secretID = ChangeCredentialWindow.this.secretAccessKeyTextField.getText();

                    if (!"".equals(secretID)) {
                        AmazonCredential.getInstance().setAwsAccessKeyId(accessID);
                        AmazonCredential.getInstance().setAwsSecretAccessKey(secretID);

                        File file = new File(System.getProperty("user.home") + "/.ssh/" + EC2Provider.KEY_PAIR_NAME);

                        if (file.exists()) {
                            ChangeCredentialWindow.this.engine.getGUI().getErrorWindow().
                                    info(ChangeCredentialWindow.this.dialog.getDialog(),
                                    "Warning", "The file " + file.getAbsolutePath() + " exists.");

                        } else {
                            AWSCredentials credential =
                                    new BasicAWSCredentials(accessID, secretID);
                            AmazonEC2Client ec2client = new AmazonEC2Client(credential);

                            try {
                                EC2ProviderUtil.buildKeyPair(ec2client, EC2Provider.KEY_PAIR_NAME);
                            } catch (NoSuchAlgorithmException e1) {
                                ChangeCredentialWindow.this.engine.getGUI().getErrorWindow().
                                        info(ChangeCredentialWindow.this.dialog.getDialog(),
                                        "Warning", e1.getMessage());
                            } catch (InvalidKeySpecException e1) {
                                ChangeCredentialWindow.this.engine.getGUI().getErrorWindow().
                                        info(ChangeCredentialWindow.this.dialog.getDialog(),
                                        "Warning", e1.getMessage());
                            } catch (IOException e1) {
                                ChangeCredentialWindow.this.engine.getGUI().getErrorWindow().
                                        info(ChangeCredentialWindow.this.dialog.getDialog(),
                                        "Warning", e1.getMessage());
                            }

                            JOptionPane.showMessageDialog(dialog.getDialog(),"The key " +
                                    file.getAbsolutePath() + " generated.");
                        }

                        hide();
                        return;
                    }
                }*/
            JOptionPane.showMessageDialog(dialog.getDialog(), "SecretKey and AccessKey can not be empty!");
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(generateButton);
    buttonPanel.add(cancelButton);
    if (this.owner == null) {
        this.dialog = new XBayaDialog(this.engine.getGUI(), "Security Credentials", mainPanel, buttonPanel);
    } else {
        this.dialog = new XBayaDialog(this.owner, "Security Credentials", mainPanel, buttonPanel);
    }
}
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) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 25 with XBayaDialog

use of org.apache.airavata.xbaya.ui.dialogs.XBayaDialog in project airavata by apache.

the class EC2InstancesManagementWindow method initGUI.

private void initGUI() {
    this.list = new XbayaEnhancedList<EC2InstanceResult>();
    GridPanel mainPanel = new GridPanel();
    TitledBorder border = new TitledBorder(new EtchedBorder(), "My Instances");
    mainPanel.getSwingComponent().setBorder(border);
    mainPanel.add(this.list);
    mainPanel.layout(1, 1, 0, 0);
    /* Connect/Refresh Button */
    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            /* Check if Credential is already set or not */
            if (credentialSet()) {
                InstancesLoader instancesLoader = new InstancesLoader(EC2InstancesManagementWindow.this.engine, EC2InstancesManagementWindow.this.dialog.getDialog());
                instancesLoader.load(EC2InstancesManagementWindow.this.list);
            }
        }
    });
    /* Launch Instance Button */
    JButton launchButton = new JButton("Launch");
    launchButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (credentialSet()) {
                EC2LaunchWindow ec2LaunchWindow = new EC2LaunchWindow(EC2InstancesManagementWindow.this.engine);
                ec2LaunchWindow.show();
            }
        }
    });
    /* Terminate Instance */
    JButton terminateButton = new JButton("Terminate");
    terminateButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            List<EC2InstanceResult> selected = EC2InstancesManagementWindow.this.list.getSelectedValues();
            if (selected.size() == 0) {
                EC2InstancesManagementWindow.this.engine.getGUI().getErrorWindow().info(EC2InstancesManagementWindow.this.dialog.getDialog(), "Warning", "No instances selected");
                return;
            }
            String text = "";
            List<String> requestIds = new ArrayList<String>();
            for (EC2InstanceResult ec2InstancesResult : selected) {
                requestIds.add(ec2InstancesResult.getInstance().getInstanceId());
                text += ec2InstancesResult.getInstance().getInstanceId() + ",";
            }
            // confirm from user
            int n = JOptionPane.showConfirmDialog(EC2InstancesManagementWindow.this.dialog.getDialog(), "Are you want to terminate instances:\n" + text, "Terminate Instances", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (n == JOptionPane.YES_OPTION) {
                // terminate
                AmazonUtil.terminateInstances(requestIds);
                // reload
                InstancesLoader instancesLoader = new InstancesLoader(EC2InstancesManagementWindow.this.engine, EC2InstancesManagementWindow.this.dialog.getDialog());
                instancesLoader.load(EC2InstancesManagementWindow.this.list);
            }
        }
    });
    /* Close Button */
    JButton closeButton = new JButton("Close");
    closeButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            EC2InstancesManagementWindow.this.hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(refreshButton);
    buttonPanel.add(launchButton);
    buttonPanel.add(terminateButton);
    buttonPanel.add(closeButton);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Amazon EC2 Management Console", mainPanel, buttonPanel);
    int width = 800;
    int height = 500;
    this.dialog.getDialog().setPreferredSize(new Dimension(width, height));
    this.dialog.setDefaultButton(closeButton);
}
Also used : XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) EC2InstanceResult(org.apache.airavata.xbaya.core.amazon.EC2InstanceResult) ActionEvent(java.awt.event.ActionEvent) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XbayaEnhancedList(org.apache.airavata.xbaya.ui.widgets.XbayaEnhancedList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ActionEvent (java.awt.event.ActionEvent)35 XBayaDialog (org.apache.airavata.xbaya.ui.dialogs.XBayaDialog)35 GridPanel (org.apache.airavata.xbaya.ui.widgets.GridPanel)33 XBayaLabel (org.apache.airavata.xbaya.ui.widgets.XBayaLabel)31 XBayaTextField (org.apache.airavata.xbaya.ui.widgets.XBayaTextField)30 AbstractAction (javax.swing.AbstractAction)29 JButton (javax.swing.JButton)29 JPanel (javax.swing.JPanel)28 XBayaTextArea (org.apache.airavata.xbaya.ui.widgets.XBayaTextArea)9 JSpinner (javax.swing.JSpinner)8 SpinnerNumberModel (javax.swing.SpinnerNumberModel)8 ActionListener (java.awt.event.ActionListener)3 JLabel (javax.swing.JLabel)3 EtchedBorder (javax.swing.border.EtchedBorder)3 TitledBorder (javax.swing.border.TitledBorder)3 XBayaComboBox (org.apache.airavata.xbaya.ui.widgets.XBayaComboBox)3 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JCheckBox (javax.swing.JCheckBox)2 AiravataClientConnectException (org.apache.airavata.model.error.AiravataClientConnectException)2 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)2