Java Code Examples for org.eclipse.swt.widgets.TreeColumn#setText()

The following examples show how to use org.eclipse.swt.widgets.TreeColumn#setText() . 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: 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 2
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
protected void createColumns ( final Tree tree )
{
    final TreeColumn typeFilterColumn = new TreeColumn ( tree, SWT.NONE );
    typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
    typeFilterColumn.setResizable ( true );
    typeFilterColumn.setWidth ( 200 );

    final TreeColumn idFilterColumn = new TreeColumn ( tree, SWT.NONE );
    idFilterColumn.setText ( getString ( "_UI_IdFilterColumn_label" ) ); //$NON-NLS-1$
    idFilterColumn.setResizable ( true );
    idFilterColumn.setWidth ( 200 );

    final TreeColumn actionFilterColumn = new TreeColumn ( tree, SWT.NONE );
    actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
    actionFilterColumn.setResizable ( true );
    actionFilterColumn.setWidth ( 200 );
}
 
Example 3
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 4
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 5
Source File: ViewPropertiesOutput.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the view.
 *
 * @param root
 */
private void create(final Composite root) {

    root.setLayout(new FillLayout());
    
    final Tree tree = new Tree(root, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);
    
    treeViewer = new TreeViewer(tree);
    tree.setMenu(new ClipboardHandlerTree(treeViewer).getMenu());
    
    final TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    tree.setLinesVisible(true);
    column1.setAlignment(SWT.LEFT);
    column1.setText(Resources.getMessage("PropertiesView.1")); //$NON-NLS-1$
    column1.setWidth(160);
    final TreeColumn column2 = new TreeColumn(tree, SWT.RIGHT);
    column2.setAlignment(SWT.LEFT);
    column2.setText(Resources.getMessage("PropertiesView.2")); //$NON-NLS-1$
    column2.setWidth(100);

    treeViewer.setContentProvider(new OutputContentProvider());
    treeViewer.setLabelProvider(new OutputLabelProvider());

    treeViewer.setInput(roots);
    treeViewer.expandAll();
}
 
Example 6
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 7
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 8
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 9
Source File: TreeExplorer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void setLeftHeader(final String title) {
    leftTree.getTree().setHeaderVisible(true);
    final TreeColumn columnName = new TreeColumn(leftTree.getTree(), SWT.NONE);
    columnName.setText(title);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, 300));
    leftTree.getTree().setLayout(layout);
}
 
Example 10
Source File: JobGridDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Add the controls to the tab
 */
private void addControls() {

  // Create the tree table...
  wTree = new Tree( jobGraph.extraViewTabFolder, SWT.V_SCROLL | SWT.H_SCROLL );
  wTree.setHeaderVisible( true );
  TreeMemory.addTreeListener( wTree, STRING_CHEF_LOG_TREE_NAME );

  TreeColumn column1 = new TreeColumn( wTree, SWT.LEFT );
  column1.setText( BaseMessages.getString( PKG, "JobLog.Column.JobJobEntry" ) );
  column1.setWidth( 200 );

  TreeColumn column2 = new TreeColumn( wTree, SWT.LEFT );
  column2.setText( BaseMessages.getString( PKG, "JobLog.Column.Comment" ) );
  column2.setWidth( 200 );

  TreeColumn column3 = new TreeColumn( wTree, SWT.LEFT );
  column3.setText( BaseMessages.getString( PKG, "JobLog.Column.Result" ) );
  column3.setWidth( 100 );

  TreeColumn column4 = new TreeColumn( wTree, SWT.LEFT );
  column4.setText( BaseMessages.getString( PKG, "JobLog.Column.Reason" ) );
  column4.setWidth( 200 );

  TreeColumn column5 = new TreeColumn( wTree, SWT.LEFT );
  column5.setText( BaseMessages.getString( PKG, "JobLog.Column.Filename" ) );
  column5.setWidth( 200 );

  TreeColumn column6 = new TreeColumn( wTree, SWT.RIGHT );
  column6.setText( BaseMessages.getString( PKG, "JobLog.Column.Nr" ) );
  column6.setWidth( 50 );

  TreeColumn column7 = new TreeColumn( wTree, SWT.RIGHT );
  column7.setText( BaseMessages.getString( PKG, "JobLog.Column.LogDate" ) );
  column7.setWidth( 120 );

  FormData fdTree = new FormData();
  fdTree.left = new FormAttachment( 0, 0 );
  fdTree.top = new FormAttachment( 0, 0 );
  fdTree.right = new FormAttachment( 100, 0 );
  fdTree.bottom = new FormAttachment( 100, 0 );
  wTree.setLayoutData( fdTree );

  final Timer tim = new Timer( "JobGrid: " + jobGraph.getMeta().getName() );
  TimerTask timtask = new TimerTask() {
    public void run() {
      Display display = jobGraph.getDisplay();
      if ( display != null && !display.isDisposed() ) {
        display.asyncExec( new Runnable() {
          public void run() {
            // Check if the widgets are not disposed.
            // This happens is the rest of the window is not yet disposed.
            // We ARE running in a different thread after all.
            //
            // TODO: add a "auto refresh" check box somewhere
            if ( !wTree.isDisposed() ) {
              refreshTreeTable();
            }
          }
        } );
      }
    }
  };
  tim.schedule( timtask, 10L, 2000L ); // refresh every 2 seconds...

  jobGraph.jobLogDelegate.getJobLogTab().addDisposeListener( new DisposeListener() {
    public void widgetDisposed( DisposeEvent disposeEvent ) {
      tim.cancel();
    }
  } );

}
 
Example 11
Source File: ContractInputTreeViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected TreeViewerColumn createColumnViewer(final String text, final int style) {
    final TreeViewerColumn columnViewer = new TreeViewerColumn(this, style);
    final TreeColumn column = columnViewer.getColumn();
    column.setText(text);
    return columnViewer;
}
 
Example 12
Source File: ViewPropertiesInput.java    From arx with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the view.
 *
 * @param root
 */
private void create(final Composite root) {

    root.setLayout(new FillLayout());
    
    Tree tree = new Tree(root, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);
    
    treeViewer = new TreeViewer(tree);
    tree.setMenu(new ClipboardHandlerTree(treeViewer).getMenu());
    
    final TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    tree.setLinesVisible(true);
    column1.setAlignment(SWT.LEFT);
    column1.setText(Resources.getMessage("PropertiesView.3")); //$NON-NLS-1$
    column1.setWidth(160);
    final TreeColumn column2 = new TreeColumn(tree, SWT.RIGHT);
    column2.setAlignment(SWT.LEFT);
    column2.setText(Resources.getMessage("PropertiesView.4")); //$NON-NLS-1$
    column2.setWidth(100);
    final TreeColumn column6 = new TreeColumn(tree, SWT.RIGHT);
    column6.setAlignment(SWT.LEFT);
    column6.setText(Resources.getMessage("PropertiesView.5")); //$NON-NLS-1$
    column6.setWidth(100);
    final TreeColumn column7 = new TreeColumn(tree, SWT.RIGHT);
    column7.setAlignment(SWT.LEFT);
    column7.setText(Resources.getMessage("PropertiesView.101")); //$NON-NLS-1$
    column7.setWidth(80);
    final TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT);
    column3.setAlignment(SWT.LEFT);
    column3.setText(Resources.getMessage("PropertiesView.6")); //$NON-NLS-1$
    column3.setWidth(50);
    final TreeColumn column4 = new TreeColumn(tree, SWT.RIGHT);
    column4.setAlignment(SWT.LEFT);
    column4.setText(Resources.getMessage("PropertiesView.7")); //$NON-NLS-1$
    column4.setWidth(50);
    final TreeColumn column5 = new TreeColumn(tree, SWT.RIGHT);
    column5.setAlignment(SWT.LEFT);
    column5.setText(Resources.getMessage("PropertiesView.8")); //$NON-NLS-1$
    column5.setWidth(50);
    final TreeColumn column8 = new TreeColumn(tree, SWT.RIGHT);
    column8.setAlignment(SWT.LEFT);
    column8.setText(Resources.getMessage("PropertiesView.113")); //$NON-NLS-1$
    column8.setWidth(50);
    final TreeColumn column9 = new TreeColumn(tree, SWT.RIGHT);
    column9.setAlignment(SWT.LEFT);
    column9.setText(Resources.getMessage("PropertiesView.126")); //$NON-NLS-1$
    column9.setWidth(50);

    treeViewer.setContentProvider(new InputContentProvider());
    treeViewer.setLabelProvider(new InputLabelProvider());

    treeViewer.setInput(roots);
    treeViewer.expandAll();
}
 
Example 13
Source File: ServerView.java    From RDFS with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the columns for the view
 */
@Override
public void createPartControl(Composite parent) {
  Tree main =
      new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
          | SWT.V_SCROLL);
  main.setHeaderVisible(true);
  main.setLinesVisible(false);
  main.setLayoutData(new GridData(GridData.FILL_BOTH));

  TreeColumn serverCol = new TreeColumn(main, SWT.SINGLE);
  serverCol.setText("Location");
  serverCol.setWidth(300);
  serverCol.setResizable(true);

  TreeColumn locationCol = new TreeColumn(main, SWT.SINGLE);
  locationCol.setText("Master node");
  locationCol.setWidth(185);
  locationCol.setResizable(true);

  TreeColumn stateCol = new TreeColumn(main, SWT.SINGLE);
  stateCol.setText("State");
  stateCol.setWidth(95);
  stateCol.setResizable(true);

  TreeColumn statusCol = new TreeColumn(main, SWT.SINGLE);
  statusCol.setText("Status");
  statusCol.setWidth(300);
  statusCol.setResizable(true);

  viewer = new TreeViewer(main);
  viewer.setContentProvider(this);
  viewer.setLabelProvider(this);
  viewer.setInput(CONTENT_ROOT); // don't care

  getViewSite().setSelectionProvider(viewer);
  
  getViewSite().getActionBars().setGlobalActionHandler(
      ActionFactory.DELETE.getId(), deleteAction);
  getViewSite().getActionBars().getToolBarManager().add(editServerAction);
  getViewSite().getActionBars().getToolBarManager().add(newLocationAction);

  createActions();
  createContextMenu();
}
 
Example 14
Source File: UpdateWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void createControl(final Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		composite.setLayout(gridLayout);
		
		treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
		GridData data = new GridData(GridData.FILL_BOTH);
		Tree tree = treeViewer.getTree();
		tree.setLayoutData(data);
		tree.setHeaderVisible(true);
		
		IUColumnConfig[] columns = getColumnConfig();		
		for (int i = 0; i < columns.length; i++) {
			TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
			tc.setResizable(true);
			tc.setText(columns[i].getColumnTitle());
			tc.setWidth(columns[i].getWidthInPixels(tree));
		}
		
		contentProvider = new ProvElementContentProvider();
		treeViewer.setContentProvider(contentProvider);
		labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
		treeViewer.setLabelProvider(labelProvider);
		
		setControl(composite);
		
		final Runnable runnable = new Runnable() {
			public void run() {				
//				updateStatus(input, operation);
				setDrilldownElements(input, operation);
				treeViewer.setInput(input);
			}
		};
		
		if (operation != null && !operation.hasResolved()) {
			try {
				getContainer().run(true, false, new IRunnableWithProgress() {
					public void run(IProgressMonitor monitor) {
						operation.resolveModal(monitor);
						parent.getDisplay().asyncExec(runnable);
					}
				});
			} catch (Exception e) {
				StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
			}
		} else {
			runnable.run();
		}
	}
 
Example 15
Source File: GenerericTreeViewer.java    From offspring with MIT License 4 votes vote down vote up
private void createColumns() {
  GC gc = new GC(getTree().getParent());

  List<Integer> widths = new ArrayList<Integer>();

  for (final IGenericTableColumn c : table.getColumns()) {
    TreeViewerColumn viewerColumn = new TreeViewerColumn(this, SWT.NONE);

    viewerColumn.setLabelProvider(new GenericLabelProvider(c
        .getDataProvider()));

    if (c.getEditable()) {
      viewerColumn.setEditingSupport(c.getEditingSupport(this));
    }

    TreeColumn column = viewerColumn.getColumn();

    if (c.getSortable() && comparator != null) {
      column.addSelectionListener(getSelectionAdapter(column, c));
    }
    column.setText(c.getLabel());
    column.setAlignment(c.getAlignMent());

    int width;
    if (c.getWidth() != -1) {
      width = c.getWidth();
    }
    else if (c.getTextExtent() != null
        && c.getLabel().length() < c.getTextExtent().length()) {
      width = gc.textExtent(c.getTextExtent()).x + 2;
    }
    else {
      width = gc.textExtent(c.getLabel()).x + 2;
    }

    widths.add(width);
    column.setWidth(width);
    column.setResizable(c.getResizable());
  }
  gc.dispose();

  // /* All columns have their prefered width set now calculate percentages */
  // TreeColumnLayout layout = new TreeColumnLayout();
  // for (int i = 0; i < widths.size(); i++) {
  // layout.setColumnData(getTree().getColumns()[i], new ColumnWeightData(
  // widths.get(i), widths.get(i), true));
  // }
  // getTree().getParent().setLayout(layout);
}
 
Example 16
Source File: UpdateWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void createControl(final Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		composite.setLayout(gridLayout);
		
		treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
		GridData data = new GridData(GridData.FILL_BOTH);
		Tree tree = treeViewer.getTree();
		tree.setLayoutData(data);
		tree.setHeaderVisible(true);
		
		IUColumnConfig[] columns = getColumnConfig();		
		for (int i = 0; i < columns.length; i++) {
			TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
			tc.setResizable(true);
			tc.setText(columns[i].getColumnTitle());
			tc.setWidth(columns[i].getWidthInPixels(tree));
		}
		
		contentProvider = new ProvElementContentProvider();
		treeViewer.setContentProvider(contentProvider);
		labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
		treeViewer.setLabelProvider(labelProvider);
		
		setControl(composite);
		
		final Runnable runnable = new Runnable() {
			public void run() {				
//				updateStatus(input, operation);
				setDrilldownElements(input, operation);
				treeViewer.setInput(input);
			}
		};
		
		if (operation != null && !operation.hasResolved()) {
			try {
				getContainer().run(true, false, new IRunnableWithProgress() {
					public void run(IProgressMonitor monitor) {
						operation.resolveModal(monitor);
						parent.getDisplay().asyncExec(runnable);
					}
				});
			} catch (Exception e) {
				StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
			}
		} else {
			runnable.run();
		}
	}
 
Example 17
Source File: ServerView.java    From hadoop-gpu with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the columns for the view
 */
@Override
public void createPartControl(Composite parent) {
  Tree main =
      new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
          | SWT.V_SCROLL);
  main.setHeaderVisible(true);
  main.setLinesVisible(false);
  main.setLayoutData(new GridData(GridData.FILL_BOTH));

  TreeColumn serverCol = new TreeColumn(main, SWT.SINGLE);
  serverCol.setText("Location");
  serverCol.setWidth(300);
  serverCol.setResizable(true);

  TreeColumn locationCol = new TreeColumn(main, SWT.SINGLE);
  locationCol.setText("Master node");
  locationCol.setWidth(185);
  locationCol.setResizable(true);

  TreeColumn stateCol = new TreeColumn(main, SWT.SINGLE);
  stateCol.setText("State");
  stateCol.setWidth(95);
  stateCol.setResizable(true);

  TreeColumn statusCol = new TreeColumn(main, SWT.SINGLE);
  statusCol.setText("Status");
  statusCol.setWidth(300);
  statusCol.setResizable(true);

  viewer = new TreeViewer(main);
  viewer.setContentProvider(this);
  viewer.setLabelProvider(this);
  viewer.setInput(CONTENT_ROOT); // don't care

  getViewSite().setSelectionProvider(viewer);
  
  getViewSite().getActionBars().setGlobalActionHandler(
      ActionFactory.DELETE.getId(), deleteAction);
  getViewSite().getActionBars().getToolBarManager().add(editServerAction);
  getViewSite().getActionBars().getToolBarManager().add(newLocationAction);

  createActions();
  createContextMenu();
}
 
Example 18
Source File: CodeRecommendationResultsView.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public CodeRecommendationResultsView() {
	super(SWT.NONE);
	setBackgroundMode(SWT.INHERIT_FORCE);
	setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	setLayout(new FillLayout(SWT.HORIZONTAL));

	treeViewer = new TreeViewer(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	treeViewer.setAutoExpandLevel(3);
	Tree tree = treeViewer.getTree();
	tree.setHeaderVisible(true);

	TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
	TreeColumn trclmnCodeRecommendations = treeViewerColumn.getColumn();
	trclmnCodeRecommendations.setResizable(false);
	trclmnCodeRecommendations.setText("Code recommendations");

	treeViewer.setContentProvider(contentProvider = new TreeContentProvider());
	treeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider = new TreeLabelProvider()));

	tree.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TreeItem item = (TreeItem) e.item;
			Object data = item.getData();

			if (data instanceof ICodeRecommendationElement) {
				ICodeRecommendationElement element = (ICodeRecommendationElement) data;
				eventManager.invoke(l -> l.onCodeRecommendationSelected(element));
			}
		}
	});

	treeViewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event) {
			TreeViewer viewer = (TreeViewer) event.getViewer();
			IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
			Object selectedNode = thisSelection.getFirstElement();
			if (selectedNode instanceof CodeRecommendationTarget) {
				CodeRecommendationTarget target = (CodeRecommendationTarget) selectedNode;

				eventManager.invoke(l -> l.onTargetDoubleClicked(target));
			}
		}
	});

	createContextMenu(treeViewer);
}
 
Example 19
Source File: HopGuiWorkflowGridDelegate.java    From hop with Apache License 2.0 4 votes vote down vote up
/**
 * Add the controls to the tab
 */
private void addControls() {

  // Create the tree table...
  wTree = new Tree( workflowGraph.extraViewTabFolder, SWT.V_SCROLL | SWT.H_SCROLL );
  wTree.setHeaderVisible( true );
  TreeMemory.addTreeListener( wTree, STRING_CHEF_LOG_TREE_NAME );

  TreeColumn column1 = new TreeColumn( wTree, SWT.LEFT );
  column1.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.WorkflowAction" ) );
  column1.setWidth( 200 );

  TreeColumn column2 = new TreeColumn( wTree, SWT.LEFT );
  column2.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.Comment" ) );
  column2.setWidth( 200 );

  TreeColumn column3 = new TreeColumn( wTree, SWT.LEFT );
  column3.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.Result" ) );
  column3.setWidth( 100 );

  TreeColumn column4 = new TreeColumn( wTree, SWT.LEFT );
  column4.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.Reason" ) );
  column4.setWidth( 200 );

  TreeColumn column5 = new TreeColumn( wTree, SWT.LEFT );
  column5.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.Filename" ) );
  column5.setWidth( 200 );

  TreeColumn column6 = new TreeColumn( wTree, SWT.RIGHT );
  column6.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.Nr" ) );
  column6.setWidth( 50 );

  TreeColumn column7 = new TreeColumn( wTree, SWT.RIGHT );
  column7.setText( BaseMessages.getString( PKG, "WorkflowLog.Column.LogDate" ) );
  column7.setWidth( 120 );

  FormData fdTree = new FormData();
  fdTree.left = new FormAttachment( 0, 0 );
  fdTree.top = new FormAttachment( 0, 0 );
  fdTree.right = new FormAttachment( 100, 0 );
  fdTree.bottom = new FormAttachment( 100, 0 );
  wTree.setLayoutData( fdTree );

  final Timer tim = new Timer( "JobGrid: " + workflowGraph.getMeta().getName() );
  TimerTask timtask = new TimerTask() {
    public void run() {
      Display display = workflowGraph.getDisplay();
      if ( display != null && !display.isDisposed() ) {
        display.asyncExec( new Runnable() {
          public void run() {
            // Check if the widgets are not disposed.
            // This happens is the rest of the window is not yet disposed.
            // We ARE running in a different thread after all.
            //
            // TODO: add a "auto refresh" check box somewhere
            if ( !wTree.isDisposed() ) {
              refreshTreeTable();
            }
          }
        } );
      }
    }
  };
  tim.schedule( timtask, 10L, 2000L ); // refresh every 2 seconds...

  workflowGraph.workflowLogDelegate.getJobLogTab().addDisposeListener( new DisposeListener() {
    public void widgetDisposed( DisposeEvent disposeEvent ) {
      tim.cancel();
    }
  } );

}
 
Example 20
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 3 votes vote down vote up
/**
 * New tree column.
 *
 * @param container the container
 * @param width the width
 * @param alignment the alignment
 * @param header the header
 * @return the tree column
 */
protected TreeColumn newTreeColumn(Tree container, int width, int alignment, String header) {
  TreeColumn tc = new TreeColumn(container, alignment);
  if (header != null && (!header.equals(""))) { //$NON-NLS-1$
    tc.setText(header);
  }
  tc.setWidth(width);
  return tc;
}