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

The following are Jave code examples for showing how to use setHeaderVisible() 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.
+ Save this method
Example 1
Project: n4js   File: TreeViewerBuilder.java   View Source Code 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   View Source Code 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: sophie   File: SystemTree.java   View Source Code Vote up 6 votes
/**
 * Create a new tree listing Solr system information.
 * 
 * @param composite
 *            Parent composite.
 */
public SystemTree(Composite composite) throws SophieException {
	// Instantiate Tree.
	tree = new Tree(composite, SWT.BORDER);
	tree.setHeaderVisible(true);
	tree.setLayoutData(new GridData(GridData.FILL_BOTH));

	// Create name/value columns.
	columnName = new TreeColumn(tree, SWT.LEFT);
	columnName.setText("Name");
	columnValue = new TreeColumn(tree, SWT.LEFT);
	columnValue.setText("Value");

	// Populate tree with data from Solr.
	populate();

	// Pack columns.
	columnName.pack();
	columnValue.pack();
}
 
Example 4
Project: convertigo-eclipse   File: ProjectSchemaWizardPage.java   View Source Code Vote up 5 votes
public void createControl(Composite parent) {
	Composite container = new Composite(parent, SWT.NULL);
	GridLayout layout = new GridLayout();
	container.setLayout(layout);
	layout.numColumns = 2;
	layout.verticalSpacing = 9;

	Label label = new Label(container, SWT.NULL);
	label.setText("&Project:");
	
	tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
	tree.setHeaderVisible(false);
	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
	gridData.verticalSpan = 20;
	gridData.horizontalSpan = 2;
	tree.setLayoutData(gridData);		
	tree.addListener(SWT.Selection, new Listener() {
		public void handleEvent(final Event event) {
			TreeItem item = (TreeItem) event.item;
			projectName = item.getText();
			dialogChanged();
		}
	});
	tree.setVisible(false);
	
	initialize();
	setControl(container);
	dialogChanged();
}
 
Example 5
Project: team-explorer-everywhere   File: QueryResultsTreeControl.java   View Source Code 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 6
Project: NEXCORE-UML-Modeler   File: StereotypePropertyComposite.java   View Source Code 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 7
Project: VariantSync   File: ResourceChangesView.java   View Source Code Vote up 5 votes
protected void createColumns(final Tree tree) {
	TableLayout layout = new TableLayout();
	tree.setLayout(layout);
	tree.setHeaderVisible(true);

	for (int i = 0; i < 4; i++) {

		if (i == 1) {
			layout.addColumnData(new ColumnPixelData(100, true));
		} else {
			layout.addColumnData(new ColumnPixelData(300, true));
		}
		TreeColumn column = new TreeColumn(tree, SWT.NONE, i);
		if (i == 0) {
			column.setText("Resource");
		}
		if (i == 1) {
			column.setText("Project");
		}
		if (i == 2) {
			column.setText("Possible Targets");
		}
		if (i == 3) {
			column.setText("Targets");
		}
		column.setResizable(true);
		TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, column);
		viewerColumn
				.setLabelProvider(new ResourceChangesColumnLabelProvider(i));
	}
}
 
Example 8
Project: SMVHunter   File: NativeHeapPanel.java   View Source Code 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 9
Project: depan   File: NodeStatsTableControl.java   View Source Code Vote up 5 votes
@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 10
Project: depan   File: NodeDisplayTableControl.java   View Source Code Vote up 5 votes
@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 11
Project: scouter   File: DbLockListView.java   View Source Code 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 12
Project: n4js   File: ProjectCompareTree.java   View Source Code 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 13
Project: convertigo-eclipse   File: ComponentInfoWizardPage.java   View Source Code Vote up 4 votes
public void createControl(Composite parent) {
	container = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	container.setLayout(layout);
	layout.numColumns = 2;
	layout.verticalSpacing = 9;

	Label label = new Label(container, SWT.NULL);
	label.setText("&Name:");

	beanName = new Text(container, SWT.BORDER | SWT.SINGLE);
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	beanName.setLayoutData(gd);
	beanName.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			dialogChanged();
		}
	});
	
	if (parentObject instanceof CouchDbConnector || parentObject instanceof FullSyncConnector) {
		couchVariablesComposite = new CouchVariablesComposite(container, SWT.V_SCROLL);
		
		GridData couchVarData = new GridData(GridData.FILL_BOTH);
		couchVarData.horizontalSpan = 2;
		
		couchVariablesComposite.setLayoutData(couchVarData);
		
	} else {
		tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
		tree.setHeaderVisible(false);
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
		gridData.verticalSpan = 20;
		gridData.horizontalSpan = 2;
		tree.setLayoutData(gridData);		
		tree.addListener(SWT.Selection, new Listener() {
			public void handleEvent(final Event event) {
				TreeItem item = (TreeItem) event.item;
				treeItemName = item.getText();
				String suffix = getBeanName().endsWith(ScHandlerStatement.EVENT_ENTRY_HANDLER) ? 
						ScHandlerStatement.EVENT_ENTRY_HANDLER:
							getBeanName().endsWith(ScHandlerStatement.EVENT_EXIT_HANDLER) ?
									ScHandlerStatement.EVENT_EXIT_HANDLER : "";
				setBeanName("on"+ treeItemName + suffix);
				dialogChanged();
			}
		});
		tree.setVisible(false);
	}
	
	initialize();
	dialogChanged();
	setControl(container);
}
 
Example 14
Project: convertigo-eclipse   File: ObjectInfoWizardPage.java   View Source Code Vote up 4 votes
public void createControl(Composite parent) {
	container = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	container.setLayout(layout);
	layout.numColumns = 2;
	layout.verticalSpacing = 9;

	Label label = new Label(container, SWT.NULL);
	label.setText("&Name:");

	beanName = new Text(container, SWT.BORDER | SWT.SINGLE);
	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
	beanName.setLayoutData(gd);
	beanName.addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			dialogChanged();
		}
	});
	
	if (parentObject instanceof CouchDbConnector || parentObject instanceof FullSyncConnector) {
		couchVariablesComposite = new CouchVariablesComposite(container, SWT.V_SCROLL);
		
		GridData couchVarData = new GridData(GridData.FILL_BOTH);
		couchVarData.horizontalSpan = 2;
		
		couchVariablesComposite.setLayoutData(couchVarData);
		
	} else {
		tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
		tree.setHeaderVisible(false);
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
		gridData.verticalSpan = 20;
		gridData.horizontalSpan = 2;
		tree.setLayoutData(gridData);		
		tree.addListener(SWT.Selection, new Listener() {
			public void handleEvent(final Event event) {
				TreeItem item = (TreeItem) event.item;
				treeItemName = item.getText();
				String suffix = getBeanName().endsWith(ScHandlerStatement.EVENT_ENTRY_HANDLER) ? 
						ScHandlerStatement.EVENT_ENTRY_HANDLER:
							getBeanName().endsWith(ScHandlerStatement.EVENT_EXIT_HANDLER) ?
									ScHandlerStatement.EVENT_EXIT_HANDLER : "";
				setBeanName("on"+ treeItemName + suffix);
				dialogChanged();
			}
		});
		tree.setVisible(false);
	}
	
	initialize();
	dialogChanged();
	setControl(container);
}
 
Example 15
Project: hybris-commerce-eclipse-plugin   File: TSVEditor.java   View Source Code 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 16
Project: hadoop-2.6.0-cdh5.4.3   File: ServerView.java   View Source Code 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 17
Project: hadoop-EAR   File: ServerView.java   View Source Code 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 18
Project: SMVHunter   File: NativeHeapPanel.java   View Source Code 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 19
Project: scouter   File: DigestTableView.java   View Source Code 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 20
Project: sophie   File: FilesTree.java   View Source Code Vote up 4 votes
/**
 * Create a new tree listing Solr config files.
 * 
 * @param composite
 *            Parent composite.
 */
public FilesTree(Composite composite) throws SophieException {
    Composite parent = new Composite(composite, SWT.NULL);
    parent.setLayout(new GridLayout(2, true));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Instantiate Tree.
    tree = new Tree(parent, SWT.BORDER);
    tree.setHeaderVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Display file in viewer when user double clicks tree item.
    tree.addListener(SWT.MouseDoubleClick, new Listener() {
        @Override
        public void handleEvent(Event event) {
            Point point = new Point(event.x, event.y);
            TreeItem item = tree.getItem(point);
            if (item != null) {
                String fullPath = Objects.toString(item.getData(), "");
                String content;
                if (StringUtils.isEmpty(fullPath)) {
                    content = "This is a directory.";
                } else {
                    try {
                        content = SolrUtils.getFileContent(fullPath);
                    } catch (SophieException e) {
                        content = "Unable to fetch content for " + fullPath + ": " + e.getMessage();
                        Sophie.log.error("Unable to fetch content for " + fullPath, e);
                    }
                }
                styledText.setText(content);
            }
        }
    });

    // Create column.
    columnName = new TreeColumn(tree, SWT.LEFT);
    columnName.setText("File Name");

    // Instantiate viewer.
    styledText = new StyledText(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    styledText.setText("No file selected.");
    styledText.setEditable(false);
    styledText.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Config files are easier to read with a monospaced font.
    Font monospaced = JFaceResources.getFont(JFaceResources.TEXT_FONT);
    styledText.setFont(monospaced);

    // Populate tree with data from Solr.
    populate();

    // Pack columns.
    columnName.pack();
}
 
Example 21
Project: hssd   File: EntryEditor.java   View Source Code 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");
}