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

The following examples show how to use org.eclipse.swt.widgets.Tree#setLinesVisible() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: n4js   File: TreeViewerBuilder.java    License: 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 Project: olca-app   File: Trees.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public static TreeViewer createViewer(
		Composite parent, String[] headers, IBaseLabelProvider label) {
	TreeViewer viewer = new TreeViewer(parent,
			SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI);
	Tree tree = viewer.getTree();
	boolean hasColumns = headers != null && headers.length > 0;
	tree.setLinesVisible(hasColumns);
	tree.setHeaderVisible(hasColumns);
	if (hasColumns) {
		createColumns(viewer, headers, label);
	}
	if (label != null) {
		viewer.setLabelProvider(label);
	}
	GridData data = UI.gridData(tree, true, true);
	data.minimumHeight = 120;
	Point p = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	data.heightHint = p.y < 120 ? 120 : p.y;
	return viewer;
}
 
Example 3
public static void main(String[] args) {

		Display display = new Display();
		Shell shell = new Shell(display);
		GridLayout layout = new GridLayout(1, false);
		shell.setLayout(layout);

		final List<Team> items = createList();

		// 1) Create pageable tree with 10 items per page
		// This SWT Component create internally a SWT Tree+JFace TreeViewer
		int pageSize = 10;
		PageableTree pageableTree = new PageableTree(shell, SWT.BORDER,
				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize);
		pageableTree.setLayoutData(new GridData(GridData.FILL_BOTH));

		// 2) Initialize the tree viewer + SWT Tree
		TreeViewer viewer = pageableTree.getViewer();
		viewer.setContentProvider(TeamContentProvider.getInstance());
		viewer.setLabelProvider(new LabelProvider());

		Tree tree = viewer.getTree();
		tree.setHeaderVisible(true);
		tree.setLinesVisible(true);

		// 3) Create Tree columns with sort of paginated list.
		createColumns(viewer);

		// 3) Set current page to 0 to refresh the tree
		pageableTree.setPageLoader(new PageResultLoaderList<Team>(items));
		pageableTree.setCurrentPage(0);

		shell.setSize(400, 250);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
 
Example 4
Source Project: nebula   File: XViewer.java    License: 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 5
Source Project: n4js   File: ProjectCompareTree.java    License: 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 6
/**
 * 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 7
Source Project: arx   File: ViewPropertiesOutput.java    License: 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 8
Source Project: nebula   File: PTWidgetTree.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#buildWidget(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void buildWidget(final Composite parent) {
	tree = new Tree(parent, SWT.FULL_SELECTION);
	tree.setLinesVisible(true);
	tree.setHeaderVisible(true);
	tree.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1));

	final TreeColumn propertyColumn = new TreeColumn(tree, SWT.NONE);
	propertyColumn.setText(ResourceManager.getLabel(ResourceManager.PROPERTY));

	final TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE);
	valueColumn.setText(ResourceManager.getLabel(ResourceManager.VALUE));

	fillData();
	tree.addControlListener(new ControlAdapter() {

		/**
		 * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent)
		 */
		@Override
		public void controlResized(final ControlEvent e) {
			final Rectangle area = tree.getParent().getClientArea();
			final Point size = tree.computeSize(SWT.DEFAULT, SWT.DEFAULT);
			final ScrollBar vBar = tree.getVerticalBar();
			int width = area.width - tree.computeTrim(0, 0, 0, 0).width - vBar.getSize().x;
			if (size.y > area.height + tree.getHeaderHeight()) {
				// Subtract the scrollbar width from the total column width
				// if a vertical scrollbar will be required
				final Point vBarSize = vBar.getSize();
				width -= vBarSize.x;
			}
			propertyColumn.pack();
			valueColumn.setWidth(width - propertyColumn.getWidth());
			tree.removeControlListener(this);
		}

	});

	tree.addListener(SWT.Selection, event -> {
		if (tree.getSelectionCount() == 0 || tree.getSelection()[0] == null) {
			return;
		}
		updateDescriptionPanel(tree.getSelection()[0].getData());
	});

}
 
Example 9
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 10
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 11
Source Project: RDFS   File: ServerView.java    License: 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 12
Source Project: arx   File: ViewPropertiesInput.java    License: 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 Project: hadoop-gpu   File: ServerView.java    License: 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();
}