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

The following are Jave code examples for showing how to use setLinesVisible() of the org.eclipse.swt.widgets.Tree class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: n4js   File: TreeViewerBuilder.java   Source Code and License Vote up 6 votes
@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
Project: durian-swt   File: ColumnFormat.java   Source Code and License Vote up 6 votes
/** Builds a table with the given columns. */
protected static Tree buildTree(Composite parent, int style, boolean linesVisible, boolean headerVisible, List<? extends ColumnBuilder> columnBuilders) {
	SwtMisc.assertClean(parent);
	// create the control
	Tree control = new Tree(parent, style);
	control.setLinesVisible(linesVisible);
	control.setHeaderVisible(headerVisible);

	// create the columns and layout
	Function<ColumnBuilder, TreeColumn> buildFunc = builder -> builder.build(control);
	List<TreeColumn> columns = columnBuilders.stream().map(buildFunc).collect(Collectors.toList());
	buildLayout(control, new TreeColumnLayout(), columns, columnBuilders);

	// return the control
	return control;
}
 
Example 3
Project: team-explorer-everywhere   File: QueryResultsTreeControl.java   Source Code and License Vote up 5 votes
private void setupTree(final Tree tree) {
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setLayout(new TreeLayout());

    /* Pad table height by four pixels to increase readability */
    tree.addListener(/* SWT.MeasureItem */41, new MeasureItemHeightListener(4));
    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(final MouseEvent e) {
        }
    });
}
 
Example 4
Project: NEXCORE-UML-Modeler   File: StereotypePropertyComposite.java   Source Code and License Vote up 5 votes
/**
 * 뷰어가 담길 컴포지트 생성
 * 
 * @param parent
 * @return Composite
 */
public Composite createComposite(final Composite parent) {
    Tree tree = new Tree(parent, SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);

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

    String[] strHeadings = { UMLMessage.LABEL_PROPERTY, UMLMessage.LABEL_VALUE };

    TreeColumn propertyTreeColumn = new TreeColumn(tree, SWT.NONE);
    propertyTreeColumn.setWidth(240);
    propertyTreeColumn.setText(strHeadings[0]);
    propertyTreeColumn.setAlignment(SWT.LEFT);
    propertyTreeColumn.setResizable(true);

    TreeColumn valueTreeColumn = new TreeColumn(tree, SWT.NONE);
    valueTreeColumn.setWidth(300);
    valueTreeColumn.setText(strHeadings[1]);
    valueTreeColumn.setAlignment(SWT.LEFT);
    valueTreeColumn.setResizable(true);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 150;
    gridData.horizontalSpan = 2;
    tree.setLayoutData(gridData);

    viewer = new TreeViewer(tree);
    tree.setItemCount(20);

    viewer.setContentProvider(new StereotypePropertyTreeContentProvider());
    viewer.setLabelProvider(new StereotypePropertyTableColumnLabelProvider(this));

    // viewer.setInput(input);
    viewer.addSelectionChangedListener(new StereotypePropertySelectionChangedListener(parent, this));

    return parent;
}
 
Example 5
Project: SMVHunter   File: NativeHeapPanel.java   Source Code and License Vote up 5 votes
private void initializeStackTraceTree(Tree tree) {
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);

    List<String> properties = Arrays.asList(new String[] {
            "Address",
            "Library",
            "Method",
            "File",
            "Line",
    });

    List<String> sampleValues = Arrays.asList(new String[] {
            "0x1234_5678",
            "/path/in/device/to/system/library.so",
            "PossiblyLongDemangledMethodName",
            "/android/out/prefix/in/home/directory/to/path/in/device/to/system/library.so",
            "2000",
    });

    for (int i = 0; i < properties.size(); i++) {
        String p = properties.get(i);
        String v = sampleValues.get(i);
        TableHelper.createTreeColumn(tree, p, SWT.LEFT, v, getPref("stack", p), mPrefStore);
    }

    mStackTraceTreeViewer = new TreeViewer(tree);

    mStackTraceTreeViewer.setContentProvider(new NativeStackContentProvider());
    mStackTraceTreeViewer.setLabelProvider(new NativeStackLabelProvider());

    mStackTraceTreeViewer.setInput(null);
}
 
Example 6
Project: scouter   File: DbLockListView.java   Source Code and License Vote up 5 votes
@Override
public void createPartControl(Composite parent) {
	this.setPartName("Lock List[" + TextProxy.object.getText(objHash) + "]");
	columnLayout = new TreeColumnLayout();
	parent.setLayout(columnLayout);
	tree = new Tree(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);
	viewer = new TreeViewer(tree);
	createColumns();
	viewer.setContentProvider(new LockContentProvider());
	viewer.setLabelProvider(new LockLabelProvider());
	viewer.setInput(root);
}
 
Example 7
Project: n4js   File: ProjectCompareTree.java   Source Code and License Vote up 4 votes
/**
 * 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 8
Project: hybris-commerce-eclipse-plugin   File: TSVEditor.java   Source Code and License Vote up 4 votes
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 9
Project: hadoop-2.6.0-cdh5.4.3   File: ServerView.java   Source Code and License Vote up 4 votes
/**
 * 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 10
Project: hadoop-EAR   File: ServerView.java   Source Code and License Vote up 4 votes
/**
 * 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 11
Project: RFRunnerPlugin   File: SampleView.java   Source Code and License Vote up 4 votes
public void createPartControl(Composite parent) {
	GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
	parent.setLayout(new GridLayout(1, true));
	parent.setLayoutData(parentData);

	Display display = Display.getCurrent();
	parent.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

	Composite searchMenu = new Composite(parent, SWT.BORDER);
	searchMenu.setLayout(new GridLayout(2, false));
	searchMenu.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
			true, false));

	Label searchLabel = new Label(searchMenu, SWT.LEFT);
	searchLabel.setLayoutData(new GridData(SWT.FILL, GridData.CENTER,
			false, false));
	searchLabel.setText("Search: ");

	filterText = new Text(searchMenu, SWT.FILL);
	filterText.setLayoutData(new GridData(SWT.FILL, GridData.CENTER, true,
			false));

	Composite tableViewerComposite = new Composite(parent, SWT.NONE);
	tableViewerComposite.setLayout(new GridLayout(1, true));
	tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
			true, true));

	Tree tree = new Tree(tableViewerComposite, SWT.FILL | SWT.H_SCROLL
			| SWT.V_SCROLL);

	treeViewer = new TreeViewer(tree);
	treeViewer.setData("GroupType", GroupType.STATUS);
	treeViewer.getControl().setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));
	TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
	tree.setLinesVisible(true);
	column1.setAlignment(SWT.LEFT);
	TreeColumn column2 = new TreeColumn(tree, SWT.RIGHT);
	column2.setAlignment(SWT.LEFT);
	column2.setWidth(50);

	treeContentProvider = new TreeContentProvider(treeViewer);
	treeViewer.setContentProvider(treeContentProvider);
	treeViewer.setLabelProvider(new TableLabelProvider(treeViewer,
			treeContentProvider));
	treeViewer.setInput(getViewSite());
	treeViewer.addFilter(filter);
	treeViewer.setSorter(new Sorter());
	treeViewer.expandAll();

	makeActions();
	setDoubleClickAction();
	createToolbar();
	setSearchListener();

	parent.addControlListener(new ControlAdapter() {
		@Override
		public void controlResized(ControlEvent e) {
			int parentWidth = parent.getSize().x;
			int scrollWidth = 42;
			column1.setWidth(parentWidth - column2.getWidth() - scrollWidth);
		}
	});
}
 
Example 12
Project: SMVHunter   File: NativeHeapPanel.java   Source Code and License Vote up 4 votes
private void initializeDetailsTree(Tree tree) {
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);

    List<String> properties = Arrays.asList(new String[] {
            "Library",
            "Total",
            "Percentage",
            "Count",
            "Size",
            "Method",
    });

    List<String> sampleValues = Arrays.asList(new String[] {
            "/path/in/device/to/system/library.so",
            "123456789",
            " 100%",
            "123456789",
            "123456789",
            "PossiblyLongDemangledMethodName",
    });

    // right align numeric values
    List<Integer> swtFlags = Arrays.asList(new Integer[] {
            SWT.LEFT,
            SWT.RIGHT,
            SWT.RIGHT,
            SWT.RIGHT,
            SWT.RIGHT,
            SWT.LEFT,
    });

    for (int i = 0; i < properties.size(); i++) {
        String p = properties.get(i);
        String v = sampleValues.get(i);
        int flags = swtFlags.get(i);
        TableHelper.createTreeColumn(tree, p, flags, v, getPref("details", p), mPrefStore);
    }

    mDetailsTreeViewer = new TreeViewer(tree);

    mDetailsTreeViewer.setUseHashlookup(true);

    boolean displayZygotes = mPrefStore.getBoolean(PREFS_SHOW_ZYGOTE_ALLOCATIONS);
    mContentProviderByAllocations = new NativeHeapProviderByAllocations(mDetailsTreeViewer,
            displayZygotes);
    mContentProviderByLibrary = new NativeHeapProviderByLibrary(mDetailsTreeViewer,
            displayZygotes);
    if (mPrefStore.getBoolean(PREFS_GROUP_BY_LIBRARY)) {
        mDetailsTreeViewer.setContentProvider(mContentProviderByLibrary);
    } else {
        mDetailsTreeViewer.setContentProvider(mContentProviderByAllocations);
    }

    mDetailsTreeLabelProvider = new NativeHeapLabelProvider();
    mDetailsTreeViewer.setLabelProvider(mDetailsTreeLabelProvider);

    mDetailsTreeViewer.setInput(null);

    tree.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            displayStackTraceForSelection();
        }
    });
}
 
Example 13
Project: scouter   File: DigestTableView.java   Source Code and License Vote up 4 votes
public void createPartControl(Composite parent) {
	this.parent = parent;
	GridLayout gridlayout = new GridLayout(1, false);
	gridlayout.marginHeight = 0;
	gridlayout.horizontalSpacing = 0;
	gridlayout.marginWidth = 0;
	parent.setLayout(gridlayout);
	columnLayout = new TreeColumnLayout();
	Composite mainComp = new Composite(parent, SWT.NONE);
	mainComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	mainComp.setLayout(columnLayout);
	viewer = new TreeViewer(mainComp, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	createColumns();
	final Tree tree = viewer.getTree();
	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);
	viewer.setLabelProvider(new TreeLabelProvider());
    viewer.setContentProvider(new TreeContentProvider());
    viewer.setComparator(new TreeLabelSorter(viewer));
    viewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			StructuredSelection sel = (StructuredSelection) event.getSelection();
			Object o = sel.getFirstElement();
			if (o instanceof DigestModel) {
				DigestModel model = (DigestModel) o;
				new DigestDetailDialog().show(model, stime, etime, serverId);
			}
		}
	});
    viewer.setInput(root);
    
    IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    Action actAutoRefresh = new Action("Auto Refresh in 10 sec.", IAction.AS_CHECK_BOX){ 
        public void run() {
        	isAutoRefresh = isChecked();
        	if (isAutoRefresh) {
        		thread.interrupt();
        	}
        }
    };
    actAutoRefresh.setImageDescriptor(ImageUtil.getImageDescriptor(Images.refresh_auto));
    man.add(actAutoRefresh);
    
    long now = TimeUtil.getCurrentTime(serverId);
    date = DateUtil.yyyymmdd(now);
    stime = now - DateUtil.MILLIS_PER_FIVE_MINUTE;
    etime = now;
    loadQueryJob.schedule(2000);
    
    thread = new RefreshThread(this, 10000);
	thread.start();
}
 
Example 14
Project: hssd   File: EntryEditor.java   Source Code and License Vote up 2 votes
@Override
public void createPartControl(Composite parent) {
    final Layout layout = new FillLayout();
    parent.setLayout(layout);

    viewer = new TreeViewer(parent,
            SWT.MULTI |
            SWT.H_SCROLL |
            SWT.V_SCROLL |
            SWT.FULL_SELECTION |
            SWT.VIRTUAL);

    final Tree tree = viewer.getTree();

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

    viewer.setContentProvider(new ValueTreeCP());
    viewer.setLabelProvider(new ValueTreeLP());
    viewer.setComparator(new ViewerComparator(new IntAwareCmp()));
    viewer.setInput(getEditorInput());
    
    final ValueTreeLP.Column[] columns = ValueTreeLP.Column.values();

    createColumns(columns);

    enableValueTreeEditing();

    ColumnViewerToolTipSupport.enableFor(viewer);
    
    setPartName(getEditorInput().getName());
    
    hookContextMenu();
    
    hookDragAndDrop();
    
    getSite().setSelectionProvider(viewer);
    
    IContextService svc = 
    		(IContextService)getSite().getService(IContextService.class);

    svc.activateContext("com.insweat.hssd.editor.contexts.inEntryEditor");
}