Exemplo n.º 1
0
 private void newVLVIndexClicked() {
   if (newVLVIndexPanel == null) {
     newVLVIndexPanel =
         new NewVLVIndexPanel(
             (String) backends.getSelectedItem(), Utilities.getParentDialog(this));
     newVLVIndexPanel.setInfo(getInfo());
     newVLVIndexDialog = new GenericDialog(null, newVLVIndexPanel);
     Utilities.centerGoldenMean(newVLVIndexDialog, Utilities.getParentDialog(this));
     newVLVIndexPanel.addConfigurationElementCreatedListener(
         new ConfigurationElementCreatedListener() {
           /** {@inheritDoc} */
           public void elementCreated(ConfigurationElementCreatedEvent ev) {
             Object o = ev.getConfigurationObject();
             if (o instanceof AbstractIndexDescriptor) {
               lastCreatedIndex = (AbstractIndexDescriptor) o;
             }
           }
         });
   } else if (!newVLVIndexDialog.isVisible()) {
     String backendID = (String) backends.getSelectedItem();
     for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) {
       if (backend.getBackendID().equalsIgnoreCase(backendID)) {
         newVLVIndexPanel.update(backend);
         break;
       }
     }
   }
   newVLVIndexDialog.setVisible(true);
 }
Exemplo n.º 2
0
 /**
  * Constructor of the task.
  *
  * @param info the control panel information.
  * @param dlg the progress dialog where the task progress will be displayed.
  * @param tasks the tasks to be canceled.
  */
 public CancelTaskTask(ControlPanelInfo info, ProgressDialog dlg, List<TaskEntry> tasks) {
   super(info, dlg);
   backendSet = new HashSet<String>();
   for (BackendDescriptor backend : info.getServerDescriptor().getBackends()) {
     backendSet.add(backend.getBackendID());
   }
   this.tasks = new ArrayList<TaskEntry>(tasks);
 }
Exemplo n.º 3
0
  /**
   * Repopulates the contents of the tree.
   *
   * @param tree the tree to be repopulated.
   */
  private void repopulateTree(JTree tree) {
    ignoreSelectionEvents = true;

    final Point currentPosition = treeScroll.getViewport().getViewPosition();
    DefaultMutableTreeNode root = getRoot(tree);

    TreePath path = tree.getSelectionPath();
    DefaultMutableTreeNode lastSelectedNode = null;
    if (path != null) {
      lastSelectedNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    }
    TreePath newSelectionPath = null;

    BackendDescriptor backend = null;
    String backendName = (String) backends.getSelectedItem();
    if (backendName != null) {
      for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends()) {
        if (b.getBackendID().equalsIgnoreCase(backendName)) {
          backend = b;
          break;
        }
      }
    }

    ArrayList<ArrayList<? extends AbstractIndexTreeNode>> nodes =
        new ArrayList<ArrayList<? extends AbstractIndexTreeNode>>();
    ArrayList<IndexTreeNode> standardIndexNodes = new ArrayList<IndexTreeNode>();
    ArrayList<VLVIndexTreeNode> vlvIndexNodes = new ArrayList<VLVIndexTreeNode>();
    nodes.add(standardIndexNodes);
    nodes.add(vlvIndexNodes);

    if (backend != null) {
      for (IndexDescriptor index : backend.getIndexes()) {
        standardIndexNodes.add(new IndexTreeNode(index.getName(), index));
      }
      for (VLVIndexDescriptor index : backend.getVLVIndexes()) {
        vlvIndexNodes.add(new VLVIndexTreeNode(index.getName(), index));
      }
    }

    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    int i = 0;
    int positionUnderRoot = 0;
    for (DefaultMutableTreeNode parent : categoryNodes) {
      if (nodes.get(i).size() == 0) {
        if (root.getIndex(parent) != -1) {
          model.removeNodeFromParent(parent);
          parent.removeAllChildren();
        }
      } else {
        boolean expand = true;
        if (root.getIndex(parent) == -1) {
          model.insertNodeInto(parent, root, positionUnderRoot);
        } else {
          expand = tree.isExpanded(new TreePath(parent)) || (parent.getChildCount() == 0);
          parent.removeAllChildren();
        }
        for (AbstractIndexTreeNode node : nodes.get(i)) {
          parent.add(node);
          if ((newSelectionPath == null)
              && ((lastSelectedNode != null) || (lastCreatedIndex != null))) {
            if (lastCreatedIndex != null) {
              if ((node instanceof IndexTreeNode)
                  && (lastCreatedIndex instanceof IndexDescriptor)) {
                if (node.getName().equals(lastCreatedIndex.getName())) {
                  newSelectionPath = new TreePath(node.getPath());
                  lastCreatedIndex = null;
                }
              } else if ((node instanceof VLVIndexTreeNode)
                  && (lastCreatedIndex instanceof VLVIndexDescriptor)) {
                if (node.getName().equals(lastCreatedIndex.getName())) {
                  newSelectionPath = new TreePath(node.getPath());
                  lastCreatedIndex = null;
                }
              }
            } else if (node.getName().equals(lastSelectedNode.getUserObject())) {
              newSelectionPath = new TreePath(node.getPath());
            }
          }
        }
        model.nodeStructureChanged(parent);
        if (expand) {
          tree.expandPath(new TreePath(parent.getPath()));
        }
        positionUnderRoot++;
      }
      i++;
    }

    if (newSelectionPath == null) {
      if (firstTreeRepopulate) {
        newSelectionPath = new TreePath(standardIndexes.getPath());
      }
    }
    if (newSelectionPath != null) {
      tree.setSelectionPath(newSelectionPath);
      tree.scrollPathToVisible(newSelectionPath);
    }

    updateEntryPane();

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            if (firstTreeRepopulate) {
              treeScroll.getViewport().setViewPosition(new Point(0, 0));
            } else {
              treeScroll.getViewport().setViewPosition(currentPosition);
            }
          }
        });
    firstTreeRepopulate = false;
    ignoreSelectionEvents = false;
  }