Java Code Examples for org.eclipse.swt.widgets.Tree#setHeaderVisible()

The following examples show how to use org.eclipse.swt.widgets.Tree#setHeaderVisible() . 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: 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 2
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 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: AbstractTmfTreeViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param parent
 *            The parent composite that holds this viewer
 * @param treeViewer
 *            The tree viewer to use
 * @since 3.1
 */
public AbstractTmfTreeViewer(Composite parent, TreeViewer treeViewer) {
    super(parent);
    /* Build the tree viewer part of the view */
    fTreeViewer = treeViewer;
    final Tree tree = fTreeViewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    fTreeViewer.setContentProvider(new TreeContentProvider());
    fTreeViewer.setLabelProvider(new TreeLabelProvider());
    List<TmfTreeColumnData> columns = getColumnDataProvider().getColumnData();
    this.setTreeColumns(columns);
}
 
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: NodeDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeViewer createTreeViewer(Composite parent) {
  TreeViewer result = super.createTreeViewer(parent);

  // Initialize the table.
  Tree tree = result.getTree();
  tree.setHeaderVisible(true);
  tree.setToolTipText("Node Display Properties");
  EditColTableDef.setupTree(TABLE_DEF, tree);

  // Configure cell editing.
  CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length];
  cellEditors[INDEX_NAME] = null;
  cellEditors[INDEX_SELECTED] = new CheckboxCellEditor(tree);
  cellEditors[INDEX_XPOS] = new TextCellEditor(tree);
  cellEditors[INDEX_YPOS] = new TextCellEditor(tree);
  cellEditors[INDEX_VISIBLE] = new CheckboxCellEditor(tree);
  cellEditors[INDEX_SIZE] = new ComboBoxCellEditor(
      tree, buildSizeOptions());
  cellEditors[INDEX_COLOR] = new ColorCellEditor(tree);

  result.setCellEditors(cellEditors);
  result.setLabelProvider(new PartLabelProvider());
  result.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));
  result.setCellModifier(new PartCellModifier());

  return result;
}
 
Example 7
Source File: NodeStatsTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeViewer createTreeViewer(Composite parent) {
  TreeViewer result = super.createTreeViewer(parent);

  // Initialize the table.
  Tree tree = result.getTree();
  tree.setHeaderVisible(true);
  tree.setToolTipText("Node Display Properties");
  EditColTableDef.setupTree(TABLE_DEF, tree);

  result.setLabelProvider(new PartLabelProvider());
  result.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF));

  return result;
}
 
Example 8
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 9
Source File: XViewer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public XViewer(Tree tree, IXViewerFactory xViewerFactory, boolean filterRealTime, boolean searchRealTime) {
   super(tree);
   this.xViewerFactory = xViewerFactory;
   this.menuManager = new MenuManager();
   this.menuManager.setRemoveAllWhenShown(true);
   this.menuManager.createContextMenu(tree.getParent());
   if (xViewerFactory.isFilterUiAvailable()) {
      this.filterDataUI = new FilterDataUI(this, filterRealTime);
   } else {
      this.filterDataUI = null;
   }
   if (xViewerFactory.isSearchUiAvailable()) {
      this.searchDataUI = new SearchDataUI(this, searchRealTime);
   } else {
      this.searchDataUI = null;
   }
   this.columnFilterDataUI = new ColumnFilterDataUI(this);
   try {
      customizeMgr = new CustomizeManager(this, xViewerFactory);
   } catch (Exception ex) {
      XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
   }
   createSupportWidgets(parentToTopComposites.get(tree.getParent()));
   parentToTopComposites.remove(tree.getParent());

   tree.setHeaderVisible(true);
   tree.setLinesVisible(true);
   setUseHashlookup(true);
   setupCtrlKeyListener();
   if (xViewerFactory.isCellGradientOn()) {
      xViewerGradient = new XViewerGradient(this);
   }
}
 
Example 10
Source File: TSVEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 4 votes vote down vote up
void createPage1() {
	Composite composite = new Composite(getContainer(), SWT.NONE);
	FillLayout layout = new FillLayout();
	composite.setLayout(layout);
	
	Tree tree = new Tree(composite, SWT.BORDER | SWT.H_SCROLL
			| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);
	TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
	column1.setWidth(250);
	column1.setResizable(true);
	TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
	column2.setWidth(40);
	column2.setResizable(true);
	TreeColumn column3 = new TreeColumn(tree, SWT.LEFT);
	column3.setWidth(250);
	column3.setResizable(true);
	TreeColumn column4 = new TreeColumn(tree, SWT.LEFT);
	column4.setWidth(600);
	column4.setResizable(true);
	
	TreeViewer resultsViewer = new TreeViewer(tree);
	resultsViewer.setLabelProvider(new TSVResultsLabelProvider());
	resultsViewer.setContentProvider(new TSVResultsContentProvider(resultMap));
	resultsViewer.setInput(createModel());
	
	resultsViewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event) {
			
			IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
	        if (structuredSelection.isEmpty()) return;

	        Object selection = structuredSelection.getFirstElement();
	        
	        if (selection instanceof TSVResult) {
	        	String fileName = ((TSVResult) selection).getFilename();
	        	int lineNumber = ((TSVResult) selection).getLineNumber();
	        	String extensionName = fileName.replaceAll("-items.xml", "");
	        		
	        	IProject extension = ResourcesPlugin.getWorkspace().getRoot().getProject(extensionName);
	        	IFile itemsxml = extension.getFile("resources/" + fileName);
	        	if (itemsxml.exists()) {
		        	IMarker marker;
		        	try {
						marker = itemsxml.createMarker(IMarker.TEXT);
						HashMap<String, Object> map = new HashMap<String, Object>();
						map.put(IMarker.LINE_NUMBER, lineNumber);
						marker.setAttributes(map);
						IDE.openEditor(getSite().getPage(), marker);
						marker.delete();
					}
		        	catch (CoreException e) {
						e.printStackTrace();
					}
	        	}
	        	else {
	        		MessageBox dialog = new MessageBox(getContainer().getShell(), SWT.ICON_WARNING | SWT.OK);
	        		dialog.setText("Extension not found");
	        		dialog.setMessage("The extension " + extensionName + " was not found in the workspace. Please import it and try again.");
	        		dialog.open();
	        	}
	        }
		}
		
	});

	int index = addPage(composite);
	setPageText(index, "Results");
}
 
Example 11
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 12
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 13
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 14
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 15
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 16
Source File: PromptParameterDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createParameterGroup( Composite composite )
{
	final Group group2 = new Group( composite, SWT.NONE );
	group2.setLayout( new GridLayout( ) );
	group2.setLayoutData( new GridData( SWT.FILL,
			SWT.FILL,
			true,
			true,
			1,
			8 ) );// GridData.FILL_BOTH));

	group2.setText( Messages.getString( "PromptParameterDialog.parameterGroup.title" ) );

	Label label1 = new Label( group2, SWT.NONE );
	label1.setText( Messages.getString( "PromptParameterDialog.parameterGroup.label" ) );

	TreeViewer viewer2 = new TreeViewer( group2, SWT.FULL_SELECTION );

	Tree tableTree2 = viewer2.getTree( );
	GridData gd = new GridData( GridData.FILL_BOTH );
	tableTree2.setLayoutData( gd );
	tableTree2.setHeaderVisible( true );
	tableTree2.setLinesVisible( true );

	TreeViewerColumn tvc21 = new TreeViewerColumn( viewer2, SWT.NONE );
	tvc21.getColumn( )
			.setText( Messages.getString( "PromptParameterDialog.parameterGroup.nameColumn" ) ); //$NON-NLS-1$
	tvc21.getColumn( ).setWidth( 200 );
	tvc21.setLabelProvider( new NameLabelProvider( selectedStatusMap ) );
	tvc21.setEditingSupport( new ParameterEditingSupport( viewer2,
			selectedStatusMap ) );

	TreeViewerColumn tvc22 = new TreeViewerColumn( viewer2, SWT.NONE );
	tvc22.getColumn( )
			.setText( Messages.getString( "PromptParameterDialog.parameterGroup.previousValue" ) ); //$NON-NLS-1$
	tvc22.getColumn( ).setWidth( 200 );
	tvc22.setLabelProvider( new PreviousValueLabelProvider( ) );

	TreeViewerColumn tvc23 = new TreeViewerColumn( viewer2, SWT.NONE );
	tvc23.getColumn( )
			.setText( Messages.getString( "PromptParameterDialog.parameterGroup.revisedValue" ) ); //$NON-NLS-1$
	tvc23.getColumn( ).setWidth( 200 );
	tvc23.setLabelProvider( new RevisedValueLabelProvider( ) );

	viewer2.setContentProvider( new ParameterContentProvider( ) );
	viewer2.setInput( ( (IAmbiguousOption) input ).getAmbiguousParameters( ) );
	viewer2.expandAll( );
}
 
Example 17
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 18
Source File: TreeWithAddRemove.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param initialItems: Can be a String[] or a HashMap<String, String> (if null it's considered String[])
 */
public TreeWithAddRemove(Composite parent, int style, Object initialItems, boolean createEditButton) {
    super(parent, style);
    if (initialItems == null) {
        initialItems = new String[] {};
    }

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    this.setLayout(layout);

    GridData data = new GridData(GridData.FILL_BOTH);

    tree = new Tree(this, SWT.BORDER | SWT.MULTI);
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    tree.setLayoutData(data);

    Composite buttonsSourceFolders = new Composite(this, SWT.NONE);
    buttonsSourceFolders.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonsSourceFolders.setLayout(layout);

    for (int i = 0; i < getNumberOfAddButtons(); i++) {
        createAddButton(buttonsSourceFolders, i);
    }

    createRemoveButton(buttonsSourceFolders);
    if (createEditButton) {
        this.createEditButton(buttonsSourceFolders);
    }

    if (initialItems instanceof String[]) {
        editingStyle = EDITING_STYLE_ARRAY_OF_STRINGS;

    } else if (initialItems instanceof Map) {
        editingStyle = EDITING_STYLE_MAP_OF_STRINGS;
        tree.setHeaderVisible(true);
        TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
        column1.setText("Key");
        column1.setWidth(200);
        TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
        column2.setText("Value");
        column2.setWidth(200);
        columns = new TreeColumn[] { column1, column2 };

    } else {
        throw new RuntimeException("Unexpected initial items: " + initialItems);
    }

    setTreeItems(initialItems);
}
 
Example 19
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 20
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();
}