Example usage for com.jgoodies.forms.layout CellConstraints xyw

List of usage examples for com.jgoodies.forms.layout CellConstraints xyw

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints xyw.

Prototype

public CellConstraints xyw(int col, int row, int colSpan) 

Source Link

Document

Sets the column, row, width, and height; uses a height (row span) of 1 and the horizontal and vertical default alignments.

Examples:

 cc.xyw(1, 3, 7); cc.xyw(1, 3, 2); 

Usage

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Method to build the main buttons zone.
 *
 * @param builder the PanelBuilder to add the buttons.
 * @param cc the constraints to use.//  w ww  .ja  v a 2 s .  c  om
 * @return the PanelBuilder with the buttons.
 */
private PanelBuilder buildButtons(PanelBuilder builder, CellConstraints cc) {
    // Row for the next and previous tab buttons.
    setNextRow();
    builder.addSeparator("", cc.xyw(1, this.rowNb, 7));
    setNextRow();
    JButton previousTabBtn = new ButtonTab(this.labels.getString("eaccpf.commons.previousTab"));
    builder.add(previousTabBtn, cc.xy(1, rowNb));
    previousTabBtn.addActionListener(new ChangeTabBtnAction(this.eaccpf, this.tabbedPane, this.model, false));

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

    // Row for exit and save buttons.
    setNextRow();
    JButton exitBtn = new ButtonTab(this.labels.getString("eaccpf.commons.exit"));
    builder.add(exitBtn, cc.xy(1, this.rowNb));
    exitBtn.addActionListener(new ExitBtnAction(this.eaccpf, this.tabbedPane, this.model));

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

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Method which builds biography parts/*from ww  w .j ava 2 s. com*/
 */
private PanelBuilder buildBiographiesForm(PanelBuilder builder, CellConstraints cc) {
    builder.addSeparator(this.labels.getString("eaccpf.description.biography"), cc.xyw(1, this.rowNb, 7));
    setNextRow();
    if (this.eaccpf.getCpfDescription() != null && this.eaccpf.getCpfDescription().getDescription() != null
            && this.eaccpf.getCpfDescription().getDescription().getBiogHist() != null) {
        builder = buildBiographies(builder, cc, this.eaccpf.getCpfDescription().getDescription().getBiogHist());
    } else {
        builder = buildBiography(builder, cc, null, null, true);
    }
    setNextRow();
    JButton jButtonAddFurtherBiographyDescription = new ButtonTab(
            this.labels.getString("eaccpf.description.button.addfurtherbiographydescription"));
    jButtonAddFurtherBiographyDescription
            .addActionListener(new AddFurtherBiographyDescriptionButton(this.eaccpf, this.tabbedPane, model));
    builder.add(jButtonAddFurtherBiographyDescription, cc.xy(1, rowNb));
    setNextRow();
    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * This method draw the different image's fields in the form
 *//*from  ww  w.jav a  2 s . c o  m*/
private PanelBuilder drawImageEacCpfForm(PanelBuilder builder, CellConstraints cc, String title,
        String language, String id, String link, String agencyName, Date dateResource,
        List<String> descriptiveNote, int index) {
    // Create elements.
    TextFieldWithLanguage resourceRelationTitle = null;
    JTextField resourceRelationIdentifier = null;
    JTextField resourceRelationLink = null;
    JTextField resourceRelationAgencyName = null;
    TextFieldsWithRadioButtonForDates resourceRelationDate = null;
    List<TextAreaWithLanguage> resourceRelationDescriptiveList = new ArrayList<TextAreaWithLanguage>();

    resourceRelationTitle = new TextFieldWithLanguage(title != null ? title : "",
            language != null ? language : "");
    resourceRelationIdentifier = new JTextField(id != null ? id : "");
    resourceRelationLink = new JTextField(link != null ? link : "");
    resourceRelationAgencyName = new JTextField(agencyName != null ? agencyName : "");
    if (descriptiveNote != null && !descriptiveNote.isEmpty()) {
        for (String content : descriptiveNote) {
            resourceRelationDescriptiveList.add(new TextAreaWithLanguage(content, ""));
        }
    } else {
        resourceRelationDescriptiveList.add(new TextAreaWithLanguage("", ""));
    }

    //dates
    if (dateResource == null) {
        dateResource = new Date();
    }

    boolean isDateUndefined = this.isUndefinedDate(dateResource.getLocalType());
    boolean isStillDate = (!isDateUndefined && dateResource.getLocalType() != null
            && (dateResource.getLocalType().equals("open")));
    resourceRelationDate = new TextFieldsWithRadioButtonForDates(
            this.labels.getString("eaccpf.commons.unknown.date"),
            this.labels.getString("eaccpf.commons.date.known"), "", dateResource.getContent(), isDateUndefined,
            isStillDate, isStillDate, dateResource.getStandardDate(), "", false, "", "", false, "", false);

    //instance elements if necessary
    if (this.resourcesRelationTitle == null) {
        this.resourcesRelationTitle = new ArrayList<TextFieldWithLanguage>();
    }
    if (this.resourcesRelationIdentifier == null) {
        this.resourcesRelationIdentifier = new ArrayList<JTextField>();
    }
    if (this.resourcesRelationLink == null) {
        this.resourcesRelationLink = new ArrayList<JTextField>();
    }
    if (this.resourcesRelationAgencyName == null) {
        this.resourcesRelationAgencyName = new ArrayList<JTextField>();
    }
    if (this.resourcesRelationDate == null) {
        this.resourcesRelationDate = new ArrayList<TextFieldsWithRadioButtonForDates>();
    }
    if (this.resourcesRelationDescriptive == null) {
        this.resourcesRelationDescriptive = new ArrayList<List<TextAreaWithLanguage>>();
    }
    // Add elements to the list.
    this.resourcesRelationTitle.add(resourceRelationTitle);
    this.resourcesRelationIdentifier.add(resourceRelationIdentifier);
    this.resourcesRelationLink.add(resourceRelationLink);
    this.resourcesRelationAgencyName.add(resourceRelationAgencyName);
    this.resourcesRelationDate.add(resourceRelationDate);
    this.resourcesRelationDescriptive.add(resourceRelationDescriptiveList);

    // Set title.
    setNextRow();
    builder.addSeparator(this.labels.getString("eaccpf.description.image"), cc.xyw(1, this.rowNb, 7));
    setNextRow();

    // Add elements to the panel.
    // Title and language.
    builder.addLabel(this.labels.getString("eaccpf.description.image.title"), cc.xy(1, this.rowNb));
    builder.add(resourceRelationTitle.getTextField(), cc.xy(3, this.rowNb));
    builder.addLabel(this.labels.getString("eaccpf.commons.select.language"), cc.xy(5, this.rowNb));
    builder.add(resourceRelationTitle.getLanguageBox(), cc.xy(7, this.rowNb));
    setNextRow();

    //Add the element id to the panel.
    builder.addLabel(this.labels.getString("eaccpf.description.image.identifier"), cc.xy(1, this.rowNb));
    builder.add(resourceRelationIdentifier, cc.xy(3, this.rowNb));
    setNextRow();

    //add link to the panel
    builder.addLabel(this.labels.getString("eaccpf.description.image.link") + "*", cc.xy(1, this.rowNb));
    builder.add(resourceRelationLink, cc.xy(3, this.rowNb));
    setNextRow();

    //add agencyName to the panel
    builder.addLabel(this.labels.getString("eaccpf.description.image.agencyName"), cc.xy(1, this.rowNb));
    builder.add(resourceRelationAgencyName, cc.xy(3, this.rowNb));
    setNextRow();

    //add date to the panel

    // First date row. Normal date text fields.
    builder.addLabel(this.labels.getString("eaccpf.description.image.date"), cc.xy(1, this.rowNb));
    resourceRelationDate.getDateTextField()
            .addFocusListener(new AddIsoText(resourceRelationDate, EacCpfIdentityPanel.UNKNOWN_DATE));
    builder.add(resourceRelationDate.getDateTextField(), cc.xy(3, this.rowNb));

    // Second date row. Unknown radiobuttons.
    setNextRow();
    resourceRelationDate.getDateDefinedRB()
            .addActionListener(new AddUndefinedTexts(resourceRelationDate, EacCpfIdentityPanel.KNOWN_DATE));
    builder.add(resourceRelationDate.getDateDefinedRB(), cc.xy(3, this.rowNb));

    setNextRow();
    resourceRelationDate.getDateUndefinedRB()
            .addActionListener(new AddUndefinedTexts(resourceRelationDate, EacCpfIdentityPanel.UNKNOWN_DATE));
    builder.add(resourceRelationDate.getDateUndefinedRB(), cc.xy(3, this.rowNb));
    setNextRow();

    // Third date row. Standard dates.

    builder.addLabel(this.labels.getString("eaccpf.commons.iso.date"), cc.xy(1, this.rowNb));
    resourceRelationDate.getStandardDateTextField()
            .addFocusListener(new CheckIsoText(resourceRelationDate, EacCpfIdentityPanel.UNKNOWN_DATE));
    builder.add(resourceRelationDate.getStandardDateTextField(), cc.xy(3, this.rowNb));
    setNextRow();

    //descriptiveNote in resourceRelation
    for (TextAreaWithLanguage resourceRelationDescriptive : resourceRelationDescriptiveList) {
        builder.addLabel(this.labels.getString("eaccpf.description.image.description"), cc.xy(1, this.rowNb));
        builder.add(resourceRelationDescriptive.getTextField(), cc.xyw(3, this.rowNb, 4));
        setNextRow();
    }
    //button to add more descriptions
    setNextRow();
    JButton jButtonAddFurtherImage = new ButtonTab(
            this.labels.getString("eaccpf.description.button.addfurtherDescriptionImage"));
    jButtonAddFurtherImage.addActionListener(
            new AddFurtherDescriptionImageButton(this.eaccpf, this.tabbedPane, model, index));
    builder.add(jButtonAddFurtherImage, cc.xy(1, rowNb));
    setNextRow();

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Build occupation parts (form)//from   w  ww. ja v  a  2s.c o  m
 */
private PanelBuilder buildOcupation(PanelBuilder builder, CellConstraints cc, Occupations ocupations,
        boolean isFirst) {

    if (ocupations != null && ocupations.getOccupation().size() > 0) {
        for (int i = 0; i < ocupations.getOccupation().size(); i++) {
            builder.addSeparator(this.labels.getString("eaccpf.description.ocupation"),
                    cc.xyw(1, this.rowNb, 7));
            setNextRow();

            Occupation ocupation = ocupations.getOccupation().get(i);
            builder = buildOcupationPlace(builder, cc, ocupation, i == 0);
            setNextRow();

            JButton jButtonAddFurtherPlaceOcupation = new ButtonTab(
                    this.labels.getString("eaccpf.description.button.addFurtherPlaceOcupation"));
            jButtonAddFurtherPlaceOcupation.addActionListener(
                    new AddFurtherPlaceOccupation(this.eaccpf, this.tabbedPane, this.model, i));
            builder.add(jButtonAddFurtherPlaceOcupation, cc.xy(1, rowNb));
            setNextRow();

            builder = buildOcupationDateSet(builder, cc, ocupation, i);
            setNextRow();
        }
    } else {
        builder.addSeparator(this.labels.getString("eaccpf.description.ocupation"), cc.xyw(1, this.rowNb, 7));
        setNextRow();

        builder = buildOcupationPlace(builder, cc, null, isFirst);
        setNextRow();

        JButton jButtonAddFurtherPlaceOcupation = new ButtonTab(
                this.labels.getString("eaccpf.description.button.addFurtherPlaceOcupation"));
        jButtonAddFurtherPlaceOcupation.addActionListener(
                new AddFurtherPlaceOccupation(this.eaccpf, this.tabbedPane, this.model, null));
        builder.add(jButtonAddFurtherPlaceOcupation, cc.xy(1, rowNb));
        setNextRow();

        builder = buildOcupationDateSet(builder, cc, null, 0);
        setNextRow();
    }

    JButton jButtonAddFurtherOcupation = new ButtonTab(
            this.labels.getString("eaccpf.description.button.addFurtherOcupation"));
    jButtonAddFurtherOcupation
            .addActionListener(new AddFurtherOccupation(this.eaccpf, this.tabbedPane, this.model));
    builder.add(jButtonAddFurtherOcupation, cc.xy(1, rowNb));
    setNextRow();

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Builds functions part (if there are severals or if there is none.
 * Also appends Add Further Places button.
 *//*from  w  ww . jav  a2 s .co  m*/
private PanelBuilder buildFunctions(PanelBuilder builder, CellConstraints cc, Functions functionObjects,
        boolean isFirst) {
    if (functionObjects != null && functionObjects.getFunction() != null
            && !functionObjects.getFunction().isEmpty()) {
        for (int i = 0; i < functionObjects.getFunction().size(); i++) {
            builder.addSeparator(this.labels.getString("eaccpf.description.function"),
                    cc.xyw(1, this.rowNb, 7));
            setNextRow();

            Function function = functionObjects.getFunction().get(i);
            builder = buildPlaceFunction(builder, cc, function, i == 0);
            setNextRow();

            JButton jButtonAddFurtherPlaceFunction = new ButtonTab(
                    this.labels.getString("eaccpf.description.button.addFurtherPlaceFunction"));
            jButtonAddFurtherPlaceFunction.addActionListener(
                    new AddFurtherPlaceFunction(this.eaccpf, this.tabbedPane, this.model, i));
            builder.add(jButtonAddFurtherPlaceFunction, cc.xy(1, rowNb));
            setNextRow();

            if (function.getDateSet() != null || function.getDateRange() != null
                    || function.getDate() != null) {
                builder = buildDatesOrDatesRangeFunctions(builder, cc, function, i);
                setNextRow();
            }
            builder = buildAddDateDateRangeLabelAndJButtons(builder, cc, FUNCTIONS, i, true);
        }
    } else {
        builder.addSeparator(this.labels.getString("eaccpf.description.function"), cc.xyw(1, this.rowNb, 7));
        setNextRow();

        builder = buildPlaceFunction(builder, cc, null, isFirst);
        setNextRow();

        JButton jButtonAddFurtherPlaceFunction = new ButtonTab(
                this.labels.getString("eaccpf.description.button.addFurtherPlaceFunction"));
        jButtonAddFurtherPlaceFunction
                .addActionListener(new AddFurtherPlaceFunction(this.eaccpf, this.tabbedPane, this.model, null));
        builder.add(jButtonAddFurtherPlaceFunction, cc.xy(1, rowNb));
        setNextRow();

        builder = buildDatesOrDatesRangeFunctions(builder, cc, null, 0);
        setNextRow();
        builder = buildAddDateDateRangeLabelAndJButtons(builder, cc, FUNCTIONS, 0, true);
    }

    JButton jButtonAddFurtherFunction = new ButtonTab(
            this.labels.getString("eaccpf.description.button.addFurtherFunction"));
    jButtonAddFurtherFunction
            .addActionListener(new AddFurtherFunction(this.eaccpf, this.tabbedPane, this.model));
    builder.add(jButtonAddFurtherFunction, cc.xy(1, rowNb));
    setNextRow();

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Method which builds genealogy part form.
 * It could load paragraph parts and language if object<StructureOrGenealogy> is used.
 *///from ww w  .  j  a v a2s. c  om
private PanelBuilder buildGenealogy(PanelBuilder builder, CellConstraints cc,
        StructureOrGenealogy structureOrGenealogy, boolean isFirst) {
    builder.addSeparator(this.labels.getString("eaccpf.description.genealogy"), cc.xyw(1, this.rowNb, 7));
    setNextRow();

    String content = "";
    String lang = "";
    TextAreaWithLanguage textFieldWithLanguage = null;
    if (structureOrGenealogy != null && structureOrGenealogy.getMDiscursiveSet() != null
            && !structureOrGenealogy.getMDiscursiveSet().isEmpty()) {
        List<Object> mDiscursiveSet = structureOrGenealogy.getMDiscursiveSet();
        for (int i = 0; i < mDiscursiveSet.size(); i++) {
            content = "";
            lang = "";
            Object paragraph = mDiscursiveSet.get(i);
            if (paragraph != null && paragraph instanceof P) {
                P p = (P) paragraph;
                content = ((P) p).getContent();
                lang = ((P) p).getLang();
                JLabel jLabelLinkDescriptionGenealogy = new JLabel(
                        this.labels.getString("eaccpf.description.description"));
                builder.add(jLabelLinkDescriptionGenealogy, cc.xy(1, rowNb));
                //                  textFieldWithLanguage = new TextFieldWithLanguage(content,lang);
                textFieldWithLanguage = new TextAreaWithLanguage(content != null ? content : "",
                        lang != null ? lang : "");
                ScrollPane genealogyTextField = textFieldWithLanguage.getTextField();
                builder.add(genealogyTextField, cc.xy(3, rowNb));
                addGenealogyTextField(textFieldWithLanguage);
                JLabel jLabelLanguageGenealogy = new JLabel(
                        this.labels.getString("eaccpf.description.selectlanguage"));
                builder.add(jLabelLanguageGenealogy, cc.xy(5, rowNb));
                JComboBox genealogyLanguageComboBox = textFieldWithLanguage.getLanguageBox();
                builder.add(genealogyLanguageComboBox, cc.xy(7, rowNb));
                addGenealogyLanguage(genealogyLanguageComboBox);
                setNextRow();
            }
        }
    } else {
        JLabel jLabelLinkDescriptionGenealogy = new JLabel(
                this.labels.getString("eaccpf.description.description"));
        builder.add(jLabelLinkDescriptionGenealogy, cc.xy(1, rowNb));
        //         JTextField jTextFieldLinkDescriptionGenealogy = new JTextField(content);
        //         builder.add(jTextFieldLinkDescriptionGenealogy, cc.xy (3, rowNb));
        TextAreaWithLanguage jTextFieldLinkDescriptionGenealogy = new TextAreaWithLanguage(content, "");
        builder.add(jTextFieldLinkDescriptionGenealogy.getTextField(), cc.xy(3, rowNb));
        addGenealogyTextField(jTextFieldLinkDescriptionGenealogy);
        JLabel jLabelLanguageGenealogy = new JLabel(this.labels.getString("eaccpf.description.selectlanguage"));
        builder.add(jLabelLanguageGenealogy, cc.xy(5, rowNb));
        JComboBox jComboboxLanguageGenealogy = buildLanguageJComboBox(/*isFirst*/);
        builder.add(jComboboxLanguageGenealogy, cc.xy(7, rowNb));
        addGenealogyLanguage(jComboboxLanguageGenealogy);
        setNextRow();
    }

    setNextRow();

    JButton jButtonAddFurtherGenealogyDescription = new ButtonTab(
            this.labels.getString("eaccpf.description.button.addfurthergenealogydescription"));
    jButtonAddFurtherGenealogyDescription
            .addActionListener(new AddFurtherGenealogy(this.eaccpf, this.tabbedPane, this.model));
    builder.add(jButtonAddFurtherGenealogyDescription, cc.xy(1, rowNb));
    setNextRow();

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Build occupations part form. //from w w w .j  a va2 s . co  m
 */
private PanelBuilder buildOcupationPlace(PanelBuilder builder, CellConstraints cc, Occupation occupation,
        boolean flag) {
    //first line
    JLabel jLabelOcupation = new JLabel(this.labels.getString("eaccpf.description.ocupation"));
    builder.add(jLabelOcupation, cc.xy(1, rowNb));
    TextFieldWithLanguage textFieldWithLanguage = null;
    if (occupation != null && occupation.getTerm() != null && occupation.getTerm().getContent() != null) {
        textFieldWithLanguage = new TextFieldWithLanguage(occupation.getTerm().getContent(),
                occupation.getTerm().getLang());
        JTextField textField = textFieldWithLanguage.getTextField();
        builder.add(textField, cc.xy(3, rowNb));
        addOcupationPlaceOcupationJTextField(textField);
    } else {
        JTextField jTextfieldOcupation = new JTextField();
        builder.add(jTextfieldOcupation, cc.xy(3, rowNb));
        addOcupationPlaceOcupationJTextField(jTextfieldOcupation);
    }

    JLabel jLabelLanguage = new JLabel(this.labels.getString("eaccpf.description.selectlanguage"));
    builder.add(jLabelLanguage, cc.xy(5, rowNb));
    if (textFieldWithLanguage != null) {
        JComboBox jComboBoxLanguage = textFieldWithLanguage.getLanguageBox();
        builder.add(jComboBoxLanguage, cc.xy(7, rowNb));
        addOcupationPlaceOcupationLanguageJComboBox(jComboBoxLanguage);
    } else {
        JComboBox jComboboxLanguage = buildLanguageJComboBox(/*flag*/);
        //         if(!flag){
        //            jComboboxLanguage.setSelectedItem("---");
        //         }
        builder.add(jComboboxLanguage, cc.xy(7, rowNb));
        addOcupationPlaceOcupationLanguageJComboBox(jComboboxLanguage);
    }
    setNextRow();
    //second line
    JLabel jLabelLinkOcupation = new JLabel(
            this.labels.getString("eaccpf.description.linktocontrolledocupations"));
    builder.add(jLabelLinkOcupation, cc.xy(1, rowNb));
    JTextField jLinkOcupationOcupation = new JTextField((occupation != null && occupation.getTerm() != null
            && occupation.getTerm().getVocabularySource() != null) ? occupation.getTerm().getVocabularySource()
                    : "");
    builder.add(jLinkOcupationOcupation, cc.xy(3, rowNb));
    addOcupationPlaceLinkToControlledVocabulary(jLinkOcupationOcupation);
    setNextRow();
    //third line
    JLabel jLabelLinkDescriptionOcupation = new JLabel(
            this.labels.getString("eaccpf.description.descriptionocupations"));
    builder.add(jLabelLinkDescriptionOcupation, cc.xy(1, rowNb));
    String content = "";
    if (occupation != null && occupation.getDescriptiveNote() != null
            && occupation.getDescriptiveNote().getP() != null) {
        for (P p : occupation.getDescriptiveNote().getP()) {
            if (p.getContent() != null) {
                content += p.getContent();
            }
        }
    }
    //      JTextField jTextFieldLinkDescriptionOcupation = new JTextField(content);
    TextAreaWithLanguage jTextFieldLinkDescriptionOcupation = new TextAreaWithLanguage(content, "");
    builder.add(jTextFieldLinkDescriptionOcupation.getTextField(), cc.xyw(3, this.rowNb, 4));
    addOcupationPlaceOcupationDescription(jTextFieldLinkDescriptionOcupation);
    setNextRow();

    textFieldWithLanguage = null;
    //each place entry, four part lines
    if (occupation != null && occupation.getPlaceEntry() != null && !occupation.getPlaceEntry().isEmpty()) {
        List<PlaceEntry> placeEntries = occupation.getPlaceEntry();
        for (int i = 0; i < placeEntries.size(); i++) {
            PlaceEntry placeEntry = placeEntries.get(i);
            JLabel jLabelOcupationPlace = new JLabel(this.labels.getString("eaccpf.description.place"));
            builder.add(jLabelOcupationPlace, cc.xy(1, rowNb));
            JTextField placeTextField = new JTextField(
                    (placeEntry.getContent() != null) ? placeEntry.getContent() : "");
            builder.add(placeTextField, cc.xy(3, rowNb));
            addOcupationPlacePlaceJTextField(i == 0, placeTextField);
            JLabel jLabelLanguageOcupationPlace = new JLabel(
                    this.labels.getString("eaccpf.description.country"));
            builder.add(jLabelLanguageOcupationPlace, cc.xy(5, rowNb));
            JComboBox placeCountryJComboBox = buildCountryJComboBox();
            if (placeEntry.getCountryCode() != null) {
                placeCountryJComboBox.setSelectedItem(parseIsoToCountry(placeEntry.getCountryCode()));
            }
            builder.add(placeCountryJComboBox, cc.xy(7, rowNb));
            addOcupationPlaceCountryPlaceJComboBoxes(i == 0, placeCountryJComboBox);
            setNextRow();
        }
    } else { //empty part
        JLabel jLabelOcupationPlace = new JLabel(this.labels.getString("eaccpf.description.place"));
        builder.add(jLabelOcupationPlace, cc.xy(1, rowNb));
        JTextField jTextfieldOcupationPlace = new JTextField();
        builder.add(jTextfieldOcupationPlace, cc.xy(3, rowNb));
        addOcupationPlacePlaceJTextField(true, jTextfieldOcupationPlace);
        JLabel jLabelLanguageOcupationPlace = new JLabel(this.labels.getString("eaccpf.description.country"));
        builder.add(jLabelLanguageOcupationPlace, cc.xy(5, rowNb));
        JComboBox placeCountryJComboBox = buildCountryJComboBox();
        builder.add(placeCountryJComboBox, cc.xy(7, rowNb));
        addOcupationPlaceCountryPlaceJComboBoxes(true, placeCountryJComboBox);
    }

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Build part of function form related to places.
 *///from ww w  . ja  v a 2 s.  com
private PanelBuilder buildPlaceFunction(PanelBuilder builder, CellConstraints cc, Function function,
        boolean flag) {
    //first line
    JLabel jLabelFunction = new JLabel(this.labels.getString("eaccpf.description.function"));
    builder.add(jLabelFunction, cc.xy(1, rowNb));
    TextFieldWithLanguage textFieldWithLanguage = null;
    if (function != null && function.getTerm() != null) {
        textFieldWithLanguage = new TextFieldWithLanguage(function.getTerm().getContent(),
                function.getTerm().getLang());
        JTextField textField = textFieldWithLanguage.getTextField();
        builder.add(textField, cc.xy(3, rowNb));
        addPlaceFunctionPlacesJTextfield(textField);
    } else {
        JTextField jTextfieldFunction = new JTextField();
        builder.add(jTextfieldFunction, cc.xy(3, rowNb));
        addPlaceFunctionPlacesJTextfield(jTextfieldFunction);
    }
    JLabel jLabelLanguage = new JLabel(this.labels.getString("eaccpf.description.selectlanguage"));
    builder.add(jLabelLanguage, cc.xy(5, rowNb));
    if (textFieldWithLanguage != null) {
        JComboBox languageBox = textFieldWithLanguage.getLanguageBox();
        builder.add(languageBox, cc.xy(7, rowNb));
        addPlaceFunctionLanguageJComboBox(languageBox);
    } else {
        JComboBox jComboboxLanguage = buildLanguageJComboBox(/*flag*/);
        //         if(!flag){
        //            jComboboxLanguage.setSelectedItem("---");
        //         }
        builder.add(jComboboxLanguage, cc.xy(7, rowNb));
        addPlaceFunctionLanguageJComboBox(jComboboxLanguage);
    }
    setNextRow();
    //second line
    JLabel jLabelVocabulary = new JLabel(this.labels.getString("eaccpf.description.linktovocabulary"));
    builder.add(jLabelVocabulary, cc.xy(1, rowNb));
    JTextField jTextfieldVocabularyLink = new JTextField(
            (function != null && function.getTerm() != null && function.getTerm().getVocabularySource() != null)
                    ? function.getTerm().getVocabularySource()
                    : "");
    builder.add(jTextfieldVocabularyLink, cc.xy(3, rowNb));
    addPlaceFunctionVocabularyJTextField(jTextfieldVocabularyLink);
    setNextRow();
    //third line
    JLabel jLabelDescription = new JLabel(this.labels.getString("eaccpf.description.descriptionfunction"));
    builder.add(jLabelDescription, cc.xy(1, rowNb));
    String content = "";
    if (function != null && function.getDescriptiveNote() != null
            && function.getDescriptiveNote().getP() != null) {
        List<P> paragraphs = function.getDescriptiveNote().getP();
        for (P p : paragraphs) {
            if (p.getContent() != null && !p.getContent().isEmpty()) {
                content += p.getContent();
            }
        }
    }
    TextAreaWithLanguage jTextFieldLinkDescriptionOcupation = new TextAreaWithLanguage(content, "");
    builder.add(jTextFieldLinkDescriptionOcupation.getTextField(), cc.xyw(3, this.rowNb, 4));
    addPlaceFunctionDescriptionTextfields(jTextFieldLinkDescriptionOcupation);
    setNextRow();
    //fourth part, each place and country for functions
    if (function != null && function.getPlaceEntry() != null && !function.getPlaceEntry().isEmpty()) {
        List<PlaceEntry> placeEntries = function.getPlaceEntry();
        for (int i = 0; placeEntries.size() > i; i++) {
            PlaceEntry placeEntry = placeEntries.get(i);
            JLabel jLabelPlace = new JLabel(this.labels.getString("eaccpf.description.place"));
            builder.add(jLabelPlace, cc.xy(1, rowNb));
            JTextField jTextfieldPlace = new JTextField(
                    placeEntry.getContent() != null ? placeEntry.getContent() : "");
            builder.add(jTextfieldPlace, cc.xy(3, rowNb));
            addPlaceFunctionPlaceJTextfields(i == 0, jTextfieldPlace);

            JLabel jCountryLabel = new JLabel(this.labels.getString("eaccpf.description.country"));
            builder.add(jCountryLabel, cc.xy(5, rowNb));
            JComboBox jComboboxCountry = buildCountryJComboBox();

            if (placeEntry.getCountryCode() != null) {
                jComboboxCountry.setSelectedItem(parseIsoToCountry(placeEntry.getCountryCode()));
            }

            builder.add(jComboboxCountry, cc.xy(7, rowNb));
            addPlaceFunctionCountryJComboBoxes(i == 0, jComboboxCountry);
            setNextRow();
        }
    } else { //empty one
        JLabel jLabelPlace = new JLabel(this.labels.getString("eaccpf.description.place"));
        builder.add(jLabelPlace, cc.xy(1, rowNb));
        JTextField jTextfieldPlace = new JTextField();
        builder.add(jTextfieldPlace, cc.xy(3, rowNb));
        addPlaceFunctionPlaceJTextfields(true, jTextfieldPlace);
        JLabel jCountryLabel = new JLabel(this.labels.getString("eaccpf.description.country"));
        builder.add(jCountryLabel, cc.xy(5, rowNb));
        JComboBox countryJComboBox = buildCountryJComboBox();
        builder.add(countryJComboBox, cc.xy(7, rowNb));
        addPlaceFunctionCountryJComboBoxes(true, countryJComboBox);
        setNextRow();
    }

    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java

License:EUPL

/**
 * Method which builds an individual place.
 * Uses placeNumber to follow which part of place it is.
 *//*w w  w .  j  a v  a 2 s  . c om*/
private PanelBuilder buildPlace(PanelBuilder builder, CellConstraints cc, Place place, Integer placeNumber) {
    builder.addSeparator(this.labels.getString("eaccpf.description.place"), cc.xyw(1, this.rowNb, 7));
    setNextRow();
    placeNumber = placeNumber != null ? placeNumber : 0; //checks for null values, index must be controlled
    boolean filled = false;
    if (place != null && place.getPlaceEntry() != null) { //each one
        if (!place.getPlaceEntry().isEmpty()) {
            for (PlaceEntry placeEntry : place.getPlaceEntry()) {
                if (StringUtils.isNotEmpty(trimStringValue(placeEntry.getContent()))) {
                    filled = true;
                }
                builder = buildPlaceEntry(builder, cc, placeEntry, true, placeNumber, filled);
            }
        } else {
            builder = buildPlaceEntry(builder, cc, null, true, placeNumber, filled);
        }
        if (place.getAddress() != null && place.getAddress().getAddressLine() != null
                && !place.getAddress().getAddressLine().isEmpty()) {
            builder = buildAddressDetails(builder, cc, place.getAddress().getAddressLine(), filled);
        } else {
            builder = buildAddressDetails(builder, cc, null, filled);
        }
        builder = buildButtonAddFurtherAddressDetails(builder, cc, placeNumber, filled);
        builder = buildPlaceDateRange(builder, cc, place, placeNumber, filled);
        builder = buildPlaceDateRangeButton(builder, cc, placeNumber, filled);
    } else { //empty one
        builder = buildPlaceEntry(builder, cc, null, true, placeNumber, filled);
        builder = buildAddressDetails(builder, cc, null, filled);
        builder = buildButtonAddFurtherAddressDetails(builder, cc, null, filled);
        builder = buildPlaceDateRange(builder, cc, null, placeNumber, filled);
        builder = buildPlaceDateRangeButton(builder, cc, placeNumber, filled);
    }
    setNextRow();
    return builder;
}

From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfIdentityPanel.java

License:EUPL

/**
 * Method to build the full name or part of the name part of name section.
 *
 * @param builder//w  ww  .ja va2 s . c om
 * @param cc
 * @param errors
 * @return the PanelBuilder
 */
private PanelBuilder buildFullNamePart(PanelBuilder builder, CellConstraints cc, List<String> errors) {
    // Define values of the part.
    if (this.eaccpf.getCpfDescription().getIdentity().getNameEntryParallelOrNameEntry().isEmpty()) {
        this.eaccpf.getCpfDescription().getIdentity().getNameEntryParallelOrNameEntry().add(new NameEntry());
    }

    List<NameEntry> nameEntries = getAllNameEntries(eaccpf);

    this.namePartComponentTfsWCbs = new HashMap<Integer, List<TextFieldWithComboBoxEacCpf>>(nameEntries.size());
    this.nameFormTfsWCbs = new ArrayList<TextFieldWithComboBoxEacCpf>(nameEntries.size());
    this.nameLanguageCbs = new ArrayList<StructureWithLanguage>(nameEntries.size());
    this.useDateTFs = new HashMap<Integer, List<TextFieldsWithRadioButtonForDates>>(nameEntries.size());

    int index = 0;

    for (NameEntry nameEntry : nameEntries) {
        // Set section title.
        this.setNextRow();
        builder.addSeparator(this.labels.getString("eaccpf.identity.name"), cc.xyw(1, this.rowNb, 7));
        this.setNextRow();

        if (nameEntry.getPart().isEmpty()) {
            nameEntry.getPart().add(new Part());
        }

        // Create list of elements.
        List<TextFieldWithComboBoxEacCpf> namePartComponentTfWCbList = new ArrayList<TextFieldWithComboBoxEacCpf>();

        for (int i = 0; i < nameEntry.getPart().size(); i++) {
            Part part = nameEntry.getPart().get(i);
            // Create element.
            TextFieldWithComboBoxEacCpf namePartComponentTfWCb = new TextFieldWithComboBoxEacCpf(
                    trimStringValue(part.getContent()), part.getLocalType(),
                    TextFieldWithComboBoxEacCpf.TYPE_COMPONENT, this.entityType, this.labels);

            // Add elements to the list.
            namePartComponentTfWCbList.add(namePartComponentTfWCb);

            // Add elements to the panel.
            if (i == 0) {
                builder.addLabel(this.labels.getString("eaccpf.identity.name.full") + (index == 0 ? "*" : ""),
                        cc.xy(1, this.rowNb));
            } else {
                builder.addLabel(this.labels.getString("eaccpf.identity.name.part"), cc.xy(1, this.rowNb));
            }
            builder.add(namePartComponentTfWCb.getTextField(), cc.xy(3, this.rowNb));
            builder.addLabel(this.labels.getString("eaccpf.identity.name.component"), cc.xy(5, this.rowNb));
            builder.add(namePartComponentTfWCb.getComboBox(), cc.xy(7, this.rowNb));
            this.setNextRow();

            // Add error mandatory field not filled when needed.
            if (errors.contains(EacCpfIdentityPanel.ERROR_NAME_PART + index)) {
                builder.add(createErrorLabel(this.labels.getString("eaccpf.identity.error.empty.name.label")),
                        cc.xyw(1, this.rowNb, 3));
                this.setNextRow();
            }
        }

        // Add elements to the map.
        this.namePartComponentTfsWCbs.put(Integer.valueOf(index), namePartComponentTfWCbList);

        // Button to add new parts of the name.
        JButton addNamePartsBtn = new ButtonTab(this.labels.getString("eaccpf.identity.add.part"));
        addNamePartsBtn
                .addActionListener(new AddNamePartsAction(this.eaccpf, this.tabbedPane, this.model, index));
        builder.add(addNamePartsBtn, cc.xy(1, this.rowNb));
        this.setNextRow();

        // Call method to build form of the name part and language.
        builder = this.buildFormNameAndLanguage(builder, cc, nameEntry);

        // Call method to build use dates of the name part.
        builder = this.buildUseDates(builder, cc, nameEntry, index);

        index++;
    }

    // Button to add new forms of the name.
    this.setNextRow();
    JButton addFormNameBtn = new ButtonTab(this.labels.getString("eaccpf.identity.add.form"));
    addFormNameBtn.addActionListener(new AddFormNameAction(this.eaccpf, this.tabbedPane, this.model));
    builder.add(addFormNameBtn, cc.xy(1, this.rowNb));
    this.setNextRow();

    return builder;
}