Logo Search packages:      
Sourcecode: jets3t version File versions  Download package

void org::jets3t::apps::cockpit::Cockpit::actionPerformed ( ActionEvent  event  )  [inline]

Event handler for this application, handles all menu items.

Definition at line 961 of file Cockpit.java.

References addThirdPartyBucket(), createBucketAction(), deleteSelectedBucket(), displayObjectsAttributesDialog(), downloadSelectedObjects(), org::jets3t::apps::cockpit::gui::BucketTableModel::getBuckets(), org::jets3t::apps::cockpit::CockpitPreferences::getEncryptionAlgorithm(), org::jets3t::apps::cockpit::CockpitPreferences::getEncryptionPassword(), org::jets3t::service::model::S3Bucket::getName(), org::jets3t::service::multithread::S3ServiceMulti::getS3Service(), org::jets3t::apps::cockpit::CockpitPreferences::isEncryptionPasswordSet(), org::jets3t::apps::cockpit::CockpitPreferences::isRememberPreferences(), listAllBuckets(), listBucketProperties(), listObjects(), loginEvent(), logoutEvent(), s3ServiceMulti, org::jets3t::apps::cockpit::CockpitPreferences::toProperties(), updateBucketAccessControlList(), and updateBucketRequesterPaysSetting().

Referenced by initGui(), and initMenus().

                                                   {
        // Service Menu Events
        if ("LoginEvent".equals(event.getActionCommand())) {
            loginEvent(null);
        } else if ("LogoutEvent".equals(event.getActionCommand())) {
            logoutEvent();
        } else if (event.getActionCommand() != null && event.getActionCommand().startsWith("LoginSwitch")) {
            String loginName = event.getActionCommand().substring("LoginSwitch:".length());
            AWSCredentials awsCredentials = (AWSCredentials) loginAwsCredentialsMap.get(loginName);
            loginEvent(awsCredentials);
        } else if ("QuitEvent".equals(event.getActionCommand())) {
            System.exit(0);
        }

        // Bucket Events.
        else if ("ViewBucketProperties".equals(event.getActionCommand())) {
            listBucketProperties();
        } else if ("RefreshBuckets".equals(event.getActionCommand())) {
            listAllBuckets();
        } else if ("CreateBucket".equals(event.getActionCommand())) {
            createBucketAction();
        } else if ("DeleteBucket".equals(event.getActionCommand())) {
            deleteSelectedBucket();
        } else if ("ManageDistributions".equals(event.getActionCommand())) {
            S3Bucket[] buckets = bucketTableModel.getBuckets();
            String[] bucketNames = new String[buckets.length];
            for (int i = 0; i < buckets.length; i++) {
                bucketNames[i] = buckets[i].getName();
            }
            ManageDistributionsDialog.showDialog(ownerFrame, cloudFrontService, bucketNames, this);
        } else if ("AddThirdPartyBucket".equals(event.getActionCommand())) {
            addThirdPartyBucket();
        } else if ("UpdateBucketACL".equals(event.getActionCommand())) {
            updateBucketAccessControlList();
        } else if ("UpdateBucketRequesterPaysStatus".equals(event.getActionCommand())) {
            updateBucketRequesterPaysSetting();
        }

        // Object Events
        else if ("ViewOrModifyObjectAttributes".equals(event.getActionCommand())) {
            displayObjectsAttributesDialog();
        } else if ("CopyObjects".equals(event.getActionCommand())) {
            copyObjects();
        } else if ("RefreshObjects".equals(event.getActionCommand())) {
            listObjects();
        } else if ("UpdateObjectACL".equals(event.getActionCommand())) {
            displayAclModificationDialog();
        } else if ("GeneratePublicGetURLs".equals(event.getActionCommand())) {
            generatePublicGetUrls();
        } else if ("GenerateTorrentURL".equals(event.getActionCommand())) {
            generateTorrentUrl();
        } else if ("DeleteObjects".equals(event.getActionCommand())) {
            deleteSelectedObjects();
        } else if ("DownloadObjects".equals(event.getActionCommand())) {
            downloadSelectedObjects();
        } else if ("UploadFiles".equals(event.getActionCommand())) {
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setMultiSelectionEnabled(true);
            fileChooser.setDialogTitle("Choose files to upload");
            fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fileChooser.setApproveButtonText("Upload files");
            fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory);

            int returnVal = fileChooser.showOpenDialog(ownerFrame);
            if (returnVal != JFileChooser.APPROVE_OPTION) {
                    return;
            }

            final File[] uploadFiles = fileChooser.getSelectedFiles();
            if (uploadFiles.length == 0) {
                return;
            }

            // Save the chosen directory location for next time.
            fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile();

            uploadFiles(uploadFiles);
        } else if (event.getSource().equals(filterObjectsCheckBox)) {
            if (filterObjectsCheckBox.isSelected()) {
                filterObjectsPanel.setVisible(true);
            } else {
                filterObjectsPanel.setVisible(false);
                filterObjectsPrefix.setText("");
                if (filterObjectsDelimiter.getSelectedIndex() != 0) {
                    filterObjectsDelimiter.setSelectedIndex(0);
                }
            }
        }

        // Tools events
        else if ("BucketLogging".equals(event.getActionCommand())) {
            S3Bucket[] buckets = bucketTableModel.getBuckets();
            BucketLoggingDialog.showDialog(ownerFrame, s3ServiceMulti.getS3Service(), buckets, this);
        }

        // Preference Events
        else if ("PreferencesDialog".equals(event.getActionCommand())) {
            PreferencesDialog.showDialog(cockpitPreferences, ownerFrame, this);

            // Save a user's preferences if requested, otherwise wipe any existing preferences file.
            File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory, Constants.COCKPIT_PROPERTIES_FILENAME);
            if (cockpitPreferences.isRememberPreferences()) {
                try {
                    Properties properties = cockpitPreferences.toProperties();
                    if (!cockpitHomeDirectory.exists()) {
                        cockpitHomeDirectory.mkdir();
                    }
                    properties.list(new PrintStream(
                        new FileOutputStream(cockpitPreferencesPropertiesFile)));
                } catch (IOException e) {
                    String message = "Unable to save your preferences";
                    log.error(message, e);
                    ErrorDialog.showDialog(ownerFrame, this, message, e);
                }
            } else if (cockpitPreferencesPropertiesFile.exists()) {
                // User elected not to store preferences, delete the existing preferences file.
                cockpitPreferencesPropertiesFile.delete();
            }

            if (cockpitPreferences.isEncryptionPasswordSet()) {
                try {
                    encryptionUtil = new EncryptionUtil(
                        cockpitPreferences.getEncryptionPassword(),
                        cockpitPreferences.getEncryptionAlgorithm(),
                        EncryptionUtil.DEFAULT_VERSION);
                } catch (Exception e) {
                    String message = "Unable to start encryption utility";
                    log.error(message, e);
                    ErrorDialog.showDialog(ownerFrame, this, message, e);
                }
            } else {
                encryptionUtil = null;
            }
        }

        // Ooops...
        else {
            log.debug("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event);
        }
    }


Generated by  Doxygen 1.6.0   Back to index