List of usage examples for com.jgoodies.forms.layout CellConstraints xyw
public CellConstraints xyw(int col, int row, int colSpan)
Examples:
cc.xyw(1, 3, 7); cc.xyw(1, 3, 2);
From source file:edu.udo.scaffoldhunter.gui.SelectionPane.java
License:Open Source License
/** * @param selection//from w w w . j a v a 2s.co m * the selection * @param window * the main window * @param selectionActions * the selection actions * @param dbManager * the database manager for reloading SVGs */ public SelectionPane(Selection selection, MainWindow window, SelectionActions selectionActions, DbManager dbManager) { super(new FormLayout("left:pref, 8dlu, pref:grow", "pref, 6dlu, pref, 2dlu, pref, 6dlu, pref, 2dlu, pref, 6dlu, pref")); this.selection = selection; this.window = window; setBorder(new EmptyBorder(8, 3, 4, 3)); CellConstraints cc = new CellConstraints(); // selection browser SVGCache svgCache = new SVGCache(dbManager); selectionIteratorPane = new SelectionBrowserPane(window, selection, svgCache); add(selectionIteratorPane, cc.xyw(1, 1, 3)); // selection label add(new JLabel(_("Selection.Label")), cc.xy(1, 3)); selectionSize = new JLabel("0"); selectionSize.setFont(selectionSize.getFont().deriveFont(Font.BOLD)); add(selectionSize, cc.xy(3, 3)); makeSubsetButton = new JButton(_("Selection.MakeSubset"), Resources.getIcon("make_subset_arrow.png")); makeSubsetButton.setToolTipText(_("Main.Selection.MakeSubset.Description")); makeSubsetButton.addActionListener(selectionActions.getMakeSubset()); makeSubsetButton.setEnabled(false); add(makeSubsetButton, cc.xyw(1, 5, 3)); add(new JLabel(_("Selection.InViewLabel")), cc.xy(1, 7)); selectionInView = new JLabel("0"); selectionInView.setFont(selectionInView.getFont().deriveFont(Font.BOLD)); add(selectionInView, cc.xy(3, 7)); makeViewSubsetButton = new JButton(_("Selection.MakeSubset"), Resources.getIcon("make_subset_arrow.png")); makeViewSubsetButton.setToolTipText(_("Main.Selection.MakeViewSubset.Description")); makeViewSubsetButton.addActionListener(selectionActions.getMakeViewSubset()); makeViewSubsetButton.setEnabled(false); add(makeViewSubsetButton, cc.xyw(1, 9, 3)); clearAllButton = new JButton(_("Selection.Clear")); clearAllButton.addActionListener(selectionActions.getDeselectAll()); add(clearAllButton, cc.xyw(1, 11, 3)); selection.addPropertyChangeListener(Selection.SELECTION_PROPERTY, selectionListener); window.addPropertyChangeListener(MainWindow.ACTIVE_SUBSET_PROPERTY, activeSubsetChangeListener); }
From source file:edu.umich.robot.GuiApplication.java
License:Open Source License
/** * <p>/*from w w w.ja v a 2s .co m*/ * Pops up a window to create a new splinter robot to add to the simulation. */ public void createSplinterRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Splinter Robot", true); dialog.setLayout(layout); final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5)); dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create splinter: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create splinter: illegal robot name"); return; } controller.createSplinterRobot(robotName, pose, true); controller.createSimSplinter(robotName); controller.createSimLaser(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:edu.umich.robot.GuiApplication.java
License:Open Source License
public void createSuperdroidRobotDialog() { final Pose pose = new Pose(); FormLayout layout = new FormLayout("right:pref, 4dlu, 30dlu, 4dlu, right:pref, 4dlu, 30dlu", "pref, 2dlu, pref, 2dlu, pref"); layout.setRowGroups(new int[][] { { 1, 3 } }); final JDialog dialog = new JDialog(frame, "Create Superdroid Robot", true); dialog.setLayout(layout);/*from w ww. j av a2 s . c om*/ final JTextField name = new JTextField(); final JTextField x = new JTextField(Double.toString((pose.getX()))); final JTextField y = new JTextField(Double.toString((pose.getY()))); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(name, cc.xyw(3, 1, 5)); dialog.add(new JLabel("x"), cc.xy(1, 3)); dialog.add(x, cc.xy(3, 3)); dialog.add(new JLabel("y"), cc.xy(5, 3)); dialog.add(y, cc.xy(7, 3)); dialog.add(cancel, cc.xyw(1, 5, 3)); dialog.add(ok, cc.xyw(5, 5, 3)); x.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setX(Double.parseDouble(x.getText())); } catch (NumberFormatException ex) { x.setText(Double.toString(pose.getX())); } } }); y.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { try { pose.setY(Double.parseDouble(y.getText())); } catch (NumberFormatException ex) { y.setText(Double.toString(pose.getX())); } } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = name.getText().trim(); if (robotName.isEmpty()) { logger.error("Create Superdroid: robot name empty"); return; } for (char c : robotName.toCharArray()) if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create Superdroid: illegal robot name"); return; } controller.createSuperdroidRobot(robotName, pose, true); controller.createSimSuperdroid(robotName); dialog.dispose(); } }; name.addActionListener(okListener); x.addActionListener(okListener); y.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:edu.umich.robot.GuiApplication.java
License:Open Source License
public void connectSuperdroidRobotDialog() { final int defaultPort = 3192; FormLayout layout = new FormLayout("right:pref, 4dlu, 35dlu, 4dlu, 35dlu", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref"); final JDialog dialog = new JDialog(frame, "Connect to Superdroid", true); dialog.setLayout(layout);//from w w w. j av a 2s . c om final JTextField namefield = new JTextField("charlie"); final JTextField hostfield = new JTextField("192.168.1.165"); final JTextField portfield = new JTextField(Integer.toString(defaultPort)); final JButton cancel = new JButton("Cancel"); final JButton ok = new JButton("OK"); CellConstraints cc = new CellConstraints(); dialog.add(new JLabel("Name"), cc.xy(1, 1)); dialog.add(namefield, cc.xyw(3, 1, 3)); dialog.add(new JLabel("Host"), cc.xy(1, 3)); dialog.add(hostfield, cc.xyw(3, 3, 3)); dialog.add(new JLabel("Port"), cc.xy(1, 5)); dialog.add(portfield, cc.xyw(3, 5, 3)); dialog.add(cancel, cc.xy(3, 7)); dialog.add(ok, cc.xy(5, 7)); portfield.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { int p = defaultPort; try { p = Integer.parseInt(portfield.getText()); if (p < 1) p = 1; if (p > 65535) p = 65535; } catch (NumberFormatException ex) { } portfield.setText(Integer.toString(p)); } }); final ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String robotName = namefield.getText().trim(); if (robotName.isEmpty()) { logger.error("Connect Superdroid: robot name empty"); return; } for (char c : robotName.toCharArray()) { if (!Character.isDigit(c) && !Character.isLetter(c)) { logger.error("Create Superdroid: illegal robot name"); return; } } try { controller.createRealSuperdroid(robotName, hostfield.getText(), Integer.valueOf(portfield.getText())); } catch (UnknownHostException ex) { ex.printStackTrace(); logger.error("Connect Superdroid: " + ex); } catch (SocketException ex) { ex.printStackTrace(); logger.error("Connect Superdroid: " + ex); } dialog.dispose(); } }; namefield.addActionListener(okListener); hostfield.addActionListener(okListener); portfield.addActionListener(okListener); ok.addActionListener(okListener); ActionListener cancelAction = new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); dialog.getRootPane().registerKeyboardAction(cancelAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); dialog.setLocationRelativeTo(frame); dialog.pack(); dialog.setVisible(true); }
From source file:emailplugin.EMailSettingsTab.java
License:Open Source License
public JPanel createSettingsPanel() { final JPanel configPanel = new JPanel(); FormLayout layout = new FormLayout("5dlu, pref, 3dlu, pref:grow, fill:75dlu, 3dlu, pref, 5dlu", "5dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 10dlu, fill:default:grow, 3dlu"); configPanel.setLayout(layout);//from ww w. ja v a 2s. c o m CellConstraints cc = new CellConstraints(); boolean osOk = OperatingSystem.isMacOs() || OperatingSystem.isWindows(); mDefaultApplication = new JCheckBox(); mDefaultApplication.setEnabled(osOk); if (!osOk) { mDefaultApplication.setText(mLocalizer.msg("defaultApp", "Default Application") + " (" + mLocalizer.msg("notOnYourOS", "Function only Available on Windows and Mac OS") + ")"); } else { mDefaultApplication.setText(mLocalizer.msg("defaultApp", "Default Application")); mDefaultApplication.setSelected(mSettings.getUseDefaultApplication()); } configPanel.add(mDefaultApplication, cc.xyw(2, 2, 6)); mAppLabel = new JLabel(mLocalizer.msg("Application", "Application") + ":"); configPanel.add(mAppLabel, cc.xy(2, 4)); mApplication = new JTextField(mSettings.getApplication()); configPanel.add(mApplication, cc.xyw(4, 4, 2)); mAppFinder = new JButton("..."); mAppFinder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { findApplication(configPanel); } }); configPanel.add(mAppFinder, cc.xy(7, 4)); mParameterLabel = new JLabel(mLocalizer.msg("Parameter", "Parameter") + ":"); configPanel.add(mParameterLabel, cc.xy(2, 6)); mParameter = new ParamInputField(new EMailParamLibrary("mailto:?body="), mSettings.getParameter(), true); configPanel.add(mParameter, cc.xyw(4, 6, 4)); mHelpText = UiUtilities.createHtmlHelpTextArea( mLocalizer.msg("Desc", "Desc", "{" + EMailParamLibrary.KEY_MAIL_TEXT + "}")); configPanel.add(mHelpText, cc.xyw(2, 8, 6)); mDefaultApplication.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setInputState(); } }); setInputState(); mConfigPanel = new PluginProgramConfigurationPanel(mPlugin.getSelectedPluginProgramFormattings(), mPlugin.getAvailableLocalPluginProgramFormattings(), EMailPlugin.getDefaultFormatting(), true, true); configPanel.add(mConfigPanel, cc.xyw(1, 10, 7)); JPanel panel = new JPanel(new BorderLayout()); panel.add(configPanel, BorderLayout.NORTH); return panel; }
From source file:emailplugin.MailCreator.java
License:Open Source License
/** * Gives the User the opportunity to specify which Desktop he uses (KDE or * Gnome)/*ww w . j av a 2 s . co m*/ * * @param parent * Parent Dialog * @return true if KDE or Gnome has been selected, false if the User wanted to * specify the App */ private boolean showKdeGnomeDialog(Frame parent) { final JDialog dialog = new JDialog(parent, true); dialog.setTitle(mLocalizer.msg("chooseTitle", "Choose")); JPanel panel = (JPanel) dialog.getContentPane(); panel.setLayout(new FormLayout("10dlu, fill:pref:grow", "default, 3dlu, default, 3dlu, default, 3dlu, default, 3dlu:grow, default")); panel.setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("cantConfigure", "Can't configure on your system")), cc.xyw(1, 1, 2)); JRadioButton kdeButton = new JRadioButton(mLocalizer.msg("kde", "I am using KDE")); panel.add(kdeButton, cc.xy(2, 3)); JRadioButton gnomeButton = new JRadioButton(mLocalizer.msg("gnome", "I am using Gnome")); panel.add(gnomeButton, cc.xy(2, 5)); JRadioButton selfButton = new JRadioButton(mLocalizer.msg("self", "I want to configure by myself")); panel.add(selfButton, cc.xy(2, 7)); ButtonGroup group = new ButtonGroup(); group.add(kdeButton); group.add(gnomeButton); group.add(selfButton); selfButton.setSelected(true); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(ok); panel.add(buttonPanel, cc.xy(2, 9)); UiUtilities.registerForClosing(new WindowClosingIf() { public void close() { dialog.setVisible(false); } public JRootPane getRootPane() { return dialog.getRootPane(); } }); dialog.getRootPane().setDefaultButton(ok); dialog.pack(); UiUtilities.centerAndShow(dialog); if (kdeButton.isSelected()) { mSettings.setApplication("kfmclient"); mSettings.setParameter("exec {content}"); } else if (gnomeButton.isSelected()) { mSettings.setApplication("gnome-open"); mSettings.setParameter("{content}"); } else { Plugin.getPluginManager().showSettings(mPlugin); return false; } return true; }
From source file:es.tunelator.gui.adv.EditPointsDialog.java
License:Open Source License
/** * The following properties from this class's resource bundle are used * as labels to the different data fields: * <dir>/*from w ww.ja va 2 s .c om*/ * <li>measurement (separator)</code> * <li>date</li> * <li>time</li> * <li>identification (separator)</li> * <li>pointId</li> * <li>code</li> * <li>profile (separator)</li> * <li>theoricPK</li> * <li>realPK</li> * <li>indexPK</li> * <li>coordinates (separator)</li> * <li>xCoord</li> * <li>yCoord</li> * <li>zCoord</li> * <li>calcs (separator)</li> * <li>heightInc</li> * <li>axisDistance</li> * </dir> * @return The <code>JPanel</code> that contains the data fields * and button bar */ private JPanel getJPanel() { if (jPanel == null) { jPanel = new JPanel(); jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS)); PanelBuilder builder = new PanelBuilder(getFormLayout()); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); builder.addSeparator(Resourcer.getString(this.getClass(), "measurement"), cc.xyw(1, 1, 12)); builder.addLabel(Resourcer.getString(this.getClass(), "date"), cc.xy(2, 3)); builder.add(getJDate(allowEmptyValues), cc.xy(4, 3)); builder.addLabel(Resourcer.getString(this.getClass(), "time"), cc.xy(6, 3)); builder.add(getJTime(allowEmptyValues), cc.xy(8, 3)); builder.addSeparator(Resourcer.getString(this.getClass(), "identification"), cc.xyw(1, 5, 12)); builder.addLabel(Resourcer.getString(this.getClass(), "pointId"), cc.xy(2, 7)); builder.add(getJID(allowEmptyValues), cc.xy(4, 7)); builder.addLabel(Resourcer.getString(this.getClass(), "code"), cc.xy(6, 7)); builder.add(getJCode(true), cc.xy(8, 7)); builder.addSeparator(Resourcer.getString(this.getClass(), "profile"), cc.xyw(1, 9, 12)); builder.addLabel(Resourcer.getString(this.getClass(), "theoricPK"), cc.xy(2, 11)); builder.add(getJPKT(allowEmptyValues), cc.xy(4, 11)); builder.addLabel(Resourcer.getString(this.getClass(), "realPK"), cc.xy(6, 11)); builder.add(getJPKA(allowEmptyValues), cc.xy(8, 11)); builder.addLabel(Resourcer.getString(this.getClass(), "indexPK"), cc.xy(10, 11)); builder.add(getJPKIndex(allowEmptyValues), cc.xy(12, 11)); builder.addSeparator(Resourcer.getString(this.getClass(), "coordinates"), cc.xyw(1, 13, 12)); builder.addLabel(Resourcer.getString(this.getClass(), "xCoord"), cc.xy(2, 15)); builder.add(getJX(allowEmptyValues), cc.xy(4, 15)); builder.addLabel(Resourcer.getString(this.getClass(), "yCoord"), cc.xy(6, 15)); builder.add(getJY(allowEmptyValues), cc.xy(8, 15)); builder.addLabel(Resourcer.getString(this.getClass(), "zCoord"), cc.xy(10, 15)); builder.add(getJZ(allowEmptyValues), cc.xy(12, 15)); builder.addSeparator(Resourcer.getString(this.getClass(), "calcs"), cc.xyw(1, 17, 12)); builder.addLabel(Resourcer.getString(this.getClass(), "heightInc"), cc.xy(2, 19)); builder.add(getJIncZ(allowEmptyValues), cc.xy(4, 19)); builder.addLabel(Resourcer.getString(this.getClass(), "axisDistance"), cc.xy(6, 19)); builder.add(getJDeje(allowEmptyValues), cc.xy(8, 19)); builder.add(getButtonBarPanel(), cc.xyw(1, 21, 12, CellConstraints.CENTER, CellConstraints.CENTER)); jPanel.add(builder.getPanel()); } return jPanel; }
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfControlPanel.java
License:EUPL
/** * Builds and answer the control tab for the given layout. * * @param errors List of errors.// w w w .j av a 2s .co m * @return the control 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 layaout 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; // First row of the panel. builder = this.buildEntityTypeText(builder, cc); // Second row is the panel. builder = buildMainPanel(builder, cc); builder.addSeparator("", cc.xyw(1, this.rowNb, 7)); setNextRow(); JButton previousTabBtn = new ButtonTab(labels.getString("eaccpf.commons.previousTab")); builder.add(previousTabBtn, cc.xy(1, rowNb)); previousTabBtn.addActionListener(new PreviousTabBtnAction(this.eaccpf, this.tabbedPane, this.model)); // Row for exit and save buttons. setNextRow(); JButton exitBtn = new ButtonTab(this.labels.getString("eaccpf.commons.exit")); builder.add(exitBtn, cc.xy(1, this.rowNb)); exitBtn.addActionListener(new ExitBtnAction(this.eaccpf, this.tabbedPane, this.model)); JButton saveBtn = new ButtonTab(labels.getString("eaccpf.commons.save")); builder.add(saveBtn, cc.xy(5, this.rowNb)); saveBtn.addActionListener(new SaveBtnAction(this.eaccpf, this.tabbedPane, this.model)); // Define the change tab listener. this.removeChangeListener(); this.tabbedPane.addChangeListener(new ChangeTabListener(this.eaccpf, this.tabbedPane, this.model, 3)); JPanel panel = builder.getPanel(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addPropertyChangeListener(new FocusManagerListener(panel)); return panel; }
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfControlPanel.java
License:EUPL
private PanelBuilder buildMainPanel(PanelBuilder builder, CellConstraints cc) { JLabel jLabelIdInTheApeEACCPF = new JLabel(this.labels.getString("eaccpf.control.idintheapeeaccpf")); builder.add(jLabelIdInTheApeEACCPF, cc.xy(1, rowNb)); //extracted from dashboard implementation Random random = new Random(); String value = ""; // String mainagencycode = (this.eaccpf.getControl().getMaintenanceAgency().getAgencyCode()!=null && this.eaccpf.getControl().getMaintenanceAgency().getAgencyCode().getValue()!=null )?this.eaccpf.getControl().getMaintenanceAgency().getAgencyCode().getValue():""; if (this.eaccpf.getControl().getRecordId().getValue() == null || this.eaccpf.getControl().getRecordId().getValue().isEmpty()) { int fakeId = random.nextInt(1000000000); value = Integer.toString(fakeId); // value = "eac_" + mainagencycode + "_" + Integer.toString(fakeId); } else {/*from ww w . ja v a 2 s . c o m*/ value = this.eaccpf.getControl().getRecordId().getValue(); } JTextField jTextFieldIdInTheApeEACCPF = new JTextField(value); jTextFieldIdInTheApeEACCPF.setEnabled(false); //put like disabled, it's not editable builder.add(jTextFieldIdInTheApeEACCPF, cc.xy(3, rowNb)); this.idAutogeneratedControl = jTextFieldIdInTheApeEACCPF.getText(); //It's not shown because field is autogenerated and it's not editabled (eaccpf object has no access to this value by form) setNextRow(); JLabel jLabelLinkPersonResponsible = new JLabel( this.labels.getString("eaccpf.control.personinstitutionresponsiblefordescription")); builder.add(jLabelLinkPersonResponsible, cc.xy(1, rowNb)); String content = ""; if (StringUtils.isNotEmpty(responsible)) { content = responsible; } else if (this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent().size() > 0 && this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent() .get(this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent().size() - 1) .getAgent() != null && this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent() .get(this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent().size() - 1) .getAgent().getContent() != null && !this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent() .get(this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent().size() - 1) .getAgent().getContent().isEmpty()) { content = this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent() .get(this.eaccpf.getControl().getMaintenanceHistory().getMaintenanceEvent().size() - 1) .getAgent().getContent(); } else { content = MAINTENANCE_AGENT_HUMAN; } JTextField jTextFieldPersonResponsible = new JTextField(content); builder.add(jTextFieldPersonResponsible, cc.xy(3, rowNb)); this.personInstitutionResponsibleTextField = jTextFieldPersonResponsible; setNextRow(); JLabel jLabelIdentifierForPersonResponsible = new JLabel( this.labels.getString("eaccpf.control.identifierofinstitutionresponsible") + "*"); builder.add(jLabelIdentifierForPersonResponsible, cc.xy(1, rowNb)); content = eaccpf.getControl().getMaintenanceAgency().getAgencyCode().getValue() != null ? eaccpf.getControl().getMaintenanceAgency().getAgencyCode().getValue() : ""; JTextField jTextFieldIdentifierForPersonResponsible = new JTextField(content); builder.add(jTextFieldIdentifierForPersonResponsible, cc.xy(3, rowNb)); this.idControl = jTextFieldIdentifierForPersonResponsible; setNextRow(); if (StringUtils.isEmpty(content)) { builder.add(createErrorLabel(this.labels.getString("eaccpf.control.error.emptyidentifier")), cc.xyw(1, this.rowNb, 3)); setNextRow(); } if (this.eaccpf.getControl().getOtherRecordId().isEmpty()) { OtherRecordId newOtherRecordId = new OtherRecordId(); newOtherRecordId.setLocalType(EacCpfPanel.LOCAL_TYPE_ORIGINAL); this.eaccpf.getControl().getOtherRecordId().add(newOtherRecordId); } List<OtherRecordId> otherRecordIds = this.eaccpf.getControl().getOtherRecordId(); this.localIdentifierForInstitution = new ArrayList<JTextField>(otherRecordIds.size()); this.listIdentifierType = new ArrayList<JTextField>(otherRecordIds.size()); for (OtherRecordId otherRecordId : otherRecordIds) { // Create element. JTextField jTextFieldLocalIdentifierPersonResponsible = new JTextField(otherRecordId.getContent()); JTextField jTextFieldIdentifierType = new JTextField(otherRecordId.getLocalType()); // Add elements to the list. this.localIdentifierForInstitution.add(jTextFieldLocalIdentifierPersonResponsible); this.listIdentifierType.add(jTextFieldIdentifierType); builder.addLabel(this.labels.getString("eaccpf.control.otherRecordIdentifier"), cc.xy(1, this.rowNb)); builder.add(jTextFieldLocalIdentifierPersonResponsible, cc.xy(3, this.rowNb)); this.setNextRow(); } JButton nextTabBtn = new ButtonTab(this.labels.getString("eaccpf.control.addlocalidentifier")); builder.add(nextTabBtn, cc.xy(1, this.rowNb)); nextTabBtn.addActionListener(new AddLocalIdentifier(eaccpf, tabbedPane, model)); setNextRow(); builder.addLabel(this.labels.getString("eaccpf.control.usedlanguagesandscriptsfordescription"), cc.xyw(1, this.rowNb, 7)); setNextRow(); builder.addLabel(labels.getString("eaccpf.commons.select.language") + "*" + ":", cc.xy(1, rowNb)); LanguageWithScript languageWithScript = new LanguageWithScript(firstLanguage, firstScript, labels); JComboBox<String> scriptBox = languageWithScript.getScriptBox(); //fix for script part, it's not selecting values boolean found = false; int size = scriptBox.getModel().getSize(); for (int i = 0; !found && i < size; i++) { String element = scriptBox.getModel().getElementAt(i); if (element != null && element.equalsIgnoreCase(firstScript)) { scriptBox.setSelectedIndex(i); found = true; } } //end fix for script part builder.add(languageWithScript.getLanguageBox(), cc.xy(3, rowNb)); this.languageFirst = languageWithScript.getLanguageBox(); builder.addLabel(labels.getString("eaccpf.control.selectascript") + "*" + ":", cc.xy(5, rowNb)); builder.add(languageWithScript.getScriptBox(), cc.xy(7, rowNb)); this.scriptFirst = languageWithScript.getScriptBox(); this.languageWithScript = languageWithScript; setNextRow(); return builder; }
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfDescriptionPanel.java
License:EUPL
/** * Method to build the label with the text related to the entity type. * * @param builder// ww w . j a v a 2s . c o m * @param cc * @return the PanelBuilder */ private PanelBuilder buildEntityTypeText(PanelBuilder builder, CellConstraints cc) { // First row of the panel. this.rowNb = 1; // Try to recover the type. String type = ""; if (this.eaccpf != null && this.eaccpf.getCpfDescription() != null && this.eaccpf.getCpfDescription().getIdentity() != null && this.eaccpf.getCpfDescription().getIdentity().getEntityType() != null && this.eaccpf.getCpfDescription().getIdentity().getEntityType().getValue() != null && !StringUtils.isEmpty(this.eaccpf.getCpfDescription().getIdentity().getEntityType().getValue())) { type = this.eaccpf.getCpfDescription().getIdentity().getEntityType().getValue(); } else { type = this.entityType.getName(); } if (XmlTypeEacCpf.EAC_CPF_CORPORATEBODY.getName().equalsIgnoreCase(type)) { builder.addLabel(this.labels.getString("eaccpf.commons.type") + " " + this.labels.getString("eaccpf.commons.corporateBody"), cc.xyw(1, this.rowNb, 3)); this.entityType = XmlTypeEacCpf.EAC_CPF_CORPORATEBODY; } else if (XmlTypeEacCpf.EAC_CPF_FAMILY.getName().equalsIgnoreCase(type)) { builder.addLabel(this.labels.getString("eaccpf.commons.type") + " " + this.labels.getString("eaccpf.commons.family"), cc.xyw(1, this.rowNb, 3)); this.entityType = XmlTypeEacCpf.EAC_CPF_FAMILY; } else if (XmlTypeEacCpf.EAC_CPF_PERSON.getName().equalsIgnoreCase(type)) { builder.addLabel(this.labels.getString("eaccpf.commons.type") + " " + this.labels.getString("eaccpf.commons.person"), cc.xyw(1, this.rowNb, 3)); this.entityType = XmlTypeEacCpf.EAC_CPF_PERSON; } else { builder.addLabel(this.labels.getString("eaccpf.commons.unrecognized.type"), cc.xyw(1, this.rowNb, 3)); } this.setNextRow(); builder.addSeparator("", cc.xyw(1, this.rowNb, 7)); this.setNextRow(); return builder; }