| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.event.KeyAdapter; |
| | | import java.awt.event.KeyEvent; |
| | | import java.awt.event.MouseAdapter; |
| | | import java.awt.event.MouseEvent; |
| | | import java.util.Comparator; |
| | |
| | | gbc.insets.top = 10; |
| | | add(Utilities.createScrollPane(usedByAttributes), gbc); |
| | | |
| | | MouseAdapter doubleClickListener = new MouseAdapter() |
| | | MouseAdapter clickListener = new MouseAdapter() |
| | | { |
| | | public void mouseClicked(MouseEvent ev) |
| | | { |
| | | if (ev.getClickCount() > 1) |
| | | if (ev.getClickCount() == 1) |
| | | { |
| | | String o = (String)usedByAttributes.getSelectedValue(); |
| | | if (o != null) |
| | | { |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(o.toLowerCase()); |
| | | if (attr != null) |
| | | { |
| | | notifySchemaSelectionListeners(attr); |
| | | } |
| | | } |
| | | } |
| | | usedBySelected(); |
| | | } |
| | | } |
| | | }; |
| | | usedByAttributes.addMouseListener(doubleClickListener); |
| | | usedByAttributes.addMouseListener(clickListener); |
| | | |
| | | KeyAdapter keyListener = new KeyAdapter() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void keyTyped(KeyEvent ev) |
| | | { |
| | | if ((ev.getKeyChar() == KeyEvent.VK_SPACE) || |
| | | (ev.getKeyChar() == KeyEvent.VK_ENTER)) |
| | | { |
| | | usedBySelected(); |
| | | } |
| | | } |
| | | }; |
| | | usedByAttributes.addKeyListener(keyListener); |
| | | |
| | | setBorder(PANEL_BORDER); |
| | | } |
| | | |
| | |
| | | model.addElement(attr); |
| | | } |
| | | } |
| | | |
| | | private void usedBySelected() |
| | | { |
| | | String o = (String)usedByAttributes.getSelectedValue(); |
| | | if (o != null) |
| | | { |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(o.toLowerCase()); |
| | | if (attr != null) |
| | | { |
| | | notifySchemaSelectionListeners(attr); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |