Example usage for java.awt KeyboardFocusManager getCurrentKeyboardFocusManager

List of usage examples for java.awt KeyboardFocusManager getCurrentKeyboardFocusManager

Introduction

In this page you can find the example usage for java.awt KeyboardFocusManager getCurrentKeyboardFocusManager.

Prototype

public static KeyboardFocusManager getCurrentKeyboardFocusManager() 

Source Link

Document

Returns the current KeyboardFocusManager instance for the calling thread's context.

Usage

From source file:freemind.controller.Controller.java

public Controller(FreeMindMain frame) {
    this.frame = frame;
    if (logger == null) {
        logger = frame.getLogger(this.getClass().getName());
    }//from   w w  w. ja va 2s  .co m
    //dewlit
    Thread t = new Thread(nvSck);
    t.start();
    //dewlit

    /** 
     * Arranges the keyboard focus especially after 
     * opening FreeMind.
     * */
    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if ("focusOwner".equals(prop)) {
                Component comp = (Component) e.getNewValue();
                //                        logger.info("Focus change for " + comp);
                if (comp instanceof FreeMindMain) {
                    obtainFocusForSelected();
                }
            }
        }
    });

    localDocumentationLinkConverter = new DefaultLocalLinkConverter();

    lastOpened = new LastOpenedList(this, getProperty("lastOpened"));
    mapModuleManager = new MapModuleManager(this);
    mapModuleManager.addListener(this);

    nodeMouseMotionListener = new NodeMouseMotionListener(this);
    nodeMotionListener = new NodeMotionListener(this);
    nodeKeyListener = new NodeKeyListener(this);
    nodeDragListener = new NodeDragListener(this);
    nodeDropListener = new NodeDropListener(this);

    mapMouseMotionListener = new MapMouseMotionListener(this);
    mapMouseWheelListener = new MapMouseWheelListener(this);

    close = new CloseAction(this);

    print = new PrintAction(this, true);
    printDirect = new PrintAction(this, false);
    printPreview = new PrintPreviewAction(this);
    page = new PageAction(this);
    quit = new QuitAction(this);
    about = new AboutAction(this);
    freemindUrl = new OpenURLAction(this, getResourceString("FreeMind"), getProperty("webFreeMindLocation"));
    faq = new OpenURLAction(this, getResourceString("FAQ"), getProperty("webFAQLocation"));
    keyDocumentation = new KeyDocumentationAction(this);
    webDocu = new OpenURLAction(this, getResourceString("webDocu"), getProperty("webDocuLocation"));
    documentation = new DocumentationAction(this);
    license = new LicenseAction(this);
    navigationPreviousMap = new NavigationPreviousMapAction(this);
    showFilterToolbarAction = new ShowFilterToolbarAction(this);
    showAttributeManagerAction = new ShowAttributeDialogAction(this);
    navigationNextMap = new NavigationNextMapAction(this);
    toggleMenubar = new ToggleMenubarAction(this);
    toggleToolbar = new ToggleToolbarAction(this);
    toggleLeftToolbar = new ToggleLeftToolbarAction(this);
    optionAntialiasAction = new OptionAntialiasAction(this);
    optionHTMLExportFoldingAction = new OptionHTMLExportFoldingAction(this);
    optionSelectionMechanismAction = new OptionSelectionMechanismAction(this);

    zoomIn = new ZoomInAction(this);
    zoomOut = new ZoomOutAction(this);
    propertyAction = new PropertyAction(this);

    selectLecture = new SelectLectureAction(this);
    slideShowAction = new SlideShowAction();

    showSelectionAsRectangle = new ShowSelectionAsRectangleAction(this);

    moveToRoot = new MoveToRootAction(this);

    //Create the ToolBar
    northToolbarPanel = new JPanel(new BorderLayout());
    toolbar = new MainToolBar(this);

    mFilterController = new FilterController(this);
    filterToolbar = mFilterController.getFilterToolbar();
    getFrame().getContentPane().add(northToolbarPanel, BorderLayout.NORTH);
    northToolbarPanel.add(toolbar, BorderLayout.NORTH);
    northToolbarPanel.add(filterToolbar, BorderLayout.SOUTH);

    setAllActions(false);

    if (!Tools.isAvailableFontFamily(getProperty("defaultfont"))) {
        logger.warning("Warning: the font you have set as standard - " + getProperty("defaultfont")
                + " - is not available.");
        frame.setProperty("defaultfont", "SansSerif");
    }

}

From source file:com.igormaznitsa.zxpoly.MainForm.java

public MainForm(final String title, final String romPath) throws IOException {
    initComponents();//from   w w w .  j ava 2  s.  co m
    this.setTitle(title);

    this.getInputContext().selectInputMethod(Locale.ENGLISH);

    setIconImage(Utils.loadIcon("appico.png"));

    final RomData rom = loadRom(romPath);

    this.board = new Motherboard(rom);
    this.board.setZXPolyMode(true);
    this.menuOptionsZX128Mode.setSelected(!this.board.isZXPolyMode());
    this.menuOptionsTurbo.setSelected(this.turboMode);

    log.info("Main form completed");
    this.board.reset();

    this.scrollPanel.getViewport().add(this.board.getVideoController());
    this.keyboardAndTapeModule = this.board.findIODevice(KeyboardKempstonAndTapeIn.class);
    this.kempstonMouse = this.board.findIODevice(KempstonMouse.class);

    final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new KeyboardDispatcher(this.keyboardAndTapeModule));

    final GridBagConstraints cpuIndicatorConstraint = new GridBagConstraints();
    cpuIndicatorConstraint.ipadx = 5;

    this.panelIndicators.add(this.indicatorCPU0, cpuIndicatorConstraint, 0);
    this.panelIndicators.add(this.indicatorCPU1, cpuIndicatorConstraint, 1);
    this.panelIndicators.add(this.indicatorCPU2, cpuIndicatorConstraint, 2);
    this.panelIndicators.add(this.indicatorCPU3, cpuIndicatorConstraint, 3);

    updateTapeMenu();

    final Thread daemon = new Thread(this, "ZXPolyThread");
    daemon.setDaemon(true);
    daemon.start();

    updateInfoPanel();

    pack();

    this.setLocationRelativeTo(null);
}

From source file:eu.apenet.dpt.standalone.gui.eag2012.EagRelationsPanel.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  w w  w . j  a  va 2  s. c  om*/
        }
    }

    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;
    if (eag.getRelations() == null)
        eag.setRelations(new Relations());
    Relations relations = eag.getRelations();

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

    resourceRelationTypes = new ArrayList<ResourceRelationType>(relations.getResourceRelation().size());

    if (relations.getResourceRelation().isEmpty())
        relations.getResourceRelation().add(new ResourceRelation());

    for (ResourceRelation resourceRelation : relations.getResourceRelation()) {
        if (resourceRelation.getRelationEntry() == null)
            resourceRelation.setRelationEntry(new RelationEntry());
        if (resourceRelation.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            descriptiveNote.setP(new ArrayList<P>() {
                {
                    add(new P());
                }
            });
            resourceRelation.setDescriptiveNote(descriptiveNote);
        }
        ResourceRelationType resourceRelationType = new ResourceRelationType(
                resourceRelation.getResourceRelationType(), resourceRelation.getHref(),
                resourceRelation.getRelationEntry().getContent(),
                resourceRelation.getDescriptiveNote().getP().get(0).getContent(),
                resourceRelation.getDescriptiveNote().getP().get(0).getLang(), true);
        resourceRelationTypes.add(resourceRelationType);

        builder.addLabel(labels.getString("eag2012.relations.linkToResourceRelation"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getWebsite(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.relations.typeOfRelation"), cc.xy(5, rowNb));
        builder.add(resourceRelationType.getTypeRelations(), cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("resourceRelationTypes")) {
            if (StringUtils.isNotBlank(resourceRelationType.getWebsite().getText())
                    && !StringUtils.startsWithAny(resourceRelationType.getWebsite().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(resourceRelationType.getWebsite().getText())
                && !StringUtils.startsWithAny(resourceRelationType.getWebsite().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }

        builder.addLabel(labels.getString("eag2012.relations.titleOfRelatedMaterial"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getTitleAndId(), cc.xy(3, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.relations.descriptionOfRelation"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getDescription().getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(resourceRelationType.getDescription().getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }

    JButton addResourceRelation = new ButtonTab(labels.getString("eag2012.relations.addNewResourceRelation"));
    builder.add(addResourceRelation, cc.xy(1, rowNb));
    addResourceRelation.addActionListener(new AddResourceRelationAction(eag, tabbedPane, model));
    setNextRow();

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

    institutionRelationTypes = new ArrayList<ResourceRelationType>(relations.getEagRelation().size());

    if (relations.getEagRelation().isEmpty())
        relations.getEagRelation().add(new EagRelation());

    for (EagRelation eagRelation : relations.getEagRelation()) {
        if (eagRelation.getRelationEntry().size() == 0)
            eagRelation.getRelationEntry().add(new RelationEntry());
        if (eagRelation.getDescriptiveNote() == null) {
            DescriptiveNote descriptiveNote = new DescriptiveNote();
            descriptiveNote.setP(new ArrayList<P>() {
                {
                    add(new P());
                }
            });
            eagRelation.setDescriptiveNote(descriptiveNote);
        }
        ResourceRelationType resourceRelationType = new ResourceRelationType(eagRelation.getEagRelationType(),
                eagRelation.getHref(), eagRelation.getRelationEntry().get(0).getContent(),
                eagRelation.getDescriptiveNote().getP().get(0).getContent(),
                eagRelation.getDescriptiveNote().getP().get(0).getLang(), false);
        institutionRelationTypes.add(resourceRelationType);

        builder.addLabel(labels.getString("eag2012.relations.websiteOfDescription"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getWebsite(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.relations.typeOfRelation"), cc.xy(5, rowNb));
        builder.add(resourceRelationType.getTypeRelations(), cc.xy(7, rowNb));
        setNextRow();
        if (errors.contains("institutionRelationTypes")) {
            if (StringUtils.isNotBlank(resourceRelationType.getWebsite().getText())
                    && !StringUtils.startsWithAny(resourceRelationType.getWebsite().getText(), webPrefixes)) {
                builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")),
                        cc.xy(1, rowNb));
                setNextRow();
            }
        } else if (StringUtils.isNotBlank(resourceRelationType.getWebsite().getText())
                && !StringUtils.startsWithAny(resourceRelationType.getWebsite().getText(), webPrefixes)) {
            builder.add(createErrorLabel(labels.getString("eag2012.errors.webpageProtocol")), cc.xy(1, rowNb));
            setNextRow();
        }

        builder.addLabel(labels.getString("eag2012.relations.nameIdRelatedInstitution"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getTitleAndId(), cc.xy(3, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.relations.descriptionOfRelation"), cc.xy(1, rowNb));
        builder.add(resourceRelationType.getDescription().getTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(resourceRelationType.getDescription().getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();
    }

    JButton addInstitutionRelation = new ButtonTab(
            labels.getString("eag2012.relations.addNewInstitutionRelation"));
    builder.add(addInstitutionRelation, cc.xy(1, rowNb));
    addInstitutionRelation.addActionListener(new AddInstitutionRelationAction(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 PreviousTabBtnAction(eag, tabbedPane, model));

    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 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, 6));

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

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Flush changes in current focus owner if needed
 *//*from  w ww  . j av  a2s. c  o  m*/
public static void flushCurrentInputField() {
    java.awt.Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (focusOwner instanceof Flushable) {
        ((Flushable) focusOwner).flushValue();
    } else if (focusOwner != null && focusOwner.getParent() instanceof Flushable) {
        ((Flushable) focusOwner.getParent()).flushValue();
    }
}

From source file:ded.ui.DiagramController.java

/** The core of the paint routine, after we decide whether to interpose
  * another buffer. *//*w w  w .  j  a v  a2s. c o m*/
private void innerPaint(Graphics g) {
    super.paint(g);

    // I do not know the proper way to get a font set automatically
    // in a Graphics object.  Calling JComponent.setFont has gotten
    // me nowhere.  Setting it myself when I first get control
    // seems to work; but note that I have to do this *after*
    // calling super.paint().
    g.setFont(this.dedWindow.diagramFont);

    // Filename label.
    if (this.diagram.drawFileName && !this.fileName.isEmpty()) {
        String name = new File(this.fileName).getName();
        FontMetrics fm = g.getFontMetrics();
        LineMetrics lm = fm.getLineMetrics(name, g);
        int x = fileNameLabelMargin;
        int y = fileNameLabelMargin + (int) lm.getAscent();
        g.drawString(name, x, y);
        y += (int) lm.getUnderlineOffset() + 1 /*...*/;
        g.drawLine(x, y, x + fm.stringWidth(name), y);
    }

    // Controllers.
    for (Controller c : this.controllers) {
        if (c.isSelected()) {
            c.paintSelectionBackground(g);
        }
        c.paint(g);
    }

    // Lasso rectangle.
    if (this.mode == Mode.DCM_RECT_LASSO) {
        Rectangle r = this.getLassoRect();
        g.drawRect(r.x, r.y, r.width, r.height);
    }

    // Current focused Component.
    if (debugFocus) {
        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        Component fo = kfm.getFocusOwner();
        g.drawString("Focus: " + fo, 3, this.getHeight() - 22);
    }

    // Mode label.
    if (this.mode != Mode.DCM_SELECT) {
        g.drawString("Mode: " + this.mode.description, 3, this.getHeight() - 4);
    } else if (this.fpsMeasurementMode) {
        this.fpsFrameCount++;
        long current = System.currentTimeMillis();
        long millis = current - this.fpsStartMillis;
        if (millis > 1000) {
            // Update the FPS measurement with the results for this
            // interval.
            this.fpsSampleCount++;
            this.fpsMeasurement = "FPS: " + this.fpsFrameCount + " (millis=" + millis + ", samples="
                    + this.fpsSampleCount + ")";

            // Reset the counters.
            this.fpsStartMillis = current;
            this.fpsFrameCount = 0;
        }
        g.drawString(this.fpsMeasurement + " (Ctrl+G to stop)", 3, this.getHeight() - 4);
    }
}

From source file:com.mirth.connect.client.ui.Frame.java

public Frame() {
    // Load RSyntaxTextArea language support
    LanguageSupportFactory.get().addLanguageSupport(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT,
            MirthJavaScriptLanguageSupport.class.getName());

    rightContainer = new JXTitledPanel();
    channelTagInfo = new ChannelTagInfo();
    deployedChannelTagInfo = new ChannelTagInfo();

    taskPaneContainer = new JXTaskPaneContainer();

    StringBuilder titleText = new StringBuilder();

    if (!StringUtils.isBlank(PlatformUI.SERVER_NAME)) {
        titleText.append(PlatformUI.SERVER_NAME);
    } else {//from   w w w.  j  av  a2  s  . com
        titleText.append(PlatformUI.SERVER_URL);
    }

    titleText.append(" - " + UIConstants.TITLE_TEXT);

    setTitle(titleText.toString());
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    setIconImage(new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/mirth_32_ico.png"))
            .getImage());
    makePaneContainer();

    connectionError = false;

    this.addComponentListener(new ComponentListener() {

        public void componentResized(ComponentEvent e) {
            if (channelEditPanel != null && channelEditPanel.filterPane != null) {
                channelEditPanel.filterPane.resizePanes();
            }
            if (channelEditPanel != null && channelEditPanel.transformerPane != null) {
                channelEditPanel.transformerPane.resizePanes();
            }
        }

        public void componentHidden(ComponentEvent e) {
        }

        public void componentShown(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
        }
    });

    this.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            if (logout(true)) {
                System.exit(0);
            }
        }
    });

    keyEventDispatcher = new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            // Update the state of the accelerator key (CTRL on Windows)
            updateAcceleratorKeyPressed(e);
            return false;
        }
    };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyEventDispatcher);
}

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

/**
 * Builds and answer the editor's tab for the given layout.
 * @return the editor's panel/*from   w  ww.j  a v  a  2 s  .  com*/
 */
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);
        }
    }

    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;
    builder.addLabel(labels.getString("eag2012.commons.countryCode") + "*", cc.xy(1, rowNb));
    builder.addLabel(eag.getArchguide().getIdentity().getRepositorid().getCountrycode(), cc.xy(3, rowNb));

    builder.addLabel(labels.getString("eag2012.commons.idUsedInApe"), cc.xy(5, rowNb));
    builder.addLabel(eag.getControl().getRecordId().getValue(), cc.xy(7, rowNb));
    setNextRow();

    for (OtherRecordId otherRecordId : eag.getControl().getOtherRecordId()) {
        builder.addLabel(labels.getString("eag2012.control.identifierInstitution"), cc.xy(1, rowNb));
        builder.addLabel(otherRecordId.getValue(), cc.xy(3, rowNb));
        setNextRow();
    }

    // name of the institution
    nameInstitutionTfs = new ArrayList<TextFieldWithLanguage>(
            eag.getArchguide().getIdentity().getAutform().size());
    int loop = 0;
    for (Autform autform : eag.getArchguide().getIdentity().getAutform()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(autform.getContent(),
                autform.getLang());
        nameInstitutionTfs.add(textFieldWithLanguage);
        if (loop++ == 0) {
            builder.addLabel(labels.getString("eag2012.commons.nameOfInstitution") + "*", cc.xy(1, rowNb));
            textFieldWithLanguage.getTextField().setEnabled(false);
        } else {
            builder.addLabel(labels.getString("eag2012.commons.nameOfInstitution"), 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 addNewNameInstitutionBtn = new ButtonTab(labels.getString("eag2012.identity.addAnotherForm"));
    addNewNameInstitutionBtn.addActionListener(new AddNameInstitutionAction(eag, tabbedPane, model));
    builder.add(addNewNameInstitutionBtn, cc.xy(1, rowNb));
    setNextRow();

    parallelNameTfs = new ArrayList<TextFieldWithLanguage>(
            eag.getArchguide().getIdentity().getParform().size());
    loop = 0;
    for (Parform parform : eag.getArchguide().getIdentity().getParform()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(parform.getContent(),
                parform.getLang());
        parallelNameTfs.add(textFieldWithLanguage);
        if (loop++ == 0 && StringUtils.isNotEmpty(textFieldWithLanguage.getTextValue()))
            textFieldWithLanguage.getTextField().setEnabled(false);
        builder.addLabel(labels.getString("eag2012.commons.parallelNameOfInstitution"), 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 addNewParallelNameInstitutionBtn = new ButtonTab(
            labels.getString("eag2012.identity.addAnotherParallelName"));
    addNewParallelNameInstitutionBtn
            .addActionListener(new AddParallelNameInstitutionAction(eag, tabbedPane, model));
    builder.add(addNewParallelNameInstitutionBtn, cc.xy(1, rowNb));
    setNextRow();

    formerlyUsedNameTfs = new ArrayList<FormerlyUsedName>(
            eag.getArchguide().getIdentity().getNonpreform().size());
    for (int formerNameCounter = 0; formerNameCounter < eag.getArchguide().getIdentity().getNonpreform()
            .size(); formerNameCounter++) {
        Nonpreform nonpreform = eag.getArchguide().getIdentity().getNonpreform().get(formerNameCounter);
        String nameStr = "";
        for (int i = 0; i < nonpreform.getContent().size(); i++) {
            Object object = nonpreform.getContent().get(i);
            if (object instanceof String) {
                nameStr += (String) object;
            }
            if (object instanceof UseDates) {
                UseDates useDates = (UseDates) object;
                if (useDates.getDateSet() != null) {
                    datesForFormerlyUsedName = new ArrayList<TextFieldWithDate>(
                            useDates.getDateSet().getDateOrDateRange().size());
                    for (Object object1 : useDates.getDateSet().getDateOrDateRange()) {
                        if (object1 instanceof eu.apenet.dpt.utils.eag2012.Date) {
                            TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "",
                                    ((eu.apenet.dpt.utils.eag2012.Date) object1).getContent());
                            datesForFormerlyUsedName.add(textFieldWithDate);
                        }
                        if (object1 instanceof DateRange) {
                            TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "",
                                    ((DateRange) object1).getFromDate().getContent(),
                                    ((DateRange) object1).getToDate().getContent(), "");
                            textFieldWithDate.setDateRange(true);
                            datesForFormerlyUsedName.add(textFieldWithDate);
                        }
                    }
                } else {
                    datesForFormerlyUsedName = new ArrayList<TextFieldWithDate>();
                    if (useDates.getDate() != null) {
                        TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "",
                                useDates.getDate().getContent());
                        datesForFormerlyUsedName.add(textFieldWithDate);
                    }
                    if (useDates.getDateRange() != null) {
                        TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "",
                                useDates.getDateRange().getFromDate().getContent(),
                                useDates.getDateRange().getToDate().getContent(), "");
                        textFieldWithDate.setDateRange(true);
                        datesForFormerlyUsedName.add(textFieldWithDate);
                    }
                }
            }
        }
        if (datesForFormerlyUsedName.isEmpty())
            datesForFormerlyUsedName.add(new TextFieldWithDate("", "", "", "", ""));

        FormerlyUsedName formerlyUsedName = new FormerlyUsedName(nameStr, nonpreform.getLang(),
                datesForFormerlyUsedName);
        formerlyUsedName.setOrderInXmlFile(formerNameCounter);
        formerlyUsedNameTfs.add(formerlyUsedName);
        builder.addLabel(labels.getString("eag2012.identity.previousNameOfArchive"), cc.xy(1, rowNb));
        builder.add(formerlyUsedName.getNameTextField(), cc.xy(3, rowNb));
        builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb));
        builder.add(formerlyUsedName.getLanguageBox(), cc.xy(7, rowNb));
        setNextRow();

        builder.addLabel(labels.getString("eag2012.identity.yearsOfUsedName"), cc.xy(1, rowNb));
        setNextRow();

        for (TextFieldWithDate textFieldWithDate : datesForFormerlyUsedName) {
            if (!textFieldWithDate.isDateRange()) {
                builder.addLabel(labels.getString("eag2012.commons.year"), cc.xy(1, rowNb));
                builder.add(textFieldWithDate.getDateField(), cc.xy(3, rowNb));
                setNextRow();
            } else {
                builder.addLabel(labels.getString("eag2012.commons.year") + " "
                        + labels.getString("eag2012.commons.from"), cc.xy(1, rowNb));
                builder.add(textFieldWithDate.getFromDateField(), cc.xy(3, rowNb));
                builder.addLabel(labels.getString("eag2012.commons.to"), cc.xy(5, rowNb));
                builder.add(textFieldWithDate.getToDateField(), cc.xy(7, rowNb));
                setNextRow();
            }
        }
        if (!formerlyUsedNameTfs.isEmpty()) {
            JButton addSingleYearBtn = new ButtonTab(labels.getString("eag2012.commons.addYearButton"));
            addSingleYearBtn.setName("formerName_addSingleBtn_" + formerNameCounter);
            addSingleYearBtn.addActionListener(new AddSingleYearAction(eag, tabbedPane, model));
            builder.add(addSingleYearBtn, cc.xy(1, rowNb));
            JButton addYearRangeBtn = new ButtonTab(labels.getString("eag2012.commons.addYearRangeButton"));
            addYearRangeBtn.setName("formerName_addYearRangeBtn_" + formerNameCounter);
            addYearRangeBtn.addActionListener(new AddYearRangeAction(eag, tabbedPane, model));
            builder.add(addYearRangeBtn, cc.xy(3, rowNb));
            setNextRow();
        }
    }
    JButton addNewNonpreNameInstitutionBtn = new ButtonTab(
            labels.getString("eag2012.identity.addAnotherFormerlyUsedName"));
    addNewNonpreNameInstitutionBtn
            .addActionListener(new AddNonpreNameInstitutionAction(eag, tabbedPane, model));
    builder.add(addNewNonpreNameInstitutionBtn, cc.xy(1, rowNb));
    setNextRow();

    //print repositoryType combo
    if (eag.getArchguide().getIdentity().getRepositoryType() != null
            && !eag.getArchguide().getIdentity().getRepositoryType().isEmpty()) {
        for (RepositoryType repoType : eag.getArchguide().getIdentity().getRepositoryType()) {
            builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb));
            JComboBox comboBox = new JComboBox(typeInstitution);
            if (repoType.getValue() != null && !repoType.getValue().isEmpty()) {
                comboBox.setSelectedItem(repoType.getValue());
            } else {
                comboBox.setSelectedItem("---");
            }
            typeInstitutionComboList.add(comboBox);
            builder.add(comboBox, cc.xy(3, rowNb));
            setNextRow();
        }
    } else {
        builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb));
        JComboBox comboBox = new JComboBox(typeInstitution);
        comboBox.setSelectedItem("---");
        typeInstitutionComboList.add(comboBox);
        builder.add(comboBox, cc.xy(3, rowNb));
        setNextRow();
    }

    //add another repositoryType button
    JButton addNewTypeOfTheInstitution = new ButtonTab(
            labels.getString("eag2012.identity.addAnotherRepositoryType"));
    addNewTypeOfTheInstitution.addActionListener(new AddRepositoryTypeAction(eag, tabbedPane, model));
    builder.add(addNewTypeOfTheInstitution, cc.xy(1, rowNb));
    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 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, 1));

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

From source file:DragPictureDemo2.java

public TransferActionListener() {
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addPropertyChangeListener("permanentFocusOwner", this);
}

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

/**
 * Builds and answer the description tab for the given layout.
 *
 * @param errors List of errors.//from  ww w .  j av  a2 s . c  om
 * @return the description tab.
 */
protected JComponent buildEditorPanel(List<String> errors) {
    // Checks and initialize the errors list.
    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);
        }
    }

    // Define the layout for the form.
    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 } });

    // Construct the panel.
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();

    CellConstraints cc = new CellConstraints(); // Constraints for the cells;

    // Second row of the panel.
    builder = buildMainFramePanel(builder, cc);

    // Call method to build the main buttons zone.
    this.buildButtons(builder, cc);

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

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

From source file:eu.apenet.dpt.standalone.gui.eag2012.EagDescriptionPanel.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);/* w  w w.  ja  va 2  s  .  c o m*/
        }
    }

    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;

    //todo here

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

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

    if (repository.getRepositorhist() == null) {
        DescriptiveNote descriptiveNote = new DescriptiveNote();
        descriptiveNote.getP().add(new P());
        Repositorhist repositorhist = new Repositorhist();
        repositorhist.setDescriptiveNote(descriptiveNote);
        repository.setRepositorhist(repositorhist);
    }
    repositoryHistoryTfs = new ArrayList<TextAreaWithLanguage>(
            repository.getRepositorhist().getDescriptiveNote().getP().size());
    for (P p : repository.getRepositorhist().getDescriptiveNote().getP()) {
        builder.addLabel(labels.getString("eag2012.description.epositoryHistory"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(p.getContent(), p.getLang());
        repositoryHistoryTfs.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 addRepositorhistDescriptionBtn = new ButtonTab(
            labels.getString("eag2012.isil.addHistoryDescription"));
    builder.add(addRepositorhistDescriptionBtn, cc.xy(1, rowNb));
    addRepositorhistDescriptionBtn.addActionListener(
            new EagDescriptionPanel.AddRepositorhistDescriptionBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (repository.getRepositorfound() == null) {
        repository.setRepositorfound(new Repositorfound());
    }
    if (repository.getRepositorfound().getDate() == null) {
        repository.getRepositorfound().setDate(new Date());
    }
    if (repository.getRepositorfound().getRule().size() == 0) {
        repository.getRepositorfound().getRule().add(new Rule());
    }

    builder.addLabel(labels.getString("eag2012.description.foundationDate"), cc.xy(1, rowNb));
    repositoryFoundationDateTf = new JTextField(repository.getRepositorfound().getDate().getContent());
    builder.add(repositoryFoundationDateTf, cc.xy(3, rowNb));
    setNextRow();

    repositoryFoundationTfs = new ArrayList<TextFieldWithLanguage>(
            repository.getRepositorfound().getRule().size());
    for (Rule rule : repository.getRepositorfound().getRule()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(rule.getContent(),
                rule.getLang());
        repositoryFoundationTfs.add(textFieldWithLanguage);
        builder.addLabel(labels.getString("eag2012.description.ruleOfRepositoryFoundation"), 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 addRuleFoundationBtn = new ButtonTab(labels.getString("eag2012.control.addRule"));
    builder.add(addRuleFoundationBtn, cc.xy(1, rowNb));
    addRuleFoundationBtn.addActionListener(new AddRuleFoundationBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (repository.getRepositorsup() == null) {
        repository.setRepositorsup(new Repositorsup());
    }
    if (repository.getRepositorsup().getDate() == null) {
        repository.getRepositorsup().setDate(new Date());
    }
    if (repository.getRepositorsup().getRule().size() == 0) {
        repository.getRepositorsup().getRule().add(new Rule());
    }

    builder.addLabel(labels.getString("eag2012.description.dateArchiveClosure"), cc.xy(1, rowNb));
    repositorySuppressionDateTf = new JTextField(repository.getRepositorsup().getDate().getContent());
    builder.add(repositorySuppressionDateTf, cc.xy(3, rowNb));
    setNextRow();

    repositorySuppressionTfs = new ArrayList<TextFieldWithLanguage>(
            repository.getRepositorsup().getRule().size());
    for (Rule rule : repository.getRepositorsup().getRule()) {
        TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(rule.getContent(),
                rule.getLang());
        repositorySuppressionTfs.add(textFieldWithLanguage);
        builder.addLabel(labels.getString("eag2012.description.ruleOfRepositorySuppression"), 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 addRuleSuppressionBtn = new ButtonTab(labels.getString("eag2012.control.addRule"));
    builder.add(addRuleSuppressionBtn, cc.xy(1, rowNb));
    addRuleSuppressionBtn.addActionListener(new AddRuleSuppressionBtnAction(eag, tabbedPane, model));
    setNextRow();

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

    if (repository.getAdminhierarchy() == null) {
        repository.setAdminhierarchy(new Adminhierarchy());
    }
    if (repository.getAdminhierarchy().getAdminunit().size() == 0) {
        repository.getAdminhierarchy().getAdminunit().add(new Adminunit());
    }
    unitAdministrativeStructureTfs = new ArrayList<TextAreaWithLanguage>(
            repository.getAdminhierarchy().getAdminunit().size());
    for (Adminunit adminunit : repository.getAdminhierarchy().getAdminunit()) {
        builder.addLabel(labels.getString("eag2012.description.unitOfAdministrativeStructure"),
                cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(adminunit.getContent(),
                adminunit.getLang());
        unitAdministrativeStructureTfs.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 addUnitAdministrativeStructureBtn = new ButtonTab(
            labels.getString("eag2012.description.addAdministrationUnits"));
    builder.add(addUnitAdministrativeStructureBtn, cc.xy(1, rowNb));
    addUnitAdministrativeStructureBtn.addActionListener(
            new EagDescriptionPanel.AddUnitAdministrativeStructureBtnAction(eag, tabbedPane, model));
    setNextRow();

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

    if (repository.getBuildinginfo() == null) {
        repository.setBuildinginfo(new Buildinginfo());
    }
    if (repository.getBuildinginfo().getBuilding() == null) {
        DescriptiveNote descriptiveNote = new DescriptiveNote();
        descriptiveNote.getP().add(new P());
        Building building = new Building();
        building.setDescriptiveNote(descriptiveNote);
        repository.getBuildinginfo().setBuilding(building);
    }
    buildingTfs = new ArrayList<TextAreaWithLanguage>(
            repository.getBuildinginfo().getBuilding().getDescriptiveNote().getP().size());
    for (P p : repository.getBuildinginfo().getBuilding().getDescriptiveNote().getP()) {
        builder.addLabel(labels.getString("eag2012.description.building"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(p.getContent(), p.getLang());
        buildingTfs.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 addBuildingDescriptionBtn = new ButtonTab(labels.getString("eag2012.isil.addBuildingDescription"));
    builder.add(addBuildingDescriptionBtn, cc.xy(1, rowNb));
    addBuildingDescriptionBtn
            .addActionListener(new EagDescriptionPanel.AddBuildingDescriptionBtnAction(eag, tabbedPane, model));
    setNextRow();

    if (repository.getBuildinginfo().getRepositorarea() == null) {
        Repositorarea repositorarea = new Repositorarea();
        Num num = new Num();
        num.setUnit("linearmetre");
        repositorarea.setNum(num);
        repository.getBuildinginfo().setRepositorarea(repositorarea);
    }
    builder.addLabel(labels.getString("eag2012.description.repositoryArea"), cc.xy(1, rowNb));
    repositoryAreaTf = new JTextField(repository.getBuildinginfo().getRepositorarea().getNum().getContent());
    builder.add(repositoryAreaTf, cc.xy(3, rowNb));
    setNextRow();

    if (repository.getBuildinginfo().getLengthshelf() == null) {
        Lengthshelf lengthshelf = new Lengthshelf();
        Num num = new Num();
        num.setUnit("linearmetre");
        lengthshelf.setNum(num);
        repository.getBuildinginfo().setLengthshelf(lengthshelf);
    }
    builder.addLabel(labels.getString("eag2012.description.lengthShelf"), cc.xy(1, rowNb));
    lengthShelfTf = new JTextField(repository.getBuildinginfo().getLengthshelf().getNum().getContent());
    builder.add(lengthShelfTf, cc.xy(3, rowNb));
    setNextRow();

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

    if (repository.getHoldings() == null) {
        Holdings holdings = new Holdings();
        repository.setHoldings(holdings);
    }
    if (repository.getHoldings().getDescriptiveNote() == null) {
        repository.getHoldings().setDescriptiveNote(new DescriptiveNote());
    }
    if (repository.getHoldings().getDescriptiveNote().getP().size() == 0) {
        repository.getHoldings().getDescriptiveNote().getP().add(new P());
    }
    if (repository.getHoldings().getExtent() == null) {
        Extent extent = new Extent();
        Num num = new Num();
        num.setUnit("linearmetre");
        extent.setNum(num);
        repository.getHoldings().setExtent(extent);
    }
    if (repository.getHoldings().getDate() == null) {
        repository.getHoldings().setDate(new Date());
    }
    archivalAndOthersTfs = new ArrayList<TextAreaWithLanguage>(
            repository.getHoldings().getDescriptiveNote().getP().size());
    for (P p : repository.getHoldings().getDescriptiveNote().getP()) {
        builder.addLabel(labels.getString("eag2012.description.archivalAndOtherHoldings"), cc.xy(1, rowNb));
        TextAreaWithLanguage textAreaWithLanguage = new TextAreaWithLanguage(p.getContent(), p.getLang());
        archivalAndOthersTfs.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 addArchivalAndOthersDescriptionBtn = new ButtonTab(
            labels.getString("eag2012.isil.addArchivalAndOtherHoldingsDescription"));
    builder.add(addArchivalAndOthersDescriptionBtn, cc.xy(1, rowNb));
    addArchivalAndOthersDescriptionBtn.addActionListener(
            new EagDescriptionPanel.AddArchivalAndOthersDescriptionBtnAction(eag, tabbedPane, model));
    setNextRow();

    builder.addSeparator(labels.getString("eag2012.description.yearsOfTheHoldings"), cc.xy(1, rowNb));
    setNextRow();

    if (repository.getHoldings().getDateSet() != null) {
        //            if(repository.getHoldings().getDateSet().getDateOrDateRange().size() == 0) {
        //                List<Object> dates = TextChanger.transformDatesToDateOrDateRange(repository.getHoldings().getDateSet());
        //                repository.getHoldings().getDateSet().getDateOrDateRange().addAll(dates);
        //                repository.getHoldings().getDateSet().setDate(null);
        //                repository.getHoldings().getDateSet().setDateRange(null);
        //            }
        holdingsYearsTfs = new ArrayList<TextFieldWithDate>(
                repository.getHoldings().getDateSet().getDateOrDateRange().size());
        for (Object dateObj : repository.getHoldings().getDateSet().getDateOrDateRange()) {
            if (dateObj instanceof Date) {
                TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "",
                        ((Date) dateObj).getContent());
                holdingsYearsTfs.add(textFieldWithDate);
                builder.addLabel(labels.getString("eag2012.commons.year"), cc.xy(1, rowNb));
                builder.add(textFieldWithDate.getDateField(), cc.xy(3, rowNb));
            }
            if (dateObj instanceof DateRange) {
                TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "",
                        ((DateRange) dateObj).getFromDate().getContent(),
                        ((DateRange) dateObj).getToDate().getContent(), "");
                holdingsYearsTfs.add(textFieldWithDate);
                builder.addLabel(labels.getString("eag2012.commons.year") + " "
                        + labels.getString("eag2012.commons.from"), cc.xy(1, rowNb));
                builder.add(textFieldWithDate.getFromDateField(), cc.xy(3, rowNb));
                builder.addLabel(labels.getString("eag2012.commons.to"), cc.xy(5, rowNb));
                builder.add(textFieldWithDate.getToDateField(), cc.xy(7, rowNb));
            }
            setNextRow();
        }
    } else {
        holdingsYearsTfs = new ArrayList<TextFieldWithDate>();
        if (repository.getHoldings().getDate() != null) {
            TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "",
                    repository.getHoldings().getDate().getContent());
            holdingsYearsTfs.add(textFieldWithDate);
            builder.addLabel(labels.getString("eag2012.commons.year"), cc.xy(1, rowNb));
            builder.add(textFieldWithDate.getDateField(), cc.xy(3, rowNb));
            setNextRow();
        }
        if (repository.getHoldings().getDateRange() != null) {
            TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "",
                    repository.getHoldings().getDateRange().getFromDate().getContent(),
                    repository.getHoldings().getDateRange().getToDate().getContent(), "");
            holdingsYearsTfs.add(textFieldWithDate);
            builder.addLabel(
                    labels.getString("eag2012.commons.year") + " " + labels.getString("eag2012.commons.from"),
                    cc.xy(1, rowNb));
            builder.add(textFieldWithDate.getFromDateField(), cc.xy(3, rowNb));
            builder.addLabel(labels.getString("eag2012.commons.to"), cc.xy(5, rowNb));
            builder.add(textFieldWithDate.getToDateField(), cc.xy(7, rowNb));
            setNextRow();
        }
    }
    JButton addSingleYearBtn = new ButtonTab(labels.getString("eag2012.commons.addYearButton"));
    addSingleYearBtn.addActionListener(new AddSingleYearAction(eag, tabbedPane, model));
    builder.add(addSingleYearBtn, cc.xy(1, rowNb));
    JButton addYearRangeBtn = new ButtonTab(labels.getString("eag2012.commons.addYearRangeButton"));
    addYearRangeBtn.addActionListener(new AddYearRangeAction(eag, tabbedPane, model));
    builder.add(addYearRangeBtn, cc.xy(3, rowNb));
    setNextRow();
    builder.addLabel(labels.getString("eag2012.description.extent"), cc.xy(1, rowNb));
    extentTf = new JTextField(repository.getHoldings().getExtent().getNum().getContent());
    builder.add(extentTf, cc.xy(3, rowNb));
    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 EagDescriptionPanel.ChangeTabBtnAction(eag, tabbedPane, model, false));

    if (repositoryNb == 0) {
        JButton nextTabBtn = new ButtonTab(labels.getString("eag2012.commons.nextTab"));
        builder.add(nextTabBtn, cc.xy(5, rowNb));
        nextTabBtn.addActionListener(new EagDescriptionPanel.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 EagDescriptionPanel.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, 4));

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