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:pl.otros.logview.gui.LogViewMainFrame.java

private void initGlobalHotKeys() {
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventPostProcessor(new KeyboardTabSwitcher(logsTabbedPane));
    manager.addKeyEventPostProcessor(//from   ww w . j  av  a 2  s.  c o m
            new FocusComponentOnHotKey(searchField, KeyEvent.VK_F, KeyEvent.META_MASK));
}

From source file:tufts.vue.ui.InspectorPane.java

public void showNotesView() {
    expandCollapsePanes(NOTES);// w w  w .  j av  a 2  s. c o  m

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
            mNotes.getTextPane().requestFocusInWindow();
        }
    });

}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

public void dispose() {
    WorkspaceSettings.getInstance().removeSettingsListener(settingsUpdateHandler);

    if (this.verticalLinealModel != null) {
        this.verticalLinealModel.removeLinealModelListener(repaintHandler);
    }/*from  w  w  w . j  a  v  a2  s  .  com*/
    if (this.horizontalLinealModel != null) {
        this.horizontalLinealModel.removeLinealModelListener(repaintHandler);
    }
    if (getElementRenderer() != null) {
        getElementRenderer().removeChangeListener(repaintHandler);
    }

    designerContext.removePropertyChangeListener(ReportDesignerContext.SELECTION_WAITING_PROPERTY,
            selectionStateHandler);

    KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener("permanentFocusOwner",
            focusHandler); // NON-NLS

    final ReportDocumentContext renderContext = getRenderContext();
    renderContext.getReportDefinition().removeReportModelListener(changeHandler);
    renderContext.getSelectionModel().removeReportSelectionListener(selectionModelListener);

    getElementRenderer().dispose();
}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

protected void removeEditor() {
    if (editorRemover != null) {
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                .removePropertyChangeListener("permanentFocusOwner", editorRemover); // NON-NLS
        editorRemover = null;//from   w w  w . j a va  2 s.co  m
    }
    if (editorComponent == null) {
        inlineEditor = null;
        return;
    }

    remove(editorComponent);
    inlineEditor.removeCellEditorListener(this);

    editorComponent = null;
    inlineEditor = null;
}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

protected boolean installEditor(final ReportElementInlineEditor inlineEditor, final Element element) {
    if (inlineEditor == null) {
        throw new NullPointerException();
    }//from  w w w . jav a 2s. co  m

    this.inlineEditor = inlineEditor;

    final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
    if (data == null) {
        removeEditor();
        return false;
    }
    final Component editorComponent = inlineEditor.getElementCellEditorComponent(this, element);
    if (editorComponent == null) {
        removeEditor();
        return false;
    }

    if (editorRemover == null) {
        final KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        editorRemover = new CellEditorRemover(fm);
        fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NON-NLS
    }

    this.editorComponent = editorComponent;

    final float zoomFactor = getRenderContext().getZoomModel().getZoomAsPercentage();

    final Rectangle2D bounds = getElementRenderer().getBounds();
    final int x = (int) ((getLeftBorder() + StrictGeomUtility.toExternalValue(data.getX())) * zoomFactor);
    final int y = (int) ((getTopBorder()
            + (StrictGeomUtility.toExternalValue(data.getY()) - bounds.getY()) * zoomFactor));
    final int width = (int) (StrictGeomUtility.toExternalValue(data.getWidth()) * zoomFactor);
    final int height = (int) (StrictGeomUtility.toExternalValue(data.getHeight()) * zoomFactor);
    editorComponent.setBounds(x, y, width, height);
    add(editorComponent);
    editorComponent.validate();
    inlineEditor.addCellEditorListener(this);

    List<Element> selectedElements = getRenderContext().getSelectionModel()
            .getSelectedElementsOfType(Element.class);
    final Element[] visualElements = selectedElements.toArray(new Element[selectedElements.size()]);
    if (visualElements.length > 0) {
        oldValues = new ArrayList<Object>();
        for (int i = 0; i < visualElements.length; i++) {
            final Object attribute = visualElements[i].getAttribute(AttributeNames.Core.NAMESPACE,
                    AttributeNames.Core.VALUE);
            oldValues.add(attribute);
        }
    }

    return true;
}

From source file:vista.ventas.DialogEntregas.java

private void eventosDeTeclas() {
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new KeyEventDispatcher() {
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow().getClass()
                    .getSimpleName().equals("DialogEntregas")) {
                if (e.getID() == KeyEvent.KEY_PRESSED) {
                    if (e.getKeyCode() == KeyEvent.VK_F3) {
                        agregarArticulo();
                        calcularSubtotalGral();
                    }// w ww.  j  a  v a  2s.  c  om
                    if (e.getKeyCode() == KeyEvent.VK_F7) {
                        realizarVenta();
                    }
                    if (e.getKeyCode() == KeyEvent.VK_F4) {
                        cerrar();
                    }

                }
            }

            return false;
        }
    });
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void initGUI() {
    try {//w  w w  . j a va2 s  . c o m
        language = Utf8ResourceBundle.getBundle("language_" + Setting.getInstance().getCurrentLanguage());

        // $hide>>$
        if (os == OSType.win) {
            if (!new File("PauseBochs.exe").exists() || !new File("StopBochs.exe").exists()) {
                JOptionPane.showMessageDialog(null, MyLanguage.getString("PauseBochsExe"),
                        MyLanguage.getString("Error"), JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
            if (!new File("ndisasm.exe").exists()) {
                JOptionPane.showMessageDialog(null, MyLanguage.getString("NdisasmExe"),
                        MyLanguage.getString("Error"), JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
        }
        // $hide<<$
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        {
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            if (Global.isBeta) {
                this.setTitle(MyLanguage.getString("Title") + " " + Global.version
                        + " , This is beta version, if you found a bug, please try older official release");
            } else {
                this.setTitle(MyLanguage.getString("Title") + " " + Global.version);
            }

            this.setIconImage(
                    new ImageIcon(getClass().getClassLoader().getResource("com/peterbochs/icons/peter.png"))
                            .getImage());
            this.addWindowListener(new WindowAdapter() {
                public void windowOpened(WindowEvent evt) {
                    thisWindowOpened(evt);
                }

                public void windowActivated(WindowEvent evt) {
                    thisWindowActivated(evt);
                }

                public void windowClosing(WindowEvent evt) {
                    thisWindowClosing(evt);
                }
            });
        }
        {
            jToolBar1 = new JToolBar();
            getContentPane().add(jToolBar1, BorderLayout.NORTH);
            {
                startBochsButton = new JButton();
                jToolBar1.add(startBochsButton);
                startBochsButton.setText(MyLanguage.getString("Start_bochs"));
                startBochsButton.setToolTipText("Launch bochs");
                startBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/accept.png")));
                startBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        startBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                stopBochsButton = new JButton();
                jToolBar1.add(stopBochsButton);
                stopBochsButton.setText(MyLanguage.getString("Stop_bochs"));
                stopBochsButton.setToolTipText("Quit bochs");
                stopBochsButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/stop.png")));
                stopBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        stopBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                runBochsButton = new JDropDownButton();
                jToolBar1.add(runBochsButton);
                runBochsButton.setText(MyLanguage.getString("Run_bochs"));
                runBochsButton.setToolTipText("Start emulation");
                runBochsButton.setMaximumSize(new java.awt.Dimension(85, 26));
                runBochsButton.add(getJRunBochsAndSkipBreakpointMenuItem());
                runBochsButton.add(getJRunCustomCommandMenuItem());
                runBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/resultset_next.png")));
                runBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        runBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                stepBochsButton = new JDropDownButton();
                jToolBar1.add(stepBochsButton);
                jToolBar1.add(getJStepOverDropDownButton());
                jToolBar1.add(getJFastStepBochsButton());
                stepBochsButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/step.png")));
                stepBochsButton.setText(MyLanguage.getString("Step"));
                stepBochsButton.setMaximumSize(new java.awt.Dimension(85, 26));
                stepBochsButton.add(getJStep10MenuItem());
                stepBochsButton.add(getJStep100MenuItem());
                stepBochsButton.add(getJStepNMenuItem());
                stepBochsButton.add(getJStepUntilCallOrJumpMenuItem());
                stepBochsButton.add(getJStepUntilRetMenuItem());
                stepBochsButton.add(getJStepUntilIRetMenuItem());
                stepBochsButton.add(getJStepUntilMovMenuItem());
                stepBochsButton.add(getJStepUntilIPBigChangeMenuItem());
                stepBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        stepBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                nextButton = new JButton();
                nextButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/step.png")));
                nextButton.setText(MyLanguage.getString("Nexti"));
                nextButton.setToolTipText("c/c++ level step-in");
                jToolBar1.add(nextButton);
                jToolBar1.add(getNextOverButton());
                nextButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        nextButtonActionPerformed(evt);
                    }
                });
            }
            {
                jUpdateBochsButton = new JButton();
                jToolBar1.add(jUpdateBochsButton);
                jToolBar1.add(getJExportToExcelButton());
                jToolBar1.add(getJSettingButton());
                jToolBar1.add(getJRegisterToggleButton());
                jToolBar1.add(getJSourceLevelDebuggerButton());
                jToolBar1.add(getJProfilerToggleButton());
                jToolBar1.add(getJLogToggleButton());
                jToolBar1.add(getJOSLogToggleButton());
                jUpdateBochsButton.setEnabled(true);
                jUpdateBochsButton.setText(MyLanguage.getString("Update"));
                jUpdateBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/arrow_refresh.png")));
                jUpdateBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jUpdateBochsButtonActionPerformed(evt);
                    }
                });
            }
        }
        {
            jStatusPanel = new JPanel();
            BorderLayout jStatusPanelLayout = new BorderLayout();
            jStatusPanel.setLayout(jStatusPanelLayout);
            getContentPane().add(jStatusPanel, BorderLayout.SOUTH);
            getContentPane().add(getJMainPanel());
            {
                jStatusProgressBar = new JProgressBar();
                jStatusPanel.add(jStatusProgressBar, BorderLayout.WEST);
                jStatusPanel.add(getJPanel25(), BorderLayout.CENTER);
            }
        }
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu3 = new JMenu();
                jMenuBar1.add(jMenu3);
                jMenu3.setText(MyLanguage.getString("File"));
                {
                    jSeparator2 = new JSeparator();
                    jMenu3.add(jSeparator2);
                }
                {
                    exitMenuItem = new JMenuItem();
                    jMenu3.add(exitMenuItem);
                    exitMenuItem.setText(MyLanguage.getString("Exit"));
                    exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exitMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jMenu4 = new JMenu();
                jMenuBar1.add(jMenu4);
                jMenuBar1.add(getJFontMenu());
                jMenuBar1.add(getJMenu6());
                jMenuBar1.add(getJSystemMenu());
                jMenu4.setText(MyLanguage.getString("Bochs"));
                {
                    startBochsMenuItem = new JMenuItem();
                    jMenu4.add(startBochsMenuItem);
                    startBochsMenuItem.setText(MyLanguage.getString("Start_bochs"));
                    startBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    stopBochsMenuItem = new JMenuItem();
                    jMenu4.add(stopBochsMenuItem);
                    stopBochsMenuItem.setText(MyLanguage.getString("Stop_bochs"));
                    stopBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            stopBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    jSeparator1 = new JSeparator();
                    jMenu4.add(jSeparator1);
                }
                {
                    runBochsMenuItem = new JMenuItem();
                    jMenu4.add(runBochsMenuItem);
                    runBochsMenuItem.setText(MyLanguage.getString("Run_bochs"));
                    runBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            runBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    pauseBochsMenuItem = new JMenuItem();
                    jMenu4.add(pauseBochsMenuItem);
                    pauseBochsMenuItem.setText(MyLanguage.getString("Pause_bochs"));
                    pauseBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            pauseBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    jUpdateBochsStatusMenuItem = new JMenuItem();
                    jMenu4.add(jUpdateBochsStatusMenuItem);
                    jUpdateBochsStatusMenuItem.setText(MyLanguage.getString("Update_bochs_status"));
                    jUpdateBochsStatusMenuItem.setBounds(83, 86, 79, 20);
                    jUpdateBochsStatusMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            jUpdateBochsStatusMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jMenu5 = new JMenu();
                jMenuBar1.add(jMenu5);
                jMenu5.setText(MyLanguage.getString("Help"));
                {
                    aboutUsMenuItem = new JMenuItem();
                    jMenu5.add(aboutUsMenuItem);
                    jMenu5.add(getJHelpRequestMenuItem());
                    jMenu5.add(getJJVMMenuItem());
                    jMenu5.add(getShortcutHelpMenuItem());
                    jMenu5.add(getJLicenseMenuItem());
                    aboutUsMenuItem.setText(MyLanguage.getString("About_us"));
                    aboutUsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            aboutUsMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
        }
        if (Setting.getInstance().getWidth() == 0 || Setting.getInstance().getHeight() == 0) {
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setSize(screenSize.width * 2 / 3, screenSize.height * 4 / 5);
        } else {
            setSize(Setting.getInstance().getWidth(), Setting.getInstance().getHeight());
        }
        int x = Setting.getInstance().getX();
        int y = Setting.getInstance().getY();
        if (x <= 0 || y <= 0) {
            this.setLocationRelativeTo(null);
        } else {
            setLocation(x, y);
        }

        jSplitPane1.setDividerLocation(Setting.getInstance().getDivX());
        jSplitPane2.setDividerLocation(Setting.getInstance().getDivY());

        jOSDebugInformationPanel1.getjMainSplitPane()
                .setDividerLocation(Setting.getInstance().getOsDebugSplitPane_DividerLocation());
        // pack();
        initGlobalFontSetting(new Font(Setting.getInstance().getFontFamily(), Font.PLAIN,
                Setting.getInstance().getFontsize()));
        jInstrumentPanel.setThing(jStatusProgressBar, jStatusLabel);

        // prevent null jmenuitem
        getJInstructionPanelPopupMenu();
        // end prevent null jmenuitem

        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
            public boolean dispatchKeyEvent(KeyEvent e) {
                if (e.getID() == KeyEvent.KEY_RELEASED) {
                    int keycode = e.getKeyCode();
                    if (keycode == 112) {
                        jTabbedPane3.setSelectedIndex(0);
                    } else if (keycode == 113) {
                        jTabbedPane3.setSelectedIndex(1);
                    } else if (keycode == 114) {
                        jTabbedPane3.setSelectedIndex(2);
                    } else if (keycode == 115) {
                        jTabbedPane3.setSelectedIndex(3);
                    } else if (keycode == 116) {
                        if (startBochsButton.isEnabled()) {
                            startBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 117) {
                        if (stopBochsButton.isEnabled()) {
                            stopBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 118) {
                        if (runBochsButton.isEnabled()) {
                            runBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 119) {
                        if (stepBochsButton.isEnabled()) {
                            stepBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 120) {
                        if (fastStepBochsButton.isEnabled()) {
                            fastStepButtonActionPerformed(null);
                        }
                    }
                }

                // If the key should not be dispatched to the
                // focused component, set discardEvent to true
                boolean discardEvent = false;
                return discardEvent;
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(ERROR);
    }
}

From source file:org.pentaho.reporting.designer.core.editor.report.AbstractRenderComponent.java

public void removeNotify() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener("permanentFocusOwner",
            editorRemover); // NON-NLS
    editorRemover = null;/*from   w  ww  .j  a  v  a2  s .c om*/
    super.removeNotify();
}

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  av a2 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.mirth.connect.client.ui.Frame.java

public boolean logout(boolean quit) {
    if (!confirmLeave()) {
        return false;
    }//from  w  ww .  j a  v  a 2s  . c  o m

    // MIRTH-3074 Remove the keyEventDispatcher to prevent memory leak.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(keyEventDispatcher);

    statusUpdaterExecutor.shutdownNow();

    if (currentContentPage == messageBrowser) {
        mirthClient.getServerConnection().abort(messageBrowser.getAbortOperations());
    }

    userPreferences = Preferences.userNodeForPackage(Mirth.class);
    userPreferences.putInt("maximizedState", getExtendedState());
    userPreferences.putInt("width", getWidth());
    userPreferences.putInt("height", getHeight());

    LoadedExtensions.getInstance().stopPlugins();

    try {
        mirthClient.logout();
        mirthClient.close();
        this.dispose();

        if (!quit) {
            LoginPanel.getInstance().initialize(PlatformUI.SERVER_URL, PlatformUI.CLIENT_VERSION, "", "");
        }
    } catch (ClientException e) {
        alertThrowable(this, e);
    }

    return true;
}