Example usage for javax.swing JTextField getText

List of usage examples for javax.swing JTextField getText

Introduction

In this page you can find the example usage for javax.swing JTextField getText.

Prototype

public String getText() 

Source Link

Document

Returns the text contained in this TextComponent.

Usage

From source file:com.osparking.osparking.Settings_System.java

private boolean someIPaddressWrong() {
    InetAddressValidator validator = InetAddressValidator.getInstance();

    for (int i = 0; i < gateCount; i++) {
        JTextField txtField;

        for (DeviceType devType : DeviceType.values()) {
            String devName = devType.toString();
            txtField = (JTextField) getComponentByName(devName + (i + 1) + "_IP_TextField");
            if (!validator.isValidInet4Address(txtField.getText())) {
                GatesTabbedPane.setSelectedIndex(i);
                txtField.requestFocusInWindow();
                JOptionPane.showConfirmDialog(this,
                        devType.getContent() + " #" + (i + 1) + " " + IP_ADDR_ERROR_1.getContent()
                                + System.lineSeparator() + IP_ADDR_ERROR_2.getContent() + "127.0.0.1",
                        IP_ERROR_TITLE.getContent(), JOptionPane.PLAIN_MESSAGE, WARNING_MESSAGE);
                return true;
            }// w ww .ja  v  a 2 s  .  c  o  m
        }
    }
    return false;
}

From source file:org.cds06.speleograph.graph.GraphEditor.java

/**
 * Creates a modal dialog by specifying the attached {@link GraphPanel}.
 * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p>
 *//* w w  w  . j a v a 2  s  .co  m*/
public GraphEditor(GraphPanel panel) {
    super((Frame) SwingUtilities.windowForComponent(panel), true);
    Validate.notNull(panel);
    this.graphPanel = panel;

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    mainPanel.registerKeyboardAction(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    setContentPane(mainPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.setTitle(I18nSupport.translate("menus.graph.graphEditor"));

    {
        // This section use FormLayout which is an external layout for Java, consult the doc before edit the
        // following lines !
        final FormLayout layout = new FormLayout(
                "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS
                "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS
        );

        PanelBuilder builder = new PanelBuilder(layout);

        final JLabel colorLabel = new JLabel();
        final JTextField titleForGraph = new JTextField(
                graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : "");
        final JLabel colorXYPlotLabel = new JLabel();
        final JLabel colorGridLabel = new JLabel();
        final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende",
                graphPanel.getChart().getLegend().isVisible());

        {
            builder.addLabel("Titre :", "1,1");
            builder.add(titleForGraph, "3,1,7,1");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3");
            colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorLabel.setText(" ");
            colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint());
            colorLabel.setOpaque(true);
            colorLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorLabel.getBackground());
                    if (c != null) {
                        colorLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorLabel, "3,3,5,1");
            builder.add(edit, "9,3");
        }

        final XYPlot xyPlot = graphPanel.getChart().getXYPlot();
        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5");
            colorXYPlotLabel.setText(" ");
            colorXYPlotLabel.setOpaque(true);
            colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint());
            colorXYPlotLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorXYPlotLabel.getBackground());
                    if (c != null) {
                        colorXYPlotLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorXYPlotLabel, "3,5,5,1");
            builder.add(edit, "9,5");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7");
            colorGridLabel.setOpaque(true);
            colorGridLabel.setText(" ");
            colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint());
            colorGridLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorGridLabel.getBackground());
                    if (c != null) {
                        colorGridLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorGridLabel, "3,7,5,1");
            builder.add(edit, "9,7");
        }

        {
            builder.add(showLegendCheckBox, "1,9,9,1");
        }

        mainPanel.add(builder.build(), BorderLayout.CENTER);

        ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder();

        buttonBarBuilder.addGlue();

        buttonBarBuilder.addButton(new AbstractAction() {
            {
                putValue(NAME, I18nSupport.translate("cancel"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                GraphEditor.this.setVisible(false);
            }
        });

        buttonBarBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("ok"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (titleForGraph.getText().isEmpty())
                    graphPanel.getChart().setTitle((String) null);
                else
                    graphPanel.getChart().setTitle(titleForGraph.getText());
                {
                    Color c = colorGridLabel.getBackground();
                    xyPlot.setRangeGridlinePaint(c);
                    xyPlot.setRangeMinorGridlinePaint(c);
                    xyPlot.setDomainGridlinePaint(c);
                    xyPlot.setDomainMinorGridlinePaint(c);
                }
                graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground());
                xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground());
                graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected());
                GraphEditor.this.setVisible(false);
            }
        });

        mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH);
    }

    pack();
    Dimension d = this.getPreferredSize();
    this.setSize(new Dimension(d.width + 20, d.height));
    setResizable(false);
}

From source file:eu.apenet.dpt.standalone.gui.eag2012.EagAccessAndServicesPanel.java

@Override
protected JComponent buildEditorPanel(List<String> errors) {
    if (errors == null)
        errors = new ArrayList<String>(0);
    else if (Utilities.isDev && errors.size() > 0) {
        LOG.info("Errors in form:");
        for (String error : errors) {
            LOG.info(error);//from  ww w .j  a  v a 2 s  .  com
        }
    }

    FormLayout layout = new FormLayout("right:max(50dlu;p), 4dlu, 100dlu, 7dlu, right:p, 4dlu, 100dlu",
            EDITOR_ROW_SPEC);

    layout.setColumnGroups(new int[][] { { 1, 3, 5, 7 } });
    PanelBuilder builder = new PanelBuilder(layout);

    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();

    rowNb = 1;

    Repository repository = eag.getArchguide().getDesc().getRepositories().getRepository().get(repositoryNb);

    //opening hours
    if (repository.getTimetable().getOpening().size() == 0) {
        repository.getTimetable().getOpening().add(new Opening());
    }
    openingHoursTfs = new ArrayList<TextAreaWithLanguage>(repository.getTimetable().getOpening().size());
    for (int i = 0; i < repository.getTimetable().getOpening().size(); i++) {
        Opening opening = repository.getTimetable().getOpening().get(i);
        //remove * from second ahead
        if (i == 0)
            builder.addLabel(labels.getString("eag2012.commons.openingHours") + "*", cc.xy(1, rowNb));
        else
            builder.addLabel(labels.getString("eag2012.commons.openingHours"), cc.xy(1, rowNb));

        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(opening.getContent(),
                opening.getLang());
        openingHoursTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    if (errors.contains("openingHoursTfs")) {
        builder.add(createErrorLabel(labels.getString("eag2012.errors.openingHours")), cc.xy(1, rowNb));
        setNextRow();
    }
    //add opening hours button
    JButton addOpeningHoursBtn = new ButtonTab(labels.getString("eag2012.commons.addOpeningHours"));
    builder.add(addOpeningHoursBtn, cc.xy(1, rowNb));
    addOpeningHoursBtn.addActionListener(new AddOpeningHoursBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (repository.getTimetable().getClosing().size() == 0) {
        repository.getTimetable().getClosing().add(new Closing());
    }
    closingDatesTfs = new ArrayList<TextAreaWithLanguage>(repository.getTimetable().getClosing().size());
    for (Closing closing : repository.getTimetable().getClosing()) {
        builder.addLabel(labels.getString("eag2012.commons.closingDates"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(closing.getContent(),
                closing.getLang());
        closingDatesTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addClosingDatesBtn = new ButtonTab(labels.getString("eag2012.commons.addClosingDates"));
    builder.add(addClosingDatesBtn, cc.xy(1, rowNb));
    addClosingDatesBtn.addActionListener(new AddClosingDatesBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (repository.getDirections().size() == 0)
        repository.getDirections().add(new Directions());
    travellingDirectionsTfs = new ArrayList<TextAreaWithLanguage>(repository.getDirections().size());
    for (Directions directions : repository.getDirections()) {
        builder.addLabel(labels.getString("eag2012.accessAndServices.travellingDirections"), cc.xy(1, rowNb));
        String str = "";
        String citation = "";
        for (Object obj : directions.getContent()) {
            if (obj instanceof String) {
                str += (String) obj;
            } else if (obj instanceof Citation) {
                citation += ((Citation) obj).getHref();
            }
        }
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(str, directions.getLang(),
                citation);
        travellingDirectionsTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.accessAndServices.link"), cc.xy(1, rowNb));
        builder.add(textAreaWithLanguage.getExtraField(), cc.xy(3, rowNb));
        setNextRow();
        if (errors.contains("travellingDirectionsTfs")) {
            if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText()) && !StringUtils
                    .startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText())
                && !StringUtils.startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }

    JButton addTravellingDirectionsBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addTravellingDirections"));
    builder.add(addTravellingDirectionsBtn, cc.xy(1, rowNb));
    addTravellingDirectionsBtn.addActionListener(new AddTravellingDirectionsBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.commons.accessiblePublic") + "*", cc.xy(1, rowNb));
    if (Arrays.asList(yesOrNo).contains(repository.getAccess().getQuestion())) {
        accessiblePublicCombo.setSelectedItem(repository.getAccess().getQuestion());
    }
    builder.add(accessiblePublicCombo, cc.xy(3, rowNb));
    setNextRow();

    if (repository.getAccess().getRestaccess().size() == 0)
        repository.getAccess().getRestaccess().add(new Restaccess());
    restaccessTfs = new ArrayList<TextAreaWithLanguage>(repository.getAccess().getRestaccess().size());
    int last = repository.getAccess().getRestaccess().size() - 1;
    for (Restaccess restaccess : repository.getAccess().getRestaccess()) {
        builder.addLabel(labels.getString("eag2012.accessAndServices.accessRestrictions"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(restaccess.getContent(),
                restaccess.getLang());
        restaccessTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
        if (last-- == 0) {
            JButton addRestaccessBtn = new ButtonTab(
                    labels.getString("eag2012.commons.addFutherAccessInformation"));
            builder.add(addRestaccessBtn, cc.xy(1, rowNb));
            addRestaccessBtn.addActionListener(new AddRestaccessBtnAction(eag, tabbedPane, model));
            setNextRow();
        }
    }

    if (repository.getAccess().getTermsOfUse().size() == 0)
        repository.getAccess().getTermsOfUse().add(new TermsOfUse());
    termsOfUseTfs = new ArrayList<TextAreaWithLanguage>(repository.getAccess().getTermsOfUse().size());
    for (TermsOfUse termsOfUse : repository.getAccess().getTermsOfUse()) {
        builder.addLabel(labels.getString("eag2012.accessAndServices.termsOfUse"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(termsOfUse.getContent(),
                termsOfUse.getLang(), termsOfUse.getHref());
        termsOfUseTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.accessAndServices.link"), cc.xy(1, rowNb));
        builder.add(textAreaWithLanguage.getExtraField(), cc.xy(3, rowNb));
        setNextRow();
        if (errors.contains("termsOfUseTfs")) {
            if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText()) && !StringUtils
                    .startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText())
                && !StringUtils.startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }

    //ad further button
    JButton addTermsOfUseBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addFurtherTermsOfUse"));
    builder.add(addTermsOfUseBtn, cc.xy(1, rowNb));
    addTermsOfUseBtn.addActionListener(new addTermsOfUseBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.commons.disabledAccess") + "*", cc.xy(1, rowNb));
    if (repository.getAccessibility().size() > 0
            && Arrays.asList(yesOrNo).contains(repository.getAccessibility().get(0).getQuestion())) {
        facilitiesForDisabledCombo.setSelectedItem(repository.getAccessibility().get(0).getQuestion());
    }
    builder.add(facilitiesForDisabledCombo, cc.xy(3, rowNb));
    setNextRow();

    //facilities for disabled persons
    accessibilityTfs = new ArrayList<TextAreaWithLanguage>(repository.getAccessibility().size());
    for (Accessibility accessibility : repository.getAccessibility()) {
        builder.addLabel(labels.getString("eag2012.commons.disabledAccess.facilities"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(accessibility.getContent(),
                accessibility.getLang());
        accessibilityTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        if (last-- == 0) {
            JButton addAccessibilityBtn = new ButtonTab(
                    labels.getString("eag2012.yourinstitution.addInfoOnExistingFacilities"));
            builder.add(addAccessibilityBtn, cc.xy(7, rowNb));
            addAccessibilityBtn.addActionListener(new AddAccessibilityBtnAction(eag, tabbedPane, model));
        }
        setNextRow();
    }

    //add button
    JButton addFacilitiesForDisabledBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addFurtherFacilitiesForDisabled"));
    builder.add(addFacilitiesForDisabledBtn, cc.xy(1, rowNb));
    addFacilitiesForDisabledBtn
            .addActionListener(new addFacilitiesForDisabledBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.accessAndServices.searchroom"), cc.xyw(1, rowNb, 7));
    setNextRow();

    if (repository.getServices() == null)
        repository.setServices(new Services());
    if (repository.getServices().getSearchroom() == null)
        repository.getServices().setSearchroom(new Searchroom());
    Searchroom searchroom = repository.getServices().getSearchroom();

    if (searchroom.getContact() == null)
        searchroom.setContact(new Contact());

    //(searchroom.getContact().getTelephone()
    builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb));
    int i = 0;
    telephoneSearchroomTf = new ArrayList<JTextField>(searchroom.getContact().getTelephone().size());
    for (Telephone telephone : searchroom.getContact().getTelephone()) {
        JTextField telephoneTf = new JTextField(telephone.getContent());
        telephoneSearchroomTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        if (i++ == 0) {
            JButton addtelephoneSearchroomTfBtn = new ButtonTab(
                    labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
            addtelephoneSearchroomTfBtn
                    .addActionListener(new AddTelephoneSearchroomBtnAction(eag, tabbedPane, model));
            builder.add(addtelephoneSearchroomTfBtn, cc.xy(5, rowNb));
        }
        setNextRow();
    }
    if (searchroom.getContact().getTelephone().size() == 0) {
        JTextField telephoneTf = new JTextField();
        telephoneSearchroomTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        JButton addtelephoneSearchroomTfBtn = new ButtonTab(
                labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
        addtelephoneSearchroomTfBtn
                .addActionListener(new AddTelephoneSearchroomBtnAction(eag, tabbedPane, model));
        builder.add(addtelephoneSearchroomTfBtn, cc.xy(5, rowNb));
        setNextRow();
    }

    //searchroom.getContact().getEmail()
    emailSearchroomTf = new ArrayList<JTextField>(searchroom.getContact().getEmail().size());
    emailTitleSearchroomTf = new ArrayList<JTextField>(searchroom.getContact().getEmail().size());
    if (searchroom.getContact().getEmail().size() == 0)
        searchroom.getContact().getEmail().add(new Email());
    for (Email email : searchroom.getContact().getEmail()) {
        JTextField emailTf = new JTextField(email.getHref());
        JTextField emailTitleTf = new JTextField(email.getContent());
        emailSearchroomTf.add(emailTf);
        emailTitleSearchroomTf.add(emailTitleTf);
        builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb));
        builder.add(emailTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(emailTitleTf, cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addEmailSearchroomBtn = new ButtonTab(labels.getString("eag2012.commons.addEmail"));
    addEmailSearchroomBtn.addActionListener(new AddEmailSearchroomAction(eag, tabbedPane, model));
    builder.add(addEmailSearchroomBtn, cc.xy(1, rowNb));
    setNextRow();

    //searchroom.getWebpage()
    webpageSearchroomTf = new ArrayList<JTextField>(searchroom.getWebpage().size());
    webpageTitleSearchroomTf = new ArrayList<JTextField>(searchroom.getWebpage().size());
    if (searchroom.getWebpage().size() == 0)
        searchroom.getWebpage().add(new Webpage());
    for (Webpage webpage : searchroom.getWebpage()) {
        JTextField webpageTf = new JTextField(webpage.getHref());
        JTextField webpageTitleTf = new JTextField(webpage.getContent());
        webpageTitleSearchroomTf.add(webpageTitleTf);
        webpageSearchroomTf.add(webpageTf);
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(webpageTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(webpageTitleTf, cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("webpageSearchroomTf")) {
            if (StringUtils.isNotBlank(webpageTf.getText())
                    && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xyw(1, rowNb, 3));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(webpageTf.getText())
                && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                    cc.xyw(1, rowNb, 3));
            setNextRow();
        }
    }
    JButton addWebpageSearchroomBtn = new ButtonTab(labels.getString("eag2012.commons.addWebpage"));
    addWebpageSearchroomBtn.addActionListener(new AddWebpageSearchroomAction(eag, tabbedPane, model));
    builder.add(addWebpageSearchroomBtn, cc.xy(1, rowNb));
    setNextRow();

    if (searchroom.getWorkPlaces() == null)
        searchroom.setWorkPlaces(new WorkPlaces());
    builder.addLabel(labels.getString("eag2012.commons.workPlaces"), cc.xy(1, rowNb));
    try {
        workplacesSearchroomTf = new JTextField(searchroom.getWorkPlaces().getNum().getContent());
    } catch (NullPointerException npe) {
        workplacesSearchroomTf = new JTextField();
    }
    builder.add(workplacesSearchroomTf, cc.xy(3, rowNb));
    setNextRow();

    if (searchroom.getComputerPlaces() == null) {
        ComputerPlaces computerPlaces = new ComputerPlaces();
        Num num = new Num();
        num.setUnit("site");
        computerPlaces.setNum(num);
        searchroom.setComputerPlaces(computerPlaces);
    }
    builder.addLabel(labels.getString("eag2012.accessAndServices.computerPlaces"), cc.xy(1, rowNb));
    computerplacesSearchroomTf = new JTextField(searchroom.getComputerPlaces().getNum().getContent());
    builder.add(computerplacesSearchroomTf, cc.xy(3, rowNb));
    if (searchroom.getComputerPlaces().getDescriptiveNote() == null) {
        JButton addDescriptionBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addDescription"));
        builder.add(addDescriptionBtn, cc.xy(5, rowNb));
        addDescriptionBtn.addActionListener(new AddComputerplacesDescriptionBtnAction(eag, tabbedPane, model));
    }
    setNextRow();
    if (searchroom.getComputerPlaces().getDescriptiveNote() != null) {
        computerplacesDescriptionTfs = new ArrayList<TextFieldWithLanguage>(
                searchroom.getComputerPlaces().getDescriptiveNote().getP().size());
        for (P p : searchroom.getComputerPlaces().getDescriptiveNote().getP()) {
            builder.addLabel(labels.getString("eag2012.commons.computerplacesDescription"), cc.xy(1, rowNb));
            TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(p.getContent(),
                    p.getLang());
            computerplacesDescriptionTfs.add(textFieldWithLanguage);
            builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
            builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
            builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
            setNextRow();
        }
        JButton addDescriptionBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addDescription"));
        builder.add(addDescriptionBtn, cc.xy(5, rowNb));
        addDescriptionBtn.addActionListener(new AddComputerplacesDescriptionBtnAction(eag, tabbedPane, model));
        setNextRow();
    }

    if (searchroom.getMicrofilmPlaces() == null) {
        MicrofilmPlaces microfilmPlaces = new MicrofilmPlaces();
        Num num = new Num();
        num.setUnit("site");
        microfilmPlaces.setNum(num);
        searchroom.setMicrofilmPlaces(microfilmPlaces);
    }
    if (searchroom.getPhotographAllowance() == null) {
        searchroom.setPhotographAllowance(new PhotographAllowance());
    }
    builder.addLabel(labels.getString("eag2012.accessAndServices.microfilmPlaces"), cc.xy(1, rowNb));
    microfilmplacesSearchroomTf = new JTextField(searchroom.getMicrofilmPlaces().getNum().getContent());
    builder.add(microfilmplacesSearchroomTf, cc.xy(3, rowNb));
    builder.addLabel(labels.getString("eag2012.accessAndServices.photographAllowance"), cc.xy(5, rowNb));
    if (Arrays.asList(photographAllowance).contains(searchroom.getPhotographAllowance().getValue())) {
        photographAllowanceCombo.setSelectedItem(searchroom.getPhotographAllowance().getValue());
    } else {
        photographAllowanceCombo.setSelectedItem("---");
    }
    builder.add(photographAllowanceCombo, cc.xy(7, rowNb));
    setNextRow();

    if (searchroom.getReadersTicket().size() == 0)
        searchroom.getReadersTicket().add(new ReadersTicket());
    readersticketSearchroomTfs = new ArrayList<TextFieldWithLanguage>(searchroom.getReadersTicket().size());
    for (ReadersTicket readersTicket : searchroom.getReadersTicket()) {
        builder.addLabel(labels.getString("eag2012.accessAndServices.readersTicket"), cc.xy(1, rowNb));
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(readersTicket.getContent(),
                readersTicket.getLang(), readersTicket.getHref());
        readersticketSearchroomTfs.add(textFieldWithLanguage);
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.accessAndServices.link"), cc.xy(1, rowNb));
        builder.add(textFieldWithLanguage.getExtraField(), cc.xy(3, rowNb));
        setNextRow();
        if (errors.contains("readersticketSearchroomTfs")) {
            if (StringUtils.isNotBlank(textFieldWithLanguage.getExtraField().getText()) && !StringUtils
                    .startsWithAny(textFieldWithLanguage.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(textFieldWithLanguage.getExtraField().getText())
                && !StringUtils.startsWithAny(textFieldWithLanguage.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }
    JButton addReadersticketBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addReadersTicket"));
    builder.add(addReadersticketBtn, cc.xy(1, rowNb));
    addReadersticketBtn.addActionListener(new AddReadersticketBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (searchroom.getAdvancedOrders().size() == 0)
        searchroom.getAdvancedOrders().add(new AdvancedOrders());
    advancedordersSearchroomTfs = new ArrayList<TextFieldWithLanguage>(searchroom.getAdvancedOrders().size());
    for (AdvancedOrders advancedOrders : searchroom.getAdvancedOrders()) {
        builder.addLabel(labels.getString("eag2012.accessAndServices.advancedOrders"), cc.xy(1, rowNb));
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(advancedOrders.getContent(),
                advancedOrders.getLang(), advancedOrders.getHref());
        advancedordersSearchroomTfs.add(textFieldWithLanguage);
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.accessAndServices.link"), cc.xy(1, rowNb));
        builder.add(textFieldWithLanguage.getExtraField(), cc.xy(3, rowNb));
        setNextRow();
        if (errors.contains("advancedordersSearchroomTfs")) {
            if (StringUtils.isNotBlank(textFieldWithLanguage.getExtraField().getText()) && !StringUtils
                    .startsWithAny(textFieldWithLanguage.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(textFieldWithLanguage.getExtraField().getText())
                && !StringUtils.startsWithAny(textFieldWithLanguage.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }
    JButton addAdvancedordersBtn = new ButtonTab(labels.getString("eag2012.control.advancedOrders"));
    builder.add(addAdvancedordersBtn, cc.xy(1, rowNb));
    addAdvancedordersBtn.addActionListener(new AddAdvancedordersBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (searchroom.getResearchServices().size() == 0) {
        DescriptiveNote descriptiveNote = new DescriptiveNote();
        descriptiveNote.getP().add(new P());
        ResearchServices researchServices = new ResearchServices();
        researchServices.setDescriptiveNote(descriptiveNote);
        searchroom.getResearchServices().add(researchServices);
    }
    researchServicesSearchroomTfs = new ArrayList<TextFieldWithLanguage>(
            searchroom.getResearchServices().size());
    for (ResearchServices researchServices : searchroom.getResearchServices()) {
        if (researchServices.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            descriptiveNote.setP(new ArrayList<P>() {
                {
                    add(new P());
                }
            });
            researchServices.setDescriptiveNote(descriptiveNote);
        }
        builder.addLabel(labels.getString("eag2012.accessAndServices.researchServices"), cc.xy(1, rowNb));
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(
                researchServices.getDescriptiveNote().getP().get(0).getContent(),
                researchServices.getDescriptiveNote().getP().get(0).getLang());
        researchServicesSearchroomTfs.add(textFieldWithLanguage);
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addResearchservicesBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addResearchservices"));
    builder.add(addResearchservicesBtn, cc.xy(1, rowNb));
    addResearchservicesBtn.addActionListener(new AddResearchservicesBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.accessAndServices.library"), cc.xyw(1, rowNb, 7));
    setNextRow();

    if (repository.getServices().getLibrary() == null)
        repository.getServices().setLibrary(new Library());
    Library library = repository.getServices().getLibrary();

    if (library.getContact() == null)
        library.setContact(new Contact());

    //LibrarygetContact().getTelephone()
    builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb));
    i = 0;
    telephoneLibraryTf = new ArrayList<JTextField>(library.getContact().getTelephone().size());
    for (Telephone telephone : library.getContact().getTelephone()) {
        JTextField telephoneTf = new JTextField(telephone.getContent());
        telephoneLibraryTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        if (i++ == 0) {
            JButton addtelephoneLibraryTfBtn = new ButtonTab(
                    labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
            addtelephoneLibraryTfBtn
                    .addActionListener(new addTelephoneLibraryTfBtnAction(eag, tabbedPane, model));
            builder.add(addtelephoneLibraryTfBtn, cc.xy(5, rowNb));
        }
        setNextRow();
    }
    if (library.getContact().getTelephone().size() == 0) {
        JTextField telephoneTf = new JTextField();
        telephoneLibraryTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        JButton addtelephoneLibraryTfBtn = new ButtonTab(
                labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
        addtelephoneLibraryTfBtn.addActionListener(new addTelephoneLibraryTfBtnAction(eag, tabbedPane, model));
        builder.add(addtelephoneLibraryTfBtn, cc.xy(5, rowNb));
        setNextRow();
    }

    //library.getContact().getEmail()
    emailLibraryTf = new ArrayList<JTextField>(library.getContact().getEmail().size());
    emailTitleLibraryTf = new ArrayList<JTextField>(library.getContact().getEmail().size());
    if (library.getContact().getEmail().size() == 0)
        library.getContact().getEmail().add(new Email());
    for (Email email : library.getContact().getEmail()) {
        JTextField emailTf = new JTextField(email.getHref());
        JTextField emailTitleTf = new JTextField(email.getContent());
        emailLibraryTf.add(emailTf);
        emailTitleLibraryTf.add(emailTitleTf);
        builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb));
        builder.add(emailTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(emailTitleTf, cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addEmailLibraryBtn = new ButtonTab(labels.getString("eag2012.commons.addEmail"));
    addEmailLibraryBtn.addActionListener(new AddEmailLibraryAction(eag, tabbedPane, model));
    builder.add(addEmailLibraryBtn, cc.xy(1, rowNb));
    setNextRow();

    //library.getWebpage()
    webpageLibraryTf = new ArrayList<JTextField>(library.getWebpage().size());
    webpageTitleLibraryTf = new ArrayList<JTextField>(library.getWebpage().size());
    if (library.getWebpage().size() == 0)
        library.getWebpage().add(new Webpage());
    for (Webpage webpage : library.getWebpage()) {
        JTextField webpageTf = new JTextField(webpage.getHref());
        JTextField webpageTitleTf = new JTextField(webpage.getContent());
        webpageTitleLibraryTf.add(webpageTitleTf);
        webpageLibraryTf.add(webpageTf);
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(webpageTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(webpageTitleTf, cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("webpageLibraryTf")) {
            if (StringUtils.isNotBlank(webpageTf.getText())
                    && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xyw(1, rowNb, 3));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(webpageTf.getText())
                && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                    cc.xyw(1, rowNb, 3));
            setNextRow();
        }
    }
    JButton addEbpageLibraryBtn = new ButtonTab(labels.getString("eag2012.commons.addWebpage"));
    addEbpageLibraryBtn.addActionListener(new AddWebpageLibraryAction(eag, tabbedPane, model));
    builder.add(addEbpageLibraryBtn, cc.xy(1, rowNb));
    setNextRow();

    if (library.getMonographicpub() == null) {
        Monographicpub monographicpub = new Monographicpub();
        Num num = new Num();
        num.setUnit("site");
        monographicpub.setNum(num);
        library.setMonographicpub(monographicpub);
    }
    if (library.getSerialpub() == null) {
        Serialpub serialpub = new Serialpub();
        Num num = new Num();
        num.setUnit("site");
        serialpub.setNum(num);
        library.setSerialpub(serialpub);
    }
    builder.addLabel(labels.getString("eag2012.accessAndServices.monographicPublication"), cc.xy(1, rowNb));
    monographicPubLibraryTf = new JTextField(library.getMonographicpub().getNum().getContent());
    builder.add(monographicPubLibraryTf, cc.xy(3, rowNb));
    builder.addLabel(labels.getString("eag2012.accessAndServices.serialPublication"), cc.xy(5, rowNb));
    serialPubLibraryTf = new JTextField(library.getSerialpub().getNum().getContent());
    builder.add(serialPubLibraryTf, cc.xy(7, rowNb));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.accessAndServices.internetAccess"), cc.xyw(1, rowNb, 7));
    setNextRow();

    // public Internet access
    if (repository.getServices().getInternetAccess() == null) {
        DescriptiveNote descriptiveNote = new DescriptiveNote();
        descriptiveNote.getP().add(new P());
        InternetAccess internetAccess = new InternetAccess();
        internetAccess.setDescriptiveNote(descriptiveNote);
        repository.getServices().setInternetAccess(internetAccess);
    }
    InternetAccess internetAccess = repository.getServices().getInternetAccess();
    internetAccessDescTfs = new ArrayList<TextFieldWithLanguage>(
            internetAccess.getDescriptiveNote().getP().size());
    for (P p : internetAccess.getDescriptiveNote().getP()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(p.getContent(), p.getLang());
        internetAccessDescTfs.add(textFieldWithLanguage);
        builder.addLabel(labels.getString("eag2012.accessAndServices.description"), cc.xy(1, rowNb));
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addInternetAccessBtn = new ButtonTab(labels.getString("eag2012.isil.addInternetAccess"));
    builder.add(addInternetAccessBtn, cc.xy(1, rowNb));
    addInternetAccessBtn.addActionListener(new AddInternetAccessBtnAction(eag, tabbedPane, model));
    setNextRow();

    // technical services
    builder.addSeparator(labels.getString("eag2012.accessAndServices.technicalServices"), cc.xyw(1, rowNb, 7));
    setNextRow();
    builder.addSeparator(labels.getString("eag2012.accessAndServices.conservationLab"), cc.xyw(1, rowNb, 7));
    setNextRow();

    if (repository.getServices().getTechservices() == null)
        repository.getServices().setTechservices(new Techservices());
    if (repository.getServices().getTechservices().getRestorationlab() == null)
        repository.getServices().getTechservices().setRestorationlab(new Restorationlab());
    Restorationlab restorationlab = repository.getServices().getTechservices().getRestorationlab();

    if (restorationlab.getDescriptiveNote() == null)
        restorationlab.setDescriptiveNote(new DescriptiveNote());
    if (restorationlab.getDescriptiveNote().getP().size() == 0)
        restorationlab.getDescriptiveNote().getP().add(new P());

    // description for restoration
    descriptionRestorationServiceTfs = new ArrayList<TextFieldWithLanguage>(
            restorationlab.getDescriptiveNote().getP().size());
    for (P p : restorationlab.getDescriptiveNote().getP()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(p.getContent(), p.getLang());
        descriptionRestorationServiceTfs.add(textFieldWithLanguage);
        builder.addLabel(labels.getString("eag2012.accessAndServices.description"), cc.xy(1, rowNb));
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addDescriptionRestorationBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addDescriptionTranslation"), true);
    builder.add(addDescriptionRestorationBtn, cc.xy(1, rowNb));
    addDescriptionRestorationBtn
            .addActionListener(new AddDescriptionRestorationBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (restorationlab.getContact() == null)
        restorationlab.setContact(new Contact());

    //restorationlab.getContact().getTelephone()
    builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb));
    i = 0;
    telephoneRestorationlabTf = new ArrayList<JTextField>(restorationlab.getContact().getTelephone().size());
    for (Telephone telephone : restorationlab.getContact().getTelephone()) {
        JTextField telephoneTf = new JTextField(telephone.getContent());
        telephoneRestorationlabTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        if (i++ == 0) {
            JButton addtelephoneRestorationlabTfBtn = new ButtonTab(
                    labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
            addtelephoneRestorationlabTfBtn
                    .addActionListener(new AddTelephoneRestorationlabTfBtnAction(eag, tabbedPane, model));
            builder.add(addtelephoneRestorationlabTfBtn, cc.xy(5, rowNb));
        }
        setNextRow();
    }
    if (restorationlab.getContact().getTelephone().size() == 0) {
        JTextField telephoneTf = new JTextField();
        telephoneRestorationlabTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        JButton addtelephoneRestorationlabTfBtn = new ButtonTab(
                labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
        addtelephoneRestorationlabTfBtn
                .addActionListener(new AddTelephoneRestorationlabTfBtnAction(eag, tabbedPane, model));
        builder.add(addtelephoneRestorationlabTfBtn, cc.xy(5, rowNb));
        setNextRow();
    }

    //Restoration.getContact().getEmail()
    emailRestorationlabTf = new ArrayList<JTextField>(restorationlab.getContact().getEmail().size());
    emailTitleRestorationlabTf = new ArrayList<JTextField>(restorationlab.getContact().getEmail().size());
    if (restorationlab.getContact().getEmail().size() == 0)
        restorationlab.getContact().getEmail().add(new Email());
    for (Email email : restorationlab.getContact().getEmail()) {
        JTextField emailTf = new JTextField(email.getHref());
        JTextField emailTitleTf = new JTextField(email.getContent());
        emailRestorationlabTf.add(emailTf);
        emailTitleRestorationlabTf.add(emailTitleTf);
        builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb));
        builder.add(emailTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(emailTitleTf, cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addEmaiRestorationlabBtn = new ButtonTab(labels.getString("eag2012.commons.addEmail"));
    addEmaiRestorationlabBtn.addActionListener(new AddEmailRestorationAction(eag, tabbedPane, model));
    builder.add(addEmaiRestorationlabBtn, cc.xy(1, rowNb));
    setNextRow();

    //restorationlab.getWebpage()
    webpageRestorationlabTf = new ArrayList<JTextField>(restorationlab.getWebpage().size());
    webpageTitleRestorationlabTf = new ArrayList<JTextField>(restorationlab.getWebpage().size());
    if (restorationlab.getWebpage().size() == 0)
        restorationlab.getWebpage().add(new Webpage());
    for (Webpage webpage : restorationlab.getWebpage()) {
        JTextField webpageTf = new JTextField(webpage.getHref());
        JTextField webpageTitleTf = new JTextField(webpage.getContent());
        webpageTitleRestorationlabTf.add(webpageTitleTf);
        webpageRestorationlabTf.add(webpageTf);
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(webpageTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(webpageTitleTf, cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("webpageRestorationlabTf")) {
            if (StringUtils.isNotBlank(webpageTf.getText())
                    && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xyw(1, rowNb, 3));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(webpageTf.getText())
                && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                    cc.xyw(1, rowNb, 3));
            setNextRow();
        }
    }
    JButton addWebpageRestorationlabBtn = new ButtonTab(labels.getString("eag2012.commons.addWebpage"));
    addWebpageRestorationlabBtn.addActionListener(new AddWebpageRestorationAction(eag, tabbedPane, model));
    builder.add(addWebpageRestorationlabBtn, cc.xy(1, rowNb));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.accessAndServices.reproductionService"),
            cc.xyw(1, rowNb, 7));
    setNextRow();

    if (repository.getServices().getTechservices().getReproductionser() == null)
        repository.getServices().getTechservices().setReproductionser(new Reproductionser());
    Reproductionser reproductionser = repository.getServices().getTechservices().getReproductionser();

    if (reproductionser.getDescriptiveNote() == null)
        reproductionser.setDescriptiveNote(new DescriptiveNote());
    if (reproductionser.getDescriptiveNote().getP().size() == 0)
        reproductionser.getDescriptiveNote().getP().add(new P());

    descriptionReproductionServiceTfs = new ArrayList<TextFieldWithLanguage>(
            reproductionser.getDescriptiveNote().getP().size());
    for (P p : reproductionser.getDescriptiveNote().getP()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(p.getContent(), p.getLang());
        descriptionReproductionServiceTfs.add(textFieldWithLanguage);
        builder.addLabel(labels.getString("eag2012.accessAndServices.description"), cc.xy(1, rowNb));
        builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addDescriptionReproductionBtn = new ButtonTab(
            labels.getString("eag2012.accessAndServices.addDescriptionTranslation"), true);
    builder.add(addDescriptionReproductionBtn, cc.xy(1, rowNb));
    addDescriptionReproductionBtn
            .addActionListener(new AddDescriptionReproductionBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (reproductionser.getContact() == null)
        reproductionser.setContact(new Contact());

    builder.addLabel(labels.getString("eag2012.commons.telephone"), cc.xy(1, rowNb));
    i = 0;

    //reproductionser.getContact().getTelephone()
    telephoneReproductionServiceTf = new ArrayList<JTextField>(
            reproductionser.getContact().getTelephone().size());
    for (Telephone telephone : reproductionser.getContact().getTelephone()) {
        JTextField telephoneTf = new JTextField(telephone.getContent());
        telephoneReproductionServiceTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        if (i++ == 0) {
            JButton addtelephoneReproductionServiceTfBtn = new ButtonTab(
                    labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
            addtelephoneReproductionServiceTfBtn
                    .addActionListener(new AddTelephoneReproductionServiceTfBtnAction(eag, tabbedPane, model));
            builder.add(addtelephoneReproductionServiceTfBtn, cc.xy(5, rowNb));
        }
        setNextRow();
    }
    if (reproductionser.getContact().getTelephone().size() == 0) {
        JTextField telephoneTf = new JTextField();
        telephoneReproductionServiceTf.add(telephoneTf);
        builder.add(telephoneTf, cc.xy(3, rowNb));
        JButton addtelephoneRestorationlabTfBtn = new ButtonTab(
                labels.getString("eag2012.contact.addFurtherTelephoneNumbers"));
        addtelephoneRestorationlabTfBtn
                .addActionListener(new AddTelephoneReproductionServiceTfBtnAction(eag, tabbedPane, model));
        builder.add(addtelephoneRestorationlabTfBtn, cc.xy(5, rowNb));
        setNextRow();
    }

    //Reproductionser.getContact().getEmail()
    emailReproductionServiceTf = new ArrayList<JTextField>(reproductionser.getContact().getEmail().size());
    emailTitleReproductionServiceTf = new ArrayList<JTextField>(reproductionser.getContact().getEmail().size());
    if (reproductionser.getContact().getEmail().size() == 0)
        reproductionser.getContact().getEmail().add(new Email());
    for (Email email : reproductionser.getContact().getEmail()) {
        JTextField emailTf = new JTextField(email.getHref());
        JTextField emailTitleTf = new JTextField(email.getContent());
        emailReproductionServiceTf.add(emailTf);
        emailTitleReproductionServiceTf.add(emailTitleTf);
        builder.addLabel(labels.getString("eag2012.commons.email"), cc.xy(1, rowNb));
        builder.add(emailTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(emailTitleTf, cc.xy(7, rowNb));
        setNextRow();
    }
    JButton addEmaiReproductionServiceBtn = new ButtonTab(labels.getString("eag2012.commons.addEmail"));
    addEmaiReproductionServiceBtn
            .addActionListener(new AddEmailReproductionServiceBtnAction(eag, tabbedPane, model));
    builder.add(addEmaiReproductionServiceBtn, cc.xy(1, rowNb));
    setNextRow();

    //reproductionser.getWebpage()
    webpageReproductionServiceTf = new ArrayList<JTextField>(reproductionser.getWebpage().size());
    webpageTitleReproductionServiceTf = new ArrayList<JTextField>(reproductionser.getWebpage().size());
    if (reproductionser.getWebpage().size() == 0)
        reproductionser.getWebpage().add(new Webpage());
    for (Webpage webpage : reproductionser.getWebpage()) {
        JTextField webpageTf = new JTextField(webpage.getHref());
        JTextField webpageTitleTf = new JTextField(webpage.getContent());
        webpageTitleReproductionServiceTf.add(webpageTitleTf);
        webpageReproductionServiceTf.add(webpageTf);
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(webpageTf, cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(webpageTitleTf, cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("webpageReproductionServiceTf")) {
            if (StringUtils.isNotBlank(webpageTf.getText())
                    && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xyw(1, rowNb, 3));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(webpageTf.getText())
                && !StringUtils.startsWithAny(webpageTf.getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                    cc.xyw(1, rowNb, 3));
            setNextRow();
        }
    }
    JButton addWebpageReproductionserBtn = new ButtonTab(labels.getString("eag2012.commons.addWebpage"));
    addWebpageReproductionserBtn.addActionListener(new AddWebpageReproductionserAction(eag, tabbedPane, model));
    builder.add(addWebpageReproductionserBtn, cc.xy(1, rowNb));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.accessAndServices.microformServices"), cc.xy(1, rowNb));
    if (reproductionser.getMicroformser() == null)
        reproductionser.setMicroformser(new Microformser());
    if (Arrays.asList(yesOrNo).contains(reproductionser.getMicroformser().getQuestion())) {
        microformServicesCombo.setSelectedItem(reproductionser.getMicroformser().getQuestion());
    } else {
        microformServicesCombo.setSelectedItem("---");
    }
    builder.add(microformServicesCombo, cc.xy(3, rowNb));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.accessAndServices.photographServices"), cc.xy(1, rowNb));
    if (reproductionser.getPhotographser() == null)
        reproductionser.setPhotographser(new Photographser());
    if (Arrays.asList(yesOrNo).contains(reproductionser.getPhotographser().getQuestion())) {
        photographServicesCombo.setSelectedItem(reproductionser.getPhotographser().getQuestion());
    } else {
        photographServicesCombo.setSelectedItem("---");
    }
    builder.add(photographServicesCombo, cc.xy(3, rowNb));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.accessAndServices.digitalServices"), cc.xy(1, rowNb));
    if (reproductionser.getDigitalser() == null)
        reproductionser.setDigitalser(new Digitalser());
    if (Arrays.asList(yesOrNo).contains(reproductionser.getDigitalser().getQuestion())) {
        digitalServicesCombo.setSelectedItem(reproductionser.getDigitalser().getQuestion());
    } else {
        digitalServicesCombo.setSelectedItem("---");
    }
    builder.add(digitalServicesCombo, cc.xy(3, rowNb));
    setNextRow();

    builder.addLabel(labels.getString("eag2012.accessAndServices.photocopyServices"), cc.xy(1, rowNb));
    if (reproductionser.getPhotocopyser() == null)
        reproductionser.setPhotocopyser(new Photocopyser());
    if (Arrays.asList(yesOrNo).contains(reproductionser.getPhotocopyser().getQuestion())) {
        photocopyServicesCombo.setSelectedItem(reproductionser.getPhotocopyser().getQuestion());
    } else {
        photocopyServicesCombo.setSelectedItem("---");
    }
    builder.add(photocopyServicesCombo, cc.xy(3, rowNb));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.accessAndServices.recreationalServices"),
            cc.xyw(1, rowNb, 7));
    setNextRow();

    if (repository.getServices().getRecreationalServices() == null)
        repository.getServices().setRecreationalServices(new RecreationalServices());
    RecreationalServices recreationalServices = repository.getServices().getRecreationalServices();

    if (recreationalServices.getRefreshment() == null) {
        DescriptiveNote descriptiveNote = new DescriptiveNote();
        descriptiveNote.getP().add(new P());
        Refreshment refreshment = new Refreshment();
        refreshment.setDescriptiveNote(descriptiveNote);
        recreationalServices.setRefreshment(refreshment);
    }
    builder.addLabel(labels.getString("eag2012.accessAndServices.refreshment"), cc.xy(1, rowNb));
    refreshmentTf = new TextAreaWithLanguage(
            recreationalServices.getRefreshment().getDescriptiveNote().getP().get(0).getContent(),
            recreationalServices.getRefreshment().getDescriptiveNote().getP().get(0).getLang());
    builder.add(refreshmentTf.getTextField(), cc.xy(3, rowNb));
    builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
    builder.add(refreshmentTf.getLanguageBox(), cc.xy(7, rowNb));
    setNextRow();

    if (recreationalServices.getExhibition().size() == 0) {
        recreationalServices.getExhibition().add(new Exhibition());
    }
    exhibitionTfs = new ArrayList<TextAreaWithLanguage>(recreationalServices.getExhibition().size());
    for (Exhibition exhibition : recreationalServices.getExhibition()) {
        if (exhibition.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            descriptiveNote.getP().add(new P());
            exhibition.setDescriptiveNote(descriptiveNote);
            exhibition.setWebpage(new Webpage());
        }

        builder.addLabel(labels.getString("eag2012.accessAndServices.exhibition"), cc.xy(1, rowNb));
        if (exhibition.getWebpage() == null) {
            exhibition.setWebpage(new Webpage());
        }
        TextAreaWithLanguage exhibitionTf = new TextAreaWithLanguage(
                exhibition.getDescriptiveNote().getP().get(0).getContent(),
                exhibition.getDescriptiveNote().getP().get(0).getLang(), exhibition.getWebpage().getHref(),
                exhibition.getWebpage().getContent());
        exhibitionTfs.add(exhibitionTf);
        builder.add(exhibitionTf.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(exhibitionTf.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(exhibitionTf.getExtraField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(exhibitionTf.getSecondExtraField(), cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("exhibitionTfs")) {
            if (StringUtils.isNotBlank(exhibitionTf.getExtraField().getText())
                    && !StringUtils.startsWithAny(exhibitionTf.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(exhibitionTf.getExtraField().getText())
                && !StringUtils.startsWithAny(exhibitionTf.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }
    JButton addExhibitionsBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addExhibitions"));
    builder.add(addExhibitionsBtn, cc.xy(1, rowNb));
    addExhibitionsBtn.addActionListener(new AddExhibitionsBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (recreationalServices.getToursSessions().size() == 0) {
        recreationalServices.getToursSessions().add(new ToursSessions());
    }
    toursAndSessionsTfs = new ArrayList<TextAreaWithLanguage>(recreationalServices.getToursSessions().size());
    for (ToursSessions toursSessions : recreationalServices.getToursSessions()) {
        if (toursSessions.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            descriptiveNote.getP().add(new P());
            toursSessions.setDescriptiveNote(descriptiveNote);
            toursSessions.setWebpage(new Webpage());
        }
        builder.addLabel(labels.getString("eag2012.accessAndServices.toursAndSessions"), cc.xy(1, rowNb));
        if (toursSessions.getWebpage() == null) {
            toursSessions.setWebpage(new Webpage());
        }
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(
                toursSessions.getDescriptiveNote().getP().get(0).getContent(),
                toursSessions.getDescriptiveNote().getP().get(0).getLang(),
                toursSessions.getWebpage().getHref(), toursSessions.getWebpage().getContent());
        toursAndSessionsTfs.add(textAreaWithLanguage);
        builder.add(textAreaWithLanguage.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(textAreaWithLanguage.getExtraField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(textAreaWithLanguage.getSecondExtraField(), cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("toursAndSessionsTfs")) {
            if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText()) && !StringUtils
                    .startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(textAreaWithLanguage.getExtraField().getText())
                && !StringUtils.startsWithAny(textAreaWithLanguage.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }
    JButton addToursSessionsBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addToursSessions"));
    builder.add(addToursSessionsBtn, cc.xy(1, rowNb));
    addToursSessionsBtn.addActionListener(new AddToursSessionsBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (recreationalServices.getOtherServices().size() == 0) {
        recreationalServices.getOtherServices().add(new OtherServices());
    }
    otherServicesTfs = new ArrayList<TextAreaWithLanguage>(recreationalServices.getOtherServices().size());
    for (OtherServices otherServices : recreationalServices.getOtherServices()) {
        if (otherServices.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            otherServices.setDescriptiveNote(descriptiveNote);
        }
        if (otherServices.getDescriptiveNote().getP().size() == 0) {
            otherServices.getDescriptiveNote().getP().add(new P());
        }
        if (otherServices.getWebpage() == null) {
            otherServices.setWebpage(new Webpage());
        }
        builder.addLabel(labels.getString("eag2012.accessAndServices.otherServices"), cc.xy(1, rowNb));
        TextAreaWithLanguage otherServicesTf = new TextAreaWithLanguage(
                otherServices.getDescriptiveNote().getP().get(0).getContent(),
                otherServices.getDescriptiveNote().getP().get(0).getLang(),
                otherServices.getWebpage().getHref(), otherServices.getWebpage().getContent());
        otherServicesTfs.add(otherServicesTf);
        builder.add(otherServicesTf.getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(otherServicesTf.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
        builder.addLabel(labels.getString("eag2012.commons.webpage"), cc.xy(1, rowNb));
        builder.add(otherServicesTf.getExtraField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.linkTitle"), cc.xy(5, rowNb));
        builder.add(otherServicesTf.getSecondExtraField(), cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("otherServicesTfs")) {
            if (StringUtils.isNotBlank(otherServicesTf.getExtraField().getText())
                    && !StringUtils.startsWithAny(otherServicesTf.getExtraField().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(otherServicesTf.getExtraField().getText())
                && !StringUtils.startsWithAny(otherServicesTf.getExtraField().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }
    }
    JButton addOtherServicesBtn = new ButtonTab(labels.getString("eag2012.accessAndServices.addOtherServices"));
    builder.add(addOtherServicesBtn, cc.xy(1, rowNb));
    addOtherServicesBtn.addActionListener(new AddOtherServicesBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addSeparator("", cc.xyw(1, rowNb, 7));
    setNextRow();

    JButton exitBtn = new ButtonTab(labels.getString("eag2012.commons.exit"));
    builder.add(exitBtn, cc.xy(1, rowNb));
    exitBtn.addActionListener(new ExitBtnAction(eag, tabbedPane, model));

    JButton previousTabBtn = new ButtonTab(labels.getString("eag2012.commons.previousTab"));
    builder.add(previousTabBtn, cc.xy(3, rowNb));
    previousTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, false));

    JButton nextTabBtn = new ButtonTab(labels.getString("eag2012.commons.nextTab"));
    builder.add(nextTabBtn, cc.xy(5, rowNb));
    nextTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, true));

    setNextRow();
    JButton saveBtn = new ButtonTab(labels.getString("eag2012.commons.save"));
    builder.add(saveBtn, cc.xy(5, rowNb));
    saveBtn.addActionListener(new SaveBtnAction(eag, tabbedPane, model));

    setNextRow();
    builder.addSeparator("", cc.xyw(1, rowNb, 7));
    setNextRow();
    JButton previousInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.previousInstitution"));
    previousInstitutionTabBtn.addActionListener(new PreviousInstitutionTabBtnAction(eag, tabbedPane, model));
    builder.add(previousInstitutionTabBtn, cc.xy(1, rowNb));
    JButton nextInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.nextInstitution"));
    nextInstitutionTabBtn.addActionListener(new NextInstitutionTabBtnAction(eag, tabbedPane, model));
    builder.add(nextInstitutionTabBtn, cc.xy(5, rowNb));

    // Define the change tab listener.
    this.removeChangeListener();
    this.tabbedPane.addChangeListener(new ChangeTabListener(this.eag, this.tabbedPane, this.model, 3));

    JPanel panel = builder.getPanel();
    KeyboardFocusManager.getCurrentKeyboardFocusManager()
            .addPropertyChangeListener(new FocusManagerListener(panel));
    return panel;
}

From source file:com.marginallyclever.makelangelo.MainGUI.java

protected void AdjustSounds() {
    final JDialog driver = new JDialog(mainframe, translator.get("MenuSoundsTitle"), true);
    driver.setLayout(new GridBagLayout());

    final JTextField sound_connect = new JTextField(prefs.get("sound_connect", ""), 32);
    final JTextField sound_disconnect = new JTextField(prefs.get("sound_disconnect", ""), 32);
    final JTextField sound_conversion_finished = new JTextField(prefs.get("sound_conversion_finished", ""), 32);
    final JTextField sound_drawing_finished = new JTextField(prefs.get("sound_drawing_finished", ""), 32);

    final JButton change_sound_connect = new JButton(translator.get("MenuSoundsConnect"));
    final JButton change_sound_disconnect = new JButton(translator.get("MenuSoundsDisconnect"));
    final JButton change_sound_conversion_finished = new JButton(translator.get("MenuSoundsFinishConvert"));
    final JButton change_sound_drawing_finished = new JButton(translator.get("MenuSoundsFinishDraw"));

    //final JCheckBox allow_metrics = new JCheckBox(String.valueOf("I want to add the distance drawn to the // total"));
    //allow_metrics.setSelected(allowMetrics);

    final JButton cancel = new JButton(translator.get("Cancel"));
    final JButton save = new JButton(translator.get("Save"));

    GridBagConstraints c = new GridBagConstraints();
    //c.gridwidth=4;    c.gridx=0;  c.gridy=0;  driver.add(allow_metrics,c);

    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;//from w ww .  ja v  a2  s .  c  om
    c.gridx = 0;
    c.gridy = 3;
    driver.add(change_sound_connect, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 3;
    driver.add(sound_connect, c);
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 4;
    driver.add(change_sound_disconnect, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 4;
    driver.add(sound_disconnect, c);
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 5;
    driver.add(change_sound_conversion_finished, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 5;
    driver.add(sound_conversion_finished, c);
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 6;
    driver.add(change_sound_drawing_finished, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 3;
    c.gridx = 1;
    c.gridy = 6;
    driver.add(sound_drawing_finished, c);

    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 12;
    driver.add(save, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    c.gridx = 3;
    c.gridy = 12;
    driver.add(cancel, c);

    ActionListener driveButtons = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object subject = e.getSource();
            if (subject == change_sound_connect)
                sound_connect.setText(SelectFile());
            if (subject == change_sound_disconnect)
                sound_disconnect.setText(SelectFile());
            if (subject == change_sound_conversion_finished)
                sound_conversion_finished.setText(SelectFile());
            if (subject == change_sound_drawing_finished)
                sound_drawing_finished.setText(SelectFile());

            if (subject == save) {
                //allowMetrics = allow_metrics.isSelected();
                prefs.put("sound_connect", sound_connect.getText());
                prefs.put("sound_disconnect", sound_disconnect.getText());
                prefs.put("sound_conversion_finished", sound_conversion_finished.getText());
                prefs.put("sound_drawing_finished", sound_drawing_finished.getText());
                machineConfiguration.SaveConfig();
                driver.dispose();
            }
            if (subject == cancel) {
                driver.dispose();
            }
        }
    };

    change_sound_connect.addActionListener(driveButtons);
    change_sound_disconnect.addActionListener(driveButtons);
    change_sound_conversion_finished.addActionListener(driveButtons);
    change_sound_drawing_finished.addActionListener(driveButtons);

    save.addActionListener(driveButtons);
    cancel.addActionListener(driveButtons);
    driver.getRootPane().setDefaultButton(save);
    driver.pack();
    driver.setVisible(true);
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @return true if a valid query name was obtained from user
 *//*from w w  w.j  a va  2s  .  c om*/
protected boolean getQueryNameFromUser(final boolean saveAs) {
    DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
    try {
        String newQueryName = query.getName();
        String oldQueryName = query.getName();
        SpQuery fndQuery = null;
        boolean good = false;
        do {
            //if (QueryTask.askUserForInfo("Query", getResourceString("QB_DATASET_INFO"), query))
            //Using above method causes Hibernate 'Dirty Collection' issues for save as.
            //Currently the only info involved is the name so using a simple dialog box is good enuf.
            JTextField nameText = new JTextField(newQueryName);
            JLabel nameLbl = UIHelper.createLabel(getNameSavePrompt());
            PanelBuilder pane = new PanelBuilder(
                    new FormLayout("4dlu, p, 2dlu, fill:p:grow, 4dlu", "5dlu, p, 5dlu"));
            CellConstraints cc = new CellConstraints();
            pane.add(nameLbl, cc.xy(2, 2));
            pane.add(nameText, cc.xy(4, 2));
            CustomDialog cd = new CustomDialog((Frame) UIRegistry.getTopWindow(), getSaveDlgTitle(saveAs), true,
                    CustomDialog.OKCANCELHELP, pane.getPanel());
            cd.setHelpContext("QBSave");
            UIHelper.centerAndShow(cd);
            if (!cd.isCancelled()) {
                //newQueryName = query.getName();
                newQueryName = nameText.getText();
                if (StringUtils.isNotEmpty(newQueryName) && newQueryName.length() > 64) {
                    UIRegistry.getStatusBar().setErrorMessage(getResourceString("QB_NAME_TOO_LONG"));
                    UIRegistry.displayErrorDlg(getResourceString("QB_NAME_TOO_LONG"));
                } else if (StringUtils.isEmpty(newQueryName)) {
                    UIRegistry.getStatusBar().setErrorMessage(getResourceString("QB_ENTER_A_NAME"));
                    UIRegistry.displayErrorDlg(getResourceString("QB_ENTER_A_NAME"));
                } else if (!UIHelper.isValidNameForDB(newQueryName)) {
                    UIRegistry.displayErrorDlg(getResourceString("INVALID_CHARS_NAME"));
                    UIRegistry.displayLocalizedStatusBarError("INVALID_CHARS_NAME");
                    Toolkit.getDefaultToolkit().beep();
                } else {
                    fndQuery = session.getData(SpQuery.class, "name", newQueryName,
                            DataProviderSessionIFace.CompareType.Equals);
                    if (fndQuery != null) {
                        UIRegistry.getStatusBar().setErrorMessage(
                                String.format(getResourceString("QB_QUERY_EXISTS"), newQueryName));
                        UIRegistry.displayErrorDlg(
                                String.format(getResourceString("QB_QUERY_EXISTS"), newQueryName));
                    } else {
                        good = true;
                        query.setName(newQueryName);
                    }
                }
            } else {
                query.setName(oldQueryName);
                return false;
            }
        } while (!good);
    } catch (Exception ex) {
        UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex);
        log.error(ex);

    } finally {
        session.close();
    }
    UIRegistry.getStatusBar().setText("");
    if (isExportMapping) {
        schemaMapping.setMappingName(query.getName());
    }
    return true;
}

From source file:userinterface.graph.Histogram.java

/**
 * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram
 * to plot data on/*from w ww  .j  av a2  s .  c o m*/
 * 
 * @param defaultSeriesName
 * @param handler instance of {@link GUIGraphHandler}
 * @param minVal the min value in data cache
 * @param maxVal the max value in data cache
 * @return Either a new instance of a Histogram or an old one depending on what the user selects
 */

public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler,
        double minVal, double maxVal) {

    // make sure that the probabilities are valid
    if (maxVal > 1.0)
        maxVal = 1.0;
    if (minVal < 0.0)
        minVal = 0.0;

    // set properties for the dialog
    JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true);
    dialog.setLayout(new BorderLayout());

    JPanel p1 = new JPanel(new FlowLayout());
    p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Number of buckets"));

    JPanel p2 = new JPanel(new FlowLayout());
    p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Series name"));

    JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1));
    buckets.setToolTipText("Select the number of buckets for this Histogram");

    // provides the ability to select a new or an old histogram to plot the series on
    JTextField seriesName = new JTextField(defaultSeriesName);
    JRadioButton newSeries = new JRadioButton("New Histogram");
    JRadioButton existing = new JRadioButton("Existing Histogram");
    newSeries.setSelected(true);
    JPanel seriesSelectPanel = new JPanel();
    seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS));
    JPanel seriesTypeSelect = new JPanel(new FlowLayout());
    JPanel seriesOptionsPanel = new JPanel(new FlowLayout());
    seriesTypeSelect.add(newSeries);
    seriesTypeSelect.add(existing);
    JComboBox<String> seriesOptions = new JComboBox<>();
    seriesOptionsPanel.add(seriesOptions);
    seriesSelectPanel.add(seriesTypeSelect);
    seriesSelectPanel.add(seriesOptionsPanel);
    seriesSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to"));

    // provides ability to select the min/max range of the plot
    JLabel minValsLabel = new JLabel("Min range:");
    JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01));
    minVals.setToolTipText("Does not allow value more than the min value in the probabilities");
    JLabel maxValsLabel = new JLabel("Max range:");
    JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01));
    maxVals.setToolTipText("Does not allow value less than the max value in the probabilities");
    JPanel minMaxPanel = new JPanel();
    minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS));
    JPanel leftValsPanel = new JPanel(new BorderLayout());
    JPanel rightValsPanel = new JPanel(new BorderLayout());
    minMaxPanel.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range"));
    leftValsPanel.add(minValsLabel, BorderLayout.WEST);
    leftValsPanel.add(minVals, BorderLayout.CENTER);
    rightValsPanel.add(maxValsLabel, BorderLayout.WEST);
    rightValsPanel.add(maxVals, BorderLayout.CENTER);
    minMaxPanel.add(leftValsPanel);
    minMaxPanel.add(rightValsPanel);

    // fill the old histograms in the property dialog

    boolean found = false;
    for (int i = 0; i < handler.getNumModels(); i++) {

        if (handler.getModel(i) instanceof Histogram) {

            seriesOptions.addItem(handler.getGraphName(i));
            found = true;
        }

    }

    existing.setEnabled(found);
    seriesOptions.setEnabled(false);

    // the bottom panel
    JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton ok = new JButton("Plot");
    JButton cancel = new JButton("Cancel");

    // bind keyboard keys to plot and cancel buttons to improve usability

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = -7324877661936685228L;

        @Override
        public void actionPerformed(ActionEvent e) {

            ok.doClick();

        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ok");
    cancel.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = 2642213543774356676L;

        @Override
        public void actionPerformed(ActionEvent e) {

            cancel.doClick();

        }
    });

    //Action listener for the new series radio button
    newSeries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (newSeries.isSelected()) {

                existing.setSelected(false);
                seriesOptions.setEnabled(false);
                buckets.setEnabled(true);
                buckets.setToolTipText("Select the number of buckets for this Histogram");
                minVals.setEnabled(true);
                maxVals.setEnabled(true);
            }
        }
    });

    //Action listener for the existing series radio button
    existing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existing.isSelected()) {

                newSeries.setSelected(false);
                seriesOptions.setEnabled(true);
                buckets.setEnabled(false);
                minVals.setEnabled(false);
                maxVals.setEnabled(false);
                buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram");
            }

        }
    });

    //Action listener for the plot button
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            dialog.dispose();

            if (newSeries.isSelected()) {

                hist = new Histogram();
                hist.setNumOfBuckets((int) buckets.getValue());
                hist.setIsNew(true);

            } else if (existing.isSelected()) {

                String HistName = (String) seriesOptions.getSelectedItem();
                hist = (Histogram) handler.getModel(HistName);
                hist.setIsNew(false);

            }

            key = hist.addSeries(seriesName.getText());

            if (minVals.isEnabled() && maxVals.isEnabled()) {

                hist.setMinProb((double) minVals.getValue());
                hist.setMaxProb((double) maxVals.getValue());

            }
        }
    });

    //Action listener for the cancel button
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
            hist = null;
        }
    });

    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {

            hist = null;
        }
    });

    p1.add(buckets, BorderLayout.CENTER);

    p2.add(seriesName, BorderLayout.CENTER);

    options.add(ok);
    options.add(cancel);

    // add everything to the main panel of the dialog
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(seriesSelectPanel);
    mainPanel.add(p1);
    mainPanel.add(p2);
    mainPanel.add(minMaxPanel);

    // add main panel to the dialog
    dialog.add(mainPanel, BorderLayout.CENTER);
    dialog.add(options, BorderLayout.SOUTH);

    // set dialog properties
    dialog.setSize(320, 290);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setVisible(true);

    // return the user selected Histogram with the properties set
    return new Pair<Histogram, SeriesKey>(hist, key);
}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeClientesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeClientesMouseClicked
    // TODO add your handling code here:
    int fila = TablaDeClientes.getSelectedRow();
    int identificacion = (int) TablaDeClientes.getValueAt(fila, 0);

    final ControladorCliente controladorCliente = new ControladorCliente();
    ArrayList<Cliente> listaClientes = controladorCliente.obtenerClientes("", identificacion);
    final Cliente clienteActual = listaClientes.get(0);

    final JDialog dialogoEditar = new JDialog(this);

    dialogoEditar.setTitle("Editar clientes");
    dialogoEditar.setSize(600, 310);/*from  w ww .j  a  v a2s. com*/
    dialogoEditar.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Editar clientes");
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 4;
    c.insets = new Insets(15, 200, 40, 0);
    c.ipadx = 100;
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 5, 10, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    JLabel editarNombreClienteDialogo = new JLabel("Nombre:");
    panelDialogo.add(editarNombreClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarNombreClienteDialogo = new JTextField();
    valorEditarNombreClienteDialogo.setText(clienteActual.getNombre());
    panelDialogo.add(valorEditarNombreClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarCelularClienteDialogo = new JLabel("Celular:");
    panelDialogo.add(editarCelularClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);

    final JTextField valorEditarCelularClienteDialogo = new JTextField();
    valorEditarCelularClienteDialogo.setText(clienteActual.getNumero_celular());
    panelDialogo.add(valorEditarCelularClienteDialogo, c);
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 5, 10, 0);
    JLabel editarMontoClienteDialogo = new JLabel("Monto a prestar:");
    panelDialogo.add(editarMontoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 2;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 15, 10, 15);
    final JTextField valorEditarMontoClienteDialogo = new JTextField();
    valorEditarMontoClienteDialogo.setText(String.valueOf(clienteActual.getMonto_prestamo()));
    panelDialogo.add(valorEditarMontoClienteDialogo, c);

    c.gridx = 2;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 15, 10, 0);
    JLabel editarTelefonoClienteDialogo = new JLabel("Telefono:");
    panelDialogo.add(editarTelefonoClienteDialogo, c);

    c.gridx = 3;
    c.gridy = 1;
    c.gridwidth = 1;
    c.ipadx = 100;
    c.insets = new Insets(0, 0, 10, 0);
    final JTextField valorEditarTelefonoClienteDialogo = new JTextField();
    valorEditarTelefonoClienteDialogo.setText(clienteActual.getNumero_telefono());
    panelDialogo.add(valorEditarTelefonoClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.ipadx = 40;
    c.insets = new Insets(0, 0, 10, 0);

    JLabel editarAddressClienteDialogo = new JLabel("Direccin:");
    panelDialogo.add(editarAddressClienteDialogo, c);

    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 3;
    c.ipadx = 400;
    c.insets = new Insets(0, 15, 10, 0);
    final JTextField valorEditarAddressClienteDialogo = new JTextField();
    valorEditarAddressClienteDialogo.setText(clienteActual.getDireccion());
    panelDialogo.add(valorEditarAddressClienteDialogo, c);

    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.ipadx = 100;
    c.insets = new Insets(15, 40, 0, 0);
    JButton botonGuardarClienteDialogo = new JButton("Guardar");
    panelDialogo.add(botonGuardarClienteDialogo, c);

    c.gridx = 2;
    c.gridy = 4;
    c.gridwidth = 2;
    c.insets = new Insets(15, 40, 0, 0);
    c.ipadx = 100;

    JButton botonCerrarClienteDialogo = new JButton("Cancelar");
    panelDialogo.add(botonCerrarClienteDialogo, c);

    dialogoEditar.add(panelDialogo);

    botonCerrarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEditar.dispose();
        }
    });

    botonGuardarClienteDialogo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                clienteActual.setDireccion(valorEditarAddressClienteDialogo.getText());
                clienteActual.setMonto_prestamo(Double.parseDouble(valorEditarMontoClienteDialogo.getText()));
                clienteActual.setNombre(valorEditarNombreClienteDialogo.getText());
                clienteActual.setNumero_celular(valorEditarCelularClienteDialogo.getText());
                clienteActual.setNumero_telefono(valorEditarTelefonoClienteDialogo.getText());

                controladorCliente.editarCliente(clienteActual);
                JOptionPane.showMessageDialog(dialogoEditar, "Se ha editado el cliente xitosamente");
                dialogoEditar.dispose();

                //Refrescar busqueda actual
                String nombreCliente = nombreClienteBusqueda.getText();

                int identificacionClienteInt = 0;

                ControladorCliente controladorCliente = new ControladorCliente();

                ArrayList<Cliente> listaDeClientes = controladorCliente.obtenerClientes(nombreCliente,
                        identificacionClienteInt);

                //Agregar filas
                DefaultTableModel modelo = (DefaultTableModel) TablaDeClientes.getModel();

                for (int i = 0; i < modelo.getRowCount(); i++) {
                    modelo.removeRow(i);
                }
                modelo.setRowCount(0);
                for (int i = 0; i < listaDeClientes.size(); i++) {
                    Cliente cliente = listaDeClientes.get(i);
                    Object[] fila = new Object[4];
                    fila[0] = cliente.getCliente_id();
                    fila[1] = cliente.getNombre();
                    fila[2] = cliente.getMonto_prestamo();
                    //button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link "+i+"</U></FONT>"+ " to go to the Java website.</HTML>");

                    fila[3] = "Editar";
                    modelo.addRow(fila);

                }

                TablaDeClientes.setModel(modelo);

            } catch (Exception event) {

                JOptionPane.showMessageDialog(dialogoEditar, "El valor del monto debe ser numrico");

            }

        }
    });

    dialogoEditar.setVisible(true);
    /*Action mostrarMensaje;
     mostrarMensaje = new AbstractAction() {
     @Override
     public void actionPerformed(ActionEvent e) {
     JTable table = (JTable) e.getSource();
     int modelRow = Integer.valueOf(e.getActionCommand());
     ((DefaultTableModel) table.getModel()).removeRow(modelRow);
     }
     };
     ButtonColumn buttonColumn = new ButtonColumn(TablaDeClientes, mostrarMensaje, 3);
     buttonColumn.setMnemonic(KeyEvent.VK_E);*/
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private void openAnalyseDialog(final int chip) {
    JTextField optionsField = new JTextField();
    JTextField destinationField = new JTextField();

    // compute and try default names for options file.
    // In order : <firmware>.dfr.txt , <firmware>.txt , dfr.txt (or the same for dtx)
    File optionsFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath())
                    + ((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt"));
    if (!optionsFile.exists()) {
        optionsFile = new File(imageFile[chip].getParentFile(),
                FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".txt");
        if (!optionsFile.exists()) {
            optionsFile = new File(imageFile[chip].getParentFile(),
                    ((chip == Constants.CHIP_FR) ? "dfr.txt" : "dtx.txt"));
            if (!optionsFile.exists()) {
                optionsFile = null;/*w w  w .  j  a v  a2 s . c om*/
            }
        }
    }
    if (optionsFile != null) {
        optionsField.setText(optionsFile.getAbsolutePath());
    }

    // compute default name for output
    File outputFile = new File(imageFile[chip].getParentFile(),
            FilenameUtils.getBaseName(imageFile[chip].getAbsolutePath()) + ".asm");
    destinationField.setText(outputFile.getAbsolutePath());

    final JCheckBox writeOutputCheckbox = new JCheckBox("Write disassembly to file");

    final FileSelectionPanel destinationFileSelectionPanel = new FileSelectionPanel("Destination file",
            destinationField, false);
    destinationFileSelectionPanel.setFileFilter(".asm", "Assembly language file (*.asm)");
    writeOutputCheckbox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean writeToFile = writeOutputCheckbox.isSelected();
            destinationFileSelectionPanel.setEnabled(writeToFile);
            prefs.setWriteDisassemblyToFile(chip, writeToFile);
        }
    });

    writeOutputCheckbox.setSelected(prefs.isWriteDisassemblyToFile(chip));
    destinationFileSelectionPanel.setEnabled(prefs.isWriteDisassemblyToFile(chip));

    FileSelectionPanel fileSelectionPanel = new FileSelectionPanel(
            (chip == Constants.CHIP_FR) ? "Dfr options file" : "Dtx options file", optionsField, false);
    fileSelectionPanel.setFileFilter((chip == Constants.CHIP_FR) ? ".dfr.txt" : ".dtx.txt",
            (chip == Constants.CHIP_FR) ? "Dfr options file (*.dfr.txt)" : "Dtx options file (*.dtx.txt)");
    final JComponent[] inputs = new JComponent[] {
            //new FileSelectionPanel("Source file", sourceFile, false, dependencies),
            fileSelectionPanel, writeOutputCheckbox, destinationFileSelectionPanel,
            makeOutputOptionCheckBox(chip, OutputOption.STRUCTURE, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.ORDINAL, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.PARAMETERS, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.INT40, prefs.getOutputOptions(chip), true),
            makeOutputOptionCheckBox(chip, OutputOption.MEMORY, prefs.getOutputOptions(chip), true),
            new JLabel("(hover over the options for help. See also 'Tools/Options/Disassembler output')",
                    SwingConstants.CENTER) };

    if (JOptionPane.OK_OPTION == JOptionPane.showOptionDialog(this, inputs, "Choose analyse options",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, JOptionPane.DEFAULT_OPTION)) {
        String outputFilename = writeOutputCheckbox.isSelected() ? destinationField.getText() : null;
        boolean cancel = false;
        if (outputFilename != null) {
            if (new File(outputFilename).exists()) {
                if (JOptionPane.showConfirmDialog(this,
                        "File '" + outputFilename + "' already exists.\nDo you really want to overwrite it ?",
                        "File exists", JOptionPane.YES_NO_OPTION,
                        JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                    cancel = true;
                }
            }
        }
        if (!cancel) {
            AnalyseProgressDialog analyseProgressDialog = new AnalyseProgressDialog(this,
                    framework.getPlatform(chip).getMemory());
            analyseProgressDialog.startBackgroundAnalysis(chip, optionsField.getText(), outputFilename);
            analyseProgressDialog.setVisible(true);
        }
    }
}

From source file:interfaces.InterfazPrincipal.java

private void TablaDeFacturaProductoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TablaDeFacturaProductoMouseClicked
    final int fila = TablaDeFacturaProducto.getSelectedRow();
    final DefaultTableModel modeloTabla = (DefaultTableModel) TablaDeFacturaProducto.getModel();

    //int identificacion = (int) TablaDeFacturaProducto.getValueAt(fila, 0);        // TODO add your handling code here:
    final JDialog dialogoEdicionProducto = new JDialog(this);
    dialogoEdicionProducto.setTitle("Editar producto");
    dialogoEdicionProducto.setSize(250, 150);
    dialogoEdicionProducto.setResizable(false);

    JPanel panelDialogo = new JPanel();

    panelDialogo.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel editarTextoPrincipalDialogo = new JLabel("Editar producto");
    c.gridx = 0;/*from   w  w w.  j  ava2  s  .  co m*/
    c.gridy = 0;
    c.gridwidth = 3;
    c.insets = new Insets(15, 40, 10, 0);
    Font textoGrande = new Font("Arial", 1, 18);
    editarTextoPrincipalDialogo.setFont(textoGrande);
    panelDialogo.add(editarTextoPrincipalDialogo, c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridwidth = 0;

    c.gridy = 1;
    c.gridx = 0;
    JLabel textoUnidades = new JLabel("Unidades");
    panelDialogo.add(textoUnidades, c);

    c.gridy = 1;
    c.gridx = 1;
    c.gridwidth = 2;
    final JTextField valorUnidades = new JTextField();
    valorUnidades.setText(String.valueOf(modeloTabla.getValueAt(fila, 4)));

    panelDialogo.add(valorUnidades, c);

    c.gridwidth = 1;
    c.gridy = 2;
    c.gridx = 0;
    JButton guardarCambios = new JButton("Guardar");
    panelDialogo.add(guardarCambios, c);

    c.gridy = 2;
    c.gridx = 1;
    JButton eliminarProducto = new JButton("Eliminar");
    panelDialogo.add(eliminarProducto, c);

    c.gridy = 2;
    c.gridx = 2;
    JButton botonCancelar = new JButton("Cerrar");
    panelDialogo.add(botonCancelar, c);
    botonCancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialogoEdicionProducto.dispose();
        }
    });

    eliminarProducto.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            double precio = (double) modeloTabla.getValueAt(fila, 6);
            double precioActual = Double.parseDouble(valorActualFactura.getText());

            precioActual -= precio;
            valorActualFactura.setText(String.valueOf(precioActual));
            modeloTabla.removeRow(fila);

            dialogoEdicionProducto.dispose();

        }
    });
    guardarCambios.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                int numeroUnidades = Integer.parseInt(valorUnidades.getText());
                modeloTabla.setValueAt(numeroUnidades, fila, 4);

                double precioARestar = (double) modeloTabla.getValueAt(fila, 6);

                double valorUnitario = Double.parseDouble((String) modeloTabla.getValueAt(fila, 5));

                double precioNuevo = valorUnitario * numeroUnidades;

                modeloTabla.setValueAt(precioNuevo, fila, 6);
                double precioActual = Double.parseDouble(valorActualFactura.getText());
                precioActual -= precioARestar;
                precioActual += precioNuevo;
                valorActualFactura.setText(String.valueOf(precioActual));

                dialogoEdicionProducto.dispose();

            } catch (Exception eve) {
                JOptionPane.showMessageDialog(dialogoEdicionProducto, "Por favor ingrese un valor numrico");
            }
        }
    });

    dialogoEdicionProducto.add(panelDialogo);
    dialogoEdicionProducto.setVisible(true);
}

From source file:base.BasePlayer.Main.java

void setMenuBar() {
    //filemenu.addMouseListener(this);

    //toolmenu.addMouseListener(this);
    filemenu = new JMenu("File");
    toolmenu = new JMenu("Tools");
    help = new JMenu("Help");
    about = new JMenu("About");
    menubar = new JMenuBar();
    //help.addMouseListener(this);
    exit = new JMenuItem("Exit");
    manual = new JButton("Online manual");
    manual.addActionListener(new ActionListener() {

        @Override/*from   w  w  w  .j a  v a 2 s  .  c  o  m*/
        public void actionPerformed(ActionEvent arg0) {
            Main.gotoURL("https://baseplayer.fi/BPmanual");
        }

    });
    //   opensamples = new JMenuItem("Add samples");
    zoomout = new JButton("Zoom out");
    back = new JButton("<<");
    forward = new JButton(">>");
    manage = new JButton("Variant Manager");
    openvcfs = new JMenuItem("Add VCFs", open);
    openbams = new JMenuItem("Add BAMs", open);
    average = new JMenuItem("Coverage calculator");
    update = new JMenuItem("Update");
    update.setVisible(false);
    errorlog = new JMenuItem("View log");
    //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki");

    addURL = new JMenu("Add from URL");
    urlField = new JTextField("Enter URL");
    addtracks = new JMenuItem("Add tracks");
    fromURL = new JMenuItem("Add track from URL");
    addcontrols = new JMenuItem("Add controls");
    pleiadesButton = new JMenuItem("PLEIADES");
    saveProject = new JMenuItem("Save project");
    saveProjectAs = new JMenuItem("Save project as...");
    openProject = new JMenuItem("Open project");
    clear = new JMenuItem("Clear data");
    clearMemory = new JMenuItem("Clean memory");
    //   welcome = new JMenuItem("Welcome screen");
    filemenu.add(openvcfs);
    filemenu.add(openbams);
    variantCaller = new JMenuItem("Variant Caller");
    tbrowser = new JMenuItem("Table Browser");
    bconvert = new JMenuItem("BED converter");
    peakCaller = new JMenuItem("Peak Caller");
    addtracks = new JMenuItem("Add tracks", open);
    filemenu.add(addtracks);
    addcontrols = new JMenuItem("Add controls", open);
    filemenu.add(addcontrols);
    filemenu.add(fromURL);
    if (pleiades) {
        pleiadesButton.setPreferredSize(buttonDimension);
        pleiadesButton.addActionListener(this);

        filemenu.add(pleiadesButton);
    }

    filemenu.add(new JSeparator());
    openProject = new JMenuItem("Open project", open);
    filemenu.add(openProject);
    saveProject = new JMenuItem("Save project", save);
    filemenu.add(saveProject);
    saveProjectAs = new JMenuItem("Save project as...", save);
    filemenu.add(saveProjectAs);
    filemenu.add(new JSeparator());
    filemenu.add(genome);
    filemenu.add(update);
    filemenu.add(clear);
    filemenu.add(new JSeparator());
    filemenu.add(exit);
    exit.addActionListener(this);
    menubar.add(filemenu);
    manage.addActionListener(this);
    manage.addMouseListener(this);
    update.addActionListener(this);
    average.addActionListener(this);
    average.setEnabled(false);
    average.setToolTipText("No bam/cram files opened");
    tbrowser.addActionListener(this);
    bconvert.addActionListener(this);
    toolmenu.add(tbrowser);
    toolmenu.add(average);
    toolmenu.add(variantCaller);
    toolmenu.add(bconvert);
    fromURL.addMouseListener(this);
    fromURL.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            final JPopupMenu menu = new JPopupMenu();
            final JTextField area = new JTextField();
            JButton add = new JButton("Fetch");
            JLabel label = new JLabel("Paste track URL below");
            JScrollPane menuscroll = new JScrollPane();
            add.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        String urltext = area.getText().trim();
                        Boolean size = true;
                        if (urltext.contains("pleiades")) {
                            openPleiades(urltext);
                            return;
                        }
                        if (!FileRead.isTrackFile(urltext)) {
                            showError("The file format is not supported.\n"
                                    + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error");
                            return;

                        }
                        if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig")
                                && !urltext.toLowerCase().endsWith(".bb")
                                && !urltext.toLowerCase().endsWith(".bigbed")) {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                menu.setVisible(false);
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {

                                SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url);
                                TabixReader tabixReader = null;
                                String index = null;

                                try {
                                    if (stream.length() / (double) 1048576 >= Settings.settings
                                            .get("bigFile")) {
                                        size = false;
                                    }
                                    tabixReader = new TabixReader(urltext, urltext + ".tbi", stream);

                                    index = urltext + ".tbi";
                                    testurl = new URL(index);
                                    huc = (HttpURLConnection) testurl.openConnection();
                                    huc.setRequestMethod("HEAD");
                                    responseCode = huc.getResponseCode();

                                    if (responseCode == 404) {
                                        menu.setVisible(false);
                                        Main.showError("Index file (.tbi) not found in the URL.", "Error");

                                        return;
                                    }

                                } catch (Exception ex) {
                                    try {
                                        tabixReader = new TabixReader(urltext,
                                                urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream);
                                        index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi";
                                    } catch (Exception exc) {
                                        menu.setVisible(false);
                                        Main.showError("Could not read tabix file.", "Error");
                                    }
                                }
                                if (tabixReader != null && index != null) {
                                    stream.close();
                                    tabixReader.close();
                                    menu.setVisible(false);
                                    FileRead filereader = new FileRead();
                                    filereader.readBED(urltext, index, size);

                                }

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        } else {
                            URL url = null;
                            try {
                                url = new URL(urltext);
                            } catch (Exception ex) {
                                Main.showError("Please paste whole url (protocol included)", "Error");
                                return;
                            }
                            final URL testurl = url;
                            HttpURLConnection huc = (HttpURLConnection) testurl.openConnection();
                            huc.setRequestMethod("HEAD");
                            int responseCode = huc.getResponseCode();

                            if (responseCode != 404) {
                                menu.setVisible(false);
                                FileRead filereader = new FileRead();

                                filereader.readBED(urltext, "nan", true);

                            } else {
                                menu.setVisible(false);
                                Main.showError("Not a valid URL", "Error");
                            }

                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }

                }

            });
            area.setFont(Main.menuFont);
            //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz");
            menu.add(label);
            menu.add(menuscroll);
            menu.add(add);
            area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8));

            area.setCaretPosition(0);
            area.revalidate();
            menuscroll.getViewport().add(area);
            area.requestFocus();
            menu.pack();

            menu.show(frame, mouseX + 20, fromURL.getY());
        }

    });
    //toolmenu.add(peakCaller);
    variantCaller.setToolTipText("No bam/cram files opened");
    variantCaller.addActionListener(this);
    variantCaller.setEnabled(false);
    peakCaller.setEnabled(true);
    peakCaller.addActionListener(this);
    settings.addActionListener(this);
    clearMemory.addActionListener(this);
    errorlog.addActionListener(this);
    toolmenu.add(clearMemory);
    toolmenu.add(errorlog);
    toolmenu.add(new JSeparator());
    toolmenu.add(settings);
    menubar.add(toolmenu);
    menubar.add(manage);
    area = new JEditorPane();

    String infotext = "<html><h2>BasePlayer</h2>This is a version " + version
            + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>"
            + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> "
            + "Contact: help@baseplayer.fi <br/> <br/>"

            + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> "
            + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> "
            + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> "

            + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> "
            + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>"
            + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>"
            + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>"
            + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>"
            + "on the same track.<br/><br/>"
            + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>";
    area = new JEditorPane();
    area.setEditable(false);
    area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
    area.setText(infotext);
    area.setFont(Main.menuFont);
    area.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
            HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
            final URL url = hyperlinkEvent.getURL();
            if (type == HyperlinkEvent.EventType.ACTIVATED) {
                Main.gotoURL(url.toString());
            }
        }
    });

    about.add(area);
    about.addMouseListener(this);
    help.add(about);
    help.add(manual);
    menubar.add(help);
    JLabel emptylab = new JLabel("  ");
    emptylab.setEnabled(false);
    emptylab.setOpaque(false);
    menubar.add(emptylab);

    chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray));
    chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    chromlabel.setToolTipText("Current chromosome");
    chromlabel.setFocusable(false);
    chromlabel.addMouseListener(this);
    chromlabel.setBackground(Color.white);
    chromlabel.setEditable(false);
    chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray));
    chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(chromlabel);
    chromosomeDropdown.setBackground(Color.white);
    chromosomeDropdown.setToolTipText("Current chromosome");
    menubar.add(chromosomeDropdown);
    JLabel empty3 = new JLabel("  ");
    empty3.setEnabled(false);
    empty3.setOpaque(false);
    menubar.add(empty3);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));

    searchField.addMouseListener(this);
    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);

    back.addMouseListener(this);
    back.setToolTipText("Back");
    forward.addMouseListener(this);
    forward.setToolTipText("Forward");
    back.setEnabled(false);
    forward.setEnabled(false);

    searchField.addMouseListener(this);

    menubar.add(back);
    menubar.add(searchField);
    searchField.setForeground(Color.gray);
    back.addMouseListener(this);
    forward.addMouseListener(this);
    back.setEnabled(false);
    forward.setEnabled(false);
    forward.setMargin(new Insets(0, 2, 0, 2));
    back.setMargin(new Insets(0, 2, 0, 2));
    menubar.add(forward);
    JLabel empty4 = new JLabel("  ");
    empty4.setOpaque(false);
    empty4.setEnabled(false);
    menubar.add(empty4);
    menubar.add(zoomout);
    JLabel empty5 = new JLabel("  ");
    empty5.setEnabled(false);
    empty5.setOpaque(false);
    menubar.add(empty5);
    positionField.setEditable(false);
    positionField.setBackground(new Color(250, 250, 250));

    positionField.setMargin(new Insets(0, 2, 0, 0));
    positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    menubar.add(positionField);
    widthLabel.setEditable(false);
    widthLabel.setBackground(new Color(250, 250, 250));
    widthLabel.setMargin(new Insets(0, 2, 0, 0));
    widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(),
            BorderFactory.createEmptyBorder(0, 0, 0, 0)));
    JLabel empty6 = new JLabel("  ");
    empty6.setEnabled(false);
    empty6.setOpaque(false);
    menubar.add(empty6);
    menubar.add(widthLabel);
    JLabel empty7 = new JLabel("  ");
    empty7.setOpaque(false);
    empty7.setEnabled(false);
    menubar.add(empty7);
}