Search in sources :

Example 16 with XBayaTextField

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

the class EndifConfigurationDialog method initGui.

/**
 * Initializes the GUI.
 */
private void initGui() {
    this.nameTextField = new XBayaTextField();
    this.nameTextField.setEditable(false);
    XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
    this.idTextField = new XBayaTextField();
    this.idTextField.setEditable(false);
    XBayaLabel idLabel = new XBayaLabel("ID", this.idTextField);
    SpinnerNumberModel model = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
    this.numPorts = new JSpinner(model);
    XBayaLabel numPortLabel = new XBayaLabel("Number of Parameters", this.numPorts);
    GridPanel gridPanel = new GridPanel();
    gridPanel.add(nameLabel);
    gridPanel.add(this.nameTextField);
    gridPanel.add(idLabel);
    gridPanel.add(this.idTextField);
    gridPanel.add(numPortLabel);
    gridPanel.add(this.numPorts);
    gridPanel.layout(3, 2, GridPanel.WEIGHT_NONE, 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, "Endif Configuration", gridPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) 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) JSpinner(javax.swing.JSpinner) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 17 with XBayaTextField

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

the class IfConfigurationDialog method initGui.

/**
 * Initializes the GUI.
 */
private void initGui() {
    this.nameTextField = new XBayaTextField();
    this.nameTextField.setEditable(false);
    XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
    this.idTextField = new XBayaTextField();
    this.idTextField.setEditable(false);
    XBayaLabel idLabel = new XBayaLabel("ID", this.idTextField);
    SpinnerNumberModel model = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
    this.numPorts = new JSpinner(model);
    XBayaLabel numPortLabel = new XBayaLabel("Number of Inputs", this.numPorts);
    this.xpathTextField = new XBayaTextField();
    XBayaLabel xpathLabel = new XBayaLabel("XPath", this.xpathTextField);
    GridPanel gridPanel = new GridPanel();
    gridPanel.add(nameLabel);
    gridPanel.add(this.nameTextField);
    gridPanel.add(idLabel);
    gridPanel.add(this.idTextField);
    gridPanel.add(numPortLabel);
    gridPanel.add(this.numPorts);
    gridPanel.add(xpathLabel);
    gridPanel.add(this.xpathTextField);
    gridPanel.layout(4, 2, GridPanel.WEIGHT_NONE, 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, "If Configuration", gridPanel, buttonPanel);
    this.dialog.setDefaultButton(okButton);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) 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) JSpinner(javax.swing.JSpinner) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AbstractAction(javax.swing.AbstractAction) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 18 with XBayaTextField

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

the class AmazonS3UtilsWindow method initGUI.

@SuppressWarnings("serial")
protected void initGUI() {
    /* Upload Panel */
    this.fileTextField = new XBayaTextField();
    XBayaLabel fileLabel = new XBayaLabel("Upload File Path", this.fileTextField);
    this.uploadBucketTextField = new XBayaTextField();
    XBayaLabel uploadBucketLabel = new XBayaLabel("Bucket Name", this.uploadBucketTextField);
    GridPanel uploadPanel = new GridPanel();
    uploadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Upload"));
    uploadPanel.add(fileLabel);
    uploadPanel.add(this.fileTextField);
    uploadPanel.add(uploadBucketLabel);
    uploadPanel.add(this.uploadBucketTextField);
    uploadPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
    /* Download Panel */
    if (AmazonCredential.getInstance().getAwsAccessKeyId().equals("AKIAI3GNMQVYA5LSQNEQ")) {
        // Avoid to use default Aws Access Key
        JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(), "Aws Access Key not set!", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    this.downloadBucketTextField = new XBayaTextField();
    XBayaLabel downloadBucketLabel = new XBayaLabel("Bucket Name", this.downloadBucketTextField);
    this.keyTextField = new XBayaTextField();
    XBayaLabel keyLabel = new XBayaLabel("Key Name", this.keyTextField);
    this.folderTextField = new XBayaTextField();
    XBayaLabel folderLabel = new XBayaLabel("Download Location", this.folderTextField);
    GridPanel downloadPanel = new GridPanel();
    downloadPanel.getSwingComponent().setBorder(BorderFactory.createTitledBorder("Download"));
    downloadPanel.add(downloadBucketLabel);
    downloadPanel.add(this.downloadBucketTextField);
    downloadPanel.add(keyLabel);
    downloadPanel.add(this.keyTextField);
    downloadPanel.add(folderLabel);
    downloadPanel.add(this.folderTextField);
    downloadPanel.layout(3, 2, GridPanel.WEIGHT_NONE, 1);
    /* Button Panel */
    JButton refreshButton = new JButton("Connect/Refresh");
    refreshButton.addActionListener(new AbstractAction() {

        private ChangeCredentialWindow credentialWindow;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (AmazonCredential.getInstance().getAwsAccessKeyId().isEmpty() || AmazonCredential.getInstance().getAwsSecretAccessKey().isEmpty()) {
                JOptionPane.showMessageDialog(AmazonS3UtilsWindow.this.dialog.getDialog(), "Aws Access Key not set!", "Error", JOptionPane.ERROR_MESSAGE);
                if (this.credentialWindow == null) {
                    this.credentialWindow = new ChangeCredentialWindow(AmazonS3UtilsWindow.this.dialog.getDialog());
                }
                try {
                    this.credentialWindow.show();
                } catch (Exception e1) {
                    xBayaEngine.getGUI().getErrorWindow().error(e1);
                }
                return;
            }
            AmazonS3UtilsWindow.this.s3Tree.clean();
            BucketsLoader bucketsLoader = new BucketsLoader(xBayaEngine.getGUI(), window.dialog.getDialog());
            bucketsLoader.load(getS3Service(), AmazonS3UtilsWindow.this.s3Tree);
        }
    });
    JButton uploadButton = new JButton("Upload");
    uploadButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((window.fileTextField.getText().length() != 0) && (window.uploadBucketTextField.getText().length() != 0)) {
                S3Uploader s3Uploader = new S3Uploader(xBayaEngine, window.dialog.getDialog());
                s3Uploader.upload(getS3Service(), AmazonS3UtilsWindow.this.s3Tree, window.uploadBucketTextField.getText(), window.fileTextField.getText());
                window.fileTextField.setText("");
                window.folderTextField.setText("");
            } else {
                xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(), "Please give input to every upload fields");
            }
        }
    });
    JButton downloadButton = new JButton("Download");
    downloadButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if ((window.downloadBucketTextField.getText().length() != 0) && (window.keyTextField.getText().length() != 0) && (window.folderTextField.getText().length() != 0)) {
                S3Downloader s3Downloader = new S3Downloader(xBayaEngine, window.dialog.getDialog());
                s3Downloader.download(getS3Service(), window.downloadBucketTextField.getText(), window.keyTextField.getText(), window.folderTextField.getText());
                window.downloadBucketTextField.setText("");
                window.keyTextField.setText("");
                window.folderTextField.setText("");
            } else {
                xBayaEngine.getGUI().getErrorWindow().error(window.dialog.getDialog(), "Please give input to every download fields");
            }
        }
    });
    JButton fileButton = new JButton("Choose File & Flolder");
    fileButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int returnVal = fc.showOpenDialog(AmazonS3UtilsWindow.this.dialog.getDialog());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String filePath = fc.getSelectedFile().getAbsolutePath();
                File file = fc.getSelectedFile();
                if (file.isFile()) {
                    window.fileTextField.setText(filePath);
                    window.folderTextField.setText("");
                } else if (file.isDirectory()) {
                    window.folderTextField.setText(filePath);
                    window.fileTextField.setText("");
                }
            }
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(refreshButton);
    buttonPanel.add(uploadButton);
    buttonPanel.add(downloadButton);
    buttonPanel.add(fileButton);
    buttonPanel.add(cancelButton);
    /* Main Panel */
    GridPanel mainPanel = new GridPanel(true);
    this.s3Tree = new S3Tree();
    mainPanel.add(new JScrollPane(this.s3Tree));
    mainPanel.add(uploadPanel);
    mainPanel.add(downloadPanel);
    mainPanel.layout(3, 1, 0, GridPanel.WEIGHT_EQUALLY);
    this.s3Tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = AmazonS3UtilsWindow.this.s3Tree.getSelectedNode();
            if (node == null)
                return;
            Object nodeInfo = node.getUserObject();
            String bucketName;
            String downloadPanelBucketName = "";
            if (node.isLeaf() && node.getParent() != null) {
                // Node is probably a key
                DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                bucketName = (String) parentNode.getUserObject();
                if (!bucketName.equals("S3 Contents")) {
                    // Node is indeed a key
                    downloadPanelBucketName = (String) parentNode.getUserObject();
                    String currentNodeName = (String) node.getUserObject();
                    int index = currentNodeName.lastIndexOf('/');
                    index = index >= 0 ? index : 0;
                    if (index > 0) {
                        bucketName = bucketName + "/" + currentNodeName.substring(0, index);
                    }
                    String keyName = (String) nodeInfo;
                    window.keyTextField.setText(keyName);
                } else // Node is a bucket
                {
                    bucketName = (String) nodeInfo;
                    window.keyTextField.setText("");
                }
            } else {
                // Node is a bucket
                bucketName = (String) nodeInfo;
                window.keyTextField.setText("");
            }
            window.uploadBucketTextField.setText(bucketName);
            window.downloadBucketTextField.setText(downloadPanelBucketName);
        }
    });
    this.dialog = new XBayaDialog(xBayaEngine.getGUI(), "Amazon S3 Upload/Download Tool", mainPanel, buttonPanel);
}
Also used : XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) S3Tree(org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree) TreeSelectionListener(javax.swing.event.TreeSelectionListener) S3ServiceException(org.jets3t.service.S3ServiceException) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) File(java.io.File) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 19 with XBayaTextField

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

the class EC2LaunchWindow method initGUI.

private void initGUI() {
    /* Main Panel */
    this.amiTextField = new XBayaTextField();
    XBayaLabel amiLabel = new XBayaLabel("AMI ID", this.amiTextField);
    this.numberOfInstanceSpinner = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
    XBayaLabel nInstanceLabel = new XBayaLabel("Number Of Instances", this.numberOfInstanceSpinner);
    this.instanceTypeComboBox = new XBayaComboBox(new DefaultComboBoxModel(AmazonUtil.INSTANCE_TYPE));
    this.instanceTypeComboBox.setSelectedItem(AmazonUtil.INSTANCE_TYPE[1]);
    XBayaLabel instanceTypeLabel = new XBayaLabel("Instance Type", this.instanceTypeComboBox);
    JRadioButton noKeyButton = new JRadioButton("No Key Pair");
    noKeyButton.setSelected(true);
    noKeyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent paramActionEvent) {
            EC2LaunchWindow.this.keyComboBox.getJComboBox().setEnabled(false);
        }
    });
    this.existKeyButton = new JRadioButton("Exist Key Pairs");
    this.existKeyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent paramActionEvent) {
            if (EC2LaunchWindow.this.keyComboBoxModel == null) {
                EC2LaunchWindow.this.keyComboBoxModel = new DefaultComboBoxModel(AmazonUtil.loadKeypairs().toArray());
                EC2LaunchWindow.this.keyComboBox.setModel(EC2LaunchWindow.this.keyComboBoxModel);
            }
            EC2LaunchWindow.this.keyComboBox.getJComboBox().setEnabled(true);
        }
    });
    ButtonGroup serviceTypeButtonGroup = new ButtonGroup();
    serviceTypeButtonGroup.add(noKeyButton);
    serviceTypeButtonGroup.add(this.existKeyButton);
    this.keyComboBox = new XBayaComboBox(new DefaultComboBoxModel());
    this.keyComboBox.getJComboBox().setEnabled(false);
    GridPanel radioPanel = new GridPanel();
    radioPanel.add(noKeyButton);
    radioPanel.add(new JPanel());
    radioPanel.add(this.existKeyButton);
    radioPanel.add(this.keyComboBox);
    radioPanel.layout(2, 2, 0, 1);
    XBayaLabel keyLabel = new XBayaLabel("Key Pair", radioPanel);
    GridPanel mainPanel = new GridPanel(true);
    mainPanel.add(amiLabel);
    mainPanel.add(this.amiTextField);
    mainPanel.add(nInstanceLabel);
    mainPanel.add(this.numberOfInstanceSpinner);
    mainPanel.add(instanceTypeLabel);
    mainPanel.add(this.instanceTypeComboBox);
    mainPanel.add(keyLabel);
    mainPanel.add(radioPanel);
    mainPanel.layout(4, 2, 0, GridPanel.WEIGHT_EQUALLY);
    /* Button Panel */
    JButton lunchButton = new JButton("Launch");
    lunchButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // validation
            if (EC2LaunchWindow.this.amiTextField.getText() == null || EC2LaunchWindow.this.amiTextField.getText().isEmpty() || (Integer) EC2LaunchWindow.this.numberOfInstanceSpinner.getValue() <= 0) {
                EC2LaunchWindow.this.engine.getGUI().getErrorWindow().info(EC2LaunchWindow.this.dialog.getDialog(), "Warning", "Please input all fields");
                return;
            }
            try {
                // get all data
                String ami = EC2LaunchWindow.this.amiTextField.getText();
                String instanceType = EC2LaunchWindow.this.instanceTypeComboBox.getText();
                Integer n = (Integer) EC2LaunchWindow.this.numberOfInstanceSpinner.getValue();
                // use exist key pair
                if (EC2LaunchWindow.this.existKeyButton.isSelected()) {
                    String keyname = EC2LaunchWindow.this.keyComboBox.getText();
                    AmazonUtil.launchInstance(ami, instanceType, n, keyname);
                } else {
                    AmazonUtil.launchInstance(ami, instanceType, n);
                }
                EC2LaunchWindow.this.hide();
            } catch (NumberFormatException nfe) {
                EC2LaunchWindow.this.engine.getGUI().getErrorWindow().info(EC2LaunchWindow.this.dialog.getDialog(), "Warning", "Number of Instances is not numeric");
            } catch (Exception ex) {
                EC2LaunchWindow.this.engine.getGUI().getErrorWindow().error(EC2LaunchWindow.this.dialog.getDialog(), "Cannot start EC2 instances: " + ex.getMessage(), ex);
            }
        }
    });
    JButton closeButton = new JButton("Close");
    closeButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            EC2LaunchWindow.this.hide();
        }
    });
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(lunchButton);
    buttonPanel.add(closeButton);
    this.dialog = new XBayaDialog(this.engine.getGUI(), "Amazon EC2 Launcher", mainPanel, buttonPanel);
}
Also used : XBayaComboBox(org.apache.airavata.xbaya.ui.widgets.XBayaComboBox) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) GridPanel(org.apache.airavata.xbaya.ui.widgets.GridPanel) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 20 with XBayaTextField

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

the class URLRegistryWindow 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)

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