private JPanel createAutoGeneratedIDPanel() { autoGeneratedIDPanel = new JPanel(); autoGeneratedIDPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); autoGeneratedIDPanel.setBorder(new TitledBorder("Auto-generated ID")); JPanel interiorPanel = new JPanel(new BorderLayout(32, 0)); interiorPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 0, 0)); // Left panel - radio buttons JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); iterativeButton = new JRadioButton("Numeric (iterative)"); uniqueIdButton = new JRadioButton("Globally unique"); final Class<? extends AutoIDGenerator> autoIDGenCls = EntityCreationPreferences.getAutoIDGeneratorClass(); iterativeButton.setSelected(autoIDGenCls.equals(IterativeAutoIDGenerator.class)); uniqueIdButton.setSelected(autoIDGenCls.equals(UniqueIdGenerator.class)); ButtonGroup group = new ButtonGroup(); group.add(iterativeButton); group.add(uniqueIdButton); iterativeButton.addActionListener(this); uniqueIdButton.addActionListener(this); leftPanel.add(iterativeButton); leftPanel.add(uniqueIdButton); leftPanel.add(Box.createVerticalGlue()); // Center panel - random group of components JPanel centerPanel = new JPanel(); centerPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // Prefix label c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, 0, 5, 0); c.anchor = GridBagConstraints.LINE_END; prefixLabel = new JLabel("Prefix: "); centerPanel.add(prefixLabel, c); // Prefix text field c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDPrefix = new JTextField(); autoIDPrefix.setText(EntityCreationPreferences.getPrefix()); autoIDPrefix.setColumns(30); centerPanel.add(autoIDPrefix, c); // Suffix label c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_END; suffixLabel = new JLabel("Suffix: "); centerPanel.add(suffixLabel, c); // Suffix text field c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDSuffix = new JTextField(); autoIDSuffix.setText(EntityCreationPreferences.getSuffix()); autoIDSuffix.setColumns(30); centerPanel.add(autoIDSuffix, c); // Digit count label c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_END; digitCountLabel = new JLabel("Digit count: "); centerPanel.add(digitCountLabel, c); // Digit count spinner c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.FIRST_LINE_START; c.weightx = 0.5; autoIDDigitCount = new JSpinner(new SpinnerNumberModel(6, 0, 255, 1)); autoIDDigitCount.setValue(EntityCreationPreferences.getAutoIDDigitCount()); autoIDDigitCount.setPreferredSize(new Dimension(100, 20)); centerPanel.add(autoIDDigitCount, c); // Start label c.gridx = 0; c.gridy = 3; c.weightx = 0; c.anchor = GridBagConstraints.LINE_END; startLabel = new JLabel("Start: "); startLabel.setEnabled(iterativeButton.isSelected()); centerPanel.add(startLabel, c); // Start spinner c.gridx = 1; c.gridy = 3; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDStart = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); autoIDStart.setPreferredSize(new Dimension(100, 20)); autoIDStart.setValue(EntityCreationPreferences.getAutoIDStart()); autoIDStart.setEnabled(iterativeButton.isSelected()); autoIDStart.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { if ((Integer) autoIDEnd.getValue() != -1 && (Integer) autoIDEnd.getValue() <= (Integer) autoIDStart.getValue()) { autoIDEnd.setValue(autoIDStart.getValue()); } } }); centerPanel.add(autoIDStart, c); // End label c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.LINE_END; endLabel = new JLabel("End: "); endLabel.setEnabled(iterativeButton.isSelected()); centerPanel.add(endLabel, c); // End spinner c.gridx = 1; c.gridy = 4; c.anchor = GridBagConstraints.FIRST_LINE_START; autoIDEnd = new JSpinner(new SpinnerNumberModel(-1, -1, Integer.MAX_VALUE, 1)); autoIDEnd.setPreferredSize(new Dimension(100, 20)); autoIDEnd.setValue(EntityCreationPreferences.getAutoIDEnd()); autoIDEnd.setEnabled(iterativeButton.isSelected()); autoIDEnd.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { if ((Integer) autoIDEnd.getValue() != -1 && (Integer) autoIDEnd.getValue() <= (Integer) autoIDStart.getValue()) { autoIDStart.setValue(autoIDEnd.getValue()); } } }); centerPanel.add(autoIDEnd, c); // Remember last ID checkbox c.gridx = 1; c.gridy = 5; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 1.0; saveIterativeIds = new JCheckBox("Remember last ID between Prot\u00E9g\u00E9 sessions"); saveIterativeIds.setSelected(EntityCreationPreferences.getSaveAutoIDStart()); saveIterativeIds.setEnabled(iterativeButton.isSelected()); centerPanel.add(saveIterativeIds, c); // Dummy label for spacing purposes c.gridx = 2; c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.weighty = 0; centerPanel.add(new JLabel("")); enableAutoGeneratedIDPanel(autoIDIriFragment.isSelected()); enableLabelCreationPanel(autoIDIriFragment.isSelected()); interiorPanel.add(leftPanel, BorderLayout.LINE_START); interiorPanel.add(centerPanel, BorderLayout.CENTER); autoGeneratedIDPanel.add(interiorPanel); return autoGeneratedIDPanel; }