Search in sources :

Example 1 with BucketsLoader

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

the class S3FileChooser method initGUI.

private void initGUI() {
    /*
         * ScrollPane for S3 Tree
         */
    // add tree listener to this
    this.s3Tree = new S3Tree();
    this.s3Tree.addTreeSelectionListener(this);
    JScrollPane scrollPane = new JScrollPane(this.s3Tree);
    /*
         * 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()) {
                S3FileChooser.this.xbayaGUI.getErrorWindow().warning(S3FileChooser.this.dialog.getDialog(), "Error", "Aws Access Key not set!");
                if (this.credentialWindow == null) {
                    this.credentialWindow = new ChangeCredentialWindow(S3FileChooser.this.dialog.getDialog());
                }
                try {
                    this.credentialWindow.show();
                } catch (Exception e1) {
                    S3FileChooser.this.xbayaGUI.getErrorWindow().error(e1);
                }
                return;
            }
            S3FileChooser.this.s3Tree.clean();
            try {
                // create S3Service
                S3Service s3Service = new RestS3Service(new AWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(), AmazonCredential.getInstance().getAwsSecretAccessKey()));
                BucketsLoader bucketsLoader = new BucketsLoader(S3FileChooser.this.xbayaGUI, S3FileChooser.this.dialog.getDialog());
                bucketsLoader.load(s3Service, S3FileChooser.this.s3Tree);
            } catch (S3ServiceException s3ex) {
                S3FileChooser.this.xbayaGUI.getErrorWindow().error(s3ex);
            }
        }
    });
    JButton okButton = new JButton("Ok");
    okButton.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (S3FileChooser.this.chosenFile != null) {
                S3FileChooser.this.inputNode.setDefaultValue(new String(S3FileChooser.this.chosenFile));
            }
            hide();
        }
    });
    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(okButton);
    buttonPanel.add(cancelButton);
    this.dialog = new XBayaDialog(this.xbayaGUI, "Amazon S3 Input Chooser", scrollPane, buttonPanel);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) XBayaDialog(org.apache.airavata.xbaya.ui.dialogs.XBayaDialog) S3Tree(org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) S3ServiceException(org.jets3t.service.S3ServiceException) AWSCredentials(org.jets3t.service.security.AWSCredentials) S3ServiceException(org.jets3t.service.S3ServiceException) BucketsLoader(org.apache.airavata.xbaya.ui.dialogs.amazon.BucketsLoader) RestS3Service(org.jets3t.service.impl.rest.httpclient.RestS3Service) ChangeCredentialWindow(org.apache.airavata.xbaya.ui.dialogs.amazon.ChangeCredentialWindow) AbstractAction(javax.swing.AbstractAction) RestS3Service(org.jets3t.service.impl.rest.httpclient.RestS3Service) S3Service(org.jets3t.service.S3Service)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 XBayaDialog (org.apache.airavata.xbaya.ui.dialogs.XBayaDialog)1 BucketsLoader (org.apache.airavata.xbaya.ui.dialogs.amazon.BucketsLoader)1 ChangeCredentialWindow (org.apache.airavata.xbaya.ui.dialogs.amazon.ChangeCredentialWindow)1 S3Tree (org.apache.airavata.xbaya.ui.widgets.amazon.S3Tree)1 S3Service (org.jets3t.service.S3Service)1 S3ServiceException (org.jets3t.service.S3ServiceException)1 RestS3Service (org.jets3t.service.impl.rest.httpclient.RestS3Service)1 AWSCredentials (org.jets3t.service.security.AWSCredentials)1