| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import javax.swing.event.DocumentEvent; |
| | | import javax.swing.event.DocumentListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BrowserNodeInfo; |
| | | import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | /** |
| | | * The panel to create a group. |
| | | * |
| | | */ |
| | | /** The panel to create a group. */ |
| | | public class NewGroupPanel extends AbstractNewEntryPanel |
| | | { |
| | | private static final long serialVersionUID = -8173120152617813282L; |
| | |
| | | private JLabel lLDAPURL; |
| | | private JLabel lReferenceGroup; |
| | | |
| | | |
| | | private JLabel[] labels = {lName, lDescription, lMembers, lDn}; |
| | | |
| | | private JTextField name = Utilities.createLongTextField(); |
| | |
| | | |
| | | private JLabel dn = Utilities.createDefaultLabel(); |
| | | |
| | | |
| | | /** |
| | | * An array containing the fields of this panel. |
| | | */ |
| | | /** An array containing the fields of this panel. */ |
| | | protected final JTextField[] fields = {name, description, filter, |
| | | referenceGroup}; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | /** Default constructor. */ |
| | | public NewGroupPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setParent(BasicNode parentNode, BrowserController controller) |
| | | { |
| | | super.setParent(parentNode, controller); |
| | |
| | | filter.setText("ldap:///"+parentNode.getDN()+"??sub?(<your filter>)"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_NEW_GROUP_PANEL_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected LocalizableMessage getProgressDialogTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_NEW_GROUP_PANEL_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected boolean checkSyntaxBackground() |
| | | { |
| | | return staticGroup.isSelected(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void checkSyntax(ArrayList<LocalizableMessage> errors) |
| | | { |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | for (JLabel label : labels) |
| | |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | setSecondaryInvalid(lMemberDNs); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Creates the layout of the panel (but the contents are not populated here). |
| | | */ |
| | | /** Creates the layout of the panel (but the contents are not populated here). */ |
| | | private void createLayout() |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | |
| | | staticGroup.setSelected(true); |
| | | ActionListener actionListener = new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | checkEnabling(); |
| | |
| | | |
| | | addMembers.addActionListener(new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | addMembersClicked(); |
| | |
| | | Utilities.createButton(INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get()); |
| | | browseReferenceGroup.addActionListener(new ActionListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | browseReferenceGroupClicked(); |
| | |
| | | }); |
| | | p.add(browseReferenceGroup, gbc2); |
| | | |
| | | |
| | | DocumentListener listener = new DocumentListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void insertUpdate(DocumentEvent ev) |
| | | { |
| | | updateDNValue(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void changedUpdate(DocumentEvent ev) |
| | | { |
| | | insertUpdate(ev); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeUpdate(DocumentEvent ev) |
| | | { |
| | | insertUpdate(ev); |
| | |
| | | |
| | | DropTargetListener dropTargetlistener = new DropTargetListener() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void dragEnter(DropTargetDragEvent e) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void dragExit(DropTargetEvent e) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void dragOver(DropTargetDragEvent e) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void dropActionChanged(DropTargetDragEvent e) |
| | | { |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void drop(DropTargetDropEvent e) |
| | | { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected String getLDIF() |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | lReferenceGroup.setEnabled(virtualGroup.isSelected()); |
| | | } |
| | | } |
| | | |