Search in sources :

Example 26 with GridPanel

use of org.apache.airavata.xbaya.ui.widgets.GridPanel 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 27 with GridPanel

use of org.apache.airavata.xbaya.ui.widgets.GridPanel 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)

Example 28 with GridPanel

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

the class WebResigtryWindow method initGUI.

/**
 * Initializes the GUI.
 */
private void initGUI() {
    this.urlTextField = new XBayaTextField();
    XBayaLabel urlLabel = new XBayaLabel("URL", this.urlTextField);
    GridPanel infoPanel = new GridPanel();
    infoPanel.add(urlLabel);
    infoPanel.add(this.urlTextField);
    infoPanel.layout(1, 2, GridPanel.WEIGHT_NONE, 1);
    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();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Web Registry", infoPanel, buttonPanel);
    this.dialog.setDefaultButton(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) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 29 with GridPanel

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

the class MemoConfigurationDialog method initGui.

/**
 * Initializes the GUI.
 */
private void initGui() {
    this.memoTextArea = new XBayaTextArea();
    XBayaLabel memoLabel = new XBayaLabel("Memo", this.memoTextArea);
    GridPanel gridPanel = new GridPanel();
    gridPanel.add(memoLabel);
    gridPanel.add(this.memoTextArea);
    gridPanel.layout(1, 2, 0, 1);
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            setInput();
        }
    });
    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);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Memo", gridPanel, buttonPanel);
    this.dialog.setDefaultButton(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) XBayaTextArea(org.apache.airavata.xbaya.ui.widgets.XBayaTextArea) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 30 with GridPanel

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

the class OutputConfigurationDialog method initGui.

/**
 * Initializes the GUI.
 */
private void initGui() {
    this.nameTextField = new XBayaTextField();
    XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
    this.dataTypeField = new XBayaTextField(this.node.getParameterType().toString());
    this.dataTypeField.setEditable(false);
    this.dataTypeLabel = new XBayaLabel("Type", this.dataTypeField);
    this.descriptionTextArea = new XBayaTextArea();
    XBayaLabel descriptionLabel = new XBayaLabel("Description", this.descriptionTextArea);
    GridPanel mainPanel = new GridPanel();
    mainPanel.add(nameLabel);
    mainPanel.add(this.nameTextField);
    mainPanel.add(this.dataTypeLabel);
    mainPanel.add(this.dataTypeField);
    mainPanel.add(descriptionLabel);
    mainPanel.add(this.descriptionTextArea);
    mainPanel.layout(3, 2, 2, 1);
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            setInput();
        }
    });
    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);
    this.dialog = new XBayaDialog(this.xbayaGUI, "Input Parameter Configuration", mainPanel, buttonPanel);
    this.dialog.setDefaultButton(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)

Aggregations

ActionEvent (java.awt.event.ActionEvent)36 GridPanel (org.apache.airavata.xbaya.ui.widgets.GridPanel)36 XBayaDialog (org.apache.airavata.xbaya.ui.dialogs.XBayaDialog)33 XBayaLabel (org.apache.airavata.xbaya.ui.widgets.XBayaLabel)31 XBayaTextField (org.apache.airavata.xbaya.ui.widgets.XBayaTextField)31 AbstractAction (javax.swing.AbstractAction)30 JButton (javax.swing.JButton)30 JPanel (javax.swing.JPanel)28 XBayaTextArea (org.apache.airavata.xbaya.ui.widgets.XBayaTextArea)11 JSpinner (javax.swing.JSpinner)8 SpinnerNumberModel (javax.swing.SpinnerNumberModel)8 JLabel (javax.swing.JLabel)5 TitledBorder (javax.swing.border.TitledBorder)4 ActionListener (java.awt.event.ActionListener)3 EtchedBorder (javax.swing.border.EtchedBorder)3 XBayaComboBox (org.apache.airavata.xbaya.ui.widgets.XBayaComboBox)3 StringSelection (java.awt.datatransfer.StringSelection)2 URL (java.net.URL)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 JCheckBox (javax.swing.JCheckBox)2