org.eclipse.swt.widgets.TreeColumn Java Examples

The following examples show how to use org.eclipse.swt.widgets.TreeColumn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RealTimeListViewer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void saveTo ( final IMemento memento )
{
    if ( memento == null )
    {
        return;
    }

    {
        final IMemento tableMemento = memento.createChild ( "tableCols" ); //$NON-NLS-1$

        for ( int i = 0; i < this.viewer.getTree ().getColumnCount (); i++ )
        {
            final TreeColumn col = this.viewer.getTree ().getColumn ( i );
            tableMemento.putInteger ( "col_" + i, col.getWidth () ); //$NON-NLS-1$
        }
    }

    for ( final ListEntry entry : this.list.getItems () )
    {
        final Item item = entry.getItem ();
        item.saveTo ( memento.createChild ( "item" ) ); //$NON-NLS-1$
    }
}
 
Example #2
Source File: TmfSynchronizationView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
    fTree = new Tree(parent, SWT.NONE);
    TreeColumn nameCol = new TreeColumn(fTree, SWT.NONE, 0);
    TreeColumn valueCol = new TreeColumn(fTree, SWT.NONE, 1);
    nameCol.setText(Messages.TmfSynchronizationView_NameColumn);
    valueCol.setText(Messages.TmfSynchronizationView_ValueColumn);

    fTree.setItemCount(0);

    fTree.setHeaderVisible(true);
    nameCol.pack();
    valueCol.pack();

    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    if (trace != null) {
        traceSelected(new TmfTraceSelectedSignal(this, trace));
    }
}
 
Example #3
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected void handleUniqeValuesColumn() {
   TreeColumn treeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn xCol = (XViewerColumn) treeCol.getData();

   TreeItem[] items = xViewer.getTree().getSelection();
   if (items.length == 0) {
      items = xViewer.getTree().getItems();
   }
   if (items.length == 0) {
      XViewerLib.popup(XViewerText.get("error"), XViewerText.get("error.no_items.sum")); //$NON-NLS-1$ //$NON-NLS-2$
      return;
   }
   Set<String> values = new HashSet<>();
   for (TreeItem item : items) {
      for (int x = 0; x < xViewer.getTree().getColumnCount(); x++) {
         if (xViewer.getTree().getColumn(x).equals(treeCol)) {
            values.add(((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(item.getData(), x));
         }
      }
   }
   String html = HtmlUtil.simplePage(HtmlUtil.textToHtml(CollectionsUtil.toString("\n", values))); //$NON-NLS-1$
   new HtmlDialog(XViewerText.get("dialog.unique.title"), XViewerText.get("dialog.unique.prompt", xCol.getName()), //$NON-NLS-1$ //$NON-NLS-2$
      html).open();
}
 
Example #4
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected void handleHideColumn() {
   TreeColumn insertTreeCol = xViewer.getRightClickSelectedColumn();
   XViewerColumn insertXCol = (XViewerColumn) insertTreeCol.getData();
   //      System.out.println("Hide column " + insertXCol);
   CustomizeData custData = xViewer.getCustomizeMgr().generateCustDataFromTable();
   List<XViewerColumn> xCols = custData.getColumnData().getColumns();
   List<XViewerColumn> newXCols = new ArrayList<>();
   for (XViewerColumn currXCol : xCols) {
      if (currXCol.equals(insertXCol)) {
         currXCol.setShow(false);
      }
      newXCols.add(currXCol);
   }
   custData.getColumnData().setColumns(newXCols);
   xViewer.getCustomizeMgr().loadCustomization(custData);
   xViewer.refresh();
}
 
Example #5
Source File: ClipboardHandlerTree.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the tree into a string.
 *
 * @param tree
 * @return
 */
private String getText(TreeViewer tree){
    
    StringBuilder builder = new StringBuilder();
   
    List<String> properties = new ArrayList<String>();
    for (TreeColumn column : getColumns(tree)){
        properties.add(column.getText());
    }
    
    for (Object item : getItems(tree)) {
        getText(tree, item, properties, builder, ""); //$NON-NLS-1$
    }
    
    return builder.toString();
}
 
Example #6
Source File: TimeGraphFilterDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the tree viewer.
 *
 * @param parent
 *            the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
    PatternFilter filter = new TreePatternFilter();
    filter.setIncludeLeadingWildcard(true);
    fTree = new FilteredCheckboxTree(parent, SWT.BORDER | SWT.MULTI, filter, true, false);

    Tree tree = fTree.getViewer().getTree();
    tree.setHeaderVisible(true);
    for (String columnName : fColumnNames) {
        TreeColumn column = new TreeColumn(tree, SWT.LEFT);
        column.setText(columnName);
    }

    fTree.getViewer().setContentProvider(fContentProvider);
    fTree.getViewer().setLabelProvider(fLabelProvider);
    fTree.addCheckStateListener(new CheckStateListener());
    fTree.getViewer().setComparator(fComparator);
    if (fFilters != null) {
        for (int i = 0; i != fFilters.size(); i++) {
            fTree.getViewer().addFilter(fFilters.get(i));
        }
    }
    fTree.getViewer().setInput(fInput);
    return (CheckboxTreeViewer) fTree.getViewer();
}
 
Example #7
Source File: XViewerCustomMenu.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void performViewOrCopyCell(Option option) {
   try {
      MouseEvent event = xViewer.getMouseListener().getLeftClickEvent();
      TreeItem item = xViewer.getItemUnderMouseClick(new Point(event.x, event.y));
      TreeColumn column = xViewer.getColumnUnderMouseClick(new Point(event.x, event.y));
      if (item != null && column != null) {
         int columnNum = 0;
         for (int x = 0; x < xViewer.getTree().getColumnCount(); x++) {
            if (xViewer.getTree().getColumn(x).equals(column)) {
               columnNum = x;
               break;
            }
         }
         ViewSelectedCellDataAction action = new ViewSelectedCellDataAction(xViewer, clipboard, option);
         action.run(column, item, columnNum);
      }
   } catch (Exception ex) {
      // do nothing
   }
}
 
Example #8
Source File: PackageTab.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void makeUIClean() {
    if (tree.isDisposed()) {
        return;
    }
    TreeColumn column = tree.getColumn(0);
    column.setText("Library");
    tree.clearAll(true);
    tree.setItemCount(0);
    btConda.setEnabled(false);
    if (btPipenv != null) {
        btPipenv.setEnabled(false);
    }
    btPip.setEnabled(false);
    if (checkUseConda != null) {
        checkUseConda.setEnabled(false);
    }
}
 
Example #9
Source File: TreeViewerBuilder.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected TreeViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout,
		final int style) {
	final TreeViewer viewer = new TreeViewer(parent, virual ? (style | VIRTUAL) : style);
	final Tree tree = viewer.getTree();
	tree.setLinesVisible(linesVisible);
	tree.setHeaderVisible(headerVisible);

	int columnIndex = 0;
	for (final String columnLabel : columnLabels) {

		final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, NONE);
		final TreeColumn column = viewerColumn.getColumn();
		columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
		column.setText(columnLabel);
		column.setMoveable(moveable);

		columnIndex++;
	}

	return viewer;
}
 
Example #10
Source File: NodeStatsTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void configSorters(Tree tree) {
  int index = 0;
  for (TreeColumn column : tree.getColumns()) {
    final int colIndex = index++;

    column.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent event) {
        updateSortColumn((TreeColumn) event.widget, colIndex);
      }
    });
  }
}
 
Example #11
Source File: NodeDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void configSorters(Tree tree) {
  int index = 0;
  for (TreeColumn column : tree.getColumns()) {
    final int colIndex = index++;

    column.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent event) {
        updateSortColumn((TreeColumn) event.widget, colIndex);
      }
    });
  }
}
 
Example #12
Source File: ViewProperties.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Refreshes the tree
 */
protected void refresh() {
    treeViewer.refresh();
    treeViewer.expandAll();
    for (TreeColumn tc : treeViewer.getTree().getColumns()) {
        tc.pack();
    }
}
 
Example #13
Source File: SelectObjectDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void setSort( int i ) {
  if ( sortColumn == i ) {
    ascending = !ascending;
  } else {
    sortColumn = i;
    ascending = true;
  }

  if ( sortColumn >= 0 && sortColumn < 5 ) {
    TreeColumn column = wTree.getColumn( sortColumn );
    wTree.setSortColumn( column );
    wTree.setSortDirection( ascending ? SWT.UP : SWT.DOWN );
  }
  refreshTree();
}
 
Example #14
Source File: NodeStatsTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void setSortColumn(
    TreeColumn column, int colIndex, int direction) {

  ViewerComparator sorter = buildColumnSorter(colIndex);
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Tree tree = propViewer.getTree();
  tree.setSortColumn(column);
  tree.setSortDirection(direction);

  propViewer.setComparator(sorter);
}
 
Example #15
Source File: NodeDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private void setSortColumn(
    TreeColumn column, int colIndex, int direction) {

  ViewerComparator sorter = buildColumnSorter(colIndex);
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Tree tree = propViewer.getTree();
  tree.setSortColumn(column);
  tree.setSortDirection(direction);

  propViewer.setComparator(sorter);
}
 
Example #16
Source File: TreeConflictsView.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setColumnWidth(TableLayout layout,
		DisposeListener disposeListener, TreeColumn col, int colIndex) {
	String columnWidth = null;
	columnWidth = settings.get("TreeConflictsView.col." + col.getText()); //$NON-NLS-1$ //$NON-NLS-1$
	if (columnWidth == null || columnWidth.equals("0")) layout.addColumnData(columnLayouts[colIndex]); //$NON-NLS-1$
	else layout.addColumnData(new ColumnPixelData(Integer.parseInt(columnWidth), true));
	col.addDisposeListener(disposeListener);
}
 
Example #17
Source File: EditColTableDef.java    From depan with Apache License 2.0 5 votes vote down vote up
public static void setupTree(EditColTableDef[] tableDef, Tree tree) {
  for (EditColTableDef d : tableDef) {
    TreeColumn col = new TreeColumn(tree, SWT.LEFT);
    col.setText(d.getLabel());
    col.setWidth(d.getWidth());
  }
}
 
Example #18
Source File: RepositoryExplorerDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void setSort( int i ) {
  if ( sortColumn == i ) {
    ascending = !ascending;
  } else {
    sortColumn = i;
    ascending = true;
  }

  if ( sortColumn >= 0 && sortColumn < 5 ) {
    TreeColumn column = wTree.getColumn( sortColumn );
    wTree.setSortColumn( column );
    wTree.setSortDirection( ascending ? SWT.UP : SWT.DOWN );
  }
  refreshTree();
}
 
Example #19
Source File: OffsetDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private TreeViewerColumn createTreeViewerColumn(String title, int style) {
    final TreeViewerColumn viewerColumn = new TreeViewerColumn(fViewer.getViewer(), style);
    final TreeColumn column = viewerColumn.getColumn();
    column.setText(title);
    column.setResizable(true);
    return viewerColumn;
}
 
Example #20
Source File: XViewerMouseListener.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void mouseUp(MouseEvent event) {
   TreeItem item = xViewer.getItemUnderMouseClick(new Point(event.x, event.y));
   if (item == null) {
      return;
   }

   try {
      TreeColumn column = xViewer.getColumnUnderMouseClick(new Point(event.x, event.y));
      if (column == null) {
         return;
      }
      if (isLeftClick(event) && controlNotBeingHeld(event)) {

         if (altIsBeingHeld(event)) {
            // System.out.println("Column " + colNum);
            xViewer.handleAltLeftClick(column, item);
         } else if (clickOccurredInIconArea(event, item)) {
            xViewer.handleLeftClickInIconArea(column, item);
         } else {
            // System.out.println("Column " + colNum);
            xViewer.handleLeftClick(column, item);
         }
      }
      xViewer.updateStatusLabel();
   } catch (ArrayIndexOutOfBoundsException ex) {
      // mouse clicked outside of last/valid column
      return;
   }

}
 
Example #21
Source File: CodeRecommendationResultsView.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public void showRecommendations(Collection<CodeRecommendationTarget> recommendations,
		CodeRecommendationRequest select) {

	List<TreePath> alreadyExpandedTreePaths = Arrays.asList(treeViewer.getExpandedTreePaths());
	List<Object> alreadyExpandedElements = Arrays.asList(treeViewer.getExpandedElements());
	treeViewer.setInput(recommendations.toArray());

	List<TreePath> expandedTreePaths = new ArrayList<>(alreadyExpandedTreePaths);
	List<Object> expandedElements = new ArrayList<>(alreadyExpandedElements);

	if (select != null) {
		expandedTreePaths.add(new TreePath(new Object[] { select.getTarget(), select }));

		expandedElements.add(select.getTarget());
		expandedElements.add(select);
	}

	treeViewer.setExpandedElements(expandedElements.toArray());
	treeViewer.setExpandedTreePaths(expandedTreePaths.toArray(new TreePath[0]));

	if (select != null) {
		treeViewer.setSelection(new StructuredSelection(select));
		eventManager.invoke(l -> l.onCodeRecommendationSelected(select));
	}

	Display.getDefault().asyncExec(() -> {
		TreeColumn[] columns = treeViewer.getTree().getColumns();
		for (TreeColumn column : columns) {
			column.pack();
		}
	});
}
 
Example #22
Source File: ContractInputTreeViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createInputDescriptionColumn() {
    final TreeViewerColumn descriptionColumnViewer = createColumnViewer(Messages.description, SWT.FILL);
    final TreeColumn column = descriptionColumnViewer.getColumn();
    column.setToolTipText(Messages.contractInputDescriptionTooltip);
    column.setImage(sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK));
    descriptionColumnViewer.setLabelProvider(new DescriptionCellLabelProvider(propertySourceProvider, knownElements()));
    final DescriptionObservableEditingSupport editingSupport = new DescriptionObservableEditingSupport(this,
            messageManager, emfDataBindingContext);
    editingSupport.setControlId(SWTBotConstants.SWTBOT_ID_INPUT_DESCRIPTION_TEXTEDITOR);
    descriptionColumnViewer.setEditingSupport(editingSupport);
}
 
Example #23
Source File: ProjectCompareTree.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create an instance.
 */
public ProjectCompareTree(Composite parent, int style, ProjectCompareTreeHelper projectCompareTreeHelper) {
	super(parent, style);
	this.projectCompareTreeHelper = projectCompareTreeHelper;

	parent.addDisposeListener(new DisposeListener() {
		@Override
		public void widgetDisposed(DisposeEvent e) {
			onDispose();
		}
	});

	col_diff_error_fg = new Color(parent.getDisplay(), 255, 40, 40);
	col_diff_conformant_fg = new Color(parent.getDisplay(), 60, 127, 95);
	col_classifier_bg = new Color(parent.getDisplay(), 200, 220, 250);

	final Tree tree = getTree();
	for (int n = 0; n < NUM_OF_COLUMNS; n++) {
		final TreeColumn colN = new TreeColumn(tree, SWT.LEFT);
		if (n == 0)
			colN.setWidth(300); // make API column a bit wider
		else
			colN.setWidth(200);
	}

	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);

	setLabelProvider(new MyLabelProvider());
	setContentProvider(new MyContentProvider());

	setComparison(null, null, null);
}
 
Example #24
Source File: AbapGitDialogObjLog.java    From ADT_Frontend with MIT License 5 votes vote down vote up
private TreeViewerColumn createTableViewerColumn(String title, int bound) {
	TreeViewerColumn viewerColumn = new TreeViewerColumn(this.abapObjTable, SWT.NONE);
	TreeColumn column = viewerColumn.getColumn();
	column.setText(title);
	column.setWidth(bound);
	column.setResizable(true);
	column.setMoveable(true);
	//-> still present for proper search
	if (column.getText().equals("Type")) { //$NON-NLS-1$
		column.setWidth(0);
		column.setResizable(false);
	}
	return viewerColumn;
}
 
Example #25
Source File: MyXViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
   if (treeColumn.getData().equals(MyXViewerFactory.Last_Run_Date)) {
      Date promptChangeDate = XPromptChange.promptChangeDate(MyXViewerFactory.Last_Run_Date.getName(), new Date());
      System.out.println("promptChangeDate " + promptChangeDate);
      SomeTask task = (SomeTask) treeItem.getData();
      task.setLastRunDate(promptChangeDate);
      refresh();
   }
   return super.handleAltLeftClick(treeColumn, treeItem);
}
 
Example #26
Source File: MyXViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean handleLeftClickInIconArea(TreeColumn treeColumn, TreeItem treeItem) {
   if (treeColumn.getData().equals(MyXViewerFactory.Run_Col)) {
      setRun((ISomeTask) treeItem.getData(), !isRun((ISomeTask) treeItem.getData()));
      update(treeItem.getData(), null);
      return true;
   } else {
      return super.handleLeftClickInIconArea(treeColumn, treeItem);
   }

}
 
Example #27
Source File: ColumnMultiEditAction.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getText(Object element) {
   if (element instanceof TreeColumn) {
      return ((TreeColumn) element).getText();
   }
   return "Unknown element type"; //$NON-NLS-1$
}
 
Example #28
Source File: ColumnMultiEditAction.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static Set<TreeColumn> getEditableTreeColumns(XViewer xViewer, Collection<TreeItem> selectedTreeItems) {
   Set<TreeColumn> editableColumns = new HashSet<TreeColumn>();
   for (TreeColumn treeCol : xViewer.getTree().getColumns()) {
      if (xViewer.isColumnMultiEditable(treeCol, selectedTreeItems)) {
         editableColumns.add(treeCol);
      }
   }
   return editableColumns;
}
 
Example #29
Source File: Trees.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static void bindColumnWidths(final Tree tree, int minimum, final double... percents) {
	if (tree == null || percents == null)
		return;
	TreeResizeListener treeListener = new TreeResizeListener(tree, minimum, percents);
	ColumnResizeListener columnListener = new ColumnResizeListener(treeListener);
	for (TreeColumn column : tree.getColumns())
		column.addControlListener(columnListener);
	tree.addControlListener(treeListener);
}
 
Example #30
Source File: ViewSelectedCellDataAction.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run() {
   try {
      TreeColumn treeCol = xViewer.getRightClickSelectedColumn();
      TreeItem treeItem = xViewer.getRightClickSelectedItem();
      run(treeCol, treeItem, xViewer.getRightClickSelectedColumnNum());
   } catch (Exception ex) {
      XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
   }
}