List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.amalto.workbench.editors.DataModelMainPage.java
License:Open Source License
private void createSchemaTreeComp(Composite parent) { Composite schemaSash = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.verticalSpacing = 0;/*from w ww . jav a 2 s . c o m*/ schemaSash.setLayout(layout); schemaSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); schemaSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Composite compInfo = new Composite(schemaSash, SWT.NONE); layout = new GridLayout(); layout.verticalSpacing = 0; compInfo.setLayout(layout); compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Composite compSchemaTree = new Composite(schemaSash, SWT.NONE); GridLayout glCompSchemaTree = new GridLayout(); glCompSchemaTree.verticalSpacing = 0; glCompSchemaTree.marginWidth = 0; glCompSchemaTree.marginHeight = 0; glCompSchemaTree.horizontalSpacing = 0; compSchemaTree.setLayout(glCompSchemaTree); compSchemaTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); compSchemaTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Label title = new Label(compInfo, SWT.VERTICAL); title.setText(Messages.DataModelEntities); title.setFont(FontUtils.getBoldFont(title.getFont())); Color blue = new Color(compInfo.getDisplay(), 0, 0, 255); title.setForeground(blue); title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); ToolBar toolBarSchemaTree = createToolbarOnComposite(compSchemaTree); viewer = new TreeViewer(compSchemaTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); addToolItems2SchemaTreeToolBar(toolBarSchemaTree); toolBarSchemaTree.pack(); drillDownAdapter = new DrillDownAdapter(viewer); schemaTreeContentProvider = new SchemaTreeContentProvider(this.getSite(), xsdSchema); viewer.setContentProvider(schemaTreeContentProvider); viewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new SchemaNameFilter(), new SchemaUniqueElementFilter() }); viewer.getTree().addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { isSchemaSelected = true; } }); viewer.setLabelProvider(new XSDTreeLabelProvider()); viewer.setSorter(schemaTreeSorter); viewer.setInput(this.getSite());// getViewSite()); viewer.getTree().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (isReadOnly()) { return; } IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection()); // delete if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) { if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) { deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer); deleteConceptWrapAction.run(); } else { MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry); } } } }); viewer.setComparer(new ElementComparer()); }
From source file:com.amalto.workbench.editors.DataModelMainPage.java
License:Open Source License
private void createTypeTreeComp(Composite parent) { Composite TypeSash = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.verticalSpacing = 0;//from w ww. j a v a 2 s . c om TypeSash.setLayout(layout); TypeSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); TypeSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Composite compInfo = new Composite(TypeSash, SWT.NONE); layout = new GridLayout(); layout.verticalSpacing = 0; compInfo.setLayout(layout); compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Composite compTypeTree = new Composite(TypeSash, SWT.NONE); GridLayout glCompTypeTree = new GridLayout(); glCompTypeTree.verticalSpacing = 0; glCompTypeTree.marginWidth = 0; glCompTypeTree.marginHeight = 0; glCompTypeTree.horizontalSpacing = 0; compTypeTree.setLayout(glCompTypeTree); compTypeTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); compTypeTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); Label title = new Label(compInfo, SWT.VERTICAL); title.setText(Messages.DataModelTypes); title.setFont(FontUtils.getBoldFont(title.getFont())); Color blue = new Color(compInfo.getDisplay(), 0, 0, 255); title.setForeground(blue); title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE)); ToolBar toolBarTypeTree = createToolbarOnComposite(compTypeTree); typesViewer = new TreeViewer(compTypeTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); typesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); addToolItems2TypeTreeToolBar(toolBarTypeTree); toolBarTypeTree.pack(); typesTreeContentProvider = new TypesTreeContentProvider(this.getSite(), xsdSchema); typesViewer.setContentProvider(typesTreeContentProvider); typesViewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new TypeNameFilter() }); typesViewer.getTree().addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { isSchemaSelected = false; } }); typesViewer.setLabelProvider(new TypesLabelProvider()); typesViewer.setSorter(typeTreeSorter); typesViewer.setInput(this.getSite());// getViewSite()); typesViewer.getTree().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (isReadOnly()) { return; } IStructuredSelection selection = ((IStructuredSelection) typesViewer.getSelection()); // delete if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) { deleteConceptWrapAction.regisExtraClassToDel(XSDComplexTypeDefinitionImpl.class); if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) { deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer); deleteConceptWrapAction.run(); } else { deleteConceptWrapAction.clearExtraClassToDel(); deleteConceptWrapAction.regisExtraClassToDel(XSDSimpleTypeDefinitionImpl.class); if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) { deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer); deleteConceptWrapAction.run(); } else { MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry); } } } } }); }
From source file:com.amalto.workbench.editors.MenuMainPage.java
License:Open Source License
@Override protected void createCharacteristicsContent(FormToolkit toolkit, Composite mainComposite) { try {// w ww . ja v a 2 s .co m // description Label descriptionLabel = toolkit.createLabel(mainComposite, Messages.MenuMainPage_Description, SWT.NULL); descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1)); descriptionText = toolkit.createText(mainComposite, "", SWT.BORDER);//$NON-NLS-1$ descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); ((GridData) descriptionText.getLayoutData()).minimumHeight = 30; descriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (refreshing) { return; } markDirtyWithoutCommit(); } }); // Util.createCompDropTarget(descriptionText); // make the Page window a DropTarget - we need to dispose it windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE); windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() }); windowTarget.addDropListener(new DCDropTargetListener()); Composite composite = toolkit.createComposite(mainComposite, SWT.BORDER); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); composite.setLayout(new GridLayout(1, false)); menuTree = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); menuTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); ((GridData) menuTree.getControl().getLayoutData()).heightHint = 150; menuTree.setContentProvider(new ITreeContentProvider() { public void dispose() { } public Object[] getChildren(Object parentElement) { if (parentElement instanceof TreeEntry) { WSMenuEntry wsEntry = ((TreeEntry) parentElement).getWSMenuEntry(); if (wsEntry.getSubMenus() != null) { TreeEntry[] children = new TreeEntry[wsEntry.getSubMenus().size()]; for (int i = 0; i < wsEntry.getSubMenus().size(); i++) { children[i] = new TreeEntry((TreeEntry) parentElement, wsEntry.getSubMenus().get(i)); } return children; } return null; } if (parentElement instanceof WSMenu) { // the root java.util.List<WSMenuEntry> menuEntries = ((WSMenu) parentElement).getMenuEntries(); if (menuEntries != null) { TreeEntry[] children = new TreeEntry[menuEntries.size()]; for (int i = 0; i < menuEntries.size(); i++) { children[i] = new TreeEntry(null, menuEntries.get(i)); } return children; } return null; } return null; // ??!!? } public Object[] getElements(Object inputElement) { return getChildren(inputElement); } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { return ((getChildren(element) == null) || (getChildren(element).length > 0)); } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); menuTree.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { WSMenuEntry wsMenuEntry = ((TreeEntry) element).getWSMenuEntry(); StringBuffer label = new StringBuffer(wsMenuEntry.getId() + " - ");//$NON-NLS-1$ for (WSMenuMenuEntriesDescriptions description : wsMenuEntry.getDescriptions()) { label.append("[").append(description.getLanguage()).append(": ")//$NON-NLS-1$//$NON-NLS-2$ .append(description.getLabel()).append("] ");//$NON-NLS-1$ } if (label.length() > 200) { return label.substring(0, 197) + "..."; //$NON-NLS-1$ } return label.toString(); } @Override public Image getImage(Object element) { return ImageCache.getCreatedImage(EImage.MENU.getPath()); } }); menuTreeMgr = new MenuManager(); menuTreeMgr.setRemoveAllWhenShown(true); menuTreeMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { IStructuredSelection selection = ((IStructuredSelection) menuTree.getSelection()); if ((selection == null) || (selection.getFirstElement() == null)) { manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); return; } // TreeEntry entry = (TreeEntry)selection.getFirstElement(); menuTreeMgr.add(new TreeEntryEditAction(menuTree)); menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_BEFORE)); menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_AFTER)); menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_UNDER)); menuTreeMgr.add(new TreeEntryDeleteAction(menuTree)); menuTreeMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } }); menuTree.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { (new TreeEntryEditAction(menuTree)).run(); } }); Menu menu = menuTreeMgr.createContextMenu(menuTree.getControl()); menuTree.getControl().setMenu(menu); getSite().registerContextMenu(menuTreeMgr, menuTree); refreshData(); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:com.amalto.workbench.widgets.composites.ComplexAnnotaionInfoComposite.java
License:Open Source License
protected void createTreeArea() { tvInfos = new TreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION); Tree tree = tvInfos.getTree();//ww w . jav a 2s.co m tree.setLinesVisible(true); tree.setHeaderVisible(true); final GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true); gd_tree.heightHint = 120; gd_tree.minimumHeight = 80; tree.setLayoutData(gd_tree); tvInfos.setContentProvider(new ListContentProvider()); tvInfos.setLabelProvider(getLabelProviderForViewer()); tvInfos.setColumnProperties(getColumnProperties()); tvInfos.setCellEditors(getCellEditors()); tvInfos.setCellModifier(getCellModifier()); tvInfos.setInput(getInfos()); fillColumnsInTree(tree); }
From source file:com.amalto.workbench.widgets.composites.ListStringContentsComposite.java
License:Open Source License
public ListStringContentsComposite(Composite parent, int style, Object[] initParas, BasePropertySection section) {/*from ww w.j a v a2 s . c om*/ super(parent, style); this.section = section; initParas(initParas); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; setLayout(gridLayout); createCandidateInfoUIArea(parent); btnAdd = new Button(this, SWT.NONE); btnAdd.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath())); btnAdd.setToolTipText(Messages._Add); tvInfos = new TreeViewer(this, SWT.FULL_SELECTION | SWT.BORDER); Tree tree = tvInfos.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3)); tvInfos.setContentProvider(new ListContentProvider()); tvInfos.setLabelProvider(new ListStringLabelProvider()); tvInfos.setInput(infos); final TreeColumn colInfo = new TreeColumn(tree, SWT.NONE); colInfo.setWidth(300); colInfo.setText(getInfoColTitle()); btnUp = new Button(this, SWT.NONE); btnUp.setImage(ImageCache.getCreatedImage(EImage.PREV_NAV.getPath())); btnUp.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); btnUp.setToolTipText(Messages._Up); btnDown = new Button(this, SWT.NONE); btnDown.setImage(ImageCache.getCreatedImage(EImage.NEXT_NAV.getPath())); final GridData gd_btnDown = new GridData(SWT.CENTER, SWT.TOP, false, false); btnDown.setLayoutData(gd_btnDown); btnDown.setToolTipText(Messages._Down); btnRemove = new Button(this, SWT.NONE); btnRemove.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false)); btnRemove.setImage(ImageCache.getCreatedImage(EImage.DELETE_OBJ.getPath())); btnRemove.setToolTipText(Messages._Del); // createExtentUIArea(parent); initUIListeners(); }
From source file:com.amalto.workbench.widgets.composites.property.PropertyComposite.java
License:Open Source License
@SuppressWarnings("unchecked") public PropertyComposite(Composite parent, int style, String title, String label, String propNameColLabel, String propValueColLabel, BasePropertySection section) { super(parent, style); final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 0;/*ww w . j a v a2 s. c om*/ gridLayout.horizontalSpacing = 0; gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.numColumns = 2; setLayout(gridLayout); final Label lblTitle = new Label(this, SWT.NONE); final GridData gd_lblTitle = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); lblTitle.setLayoutData(gd_lblTitle); lblTitle.setText((title == null ? "" : title));//$NON-NLS-1$ hideEmptyLabel(lblTitle); final Label lblLabel = new Label(this, SWT.NONE); lblLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); lblLabel.setText((label == null ? "" : label));//$NON-NLS-1$ hideEmptyLabel(lblLabel); tvProperty = new TreeViewer(this, SWT.FULL_SELECTION | SWT.BORDER); propModifier = new PropertyModifier(tvProperty); propModifier.setSection(section); tvProperty.setContentProvider(new ListContentProvider()); tvProperty.setLabelProvider(new CommonTableLabelProvider<IPropertySource<?>>( new ColumnTextExtractor[] { new ColumnTextExtractor<IPropertySource<?>>("getPropertyName"), //$NON-NLS-1$ new ColumnTextExtractor<IPropertySource<?>>("getPropertyValueLabel") }));//$NON-NLS-1$ tvProperty.setSorter(new PropertySourceSorter()); tvProperty.setCellEditors(new CellEditor[2]); tvProperty.setColumnProperties(PropertyModifier.COLPROPS); tvProperty.setCellModifier(propModifier); tvProperty.setInput(propertySources); Tree tree = tvProperty.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final TreeColumn colName = new TreeColumn(tree, SWT.NONE); colName.setWidth(150); colName.setText((propNameColLabel == null ? "name" : propNameColLabel));//$NON-NLS-1$ final TreeColumn colValue = new TreeColumn(tree, SWT.NONE); colValue.setWidth(330); colValue.setText((propValueColLabel == null ? "value" : propValueColLabel));//$NON-NLS-1$ }
From source file:com.amalto.workbench.widgets.composites.SelectXPathComposite.java
License:Open Source License
public SelectXPathComposite(Composite parent, int style, IAllDataModelHolder allDataModelHolder, String defaultSelectedDataModel, String conceptName, boolean isAbsolutePath, IXPathSelectionFilter filter) {/*from w w w. j a v a2 s .co m*/ super(parent, style); this.allDataModelHolder = allDataModelHolder; this.defaultSelectedDataModel = defaultSelectedDataModel; this.conceptName = conceptName; this.isAbsolutePath = isAbsolutePath; this.xpathSelectionFilter = filter; final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; setLayout(gridLayout); final Label lblDataModels = new Label(this, SWT.NONE); lblDataModels.setText(Messages.SelectXPathComposite_DataModels); comboDataModels = new Combo(this, SWT.READ_ONLY); comboDataModels.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Label lblXPath = new Label(this, SWT.NONE); lblXPath.setText(Messages.SelectXPathComposite_XPath); txtXPath = new Text(this, SWT.READ_ONLY | SWT.BORDER); final GridData gd_txtXPath = new GridData(SWT.FILL, SWT.CENTER, true, false); txtXPath.setLayoutData(gd_txtXPath); final Label lblFilter = new Label(this, SWT.NONE); lblFilter.setText(Messages.SelectXPathComposite_Filters); txtFilter = new Text(this, SWT.BORDER); final GridData gd_txtFilter = new GridData(SWT.FILL, SWT.CENTER, true, false); txtFilter.setLayoutData(gd_txtFilter); tvXPath = new TreeViewer(this, SWT.BORDER); tvXPath.setContentProvider(new XPathContentProvider()); tvXPath.setLabelProvider(new XSDTreeLabelProvider(xpathSelectionFilter)); xpathTopElementNameFilter = new SchemaNameFilter(new SchemaElementNameFilterDes(true, "*")); //$NON-NLS-1$ tvXPath.setFilters(new ViewerFilter[] { xpathTopElementNameFilter }); Tree tree = tvXPath.getTree(); final GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); tree.setLayoutData(gd_tree); // initUIListeners(); initUIContents(); }
From source file:com.amazonaws.eclipse.codedeploy.explorer.editor.table.DeploymentsTableView.java
License:Apache License
private TreeViewer createControls(FormToolkit toolkit) { GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginWidth = 0;// w ww . j av a 2 s . c o m gridLayout.marginHeight = 0; setLayout(gridLayout); Composite sectionComp = toolkit.createComposite(this, SWT.None); sectionComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); sectionComp.setLayout(new GridLayout(1, false)); Composite headingComp = toolkit.createComposite(sectionComp, SWT.None); headingComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); headingComp.setLayout(new GridLayout()); tableTitleLabel = toolkit.createLabel(headingComp, "Deployments"); tableTitleLabel.setFont(JFaceResources.getHeaderFont()); tableTitleLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); Composite tableHolder = toolkit.createComposite(sectionComp, SWT.None); tableHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); FillLayout layout = new FillLayout(); layout.marginHeight = 0; layout.marginWidth = 10; layout.type = SWT.VERTICAL; tableHolder.setLayout(layout); Composite tableComp = toolkit.createComposite(tableHolder, SWT.None); final TreeColumnLayout tableColumnLayout = new TreeColumnLayout(); tableComp.setLayout(tableColumnLayout); final TreeViewer viewer = new TreeViewer(tableComp, SWT.BORDER | SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL); viewer.getTree().setLinesVisible(true); viewer.getTree().setHeaderVisible(true); viewer.setUseHashlookup(true); viewer.setLabelProvider(new DeploymentsTableViewLabelProvider()); viewer.setContentProvider(new DeploymentsTableViewContentProvider(this.viewer, this.contentCache)); Tree tree = viewer.getTree(); createColumns(tableColumnLayout, tree); viewer.setInput(loadingContentProvider); updateRefreshProgress(0, false); // Async load top-level data new Thread(new Runnable() { public void run() { Display.getDefault().syncExec(new Runnable() { public void run() { // Preserve the current column widths int[] colWidth = new int[viewer.getTree().getColumns().length]; int i = 0; for (TreeColumn col : viewer.getTree().getColumns()) { colWidth[i++] = col.getWidth(); } i = 0; for (TreeColumn col : viewer.getTree().getColumns()) { tableColumnLayout.setColumnData(col, new ColumnPixelData(colWidth[i])); } } }); // Cache the children of all the top-level elements before // updating the tree view loadAllTopLevelElements(); Display.getDefault().syncExec(new Runnable() { public void run() { viewer.setInput(contentCache); } }); } }).start(); return viewer; }
From source file:com.amazonaws.eclipse.dynamodb.testtool.TestToolVersionTable.java
License:Apache License
/** * Create the actual table view displaying the list of selectable test * tool versions.// ww w .j av a 2 s.c o m */ private void createViewer() { // Grab any leftover space in the middle. Composite wrapper = new Composite(this, SWT.NONE); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = 200; wrapper.setLayoutData(data); TreeColumnLayout layout = new TreeColumnLayout(); wrapper.setLayout(layout); viewer = new TreeViewer(wrapper, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE); TestToolVersionProvider provider = new TestToolVersionProvider(); viewer.setContentProvider(provider); viewer.setLabelProvider(provider); viewer.setComparator(new VersionComparator()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { onSelectionChanged(); } }); Tree tree = viewer.getTree(); tree.setHeaderVisible(true); TreeColumn versionColumn = new TreeColumn(tree, SWT.LEFT); versionColumn.setText("Version"); layout.setColumnData(versionColumn, new ColumnWeightData(75)); TreeColumn installColumn = new TreeColumn(tree, SWT.CENTER); installColumn.setText("Installed?"); layout.setColumnData(installColumn, new ColumnWeightData(25)); }
From source file:com.amazonaws.eclipse.ec2.ui.SelectionTable.java
License:Apache License
/** * Creates and configures the actual tree control. */// w ww . j av a 2 s .com protected void createControl() { TreeColumnLayout treeColumnLayout = new TreeColumnLayout(); setLayout(treeColumnLayout); int style = SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER; if (allowMultipleSelections) { style |= SWT.MULTI; } else { style |= SWT.SINGLE; } if (virtualTable) { style |= SWT.VIRTUAL; } viewer = new TreeViewer(this, style); if (virtualTable) viewer.setUseHashlookup(true); Tree tree = viewer.getTree(); tree.setLinesVisible(true); tree.setHeaderVisible(true); createColumns(); makeActions(); hookContextMenu(); }