Example usage for javax.swing JLabel getName

List of usage examples for javax.swing JLabel getName

Introduction

In this page you can find the example usage for javax.swing JLabel getName.

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:labr_client.xml.ObjToXML.java

public static void saveProfile(Component[] comps, String profile) {

    try {// w  w  w.j a  v a  2  s  .  co m
        if (comps != null) {
            JAXBContext context = JAXBContext.newInstance(LabrRequest.class);
            Marshaller m = context.createMarshaller();
            //for pretty-print XML in JAXB
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            LabrRequest request = new LabrRequest();
            for (Component comp : comps) {

                if (comp.getName() != null) {

                    if (comp.getName().equals("name")) {
                        request.patient.name.setValue(((JTextField) comp).getText());
                        request.patient.name.setX(comp.getX());
                        request.patient.name.setY(comp.getY());
                        request.patient.name.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("firstName")) {
                        request.patient.firstName.setValue(((JTextField) comp).getText());
                        request.patient.firstName.setX(comp.getX());
                        request.patient.firstName.setY(comp.getY());
                        request.patient.firstName.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("birthDate")) {
                        request.patient.birthDate.setValue(((JFormattedTextField) comp).getText());
                        request.patient.birthDate.setX(comp.getX());
                        request.patient.birthDate.setY(comp.getY());
                        request.patient.birthDate.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("gender")) {
                        request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.gender.setX(comp.getX());
                        request.patient.gender.setY(comp.getY());
                    } else if (comp.getName().equals("straatAndNumber")) {
                        request.patient.straatAndNumber.setValue(((JTextField) comp).getText());
                        request.patient.straatAndNumber.setX(comp.getX());
                        request.patient.straatAndNumber.setY(comp.getY());
                        request.patient.straatAndNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("zip")) {
                        request.patient.zip.setValue(((JTextField) comp).getText());
                        request.patient.zip.setX(comp.getX());
                        request.patient.zip.setY(comp.getY());
                        request.patient.zip.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("city")) {
                        request.patient.city.setValue(((JTextField) comp).getText());
                        request.patient.city.setX(comp.getX());
                        request.patient.city.setY(comp.getY());
                        request.patient.city.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("country")) {
                        request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.country.setX(comp.getX());
                        request.patient.country.setY(comp.getY());
                    } else if (comp.getName().equals("nationalNumber")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("Save")) {
                        JButton jbut = (JButton) comp;
                        ImageIcon icon = (ImageIcon) jbut.getIcon();
                        request.buttons.save.setX(comp.getX());
                        request.buttons.save.setY(comp.getY());
                        request.buttons.save.setValue("Save");
                        if (icon != null) {
                            request.buttons.save.setIcon(icon.getDescription());
                        }
                    } else if (comp.getName().equals("Search")) {
                    } else if (comp.getName().equals("saveAndSend")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("print")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else {
                        Class<? extends Component> c = comp.getClass();
                        if (c.getSimpleName().equals("JLabel")) {
                            JLabel lbl = (JLabel) comp;
                            LabrXMLLabel l = new LabrXMLLabel();
                            l.setColor(String.valueOf(lbl.getForeground().getRGB()));
                            l.setSize(lbl.getFont().getSize());
                            l.setId(lbl.getName());
                            l.setValue(lbl.getText());
                            l.setX(lbl.getX());
                            l.setY(lbl.getY());
                            request.labels.getLabel().add(l);
                        }
                        ;
                        if (c.getSimpleName().equals("JCheckBox")) {
                            JCheckBox chbx = (JCheckBox) comp;
                            LabrXMLRequest req = new LabrXMLRequest();
                            req.setX(chbx.getX());
                            req.setY(chbx.getY());
                            req.setLoinc(chbx.getName());
                            req.setValue(chbx.getText());
                            req.setSelected(chbx.isSelected());
                            request.requests.getRequest().add(req);
                        }
                        ;
                        if (c.getSimpleName().equals("JTextBox")) {

                        }
                        ;
                    }
                }

            }
            m.marshal(request, new File(PublicVars.getUserData()[9] + "\\" + profile + ".xml"));
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:labr_client.xml.ObjToXML.java

public static LabrRequest saveLabrRequest(Component[] comps) {

    try {/*  ww  w  .ja v a 2s .  com*/
        if (comps != null) {
            JAXBContext context = JAXBContext.newInstance(LabrRequest.class);
            Marshaller m = context.createMarshaller();
            //for pretty-print XML in JAXB
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            LabrRequest request = new LabrRequest();
            for (Component comp : comps) {

                if (comp.getName() != null) {

                    if (comp.getName().equals("name")) {
                        request.patient.name.setValue(((JTextField) comp).getText());
                        request.patient.name.setX(comp.getX());
                        request.patient.name.setY(comp.getY());
                        request.patient.name.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("firstName")) {
                        request.patient.firstName.setValue(((JTextField) comp).getText());
                        request.patient.firstName.setX(comp.getX());
                        request.patient.firstName.setY(comp.getY());
                        request.patient.firstName.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("birthDate")) {
                        request.patient.birthDate.setValue(((JFormattedTextField) comp).getText());
                        request.patient.birthDate.setX(comp.getX());
                        request.patient.birthDate.setY(comp.getY());
                        request.patient.birthDate.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("gender")) {
                        request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.gender.setX(comp.getX());
                        request.patient.gender.setY(comp.getY());
                    } else if (comp.getName().equals("straatAndNumber")) {
                        request.patient.straatAndNumber.setValue(((JTextField) comp).getText());
                        request.patient.straatAndNumber.setX(comp.getX());
                        request.patient.straatAndNumber.setY(comp.getY());
                        request.patient.straatAndNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("zip")) {
                        request.patient.zip.setValue(((JTextField) comp).getText());
                        request.patient.zip.setX(comp.getX());
                        request.patient.zip.setY(comp.getY());
                        request.patient.zip.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("city")) {
                        request.patient.city.setValue(((JTextField) comp).getText());
                        request.patient.city.setX(comp.getX());
                        request.patient.city.setY(comp.getY());
                        request.patient.city.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("country")) {
                        request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem()));
                        request.patient.country.setX(comp.getX());
                        request.patient.country.setY(comp.getY());
                    } else if (comp.getName().equals("nationalNumber")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("Save")) {
                        JButton jbut = (JButton) comp;
                        ImageIcon icon = (ImageIcon) jbut.getIcon();
                        request.buttons.save.setX(comp.getX());
                        request.buttons.save.setY(comp.getY());
                        request.buttons.save.setValue("Save");
                        if (icon != null) {
                            request.buttons.save.setIcon(icon.getDescription());
                        }
                    } else if (comp.getName().equals("Search")) {
                    } else if (comp.getName().equals("saveAndSend")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else if (comp.getName().equals("print")) {
                        request.patient.nationalNumber.setValue(((JTextField) comp).getText());
                        request.patient.nationalNumber.setX(comp.getX());
                        request.patient.nationalNumber.setY(comp.getY());
                        request.patient.nationalNumber.setWidth(comp.getWidth());
                    } else {
                        Class<? extends Component> c = comp.getClass();
                        if (c.getSimpleName().equals("JLabel")) {
                            JLabel lbl = (JLabel) comp;
                            LabrXMLLabel l = new LabrXMLLabel();
                            l.setColor(String.valueOf(lbl.getForeground().getRGB()));
                            l.setSize(lbl.getFont().getSize());
                            l.setId(lbl.getName());
                            l.setValue(lbl.getText());
                            l.setX(lbl.getX());
                            l.setY(lbl.getY());
                            request.labels.getLabel().add(l);
                        }
                        ;
                        if (c.getSimpleName().equals("JCheckBox")) {
                            JCheckBox chbx = (JCheckBox) comp;
                            LabrXMLRequest req = new LabrXMLRequest();
                            req.setX(chbx.getX());
                            req.setY(chbx.getY());
                            req.setLoinc(chbx.getName());
                            req.setValue(chbx.getText());
                            req.setSelected(chbx.isSelected());
                            request.requests.getRequest().add(req);
                        }
                        ;
                        if (c.getSimpleName().equals("JTextBox")) {

                        }
                        ;
                    }
                }
            }
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmm");
            String date = dateFormat.format(Calendar.getInstance().getTime());
            request.attributes.setTitle("LABR-" + PublicVars.getUserData()[5] + "-" + date);
            return request;
        }
        return null;
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setSize(400, 300);//from   w  ww  .j a  va2s  .c om
    jPopupMenu1.add(jMenuItem1);
    jTabbedPane1.addTab(null, jLabel1);
    jTabbedPane1.addTab(null, jLabel2);
    getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
    int tabCount = jTabbedPane1.getTabCount();
    for (int i = 0; i < tabCount; i++) {
        JLabel jLabel = new JLabel("Testing the tab" + (i + 1));
        jTabbedPane1.setTabComponentAt(i, jLabel);
        jLabel.setName(String.valueOf(i));
        jLabel.setComponentPopupMenu(jPopupMenu1);
    }
    jPopupMenu1.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuCanceled(final PopupMenuEvent evt) {
        }

        @Override
        public void popupMenuWillBecomeInvisible(final PopupMenuEvent evt) {
        }

        @Override
        public void popupMenuWillBecomeVisible(final PopupMenuEvent evt) {
            JPopupMenu source = (JPopupMenu) evt.getSource();
            JLabel invoker = (JLabel) source.getInvoker();
            JLabel component = (JLabel) jTabbedPane1.getComponentAt(Integer.parseInt(invoker.getName()));
            jMenuItem1.setText(invoker.getText() + ":  " + component.getText());
        }
    });
}

From source file:com.ssn.event.controller.SSNShareController.java

@Override
public void mouseEntered(MouseEvent e) {
    Object mouseEventObj = e.getSource();
    if (mouseEventObj != null && mouseEventObj instanceof JLabel) {
        JLabel jLbl = (JLabel) mouseEventObj;
        if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-hover.png")));
        } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-hover.png")));
        } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-hover.png")));
        } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-hover.png")));
        }/*ww  w  .j  a  v  a2 s.c  om*/
    }
}

From source file:com.ssn.event.controller.SSNShareController.java

@Override
public void mouseExited(MouseEvent e) {
    Object mouseEventObj = e.getSource();
    if (mouseEventObj != null && mouseEventObj instanceof JLabel) {
        JLabel jLbl = (JLabel) mouseEventObj;
        if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-normal.png")));
        } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-normal.png")));
        } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-normal.png")));
        } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) {
            jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-normal.png")));
        }//  w ww.  jav  a2  s. c om
    }
}

From source file:client.InterfaceJeu.java

public String listerCartesJouees() {
    // modifier (ou pas) pour envoyer en JSON
    Iterator it = cartesSelectionnees.iterator();
    String liste = "[";
    boolean flag = true;
    while (it.hasNext()) {
        if (flag) {
            flag = false;//from   w  w  w  . j  a va2 s.  com
        } else {
            liste = liste + ",";
        }
        JLabel obj = (JLabel) it.next();
        liste = liste + "{\"couleur\":\"" + obj.getName().split("-")[1] + "\",\"hauteur\":\""
                + obj.getName().split("-")[0] + "\"}";
    }
    liste = liste + "]";
    cartesSelectionnees.clear();
    return liste;
}

From source file:client.InterfaceJeu.java

public void verifierCartes() {
    //on compare avec les cartes jouables
    //on crer un JSON Array depuis les cartes selectionnes
    Iterator it = cartesSelectionnees.iterator();
    JSONArray arr = new JSONArray();
    while (it.hasNext()) {
        JLabel o = (JLabel) it.next();
        JSONObject obj = new JSONObject();
        obj.put("couleur", o.getName().split("-")[1]);
        obj.put("hauteur", o.getName().split("-")[0]);
        arr.add(obj);//  w  ww. j  a v a2  s .  c  o m
    }

    System.out.println(arr);
    //si ok on enabled le bouton jouer
    if (!interSession) {
        if (!arr.isEmpty() && cartesJouables.contains(arr)) {
            jButton1.setEnabled(true);
        } else {
            jButton1.setEnabled(false);
        }
    } else {
        if (role.equals("president")) {
            if (arr.size() == 2) {
                jButton1.setEnabled(true);
            } else {
                jButton1.setEnabled(false);
            }
        } else if (role.equals("vicepresident")) {
            if (arr.size() == 1) {
                jButton1.setEnabled(true);
            } else {
                jButton1.setEnabled(false);
            }
        }
    }
}

From source file:gdt.jgui.tool.JIconSelector.java

/**
 * Create the context.// w w  w .j ava 2  s  .  c o m
 * @param console the main console.
 * @param locator$ the locator string.
 * @return the procedure context.
 */
@Override
public JContext instantiate(JMainConsole console, String locator$) {
    this.console = console;
    try {
        panel.removeAll();
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL);
        requesterResponseLocator$ = locator.getProperty(JRequester.REQUESTER_RESPONSE_LOCATOR);
        //          System.out.println("IconSelector:instantiate:locator="+locator$);
        Entigrator entigrator = console.getEntigrator(entihome$);
        String icons$ = entigrator.ent_getHome(Entigrator.ICONS);
        File icons = new File(icons$);
        File[] fa = icons.listFiles();
        if (fa == null)
            return this;
        ImageIcon icon;
        JLabel label;
        Image img;
        for (File aFa : fa) {
            icon = new ImageIcon(aFa.getPath());
            img = icon.getImage();
            img = img.getScaledInstance(smallIcon, smallIcon, java.awt.Image.SCALE_SMOOTH);
            icon = new ImageIcon(img);
            label = new JLabel();
            label.setIcon(icon);
            label.setName(aFa.getName());
            label.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent me) {
                    try {
                        JLabel label = (JLabel) me.getSource();
                        icon$ = label.getName();
                        byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                        String responseLocator$ = new String(ba, "UTF-8");
                        responseLocator$ = Locator.append(responseLocator$, ICON, icon$);
                        JConsoleHandler.execute(JIconSelector.this.console, responseLocator$);
                    } catch (Exception ee) {
                        LOGGER.severe(ee.toString());
                    }
                }
            });

            panel.add(label);
        }

    } catch (Exception e) {
        LOGGER.severe(e.toString());
    }
    return this;
}

From source file:com.ssn.event.controller.SSNShareController.java

@Override
public void mouseClicked(MouseEvent e) {
    Object mouseEventObj = e.getSource();
    if (mouseEventObj != null && mouseEventObj instanceof JLabel) {
        JLabel label = (JLabel) mouseEventObj;
        getShareForm().setCursor(new Cursor(Cursor.WAIT_CURSOR));
        // Tracking this sharing event in Google Analytics
        GoogleAnalyticsUtil.track(SSNConstants.SSN_APP_EVENT_SHARING);
        Thread thread = null;/*  w  ww  .ja  v a  2  s.  co m*/
        switch (label.getName()) {
        case "FacebookSharing":
            thread = new Thread() {
                boolean isAlreadyLoggedIn = false;

                @Override
                public void run() {

                    Set<String> sharedFileList = getFiles();
                    AccessGrant facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                    if (facebookAccessGrant == null) {
                        try {
                            LoginWithFacebook loginWithFacebook = new LoginWithFacebook(null);
                            loginWithFacebook.setHomeForm(getHomeModel().getHomeForm());
                            loginWithFacebook.login();

                            boolean processFurther = false;
                            while (!processFurther) {
                                facebookAccessGrant = getHomeModel().getHomeForm().getFacebookAccessGrant();
                                if (facebookAccessGrant == null) {
                                    Thread.sleep(10000);
                                } else {
                                    processFurther = true;
                                    isAlreadyLoggedIn = true;
                                }
                            }
                        } catch (InterruptedException ex) {
                            logger.error(ex);
                        }
                    }

                    FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(
                            SSNConstants.SSN_FACEBOOK_API_KEY, SSNConstants.SSN_FACEBOOK_SECRET_KEY);
                    Connection<Facebook> connection = connectionFactory.createConnection(facebookAccessGrant);
                    Facebook facebook = connection.getApi();
                    MediaOperations mediaOperations = facebook.mediaOperations();

                    if (!isAlreadyLoggedIn) {
                        // SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                        SSNConfirmationDialogBox confirmeDialog = new SSNConfirmationDialogBox();
                        FacebookProfile userProfile = facebook.userOperations().getUserProfile();
                        String userName = "";
                        if (userProfile != null) {
                            userName = userProfile.getName() != null ? userProfile.getName()
                                    : userProfile.getFirstName();
                        }
                        confirmeDialog.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(),
                                "Confirmation", "",
                                "You are already logged in with " + userName + ", Click OK to continue.");
                        int result = confirmeDialog.getResult();
                        if (result == JOptionPane.YES_OPTION) {
                            SwingUtilities.invokeLater(new Runnable() {
                                public void run() {
                                    SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                                    messageDialogBox.initDialogBoxUI(
                                            SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Message", "",
                                            "Successfully uploaded.");
                                    messageDialogBox.setFocusable(true);

                                }
                            });
                        } else if (result == JOptionPane.NO_OPTION) {

                            AccessGrant facebookAccessGrant1 = null;
                            if (facebookAccessGrant1 == null) {
                                try {
                                    LoginWithFacebook loginWithFacebook = new LoginWithFacebook(null);
                                    loginWithFacebook.setHomeForm(getHomeModel().getHomeForm());
                                    loginWithFacebook.login();

                                    boolean processFurther = false;
                                    while (!processFurther) {
                                        facebookAccessGrant1 = getHomeModel().getHomeForm()
                                                .getFacebookAccessGrant();
                                        if (facebookAccessGrant1 == null) {
                                            Thread.sleep(10000);
                                        } else {
                                            processFurther = true;
                                            //isAlreadyLoggedIn = true;
                                        }
                                    }
                                    connectionFactory = new FacebookConnectionFactory(
                                            SSNConstants.SSN_FACEBOOK_API_KEY,
                                            SSNConstants.SSN_FACEBOOK_SECRET_KEY);
                                    connection = connectionFactory.createConnection(facebookAccessGrant);
                                    facebook = connection.getApi();
                                    mediaOperations = facebook.mediaOperations();
                                } catch (InterruptedException ex) {
                                    logger.error(ex);
                                }
                            }
                        }
                    }

                    String[] videoSupported = SSNConstants.SSN_VIDEO_FORMAT_SUPPORTED;
                    final List<String> videoSupportedList = Arrays.asList(videoSupported);

                    for (String file : sharedFileList) {
                        String fileExtension = file.substring(file.lastIndexOf(".") + 1, file.length());
                        Resource resource = new FileSystemResource(file);

                        if (!videoSupportedList.contains(fileExtension.toUpperCase())) {
                            String output = mediaOperations.postPhoto(resource);
                        } else {
                            String output = mediaOperations.postVideo(resource);
                        }

                    }

                    getShareForm().dispose();
                }
            };
            thread.start();
            break;
        case "TwitterSharing":
            LoginWithTwitter.deniedPermission = false;
            thread = new Thread() {
                boolean isAlreadyLoggedIn = false;

                @Override
                public void run() {
                    Set<String> sharedFileList = getFiles();
                    OAuthToken twitterOAuthToken = getHomeModel().getHomeForm().getTwitterOAuthToken();
                    if (twitterOAuthToken == null) {
                        try {
                            LoginWithTwitter loginWithTwitter = new LoginWithTwitter(null);
                            loginWithTwitter.setHomeForm(getHomeModel().getHomeForm());
                            loginWithTwitter.login();

                            boolean processFurther = false;
                            while (!processFurther) {
                                if (LoginWithTwitter.deniedPermission)
                                    break;

                                twitterOAuthToken = getHomeModel().getHomeForm().getTwitterOAuthToken();
                                if (twitterOAuthToken == null) {
                                    Thread.sleep(10000);
                                } else {
                                    processFurther = true;
                                    isAlreadyLoggedIn = true;
                                }
                            }
                        } catch (IOException | InterruptedException ex) {
                            logger.error(ex);
                        }
                    }
                    if (!LoginWithTwitter.deniedPermission) {
                        Twitter twitter = new TwitterTemplate(SSNConstants.SSN_TWITTER_API_KEY,
                                SSNConstants.SSN_TWITTER_SECRET_KEY, twitterOAuthToken.getValue(),
                                twitterOAuthToken.getSecret());
                        TimelineOperations timelineOperations = twitter.timelineOperations();
                        if (!isAlreadyLoggedIn) {
                            SSNConfirmationDialogBox confirmeDialog = new SSNConfirmationDialogBox();
                            TwitterProfile userProfile = twitter.userOperations().getUserProfile();

                            String userName = "";
                            if (userProfile != null) {
                                userName = twitter.userOperations().getScreenName() != null
                                        ? twitter.userOperations().getScreenName()
                                        : userProfile.getName();
                            }
                            confirmeDialog.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(),
                                    "Confirmation", "",
                                    "You are already logged in with " + userName + ", Click OK to continue.");
                            int result = confirmeDialog.getResult();
                            if (result == JOptionPane.YES_OPTION) {
                                SwingUtilities.invokeLater(new Runnable() {
                                    public void run() {
                                        SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                                        messageDialogBox.initDialogBoxUI(
                                                SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Message", "",
                                                "Successfully uploaded.");
                                        messageDialogBox.setFocusable(true);

                                    }
                                });
                            } else if (result == JOptionPane.NO_OPTION) {

                                twitterOAuthToken = null;
                                if (twitterOAuthToken == null) {
                                    try {
                                        LoginWithTwitter loginWithTwitter = new LoginWithTwitter(null);
                                        loginWithTwitter.setHomeForm(getHomeModel().getHomeForm());
                                        loginWithTwitter.login();

                                        boolean processFurther = false;
                                        while (!processFurther) {
                                            twitterOAuthToken = getHomeModel().getHomeForm()
                                                    .getTwitterOAuthToken();
                                            if (twitterOAuthToken == null) {
                                                Thread.sleep(10000);
                                            } else {
                                                processFurther = true;

                                            }
                                        }
                                        twitter = new TwitterTemplate(SSNConstants.SSN_TWITTER_API_KEY,
                                                SSNConstants.SSN_TWITTER_SECRET_KEY,
                                                twitterOAuthToken.getValue(), twitterOAuthToken.getSecret());
                                        timelineOperations = twitter.timelineOperations();
                                    } catch (IOException | InterruptedException ex) {
                                        logger.error(ex);
                                    }
                                }
                            }
                        }

                        for (String file : sharedFileList) {
                            Resource image = new FileSystemResource(file);

                            TweetData tweetData = new TweetData("At " + new Date());
                            tweetData.withMedia(image);
                            timelineOperations.updateStatus(tweetData);
                        }
                    } else {
                        SSNMessageDialogBox messageDialogBox = new SSNMessageDialogBox();
                        messageDialogBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Alert",
                                "", "User denied for OurHive App permission on twitter.");
                        messageDialogBox.setFocusable(true);
                    }
                    getShareForm().dispose();
                }

            };
            thread.start();
            break;
        case "InstagramSharing":
            break;
        case "MailSharing":
            try {
                String OS = System.getProperty("os.name").toLowerCase();

                Set<String> sharedFileList = getFiles();
                Set<String> voiceNoteList = new HashSet<String>();
                for (String sharedFile : sharedFileList) {
                    String voiceNote = SSNDao.getVoiceCommandPath(new File(sharedFile).getAbsolutePath());
                    if (voiceNote != null && !voiceNote.isEmpty()) {
                        voiceNoteList.add(voiceNote);
                    }
                }
                sharedFileList.addAll(voiceNoteList);

                String fileFullPath = "";
                String caption = "";
                if (sharedFileList.size() == 1) {
                    fileFullPath = sharedFileList.toArray(new String[0])[0];

                    caption = SSMMediaGalleryPanel.readMetaDataForTitle(new File(fileFullPath));

                } else if (sharedFileList.size() > 1) {
                    fileFullPath = SSNHelper.createZipFileFromMultipleFiles(sharedFileList);
                }

                if (OS.contains("win")) {

                    // String subject = "SSN Subject";
                    String subject = caption.equals("") ? SSNConstants.SSN_SHARE_WITH_MAIL_SUBJECT : caption;
                    String body = "";
                    String m = "&subject=%s&body=%s";

                    String outLookExeDir = "C:\\Program Files\\Microsoft Office\\Office14\\Outlook.exe";
                    String mailCompose = "/c";
                    String note = "ipm.note";
                    String mailBodyContent = "/m";

                    m = String.format(m, subject, body);
                    String slashA = "/a";

                    String mailClientConfigParams[] = null;
                    Process startMailProcess = null;

                    mailClientConfigParams = new String[] { outLookExeDir, mailCompose, note, mailBodyContent,
                            m, slashA, fileFullPath };
                    startMailProcess = Runtime.getRuntime().exec(mailClientConfigParams);
                    OutputStream out = startMailProcess.getOutputStream();
                    File zipFile = new File(fileFullPath);
                    zipFile.deleteOnExit();
                } else if (OS.indexOf("mac") >= 0) {
                    //Process p = Runtime.getRuntime().exec(new String[]{String.format("open -a mail ", fileFullPath)});
                    Desktop desktop = Desktop.getDesktop();
                    String mailTo = caption.equals("") ? "?SUBJECT=" + SSNConstants.SSN_SHARE_WITH_MAIL_SUBJECT
                            : caption;
                    URI uriMailTo = null;
                    uriMailTo = new URI("mailto", mailTo, null);
                    desktop.mail(uriMailTo);
                }

                this.getShareForm().dispose();
            } catch (Exception ex) {
                logger.error(ex);
            }
            break;
        case "moveCopy":
            getShareForm().dispose();
            File album = new File(SSNHelper.getSsnHiveDirPath());
            File[] albumPaths = album.listFiles();
            Vector albumNames = new Vector();
            for (int i = 0; i < albumPaths.length; i++) {
                if (!(albumPaths[i].getName().equals("OurHive")) && SSNHelper.lastAlbum != null
                        && !(albumPaths[i].getName().equals(SSNHelper.lastAlbum)))
                    albumNames.add(albumPaths[i].getName());
            }
            if (SSNHelper.lastAlbum != null && !SSNHelper.lastAlbum.equals("OurHive"))
                albumNames.insertElementAt("OurHive", 0);

            SSNInputDialogBox inputBox = new SSNInputDialogBox(true, albumNames);
            inputBox.initDialogBoxUI(SSNDialogChoice.NOTIFICATION_DIALOG.getType(), "Copy Media",
                    "Please Select Album Name");
            String destAlbumName = inputBox.getTextValue();
            if (StringUtils.isNotBlank(destAlbumName)) {
                homeModel.moveAlbum(destAlbumName, getFiles());
            }

        }
        getShareForm().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:ffx.ui.ModelingPanel.java

/**
 * This handles conditional command option input.
 *
 * @param evt ActionEvent/*  w ww  . j a va  2 s  .  co m*/
 */
private void conditionalCommandEvent(ActionEvent evt) {
    Object source = evt.getSource();
    if (source instanceof JRadioButton) {
        JRadioButton jrb = (JRadioButton) source;
        String selection = jrb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            JTextField jtf = (JTextField) label.getLabelFor();
            String cupon = label.getName().toLowerCase();
            if (cupon.contains(selection) && jrb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    } else if (source instanceof JCheckBox) {
        JCheckBox jcb = (JCheckBox) source;
        String selection = jcb.getText().toLowerCase();
        for (JLabel label : conditionals) {
            String cupon = label.getName().toLowerCase();
            JTextField jtf = (JTextField) label.getLabelFor();
            if (cupon.contains(selection) && jcb.isSelected()) {
                label.setEnabled(true);
                jtf.setEnabled(true);
            } else {
                label.setEnabled(false);
                jtf.setEnabled(false);
            }
        }
    }
    statusLabel.setText("  " + createCommandInput());
}