Java Code Examples for org.eclipse.swt.widgets.Tree

The following examples show how to use org.eclipse.swt.widgets.Tree. 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: hop   Source File: TreeItemAccelerator.java    License: 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 2
/**
 *	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 3
Source Project: uima-uimaj   Source File: AbstractSection.java    License: 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 4
Source Project: birt   Source File: DeleteWarningDialog.java    License: 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 5
/**
 * 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 6
/** @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 7
Source Project: neoscada   Source File: SecurityEditor.java    License: 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 8
/**
 * 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 9
Source Project: tracecompass   Source File: ExportToTsvUtils.java    License: 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 10
/**
 * 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 11
/**
 * 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 12
Source Project: tmxeditor8   Source File: TmDbManagerDialog.java    License: 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 13
protected void removeLanguage(List<?> languages) {
	try {
		String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
		for (Object object : languages) {
			if (object instanceof Language) {
				Language lang = (Language) object;
				languageModel.removeLanguage(lang);
				LocaleService.getLanguageConfiger().deleteLanguageByCode(lang.getCode());
				String imgPath = lang.getImagePath();
				if (!imgPath.equals("")) {
					File file = new File(bundlePath + imgPath);
					if (file.exists()) {
						file.delete();
					}
				}
			}
		}
	} catch (IOException e) {
		logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger4"), e);
		e.printStackTrace();
	}
	// refresh the viewer
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}

}
 
Example 14
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 15
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 16
/**
 * Export a given items's TSV
 *
 * @param stream
 *            an output stream to write the TSV to
 * @since 1.2
 */
@VisibleForTesting
protected void exportToTsv(@Nullable OutputStream stream) {
    AbstractTmfTreeViewer statsViewer = fStatsViewer;
    if (statsViewer == null) {
        return;
    }
    Tree tree = statsViewer.getTreeViewer().getTree();
    ExportToTsvUtils.exportTreeToTsv(tree, stream);
}
 
Example 17
@Override
protected Tree getParent(SelectionEvent e) {
	// 1) Get tree column which fire this selection event
	TreeColumn treeColumn = (TreeColumn) e.getSource();
	// 2) Get the owner tree
	return treeColumn.getParent();
}
 
Example 18
@Override
protected void sort(SelectionEvent e) {
	// 1) Get tree column which fire this selection event
	TreeColumn treeColumn = (TreeColumn) e.getSource();
	// 2) Get the owner tree
	Tree tree = treeColumn.getParent();
	// 3) Modify the SWT Tree sort
	tree.setSortColumn(treeColumn);
	tree.setSortDirection(getSortDirection());
}
 
Example 19
/**
 * If the tree contains an item with the given label return it
 */
private TreeItem getTreeItem(Tree tree, String label) {
	for (TreeItem treeItem : tree.getItems()) {
		if (treeItem.getText().equals(label)) {
			return treeItem;
		}
	}
	return null;
}
 
Example 20
protected void removeLanguage(List<?> languages) {
	try {
		String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry("")).getPath();
		for (Object object : languages) {
			if (object instanceof Language) {
				Language lang = (Language) object;
				languageModel.removeLanguage(lang);
				LocaleService.getLanguageConfiger().deleteLanguageByCode(lang.getCode());
				String imgPath = lang.getImagePath();
				if (!imgPath.equals("")) {
					File file = new File(bundlePath + imgPath);
					if (file.exists()) {
						file.delete();
					}
				}
			}
		}
	} catch (IOException e) {
		logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger4"), e);
		e.printStackTrace();
	}
	// refresh the viewer
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}

}
 
Example 21
private void unSelectAllChildren(Tree tree, TreeItem treeItem) {
	Collection<TreeItem> selectedLeaves = ArrayUtil.asCollection(tree.getSelection());
	if(isColumnGroupLeaf(treeItem)){
		selectedLeaves.removeAll(ArrayUtil.asCollection(treeItem.getItems()));
	}
	tree.setSelection(selectedLeaves.toArray(new TreeItem[]{}));
	tree.showSelection();
}
 
Example 22
public BotContractInputRow addChild() {
    bot.button(Messages.addChild).click();
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            final Tree tree = inputTable().getSWTBotWidget().widget;
            treeItem = tree.getSelection()[0];
        }
    });

    return new BotContractInputRow(bot, new SWTBotTreeItem(treeItem));
}
 
Example 23
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;
}
 
Example 24
/**
 * {@inheritDoc}
 */
@Override
protected TreeViewer createTreeViewer(Composite parent, int style) {
	Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
	GridData gd= new GridData(GridData.FILL_BOTH);
	gd.heightHint= tree.getItemHeight() * 12;
	tree.setLayoutData(gd);

	final TreeViewer treeViewer= new OutlineTreeViewer(tree);

	// Hard-coded filters
	treeViewer.addFilter(new NamePatternFilter());
	treeViewer.addFilter(new MemberFilter());

	fInnerLabelProvider= new OutlineLabelProvider();
	fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
	IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager();
	if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$
		fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null));

	treeViewer.setLabelProvider(new ColoringLabelProvider(fInnerLabelProvider));

	fLexicalSortingAction= new LexicalSortingAction(treeViewer);
	fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer);
	fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer);
	fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer, getId(), getInputForCategories());

	fOutlineContentProvider= new OutlineContentProvider(false);
	treeViewer.setContentProvider(fOutlineContentProvider);
	fOutlineSorter= new OutlineSorter();
	treeViewer.setComparator(fOutlineSorter);
	treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);


	treeViewer.getTree().addKeyListener(getKeyAdapter());

	return treeViewer;
}
 
Example 25
/**
 * Marks the leaves in the tree as selected
 * @param tree containing the leaves
 * @param indexes index of the leaf in the tree
 */
protected void setSelection(Tree tree, List<Integer> indexes) {
	List<TreeItem> selectedLeaves = new ArrayList<TreeItem>();

	for (Integer leafIndex : indexes) {
		selectedLeaves.add(tree.getItem(leafIndex.intValue()));
	}
	tree.setSelection(selectedLeaves.toArray(new TreeItem[] {}));
	tree.showSelection();
}
 
Example 26
protected void addLanguage() {
	AddOrUpdateLanguageDialog dialog = new AddOrUpdateLanguageDialog(fFilteredTree.getShell(),
			AddOrUpdateLanguageDialog.DIALOG_ADD);
	dialog.setLanguageModel(languageModel);
	if (dialog.open() == IDialogConstants.OK_ID) {
		String strCode = dialog.getStrCode();
		String imagePath = dialog.getImagePath();
		String resultImagePath = "";
		if (!imagePath.equals("")) {
			File imgFile = new File(imagePath);
			if (imgFile.exists()) {
				try {
					String bundlePath = FileLocator.toFileURL(Activator.getDefault().getBundle().getEntry(""))
							.getPath();
					String rsImagePath = bundlePath + "images/lang/" + strCode + ".png";
					File rsImgFile = new File(rsImagePath);
					if (!rsImgFile.exists()) {
						rsImgFile.createNewFile();
					}
					ResourceUtils.copyFile(imgFile, rsImgFile);
				} catch (IOException e) {
					logger.error(Messages.getString("languagecode.LanguageCodesPreferencePage.logger2"), e);
					e.printStackTrace();
				}
			}
			resultImagePath = "images/lang/" + strCode + ".png";
		}
		Language language = new Language(strCode, dialog.getStrName(), resultImagePath, dialog.isBlnIsBidi());
		LocaleService.getLanguageConfiger().addLanguage(language);
		languageModel.getLanguages().add(language);
		languageModel.getLanguagesMap().put(strCode, language);
	}
	Tree tree = fFilteredTree.getViewer().getTree();
	try {
		tree.setRedraw(false);
		fFilteredTree.getViewer().refresh();
	} finally {
		tree.setRedraw(true);
	}
}
 
Example 27
Source Project: n4js   Source File: UIUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static Optional<TreeItem> getChildItem(Object parent, String text) {
	if (parent instanceof TreeItem && !((TreeItem) parent).getExpanded()) {
		((TreeItem) parent).setExpanded(true);
		waitForUiThread();
	}
	TreeItem[] currChildren = parent instanceof Tree
			? ((Tree) parent).getItems()
			: ((TreeItem) parent).getItems();
	return Stream.of(currChildren)
			.filter(child -> text.equals(child.getText()))
			.findFirst();
}
 
Example 28
Source Project: Pydev   Source File: TreeSelectionDialog.java    License: 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 29
Source Project: olca-app   Source File: JsonTreeViewer.java    License: 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 30
Source Project: uima-uimaj   Source File: AbstractSection.java    License: 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();
  }
}