/**
   * Sets up tree columns.
   *
   * <p>Conveniently located here to keep column semantics in one place
   *
   * @param tv the tree viewer
   */
  public void configureTreeColumns(final TreeViewer tv) {

    final Tree tree = tv.getTree();

    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setWidth(450);
    c1.setText("Name");

    tree.setHeaderVisible(true);

    tree.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            TreeItem item = tree.getItem(new Point(e.x, e.y));
            if (item != null) {
              boolean expanded = tv.getExpandedState(item.getData());
              if (expanded) {
                tv.collapseToLevel(item.getData(), 1);
              } else {
                tv.expandToLevel(item.getData(), 1);
              }
            }
          }
        });
  }
Пример #2
0
 static TreeItem NextItem(Tree tree, TreeItem item) {
   if (item == null) return null;
   if (item.getExpanded()) {
     return item.getItem(0);
   } else {
     TreeItem childItem = item;
     TreeItem parentItem = childItem.getParentItem();
     int index = parentItem == null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
     int count = parentItem == null ? tree.getItemCount() : parentItem.getItemCount();
     while (true) {
       if (index + 1 < count) {
         return parentItem == null ? tree.getItem(index + 1) : parentItem.getItem(index + 1);
       } else {
         if (parentItem == null) {
           return null;
         } else {
           childItem = parentItem;
           parentItem = childItem.getParentItem();
           index = parentItem == null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
           count = parentItem == null ? tree.getItemCount() : parentItem.getItemCount();
         }
       }
     }
   }
 }
  @Override
  protected Object createLowerView(Composite parent) {
    //	Tree viewer for variable structure ...
    fTree = new Tree(parent, SWT.BORDER);
    fTree.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // https://jira.jboss.org/browse/JBIDE-7107
            // update "OK" button enablement
            updateOkState();
          }
        });

    fTreeViewer = new TreeViewer(fTree);
    fTreeViewer.setContentProvider(treeContentProvider);
    fTreeViewer.setLabelProvider(new ModelTreeLabelProvider());
    fTreeViewer.setInput(null);
    fTreeViewer.setAutoExpandLevel(getAutoExpandLevel());
    // end tree viewer for variable structure
    GridData data = new GridData();
    data.grabExcessVerticalSpace = true;
    data.grabExcessHorizontalSpace = true;
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.minimumHeight = 200;
    fTree.setLayoutData(data);

    return fTree;
  }
  @Override
  public Control createDialogArea(Composite parent) {
    memento.readSettings();
    Control ret = super.createDialogArea(parent);

    getTreeViewer()
        .getTree()
        .addKeyListener(
            new KeyListener() {

              /** Support for deleting the current selection on del or backspace. */
              public void keyReleased(KeyEvent e) {
                if (e.keyCode == SWT.DEL || e.keyCode == SWT.BS) {
                  removeSelection();
                }
              }

              public void keyPressed(KeyEvent e) {}
            });

    Tree tree = getTreeViewer().getTree();
    GridData layoutData = (GridData) tree.getLayoutData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    return ret;
  }
Пример #5
0
  private void createHiddenButtonsComposition(Composite parent) {
    Composite hiddenTableComp = new Composite(parent, SWT.NONE);
    hiddenTableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout gridLayout_4 = new GridLayout();
    gridLayout_4.marginWidth = 0;
    gridLayout_4.marginHeight = 0;
    hiddenTableComp.setLayout(gridLayout_4);

    Label hiddenColumnsLabel = new Label(hiddenTableComp, SWT.NONE);
    hiddenColumnsLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    hiddenColumnsLabel.setText("Hidden Columns");

    // Hidden Column Table
    hiddenColTable = new XViewerFilteredTree(hiddenTableComp);
    Tree table_1 = hiddenColTable.getViewer().getTree();
    GridData gd_table_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
    gd_table_1.widthHint = 300;
    table_1.setLayoutData(gd_table_1);
    hiddenColTable.getViewer().setLabelProvider(new XViewerColumnLabelProvider());
    hiddenColTable.getViewer().setContentProvider(new ArrayTreeContentProvider());
    hiddenColTable.getViewer().setSorter(new XViewerColumnSorter());
    hiddenColTable
        .getViewer()
        .addSelectionChangedListener(
            new ISelectionChangedListener() {
              @Override
              public void selectionChanged(SelectionChangedEvent event) {
                updateButtonEnablements();
              }
            });
  }
Пример #6
0
  private void createFileListArea(Composite parent) {
    Font font = parent.getFont();
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(font);
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));

    fileTree = new Tree(composite, SWT.VIRTUAL | SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.minimumHeight = 300;
    gd.minimumWidth = 350;
    fileTree.setLayoutData(gd);
    fileTree.setFont(font);
    fileTree.addListener(
        SWT.SetData,
        new Listener() {
          public void handleEvent(Event event) {
            TreeItem item = (TreeItem) event.item;
            FileInfo info = findFileInfo(item);
            if (info == null) {
              updateItems(item.getParentItem(), false);
            } else {
              fillItem(item, info);
            }
          }
        });
  }
Пример #7
0
  // --------------------------------------------------------------------------------
  private void onTreeItemSelect() {
    TreeItem[] selectedItems = tree.getSelection();
    if (selectedItems.length != 1) {
      return;
    }
    TreeItem selectedItem = selectedItems[0];

    if (selectedItem == tree.getItem(0)) // root
    {
      shell
          .getDisplay()
          .asyncExec(
              new Runnable() {
                public void run() { // *****
                  debug(Thread.currentThread());
                  nameText.setText("");
                  valueText.setText("");
                  typeCombo.select(0);
                  updateButton.setEnabled(false);
                }
              }); // *******
      return;
    }

    String fieldName = (String) selectedItem.getData("fieldName");

    executeAction("mj edit field " + fieldName);
  }
Пример #8
0
 private void fillTree(Composite parent) {
   final HashMap<String, ExampleTab> exampleMap = new HashMap<String, ExampleTab>();
   final BrowserNavigation navigation = RWT.getClient().getService(BrowserNavigation.class);
   for (ExampleTab tab : createExampleTabs()) {
     TreeItem item = new TreeItem(tree, SWT.NONE);
     item.setText(tab.getName());
     item.setData(tab);
     tab.setData(item);
     exampleMap.put(tab.getId(), tab);
   }
   tree.addListener(
       SWT.Selection,
       new Listener() {
         public void handleEvent(Event event) {
           ExampleTab tab = (ExampleTab) event.item.getData();
           selectTab(tab);
           navigation.pushState(tab.getId(), null);
         }
       });
   navigation.addBrowserNavigationListener(
       new BrowserNavigationListener() {
         public void navigated(BrowserNavigationEvent event) {
           ExampleTab tab = exampleMap.get(event.getState());
           if (tab != null) {
             tree.select((TreeItem) tab.getData());
             tree.showSelection();
             selectTab(tab);
           }
         }
       });
   selectTab((ExampleTab) tree.getItem(0).getData());
 }
Пример #9
0
  void setData(final Repository localDb, final PushOperationResult result) {
    reader = localDb.newObjectReader();
    repo = localDb;

    // Set empty result for a while.
    treeViewer.setInput(null);

    if (result == null) {
      root.layout();
      return;
    }

    final List<RefUpdateElement> results = new ArrayList<RefUpdateElement>();

    for (URIish uri : result.getURIs())
      if (result.isSuccessfulConnection(uri))
        for (RemoteRefUpdate update : result.getPushResult(uri).getRemoteUpdates())
          results.add(new RefUpdateElement(result, update, uri, reader, repo));

    treeViewer.setInput(results.toArray());
    // select the first row of table to get the details of the first
    // push result shown in the Text control
    Tree table = treeViewer.getTree();
    if (table.getItemCount() > 0)
      treeViewer.setSelection(new StructuredSelection(table.getItem(0).getData()));
    root.layout();
  }
 private void createSchemaGui(final TabFolder tabFolder, final SchemaTree schemaTreeModel) {
   final TabItem dbStructureTabItem = new TabItem(tabFolder, SWT.NULL);
   dbStructureTabItem.setText("Database Structure");
   final Tree tree = new Tree(tabFolder, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
   tree.setHeaderVisible(true);
   tree.setLinesVisible(true);
   tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   // create the jface wrapper
   final TreeViewer treeViewer = new TreeViewer(tree);
   final String[] schemaColumnNames = new String[] {"Name", "Object", "Type", "Schema"};
   final int[] schemaColumnWidths = new int[] {200, 100, 150, 800};
   final int[] schemaColumnAlignments = new int[] {SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT};
   for (int i = 0; i < schemaColumnNames.length; i++) {
     final TreeColumn treeColumn = new TreeColumn(tree, schemaColumnAlignments[i]);
     treeColumn.setText(schemaColumnNames[i]);
     treeColumn.pack();
     treeColumn.setWidth(schemaColumnWidths[i]);
   }
   final SchemaContentProvider schemaContentProvider = new SchemaContentProvider();
   treeViewer.setContentProvider(schemaContentProvider);
   treeViewer.setLabelProvider(new SchemaLabelProvider());
   treeViewer.setInput(schemaTreeModel.getRoot());
   // Add table viewer to database structure tab item
   dbStructureTabItem.setControl(tree);
 }
Пример #11
0
  /**
   * DOC chuang Comment method "createTreeTableView".
   *
   * @param parent
   */
  private void createTreeTableViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer =
        new TreeViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

    // init tree
    final Tree tree = viewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // create tree column
    TreeColumn column = new TreeColumn(tree, SWT.NONE);
    column.setText("Resource"); // $NON-NLS-1$
    column.setWidth(150);

    column = new TreeColumn(tree, SWT.NONE);
    column.setText("Description"); // $NON-NLS-1$
    column.setWidth(300);

    viewer.setContentProvider(new ErrorDetailContentProvider());
    viewer.setLabelProvider(new ErrorDetailLabelProvider());
    viewer.setInput(errors);
    viewer.expandAll();
  }
  protected void setSelectionInViewer(CloudSpace selectedSpace) {
    // Now set the cloud space in the tree
    Tree tree = orgsSpacesViewer.getTree();
    TreeItem[] orgItems = tree.getItems();
    if (orgItems != null) {
      TreeItem orgItem = null;

      // Find the tree item corresponding to the cloud space's
      // org
      for (TreeItem item : orgItems) {
        Object treeObj = item.getData();
        if (treeObj instanceof CloudOrganization
            && ((CloudOrganization) treeObj)
                .getName()
                .equals(selectedSpace.getOrganization().getName())) {
          orgItem = item;
          break;
        }
      }

      if (orgItem != null) {
        TreeItem[] children = orgItem.getItems();
        if (children != null) {
          for (TreeItem childItem : children) {
            Object treeObj = childItem.getData();
            if (treeObj instanceof CloudSpace
                && ((CloudSpace) treeObj).getName().equals(selectedSpace.getName())) {
              tree.select(childItem);
              break;
            }
          }
        }
      }
    }
  }
Пример #13
0
 private Point computeMenuLocation(Control focus, Menu menu) {
   Point cursorLocation = focus.getDisplay().getCursorLocation();
   Rectangle clientArea = null;
   Point result = null;
   if (focus instanceof StyledText) {
     StyledText styledText = (StyledText) focus;
     clientArea = styledText.getClientArea();
     result = computeMenuLocation(styledText);
   } else if (focus instanceof Tree) {
     Tree tree = (Tree) focus;
     clientArea = tree.getClientArea();
     result = computeMenuLocation(tree);
   } else if (focus instanceof Table) {
     Table table = (Table) focus;
     clientArea = table.getClientArea();
     result = computeMenuLocation(table);
   }
   if (result == null) {
     result = focus.toControl(cursorLocation);
   }
   if (clientArea != null && !clientArea.contains(result)) {
     result = new Point(clientArea.x + clientArea.width / 2, clientArea.y + clientArea.height / 2);
   }
   Rectangle shellArea = focus.getShell().getClientArea();
   if (!shellArea.contains(focus.getShell().toControl(focus.toDisplay(result)))) {
     result = new Point(shellArea.x + shellArea.width / 2, shellArea.y + shellArea.height / 2);
   }
   return focus.toDisplay(result);
 }
Пример #14
0
 /**
  * Hook to compute the menu location if the focus widget is a tree widget.
  *
  * @param tree the tree widget that has the focus
  * @return a widget relative position of the menu to pop up or <code>null</code> if now position
  *     inside the widget can be computed
  */
 protected Point computeMenuLocation(Tree tree) {
   TreeItem[] items = tree.getSelection();
   Rectangle clientArea = tree.getClientArea();
   switch (items.length) {
     case 0:
       return null;
     case 1:
       Rectangle bounds = items[0].getBounds();
       Rectangle intersect = clientArea.intersection(bounds);
       if (intersect != null && intersect.height == bounds.height) {
         return new Point(
             Math.max(0, bounds.x + getAvarageCharWith(tree) * CHAR_INDENT),
             bounds.y + bounds.height);
       } else {
         return null;
       }
     default:
       Rectangle[] rectangles = new Rectangle[items.length];
       for (int i = 0; i < rectangles.length; i++) {
         rectangles[i] = items[i].getBounds();
       }
       Point cursorLocation = tree.getDisplay().getCursorLocation();
       Point result =
           findBestLocation(
               getIncludedPositions(rectangles, clientArea), tree.toControl(cursorLocation));
       if (result != null) result.x = result.x + getAvarageCharWith(tree) * CHAR_INDENT;
       return result;
   }
 }
  private void createTaskTree(Composite parent) {
    PatternFilter filter = new PatternFilter();
    FilteredTree filteredTree =
        new FilteredTree(parent, SWT.CHECK | SWT.BORDER, filter, true) {
          @Override
          protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
            return new ContainerCheckedTreeViewer(parent, style);
          }
        };
    taskSelectionTreeViewer = (CheckboxTreeViewer) filteredTree.getViewer();
    filteredTree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Add multi column support
    Tree tree = taskSelectionTreeViewer.getTree();
    tree.setHeaderVisible(true);
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("Project/Task");
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Description");
    column1.pack();
    column2.pack();

    taskSelectionTreeViewer.setLabelProvider(new GradleTaskTreeLabelProvider());
    taskSelectionTreeViewer.setContentProvider(
        new GradleTaskTreeContentProvider(taskSelectionTreeViewer, true));
    taskSelectionTreeViewer.setCheckStateProvider(tasksChecked);
    taskSelectionTreeViewer.addCheckStateListener(tasksChecked);

    if (project != null) {
      setTreeInput(project);
    }
  }
Пример #16
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets .Composite)
   */
  @Override
  public void createPartControl(final Composite parent) {
    final Tree variableTree = new Tree(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    variableTree.setHeaderVisible(true);
    viewer = new TreeViewer(variableTree);

    final TreeColumn column1 = new TreeColumn(variableTree, SWT.LEFT);
    variableTree.setLinesVisible(true);
    column1.setAlignment(SWT.LEFT);
    column1.setText("Variable-Name");
    column1.setWidth(130);
    final TreeColumn column2 = new TreeColumn(variableTree, SWT.RIGHT);
    column2.setAlignment(SWT.LEFT);
    column2.setText("Assignment");
    column2.setWidth(130);

    viewer.expandAll();

    contProv = new VariableAssignmentContentProvider();
    viewer.setContentProvider(contProv);
    // we have to define an own label provider
    viewer.setLabelProvider(new VariableAssignmentLabelProvider());
    // we add this object as selection listener
    getViewSite().getPage().addSelectionListener(this);
  }
Пример #17
0
  public void performVisibleTableDragOver(DropTargetEvent event) {
    if (!TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
      event.detail = DND.DROP_NONE;
      return;
    }

    Tree tree = visibleColTable.getViewer().getTree();
    TreeItem dragOverTreeItem =
        tree.getItem(visibleColTable.getViewer().getTree().toControl(event.x, event.y));
    if (dragOverTreeItem == null) {
      return;
    }

    event.feedback = DND.FEEDBACK_EXPAND;
    event.detail = DND.DROP_NONE;

    IStructuredSelection selectedItem =
        (IStructuredSelection) visibleColTable.getViewer().getSelection();
    if (selectedItem == null || selectedItem.isEmpty()) {
      selectedItem = (IStructuredSelection) hiddenColTable.getViewer().getSelection();
    }
    if (selectedItem == null) {
      return;
    }
    Object obj = selectedItem.getFirstElement();
    if (obj instanceof XViewerColumn) {
      if (isFeedbackAfter) {
        event.feedback = DND.FEEDBACK_INSERT_AFTER;
      } else {
        event.feedback = DND.FEEDBACK_INSERT_BEFORE;
      }
      event.detail = DND.DROP_MOVE;
    }
  }
Пример #18
0
 /**
  * Add mouse tree listener.
  *
  * @param menuService The menu service reference.
  */
 private void addListeners(EMenuService menuService) {
   properties.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseDoubleClick(MouseEvent e) {
           final TreeItem[] items = properties.getSelection();
           if (items.length > 0) {
             final TreeItem item = items[0];
             if (properties.getData() instanceof Configurer) {
               final Configurer configurer = (Configurer) properties.getData();
               if (updateProperties(item, configurer)) {
                 configurer.save();
               }
             }
           }
         }
       });
   properties.addMenuDetectListener(
       new MenuDetectListener() {
         @Override
         public void menuDetected(MenuDetectEvent menuDetectEvent) {
           properties.getMenu().setVisible(false);
           properties.update();
         }
       });
   menuService.registerContextMenu(properties, MENU_ID);
 }
Пример #19
0
  public static void createItemAtTab(
      DataObject note, String agroup, CTabItem tabItem, ActionContext actionContext) {
    ActionContext ac = (ActionContext) tabItem.getData("actionContext");
    Tree tree = (Tree) ac.get("tree");
    String[] group = agroup.split("[.]");
    for (TreeItem item : tree.getItems()) {
      if (createToTreeItem(item, note, tabItem.getText(), agroup, group, 0, actionContext)) {
        return;
      }
    }

    if (!"".equals(agroup)) {
      TreeItem nodeItem = new TreeItem(tree, SWT.None);
      nodeItem.setData("type", "node");
      nodeItem.setText(group[0]);
      nodeItem.setData("group", agroup);
      nodeItem.setData("label", tabItem.getText());
      setImage(nodeItem, "nodeImage", actionContext);
      createToTreeItem(nodeItem, note, tabItem.getText(), agroup, group, 0, actionContext);
    } else {
      TreeItem newItem = new TreeItem(tree, SWT.None);
      newItem.setData("type", "note");
      newItem.setData(note);
      newItem.setText(note.getString("name"));
      newItem.setData("label", tabItem.getText());
      newItem.setData("group", agroup);
      setImage(newItem, "noteImage", actionContext);
      addTreeItemToNode(newItem, note);
    }
  }
Пример #20
0
 private void expandSelect() {
   if (fPathToSelect == null) return;
   if (fPathToSelect.isEmpty()) {
     fPathToSelect = null;
     fFileToSelect = null;
     return;
   }
   do {
     String name = fPathToSelect.getFirst();
     if (name.length() == 0) {
       fPathToSelect.removeFirst();
       continue;
     }
     FileInfo info = findFileInfo(fLastSelectedFileInfo, name);
     if (info == null) break;
     TreeItem item = findItem(info);
     if (item == null) break;
     fPathToSelect.removeFirst();
     if (fPathToSelect.isEmpty()) {
       fileTree.setSelection(item);
       fileTree.showItem(item);
     } else {
       item.setExpanded(true);
       fileTree.showItem(item);
     }
     fLastSelectedFileInfo = info;
   } while (!fPathToSelect.isEmpty());
 }
Пример #21
0
  public static void main(String[] args) {
    LoggerContext loggerContext = new LoggerContext();
    Display display = new Display();
    ResourceUtil.init(display);
    Shell shell = new Shell(display);
    final Tree tree = new Tree(shell, SWT.BORDER);
    Rectangle clientArea = shell.getClientArea();
    tree.setBounds(clientArea.x, clientArea.y, 200, 200);

    LoggerTree loggerTree = new LoggerTree(loggerContext, tree);
    tree.setMenu(TreeMenuBuilder.buildTreeMenu(loggerTree, null));
    loggerTree.update("com.foo.Bar");
    loggerTree.update("com.foo.Bar");

    loggerContext.getLogger("org.apache.struts").setLevel(Level.ERROR);

    loggerTree.update("org.apache.struts.BlahAction");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #22
0
  //	template<typename T>
  //	class A {
  // 	public:
  //    int field1;
  //    int method1();
  // 	};
  // 	class B : public A<int> {
  //	public:
  //	  int field2;
  //	  int method2();
  //	};
  public void testTemplateInstance_403418() throws Exception {
    String content = getContentsForTest(1)[0].toString();
    IFile file = createFile(getProject(), "class.cpp", content);
    waitUntilFileIsIndexed(fIndex, file);
    CEditor editor = openEditor(file);
    Tree tree;
    TreeItem item1, item2;

    editor.selectAndReveal(content.indexOf("A"), 1);
    openTypeHierarchy(editor);
    tree = getHierarchyViewer().getTree();

    item1 = checkTreeNode(tree, 0, "A");
    assertEquals(1, tree.getItemCount());
    getHierarchyViewer().expandAll();

    item2 = checkTreeNode(item1, 0, "B");
    checkMethodTable(new String[] {"field1 : int", "method1() : int"});
    assertEquals(1, item1.getItemCount());
    assertEquals(0, item2.getItemCount());

    editor.selectAndReveal(content.indexOf("B"), 1);
    openTypeHierarchy(editor);
    tree = getHierarchyViewer().getTree();
    item1 = checkTreeNode(tree, 0, "A");
    assertEquals(1, tree.getItemCount());

    item2 = checkTreeNode(item1, 0, "B");
    assertEquals(1, item1.getItemCount());
    assertEquals(0, item2.getItemCount());
    checkMethodTable(new String[] {"field2 : int", "method2() : int"});
  }
Пример #23
0
  @Override
  public void performDragOver(DropTargetEvent event) {
    if (!ArtifactTransfer.getInstance().isSupportedType(event.currentDataType)) {
      event.detail = DND.DROP_NONE;
      return;
    }
    final ArtifactData artData = ArtifactTransfer.getInstance().nativeToJava(event.currentDataType);
    if (artData == null) {
      event.detail = DND.DROP_NONE;
      return;
    }
    for (Artifact art : artData.getArtifacts()) {
      if (art.isOfType(CoreArtifactTypes.UniversalGroup)) {
        event.detail = DND.DROP_NONE;
        return;
      }
    }
    Tree tree = treeViewer.getTree();
    TreeItem dragOverTreeItem = tree.getItem(treeViewer.getTree().toControl(event.x, event.y));

    event.feedback = DND.FEEDBACK_EXPAND;
    event.detail = DND.DROP_NONE;

    // Set as COPY if drag item over group (copy versus move will be determined on drop
    if (dragOverTreeItem != null
        && ((GroupExplorerItem) dragOverTreeItem.getData()).isUniversalGroup()) {
      event.detail = DND.DROP_COPY;
      tree.setInsertMark(null, false);
    }
    // Handle re-ordering within same group
    else if (dragOverTreeItem != null
        && !((GroupExplorerItem) dragOverTreeItem.getData()).isUniversalGroup()) {
      GroupExplorerItem dragOverGroupItem = (GroupExplorerItem) dragOverTreeItem.getData();
      IStructuredSelection selectedItem = (IStructuredSelection) treeViewer.getSelection();
      Object obj = selectedItem.getFirstElement();
      if (obj instanceof GroupExplorerItem) {
        GroupExplorerItem droppingGroupItem = (GroupExplorerItem) obj;

        // the group to move must belong to the same group as the member to insert before/after
        if (dragOverGroupItem.getParentItem().equals(droppingGroupItem.getParentItem())) {
          if (isFeedbackAfter) {
            event.feedback = DND.FEEDBACK_INSERT_AFTER;
          } else {
            event.feedback = DND.FEEDBACK_INSERT_BEFORE;
          }
          event.detail = DND.DROP_MOVE;
        }
      } else {
        if (isFeedbackAfter) {
          event.feedback = DND.FEEDBACK_INSERT_AFTER;
        } else {
          event.feedback = DND.FEEDBACK_INSERT_BEFORE;
        }
        event.detail = DND.DROP_COPY;
      }
    } else {
      tree.setInsertMark(null, false);
    }
  }
Пример #24
0
 private void refreshNode() {
   Tree tree = LFWPersTool.getTree();
   TreeItem[] tis = tree.getSelection();
   if (tis == null || tis.length == 0) return;
   TreeItem ti = tis[0];
   ti.removeAll();
   LFWExplorerTreeView.getLFWExploerTreeView(null).refreshDirtoryTreeItem();
 }
 private void packTable() {
   for (int i = 0; i < titles.length; i++) {
     tree.getColumn(i).pack();
   }
   if (tree.getColumn(titles.length - 1).getWidth() < MAX_WIDTH) {
     tree.getColumn(titles.length - 1).setWidth(MAX_WIDTH);
   }
 }
Пример #26
0
 /**
  * Gets the column index corresponding to the given column.
  *
  * @param tree The tree
  * @param column The thread column
  * @return The column index
  */
 private static int getColumnIndex(Tree tree, HeapColumn column) {
   for (int i = 0; i < tree.getColumnCount(); i++) {
     if (tree.getColumn(i).getText().equals(column.label)) {
       return i;
     }
   }
   return -1;
 }
 /**
  * Gets the column index corresponding to the given column.
  *
  * @param column The heap column
  * @return The column index
  */
 private int getColumnIndex(HeapColumn column) {
   Tree table = treeViewer.getTree();
   for (int i = 0; i < table.getColumnCount(); i++) {
     if (table.getColumn(i).getText().equals(column.label)) {
       return i;
     }
   }
   return -1;
 }
 private void setTreeInput(GradleProject project) {
   if (taskSelectionTreeViewer != null) {
     taskSelectionTreeViewer.setInput(project);
     Tree tree = taskSelectionTreeViewer.getTree();
     for (TreeColumn col : tree.getColumns()) {
       col.pack();
     }
   }
 }
Пример #29
0
  /*
   * (non-Javadoc)
   * @see edu.rice.cs.hpc.viewer.scope.AbstractBaseScopeView#initTableColumns()
   */
  protected void initTableColumns(boolean keepColumnStatus) {

    if (treeViewer != null) {
      Tree tree = treeViewer.getTree();
      if (tree != null && !tree.isDisposed()) {
        initTableColumns(tree, keepColumnStatus);
      }
    }
  }
  private Tree createTree(final Composite c, final boolean left) {
    final Tree tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
    final GridData gd_list = new GridData(SWT.FILL, SWT.FILL, true, true);
    tree.setLayoutData(gd_list);
    tree.addListener(SWT.Selection, createTreeSelChangeListener(left));
    tree.addListener(SWT.Selection, this);

    return tree;
  }