001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2009 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.quicksetup.installer.ui; 028 029import static org.opends.messages.QuickSetupMessages.*; 030 031import java.awt.Component; 032import java.awt.GridBagConstraints; 033import java.awt.GridBagLayout; 034import java.awt.event.ActionEvent; 035import java.awt.event.ActionListener; 036import java.awt.event.FocusEvent; 037import java.awt.event.FocusListener; 038import java.util.HashMap; 039import java.util.List; 040 041import javax.swing.Box; 042import javax.swing.ButtonGroup; 043import javax.swing.JButton; 044import javax.swing.JComboBox; 045import javax.swing.JLabel; 046import javax.swing.JPanel; 047import javax.swing.JRadioButton; 048import javax.swing.event.DocumentEvent; 049import javax.swing.event.DocumentListener; 050import javax.swing.text.JTextComponent; 051 052import org.forgerock.i18n.LocalizableMessage; 053import org.opends.quicksetup.UserData; 054import org.opends.quicksetup.event.BrowseActionListener; 055import org.opends.quicksetup.installer.NewSuffixOptions; 056import org.opends.quicksetup.ui.FieldName; 057import org.opends.quicksetup.ui.GuiApplication; 058import org.opends.quicksetup.ui.LabelFieldDescriptor; 059import org.opends.quicksetup.ui.QuickSetupStepPanel; 060import org.opends.quicksetup.ui.UIFactory; 061import org.opends.quicksetup.ui.Utilities; 062import org.opends.server.tools.BackendTypeHelper; 063import org.opends.server.tools.BackendTypeHelper.BackendTypeUIAdapter; 064 065/** 066 * This is the panel that contains the Data Options: the suffix dn, whether to 067 * import data to the suffix or not, etc. 068 */ 069public class DataOptionsPanel extends QuickSetupStepPanel 070{ 071 private static final long serialVersionUID = 1815782841921928118L; 072 073 private Component lastFocusComponent; 074 private UserData defaultUserData; 075 076 private HashMap<FieldName, JLabel> hmLabels = new HashMap<>(); 077 private HashMap<FieldName, JTextComponent> hmFields = new HashMap<>(); 078 private HashMap<NewSuffixOptions.Type, JRadioButton> hmRadioButtons = new HashMap<>(); 079 080 private JButton ldifBrowseButton; 081 private JComboBox<BackendTypeUIAdapter> backendTypeComboBox; 082 083 /** 084 * Constructor of the panel. 085 * 086 * @param application 087 * Application represented by this panel the fields of the panel. 088 */ 089 public DataOptionsPanel(GuiApplication application) 090 { 091 super(application); 092 this.defaultUserData = application.getUserData(); 093 populateComponentMaps(); 094 createBackendTypeComboBox(); 095 addDocumentListeners(); 096 addFocusListeners(); 097 addActionListeners(); 098 } 099 100 /** {@inheritDoc} */ 101 public Object getFieldValue(FieldName fieldName) 102 { 103 if (fieldName == FieldName.DATA_OPTIONS) 104 { 105 for (NewSuffixOptions.Type type : hmRadioButtons.keySet()) 106 { 107 if (hmRadioButtons.get(type).isSelected()) 108 { 109 return type; 110 } 111 } 112 } 113 else if (FieldName.BACKEND_TYPE == fieldName) 114 { 115 return ((BackendTypeUIAdapter) backendTypeComboBox.getSelectedItem()).getBackend(); 116 } 117 else 118 { 119 final JTextComponent field = getField(fieldName); 120 if (field != null) 121 { 122 return field.getText(); 123 } 124 } 125 126 return null; 127 } 128 129 /** {@inheritDoc} */ 130 public void displayFieldInvalid(final FieldName fieldName, final boolean invalid) 131 { 132 final JLabel label = getLabel(fieldName); 133 if (label != null) 134 { 135 final UIFactory.TextStyle style; 136 137 if (fieldName != FieldName.DIRECTORY_BASE_DN) 138 { 139 style = invalid ? UIFactory.TextStyle.SECONDARY_FIELD_INVALID : UIFactory.TextStyle.SECONDARY_FIELD_VALID; 140 } 141 else 142 { 143 style = invalid ? UIFactory.TextStyle.PRIMARY_FIELD_INVALID : UIFactory.TextStyle.PRIMARY_FIELD_VALID; 144 } 145 146 UIFactory.setTextStyle(label, style); 147 } 148 } 149 150 /** {@inheritDoc} */ 151 protected Component createInputPanel() 152 { 153 JPanel panel = new JPanel(new GridBagLayout()); 154 panel.setOpaque(false); 155 156 GridBagConstraints gbc = new GridBagConstraints(); 157 // Add the server location widgets 158 addBackendTypeSection(panel, gbc); 159 addBaseDNSection(panel, gbc); 160 161 int h1 = getLabel(FieldName.DATA_OPTIONS).getPreferredSize().height; 162 int h2 = getRadioButton(NewSuffixOptions.Type.CREATE_BASE_ENTRY).getPreferredSize().height; 163 int additionalInset = Math.abs(h2 - h1) / 2; 164 gbc.gridwidth = GridBagConstraints.RELATIVE; 165 gbc.weightx = 0.0; 166 gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD + additionalInset; 167 gbc.insets.left = 0; 168 gbc.anchor = GridBagConstraints.NORTHWEST; 169 panel.add(getLabel(FieldName.DATA_OPTIONS), gbc); 170 171 gbc.weightx = 1.0; 172 gbc.fill = GridBagConstraints.HORIZONTAL; 173 gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; 174 gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; 175 gbc.gridwidth = GridBagConstraints.REMAINDER; 176 panel.add(createRadioButtonPanel(), gbc); 177 178 addVerticalGlue(panel); 179 180 return panel; 181 } 182 183 private void addBackendTypeSection(final JPanel panel, final GridBagConstraints gbc) 184 { 185 gbc.gridwidth = GridBagConstraints.RELATIVE; 186 gbc.weightx = 0.0; 187 gbc.insets.top = 0; 188 gbc.insets.left = 0; 189 gbc.anchor = GridBagConstraints.WEST; 190 panel.add(getLabel(FieldName.BACKEND_TYPE), gbc); 191 192 JPanel auxPanel = new JPanel(new GridBagLayout()); 193 auxPanel.setOpaque(false); 194 gbc.gridwidth = GridBagConstraints.RELATIVE; 195 gbc.insets = UIFactory.getEmptyInsets(); 196 gbc.fill = GridBagConstraints.HORIZONTAL; 197 gbc.weightx = 0.0; 198 auxPanel.add(backendTypeComboBox, gbc); 199 200 gbc.gridwidth = GridBagConstraints.REMAINDER; 201 gbc.insets.left = UIFactory.LEFT_INSET_BROWSE; 202 gbc.weightx = 1.0; 203 gbc.fill = GridBagConstraints.HORIZONTAL; 204 auxPanel.add(Box.createHorizontalGlue(), gbc); 205 206 gbc.weightx = 1.0; 207 gbc.fill = GridBagConstraints.HORIZONTAL; 208 gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; 209 gbc.gridwidth = GridBagConstraints.REMAINDER; 210 panel.add(auxPanel, gbc); 211 } 212 213 private void addBaseDNSection(final JPanel panel, final GridBagConstraints gbc) 214 { 215 gbc.gridwidth = GridBagConstraints.RELATIVE; 216 gbc.weightx = 0.0; 217 gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; 218 gbc.insets.left = 0; 219 gbc.anchor = GridBagConstraints.WEST; 220 panel.add(getLabel(FieldName.DIRECTORY_BASE_DN), gbc); 221 222 final JPanel auxPanel = new JPanel(new GridBagLayout()); 223 auxPanel.setOpaque(false); 224 gbc.weightx = 1.0; 225 gbc.fill = GridBagConstraints.HORIZONTAL; 226 gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; 227 gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; 228 gbc.gridwidth = GridBagConstraints.REMAINDER; 229 panel.add(auxPanel, gbc); 230 231 gbc.gridwidth = GridBagConstraints.RELATIVE; 232 gbc.insets = UIFactory.getEmptyInsets(); 233 gbc.weightx = 0.0; 234 auxPanel.add(getField(FieldName.DIRECTORY_BASE_DN), gbc); 235 236 gbc.gridwidth = GridBagConstraints.REMAINDER; 237 gbc.weightx = 1.0; 238 gbc.fill = GridBagConstraints.HORIZONTAL; 239 auxPanel.add(Box.createHorizontalGlue(), gbc); 240 241 gbc.gridwidth = GridBagConstraints.RELATIVE; 242 gbc.weightx = 0.0; 243 gbc.insets.top = 0; 244 gbc.insets.left = 0; 245 gbc.anchor = GridBagConstraints.WEST; 246 panel.add(Box.createHorizontalGlue(), gbc); 247 248 gbc.insets.top = 3; 249 gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; 250 gbc.gridwidth = GridBagConstraints.REMAINDER; 251 final JLabel noBaseDNLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, INFO_NO_BASE_DN_INLINE_HELP.get(), 252 UIFactory.TextStyle.INLINE_HELP); 253 panel.add(noBaseDNLabel, gbc); 254 } 255 256 /** 257 * Returns and creates the radio buttons panel. 258 * 259 * @return the radio buttons panel. 260 */ 261 private JPanel createRadioButtonPanel() 262 { 263 JPanel panel = new JPanel(new GridBagLayout()); 264 GridBagConstraints gbc = new GridBagConstraints(); 265 panel.setOpaque(false); 266 267 gbc.gridwidth = GridBagConstraints.REMAINDER; 268 gbc.insets = UIFactory.getEmptyInsets(); 269 gbc.weightx = 1.0; 270 gbc.fill = GridBagConstraints.HORIZONTAL; 271 panel.add(getRadioButton(NewSuffixOptions.Type.LEAVE_DATABASE_EMPTY), gbc); 272 gbc.insets.top = UIFactory.TOP_INSET_RADIOBUTTON; 273 panel.add(getRadioButton(NewSuffixOptions.Type.CREATE_BASE_ENTRY), gbc); 274 panel.add(getRadioButton(NewSuffixOptions.Type.IMPORT_FROM_LDIF_FILE), gbc); 275 276 JPanel auxPanel = createBrowseButtonPanel(FieldName.LDIF_PATH, getLDIFBrowseButton()); 277 278 gbc.insets = UIFactory.getEmptyInsets(); 279 gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE; 280 gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE; 281 panel.add(auxPanel, gbc); 282 283 gbc.insets.left = 0; 284 panel.add(getRadioButton(NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA), gbc); 285 286 auxPanel = createNumberEntriesPanel(); 287 288 gbc.insets = UIFactory.getEmptyInsets(); 289 gbc.insets.top = UIFactory.TOP_INSET_SECONDARY_FIELD; 290 gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE; 291 panel.add(auxPanel, gbc); 292 293 return panel; 294 } 295 296 /** 297 * Returns the number entries panel. 298 * 299 * @return the number entries panel. 300 */ 301 private JPanel createNumberEntriesPanel() 302 { 303 JPanel panel; 304 305 GridBagConstraints gbc = new GridBagConstraints(); 306 307 panel = new JPanel(new GridBagLayout()); 308 panel.setOpaque(false); 309 gbc.gridwidth = 3; 310 gbc.insets = UIFactory.getEmptyInsets(); 311 gbc.weightx = 0.0; 312 panel.add(getLabel(FieldName.NUMBER_ENTRIES), gbc); 313 314 gbc.gridwidth--; 315 gbc.weightx = 0.1; 316 gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD; 317 panel.add(getField(FieldName.NUMBER_ENTRIES), gbc); 318 319 gbc.gridwidth = GridBagConstraints.REMAINDER; 320 gbc.weightx = 1.0; 321 gbc.fill = GridBagConstraints.HORIZONTAL; 322 panel.add(Box.createHorizontalGlue(), gbc); 323 324 return panel; 325 } 326 327 /** 328 * Creates a panel with a field and a browse button. 329 * 330 * @param fieldName 331 * the field name of the field. 332 * @param browseButton 333 * the browse button. 334 * @return the created panel. 335 */ 336 private JPanel createBrowseButtonPanel(FieldName fieldName, JButton browseButton) 337 { 338 return Utilities.createBrowseButtonPanel(getLabel(fieldName), getField(fieldName), browseButton); 339 } 340 341 /** {@inheritDoc} */ 342 protected LocalizableMessage getInstructions() 343 { 344 return INFO_DATA_OPTIONS_PANEL_INSTRUCTIONS.get(); 345 } 346 347 /** {@inheritDoc} */ 348 protected LocalizableMessage getTitle() 349 { 350 return INFO_DATA_OPTIONS_PANEL_TITLE.get(); 351 } 352 353 /** {@inheritDoc} */ 354 public void endDisplay() 355 { 356 if (lastFocusComponent != null) 357 { 358 lastFocusComponent.requestFocusInWindow(); 359 } 360 } 361 362 /** 363 * Returns the default value for the provided field Name. 364 * 365 * @param fieldName 366 * the field name for which we want to get the default value. 367 * @return the default value for the provided field Name. 368 */ 369 private String getDefaultValue(FieldName fieldName) 370 { 371 final NewSuffixOptions suffixOptions = defaultUserData.getNewSuffixOptions(); 372 switch (fieldName) 373 { 374 case DIRECTORY_BASE_DN: 375 return firstElementOrNull(suffixOptions.getBaseDns()); 376 377 case LDIF_PATH: 378 return firstElementOrNull(suffixOptions.getLDIFPaths()); 379 380 default: 381 throw new IllegalArgumentException("Unknown field name: " + fieldName); 382 } 383 } 384 385 private String firstElementOrNull(final List<String> list) 386 { 387 if (list != null && !list.isEmpty()) 388 { 389 return list.get(0); 390 } 391 392 return null; 393 } 394 395 /** Creates the components and populates the Maps with them. */ 396 private void populateComponentMaps() 397 { 398 final HashMap<FieldName, LabelFieldDescriptor> hm = new HashMap<>(); 399 400 final LabelFieldDescriptor baseDNLabelDescriptor = new LabelFieldDescriptor( 401 INFO_BASE_DN_LABEL.get(), INFO_BASE_DN_TOOLTIP.get(), LabelFieldDescriptor.FieldType.TEXTFIELD, 402 LabelFieldDescriptor.LabelType.PRIMARY, UIFactory.DN_FIELD_SIZE); 403 hm.put(FieldName.DIRECTORY_BASE_DN, baseDNLabelDescriptor); 404 405 final LabelFieldDescriptor importPathLabelDescriptor = new LabelFieldDescriptor( 406 INFO_IMPORT_PATH_LABEL.get(), INFO_IMPORT_PATH_TOOLTIP.get(), LabelFieldDescriptor.FieldType.TEXTFIELD, 407 LabelFieldDescriptor.LabelType.SECONDARY, UIFactory.PATH_FIELD_SIZE); 408 hm.put(FieldName.LDIF_PATH, importPathLabelDescriptor); 409 410 final LabelFieldDescriptor entryNumberLabelDescriptor = new LabelFieldDescriptor( 411 INFO_NUMBER_ENTRIES_LABEL.get(), INFO_NUMBER_ENTRIES_TOOLTIP.get(), LabelFieldDescriptor.FieldType.TEXTFIELD, 412 LabelFieldDescriptor.LabelType.SECONDARY, UIFactory.NUMBER_ENTRIES_FIELD_SIZE); 413 hm.put(FieldName.NUMBER_ENTRIES, entryNumberLabelDescriptor); 414 415 for (final FieldName fieldName : hm.keySet()) 416 { 417 final LabelFieldDescriptor desc = hm.get(fieldName); 418 final String defaultValue = fieldName == FieldName.NUMBER_ENTRIES ? 419 Integer.toString(defaultUserData.getNewSuffixOptions().getNumberEntries()) 420 : getDefaultValue(fieldName); 421 final JTextComponent field = UIFactory.makeJTextComponent(desc, defaultValue); 422 final JLabel label = UIFactory.makeJLabel(desc); 423 label.setLabelFor(field); 424 hmFields.put(fieldName, field); 425 hmLabels.put(fieldName, label); 426 } 427 428 final JLabel dataLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, INFO_DIRECTORY_DATA_LABEL.get(), 429 UIFactory.TextStyle.PRIMARY_FIELD_VALID); 430 hmLabels.put(FieldName.DATA_OPTIONS, dataLabel); 431 432 final JLabel backendTypeLabel = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, INFO_BACKEND_TYPE_LABEL.get(), 433 UIFactory.TextStyle.PRIMARY_FIELD_VALID); 434 hmLabels.put(FieldName.BACKEND_TYPE, backendTypeLabel); 435 createDirectoryDataChoiceRadioButton(dataLabel); 436 checkEnablingState(); 437 } 438 439 private void createBackendTypeComboBox() 440 { 441 final BackendTypeHelper backendTypeHelper = new BackendTypeHelper(); 442 backendTypeComboBox = new JComboBox<>(backendTypeHelper.getBackendTypeUIAdaptors()); 443 } 444 445 private void createDirectoryDataChoiceRadioButton(final JLabel dataLabel) 446 { 447 final JRadioButton createBaseEntryRB = UIFactory.makeJRadioButton( 448 INFO_CREATE_BASE_ENTRY_LABEL.get(getDefaultValue(FieldName.DIRECTORY_BASE_DN)), 449 INFO_CREATE_BASE_ENTRY_TOOLTIP.get(), 450 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 451 hmRadioButtons.put(NewSuffixOptions.Type.CREATE_BASE_ENTRY, createBaseEntryRB); 452 453 final JRadioButton leaveDataBaseEmptyRB = UIFactory.makeJRadioButton( 454 INFO_LEAVE_DATABASE_EMPTY_LABEL.get(), 455 INFO_LEAVE_DATABASE_EMPTY_TOOLTIP.get(), 456 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 457 hmRadioButtons.put(NewSuffixOptions.Type.LEAVE_DATABASE_EMPTY, leaveDataBaseEmptyRB); 458 dataLabel.setLabelFor(leaveDataBaseEmptyRB); 459 460 final JRadioButton importFileDataRB = UIFactory.makeJRadioButton( 461 INFO_IMPORT_DATA_FROM_LDIF_LABEL.get(), 462 INFO_IMPORT_DATA_FROM_LDIF_TOOLTIP.get(), 463 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 464 hmRadioButtons.put(NewSuffixOptions.Type.IMPORT_FROM_LDIF_FILE, importFileDataRB); 465 466 final JRadioButton importGeneratedDataRB = UIFactory.makeJRadioButton( 467 INFO_IMPORT_AUTOMATICALLY_GENERATED_LABEL.get(), 468 INFO_IMPORT_AUTOMATICALLY_GENERATED_TOOLTIP.get(), 469 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 470 hmRadioButtons.put(NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA, importGeneratedDataRB); 471 472 final NewSuffixOptions.Type defaultType = defaultUserData.getNewSuffixOptions().getType(); 473 final ButtonGroup buttonGroup = new ButtonGroup(); 474 for (NewSuffixOptions.Type type : hmRadioButtons.keySet()) 475 { 476 final JRadioButton radioButton = hmRadioButtons.get(type); 477 radioButton.setSelected(type == defaultType); 478 buttonGroup.add(radioButton); 479 } 480 } 481 482 private JButton getLDIFBrowseButton() 483 { 484 if (ldifBrowseButton == null) 485 { 486 ldifBrowseButton = UIFactory.makeJButton(INFO_BROWSE_BUTTON_LABEL.get(), INFO_BROWSE_BUTTON_TOOLTIP.get()); 487 488 final BrowseActionListener listener = new BrowseActionListener( 489 getField(FieldName.LDIF_PATH), BrowseActionListener.BrowseType.OPEN_LDIF_FILE, getMainWindow()); 490 ldifBrowseButton.addActionListener(listener); 491 } 492 493 return ldifBrowseButton; 494 } 495 496 /** Adds all the required document listeners to the fields. */ 497 private void addDocumentListeners() 498 { 499 final DocumentListener docListener = new DocumentListener() 500 { 501 public void changedUpdate(DocumentEvent ev) 502 { 503 final LocalizableMessage newLabel = 504 INFO_CREATE_BASE_ENTRY_LABEL.get((String) getFieldValue(FieldName.DIRECTORY_BASE_DN)); 505 getRadioButton(NewSuffixOptions.Type.CREATE_BASE_ENTRY).setText(newLabel.toString()); 506 } 507 508 public void insertUpdate(DocumentEvent ev) 509 { 510 changedUpdate(ev); 511 } 512 513 public void removeUpdate(DocumentEvent ev) 514 { 515 changedUpdate(ev); 516 } 517 }; 518 519 getField(FieldName.DIRECTORY_BASE_DN).getDocument().addDocumentListener(docListener); 520 } 521 522 /** Adds the required focus listeners to the fields. */ 523 private void addFocusListeners() 524 { 525 final FocusListener focusListener = new FocusListener() 526 { 527 public void focusGained(FocusEvent e) 528 { 529 lastFocusComponent = e.getComponent(); 530 if (lastFocusComponent == getField(FieldName.LDIF_PATH)) 531 { 532 getRadioButton(NewSuffixOptions.Type.IMPORT_FROM_LDIF_FILE).setSelected(true); 533 } 534 else if (lastFocusComponent == getField(FieldName.NUMBER_ENTRIES)) 535 { 536 getRadioButton(NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA).setSelected(true); 537 } 538 } 539 540 public void focusLost(FocusEvent e) 541 { 542 } 543 }; 544 545 for (JTextComponent tf : hmFields.values()) 546 { 547 tf.addFocusListener(focusListener); 548 } 549 for (JRadioButton rb : hmRadioButtons.values()) 550 { 551 rb.addFocusListener(focusListener); 552 } 553 getLDIFBrowseButton().addFocusListener(focusListener); 554 555 lastFocusComponent = getField(FieldName.DIRECTORY_BASE_DN); 556 } 557 558 /** Adds the required focus listeners to the fields. */ 559 private void addActionListeners() 560 { 561 final ActionListener l = new ActionListener() 562 { 563 public void actionPerformed(ActionEvent e) 564 { 565 checkEnablingState(); 566 } 567 }; 568 569 for (final JRadioButton radioButton : hmRadioButtons.values()) 570 { 571 radioButton.addActionListener(l); 572 } 573 } 574 575 /** Enables/disables the fields. */ 576 private void checkEnablingState() 577 { 578 boolean importLDIF = getRadioButton(NewSuffixOptions.Type.IMPORT_FROM_LDIF_FILE).isSelected(); 579 boolean automaticData = getRadioButton(NewSuffixOptions.Type.IMPORT_AUTOMATICALLY_GENERATED_DATA).isSelected(); 580 581 getField(FieldName.LDIF_PATH).setEnabled(importLDIF); 582 getLDIFBrowseButton().setEnabled(importLDIF); 583 getField(FieldName.NUMBER_ENTRIES).setEnabled(automaticData); 584 585 getLabel(FieldName.LDIF_PATH).setEnabled(importLDIF); 586 getLabel(FieldName.NUMBER_ENTRIES).setEnabled(automaticData); 587 } 588 589 private JLabel getLabel(FieldName fieldName) 590 { 591 return hmLabels.get(fieldName); 592 } 593 594 private JTextComponent getField(FieldName fieldName) 595 { 596 return hmFields.get(fieldName); 597 } 598 599 private JRadioButton getRadioButton(NewSuffixOptions.Type type) 600 { 601 return hmRadioButtons.get(type); 602 } 603}