Example usage for javax.swing JCheckBox setEnabled

List of usage examples for javax.swing JCheckBox setEnabled

Introduction

In this page you can find the example usage for javax.swing JCheckBox setEnabled.

Prototype

public void setEnabled(boolean b) 

Source Link

Document

Enables (or disables) the button.

Usage

From source file:Main.java

public static void main(String[] args) {
    JCheckBox checkBox = new JCheckBox("Enabled", true);

    checkBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (checkBox.isEnabled())
                checkBox.setEnabled(false);
            else/*from w  w  w  .ja  v a 2  s . co m*/
                checkBox.setEnabled(true);
        }
    });
    JOptionPane.showMessageDialog(null, checkBox);
}

From source file:com.emental.mindraider.ui.dialogs.ConnectUriqaServerJDialog.java

/**
 * Constructor./*from  w  w w.j a  va  2  s  .  c om*/
 */
public ConnectUriqaServerJDialog() {
    super(Messages.getString("ConnectUriqaServerJDialog.title"));
    getContentPane().setLayout(new BorderLayout());

    // north
    JPanel north = new JPanel();
    north.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.serverUrl")));

    uriqaServerUrl = new JTextField("http://sw.nokia.com/uriqa/", 31);
    uriqaServerUrl.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, uriqaServerUrl.getPreferredSize().height));
    uriqaServerUrl.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                connect();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    north.add(uriqaServerUrl);
    getContentPane().add(north, BorderLayout.NORTH);

    // center
    JPanel center = new JPanel();
    center.setLayout(new BorderLayout());

    JPanel centerTop = new JPanel();
    centerTop.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.resource")));
    String[] knowUriqaUris = new String[] { "http://sw.nokia.com/VOC-1/term", "http://sw.nokia.com/MARS-3/Rank",
            "http://sw.nokia.com/MARS-3", "http://sw.nokia.com/schemas/nokia/MARS-3.1.rdf" };
    resourceUri = new JComboBox(knowUriqaUris);
    resourceUri.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, resourceUri.getPreferredSize().height));
    resourceUri.setEditable(true);
    centerTop.add(resourceUri);

    JPanel centerCenter = new JPanel();
    centerCenter.setLayout(new FlowLayout(FlowLayout.LEFT));
    centerCenter.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.loadOverToolTip"));
    centerCenter.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.loadOver")));
    JCheckBox loadOver = new JCheckBox();
    loadOver.setSelected(true);
    loadOver.setEnabled(false);
    centerCenter.add(loadOver);

    JPanel centerBottom = new JPanel();
    centerBottom.setLayout(new FlowLayout(FlowLayout.LEFT));
    centerBottom.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.addInferedToolTip"));
    centerBottom.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.addInfered")));
    addInfered = new JCheckBox();
    addInfered.setSelected(true);
    centerBottom.add(addInfered);

    center.add(centerTop, BorderLayout.NORTH);
    center.add(centerCenter, BorderLayout.CENTER);
    center.add(centerBottom, BorderLayout.SOUTH);
    getContentPane().add(center, BorderLayout.CENTER);

    // south
    JPanel south = new JPanel();
    JButton uploadButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.connect"));
    uploadButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            connect();
        }
    });
    south.add(uploadButton);

    JButton cancelButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    south.add(cancelButton);
    getContentPane().add(south, BorderLayout.SOUTH);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:es.emergya.ui.gis.popups.SummaryDialog.java

public SummaryDialog(Recurso r) {

    super();//from ww  w.  j ava2s  .  c  om
    r = (r == null) ? null : RecursoConsultas.getByIdentificador(r.getIdentificador());
    setAlwaysOnTop(true);
    setResizable(false);
    setName(r.getIdentificador());
    setBackground(Color.WHITE);
    setSize(600, 400);
    setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    try {
        setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getIconImage());
    } catch (Throwable e) {
        LOG.error("There is no icon image", e);
    }
    JPanel base = new JPanel();
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));
    base.setBackground(Color.WHITE);

    r = RecursoConsultas.getByIdentificador(r.getIdentificador());

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));

    final JLabel labelTitle = new JLabel(i18n.getString("Resources.summary.title") + " " + r.getIdentificador(),
            LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);
    labelTitle.setFont(LogicConstants.deriveBoldFont(12f));

    title.setBackground(Color.WHITE);

    title.add(labelTitle);

    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setBackground(Color.WHITE);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    JTextField name = new JTextField(25);
    if (r != null)
        name.setText(r.getIdentificador());
    name.setEditable(false);
    mid.add(name);
    // Patrulla
    mid.add(new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT));
    // JComboBox squads = new
    // JComboBox(PatrullaConsultas.getAll().toArray());
    JTextField squads = new JTextField(r.getPatrullas() == null ? null : r.getPatrullas().getNombre());
    // squads.setSelectedItem(r.getPatrullas());
    squads.setEditable(false);
    squads.setColumns(21);
    // squads.setEnabled(false);
    mid.add(squads);

    // Tipo
    mid.add(new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT));
    JTextField types = new JTextField(r.getTipo());
    types.setEditable(false);
    mid.add(types);

    // Estado Eurocop
    mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT));
    JTextField status = new JTextField();
    if (r.getEstadoEurocop() != null)
        status.setText(r.getEstadoEurocop().getIdentificador());
    status.setEditable(false);
    mid.add(status);

    // Subflota
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    JTextField subfleets = new JTextField(r.getFlotas() == null ? null : r.getFlotas().getNombre());
    subfleets.setEditable(false);
    mid.add(subfleets);

    // Referencia Humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    JTextField rHumana = new JTextField();
    // if (r.getIncidencias() != null)
    // rHumana.setText(r.getIncidencias().getReferenciaHumana());
    rHumana.setEditable(false);
    mid.add(rHumana);
    // dispositivo
    mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT));
    JTextField issi = new JTextField();
    issi.setEditable(false);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    JCheckBox enabled = new JCheckBox("", true);
    enabled.setEnabled(false);
    enabled.setOpaque(false);
    if (r.getDispositivo() != null) {
        final String valueOf = String.valueOf(r.getDispositivo());
        try {
            issi.setText(String.format(FORMAT, r.getDispositivo()));
        } catch (Throwable t) {
            issi.setText(valueOf);
        }
        enabled.setSelected(r.getHabilitado());
    }
    mid.add(enabled);

    // Fecha ultimo gps
    mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT));
    JTextField lastGPS = new JTextField();

    final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r);
    if (lastGPSDateForRecurso != null) {
        lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso));
    }
    lastGPS.setEditable(false);
    mid.add(lastGPS);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18);
    base.add(mid);

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    JTextField info = new JTextField(25);
    info.setText(r.getInfoAdicional());
    info.setEditable(false);
    infoPanel.setOpaque(false);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);
    base.add(infoPanel);

    JPanel buttons = new JPanel();

    buttons.setBackground(Color.WHITE);
    JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept"));

    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    buttons.add(accept);
    base.add(buttons);

    getContentPane().add(base);
    pack();
    int x;
    int y;

    Container myParent;
    try {
        myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame()
                .getContentPane();
        java.awt.Point topLeft = myParent.getLocationOnScreen();
        Dimension parentSize = myParent.getSize();

        Dimension mySize = getSize();

        if (parentSize.width > mySize.width)
            x = ((parentSize.width - mySize.width) / 2) + topLeft.x;
        else
            x = topLeft.x;

        if (parentSize.height > mySize.height)
            y = ((parentSize.height - mySize.height) / 2) + topLeft.y;
        else
            y = topLeft.y;

        setLocation(x, y);
    } catch (Throwable e1) {
        LOG.error("There is no basic window!", e1);
    }
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

void adaptToBootVersion(String bootVersion) {
    for (List<JCheckBox> chList : chkBoxesMap.values()) {
        for (JCheckBox cb : chList) {
            String verRange = (String) cb.getClientProperty(PROP_VERSION_RANGE);
            String description = (String) cb.getClientProperty(PROP_DESCRIPTION);
            final boolean allowable = allowable(verRange, bootVersion);
            cb.setEnabled(allowable);
            cb.setToolTipText(prepTooltip(description, allowable, verRange));
        }// www .  j a v  a  2  s .  c om
    }
}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(//from ww w. j  a va 2 s .c  o  m
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Set the tags in the UI from the given list (null if the server couldn't be contacted or
 * didn't respond as expected)./*ww  w . java  2s. c om*/
 * 
 * <p>Should be called from event thread
 */
private void setPopularTags(List<String> tags) {
    if (tags == null) {
        // Couldn't get the tags list.
        popTags[0].setText("Unavailable");
        for (int i = 1; i < popTags.length; i++) {
            popTags[i].setText("");
        }
        return;
    }

    int minLength = popTags.length < tags.size() ? popTags.length : tags.size();
    for (int i = 0; i < minLength; i++) {
        JCheckBox checkBox = popTags[i];
        checkBox.setText(tags.get(i));
        checkBox.setEnabled(true);
        setTags(getTags());
    }

    // Clear any remaining checkboxes.
    for (int i = minLength; i < popTags.length; i++) {
        popTags[i].setText("");
    }
}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Creates the tag display with popular tags and an option to add tags
 *//*from ww  w. j  a  v  a  2 s . c  om*/
private JComponent getTagDisplay() {
    JComponent tagPanel = new JPanel(new MiksGridLayout(3, 1, 8, 8));
    {
        tagPanel.setBackground(background);
        JComponent popPanel = new JPanel(new MiksGridLayout(8, 1, 8, 0));
        popPanel.setBackground(background);
        JLabel popLabel = new JLabel(Config.getString("export.publish.tags.popular"), SwingConstants.LEADING);
        popLabel.setFont(font);
        popPanel.add(popLabel);
        for (int i = 0; i < popTags.length; i++) {
            JCheckBox popTag = new JCheckBox(Config.getString("export.publish.tags.loading"));
            popTag.setBackground(background);
            popTag.setFont(font);
            popTag.setEnabled(false);
            popTags[i] = popTag;
            popPanel.add(popTag);
        }

        tagPanel.add(popPanel);

        Box textPanel = new Box(BoxLayout.Y_AXIS);
        {
            JLabel additionalLabel = new JLabel(Config.getString("export.publish.tags.additional1"),
                    SwingConstants.LEADING);
            additionalLabel.setFont(font);
            textPanel.add(additionalLabel);

            JLabel additionalLabel2 = new JLabel(Config.getString("export.publish.tags.additional2"),
                    SwingConstants.CENTER);
            additionalLabel2.setFont(font);
            textPanel.add(additionalLabel2);
        }
        tagPanel.add(textPanel);

        tagArea = new JTextArea();
        tagArea.setRows(3);
        JScrollPane tagScroller = new JScrollPane(tagArea);
        tagPanel.add(tagScroller);
    }
    return tagPanel;
}

From source file:be.agiv.security.demo.Main.java

private void invokeClaimsAwareService() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    JPanel contentPanel = new JPanel(gridBagLayout);

    final JLabel ipStsLabel = new JLabel("IP-STS:");
    gridBagConstraints.gridx = 0;// w ww . j a  v a  2s.  c o  m
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.ipadx = 5;
    gridBagLayout.setConstraints(ipStsLabel, gridBagConstraints);
    contentPanel.add(ipStsLabel);

    final JTextField ipStsTextField = new JTextField(
            "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13",
            60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(ipStsTextField, gridBagConstraints);
    contentPanel.add(ipStsTextField);

    JLabel realmLabel = new JLabel("Realm:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(realmLabel, gridBagConstraints);
    contentPanel.add(realmLabel);

    JTextField realmTextField = new JTextField(AGIVSecurity.BETA_REALM, 30);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(realmTextField, gridBagConstraints);
    contentPanel.add(realmTextField);

    final CredentialPanel credentialPanel = new CredentialPanel();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(credentialPanel, gridBagConstraints);
    contentPanel.add(credentialPanel);

    final JLabel rStsLabel = new JLabel("R-STS:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = 1;
    gridBagLayout.setConstraints(rStsLabel, gridBagConstraints);
    contentPanel.add(rStsLabel);

    final JTextField rStsTextField = new JTextField(
            "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13",
            60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(rStsTextField, gridBagConstraints);
    contentPanel.add(rStsTextField);

    JLabel serviceRealmLabel = new JLabel("Service realm:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(serviceRealmLabel, gridBagConstraints);
    contentPanel.add(serviceRealmLabel);

    JTextField serviceRealmTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_REALM, 60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(serviceRealmTextField, gridBagConstraints);
    contentPanel.add(serviceRealmTextField);

    JLabel urlLabel = new JLabel("Service URL:");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagLayout.setConstraints(urlLabel, gridBagConstraints);
    contentPanel.add(urlLabel);

    JTextField urlTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_LOCATION, 60);
    gridBagConstraints.gridx++;
    gridBagLayout.setConstraints(urlTextField, gridBagConstraints);
    contentPanel.add(urlTextField);

    final JCheckBox noWsPolicyCheckBox = new JCheckBox("WSDL without WS-Policy");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(noWsPolicyCheckBox, gridBagConstraints);
    contentPanel.add(noWsPolicyCheckBox);

    final JCheckBox useWsSecureConversationCheckBox = new JCheckBox("Use WS-SecureConversation");
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(useWsSecureConversationCheckBox, gridBagConstraints);
    contentPanel.add(useWsSecureConversationCheckBox);

    final JCheckBox usePreviousSecurityCheckBox = new JCheckBox("Use previous AGIV Security");
    final JCheckBox cancelPreviousSecureConversationToken = new JCheckBox("Cancel previous conversation token");
    usePreviousSecurityCheckBox.setEnabled(null != this.agivSecurity);
    cancelPreviousSecureConversationToken.setEnabled(false);
    usePreviousSecurityCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            LOG.debug("use previous security: " + usePreviousSecurityCheckBox.isSelected());
            boolean newSecurity = !usePreviousSecurityCheckBox.isSelected();
            ipStsLabel.setEnabled(newSecurity);
            ipStsTextField.setEditable(newSecurity);
            credentialPanel.setEnabled(newSecurity);
            rStsLabel.setEnabled(newSecurity);
            rStsTextField.setEnabled(newSecurity);
            cancelPreviousSecureConversationToken.setEnabled(!newSecurity);
        }
    });
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(usePreviousSecurityCheckBox, gridBagConstraints);
    contentPanel.add(usePreviousSecurityCheckBox);

    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(cancelPreviousSecureConversationToken, gridBagConstraints);
    contentPanel.add(cancelPreviousSecureConversationToken);

    JPanel expiresPanel = new JPanel();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy++;
    gridBagConstraints.gridwidth = 2;
    gridBagLayout.setConstraints(expiresPanel, gridBagConstraints);
    contentPanel.add(expiresPanel);

    JLabel expiresLabelLabel = new JLabel("Secure conversation token expires:");
    expiresLabelLabel.setEnabled(null != this.agivSecurity);
    expiresPanel.add(expiresLabelLabel);

    JLabel expiresLabel = new JLabel();
    expiresLabel.setEnabled(null != this.agivSecurity);
    expiresPanel.add(expiresLabel);
    if (null != this.agivSecurity) {
        if (false == this.agivSecurity.getSecureConversationTokens().isEmpty()) {
            SecurityToken secureConversationToken = this.agivSecurity.getSecureConversationTokens().values()
                    .iterator().next();
            expiresLabel.setText(secureConversationToken.getExpires().toString());
        }
    }

    int dialogResult = JOptionPane.showConfirmDialog(this, contentPanel, "Claims Aware Service",
            JOptionPane.OK_CANCEL_OPTION);
    if (dialogResult == JOptionPane.CANCEL_OPTION) {
        return;
    }

    final String location = urlTextField.getText();
    final String serviceRealm = serviceRealmTextField.getText();
    final String ipStsLocation = ipStsTextField.getText();
    final String rStsLocation = rStsTextField.getText();
    final String username = credentialPanel.getUsername();
    final String password = credentialPanel.getPassword();
    final File pkcs12File = credentialPanel.getPKCS12File();
    final String realm = realmTextField.getText();

    ExecutorService executor = Executors.newFixedThreadPool(1);
    FutureTask<ArrayOfClaimInfo> futureTask = new FutureTask<ArrayOfClaimInfo>(
            new Callable<ArrayOfClaimInfo>() {

                public ArrayOfClaimInfo call() throws Exception {
                    Service service;
                    if (noWsPolicyCheckBox.isSelected()) {
                        service = ClaimsAwareServiceFactory.getInstanceNoWSPolicy();
                    } else {
                        service = ClaimsAwareServiceFactory.getInstance();
                    }
                    IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature());
                    BindingProvider bindingProvider = (BindingProvider) iservice;

                    if (false == usePreviousSecurityCheckBox.isSelected()) {
                        if (null != username) {
                            Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm,
                                    username, password);
                        } else {
                            Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm,
                                    pkcs12File, password);
                        }
                        Main.this.agivSecurity.addSTSListener(Main.this);
                        if (Main.this.proxyEnable) {
                            agivSecurity.setProxy(Main.this.proxyHost, Main.this.proxyPort,
                                    Main.this.proxyType);
                        }
                    }
                    if (cancelPreviousSecureConversationToken.isSelected()) {
                        Main.this.agivSecurity.cancelSecureConversationTokens();
                    }
                    Main.this.agivSecurity.enable(bindingProvider, location,
                            useWsSecureConversationCheckBox.isSelected(), serviceRealm);

                    ArrayOfClaimInfo result = iservice.getData(0);
                    return result;
                }
            }) {

        @Override
        protected void done() {
            try {
                ArrayOfClaimInfo result = get();
                List<ClaimInfo> claims = result.getClaimInfo();
                StringBuffer message = new StringBuffer();
                for (ClaimInfo claim : claims) {
                    message.append(claim.getName());
                    message.append(" = ");
                    message.append(claim.getValue());
                    message.append("\n");
                }

                JOptionPane.showMessageDialog(Main.this, message.toString(), "Claims Aware Service Result",
                        JOptionPane.INFORMATION_MESSAGE);
            } catch (final Exception e) {
                try {
                    SwingUtilities.invokeAndWait(new Runnable() {

                        public void run() {
                            Main.this.statusBar.setErrorStatus(e.getMessage());
                        }
                    });
                } catch (Exception e1) {
                }
                showException(e);
            }
        }
    };
    executor.execute(futureTask);
}

From source file:configuration.Util.java

private static void eao_BoxSpin(workflow_properties properties, boolean e,
        HashMap<JCheckBox, JSpinner> BoxSpin) {
    for (JCheckBox cb : BoxSpin.keySet()) {
        cb.setEnabled(e);
        if (BoxSpin.get(cb) != null) {
            String s = cb.getName();
            if (properties.isSet(s) && e == true) {
                BoxSpin.get(cb).setEnabled(true);
            } else {
                BoxSpin.get(cb).setEnabled(false);
            }//from  w ww  .j a v a2  s. c om
        }
    }
}

From source file:configuration.Util.java

private static void eao_BoxText(workflow_properties properties, boolean e,
        HashMap<JCheckBox, JTextField> BoxText) {
    for (JCheckBox cb : BoxText.keySet()) {
        cb.setEnabled(e);
        if (BoxText.get(cb) != null) {
            String s = cb.getName();
            if (properties.isSet(s) && e == true) {
                BoxText.get(cb).setEnabled(true);
            } else {
                BoxText.get(cb).setEnabled(false);
            }//from www  .  j a  va2 s  .  c om
        }
    }
}