Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showInputDialog.

Prototype

public static String showInputDialog(Component parentComponent, Object message, Object initialSelectionValue) 

Source Link

Document

Shows a question-message dialog requesting input from the user and parented to parentComponent.

Usage

From source file:org.wso2.appserver.sample.flickr.client.FlickrServiceFrame.java

public FlickrServiceFrame() {

    this.setTitle("WSO2 AppServer FlickrClient Sample - Invokes Flickr in a RESTfull manner");

    for (int i = 1; i <= 50; i++) {
        cmbGetContactsPhotos.addItem(new Integer(i));
        cmbGetContactsPublicPhotosCount.addItem(new Integer(i));
        cmbUserCommentsPerPage.addItem(new Integer(i));
        cmbUserPhotosPerPage.addItem(new Integer(i));
    }//from   w w  w.  ja  v  a  2  s.c o  m
    for (int i = 1; i <= 400; i++) {
        cmbGrpPoolsGrpsPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 500; i++) {
        cmbGetFavoritesPerPage.addItem(new Integer(i));
        cmbGetNotInSetPerPage.addItem(new Integer(i));
        cmbGetRecentPerPage.addItem(new Integer(i));
        cmbGetUntaggedPerPage.addItem(new Integer(i));
        cmbGetWithGeoDataPerPage.addItem(new Integer(i));
        cmbGetWithoutGeoDataPerPage.addItem(new Integer(i));
        cmbRecentlyUpdatedPerPage.addItem(new Integer(i));
        cmbSearchPerPage.addItem(new Integer(i));
        cmbFavoritesGetPerPage.addItem(new Integer(i));
        cmbFavoritesGetPubPerPage.addItem(new Integer(i));
        cmbGroupsSearchPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 1000; i++) {
        cmbContactsGetPerPage.addItem(new Integer(i));
        cmbContactsGetPubPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 16; i++) {
        cmbGeoSetLocAccuracy.addItem(new Integer(i));
        cmbSearchAccuracy.addItem(new Integer(i));
    }

    for (int i = -90; i <= 90; i++) {
        cmbGeoSetLocLatitude.addItem(new Integer(i));
    }

    for (int i = -180; i <= 180; i++) {
        cmbGeoSetLocLongitude.addItem(new Integer(i));
    }

    cmbGeoSetLocLatitude.setSelectedIndex(89);
    cmbGeoSetLocLongitude.setSelectedIndex(179);
    cmbGeoSetLocAccuracy.setSelectedIndex(15);
    cmbSearchAccuracy.setSelectedIndex(15);
    cmbUserCommentsPerPage.setSelectedIndex(9);
    cmbUserPhotosPerPage.setSelectedIndex(9);
    cmbGetContactsPhotos.setSelectedIndex(9);
    cmbGetContactsPublicPhotosCount.setSelectedIndex(9);
    cmbContactsGetPerPage.setSelectedIndex(999);
    cmbContactsGetPubPerPage.setSelectedIndex(999);
    cmbGetFavoritesPerPage.setSelectedIndex(9);
    cmbGetNotInSetPerPage.setSelectedIndex(99);
    cmbGetRecentPerPage.setSelectedIndex(99);
    cmbGetUntaggedPerPage.setSelectedIndex(99);
    cmbGetWithGeoDataPerPage.setSelectedIndex(99);
    cmbGetWithoutGeoDataPerPage.setSelectedIndex(99);
    cmbRecentlyUpdatedPerPage.setSelectedIndex(99);
    cmbSearchPerPage.setSelectedIndex(99);
    cmbFavoritesGetPerPage.setSelectedIndex(99);
    cmbFavoritesGetPubPerPage.setSelectedIndex(99);
    cmbGroupsSearchPerPage.setSelectedIndex(99);
    cmbGrpPoolsGrpsPerPage.setSelectedIndex(399);

    cmbContactsGetFilter.addItem("");
    cmbContactsGetFilter.addItem(Filter._both);
    cmbContactsGetFilter.addItem(Filter._family);
    cmbContactsGetFilter.addItem(Filter._friends);
    cmbContactsGetFilter.addItem(Filter._neither);

    cmbGetWithGeoDataPrivacy.addItem("");
    cmbGetWithGeoDataPrivacy.addItem(Filter._both);
    cmbGetWithGeoDataPrivacy.addItem(Filter._family);
    cmbGetWithGeoDataPrivacy.addItem(Filter._friends);
    cmbGetWithGeoDataPrivacy.addItem(Filter._neither);

    cmbGetWithoutGeoDataPrivacy.addItem("");
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._both);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._family);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._friends);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._neither);

    JMenu configMenu = new JMenu("Configure");
    JMenuItem hostMenuItem = configMenu.add("Host");
    hostMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String result = JOptionPane.showInputDialog(getContentPane(), "Enter host address", host);
            if (result != null && !"".equals(result.trim())) {
                host = result;
            }
        }
    });
    JMenuItem portMenuItem = configMenu.add("Port");
    portMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String result = JOptionPane.showInputDialog(getContentPane(), "Enter port", port);
            if (result != null && !"".equals(result.trim())) {
                port = result;
            }
        }
    });

    JMenuItem keyMenuItem = configMenu.add("API KEY");
    keyMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getAPIKEY();
        }
    });

    JMenuItem secretMenuItem = configMenu.add("Secret");
    secretMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getSharedSecret();
        }
    });

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    menuBar.add(configMenu);

    // flickr.people Operations

    findByEmailInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleEmail.getText().trim())) {
                showRequiredMessage("E-mail");
            } else {
                findByEmailOutput
                        .setText(client.flickrPeopleFindByEmail(txtPeopleEmail.getText(), key, host, port));
            }
        }
    });

    findByUsernameInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleUsername.getText().trim())) {
                showRequiredMessage("Username");
            } else {
                findByUsernameOutput.setText(
                        client.flickrPeopleFindByUsername(txtPeopleUsername.getText(), key, host, port));
            }
        }
    });

    getInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleGetInfo.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getInfoOutput.setText(client.flickrPeopleGetInfo(txtPeopleGetInfo.getText(), key, host, port));
            }
        }
    });

    getPublicGroupsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPublicGroups.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getPublicGroupsOutput.setText(
                        client.flickrPeopleGetPublicGroups(txtGetPublicGroups.getText(), key, host, port));
            }
        }
    });
    getPublicPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPublicPhotos.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getPublicPhotosOutput.setText(
                        client.flickrPeopleGetPublicPhotos(txtGetPublicPhotos.getText(), key, host, port));
            }
        }
    });
    getUploadStatusInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {

            if (checkToken(READ))
                getUploadStatusOutput
                        .setText(client.flickrPeopleGetUploadStatus(sharedSecret, token, key, host, port));
        }
    });

    photosGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            String photoID = txtPhotosGetInfoPhotoID.getText();
            if ("".equals(photoID.trim())) {
                showRequiredMessage("PhotoID");
            } else {
                photosGetInfoOutput.setText(
                        client.flickrPhotosGetInfo(photoID, txtPhotosGetInfoSecret.getText(), key, host, port));
            }
        }

    });

    // flickr.activity Operations

    userCommentsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                userCommentsOutput.setText(client.flickrActivityUserComments(txtUserCommentsPage.getText(),
                        cmbUserCommentsPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
        }
    });

    userPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                userPhotosOutput.setText(client.flickrActivityUserPhotos(txtUserPhotosPage.getText(),
                        cmbUserPhotosPerPage.getSelectedItem().toString(), txtUserPhotosTimeFrame.getText(),
                        sharedSecret, token, key, host, port));
        }
    });

    // flickr.blog Operations

    blogsGetListInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                blogsGetListOutput.setText(client.flickrBlogsGetList(sharedSecret, token, key, host, port));
        }
    });

    postPhotoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPostPhotoBlogID.getText().trim())) {
                showRequiredMessage("Blog ID");
            } else if ("".equals(txtPostPhotoPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtPostPhotoTitle.getText().trim())) {
                showRequiredMessage("Title");
            } else if ("".equals(txtPostPhotoDescription.getText().trim())) {
                showRequiredMessage("Description");
            } else {
                if (checkToken(WRITE))
                    postPhotoOutput.setText(client.flickrBlogsPostPhoto(txtPostPhotoBlogID.getText(),
                            txtPostPhotoPhotoID.getText(), txtPostPhotoTitle.getText(),
                            txtPostPhotoDescription.getText(), txtPostPhotoPassword.getText(), sharedSecret,
                            token, key, host, port));
            }
        }
    });

    // flickr.photosets.comments operations

    photoSetsCommAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(PhotoSetsCommAddComment.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtPhotoSetsCommAddID.getText().trim())) {
                showRequiredMessage("Comment");
            } else {
                if (checkToken(WRITE))
                    photoSetsCommAddOutput
                            .setText(client.flickrPhotosetsCommentsAddComment(PhotoSetsCommAddComment.getText(),
                                    txtPhotoSetsCommAddID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommDelInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommDelID.getText().trim())) {
                showRequiredMessage("Comment ID");
            } else {
                if (checkToken(WRITE))
                    photoSetsCommDelOutput.setText(client.flickrPhotosetsCommentsDeleteComment(
                            txtPhotoSetsCommDelID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommEditInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommEditID.getText().trim())) {
                showRequiredMessage("Comment ID");
            } else if ("".equals(txtPhotoSetsCommEditComment.getText().trim())) {
                showRequiredMessage("Comment");
            } else {
                if (checkToken(WRITE))
                    PhotoSetsCommEditOutput.setText(
                            client.flickrPhotosetsCommentsEditComment(txtPhotoSetsCommEditComment.getText(),
                                    txtPhotoSetsCommEditID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommGetID.getText().trim())) {
                showRequiredMessage("Photoset ID");
            } else {
                photoSetsCommGetOutput.setText(client.flickrPhotosetsCommentsGetList(
                        txtPhotoSetsCommGetID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.contacts Operations

    contactsGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            contactsGetOutput.setText(client.flickrContactsGetList(cmbContactsGetFilter.getSelectedItem(),
                    txtContactsGetPage.getText(), cmbContactsGetPerPage.getSelectedItem().toString(),
                    sharedSecret, token, key, host, port));
        }
    });

    contactsGetPubInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtContactsGetPubID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                contactsGetPubOutput.setText(client.flickrContactsGetPublicList(txtContactsGetPubID.getText(),
                        txtContactsGetPubPage.getText(), cmbContactsGetPubPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.favorites Operations

    favoritesAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesAddID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    favoritesAddOutput.setText(client.flickrFavoritesAdd(txtFavoritesAddID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    favoritesGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkFavoritesGetLicense.isSelected());
                extrasBean.setDate_taken(chkFavoritesGetDateTak.isSelected());
                extrasBean.setDate_upload(chkFavoritesGetDateUp.isSelected());
                extrasBean.setGeo(chkFavoritesGetGeo.isSelected());
                extrasBean.setIcon_server(chkFavoritesGetServer.isSelected());
                extrasBean.setLast_update(chkFavoritesGetLastUp.isSelected());
                extrasBean.setMachine_tags(chkFavoritesGetMachine.isSelected());
                extrasBean.setOriginal_format(chkFavoritesGetOriginal.isSelected());
                extrasBean.setOwner_name(chkFavoritesGetOwner.isSelected());
                extrasBean.setTags(chkFavoritesGetTags.isSelected());
                favoritesGetOutput.setText(client.flickrFavoritesGetList(txtFavoritesGetID.getText(),
                        txtFavoritesGetPage.getText(), cmbFavoritesGetPerPage.getSelectedItem().toString(),
                        extrasBean, sharedSecret, token, key, host, port));
            }
        }
    });

    favoritesGetPubInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesGetPubID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkFavoritesGetPubLicense.isSelected());
                extrasBean.setDate_taken(chkFavoritesGetPubDateTak.isSelected());
                extrasBean.setDate_upload(chkFavoritesGetPubDateUp.isSelected());
                extrasBean.setGeo(chkFavoritesGetPubGeo.isSelected());
                extrasBean.setIcon_server(chkFavoritesGetPubServer.isSelected());
                extrasBean.setLast_update(chkFavoritesGetPubLastUp.isSelected());
                extrasBean.setMachine_tags(chkFavoritesGetPubMachine.isSelected());
                extrasBean.setOriginal_format(chkFavoritesGetPubOriginal.isSelected());
                extrasBean.setOwner_name(chkFavoritesGetPubOwner.isSelected());
                extrasBean.setTags(chkFavoritesGetPubTags.isSelected());
                favoritesGetPubOutput.setText(client.flickrFavoritesGetPublicList(
                        txtFavoritesGetPubID.getText(), txtFavoritesGetPubPage.getText(),
                        cmbFavoritesGetPubPerPage.getSelectedItem().toString(), extrasBean, sharedSecret, token,
                        key, host, port));
            }
        }
    });

    favoritesRmvInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesRmvID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                if (checkToken(WRITE))
                    favoritesRmvOutput.setText(client.flickrFavoritesRemove(txtFavoritesRmvID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.photos.geo Operations

    geoGetLocInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoGetLocID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                geoGetLocOutput.setText(client.flickrPhotosGeoGetLocation(txtGeoGetLocID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    geoGetPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoGetPermsID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(READ))
                    geoGetPermsOutput.setText(client.flickrPhotosGeoGetPerms(txtGeoGetPermsID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    geoRmvLocInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoRmvLocID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    geoRmvLocOutput.setText(client.flickrPhotosGeoRemoveLocation(txtGeoRmvLocID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    geoSetPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoSetPermsID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    geoSetPermsOutput.setText(client.flickrPhotosGeoSetPerms(txtGeoSetPermsID.getText(),
                            chkGeoSetPermsPublic.isSelected(), chkGeoSetPermsContact.isSelected(),
                            chkGeoSetPermsFriend.isSelected(), chkGeoSetPermsFamily.isSelected(), sharedSecret,
                            token, key, host, port));
            }
        }
    });

    // flickr.groups Operations

    groupsBrowseInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                groupsBrowseOutput.setText(client.flickrGroupsBrowse(txtGroupsBrowseID.getText(), sharedSecret,
                        token, key, host, port));
        }
    });

    groupsGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGroupsGetInfoID.getText().trim())) {
                showRequiredMessage("Group ID");
            } else {
                groupsGetInfoOutput.setText(client.flickrGroupsGetInfo(txtGroupsGetInfoID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    groupsSearchInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGroupsSearchText.getText().trim())) {
                showRequiredMessage("Text");
            } else {
                if (checkToken(WRITE))
                    groupsSearchOutput.setText(client.flickrGroupsSearch(txtGroupsSearchText.getText(),
                            txtGroupsSearchPage.getText(), cmbGroupsSearchPerPage.getSelectedItem().toString(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.groups.pools Operations

    grpPoolsAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGrpPoolsAddPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtGrpPoolsAddGroupID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                grpPoolsAddOutput.setText(client.flickrGroupsPoolsAdd(txtGrpPoolsAddPhotoID.getText(),
                        txtGrpPoolsAddGroupID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    grpPoolsContextInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGrpPoolsContextPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtGrpPoolsContextGrpID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                grpPoolsContextOutput
                        .setText(client.flickrGroupsPoolsGetContext(txtGrpPoolsContextPhotoID.getText(),
                                txtGrpPoolsContextGrpID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    grpPoolsGrpsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                grpPoolsGrpsOutput.setText(client.flickrGroupsPoolsGetGroups(txtGrpPoolsGrpsPage.getText(),
                        cmbGrpPoolsGrpsPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
        }
    });

    // flickr.photos Operations

    photosGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosGetInfoPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                photosGetInfoOutput.setText(client.flickrPhotosGetInfo(txtPhotosGetInfoPhotoID.getText(),
                        sharedSecret, key, host, port));
            }
        }
    });

    photosAddTagsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosAddTagsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtAddTags.getText().trim())) {
                showRequiredMessage("Tags");
            } else {
                if (checkToken(WRITE))
                    photosAddTagsOutput.setText(client.flickrPhotosAddTags(txtPhotosAddTagsPhotoID.getText(),
                            txtAddTags.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photosDeleteInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosDeletePhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(DELETE))
                    photosDeleteOutput.setText(client.flickrPhotosDelete(txtPhotosDeletePhotoID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    getAllContextsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetAllContextsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(DELETE))
                    getAllContextsOutput.setText(client.flickrPhotosGetAllContexts(
                            txtGetAllContextsPhotoID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    getContactsPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetContactsPhotosLicense.isSelected());
                extrasBean.setDate_taken(chkGetContactsPhotosDateTaken.isSelected());
                extrasBean.setDate_upload(chkGetContactsPhotosUploadDate.isSelected());
                extrasBean.setIcon_server(chkGetContactsPhotosServer.isSelected());
                extrasBean.setLast_update(chkGetContactsPhotosLastUpdate.isSelected());
                extrasBean.setOriginal_format(chkGetContactsPhotosOriginal.isSelected());
                extrasBean.setOwner_name(chkGetContactsPhotosOwner.isSelected());

                getContactsPhotosOutput.setText(
                        client.flickrPhotosGetContactsPhotos(cmbGetContactsPhotos.getSelectedItem().toString(),
                                chkGetContactsPhotosFriends.isSelected(),
                                chkGetContactsPhotosSingle.isSelected(), chkGetContactsPhotosSelf.isSelected(),
                                extrasBean, sharedSecret, token, key, host, port));
            }
        }
    });

    getContactsPublicPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetContactsPhotosLicense.isSelected());
                extrasBean.setDate_taken(chkGetContactsPhotosDateTaken.isSelected());
                extrasBean.setDate_upload(chkGetContactsPhotosUploadDate.isSelected());
                extrasBean.setIcon_server(chkGetContactsPhotosServer.isSelected());
                extrasBean.setLast_update(chkGetContactsPhotosLastUpdate.isSelected());
                extrasBean.setOriginal_format(chkGetContactsPhotosOriginal.isSelected());
                extrasBean.setOwner_name(chkGetContactsPhotosOwner.isSelected());

                getContactsPublicPhotosOutput.setText(
                        client.flickrPhotosGetContactsPublicPhotos(txtGetContactsPublicPhotosUserID.getText(),
                                cmbGetContactsPublicPhotosCount.getSelectedItem().toString(),
                                chkGetContactsPublicPhotosFriends.isSelected(),
                                chkGetContactsPublicPhotosSingle.isSelected(),
                                chkGetContactsPublicPhotosSelf.isSelected(), extrasBean, sharedSecret, token,
                                key, host, port));
            }
        }
    });

    getContextInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetContextPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getContextOutput.setText(client.flickrPhotosGetContext(txtGetContextPhotoID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getCountsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                getCountsOutput.setText(client.flickrPhotosGetCounts(txtGetCountsDates.getText(),
                        txtGetCountsDatesTaken.getText(), sharedSecret, token, key, host, port));
        }
    });

    getExifInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetExifPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getExifOutput.setText(client.flickrPhotosGetExif(txtGetExifPhotoID.getText(),
                        txtGetExifSecret.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    getFavoritesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetFavoritesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getFavoritesOutput.setText(client.flickrPhotosGetFavorites(txtGetFavoritesPhotoID.getText(),
                        txtGetFavoritesPage.getText(), cmbGetFavoritesPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getNotInSetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetNotInSetLicense.isSelected());
                extrasBean.setDate_taken(chkGetNotInSetDateTak.isSelected());
                extrasBean.setDate_upload(chkGetNotInSetDateUp.isSelected());
                extrasBean.setGeo(chkGetNotInSetGeo.isSelected());
                extrasBean.setIcon_server(chkGetNotInSetServer.isSelected());
                extrasBean.setLast_update(chkGetNotInSetLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetNotInSetMachine.isSelected());
                extrasBean.setOriginal_format(chkGetNotInSetOriginal.isSelected());
                extrasBean.setOwner_name(chkGetNotInSetOwner.isSelected());
                extrasBean.setTags(chkGetNotInSetTags.isSelected());
                getNotInSetOutput.setText(client.flickrPhotosGetNotInSet(txtGetNotInSetMinUpDate.getText(),
                        txtGetNotInSetMaxUpDate.getText(), txtGetNotInSetMinTakDate.getText(),
                        txtGetNotInSetMaxTakDate.getText(), cmbGetNotInSetPrivacy.getSelectedItem().toString(),
                        extrasBean, txtGetNotInSetPage.getText(),
                        cmbGetNotInSetPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    getPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPermsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(READ))
                    getPermsOutput.setText(client.flickrPhotosGetPerms(txtGetPermsPhotoID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    getRecentInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            ExtrasBean extrasBean = new ExtrasBean();
            extrasBean.setLicense(chkGetRecentLicense.isSelected());
            extrasBean.setDate_taken(chkGetRecentDateTak.isSelected());
            extrasBean.setDate_upload(chkGetRecentDateUp.isSelected());
            extrasBean.setGeo(chkGetRecentGeo.isSelected());
            extrasBean.setIcon_server(chkGetRecentServer.isSelected());
            extrasBean.setLast_update(chkGetRecentLastUp.isSelected());
            extrasBean.setMachine_tags(chkGetRecentMachine.isSelected());
            extrasBean.setOriginal_format(chkGetRecentOriginal.isSelected());
            extrasBean.setOwner_name(chkGetRecentOwner.isSelected());
            extrasBean.setTags(chkGetRecentTags.isSelected());
            getRecentOutput.setText(client.flickrPhotosGetRecent(extrasBean, txtGetRecentPage.getText(),
                    cmbGetRecentPerPage.getSelectedItem().toString(), sharedSecret, token, key, host, port));
        }
    });

    getSizesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetSizesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getSizesOutput.setText(client.flickrPhotosGetSizes(txtGetSizesPhotoID.getText(), sharedSecret,
                        token, key, host, port));
            }
        }
    });

    getUntaggedInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetUntaggedLicense.isSelected());
                extrasBean.setDate_taken(chkGetUntaggedDateTak.isSelected());
                extrasBean.setDate_upload(chkGetUntaggedDateUp.isSelected());
                extrasBean.setGeo(chkGetUntaggedGeo.isSelected());
                extrasBean.setIcon_server(chkGetUntaggedServer.isSelected());
                extrasBean.setLast_update(chkGetUntaggedLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetUntaggedMachine.isSelected());
                extrasBean.setOriginal_format(chkGetUntaggedOriginal.isSelected());
                extrasBean.setOwner_name(chkGetUntaggedOwner.isSelected());
                extrasBean.setTags(chkGetUntaggedTags.isSelected());
                getUntaggedOutput.setText(client.flickrPhotosGetUntagged(txtGetUntaggedMinUpDate.getText(),
                        txtGetUntaggedMaxUpDate.getText(), txtGetUntaggedMinTakDate.getText(),
                        txtGetUntaggedMaxTakDate.getText(), cmbGetUntaggedPrivacy.getSelectedItem().toString(),
                        extrasBean, txtGetUntaggedPage.getText(),
                        cmbGetUntaggedPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    getWithGeoDataInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetWithGeoDataLicense.isSelected());
                extrasBean.setDate_taken(chkGetWithGeoDataDateTak.isSelected());
                extrasBean.setDate_upload(chkGetWithGeoDataDateUp.isSelected());
                extrasBean.setGeo(chkGetWithGeoDataGeo.isSelected());
                extrasBean.setIcon_server(chkGetWithGeoDataServer.isSelected());
                extrasBean.setLast_update(chkGetWithGeoDataLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetWithGeoDataMachine.isSelected());
                extrasBean.setOriginal_format(chkGetWithGeoDataOriginal.isSelected());
                extrasBean.setOwner_name(chkGetWithGeoDataOwner.isSelected());
                extrasBean.setTags(chkGetWithGeoDataTags.isSelected());
                getWithGeoDataOutput.setText(client.flickrPhotosGetWithGeoData(
                        txtGetWithGeoDataMinUpDate.getText(), txtGetWithGeoDataMaxUpDate.getText(),
                        txtGetWithGeoDataMinTakDate.getText(), txtGetWithGeoDataMaxTakDate.getText(),
                        cmbGetWithGeoDataPrivacy.getSelectedItem().toString(), extrasBean,
                        txtGetWithGeoDataPage.getText(), cmbGetWithGeoDataPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getWithoutGeoDataInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetWithoutGeoDataLicense.isSelected());
                extrasBean.setDate_taken(chkGetWithoutGeoDataDateTak.isSelected());
                extrasBean.setDate_upload(chkGetWithoutGeoDataDateUp.isSelected());
                extrasBean.setGeo(chkGetWithoutGeoDataGeo.isSelected());
                extrasBean.setIcon_server(chkGetWithoutGeoDataServer.isSelected());
                extrasBean.setLast_update(chkGetWithoutGeoDataLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetWithoutGeoDataMachine.isSelected());
                extrasBean.setOriginal_format(chkGetWithoutGeoDataOriginal.isSelected());
                extrasBean.setOwner_name(chkGetWithoutGeoDataOwner.isSelected());
                extrasBean.setTags(chkGetWithoutGeoDataTags.isSelected());
                getWithoutGeoDataOutput.setText(client.flickrPhotosGetWithoutGeoData(
                        txtGetWithoutGeoDataMinUpDate.getText(), txtGetWithoutGeoDataMaxUpDate.getText(),
                        txtGetWithoutGeoDataMinTakDate.getText(), txtGetWithoutGeoDataMaxTakDate.getText(),
                        cmbGetWithoutGeoDataPrivacy.getSelectedItem().toString(), extrasBean,
                        txtGetWithoutGeoDataPage.getText(),
                        cmbGetWithoutGeoDataPerPage.getSelectedItem().toString(), sharedSecret, token, key,
                        host, port));
            }
        }
    });

    recentlyUpdatedInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkRecentlyUpdatedLicense.isSelected());
                extrasBean.setDate_taken(chkRecentlyUpdatedDateTak.isSelected());
                extrasBean.setDate_upload(chkRecentlyUpdatedDateUp.isSelected());
                extrasBean.setGeo(chkRecentlyUpdatedGeo.isSelected());
                extrasBean.setIcon_server(chkRecentlyUpdatedServer.isSelected());
                extrasBean.setLast_update(chkRecentlyUpdatedLastUp.isSelected());
                extrasBean.setMachine_tags(chkRecentlyUpdatedMachine.isSelected());
                extrasBean.setOriginal_format(chkRecentlyUpdatedOriginal.isSelected());
                extrasBean.setOwner_name(chkRecentlyUpdatedOwner.isSelected());
                extrasBean.setTags(chkRecentlyUpdatedTags.isSelected());
                recentlyUpdatedOutput.setText(client.flickrPhotosRecentlyUpdated(
                        txtRecentlyUpdatedMinDate.getText(), extrasBean, txtRecentlyUpdatedPage.getText(),
                        cmbRecentlyUpdatedPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    removeTagInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtRemoveTagTadID.getText().trim())) {
                showRequiredMessage("Tag ID");
            } else {
                removeTagOutput.setText(client.flickrPhotosRemoveTag(txtRemoveTagTadID.getText(), sharedSecret,
                        token, key, host, port));
            }
        }
    });

    searchInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            ExtrasBean extrasBean = new ExtrasBean();
            extrasBean.setLicense(chkSearchLicense.isSelected());
            extrasBean.setDate_taken(chkSearchDateTak.isSelected());
            extrasBean.setDate_upload(chkSearchDateUp.isSelected());
            extrasBean.setGeo(chkSearchGeo.isSelected());
            extrasBean.setIcon_server(chkSearchServer.isSelected());
            extrasBean.setLast_update(chkSearchLastUp.isSelected());
            extrasBean.setMachine_tags(chkSearchMachine.isSelected());
            extrasBean.setOriginal_format(chkSearchOriginal.isSelected());
            extrasBean.setOwner_name(chkSearchOwner.isSelected());
            extrasBean.setTags(chkSearchTags.isSelected());
            searchOutput.setText(client.flickrPhotosSearch(txtSearchUserID.getText(), txtSearchTags.getText(),
                    (AnyOrAll) cmbSearchTagMode.getSelectedItem(), txtSearchText.getText(),
                    txtSearchMinUpDate.getText(), txtSearchMaxUpDate.getText(), txtSearchMinTakDate.getText(),
                    txtMaxTakDate.getText(), txtSearchLicense.getText(),
                    (SortOrder) cmbSearchSort.getSelectedItem(), cmbSearchPrivacy.getSelectedItem().toString(),
                    cmbSearchAccuracy.getSelectedItem().toString(), txtSearchMachine.getText(),
                    (AnyOrAll) cmbSearchMachineMode.getSelectedItem(), txtSearchGroupID.getText(), extrasBean,
                    txtSearchPage.getText(), cmbSearchPerPage.getSelectedItem().toString(), sharedSecret, token,
                    key, host, port));
        }
    });

    setDatesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetDatesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    setDatesOutput.setText(client.flickrPhotosSetDates(txtSetDatesPhotoID.getText(),
                            txtSetDatesPosted.getText(), txtSetDatesTaken.getText(),
                            txtSetDatesGranularity.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    setMetaInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetMetaPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtSetMetaTitle.getText().trim())) {
                showRequiredMessage("Title");
            } else if ("".equals(txtSetMetaDescription.getText().trim())) {
                showRequiredMessage("Description");
            } else {
                if (checkToken(WRITE))
                    setMetaOutput.setText(
                            client.flickrPhotosSetMeta(txtSetMetaPhotoID.getText(), txtSetMetaTitle.getText(),
                                    txtSetMetaDescription.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    setPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetPermsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    setPermsOutput.setText(client.flickrPhotosSetPerms(txtSetPermsPhotoID.getText(),
                            chkSetPermsPublic.isSelected(), chkSetPermsFriends.isSelected(),
                            chkSetPermsFamily.isSelected(), cmbSetPermsComments.getSelectedItem().toString(),
                            cmbSetPermsMeta.getSelectedItem().toString(), sharedSecret, token, key, host,
                            port));
            }
        }
    });

}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void alertIndicatorRename() {
    final String oldProjectName = (String) this.jList1.getSelectedValue();
    if (oldProjectName == null) {
        JOptionPane.showMessageDialog(this,
                MessagesBundle.getString("warning_message_you_must_select_alert_indicator"),
                MessagesBundle.getString("warning_title_you_must_select_alert_indicator"),
                JOptionPane.WARNING_MESSAGE);
        return;/*from  w w w  . j  a  v  a  2  s  .  c  o  m*/
    }
    assert (this.alertIndicatorProjectManager.contains(oldProjectName));

    String newProjectName = null;

    while (true) {
        newProjectName = JOptionPane.showInputDialog(this,
                MessagesBundle.getString("info_message_enter_rename_alert_indicator_name"), oldProjectName);

        if (newProjectName == null) {
            return;
        }

        newProjectName = newProjectName.trim();

        if (newProjectName.length() == 0) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_you_need_to_specific_alert_indicator_name"),
                    MessagesBundle.getString("warning_title_you_need_to_specific_alert_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.alertIndicatorProjectManager.contains(newProjectName)) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_already_an_alert_indicator_with_same_name"),
                    MessagesBundle.getString("warning_title_already_an_alert_indicator_with_same_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.alertIndicatorProjectManager.renameProject(newProjectName, oldProjectName)) {
            final DefaultListModel defaultListModel = (DefaultListModel) this.jList1.getModel();
            defaultListModel.setElementAt(newProjectName, this.jList1.getSelectedIndex());
            // sync may not work well for rename operation, as the method
            // may false thought we are deleting oldProjectName, and added
            // newProjectName. We will then perform wrong selection on the
            // project.
            //this.syncJListWithIndicatorProjectManager(this.jList1, this.alertIndicatorProjectManager);

            // Update the project.xml as well.
            IndicatorPanel.this.saveAlertIndicatorProjectManager();

            // Update selection info as well.
            if (this.listSelectionEx != null) {
                this.listSelectionEx = ListSelectionEx.newInstance(this.listSelectionEx.list, newProjectName);
            }
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("error_message_unknown_error_during_renaming"),
                    MessagesBundle.getString("error_title_unknown_error_during_renaming"),
                    JOptionPane.ERROR_MESSAGE);
        }

        break;
    }
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private void moduleIndicatorRename() {
    final String oldProjectName = (String) this.jList2.getSelectedValue();
    if (oldProjectName == null) {
        JOptionPane.showMessageDialog(this,
                MessagesBundle.getString("warning_message_you_must_select_module_indicator"),
                MessagesBundle.getString("warning_title_you_must_select_module_indicator"),
                JOptionPane.WARNING_MESSAGE);
        return;//  w w w  .  jav  a 2 s  .c  o m
    }
    assert (this.moduleIndicatorProjectManager.contains(oldProjectName));

    String newProjectName = null;

    while (true) {
        newProjectName = JOptionPane.showInputDialog(this,
                MessagesBundle.getString("info_message_enter_rename_module_indicator_name"), oldProjectName);

        if (newProjectName == null) {
            return;
        }

        newProjectName = newProjectName.trim();

        if (newProjectName.length() == 0) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_you_need_to_specific_module_indicator_name"),
                    MessagesBundle.getString("warning_title_you_need_to_specific_module_indicator_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.moduleIndicatorProjectManager.contains(newProjectName)) {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("warning_message_already_a_module_indicator_with_same_name"),
                    MessagesBundle.getString("warning_title_already_a_module_indicator_with_same_name"),
                    JOptionPane.WARNING_MESSAGE);
            continue;
        }

        if (this.moduleIndicatorProjectManager.renameProject(newProjectName, oldProjectName)) {
            final DefaultListModel defaultListModel = (DefaultListModel) this.jList2.getModel();
            defaultListModel.setElementAt(newProjectName, this.jList2.getSelectedIndex());
            // sync may not work well for rename operation, as the method
            // may false thought we are deleting oldProjectName, and added
            // newProjectName. We will then perform wrong selection on the
            // project.
            //this.syncJListWithIndicatorProjectManager(this.jList2, this.moduleIndicatorProjectManager);
            // Update the project.xml as well.
            IndicatorPanel.this.saveModuleIndicatorProjectManager();
        } else {
            JOptionPane.showMessageDialog(this,
                    MessagesBundle.getString("error_message_unknown_error_during_renaming"),
                    MessagesBundle.getString("error_title_unknown_error_during_renaming"),
                    JOptionPane.ERROR_MESSAGE);
        }

        break;
    }
}

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

public void associateDefaultValue(XsdNode node) {
    String value;/*from  w  ww  .  j a v  a 2 s. c om*/
    if (((XsdTreeStructImpl) xsdTree).hasDefaultValue(node)) {
        value = (String) JOptionPane.showInputDialog(new JFrame(), "Enter a default value, \n",
                (String) ((XsdTreeStructImpl) xsdTree).associatedValues.get(node));
    } else {
        value = (String) JOptionPane.showInputDialog(new JFrame(), "Enter a default value, \n",
                lastValueEntered);
    }

    if (value != null) {
        if (((Annotated) (node.getUserObject())).getStructureType() != Structure.ELEMENT
                && ((Annotated) (node.getUserObject())).getStructureType() != Structure.ATTRIBUTE) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "a value can only be associated with an node of type element or attribute",
                    "associating a value", JOptionPane.ERROR_MESSAGE);
            return;
        }
        lastValueEntered = value;
        ((XsdTreeStructImpl) xsdTree).associateDefaultValue(node, value);
    }
}

From source file:pt.lsts.neptus.console.plugins.ImageLayers.java

@Override
public void mouseClicked(MouseEvent event, StateRenderer2D source) {
    if (event.getButton() == MouseEvent.BUTTON3) {
        JPopupMenu popup = new JPopupMenu();
        popup.add("Add layer from file").addActionListener(new ActionListener() {

            @Override/*from www  . ja  va  2  s.  c o m*/
            public void actionPerformed(ActionEvent e) {
                JFileChooser chooser = GuiUtils.getFileChooser(lastDir, I18n.text("Neptus image layers"),
                        "layer");
                int op = chooser.showOpenDialog(getConsole());
                if (op != JFileChooser.APPROVE_OPTION)
                    return;
                lastDir = chooser.getSelectedFile().getParent();
                Future<ImageLayer> il = addLayer(chooser.getSelectedFile());
                try {
                    il.get();
                } catch (Exception ex) {
                    GuiUtils.errorMessage(getConsole(), ex);
                }
            }
        });

        if (!layers.isEmpty()) {
            JMenu menu = new JMenu("Remove");
            JMenu menu2 = new JMenu("Opacity");
            for (final ImageLayer l : layers) {
                menu.add(l.getName()).addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        layers.remove(l);
                        layerFiles = StringUtils.join(layers, ",");
                        rebuildControls();
                    }
                });

                menu2.add(l.getName() + "(" + l.getTransparency() + ")")
                        .addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                String s = JOptionPane.showInputDialog(getConsole(),
                                        "Enter opacity (1 for opaque, 0 for invisible)", l.getTransparency());
                                if (s == null)
                                    return;
                                try {
                                    double val = Double.parseDouble(s);
                                    if (val < 0)
                                        throw new Exception("Value must be greater or equal to 0");
                                    if (val > 1)
                                        throw new Exception("Value must be less or equal to 1");
                                    l.setTransparency(val);

                                } catch (Exception ex) {
                                    GuiUtils.errorMessage(getConsole(), ex);
                                }
                            }
                        });

            }
            popup.add(menu);
            popup.add(menu2);
        }

        popup.show(source, event.getX(), event.getY());
    }
}