Example usage for javax.swing JLabel setLabelFor

List of usage examples for javax.swing JLabel setLabelFor

Introduction

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

Prototype

@BeanProperty(description = "The component this is labelling.")
public void setLabelFor(Component c) 

Source Link

Document

Set the component this is labelling.

Usage

From source file:net.java.sip.communicator.gui.AuthenticationSplash.java

/**
 *
 * We use dynamic layout managers, so that layout is dynamic and will
 * adapt properly to user-customized fonts and localized text. The
 * GridBagLayout makes it easy to line up components of varying
 * sizes along invisible vertical and horizontal grid lines. It
 * is important to sketch the layout of the interface and decide
 * on the grid before writing the layout code.
 *
 * Here we actually use/*  ww w .jav  a 2s . co  m*/
 * our own subclass of GridBagLayout called StringGridBagLayout,
 * which allows us to use strings to specify constraints, rather
 * than having to create GridBagConstraints objects manually.
 *
 *
 * We use the JLabel.setLabelFor() method to connect
 * labels to what they are labeling. This allows mnemonics to work
 * and assistive to technologies used by persons with disabilities
 * to provide much more useful information to the user.
 */

private void initComponents(final Frame parent) {
    Container contents = getContentPane();
    contents.setLayout(new BorderLayout());

    String title = Utils.getProperty("net.java.sip.communicator.gui.AUTH_WIN_TITLE");

    if (title == null)
        title = "Login Manager";

    setTitle(title);
    setResizable(false);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            dialogDone(CMD_CANCEL, parent);
        }
    });

    // Accessibility -- all frames, dialogs, and applets should
    // have a description
    getAccessibleContext().setAccessibleDescription("Authentication Splash");

    String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.AUTHENTICATION_PROMPT");

    if (authPromptLabelValue == null)
        authPromptLabelValue = "Please register to the service or enter your credentials to log in:";

    JLabel splashLabel = new JLabel(authPromptLabelValue);
    splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    splashLabel.setHorizontalAlignment(SwingConstants.CENTER);
    splashLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    contents.add(splashLabel, BorderLayout.NORTH);

    JPanel centerPane = new JPanel();
    centerPane.setLayout(new GridBagLayout());

    userNameTextField = new JTextField(); // needed below

    // user name label
    JLabel userNameLabel = new JLabel();
    userNameLabel.setDisplayedMnemonic('U');
    // setLabelFor() allows the mnemonic to work
    userNameLabel.setLabelFor(userNameTextField);

    String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL");

    if (userNameLabelValue == null)
        userNameLabelValue = "Username";

    int gridy = 0;

    userNameLabel.setText(userNameLabelValue);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(12, 12, 0, 0);
    centerPane.add(userNameLabel, c);

    // user name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(12, 7, 0, 11);
    centerPane.add(userNameTextField, c);

    passwordTextField = new JPasswordField(); //needed below

    // password label
    JLabel passwordLabel = new JLabel();
    passwordLabel.setDisplayedMnemonic('P');
    passwordLabel.setLabelFor(passwordTextField);
    String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL");

    if (pLabelStr == null)
        pLabelStr = "Password";

    passwordLabel.setText(pLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(passwordLabel, c);

    // password text
    passwordTextField.setEchoChar('\u2022');
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(passwordTextField, c);

    //Set a relevant realm value
    //Bug report by Steven Lass (sltemp at comcast.net)
    //JLabel realmValueLabel = new JLabel("SipPhone.com"); // needed below

    // realm label

    JLabel realmLabel = new JLabel();
    realmLabel.setDisplayedMnemonic('R');
    realmLabel.setLabelFor(realmValueLabel);
    realmLabel.setText("Realm");
    realmValueLabel = new JLabel();

    // Buttons along bottom of window
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));
    loginButton = new JButton();
    loginButton.setText("Login");
    loginButton.setActionCommand(CMD_LOGIN);
    loginButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(loginButton);

    // space
    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    registerButton = new JButton();
    registerButton.setMnemonic('G');
    registerButton.setText("Register");
    registerButton.setActionCommand(CMD_REGISTER);
    registerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(registerButton);

    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    cancelButton = new JButton();
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(cancelButton);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.insets = new Insets(11, 12, 11, 11);

    centerPane.add(buttonPanel, c);

    contents.add(centerPane, BorderLayout.CENTER);
    getRootPane().setDefaultButton(loginButton);
    equalizeButtonSizes();

    setFocusTraversalPolicy(new FocusTraversalPol());

}

From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java

BamFrame(List<BamFileRef> BamFileRefs) {
    super((JFrame) null, "Bam View (" + BamFileRefs.size() + " files)", ModalityType.APPLICATION_MODAL);
    this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    this.BamFileRefs = BamFileRefs;

    addWindowListener(new WindowAdapter() {

        @Override//from ww  w. ja  v a2s  .co  m
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            d.width -= 150;
            d.height -= 150;
            for (BamFileRef vfr : BamFrame.this.BamFileRefs) {
                LOG.info("Reading " + vfr.bamFile);
                int w = (int) (d.width * 0.8);
                int h = (int) (d.height * 0.8);
                BamInternalFrame iFrame = new BamInternalFrame(vfr);
                iFrame.setBounds(Math.max((int) ((d.width - w) * Math.random()), 0),
                        Math.max((int) ((d.height - h) * Math.random()), 0), w, h);
                desktopPane.add(iFrame);
                BamInternalFrames.add(iFrame);
                iFrame.setVisible(true);
                iFrame.jTable.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if (e.getClickCount() == 2) {
                            JTable t = (JTable) e.getSource();
                            int row = t.getSelectedRow();
                            if (row == -1)
                                return;
                            BamTableModel tm = (BamTableModel) t.getModel();
                            showIgv(tm.getValueAt(row, 0), tm.getValueAt(row, 1));
                        }
                    }
                });
            }
            reloadFrameContent();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doMenuClose();
        }
    });
    JMenuBar bar = new JMenuBar();
    setJMenuBar(bar);

    JMenu menu = new JMenu("File");
    bar.add(menu);
    menu.add(new AbstractAction("Quit") {
        @Override
        public void actionPerformed(ActionEvent e) {
            doMenuClose();
        }
    });

    menu = new JMenu("Flags");
    bar.add(menu);
    for (SamFlag flag : SamFlag.values()) {
        JCheckBox cbox = new JCheckBox("Require " + flag);
        requiredFlags.add(cbox);
        menu.add(cbox);
    }
    menu.add(new JSeparator());
    for (SamFlag flag : SamFlag.values()) {
        JCheckBox cbox = new JCheckBox("Filter out " + flag);
        filteringFlags.add(cbox);
        menu.add(cbox);
    }

    JPanel contentPane = new JPanel(new BorderLayout(5, 5));
    setContentPane(contentPane);
    this.desktopPane = new JDesktopPane();
    contentPane.add(this.desktopPane, BorderLayout.CENTER);

    JPanel top = new JPanel(new FlowLayout(FlowLayout.LEADING));
    contentPane.add(top, BorderLayout.NORTH);

    JLabel lbl = new JLabel("Max Rows:", JLabel.LEADING);
    JSpinner spinner = new JSpinner(this.numFetchModel = new SpinnerNumberModel(100, 1, 10000, 10));
    lbl.setLabelFor(spinner);
    top.add(lbl);
    top.add(spinner);

    lbl = new JLabel("Timeout (secs):", JLabel.LEADING);
    spinner = new JSpinner(this.numSecondsModel = new SpinnerNumberModel(2, 1, 10000, 1));
    lbl.setLabelFor(spinner);
    top.add(lbl);
    top.add(spinner);

    //lbl=new JLabel("JEXL:",JLabel.LEADING);
    /*jexlField=new JTextField(20);
    lbl.setLabelFor(jexlField);
            
    top.add(lbl);
    top.add(jexlField);*/

    lbl = new JLabel("Region:", JLabel.LEADING);
    selectRgnField = new JTextField(20);
    lbl.setLabelFor(selectRgnField);
    AbstractAction action = new AbstractAction("Select") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent a) {
            if (
            /* (jexlField.getText().trim().isEmpty() || parseJex(jexlField.getText().trim())!=null) && */
            (selectRgnField.getText().trim().isEmpty() || parseOne(selectRgnField.getText()) != null)) {
                reloadFrameContent();
            } else {
                LOG.info("Bad input " + selectRgnField.getText());
            }
        }
    };
    selectRgnField.addActionListener(action);
    //jexlField.addActionListener(action);

    top.add(lbl);
    top.add(selectRgnField);
    top.add(new JButton(action));

}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

@SuppressWarnings("unchecked")
private JPanel buildPie(final String label_pie, final SaveOrUpdateAction guardar, final int textfieldSize,
        final JFrame d) {
    GridBagConstraints gbc;/*from ww w.  java 2  s . c om*/
    JPanel pie = new JPanel(new GridBagLayout());
    pie.setBorder(new EmptyBorder(5, 15, 15, 15));
    pie.setOpaque(false);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(15, 15, 15, 15);
    gbc.gridwidth = 1;
    JLabel labl_pie = new JLabel(label_pie, JLabel.LEFT);
    pie.add(labl_pie, gbc);
    textfieldPie.setColumns(textfieldSize);
    textfieldPie.getDocument().addDocumentListener(changeListener);
    labl_pie.setLabelFor(textfieldPie);
    gbc.gridx++;
    gbc.gridwidth = 1;
    pie.add(textfieldPie, gbc);
    gbc.gridy++;
    gbc.gridx = 1;
    gbc.insets = new Insets(15, -90, 15, 15);
    JPanel botones = getBotonesSalir(guardar, d, 200);
    pie.add(botones, gbc);
    return pie;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

@SuppressWarnings("unchecked")
private JPanel buildSimpleCentral(final String labelPie, final SaveOrUpdateAction guardar, final JFrame d) {
    JPanel central = new JPanel(new GridBagLayout());
    central.setOpaque(false);//from   w w  w  .ja va  2 s  .com
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(2, 1, 2, 1);
    gbc.gridwidth = 1;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel nombreLbl = new JLabel("Nombre:", SwingConstants.RIGHT);
    central.add(nombreLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(nombre, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel apellidosLbl = new JLabel("Apellidos: ", SwingConstants.RIGHT);
    central.add(apellidosLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(apellidos, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel rolLbl = new JLabel("Rol:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    central.add(rolLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(rol, gbc);
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenyaLbl = new JLabel("Contrasea:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(contrasenyaLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(contrasenya, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenya2Lbl = new JLabel("Repetir Contrasea:", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(contrasenya2Lbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(repetir, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel administradorLbl = new JLabel("Administrador:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(administradorLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(administrador, gbc);
    administrador.setOpaque(false);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel habilitadoLbl = new JLabel("Habilitado", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(habilitadoLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(habilitado, gbc);
    habilitado.setOpaque(false);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel labl_pie = new JLabel(labelPie, JLabel.LEFT);
    central.add(labl_pie, gbc);
    textfieldPie.setColumns(textfieldSize);
    labl_pie.setLabelFor(textfieldPie);
    gbc.gridx++;
    gbc.gridwidth = 4;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(textfieldPie, gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridwidth = 2;
    gbc.gridy++;
    gbc.gridx = 1;
    JPanel botones = getBotonesSalir(guardar, d, 250);
    central.add(botones, gbc);

    ((DefaultComboBoxModel) rol.getModel()).removeAllElements();
    for (String r : RolConsultas.getAllNames()) {
        ((DefaultComboBoxModel) rol.getModel()).addElement(r);
    }

    return central;
}

From source file:es.emergya.ui.plugins.admin.aux1.RecursoDialog.java

public RecursoDialog(final Recurso rec, final AdminResources adminResources) {
    super();/*from  ww w .j a  va 2 s  .c o m*/
    setAlwaysOnTop(true);
    setSize(600, 400);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId());
    if (r != null) {
        setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    } else {
        setTitle(i18n.getString("Resources.summary.titleWindow.new"));
    }
    setIconImage(getBasicWindow().getFrame().getIconImage());
    JPanel base = new JPanel();
    base.setBackground(Color.WHITE);
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setOpaque(false);
    JLabel labelTitulo = null;
    if (r != null) {
        labelTitulo = new JLabel(i18n.getString("Resources.summary"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    } else {
        labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    }
    labelTitulo.setFont(LogicConstants.deriveBoldFont(12f));
    title.add(labelTitulo);
    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setOpaque(false);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    final JTextField name = new JTextField(25);
    if (r != null) {
        name.setText(r.getNombre());
    }

    name.getDocument().addDocumentListener(changeListener);
    name.setEditable(r == null);
    mid.add(name);

    // patrullas
    final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT);
    mid.add(labelSquads);
    List<Patrulla> pl = PatrullaConsultas.getAll();
    pl.add(0, null);
    final JComboBox squads = new JComboBox(pl.toArray());
    squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX");
    squads.addActionListener(changeSelectionListener);
    squads.setOpaque(false);
    labelSquads.setLabelFor(squads);
    if (r != null) {
        squads.setSelectedItem(r.getPatrullas());
    } else {
        squads.setSelectedItem(null);
    }
    squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true);
    mid.add(squads);

    // // Identificador
    // mid.setOpaque(false);
    // mid.add(new JLabel(i18n.getString("Resources.identificador"),
    // JLabel.RIGHT));
    // final JTextField identificador = new JTextField("");
    // if (r != null) {
    // identificador.setText(r.getIdentificador());
    // }
    // identificador.getDocument().addDocumentListener(changeListener);
    // identificador.setEditable(r == null);
    // mid.add(identificador);
    // Espacio en blanco
    // mid.add(Box.createHorizontalGlue());
    // mid.add(Box.createHorizontalGlue());

    // Tipo
    final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT);
    mid.add(labelTipoRecursos);
    final JComboBox types = new JComboBox(RecursoConsultas.getTipos());
    labelTipoRecursos.setLabelFor(types);
    types.addActionListener(changeSelectionListener);
    if (r != null) {
        types.setSelectedItem(r.getTipo());
    } else {
        types.setSelectedItem(0);
    }
    // types.setEditable(true);
    types.setEnabled(true);
    mid.add(types);

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

    // Subflota y patrulla
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas());
    subfleets.addActionListener(changeSelectionListener);
    if (r != null) {
        subfleets.setSelectedItem(r.getFlotas());
    } else {
        subfleets.setSelectedIndex(0);
    }
    subfleets.setEnabled(true);
    subfleets.setOpaque(false);
    mid.add(subfleets);

    // Referencia humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    final JTextField rhumana = new JTextField();
    // if (r != null && 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));
    final PlainDocument plainDocument = new PlainDocument() {

        private static final long serialVersionUID = 4929271093724956016L;

        @Override
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
            if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) {
                super.insertString(offs, str, a);
            }
        }
    };
    final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI);
    plainDocument.addDocumentListener(changeListener);
    issi.setEditable(true);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    final JCheckBox enabled = new JCheckBox("", true);
    enabled.addActionListener(changeSelectionListener);
    enabled.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (enabled.isSelected()) {
                squads.setSelectedIndex(0);
            }
            squads.setEnabled(enabled.isSelected());
        }
    });
    enabled.setEnabled(true);
    enabled.setOpaque(false);
    if (r != null) {
        enabled.setSelected(r.getHabilitado());
    } else {
        enabled.setSelected(true);
    }
    if (r != null && r.getDispositivo() != null) {
        issi.setText(
                StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0'));
    }

    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());

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    final JTextField info = new JTextField(25);
    info.getDocument().addDocumentListener(changeListener);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    infoPanel.setOpaque(false);
    info.setOpaque(false);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);

    if (r != null) {
        info.setText(r.getInfoAdicional());
    } else {
        info.setText("");
    }
    info.setEditable(true);

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

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

    JPanel buttons = new JPanel();
    buttons.setOpaque(false);
    JButton accept = null;
    if (r == null) {
        accept = new JButton("Crear", LogicConstants.getIcon("button_crear"));
    } else {
        accept = new JButton("Guardar", LogicConstants.getIcon("button_save"));
    }
    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (cambios || r == null || r.getId() == null) {
                    boolean shithappens = true;
                    if ((r == null || r.getId() == null)) { // Estamos
                        // creando
                        // uno nuevo
                        if (RecursoConsultas.alreadyExists(name.getText())) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                            shithappens = false;
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText())
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.dispositivoUnico"));
                        }
                    }
                    if (shithappens) {
                        if (name.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreNulo"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.issiUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && !LogicConstants.isNumeric(issi.getText())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noNumerico"));
                            // } else if (identificador.getText().isEmpty())
                            // {
                            // JOptionPane
                            // .showMessageDialog(
                            // RecursoDialog.this,
                            // i18n.getString("admin.recursos.popup.error.identificadorNulo"));
                        } else if (subfleets.getSelectedIndex() == -1) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noSubflota"));
                        } else if (types.getSelectedItem() == null
                                || types.getSelectedItem().toString().trim().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noTipo"));
                        } else {
                            int i = JOptionPane.showConfirmDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"),
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                Recurso recurso = r;

                                if (r == null) {
                                    recurso = new Recurso();
                                }

                                recurso.setInfoAdicional(info.getText());
                                if (issi.getText() != null && issi.getText().length() > 0) {
                                    recurso.setDispositivo(new Integer(issi.getText()));
                                } else {
                                    recurso.setDispositivo(null);
                                }
                                recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString()));
                                if (squads.getSelectedItem() != null && enabled.isSelected()) {
                                    recurso.setPatrullas(
                                            PatrullaConsultas.find(squads.getSelectedItem().toString()));
                                } else {
                                    recurso.setPatrullas(null);
                                }
                                recurso.setNombre(name.getText());
                                recurso.setHabilitado(enabled.isSelected());
                                // recurso.setIdentificador(identificador
                                // .getText());
                                recurso.setTipo(types.getSelectedItem().toString());
                                dispose();

                                RecursoAdmin.saveOrUpdate(recurso);
                                adminResources.refresh(null);

                                PluginEventHandler.fireChange(adminResources);
                            } else if (i == JOptionPane.NO_OPTION) {
                                dispose();
                            }
                        }
                    }
                } else {
                    log.debug("No hay cambios");
                    dispose();
                }

            } catch (Throwable t) {
                log.error("Error guardando un recurso", t);
            }
        }
    });
    buttons.add(accept);

    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));

    cancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cambios) {
                if (JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) {
                    dispose();
                }
            } else {
                dispose();
            }
        }
    });

    buttons.add(cancelar);

    base.add(buttons);

    getContentPane().add(base);
    setLocationRelativeTo(null);
    cambios = false;
    if (r == null) {
        cambios = true;
    }

    pack();

    int x;
    int y;

    Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0);
    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);
    cambios = false;
}

From source file:es.emergya.ui.plugins.admin.AdminLayers.java

protected SummaryAction getSummaryAction(final CapaInformacion capaInformacion) {
    SummaryAction action = new SummaryAction(capaInformacion) {

        private static final long serialVersionUID = -3691171434904452485L;

        @Override//from  w  w  w  .  j av  a 2 s  .  c om
        protected JFrame getSummaryDialog() {

            if (capaInformacion != null) {
                d = getDialog(capaInformacion, null, "", null, "image/png");
                return d;
            } else {
                JDialog primera = getJDialog();
                primera.setResizable(false);
                primera.setVisible(true);
                primera.setAlwaysOnTop(true);
            }
            return null;
        }

        private JDialog getJDialog() {
            final JDialog dialog = new JDialog();
            dialog.setTitle(i18n.getString("admin.capas.nueva.titleBar"));
            dialog.setIconImage(getBasicWindow().getIconImage());

            dialog.setLayout(new BorderLayout());

            JPanel centro = new JPanel(new FlowLayout());
            centro.setOpaque(false);
            JLabel label = new JLabel(i18n.getString("admin.capas.nueva.url"));
            final JTextField url = new JTextField(50);
            final JLabel icono = new JLabel(LogicConstants.getIcon("48x48_transparente"));
            label.setLabelFor(url);
            centro.add(label);
            centro.add(url);
            centro.add(icono);
            dialog.add(centro, BorderLayout.CENTER);

            JPanel pie = new JPanel(new FlowLayout(FlowLayout.TRAILING));
            pie.setOpaque(false);
            final JButton siguiente = new JButton(i18n.getString("admin.capas.nueva.boton.siguiente"),
                    LogicConstants.getIcon("button_next"));
            JButton cancelar = new JButton(i18n.getString("admin.capas.nueva.boton.cancelar"),
                    LogicConstants.getIcon("button_cancel"));
            final SiguienteActionListener siguienteActionListener = new SiguienteActionListener(url, dialog,
                    icono, siguiente);
            url.addActionListener(siguienteActionListener);

            siguiente.addActionListener(siguienteActionListener);

            cancelar.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    dialog.dispose();
                }
            });
            pie.add(siguiente);
            pie.add(cancelar);
            dialog.add(pie, BorderLayout.SOUTH);

            dialog.getContentPane().setBackground(Color.WHITE);

            dialog.pack();
            dialog.setLocationRelativeTo(null);
            return dialog;
        }

        private JFrame getDialog(final CapaInformacion c, final Capa[] left_items, final String service,
                final Map<String, Boolean> transparentes, final String png) {

            if (left_items != null && left_items.length == 0) {
                JOptionPane.showMessageDialog(AdminLayers.this,
                        i18n.getString("admin.capas.nueva.error.noCapasEnServicio"));
            } else {

                final String label_cabecera = i18n.getString("admin.capas.nueva.nombreCapa");
                final String label_pie = i18n.getString("admin.capas.nueva.infoAdicional");
                final String centered_label = i18n.getString("admin.capas.nueva.origenDatos");
                final String left_label = i18n.getString("admin.capas.nueva.subcapasDisponibles");
                final String right_label;
                if (left_items != null) {
                    right_label = i18n.getString("admin.capas.nueva.capasSeleccionadas");
                } else {
                    right_label = i18n.getString("admin.capas.ficha.capasSeleccionadas");
                }
                final String tituloVentana, cabecera;
                if (c.getNombre() == null) {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.nuevaCapa");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.nuevaCapa");
                } else {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.ficha");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.ficha");
                }

                final Capa[] right_items = c.getCapas().toArray(new Capa[0]);
                final AdminPanel.SaveOrUpdateAction<CapaInformacion> guardar = layers.new SaveOrUpdateAction<CapaInformacion>(
                        c) {

                    private static final long serialVersionUID = 7447770296943341404L;

                    @Override
                    public void actionPerformed(ActionEvent e) {

                        if (isNew && CapaConsultas.alreadyExists(textfieldCabecera.getText())) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaYaExiste"));

                        } else if (textfieldCabecera.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaEnBlanco"));

                        } else if (((DefaultListModel) right.getModel()).size() == 0) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.noCapasSeleccionadas"));

                        } else if (cambios) {
                            int i = JOptionPane.showConfirmDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.confirmar.guardar.titulo"),
                                    i18n.getString("admin.capas.nueva.confirmar.boton.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                if (original == null) {
                                    original = new CapaInformacion();

                                }
                                original.setInfoAdicional(textfieldPie.getText());
                                original.setNombre(textfieldCabecera.getText());
                                original.setHabilitada(habilitado.isSelected());
                                original.setOpcional(comboTipoCapa.getSelectedIndex() != 0);

                                boolean transparente = true;

                                HashSet<Capa> capas = new HashSet<Capa>();
                                List<Capa> capasEnOrdenSeleccionado = new ArrayList<Capa>();
                                int indice = 0;
                                for (Object c : ((DefaultListModel) right.getModel()).toArray()) {
                                    if (c instanceof Capa) {
                                        transparente = transparente && (transparentes != null
                                                && transparentes.get(((Capa) c).getNombre()) != null
                                                && transparentes.get(((Capa) c).getNombre()));
                                        capas.add((Capa) c);
                                        capasEnOrdenSeleccionado.add((Capa) c);
                                        ((Capa) c).setCapaInformacion(original);
                                        ((Capa) c).setOrden(indice++);
                                        // ((Capa)
                                        // c).setNombre(c.toString());
                                    }

                                }
                                original.setCapas(capas);

                                if (original.getId() == null) {
                                    String url = nombre.getText();

                                    if (url.indexOf("?") > -1) {
                                        if (!url.endsWith("?")) {
                                            url += "&";

                                        }
                                    } else {
                                        url += "?";

                                    }
                                    url += "VERSION=" + version + "&REQUEST=GetMap&FORMAT=" + png + "&SERVICE="
                                            + service + "&WIDTH={2}&HEIGHT={3}&BBOX={1}&SRS={0}";
                                    // if (transparente)
                                    url += "&TRANSPARENT=TRUE";
                                    url += "&LAYERS=";

                                    String estilos = "";
                                    final String coma = "%2C";
                                    if (capasEnOrdenSeleccionado.size() > 0) {
                                        for (Capa c : capasEnOrdenSeleccionado) {
                                            url += c.getTitulo().replaceAll(" ", "+") + coma;
                                            estilos += c.getEstilo() + coma;
                                        }
                                        estilos = estilos.substring(0, estilos.length() - coma.length());

                                        estilos = estilos.replaceAll(" ", "+");

                                        url = url.substring(0, url.length() - coma.length());
                                    }
                                    url += "&STYLES=" + estilos;
                                    original.setUrl_visible(original.getUrl());
                                    original.setUrl(url);
                                }
                                CapaInformacionAdmin.saveOrUpdate(original);

                                cambios = false;

                                layers.setTableData(getAll(new CapaInformacion()));

                                closeFrame();
                            } else if (i == JOptionPane.NO_OPTION) {
                                closeFrame();

                            }
                        } else {
                            closeFrame();

                        }
                    }
                };
                JFrame segunda = generateUrlDialog(label_cabecera, label_pie, centered_label, tituloVentana,
                        left_items, right_items, left_label, right_label, guardar,
                        LogicConstants.getIcon("tittleficha_icon_capa"), cabecera, c.getHabilitada(),
                        c.getOpcional(), c.getUrl_visible());
                segunda.setResizable(false);

                if (c != null) {
                    textfieldCabecera.setText(c.getNombre());
                    textfieldPie.setText(c.getInfoAdicional());
                    nombre.setText(c.getUrl_visible());
                    nombre.setEditable(false);
                    if (c.getHabilitada() == null) {
                        c.setHabilitada(false);

                    }
                    habilitado.setSelected(c.getHabilitada());
                    if (c.isOpcional() != null && c.isOpcional()) {
                        comboTipoCapa.setSelectedIndex(1);
                    } else {
                        comboTipoCapa.setSelectedIndex(0);
                    }
                }

                if (c.getId() == null) {
                    habilitado.setSelected(true);
                    comboTipoCapa.setSelectedIndex(1);
                }

                habilitado.setEnabled(true);
                if (c == null || c.getId() == null) {
                    textfieldCabecera.setEditable(true);
                } else {
                    textfieldCabecera.setEditable(false);
                }

                cambios = false;

                segunda.pack();
                segunda.setLocationRelativeTo(null);
                segunda.setVisible(true);
                return segunda;
            }
            return null;
        }

        class SiguienteActionListener implements ActionListener {

            private final JTextField url;
            private final JDialog dialog;
            private final JLabel icono;
            private final JButton siguiente;

            public SiguienteActionListener(JTextField url, JDialog dialog, JLabel icono, JButton siguiente) {
                this.url = url;
                this.dialog = dialog;
                this.icono = icono;
                this.siguiente = siguiente;
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                final CapaInformacion ci = new CapaInformacion();
                ci.setUrl(url.getText());
                ci.setCapas(new HashSet<Capa>());
                SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                    private List<Capa> res = new LinkedList<Capa>();
                    private String service = "WMS";
                    private String png = null;
                    private Map<String, Boolean> transparentes = new HashMap<String, Boolean>();
                    private ArrayList<String> errorStack = new ArrayList<String>();
                    private Boolean goOn = true;

                    @SuppressWarnings(value = "unchecked")
                    @Override
                    protected Object doInBackground() throws Exception {
                        try {
                            final String url2 = ci.getUrl();
                            WMSClient client = new WMSClient(url2);
                            client.connect(new ICancellable() {

                                @Override
                                public boolean isCanceled() {
                                    return false;
                                }

                                @Override
                                public Object getID() {
                                    return System.currentTimeMillis();
                                }
                            });

                            version = client.getVersion();

                            for (final String s : client.getLayerNames()) {
                                WMSLayer layer = client.getLayer(s);
                                // this.service =
                                // client.getServiceName();
                                final Vector allSrs = layer.getAllSrs();
                                boolean epsg = (allSrs != null) ? allSrs.contains("EPSG:4326") : false;
                                final Vector formats = client.getFormats();
                                if (formats.contains("image/png")) {
                                    png = "image/png";
                                } else if (formats.contains("IMAGE/PNG")) {
                                    png = "IMAGE/PNG";
                                } else if (formats.contains("png")) {
                                    png = "png";
                                } else if (formats.contains("PNG")) {
                                    png = "PNG";
                                }
                                boolean image = png != null;
                                if (png == null) {
                                    png = "IMAGE/PNG";
                                }
                                if (epsg && image) {
                                    boolean hasTransparency = layer.hasTransparency();
                                    this.transparentes.put(s, hasTransparency);
                                    Capa capa = new Capa();
                                    capa.setCapaInformacion(ci);
                                    if (layer.getStyles().size() > 0) {
                                        capa.setEstilo(((WMSStyle) layer.getStyles().get(0)).getName());
                                    }
                                    capa.setNombre(layer.getTitle());
                                    capa.setTitulo(s);
                                    res.add(capa);
                                    if (!hasTransparency) {
                                        errorStack.add(i18n.getString(Locale.ROOT,
                                                "admin.capas.nueva.error.capaNoTransparente",
                                                layer.getTitle()));
                                    }
                                } else {
                                    String error = "";
                                    // if (opaque)
                                    // error += "<li>Es opaca</li>";
                                    if (!image) {
                                        error += i18n.getString("admin.capas.nueva.error.formatoPNG");
                                    }
                                    if (!epsg) {
                                        error += i18n.getString("admin.capas.nueva.error.projeccion");
                                    }
                                    final String cadena = i18n.getString(Locale.ROOT,
                                            "admin.capas.nueva.error.errorCapa", new Object[] { s, error });
                                    errorStack.add(cadena);
                                }
                            }
                        } catch (final Throwable t) {
                            log.error("Error al parsear el WMS", t);
                            goOn = false;
                            icono.setIcon(LogicConstants.getIcon("48x48_transparente"));

                            JOptionPane.showMessageDialog(dialog,
                                    i18n.getString("admin.capas.nueva.error.errorParseoWMS"));

                            siguiente.setEnabled(true);
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        super.done();
                        if (goOn) {

                            dialog.dispose();
                            ci.setUrl_visible(ci.getUrl());
                            final JFrame frame = getDialog(ci, res.toArray(new Capa[0]), service, transparentes,
                                    png);
                            if (!errorStack.isEmpty()) {
                                String error = "<html>";
                                for (final String s : errorStack) {
                                    error += s + "<br/>";
                                }
                                error += "</html>";
                                final String errorString = error;
                                SwingUtilities.invokeLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        JOptionPane.showMessageDialog(frame, errorString);
                                    }
                                });
                            }
                        }
                    }
                };
                sw.execute();
                icono.setIcon(LogicConstants.getIcon("anim_conectando"));
                icono.repaint();
                siguiente.setEnabled(false);
            }
        }
    };

    return action;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JPanel buildCabecera(final String label_cabecera, final int textfieldSize, final Icon icono,
        final String titulo, final String icono_seleccionado) {
    JLabel title = new JLabel(titulo, icono, SwingConstants.LEFT);
    title.setFont(LogicConstants.deriveBoldFont(12f));
    JPanel resultado = new JPanel(new BorderLayout(2, 2));
    resultado.setOpaque(false);//from  w  w  w. ja  v a 2  s.  c o  m
    resultado.add(title, BorderLayout.NORTH);
    JPanel cabecera = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    cabecera.setOpaque(false);

    JLabel nombre = new JLabel(label_cabecera, JLabel.RIGHT);
    gbc.gridx = 0;
    gbc.gridy = 0;
    cabecera.add(nombre, gbc);
    textfieldCabecera.setColumns(textfieldSize);
    textfieldCabecera.getDocument().addDocumentListener(changeListener);
    nombre.setLabelFor(textfieldCabecera);
    gbc.gridx++;
    cabecera.add(textfieldCabecera, gbc);

    if (icono_seleccionado != null) {
        JLabel nombre2 = new JLabel("Icono:", JLabel.RIGHT);
        gbc.gridx = 0;
        gbc.gridy++;
        cabecera.add(nombre2, gbc);
        ((DefaultComboBoxModel) iconos.getModel()).removeAllElements();
        for (String icon : FlotaConsultas.getAllIcons("/images/" + LogicConstants.DIRECTORIO_ICONOS_FLOTAS)) {
            ((DefaultComboBoxModel) iconos.getModel()).addElement(icon);
        }
        for (ActionListener l : iconos.getActionListeners()) {
            iconos.removeActionListener(l);
        }
        iconos.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cambios = true;
                if (iconos.getSelectedItem() != null) {
                    i.setIcon(LogicConstants.getIcon(LogicConstants.DIRECTORIO_ICONOS_FLOTAS
                            + iconos.getSelectedItem().toString() + "_flota_preview"));
                }
                i.updateUI();
            }
        });
        iconos.setSelectedItem(icono_seleccionado);
        if (iconos.getSelectedIndex() == -1 || i.getIcon() == null) {
            if (iconos.getModel().getSize() > 0)
                iconos.setSelectedIndex(0);
        }
        cambios = false;
        nombre2.setLabelFor(iconos);
        gbc.gridx++;
        gbc.anchor = GridBagConstraints.WEST;
        cabecera.add(iconos, gbc);

        gbc.gridheight = 2;
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.insets = new Insets(2, 10, 2, 10);
        gbc.ipadx = 5;
        gbc.ipady = 5;
        i.setBorder(BorderFactory.createLineBorder(Color.black));
        cabecera.add(i, gbc);
    }

    resultado.add(cabecera, BorderLayout.CENTER);
    resultado.setBorder(new EmptyBorder(15, 15, 15, 15));
    return resultado;
}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder//from  w  w  w  .  j a  va 2s . c o m
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:org.pentaho.support.standalone.SDSupportUtility.java

/**
 * initializing UI/*from  w  w w. j a  v a 2  s  . c o  m*/
 * 
 * @throws Exception
 */
public SDSupportUtility() throws Exception {

    prop = loadProperty();

    setResizable(false);
    setTitle(SDConstant.PENT_SUP_WIZARD);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 665, 516);

    contentPane = new JPanel();
    contentPane.setBackground(UIManager.getColor("Button.background"));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblLastAttached = new JLabel("Last Attached");
    lblLastAttached.setOpaque(false);
    lblLastAttached.setHorizontalAlignment(SwingConstants.LEFT);
    lblLastAttached.setBounds(322, 335, 127, 23);
    contentPane.add(lblLastAttached);

    JLabel lblPentahoCustomerSupport = new JLabel("Pentaho Customer Support Wizard");
    lblPentahoCustomerSupport.setForeground(new Color(51, 51, 51));
    lblPentahoCustomerSupport.setVerticalAlignment(SwingConstants.TOP);
    lblPentahoCustomerSupport.setHorizontalAlignment(SwingConstants.RIGHT);
    lblPentahoCustomerSupport.setFont(new Font("Tahoma", Font.BOLD, 23));
    lblPentahoCustomerSupport.setBounds(130, 109, 506, 37);
    contentPane.add(lblPentahoCustomerSupport);

    JLabel lbllogo = new JLabel();
    lbllogo.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/puc-login-logo.png")));
    lbllogo.setBounds(10, 11, 409, 93);
    contentPane.add(lbllogo);

    chckbxNewCheckBoxEnvironment = new JCheckBox("Environment");
    chckbxNewCheckBoxEnvironment.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.ENVIRONMENT);
            } else {
                ArgList.remove(SDConstant.ENVIRONMENT);
            }
        }
    });
    chckbxNewCheckBoxEnvironment.setBounds(109, 268, 243, 23);
    contentPane.add(chckbxNewCheckBoxEnvironment);
    chckbxNewCheckBoxEnvironment.setOpaque(false);

    chckbxNewCheckBoxStructure = new JCheckBox("Structure Details");
    chckbxNewCheckBoxStructure.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.STRUCT);
            } else {
                ArgList.remove(SDConstant.STRUCT);
            }
        }
    });
    chckbxNewCheckBoxStructure.setBounds(377, 190, 248, 23);
    contentPane.add(chckbxNewCheckBoxStructure);
    chckbxNewCheckBoxStructure.setOpaque(false);

    chckbxLogs = new JCheckBox("Logs");
    chckbxLogs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LOGS);
            } else {
                ArgList.remove(SDConstant.LOGS);
            }
        }
    });
    chckbxLogs.setBounds(377, 164, 248, 23);
    contentPane.add(chckbxLogs);
    chckbxLogs.setOpaque(false);

    chckbxGetSecureFiles = new JCheckBox("Secure Files");
    chckbxGetSecureFiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.SECURITY);
            } else {
                ArgList.remove(SDConstant.SECURITY);
            }
        }
    });
    chckbxGetSecureFiles.setBounds(109, 190, 243, 23);
    contentPane.add(chckbxGetSecureFiles);
    chckbxGetSecureFiles.setOpaque(false);

    chckbxMd5 = new JCheckBox("MD5 Hash Value");
    chckbxMd5.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.MD5);
            } else {
                ArgList.remove(SDConstant.MD5);
            }
        }
    });
    chckbxMd5.setBounds(109, 216, 243, 23);
    contentPane.add(chckbxMd5);
    chckbxMd5.setOpaque(false);

    chckbxDbdetails = new JCheckBox("Datasource Details");
    chckbxDbdetails.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.DATASOURCE);
            } else {
                ArgList.remove(SDConstant.DATASOURCE);
            }
        }
    });
    chckbxDbdetails.setBounds(109, 294, 243, 23);
    contentPane.add(chckbxDbdetails);
    chckbxDbdetails.setOpaque(false);

    chckbxLicense = new JCheckBox("License File");
    chckbxLicense.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LICENSE);
            } else {
                ArgList.remove(SDConstant.LICENSE);
            }
        }
    });
    chckbxLicense.setBounds(109, 164, 243, 23);
    contentPane.add(chckbxLicense);
    chckbxLicense.setOpaque(false);

    chckbxProcesslist = new JCheckBox("Running Process");
    chckbxProcesslist.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.RUNNING_TASK);
            } else {
                ArgList.remove(SDConstant.RUNNING_TASK);
            }
        }
    });
    chckbxProcesslist.setBounds(109, 242, 243, 23);
    contentPane.add(chckbxProcesslist);
    chckbxProcesslist.setOpaque(false);

    chckbxTomcatxml = new JCheckBox("XML files from Tomcat");
    chckbxTomcatxml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                tomcatXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                tomcatXml = false;
            }
        }
    });
    chckbxTomcatxml.setBounds(377, 242, 248, 23);
    contentPane.add(chckbxTomcatxml);
    chckbxTomcatxml.setOpaque(false);

    chckbxServerXml = new JCheckBox("XML files from Server");
    chckbxServerXml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverXml = false;
            }
        }
    });
    chckbxServerXml.setBounds(377, 216, 248, 23);
    contentPane.add(chckbxServerXml);
    chckbxServerXml.setOpaque(false);

    chckbxGetBatfiles = new JCheckBox("Start up files from server");
    chckbxGetBatfiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverBatFile = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverBatFile = false;
            }
        }
    });
    chckbxGetBatfiles.setBounds(377, 268, 248, 23);
    contentPane.add(chckbxGetBatfiles);
    chckbxGetBatfiles.setOpaque(false);

    chckbxServerproperties = new JCheckBox("Properites files from server");
    chckbxServerproperties.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverProrperties = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverProrperties = false;
            }
        }
    });
    chckbxServerproperties.setBounds(377, 294, 248, 23);
    contentPane.add(chckbxServerproperties);
    chckbxServerproperties.setOpaque(false);

    btnNewButton = new JButton("Package");
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {

            try {

                if (installType.equalsIgnoreCase("Manual")) {

                    if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                        JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {

                        WEB_XML = new StringBuilder();
                        WEB_XML.append(prop.getProperty(SDConstant.BI_TOM_PATH)).append(File.separator)
                                .append(SDConstant.WEB_APP).append(File.separator).append(SDConstant.PENTAHO)
                                .append(File.separator).append(SDConstant.WEB_INF).append(File.separator)
                                .append(SDConstant.WEB_XML);

                        PENTAHO_SOLU_PATH = getSolutionPath("biserver", WEB_XML.toString());
                        prop.put(SDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
                        prop.put(SDConstant.BI_PATH, PENTAHO_SOLU_PATH);
                    }

                }

                if (prop.getProperty(SDConstant.BI_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_1, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                disableAll();
                setBIServerPath(prop);
                final String data = textFieldBrowser.getText();
                if (!data.equalsIgnoreCase(null)) {
                    ArgList.add(SDConstant.BROWSER);
                }

                String[] array = new String[ArgList.size()];

                int count = 0;
                for (int i = 0; i < ArgList.size(); i++) {

                    String retName = ArgList.get(i);
                    if (retName.equals("file")) {
                        if (count == 0) {
                            array[i] = retName;
                            count++;
                        }
                    } else {
                        array[i] = retName;
                    }

                }

                ApplicationContext context = new ClassPathXmlApplicationContext(SDConstant.SPRNG_FILE_NAME);

                factory = (CofingRetrieverFactory) context.getBean("cofingRetrieverFactory");
                ConfigRetreiver[] config = factory.getConfigRetrevier(array);

                ExecutorService service = Executors.newFixedThreadPool(10);

                for (final ConfigRetreiver configobj : config) {
                    if (null != configobj) {
                        configobj.setBISeverPath(prop);
                        configobj.setServerName("biserver");

                        if (installType.equalsIgnoreCase("Installer")) {
                            configobj.setInstallType("Installer");
                        } else if (installType.equalsIgnoreCase("Archive")) {
                            configobj.setInstallType("Archive");
                        } else if (installType.equalsIgnoreCase("Manual")) {
                            configobj.setInstallType("Manual");
                        }

                        if (configobj instanceof FileRetriever) {
                            configobj.setBidiXml(serverXml);
                            configobj.setBidiBatFile(serverBatFile);
                            configobj.setBidiProrperties(serverProrperties);
                            configobj.setTomcatXml(tomcatXml);
                        }
                        if (configobj instanceof BrowserInfoRetriever) {
                            configobj.setBrowserInfo(data);
                        }

                        service.execute(new Runnable() {
                            public void run() {
                                if (null != configobj)
                                    configobj.readAndSaveConfiguration(prop);
                            }
                        });
                    }
                }
                btnNewButton.setVisible(false);
                progressBar.setVisible(true);
                ProgressThread thread = new ProgressThread();
                thread.setSupport(getSupport());
                thread.setProp(prop);
                new Thread(thread).start();

                service.shutdown();
            } catch (Exception e1) {
                e1.printStackTrace();
            }

        }

    });

    chckbxSelectAll = new JCheckBox("Select/ De-select");
    chckbxSelectAll.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectAll();
            } else {
                deSelectAll();
            }
        }
    });

    chckbxSelectAll.setBounds(46, 138, 201, 23);
    chckbxSelectAll.setOpaque(false);
    contentPane.add(chckbxSelectAll);
    btnNewButton.setForeground(SystemColor.infoText);
    btnNewButton.setBounds(10, 430, 639, 37);
    contentPane.add(btnNewButton);
    chckbxServerproperties.setOpaque(false);

    JLabel lblAttach = new JLabel("Attach Artifact");
    lblAttach.setHorizontalAlignment(SwingConstants.LEFT);
    lblAttach.setBounds(32, 335, 177, 23);
    contentPane.add(lblAttach);
    lblAttach.setOpaque(false);

    JButton btnNewButtonBrowse = new JButton("Browse");
    btnNewButtonBrowse.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            saveSelectedFile(prop);

            JFrame parentFrame = new JFrame();
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setDialogTitle("Specify a file to save");
            fileChooser.setMultiSelectionEnabled(true);

            int userSelection = fileChooser.showSaveDialog(parentFrame);

            if (userSelection == JFileChooser.APPROVE_OPTION) {
                fileToSave = fileChooser.getSelectedFiles();
                for (int i = 0; i < fileToSave.length; i++) {
                    File file = fileToSave[i];
                    String artifactpath = file.getAbsolutePath();

                    File f = new File(artifactpath);
                    String absolutefilename = f.getName();
                    String filename = ArtifactsDirectory.concat(absolutefilename);
                    CopyFile artifactcopy = new CopyFile(artifactpath, filename);
                    try {
                        artifactcopy.copy();
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                }
                uploadedFiles();

                rowList = new JList(model);
                listScrollPane.setViewportView(rowList);
                panel.add(listScrollPane);

            }
            rowList.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    lblDelete.setVisible(true);
                }
            });

        }
    });
    btnNewButtonBrowse.setBounds(208, 335, 104, 23);
    contentPane.add(btnNewButtonBrowse);
    btnNewButtonBrowse.setOpaque(false);

    textFieldBrowser = new JTextField();
    textFieldBrowser.setBounds(208, 364, 441, 23);
    contentPane.add(textFieldBrowser);
    textFieldBrowser.setColumns(10);

    progressBar = new JProgressBar(0, 100);
    progressBar.setBounds(8, 437, 639, 24);
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    contentPane.add(progressBar);

    JLabel lblBrowserInformation = new JLabel("Browser Information");
    lblBrowserInformation.setHorizontalAlignment(SwingConstants.LEFT);
    lblBrowserInformation.setLabelFor(textFieldBrowser);
    lblBrowserInformation.setBounds(32, 368, 174, 14);
    contentPane.add(lblBrowserInformation);

    panel = new JPanel();
    panel.setBounds(423, 325, 127, 33);
    contentPane.add(panel);
    panel.setLayout(null);

    listScrollPane = new JScrollPane();
    listScrollPane.setBounds(0, 0, 127, 33);
    panel.add(listScrollPane);

    lblDelete = new JLabel("");
    lblDelete.setBounds(552, 325, 22, 23);
    lblDelete.setVisible(false);
    lblDelete.setIcon(
            new ImageIcon(SDSupportUtility.class.getResource("/org/pentaho/support/standalone/remove.png")));
    contentPane.add(lblDelete);
    lblDelete.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this file ?");
            if (option == JOptionPane.YES_OPTION) {
                String sel = rowList.getSelectedValue().toString();
                String selected = dir + "/" + sel;
                File fileExists = new File(selected);
                fileExists.delete();
                model.remove(sel.indexOf(sel));
                lblDelete.setVisible(false);

            }
        }
    });

    JLabel instalType = new JLabel("Installation Type : ");
    instalType.setBounds(32, 395, 177, 23);
    instalType.setVisible(true);
    contentPane.add(instalType);

    ButtonGroup btnGrp = new ButtonGroup();

    rdbtnInstaller = new JRadioButton("Installer");
    rdbtnInstaller.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Installer";
        }
    });
    rdbtnInstaller.setBounds(208, 395, 104, 23);
    rdbtnInstaller.setSelected(true);
    contentPane.add(rdbtnInstaller);
    btnGrp.add(rdbtnInstaller);

    rdbtnArchive = new JRadioButton("Archive");
    rdbtnArchive.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Archive";
        }
    });
    rdbtnArchive.setBounds(333, 395, 104, 23);
    contentPane.add(rdbtnArchive);
    btnGrp.add(rdbtnArchive);

    rdbtnManual = new JRadioButton("Manual");
    rdbtnManual.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Manual";
        }
    });
    rdbtnManual.setBounds(460, 395, 127, 27);
    contentPane.add(rdbtnManual);
    btnGrp.add(rdbtnManual);

    JLabel lblBackground = new JLabel();
    lblBackground.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/login-crystal-bg.jpg")));
    lblBackground.setBackground(SystemColor.controlHighlight);
    lblBackground.setHorizontalAlignment(SwingConstants.CENTER);
    lblBackground.setBounds(0, 0, 659, 488);
    contentPane.add(lblBackground);
}

From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java

private JPanel createGeneralTab() {
    JPanel jpGeneral = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    // All components to be anchored WEST
    c.anchor = GridBagConstraints.WEST;

    c.gridx = 0;//from   w w  w  . ja v a2 s.c om
    c.gridy = 0;
    c.gridwidth = 1;
    c.insets = new Insets(7, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    JLabel labelMethod = new JLabel("HTTP Method:", infoIcon, JLabel.LEFT);
    labelMethod.setToolTipText(
            "<html>HTTP method determines how a request to the remote server will be made.<br><br>"
                    + "Supported HTTP methods are normally used for different purposes:<br>"
                    + "<b>GET</b> - to fetch data;<br>" + "<b>POST</b> - to create new resources;<br>"
                    + "<b>PUT</b> - to update existing resources;<br>"
                    + "<b>DELETE</b> - to remove existing resources.<br><br>"
                    + "Documentation of the server that is about to be used may suggest the<br>"
                    + "HTTP method that should be used.</html>");
    jpGeneral.add(labelMethod, c);

    // the HTTP method combo-box will always contain the same values - it is
    // the selected
    // method which is important; therefore, can prepopulate as the set of
    // values is known
    c.gridx++;
    c.insets = new Insets(7, 3, 3, 7);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    cbHTTPMethod = new JComboBox<>(HTTP_METHOD.values());
    cbHTTPMethod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean contentTypeSelEnabled = RESTActivity
                    .hasMessageBodyInputPort((HTTP_METHOD) cbHTTPMethod.getSelectedItem());

            jlContentTypeExplanation.setVisible(contentTypeSelEnabled);
            jlContentType.setVisible(contentTypeSelEnabled);
            cbContentType.setVisible(contentTypeSelEnabled);
            jlSendDataAs.setVisible(contentTypeSelEnabled);
            cbSendDataAs.setVisible(contentTypeSelEnabled);

            jlContentTypeExplanationPlaceholder.setVisible(!contentTypeSelEnabled);
            jlContentTypeLabelPlaceholder.setVisible(!contentTypeSelEnabled);
            jlContentTypeFieldPlaceholder.setVisible(!contentTypeSelEnabled);
            jlSendDataAsLabelPlaceholder.setVisible(!contentTypeSelEnabled);
            jlSendDataAsFieldPlaceholder.setVisible(!contentTypeSelEnabled);
        }
    });
    jpGeneral.add(cbHTTPMethod, c);

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    JLabel labelString = new JLabel("URL Template:", infoIcon, JLabel.LEFT);
    labelString.setToolTipText("<html>URL template enables to define a URL with <b>configurable<br>"
            + "parameters</b> that will be used to access a remote server.<br><br>"
            + "The template may contain zero or more <b>parameters</b> - each<br>"
            + "enclosed within curly braces <b>\"{\"</b> and <b>\"}\"</b>.<br>"
            + "Taverna will automatically create an individual input port for<br>"
            + "this activity for each parameter.<br><br>"
            + "Values extracted from these input ports during the workflow<br>"
            + "execution these will be used to replace the parameters to<br>" + "produce complete URLs.<br><br>"
            + "For example, if the URL template is configured as<br>"
            + "\"<i>http://www.myexperiment.org/user.xml?id={userID}</i>\", a<br>"
            + "single input port with the name \"<i>userID</i>\" will be created.</html>");
    labelString.setLabelFor(tfURLSignature);
    jpGeneral.add(labelString, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    tfURLSignature = new JTextField(40);
    tfURLSignature.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            tfURLSignature.selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    jpGeneral.add(tfURLSignature, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(18, 7, 3, 7);
    JLabel jlAcceptsExplanation = new JLabel(
            "Preferred MIME type for data to be fetched from the remote server --");
    jpGeneral.add(jlAcceptsExplanation, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    JLabel jlAccepts = new JLabel("'Accept' header:", infoIcon, JLabel.LEFT);
    jlAccepts.setToolTipText(
            "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</br>");
    jlAccepts.setLabelFor(cbAccepts);
    jpGeneral.add(jlAccepts, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbAccepts = new JComboBox<>(getMediaTypes());
    cbAccepts.setEditable(true);
    cbAccepts.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            cbAccepts.getEditor().selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    jpGeneral.add(cbAccepts, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.insets = new Insets(18, 7, 3, 7);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeExplanation = new JLabel("MIME type of data that will be sent to the remote server --");
    jpGeneral.add(jlContentTypeExplanation, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentType = new JLabel("'Content-Type' header:", infoIcon, JLabel.LEFT);
    jlContentType.setToolTipText(
            "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</html>");
    jlContentType.setLabelFor(cbContentType);
    jpGeneral.add(jlContentType, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbContentType = new JComboBox<>(getMediaTypes());
    cbContentType.setEditable(true);
    cbContentType.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            cbContentType.getEditor().selectAll();
        }

        public void focusLost(FocusEvent e) { /* do nothing */
        }
    });
    cbContentType.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // change selection in the "Send data as" combo-box, based on
            // the selection of Content-Type
            String selectedContentType = (String) cbContentType.getSelectedItem();
            if (selectedContentType.startsWith("text")) {
                cbSendDataAs.setSelectedItem(DATA_FORMAT.String);
            } else {
                cbSendDataAs.setSelectedItem(DATA_FORMAT.Binary);
            }
        }
    });
    jpGeneral.add(cbContentType, c);

    c.gridx = 0;
    c.gridwidth = 2;
    c.gridy++;
    c.insets = new Insets(18, 7, 3, 7);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeExplanationPlaceholder = new JLabel();
    jlContentTypeExplanationPlaceholder.setPreferredSize(jlContentTypeExplanation.getPreferredSize());
    jpGeneral.add(jlContentTypeExplanationPlaceholder, c);
    c.gridwidth = 1;

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 3, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlContentTypeLabelPlaceholder = new JLabel();
    jlContentTypeLabelPlaceholder.setPreferredSize(jlContentType.getPreferredSize());
    jpGeneral.add(jlContentTypeLabelPlaceholder, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 3, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jlContentTypeFieldPlaceholder = new JLabel();
    jlContentTypeFieldPlaceholder.setPreferredSize(cbContentType.getPreferredSize());
    jpGeneral.add(jlContentTypeFieldPlaceholder, c);

    c.gridx = 0;
    c.gridy++;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(3, 7, 8, 3);
    jlSendDataAs = new JLabel("Send data as:", infoIcon, JLabel.LEFT);
    jlSendDataAs.setToolTipText("Select the format for the data to be sent to the remote server");
    jlSendDataAs.setLabelFor(cbSendDataAs);
    jpGeneral.add(jlSendDataAs, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 8, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    cbSendDataAs = new JComboBox<>(DATA_FORMAT.values());
    cbSendDataAs.setEditable(false);
    jpGeneral.add(cbSendDataAs, c);

    c.gridx = 0;
    c.gridy++;
    c.insets = new Insets(3, 7, 8, 3);
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    jlSendDataAsLabelPlaceholder = new JLabel();
    jlSendDataAsLabelPlaceholder.setPreferredSize(jlSendDataAs.getPreferredSize());
    jpGeneral.add(jlSendDataAsLabelPlaceholder, c);

    c.gridx++;
    c.insets = new Insets(3, 3, 8, 7);
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jlSendDataAsFieldPlaceholder = new JLabel();
    jlSendDataAsFieldPlaceholder.setPreferredSize(cbSendDataAs.getPreferredSize());
    jpGeneral.add(jlSendDataAsFieldPlaceholder, c);

    JPanel finalPanel = new JPanel(new BorderLayout());
    finalPanel.add(jpGeneral, BorderLayout.NORTH);
    return (finalPanel);
}