org.eclipse.swt.widgets.Tree Java Examples

The following examples show how to use org.eclipse.swt.widgets.Tree. 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: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns true if the specified project can be found in the 'Package Explorer' or 'Project View',
 * otherwise returns false. Throws a WidgetNotFoundException exception if the 'Package Explorer'
 * or 'Project Explorer' view cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to be found.
 * @return if the project exists
 */
public static boolean doesProjectExist(final SWTWorkbenchBot bot, String projectName) {
  SWTBotView explorer = getPackageExplorer(bot);
  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  SWTBotTreeItem[] allItems = new SWTBotTree(explorerTree).getAllItems();
  for (int i = 0; i < allItems.length; i++) {
    if (allItems[i].getText().equals(projectName)) {
      return true;
    }
  }
  return false;
}
 
Example #2
Source File: AbstractInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Selects the first element in the tree which
 * matches the current filter pattern.
 */
protected void selectFirstMatch() {
	Object selectedElement= fTreeViewer.testFindItem(fInitiallySelectedType);
	TreeItem element;
	final Tree tree= fTreeViewer.getTree();
	if (selectedElement instanceof TreeItem)
		element= findElement(new TreeItem[] { (TreeItem)selectedElement });
	else
		element= findElement(tree.getItems());

	if (element != null) {
		tree.setSelection(element);
		tree.showItem(element);
	} else
		fTreeViewer.setSelection(StructuredSelection.EMPTY);
}
 
Example #3
Source File: ExportToTsvUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Export content of a tree to TSV file
 * @param tree
 *              the tree to export
 * @param stream
 *              the output stream
 */
public static void exportTreeToTsv(@Nullable Tree tree, @Nullable OutputStream stream) {
    if (tree == null || stream == null) {
        return;
    }
    try (PrintWriter pw = new PrintWriter(stream)) {
        int size = tree.getItemCount();
        List<String> columns = new ArrayList<>();
        for (int i = 0; i < tree.getColumnCount(); i++) {
            String valueOf = String.valueOf(tree.getColumn(i).getText());
            if (valueOf.isEmpty() && i == tree.getColumnCount() - 1) {
                // Linux "feature", an invisible column is added at the end
                // with gtk2
                break;
            }
            columns.add(valueOf);
        }
        String join = Joiner.on('\t').skipNulls().join(columns);
        pw.println(join);
        for (int i = 0; i < size; i++) {
            TreeItem item = tree.getItem(i);
            printItem(pw, columns, item);
        }
    }
}
 
Example #4
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the specified project. Throws a WidgetNotFoundException if the 'Package Explorer' or
 * 'Project Explorer' view cannot be found or if the specified project cannot be found.
 *
 * @param bot The SWTWorkbenchBot.
 * @param projectName The name of the project to select.
 * @return the tree
 */
public static SWTBotTreeItem selectProject(final SWTWorkbenchBot bot, String projectName) {
  /*
   * Choose either the Package Explorer View or the Project Explorer view. Eclipse 3.3 and 3.4
   * start with the Java Perspective, which has the Package Explorer View open by default, whereas
   * Eclipse 3.5 starts with the Resource Perspective, which has the Project Explorer View open.
   */
  SWTBotView explorer = getPackageExplorer(bot);
  for (SWTBotView view : bot.views()) {
    if (view.getTitle().equals("Package Explorer")
        || view.getTitle().equals("Project Explorer")) {
      explorer = view;
      break;
    }
  }

  if (explorer == null) {
    throw new WidgetNotFoundException(
        "Could not find the 'Package Explorer' or 'Project Explorer' view.");
  }

  // Select the root of the project tree in the explorer view
  Widget explorerWidget = explorer.getWidget();
  Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget);
  return new SWTBotTree(explorerTree).getTreeItem(projectName).select();
}
 
Example #5
Source File: DeleteWarningDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the dialog area.
 * 
 * @param parent
 *            the parent
 */
protected Control createDialogArea( Composite parent )
{
	Composite composite = (Composite) super.createDialogArea( parent );

	new Label( composite, SWT.NONE ).setText( preString );
	Tree tree = new Tree( composite, SWT.NONE );
	tree.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	for ( Iterator itor = refrenceList.iterator( ); itor.hasNext( ); )
	{
		Object reference = itor.next( );
		TreeItem item = new TreeItem( tree, SWT.NONE );
		item.setText( DEUtil.getDisplayLabel( reference ) );
		item.setImage( ReportPlatformUIImages.getImage( reference ) );
	}
	new Label( composite, SWT.NONE ).setText( sufString );
	
	UIUtil.bindHelp( parent,IHelpContextIds.DELETE_WARNING_DIALOG_ID ); 

	return composite;
}
 
Example #6
Source File: SecurityEditor.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
protected void createColumns ( final Tree tree )
{
    final TreeColumn typeFilterColumn = new TreeColumn ( tree, SWT.NONE );
    typeFilterColumn.setText ( getString ( "_UI_TypeFilterColumn_label" ) ); //$NON-NLS-1$
    typeFilterColumn.setResizable ( true );
    typeFilterColumn.setWidth ( 200 );

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

    final TreeColumn actionFilterColumn = new TreeColumn ( tree, SWT.NONE );
    actionFilterColumn.setText ( getString ( "_UI_ActionFilterColumn_label" ) ); //$NON-NLS-1$
    actionFilterColumn.setResizable ( true );
    actionFilterColumn.setWidth ( 200 );
}
 
Example #7
Source File: ChangeTypeWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Tree-viewer that shows the allowable types in a tree view.
 * @param parent the parent
 */
private void addTreeComponent(Composite parent) {
	fTreeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.grabExcessHorizontalSpace= true;
	gd.grabExcessVerticalSpace= true;
	Tree tree= fTreeViewer.getTree();
	Dialog.applyDialogFont(tree);
	gd.heightHint= tree.getItemHeight() * 12;
	tree.setLayoutData(gd);

	fTreeViewer.setContentProvider(new ChangeTypeContentProvider(((ChangeTypeRefactoring)getRefactoring())));
	fLabelProvider= new ChangeTypeLabelProvider();
	fTreeViewer.setLabelProvider(fLabelProvider);
	ISelectionChangedListener listener= new ISelectionChangedListener(){
		public void selectionChanged(SelectionChangedEvent event) {
			IStructuredSelection selection= (IStructuredSelection)event.getSelection();
			typeSelected((ITypeBinding)selection.getFirstElement());
		}
	};
	fTreeViewer.addSelectionChangedListener(listener);
	fTreeViewer.setInput(new ChangeTypeContentProvider.RootType(getGeneralizeTypeRefactoring().getOriginalType()));
	fTreeViewer.expandToLevel(10);
}
 
Example #8
Source File: ExternalLibraryPreferencePage.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/** @return either a URI of a node_modules folder or a external N4JSProject instance */
private Object getSelectedItem() {
	final Tree tree = viewer.getTree();
	final TreeItem[] selection = tree.getSelection();
	if (!Arrays2.isEmpty(selection) && 1 == selection.length) {
		Object data = selection[0].getData();

		if (data instanceof SafeURI<?>) {
			SafeURI<?> uri = (SafeURI<?>) data;
			if (ExternalLibraryPreferenceModel.isNodeModulesLocation(uri)) {
				return data;
			}
		}

		if (data instanceof IN4JSProject) {
			return data;
		}
	}
	return null;
}
 
Example #9
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * New tree.
 *
 * @param parent the parent
 * @param style          SWT.SINGLE SWT.MULTI SWT.CHECK SWT.FULL_SELECTION
 * @return the TableTree
 */
protected Tree newTree(Composite parent, int style) {
  Tree tt = new Tree(parent, style);
  tt.setLayoutData(new GridData(GridData.FILL_BOTH));
  toolkit.adapt(tt, true, true);
  tt.addListener(SWT.Selection, this);
  tt.addListener(SWT.KeyUp, this); // for delete key
  tt.addListener(SWT.MouseDoubleClick, this); // for edit
  tt.addListener(SWT.Expand, this);
  tt.addListener(SWT.Collapse, this);
 
  // Make the TableTree's border visible since TableTree is NOT a widget supported
  // by FormToolkit.  Needed by RedHat Linux
  tt.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
  return tt;
}
 
Example #10
Source File: CheckboxTreeAndListGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *	Creates this group's tree viewer.
 * @param parent parent composite
 * @param width the width
 * @param height the height
 */
protected void createTreeViewer(Composite parent, int width, int height) {
	Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER);
	GridData data= new GridData(GridData.FILL_BOTH);
	data.widthHint= width;
	data.heightHint= height;
	tree.setLayoutData(data);

	fTreeViewer= new CheckboxTreeViewer(tree);
	fTreeViewer.setUseHashlookup(true);
	fTreeViewer.setContentProvider(fTreeContentProvider);
	fTreeViewer.setLabelProvider(fTreeLabelProvider);
	fTreeViewer.addTreeListener(this);
	fTreeViewer.addCheckStateListener(this);
	fTreeViewer.addSelectionChangedListener(this);
}
 
Example #11
Source File: TreeItemAccelerator.java    From hop with Apache License 2.0 6 votes vote down vote up
public static final void addDoubleClick( final TreeItem treeItem, final IDoubleClick doubleClick ) {
  final String[] path1 = ConstUi.getTreeStrings( treeItem );
  final Tree tree = treeItem.getParent();

  if ( doubleClick != null ) {
    final SelectionAdapter selectionAdapter = new SelectionAdapter() {
      public void widgetDefaultSelected( SelectionEvent selectionEvent ) {
        TreeItem[] items = tree.getSelection();
        for ( int i = 0; i < items.length; i++ ) {
          String[] path2 = ConstUi.getTreeStrings( items[ i ] );
          if ( equalPaths( path1, path2 ) ) {
            doubleClick.action( treeItem );
          }
        }
      }
    };
    tree.addSelectionListener( selectionAdapter );

    // Clean up when we do a refresh too.
    treeItem.addDisposeListener( new DisposeListener() {
      public void widgetDisposed( DisposeEvent disposeEvent ) {
        tree.removeSelectionListener( selectionAdapter );
      }
    } );
  }
}
 
Example #12
Source File: JsonTreeViewer.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected TreeViewer createViewer(Composite parent) {
	TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.NO_FOCUS | SWT.HIDE_SELECTION | SWT.BORDER);
	viewer.setContentProvider(new ContentProvider());
	Tree tree = viewer.getTree();
	if (viewerParameters[0] == Site.LOCAL)
		tree.getVerticalBar().setVisible(false);
	UI.gridData(tree, true, true);
	viewer.addDoubleClickListener((e) -> onDoubleClick(e));
	return viewer;
}
 
Example #13
Source File: RenameResourceAndCloseEditorAction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
Composite createParent() {
	Tree tree = getTree();
	Composite result = new Composite(tree, SWT.NONE);
	TreeItem[] selectedItems = tree.getSelection();
	treeEditor.horizontalAlignment = SWT.LEFT;
	treeEditor.grabHorizontal = true;
	treeEditor.setEditor(result, selectedItems[0]);
	return result;
}
 
Example #14
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Pack tree.
 *
 * @param p_tree the tree
 */
public void packTree(Tree p_tree) {
  TreeColumn[] columns = p_tree.getColumns();
  for (int i = 0; i < columns.length; i++) {
    columns[i].pack();
  }
}
 
Example #15
Source File: TermDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 初始化树右键菜单 ;
 */
private void initTreePopMenu() {
	MenuManager menuManager = new MenuManager("");
	menuManager.add(new Action(Messages.getString("dialog.TermDbManagerDialog.deleteAction")) {
		@Override
		public void run() {
			ISelection selection = getTreeViewer().getSelection();
			if (selection.isEmpty()) {
				return;
			}
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
			Object obj = structuredSelection.getFirstElement();
			if (obj instanceof DatabaseModelBean) {
				List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
				configer.deleteServerById(((DatabaseModelBean) obj).getId());
				int i = currDbTypeServers.indexOf(obj);
				currDbTypeServers.remove(i);
				getTreeViewer().refresh();
				// selectSaveItem();
				// setLastSelectedServer(null);

				if (currDbTypeServers.size() != 0) {
					if (i > currDbTypeServers.size() - 1) {
						setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
					} else {
						setLastSelectedServer(currDbTypeServers.get(i).getId());
					}
					initUI(false);
				} else {
					setLastSelectedServer(null);
					initUI(true);
				}
				selectSaveItem();

			}
		}
	});
	Tree tree = treeViewer.getTree();
	this.treePopMenu = menuManager.createContextMenu(tree);
}
 
Example #16
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected void updateSelectionIfNothingSelected(Tree tree) {
    TreeItem[] sel = tree.getSelection();
    if (sel == null || sel.length == 0) {
        TreeItem[] items = tree.getItems();
        if (items != null && items.length > 0) {
            tree.setSelection(items[0]);
        }
    }
}
 
Example #17
Source File: M2DocFileSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    fileText = createFilePathComposite(container, defaultFileName);

    final TreeViewer containerTreeViewer = new TreeViewer(container, SWT.BORDER);
    Tree tree = containerTreeViewer.getTree();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    tree.setLayoutData(gdTable);
    containerTreeViewer.setContentProvider(new WorkbenchContentProvider() {
        @Override
        public Object[] getChildren(Object element) {
            final List<Object> res = new ArrayList<>();
            for (Object obj : super.getChildren(element)) {
                if (obj instanceof IContainer
                    || (obj instanceof IFile && fileExtension.equals(((IFile) obj).getFileExtension()))) {
                    res.add(obj);
                }
            }
            return res.toArray();
        }
    });
    containerTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
    containerTreeViewer.addSelectionChangedListener(new ContainerSelectionChangedListener());
    containerTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (defaultFileName != null && !defaultFileName.isEmpty()) {
        final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(defaultFileName));
        containerTreeViewer.setSelection(new StructuredSelection(file));
    }

    return container;
}
 
Example #18
Source File: ColumnChooserDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void selectAllChildren(Tree tree, TreeItem treeItem) {
	Collection<TreeItem> selectedLeaves = ArrayUtil.asCollection(tree.getSelection());
	if(isColumnGroupLeaf(treeItem)){
		selectedLeaves.addAll(ArrayUtil.asCollection(treeItem.getItems()));
	}
	tree.setSelection(selectedLeaves.toArray(new TreeItem[]{}));
	tree.showSelection();
}
 
Example #19
Source File: TmDbManagerDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 初始化树右键菜单 ;
 */
private void initTreePopMenu() {
	MenuManager menuManager = new MenuManager("");
	menuManager.add(new Action(Messages.getString("dialog.TmDbManagerDialog.deleteAction")) {
		@Override
		public void run() {
			ISelection selection = getTreeViewer().getSelection();
			if (selection.isEmpty()) {
				return;
			}
			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
			Object obj = structuredSelection.getFirstElement();
			if (obj instanceof DatabaseModelBean) {
				List<DatabaseModelBean> currDbTypeServers = treeInputMap.get(currDbType);
				configer.deleteServerById(((DatabaseModelBean) obj).getId());
				int i = currDbTypeServers.indexOf(obj);
				currDbTypeServers.remove(i);
				getTreeViewer().refresh();
				// selectSaveItem();
				// setLastSelectedServer(null);

				if (currDbTypeServers.size() != 0) {
					if (i > currDbTypeServers.size() - 1) {
						setLastSelectedServer(currDbTypeServers.get(i - 1).getId());
					} else {
						setLastSelectedServer(currDbTypeServers.get(i).getId());
					}
					initUI(false);
				} else {
					setLastSelectedServer(null);
					initUI(true);
				}
				selectSaveItem();

			}
		}
	});
	Tree tree = treeViewer.getTree();
	this.treePopMenu = menuManager.createContextMenu(tree);
}
 
Example #20
Source File: Actions.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a context menu with the given actions on the tree viewer.
 */
public static void bind(TreeViewer viewer, Action... actions) {
	Tree tree = viewer.getTree();
	if (tree == null)
		return;
	MenuManager menu = new MenuManager();
	for (Action action : actions)
		menu.add(action);
	tree.setMenu(menu.createContextMenu(tree));
}
 
Example #21
Source File: TreeViewerNavigator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private TreeItem[] getSiblings(TreeItem currentItem) {
	Tree tree = viewer.getTree();
	TreeItem parentItem = currentItem.getParentItem();
	if (parentItem != null)
		return parentItem.getItems();
	return tree.getItems();
}
 
Example #22
Source File: RobotTreeUtil.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
public static Vector<TreeItem> getSelectElements(Tree tree){
	Vector<TreeItem> vecTreeItem = new Vector(); 
	TreeItem[] tiRoot = tree.getItems();
	for(int i = 0;i<tiRoot.length;i++){
		getSelection(vecTreeItem,tiRoot[i]);
	}
	return vecTreeItem;
}
 
Example #23
Source File: TexlipseProjectFilesWizardPage.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create a directory tree settings box.
 * @param parent the parent container
 */
private void createTreeControl(Composite parent) {

    dirTree = new Tree(parent, SWT.SINGLE | SWT.BORDER);
    dirTree.setToolTipText(TexlipsePlugin.getResourceString("projectWizardDirTreeTooltip"));
    dirTree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    recreateSubTree();
}
 
Example #24
Source File: ProjectFileDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Add Tooltip for root TreeItem.
 */
protected void addToolTip( )
{
	final Tree tree = getTreeViewer( ).getTree( );
	tree.addMouseTrackListener( new MouseTrackAdapter( ) {

		public void mouseHover( MouseEvent event )
		{
			Widget widget = event.widget;
			if ( widget == tree )
			{
				Point pt = new Point( event.x, event.y );
				TreeItem item = tree.getItem( pt );

				if ( item == null )
				{
					tree.setToolTipText( null );
				}
				else
				{
					if ( getTreeViewer( ).getLabelProvider( ) instanceof FileLabelProvider )
					{
						tree.setToolTipText( ( (FileLabelProvider) getTreeViewer( ).getLabelProvider( ) ).getToolTip( item.getData( ) ) );
					}
					else
					{
						tree.setToolTipText( null );
					}
				}
			}
		}
	} );
	refreshRoot( );
}
 
Example #25
Source File: TreeMemory.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Expand of collapse all TreeItems in the complete tree based on the values stored in memory.
 *
 * @param tree
 *          The tree to format.
 */
public static void setExpandedFromMemory( Tree tree, String treeName ) {
  TreeItem[] items = tree.getItems();
  for ( int i = 0; i < items.length; i++ ) {
    setExpandedFromMemory( tree, treeName, items[i] );
  }
}
 
Example #26
Source File: SelectVisibleColumnDialog.java    From logbook with MIT License 5 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    this.shell = new Shell(this.getParent(), SWT.SHELL_TRIM | SWT.PRIMARY_MODAL);
    this.shell.setSize(300, 275);
    this.shell.setText("列の表示非表示");
    this.shell.setLayout(new FillLayout(SWT.HORIZONTAL));

    // ヘッダー
    String[] header = Stream.of(this.table.getColumns()).map(c -> c.getText()).toArray(String[]::new);
    // カラム設定を取得
    boolean[] visibles = AppConfig.get().getVisibleColumnMap().get(this.clazz.getName());
    if ((visibles == null) || (visibles.length != header.length)) {
        visibles = new boolean[header.length];
        Arrays.fill(visibles, true);
        AppConfig.get().getVisibleColumnMap().put(this.clazz.getName(), visibles);
    }

    Tree tree = new Tree(this.shell, SWT.BORDER | SWT.CHECK);

    for (int i = 1; i < header.length; i++) {
        TreeItem column = new TreeItem(tree, SWT.CHECK);
        column.setText(header[i]);
        column.setChecked(visibles[i]);
        column.setExpanded(true);
    }
    this.shell.addShellListener(new TreeShellAdapter(tree, visibles));
}
 
Example #27
Source File: DBNodeUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public static void createRootTip( Tree tree, RootNode node, String metadataBidiFormatStr )
{
	tree.removeAll( );
	TreeItem root = new TreeItem( tree, SWT.NONE );
	//bidi_hcg: pass value of metadataBidiFormatStr
	root.setText( node.getDisplayName( metadataBidiFormatStr ) );
	root.setImage( node.getImage( ) );
	root.setData( node );
}
 
Example #28
Source File: AbstractSelectTreeViewer2.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the legend image for a entry's ID
 *
 * @param id
 *            the entry's unique ID
 * @return the correctly dimensioned image if there is a legend image provider
 * @since 6.0
 */
protected Image getLegendImage(@NonNull Long id) {
    /* If the image height match the row height, row height will increment */
    ILegendImageProvider2 legendImageProvider = fLegendImageProvider;
    int legendColumnIndex = fLegendIndex;
    if (legendImageProvider != null && legendColumnIndex >= 0) {
        Tree tree = getTreeViewer().getTree();
        int imageWidth = tree.getColumn(legendColumnIndex).getWidth();
        int imageHeight = tree.getItemHeight() - 1;
        if (imageHeight > 0 && imageWidth > 0) {
            return legendImageProvider.getLegendImage(imageHeight, imageWidth, id);
        }
    }
    return null;
}
 
Example #29
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 #30
Source File: ColumnChooserDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isFirstLeafSelected(Tree tree) {
	TreeItem[] selectedLeaves = tree.getSelection();
	for (int i = 0; i < selectedLeaves.length; i++) {
		if (selectedTree.indexOf(selectedLeaves[i]) == 0) {
			return true;
		}
	}
	return false;
}