Example usage for javax.swing AbstractButton isSelected

List of usage examples for javax.swing AbstractButton isSelected

Introduction

In this page you can find the example usage for javax.swing AbstractButton isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

private String getCorrectRights(String type) {
    if (type.equals(CREATIVE_COMMONS)) {
        CreativeCommonsType creativeCommonsType = new CreativeCommonsType();
        Enumeration<AbstractButton> enumeration = creativeCommonsBtnGrp.getElements();
        while (enumeration.hasMoreElements()) {
            AbstractButton btn = enumeration.nextElement();
            if (btn.isSelected()) {
                creativeCommonsType.setBtnChecked(btn.getActionCommand());
            }//  w  w w  .  j  av a  2 s  . c o m
        }
        String urlType = creativeCommonsType.getUrlType();
        CreativeCommons creativeCommons = CreativeCommons
                .getCreativeCommonsByCountryName(creativeCommonsComboBox.getSelectedItem().toString());
        String url = CreativeCommons.constructUrl(creativeCommons);
        return MessageFormat.format(url, urlType);
    } else if (type.equals(EUROPEANA_RIGHTS_STATEMENTS)) {
        String europeanaRights = europeanaRightsComboBox.getSelectedItem().toString();
        if (europeanaRights.equals(this.labels.getString("edm.panel.license.europeana.free"))) {
            return "http://www.europeana.eu/rights/rr-f/";
        } else if (europeanaRights.equals(this.labels.getString("edm.panel.license.europeana.paid"))) {
            return "http://www.europeana.eu/rights/rr-p/";
        } else if (europeanaRights.equals(this.labels.getString("edm.panel.license.europeana.orphan"))) {
            return "http://www.europeana.eu/rights/orphan-work-eu/";
        } else {
            return "http://www.europeana.eu/rights/unknown/";
        }
    } else if (type.equalsIgnoreCase(EdmOptionsPanel.OUT_OF_COPYRIGHT)) {
        return "http://www.europeana.eu/rights/out-of-copyright-non-commercial/";
    } else if (type.equals(CREATIVE_COMMONS_CC0)) {
        return "http://creativecommons.org/publicdomain/zero/1.0/";
    } else {
        return "http://creativecommons.org/publicdomain/mark/1.0/";
    }
}

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

private EdmConfig fillEdmConfig() {
    EdmConfig config = new EdmConfig();

    Enumeration<AbstractButton> enumeration = cLevelIdSourceButtonGroup.getElements();
    boolean found = false;
    while (!found && enumeration.hasMoreElements()) {
        AbstractButton btn = enumeration.nextElement();
        if (btn.isSelected()) {
            if (EdmOptionsPanel.UNITID.equals(btn.getActionCommand())) {
                config.setIdSource(EdmOptionsPanel.UNITID);
            } else if (EdmOptionsPanel.CID.equals(btn.getActionCommand())) {
                config.setIdSource(EdmOptionsPanel.CID);
            }/*from  ww  w . ja  v  a 2  s.  c  o m*/
            found = true;
        }
    }

    enumeration = landingPageButtonGroup.getElements();
    found = false;
    while (!found && enumeration.hasMoreElements()) {
        AbstractButton btn = enumeration.nextElement();
        if (btn.isSelected()) {
            if (EdmOptionsPanel.APE.equals(btn.getActionCommand())) {
                config.setLandingPage(EdmOptionsPanel.APE);
            } else if (EdmOptionsPanel.OTHER.equals(btn.getActionCommand())) {
                config.setLandingPage(landingPageTextArea.getText());
            }
            found = true;
        }
    }

    config.setUseExistingRepository(false);
    if (useExistingRepoCheckbox.isSelected()) {
        config.setUseExistingRepository(true);
    }

    config.setDataProvider(dataProviderTextArea.getText());
    config.setProvider("Archives Portal Europe");

    enumeration = typeGroup.getElements();
    found = false;
    while (!found && enumeration.hasMoreElements()) {
        AbstractButton btn = enumeration.nextElement();
        if (btn.isSelected()) {
            if (EdmOptionsPanel.TEXT.equals(btn.getActionCommand())) {
                config.setType(EdmOptionsPanel.TEXT);
            } else if (EdmOptionsPanel.IMAGE.equals(btn.getActionCommand())) {
                config.setType(EdmOptionsPanel.IMAGE);
            } else if (EdmOptionsPanel.VIDEO.equals(btn.getActionCommand())) {
                config.setType(EdmOptionsPanel.VIDEO);
            } else if (EdmOptionsPanel.SOUND.equals(btn.getActionCommand())) {
                config.setType(EdmOptionsPanel.SOUND);
            } else {
                config.setType(EdmOptionsPanel.THREE_D);
            }
            found = true;
        }
    }

    config.setUseExistingDaoRole(false);
    if (useExistingDaoRoleCheckbox.isSelected()) {
        config.setUseExistingDaoRole(true);
    }

    config.setInheritElementsFromFileLevel(false);
    enumeration = inheritParentGroup.getElements();
    while (enumeration.hasMoreElements()) {
        AbstractButton btn = enumeration.nextElement();
        if (FULL.equals(conversionMode) && inheritParentCheckbox.isSelected() && btn.isSelected()
                && btn.getActionCommand().equals(YES)) {
            config.setInheritElementsFromFileLevel(true);
        }
    }

    config.setInheritOrigination(false);
    enumeration = inheritOriginationGroup.getElements();
    while (enumeration.hasMoreElements()) {
        AbstractButton btn = enumeration.nextElement();
        if (FULL.equals(conversionMode) && inheritOriginationCheckbox.isSelected() && btn.isSelected()
                && btn.getActionCommand().equals(YES)) {
            config.setInheritOrigination(true);
        }
    }

    config.setInheritLanguage(true);
    if (this.batch) {
        if (!useExistingLanguageCheckbox.isSelected()) {
            config.setInheritLanguage(false);
        }
        StringBuilder result = new StringBuilder();
        Object[] languageValues = languageList.getSelectedValues();
        for (int i = 0; i < languageValues.length; i++) {
            result.append(languages.get(languageValues[i].toString()));
            if (languageValues.length > 0 && i < (languageValues.length - 1)) {
                result.append(" ");
            }
        }
        config.setLanguage(result.toString());
    } else {
        enumeration = inheritLanguageGroup.getElements();
        while (enumeration.hasMoreElements()) {
            AbstractButton btn = enumeration.nextElement();
            if (/*inheritLanguageCheckbox.isSelected() &&*/btn.isSelected()) {
                if (btn.getActionCommand().equals(NO)) {
                    config.setInheritLanguage(false);
                } else if (btn.getActionCommand().equals(PROVIDE)) {
                    if (!useExistingLanguageCheckbox.isSelected()) {
                        config.setInheritLanguage(false);
                    }
                    StringBuilder result = new StringBuilder();
                    Object[] languageValues = languageList.getSelectedValues();
                    for (int i = 0; i < languageValues.length; i++) {
                        result.append(languages.get(languageValues[i].toString()));
                        if (languageValues.length > 0 && i < (languageValues.length - 1)) {
                            result.append(" ");
                        }
                    }
                    config.setLanguage(result.toString());
                }
            }
        }
    }
    if (useExistingLanguageCheckbox.isSelected()) {
        config.setUseExistingLanguage(true);
    }

    //        config.setInheritRightsInfo(false);
    //        if (this.batch) {
    config.setInheritRightsInfo(true);
    Enumeration<AbstractButton> licenseEnumeration = licenseGroup.getElements();
    while (licenseEnumeration.hasMoreElements()) {
        AbstractButton btn = licenseEnumeration.nextElement();
        if (btn.isSelected()) {
            config.setRights(getCorrectRights(btn.getActionCommand()));
        }
    }
    //        } else {
    //            enumeration = inheritLicenseGroup.getElements();
    //            while (enumeration.hasMoreElements()) {
    //                AbstractButton btn = enumeration.nextElement();
    //                if (/*inheritLanguageCheckbox.isSelected() &&*/btn.isSelected()) {
    //                    if (btn.getActionCommand().equals(YES)) {
    //                        config.setInheritRightsInfo(true);
    //                    } else {
    //                        Enumeration<AbstractButton> licenseEnumeration = licenseGroup.getElements();
    //                        while (licenseEnumeration.hasMoreElements()) {
    //                            AbstractButton licenseBtn = licenseEnumeration.nextElement();
    //                            if (licenseBtn.isSelected()) {
    //                                config.setRights(getCorrectRights(licenseBtn.getActionCommand()));
    //                            }
    //                        }
    //                    }
    //                }
    //            }
    //        }
    if (useExistingRightsInfoCheckbox.isSelected()) {
        config.setUseExistingRightsInfo(true);
    } else {
        config.setUseExistingRightsInfo(false);
    }

    if (additionalRightsTextArea != null && StringUtils.isNotEmpty(additionalRightsTextArea.getText())) {
        config.setRightsAdditionalInformation(additionalRightsTextArea.getText());
    }

    if (MINIMAL.equals(conversionMode)) {
        config.setMinimalConversion(true);
    } else {
        config.setMinimalConversion(false);
    }

    if (ARCHDESC_UNITTITLE.equals(sourceOfFondsTitle)) {
        config.setUseArchUnittitle(true);
    } else {
        config.setUseArchUnittitle(false);
    }

    //EDM identifier used for OAI-PMH; not needed for DPT purposes, so set to empty string
    config.setEdmIdentifier("");

    //prefixUrl, repositoryCode and xmlTypeName used for EDM element id generation;
    //repositoryCode is taken from the tool while the other two have fixed values.
    config.setHost("www.archivesportaleurope.net");
    config.setRepositoryCode(dataPreparationToolGUI.getRepositoryCodeIdentifier());
    config.setXmlTypeName("fa");

    return config;
}

From source file:net.jradius.client.gui.JRadiusSimulator.java

/**
 * This method initializes sendButton//from w  ww  . j  a v a 2 s .c om
 * 
 * @return javax.swing.JButton
 */
private JToggleButton getRunButton() {
    if (runButton == null) {
        runButton = new JToggleButton();
        runButton.setText("Start");

        runButton.addActionListener(new java.awt.event.ActionListener() {
            public synchronized void actionPerformed(java.awt.event.ActionEvent e) {
                AbstractButton ab = (AbstractButton) e.getSource();
                if (ab.isSelected()) {
                    shutdown();

                    simulationMonitor = new Thread(new SimulationMonitor());
                    simulationThreads = new Thread[(Integer) requestersTextField.getValue()];
                    simulationRunners = new SimulationRunner[(Integer) requestersTextField.getValue()];

                    for (int i = 0; i < simulationThreads.length; i++) {
                        simulationThreads[i] = new Thread(simulationRunners[i] = new SimulationRunner());
                        simulationThreads[i].start();
                    }

                    simulationMonitor.start();

                    runButton.setText("Stop");
                } else {
                    shutdown();
                    setStatus("Ready");
                    runButton.setText("Start");
                }
            }
        });

        runButton.setEnabled(false);
    }
    return runButton;
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Sets the properties and adds the listeners for the Message Table. No data is loaded at this
 * point.//  w w w.  j  av  a 2 s. co m
 */
private void makeMessageTable() {
    messageTreeTable.setDragEnabled(true);
    messageTreeTable.setSortable(false);
    messageTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    messageTreeTable.setColumnFactory(new MessageBrowserTableColumnFactory());
    messageTreeTable.setLeafIcon(null);
    messageTreeTable.setOpenIcon(null);
    messageTreeTable.setClosedIcon(null);
    messageTreeTable.setAutoCreateColumnsFromModel(false);
    messageTreeTable.setMirthColumnControlEnabled(true);
    messageTreeTable.setShowGrid(true, true);
    messageTreeTable.setHorizontalScrollEnabled(true);
    messageTreeTable.setPreferredScrollableViewportSize(messageTreeTable.getPreferredSize());
    messageTreeTable.setMirthTransferHandlerEnabled(true);

    tableModel = new MessageBrowserTableModel(columnMap.size());
    // Add a blank column to the column initially, otherwise it return an exception on load
    // Columns will be re-generated when the message browser is viewed
    tableModel.setColumnIdentifiers(Arrays.asList(new String[] { "" }));
    messageTreeTable.setTreeTableModel(tableModel);

    // Sets the alternating highlighter for the table
    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        messageTreeTable.setHighlighters(highlighter);
    }

    // Add the listener for when the table selection changes
    messageTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            MessageListSelected(evt);
        }

    });

    // Add the mouse listener
    messageTreeTable.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent evt) {
            checkMessageSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            checkMessageSelectionAndPopupMenu(evt);
        }

        // Opens the send message dialog when a message is double clicked.
        // If the root message or source connector is selected, select all destination connectors initially
        // If a destination connector is selected, select only that destination connector initially
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (evt.getClickCount() >= 2) {
                int row = getSelectedMessageIndex();
                if (row >= 0) {
                    MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable
                            .getPathForRow(row).getLastPathComponent();
                    if (messageNode.isNodeActive()) {
                        Long messageId = messageNode.getMessageId();
                        Integer metaDataId = messageNode.getMetaDataId();

                        Message currentMessage = messageCache.get(messageId);
                        ConnectorMessage connectorMessage = currentMessage.getConnectorMessages()
                                .get(metaDataId);
                        List<Integer> selectedMetaDataIds = new ArrayList<Integer>();

                        Map<String, Object> sourceMap = new HashMap<String, Object>();
                        if (connectorMessage.getSourceMap() != null) {
                            sourceMap.putAll(connectorMessage.getSourceMap());
                            // Remove the destination set if it exists, because that will be determined by the selected metadata IDs
                            sourceMap.remove("destinationSet");
                        }

                        if (metaDataId == 0) {
                            selectedMetaDataIds = null;
                        } else {
                            selectedMetaDataIds.add(metaDataId);
                        }

                        if (connectorMessage.getRaw() != null) {
                            parent.editMessageDialog.setPropertiesAndShow(
                                    connectorMessage.getRaw().getContent(),
                                    connectorMessage.getRaw().getDataType(), channelId,
                                    parent.dashboardPanel.getDestinationConnectorNames(channelId),
                                    selectedMetaDataIds, sourceMap);
                        }
                    }
                }
            }
        }
    });

    // Key Listener trigger for DEL
    messageTreeTable.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            int row = getSelectedMessageIndex();
            if (row >= 0) {
                if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                    MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable
                            .getPathForRow(row).getLastPathComponent();

                    if (messageNode.isNodeActive()) {
                        parent.doRemoveMessage();
                    }

                } else if (descriptionTabbedPane.getTitleAt(descriptionTabbedPane.getSelectedIndex())
                        .equals("Messages")) {
                    if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                        List<AbstractButton> buttons = Collections.list(messagesGroup.getElements());
                        boolean passedSelected = false;
                        for (int i = buttons.size() - 1; i >= 0; i--) {
                            AbstractButton button = buttons.get(i);
                            if (passedSelected && button.isShowing()) {
                                lastUserSelectedMessageType = buttons.get(i).getText();
                                updateMessageRadioGroup();
                                break;
                            } else if (button.isSelected()) {
                                passedSelected = true;
                            }
                        }
                    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                        List<AbstractButton> buttons = Collections.list(messagesGroup.getElements());
                        boolean passedSelected = false;
                        for (int i = 0; i < buttons.size(); i++) {
                            AbstractButton button = buttons.get(i);
                            if (passedSelected && button.isShowing()) {
                                lastUserSelectedMessageType = buttons.get(i).getText();
                                updateMessageRadioGroup();
                                break;
                            } else if (button.isSelected()) {
                                passedSelected = true;
                            }
                        }
                    }
                }
            }

        }
    });
}