| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.Insets; |
| | | import java.awt.Point; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.awt.event.KeyAdapter; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.TreeCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.api.MatchingRule; |
| | |
| | | private SchemaBrowserRightPanel entryPane; |
| | | private TreePanel treePane; |
| | | |
| | | private JScrollPane treeScroll; |
| | | |
| | | private TreePath lastEntryTreePath; |
| | | |
| | | private Schema lastSchema; |
| | |
| | | if ((e.getKeyCode() == KeyEvent.VK_ENTER) && applyButton.isEnabled()) |
| | | { |
| | | filter.displayRefreshIcon(FilterTextField.DEFAULT_REFRESH_ICON_TIME); |
| | | repopulateTree(treePane.getTree()); |
| | | repopulateTree(treePane.getTree(), false); |
| | | } |
| | | } |
| | | }); |
| | |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | filter.displayRefreshIcon(FilterTextField.DEFAULT_REFRESH_ICON_TIME); |
| | | repopulateTree(treePane.getTree()); |
| | | repopulateTree(treePane.getTree(), false); |
| | | } |
| | | }); |
| | | gbc.gridx ++; |
| | |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | filter.displayRefreshIcon(FilterTextField.DEFAULT_REFRESH_ICON_TIME); |
| | | repopulateTree(treePane.getTree()); |
| | | repopulateTree(treePane.getTree(), false); |
| | | } |
| | | }); |
| | | |
| | |
| | | Utilities.setBorder(lNoMatchFound, new EmptyBorder(15, 15, 15, 15)); |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | p.add(lNoMatchFound, gbc); |
| | | JScrollPane treeScroll = Utilities.createScrollPane(p); |
| | | treeScroll = Utilities.createScrollPane(p); |
| | | |
| | | entryPane.addSchemaElementSelectionListener( |
| | | new SchemaElementSelectionListener() |
| | |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | final ServerDescriptor desc = ev.getNewDescriptor(); |
| | | final boolean forceScroll = lastSchema == null; |
| | | if ((lastSchema == null) || |
| | | !ServerDescriptor.areSchemasEqual(lastSchema, desc.getSchema())|| |
| | | true) |
| | |
| | | { |
| | | public void run() |
| | | { |
| | | repopulateTree(treePane.getTree()); |
| | | repopulateTree(treePane.getTree(), forceScroll); |
| | | } |
| | | }); |
| | | } |
| | |
| | | /** |
| | | * Repopulates the tree. |
| | | * @param tree the tree to be repopulated. |
| | | * @param forceScroll whether the scroll must be reset or not. |
| | | */ |
| | | private void repopulateTree(JTree tree) |
| | | private void repopulateTree(JTree tree, final boolean forceScroll) |
| | | { |
| | | if (lastSchema == null) |
| | | { |
| | | return; |
| | | } |
| | | ignoreSelectionEvents = true; |
| | | |
| | | final Point currentPosition = treeScroll.getViewport().getViewPosition(); |
| | | |
| | | DefaultMutableTreeNode root = getRoot(tree); |
| | | |
| | | TreePath path = tree.getSelectionPath(); |
| | |
| | | } |
| | | } |
| | | repaint(); |
| | | |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | if (forceScroll) |
| | | { |
| | | treeScroll.getViewport().setViewPosition(new Point(0, 0)); |
| | | } |
| | | else |
| | | { |
| | | treeScroll.getViewport().setViewPosition(currentPosition); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void updateEntryPane() |
| | | { |
| | | ViewPositions pos = Utilities.getViewPositions(entryPane); |
| | | TreePath[] paths = treePane.getTree().getSelectionPaths(); |
| | | TreePath path = null; |
| | | if ((paths != null) && (paths.length == 1)) |
| | |
| | | entryPane.displayMessage(NO_SCHEMA_ITEM_SELECTED); |
| | | } |
| | | } |
| | | Utilities.updateViewPositions(pos); |
| | | } |
| | | |
| | | /** |