public ServersViewer ( final Composite parent ) { parent.setLayout ( new FillLayout () ); this.viewer = new TreeViewer ( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ); this.contentProvider = new ObservableSetTreeContentProvider ( new ObservableFactoryImpl (), null ); this.viewer.setContentProvider ( this.contentProvider ); this.labelProvider = new ServerLabelProvider ( this.contentProvider.getKnownElements () ); this.viewer.setLabelProvider ( this.labelProvider ); this.viewer.setInput ( HivesPlugin.getDefault ().getServerManager () ); this.viewer.getControl ().addDisposeListener ( new DisposeListener () { @Override public void widgetDisposed ( final DisposeEvent e ) { handleDispose (); } } ); ColumnViewerToolTipSupport.enableFor ( this.viewer ); }
private void createColumns(TreeViewer viewer) { viewer.setColumnProperties(new String[] { "Name", "Value"}); ColumnViewerToolTipSupport.enableFor(viewer); TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.LEFT, 0); nameColumn.getColumn().setText("Name"); nameColumn.getColumn().setWidth(200); nameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { INamedNode node = (INamedNode)element; return node.getDisplayName(); } }); nameColumn.setEditingSupport(new NameEditingSupport(this)); TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.LEFT, 1); valueColumn.getColumn().setText("Value"); valueColumn.getColumn().setWidth(300); valueColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new ControlValueLabelProvider(cservice, this))); valueColumn.setEditingSupport(new ControlEditingSupport(viewer, cservice, controlViewerMode)); }
private void createColumns(final TableViewer tableViewer) { final String[] titles = { "Icon", "Name", "Small", "Medium", "Large", "Source", "Class" }; final int[] bounds = { 40, 200, 60, 60, 60, 200, 200 }; for (int i = 0; i < titles.length; i++) { final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); tableViewer.setSorter(new TableViewerSorter(titles)); viewerColumn.setLabelProvider(new TableCellLabelProvider()); final TableColumn column = viewerColumn.getColumn(); column.addSelectionListener(new ColumnSelectionListener(column, tableViewer)); column.setText(titles[i]); column.setWidth(bounds[i]); column.setResizable(true); column.setMoveable(false); } final Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE); }
private void createColumns(final TableViewer tableViewer) { final String[] titles = { "Relation", "Type", "Name" }; final int[] bounds = { 120, 100, 200 }; for (int i = 0; i < titles.length; i++) { final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); tableViewer.setSorter(new TableViewerSorter(titles)); viewerColumn.setLabelProvider(new TableCellLabelProvider()); final TableColumn column = viewerColumn.getColumn(); column.addSelectionListener(new ColumnSelectionListener(column, tableViewer)); column.setText(titles[i]); column.setWidth(bounds[i]); column.setResizable(true); column.setMoveable(false); } final Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE); // Object[] projectsToSelect = openProjects.toArray(); // IViewPart view = window.getActivePage().showView( "org.eclipse.jdt.ui.PackageExplorer" ); // view.getSite().getSelectionProvider().setSelection( new StructuredSelection( projectsToSelect ) ); }
private void createColumns(final TableViewer tableViewer) { final String[] titles = { "Class" }; final int[] bounds = { 120, 100, 200 }; for (int i = 0; i < titles.length; i++) { final TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); tableViewer.setSorter(new TableViewerSorter(titles)); viewerColumn.setLabelProvider(new TableCellLabelProvider()); final TableColumn column = viewerColumn.getColumn(); column.addSelectionListener(new ColumnSelectionListener(column, tableViewer)); column.setText(titles[i]); column.setWidth(bounds[i]); column.setResizable(true); column.setMoveable(false); } final Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.RECREATE); }
public TranslatableTreeComposite(Composite parent, ITreeContentProvider contentProvider, Object input, TranslatableSet languageSet, Set<TranslatableResourceBundle> updatedBundles) { super(parent, SWT.NONE); setLayout(new GridLayout(1, false)); final TreeViewer viewer = new TreeViewer(this, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); treeControl = viewer.getTree(); viewer.getTree().setHeaderVisible(true); viewer.getTree().setLinesVisible(true); viewer.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); viewer.setContentProvider(contentProvider); createTreeColumns(viewer, languageSet, updatedBundles); viewer.setInput(input); ColumnViewerToolTipSupport.enableFor(viewer); createButtonsSection(this, viewer, languageSet, updatedBundles).setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); }
@Override public void createPartControl(Composite parent) { GridLayoutFactory.fillDefaults().applyTo(parent); initNoProjectHint(parent); // init viewer viewer = new TreeViewerWithModelElementSelectionProvider(parent); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); Tree tree = viewer.getTree(); tree.setHeaderVisible(true); ColumnViewerToolTipSupport.enableFor(viewer); getSite().setSelectionProvider(viewer); initMenuManager(); changeColumn = createColumn("Changes", 250); branchColumn = createColumn("Branches", 150); commitColumn = createColumn("Commit Message", 250); authorColumn = createColumn("Author and Date", 250); initContentAndLabelProvider(); initGraphRenderer(); initToolBar(); initProjectDeleteListener(); }
/** * This is a callback that will allow us * to create the viewer and initialize it. */ public void createPartControl(Composite parent) { _viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); _contentProvider = new ViewContentProvider(); _viewer.setContentProvider(_contentProvider); ColumnViewerToolTipSupport.enableFor(_viewer); _viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { fireEngineSelectionChanged(); } }); createColumns(); // _viewer.setColumnProperties( new String[] {"Status", "Identifier", "Step", "Status"} ); // _viewer.getTree().setHeaderVisible(true); Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT); _viewer.getTree().setFont(mono); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(_viewer.getControl(), "org.eclipse.gemoc.executionframework.ui.views.engine.EngineStatusView"); // register for changes in the RunningEngineRegistry //org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addObserver(this); buildMenu(); org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addEngineRegistrationListener(this); }
private Table createMappingTable(Composite composite_6) { mappingTableViewer = new TableViewer(composite_6, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); Table table = mappingTableViewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_table.widthHint = 374; table.setLayoutData(gd_table); mappingTableViewer.setContentProvider(new ArrayContentProvider()); ColumnViewerToolTipSupport.enableFor(mappingTableViewer); return table; }
public TableViewer createTable(final Composite parent, final WritableList<IDependencyRelation> descriptions) { final TableViewer table = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); createColumns(table); table.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); table.setContentProvider(new ObservableListContentProvider()); table.setInput(descriptions); table.setLabelProvider(new TableLabelProvider()); ColumnViewerToolTipSupport.enableFor(table); return table; }
public TableViewer createTable(final Composite parent, final WritableList<IType> descriptions) { final TableViewer table = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); createColumns(table); table.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); table.setContentProvider(new ObservableListContentProvider()); table.setInput(descriptions); table.setLabelProvider(new TableLabelProvider()); ColumnViewerToolTipSupport.enableFor(table); return table; }
@Override protected Control createDialogArea(Composite container) { Control area = super.createDialogArea(container); TableViewer tableViewer = getTableViewer(); Table table = tableViewer.getTable(); tableViewer.setLabelProvider(new DefaultCellLabelProvider()); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); table.setHeaderVisible(true); newTableColumn(table, "Description", 200); newTableColumn(table, "ID", 200); newTableColumn(table, "Name", 200); tableViewer.refresh(); return area; }
public ResultsTable(final Composite parent, final Object layoutData, final EarthquakeBulletinGui gui) { tableViewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION) { // Auto resize columns on content change @Override protected void inputChanged(final Object input, final Object oldInput) { super.inputChanged(input, oldInput); if (!initialized) { final Table table = tableViewer.getTable(); table.setRedraw(false); final TableColumn sortedColumn = table.getSortColumn(); table.setSortColumn(null); for (int j = 0; j < table.getColumns().length; j++) { table.getColumn(j).pack(); } table.setSortColumn(sortedColumn); table.setRedraw(true); initialized = true; } } }; final Table table = tableViewer.getTable(); createColumns(table); table.setLayoutData(layoutData); table.setHeaderVisible(true); table.setLinesVisible(true); table.addListener(SWT.DefaultSelection, new ShowMapListener(gui)); tableViewer.setContentProvider(new ArrayContentProvider()); ColumnViewerToolTipSupport.enableFor(tableViewer); comparator = new EarthquakeViewerComparator(); tableViewer.setComparator(comparator); contextMenu = new ContextMenu(gui); }
@Override protected void initialize(ColumnViewer viewer, ViewerColumn column) { super.initialize(viewer, column); if (decorator != null) { ColumnViewerToolTipSupport.enableFor(viewer); } }
@Override public void createPartControl(final Composite parent) { NavigationTreeService navigationTree; try { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); viewer.setContentProvider(new NavigationViewContentProvider()); ColumnViewerToolTipSupport.enableFor(viewer); viewer.setLabelProvider(new NavigationViewLabelProvider()); viewer.addDoubleClickListener(new TreeCollapseExpandListener(viewer)); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { CommandExecutor.executeCommand(ICommandIds.CMD_MANAGE_BORROWER_MEDIUM); } }); viewer.setSorter(new ViewerSorter()); viewer.setAutoExpandLevel(2); navigationTree = new NavigationTreeService(viewer); viewer.setInput(navigationTree.getRoot()); // popup menu related stuff final MenuManager manager = new MenuManager(); viewer.getTree().setMenu(manager.createContextMenu(viewer.getTree())); getSite().registerContextMenu(manager, viewer); getSite().setSelectionProvider(viewer); } catch (final ConnectException e) { e.printStackTrace(); } }
public void contribute(final TreeViewer treeViewer) { KeyTreeContentProvider contentProvider = new KeyTreeContentProvider(treeType); treeViewer.setContentProvider(contentProvider); ColumnViewerToolTipSupport.enableFor(treeViewer); treeViewer.setLabelProvider(new KeyTreeLabelProvider(editor, treeModel,contentProvider)); if (treeViewer.getInput() == null) treeViewer.setUseHashlookup(true); ViewerFilter onlyUnusedAndMissingKeysFilter = new OnlyUnsuedAndMissingKey(); keyFilter = new KeyNameFilter(); ViewerFilter[] filters = { onlyUnusedAndMissingKeysFilter, keyFilter }; treeViewer.setFilters(filters); contributeActions(treeViewer); contributeKeySync(treeViewer); contributeModelChanges(treeViewer); contributeDoubleClick(treeViewer); contributeMarkers(treeViewer); // Set input model treeViewer.setInput(treeModel); treeViewer.expandAll(); treeViewer.setColumnProperties(new String[] { "column1" }); treeViewer.setCellEditors(new CellEditor[] { new TextCellEditor(treeViewer.getTree()) }); }
@Override public void createControl(Composite parent) { super.createControl(parent); TreeViewer treeViewer = getTreeViewer(); treeViewer.setContentProvider(new ReportTreeContetProvider()); treeViewer.setLabelProvider(new ReportTreeLabelProvider()); treeViewer.setInput(model); treeViewer.expandToLevel(2); ColumnViewerToolTipSupport.enableFor(treeViewer); getSite().setSelectionProvider(treeViewer); }
@Override public void createPartControl(Composite parent) { Filter filter = new Filter(); FilteredTree tree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true) { @Override protected void updateToolbar(boolean visible) { super.updateToolbar(visible); viewer.collapseAll(); viewer.expandToLevel(2); } }; viewer = tree.getViewer(); drillDownAdapter = new DrillDownAdapter(viewer); viewer.setContentProvider(new ViewContentProvider(this)); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setComparator(new ViewSorter()); viewer.getTree().setToolTipText(null); ColumnViewerToolTipSupport.enableFor(viewer); getSite().setSelectionProvider(viewer); refresh(new Object()); targetActions = new LinkedHashSet<>(); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); readTargetDefinitions(); }
/** * Constructs a CellEditor with a given viewer for the given column. * * @param viewer for the table * @param columnType Parameter for the Cell editor. */ public ConfigurationCellEditor(TreeViewer viewer, ColumnType columnType) { super(viewer); this.columnType = columnType; this.viewer = viewer; // Activate the tooltip support for the viewer ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); }
@Override public void createControl(Composite parent) { super.createControl(parent); Composite container = new Composite(parent, SWT.NONE); GridLayout layout = WizardUtils.createGridLayout(1, 5); container.setLayout(layout); _newRadio = WizardUtils.createRadio(container, "Create a new application:", 1, this); // $NLX-NameBluemixWizardPage.Createanewapplication-1$ _newRadio.setSelection(true); _nameText = WizardUtils.createText(container, 1, 20); _nameText.addModifyListener(this); _existingRadio = WizardUtils.createRadio(container, "Overwrite an existing application:", 1, this); // $NLX-NameBluemixWizardPage.Overwriteanexistingapplication-1$ _appViewer = WizardUtils.createTableViewer(container, 1, 1, null, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL, 20); ColumnViewerToolTipSupport.enableFor(_appViewer, ToolTip.NO_RECREATE); _appViewer.getTable().setToolTipText("Choose application"); // $NLX-NameBluemixWizardPage.ChooseApplication-1$ _appViewer.getTable().setHeaderVisible(false); _appViewer.getTable().setLinesVisible(false); _appViewer.getTable().addControlListener(this); _appViewer.setContentProvider(new ArrayContentProvider()); _appViewer.addSelectionChangedListener(this); _appViewer.getTable().addSelectionListener(this); // Create the only column TableViewerColumn col = new TableViewerColumn(_appViewer, SWT.LEFT); col.getColumn().setResizable(false); col.setLabelProvider(new ColumnLabelProvider()); // Create Host Group _hostGroup = WizardUtils.createGroup(container, 3, 3); WizardUtils.createLabel(_hostGroup, "Host:", 1); // $NLX-NameBluemixWizardPage.Host-1$ _hostText = WizardUtils.createText(_hostGroup, 1, 0); _hostText.addModifyListener(this); _domainLabel = WizardUtils.createLabel(_hostGroup, "", 1); setControl(container); }
final void configure() { adapterFactory = createAdapterFactory(); viewer.addDoubleClickListener(listener); viewer.setSorter(new ViewerSorter()); ColumnViewerToolTipSupport.enableFor(viewer); doConfigure(); }
@Override public void create() { super.create(); final NiemContainerCheckedTreeViewer theTreeViewer = getTreeViewer(); ColumnViewerToolTipSupport.enableFor(theTreeViewer); final Collection<TreeItem> visibleTreeItems = new ArrayList<>(); final TreeItem theRootItem = theTreeViewer.getTree().getItem(0); visibleTreeItems.add(theRootItem); visibleTreeItems.addAll(asList(theRootItem.getItems())); updateExpanded(visibleTreeItems, theTreeViewer); }
/** * Create a table viewer under the given parent. Initializes the viewer with * the given input. Uses SpotterExtensionsContentProvider as content * provider and SpotterExtensionsLabelProvider as label provider. * * @param parent * The parent composite. Must not be <code>null</code>. * @param input * The input of the viewer. Must not be <code>null</code>. * @param editor * The underlying editor if any or <code>null</code>. * @param dragAndDropSupport * Determines whether drag 'n drop is supported. * * @return the created table viewer * * @see SpotterExtensionsContentProvider * @see SpotterExtensionsLabelProvider */ public static TableViewer createTableViewer(Composite parent, IExtensionItem input, AbstractExtensionsEditor editor, boolean dragAndDropSupport) { if (parent == null) { throw new IllegalArgumentException("parent must not be null"); } if (input == null) { throw new IllegalArgumentException("input must not be null"); } // configure table layout Composite tblExtensionsComp = new Composite(parent, SWT.NONE); tblExtensionsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); TableColumnLayout tblExtensionsColLayout = new TableColumnLayout(); tblExtensionsComp.setLayout(tblExtensionsColLayout); // create table Table table = new Table(tblExtensionsComp, VIEWER_CONTROL_STYLE); table.setHeaderVisible(false); table.setLinesVisible(false); // create viewer for table TableViewer tableViewer = new TableViewer(table); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); TableViewerColumn extensionsColumn = new TableViewerColumn(tableViewer, SWT.NONE); tblExtensionsColLayout.setColumnData(extensionsColumn.getColumn(), new ColumnWeightData(1)); if (dragAndDropSupport) { addDragAndDropSupport(tableViewer, editor, false); } tableViewer.setContentProvider(new SpotterExtensionsContentProvider()); tableViewer.setLabelProvider(new SpotterExtensionsLabelProvider()); tableViewer.setInput(input); return tableViewer; }
/** * Create a tree viewer under the given parent. Initializes the viewer with * the given input. Uses SpotterExtensionsContentProvider as content * provider and SpotterExtensionsLabelProvider as label provider. * * @param parent * The parent composite. Must not be <code>null</code>. It is * recommended to use a {@link GridLayout} on the parent or at * least a layout that has set the <i>fill flag</i>. * @param input * The input of the viewer. Must not be <code>null</code>. * @param editor * The underlying editor if any or <code>null</code>. * @param dragAndDropSupport * Determines whether drag 'n drop is supported. * * @return the created table viewer * * @see SpotterExtensionsContentProvider * @see SpotterExtensionsLabelProvider */ public static TreeViewer createTreeViewer(Composite parent, IExtensionItem input, AbstractExtensionsEditor editor, boolean dragAndDropSupport) { if (parent == null) { throw new IllegalArgumentException("parent must not be null"); } if (input == null) { throw new IllegalArgumentException("input must not be null"); } // configure tree layout Composite treeExtensionsComp = new Composite(parent, SWT.NONE); if (parent.getLayout() instanceof GridLayout) { treeExtensionsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } TreeColumnLayout treeExtensionsColLayout = new TreeColumnLayout(); treeExtensionsComp.setLayout(treeExtensionsColLayout); // create tree Tree tree = new Tree(treeExtensionsComp, VIEWER_CONTROL_STYLE); tree.setHeaderVisible(false); tree.setLinesVisible(false); // create viewer for tree TreeViewer treeViewer = new TreeViewer(tree); ColumnViewerToolTipSupport.enableFor(treeViewer, ToolTip.NO_RECREATE); TreeViewerColumn extensionsColumn = new TreeViewerColumn(treeViewer, SWT.NONE); treeExtensionsColLayout.setColumnData(extensionsColumn.getColumn(), new ColumnWeightData(1)); if (dragAndDropSupport) { addDragAndDropSupport(treeViewer, editor, true); } treeViewer.setContentProvider(new SpotterExtensionsContentProvider()); treeViewer.setLabelProvider(new SpotterExtensionsLabelProvider()); treeViewer.setInput(input); return treeViewer; }
private void createTableViewer(Composite grpProperties) { // configure table layout Composite tblPropertiesComp = new Composite(grpProperties, SWT.NONE); tblPropertiesComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, TABLE_COMPOSITE_HOR_SPAN, 1)); TableColumnLayout tableColLayout = new TableColumnLayout(); tblPropertiesComp.setLayout(tableColLayout); // create table tblProperties = new Table(tblPropertiesComp, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); tblProperties.setHeaderVisible(true); tblProperties.setLinesVisible(true); // create viewer for table propertiesTblViewer = new TableViewer(tblProperties); ColumnViewerToolTipSupport.enableFor(propertiesTblViewer, ToolTip.NO_RECREATE); TableViewerColumn nameColumn = new TableViewerColumn(propertiesTblViewer, SWT.NONE); nameColumn.getColumn().setText("name"); tableColLayout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(TABLE_COLUMN_NAME_WEIGHT)); TableViewerColumn valueColumn = new TableViewerColumn(propertiesTblViewer, SWT.NONE); valueColumn.getColumn().setText("value"); tableColLayout.setColumnData(valueColumn.getColumn(), new ColumnWeightData(TABLE_COLUMN_VALUE_WEIGHT)); editingSupport = new PropertiesEditingSupport(valueColumn.getViewer(), editor, this); valueColumn.setEditingSupport(editingSupport); propertiesTblViewer.setContentProvider(new PropertiesContentProvider()); propertiesTblViewer.setLabelProvider(new PropertiesLabelProvider(this)); PropertiesComparator comparator = new PropertiesComparator(); nameColumn.getColumn().addSelectionListener(createColumnSelectionAdapter(comparator)); propertiesTblViewer.setComparator(comparator); }
private void createStepColumn(int i, TreeColumnLayout layout) { TreeViewerColumn stepCol = new TreeViewerColumn(treeViewer, SWT.None); stepCol.getColumn().setText("Step " + (i + 1)); ColumnViewerToolTipSupport.enableFor(stepCol.getViewer()); stepCol.setLabelProvider(new AgreeCounterexampleStepLabelProvider(i)); layout.setColumnData(stepCol.getColumn(), new ColumnWeightData(1, 50)); }
public MedicationHistoryTableComposite(Composite parent, int style){ super(parent, style); setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); layout = new TableColumnLayout(); setLayout(layout); viewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); viewer.getTable().setHeaderVisible(true); ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent e){ IStructuredSelection is = (IStructuredSelection) viewer.getSelection(); MedicationTableViewerItem presc = (MedicationTableViewerItem) is.getFirstElement(); // set last disposition information IPersistentObject po = (presc != null) ? presc.getLastDisposed() : null; medicationComposite.setLastDisposalPO(po); // set writable databinding value medicationComposite.setSelectedMedication(presc); ElexisEventDispatcher .fireSelectionEvent((presc != null) ? presc.getPrescription() : null); } }); MedicationViewerHelper.createTypeColumn(viewer, layout, 0); MedicationViewerHelper.createArticleColumn(viewer, layout, 1); MedicationViewerHelper.createDosageColumn(viewer, layout, 2); MedicationViewerHelper.createBeginColumn(viewer, layout, 3); MedicationViewerHelper.createIntakeCommentColumn(viewer, layout, 4); MedicationViewerHelper.createStopColumn(viewer, layout, 5); MedicationViewerHelper.createStopReasonColumn(viewer, layout, 6); MedicationViewerHelper.createMandantColumn(viewer, layout, 7); viewer.setContentProvider(new MedicationTableViewerContentProvider(viewer)); }
@Override protected void initListeners(TreeViewer viewer) { super.initListeners(viewer); viewer.setUseHashlookup(true); ColumnViewerToolTipSupport.enableFor(viewer); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { onDoubleClick(event.getSelection()); } }); }
private static TreeViewer createViewer(Composite parent, boolean multi) { int selectionFlag = multi ? SWT.MULTI : SWT.SINGLE; TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | selectionFlag); viewer.setContentProvider(new NavigationContentProvider()); viewer.setLabelProvider(new NavigationLabelProvider(false)); viewer.setSorter(new NavigationSorter()); ColumnViewerToolTipSupport.enableFor(viewer); return viewer; }
private void createViewer(Composite composite) { viewer = new CheckboxTreeViewer(composite, SWT.VIRTUAL | SWT.MULTI | SWT.BORDER); viewer.setUseHashlookup(true); viewer.getTree().setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true)); viewer.setContentProvider(new NavigationContentProvider()); viewer.setLabelProvider(new NavigationLabelProvider(false)); viewer.setSorter(new NavigationSorter()); viewer.addFilter(new ModelTypeFilter(types)); viewer.addCheckStateListener(new ModelSelectionState(this, viewer)); registerInputHandler(composite); ColumnViewerToolTipSupport.enableFor(viewer); }
/** * Creates a new TreeViewerBuilder. */ public TreeViewerBuilder(Composite parent, int style) { mappings = Collections.emptyMap(); checkable = (style & SWT.CHECK) == SWT.CHECK; if (checkable) { viewer = new CheckboxTreeViewer(parent, style); } else { viewer = new TreeViewer(parent, style); } // enable tooltip support ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); }
/** * Creates a new TableViewerBuilder * * @param parent * @param style */ public TableViewerBuilder(Composite parent, int style) { // check parent if (parent.getChildren().length > 0) { throw new IllegalArgumentException( "The parent composite for the table needs to be empty for TableColumnLayout."); //$NON-NLS-1$ } mappings = Collections.emptyMap(); checkable = (style & SWT.CHECK) == SWT.CHECK; if (checkable) { viewer = CheckboxTableViewer.newCheckList(parent, style); } else { viewer = new TableViewer(parent, style); } viewer.setContentProvider(new ArrayContentProvider()); viewer.setUseHashlookup(true); // enable tooltip support ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); Table table = viewer.getTable(); // set TableColumnLayout to table parent // Table parent layout needs to be a TableColumnLayout table.getParent().setLayout(new TableColumnLayout()); // headers / lines visible by default table.setHeaderVisible(true); table.setLinesVisible(true); }
protected TreeViewer createTreeViewer(Composite parent) { TreeViewer viewer = new TreeViewer(parent, schemaViewerConfiguration.getTreeViewerStyle(editor, context, displayMode)); contentProvider = schemaViewerConfiguration.getContentProvider(editor, context, displayMode); schemaNodeRegistry.setSchemaContentProvider(contentProvider); viewer.setContentProvider(new SchemaViewerTreeContentProviderImpl(nodeConverter)); labelProvider = schemaViewerConfiguration.getLabelProvider(editor, context, displayMode); SchemaViewerStyledCellLabelProvider styledLabelProvider = new SchemaViewerStyledCellLabelProvider(labelProvider, nodeConverter); viewer.setLabelProvider(styledLabelProvider); ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); return viewer; }
/** * Creates a new {@code TableViewer} to show a {@link TableComponent}. * * @param parent * The containing {@code Composite}. * @return The created JFace {@code TableViewer}. */ private TableViewer createTableViewer(Composite parent) { // Create the TableViewer and the underlying Table Control. TableViewer viewer = new TableViewer(this, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); // Set some properties for the table. final Table table = viewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); // Set up the content provider for the viewer. Now the viewer's input // can be set. viewer.setContentProvider(new TableComponentContentProvider()); // Enable tool tips for the Table's cells. ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE); // Add a selection listener to tell the TableComponent which rows are // selected. ISelectionChangedListener listener = new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // To delete rows (later), the TableComponent expects indices. // Thus, we must keep track of selected indicies by updating the // class' list. // To select rows, the TableComponent expects an // ArrayList<Integer> containing the row IDs, not indices. Thus, // we must convert the int[] of indices into an // ArrayList<Integer> of IDs to select. int[] selected = table.getSelectionIndices(); List<Integer> rowIds = tableComponent.getRowIds(); ArrayList<Integer> rows = new ArrayList<Integer>( selected.length); selectedIndices.clear(); for (int i : selected) { selectedIndices.add(i); rows.add(rowIds.get(i)); } tableComponent.setSelectedRows(rows); // Enable/disable the remove action if the selection is // non/empty. removeRowAction.setEnabled(!event.getSelection().isEmpty()); return; } }; viewer.addSelectionChangedListener(listener); // Use a custom comparer to just check references rather than calling // equals(Object), which causes strange behavior when multiple rows have // the same values. viewer.setComparer(new IElementComparer() { @Override public boolean equals(Object a, Object b) { return a == b; } @Override public int hashCode(Object element) { return element.hashCode(); } }); return viewer; }
@Override protected Control createDialogArea(Composite parent) { Composite cmp = (Composite) super.createDialogArea(parent); treeViewer = new TreeViewer(cmp, SWT.MULTI | SWT.BORDER); treeViewer.setContentProvider(new ReportTreeContetProvider() { @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof MSqlSchema) { MSqlSchema p = (MSqlSchema) parentElement; if (p.getChildren() != null && p.getChildren().size() > 0) { List<INode> n = new ArrayList<INode>(); for (INode node : p.getChildren()) { if (node instanceof MTables) n.add(node); } return n.toArray(); } } return super.getChildren(parentElement); } }); treeViewer.setLabelProvider(new ReportTreeLabelProvider()); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 400; gd.minimumWidth = 400; treeViewer.getControl().setLayoutData(gd); treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { TreeSelection ts = (TreeSelection) treeViewer.getSelection(); Object el = ts.getFirstElement(); if (el instanceof MSQLColumn) okPressed(); else { if (treeViewer.getExpandedState(el)) treeViewer.collapseToLevel(el, 1); else treeViewer.expandToLevel(el, 1); } } }); ColumnViewerToolTipSupport.enableFor(treeViewer); treeViewer.setInput(root); return cmp; }
@Override protected Control createDialogArea(Composite parent) { Composite cmp = (Composite) super.createDialogArea(parent); treeViewer = new TreeViewer(cmp, SWT.MULTI | SWT.BORDER); treeViewer.setContentProvider(new ReportTreeContetProvider() { @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof MSqlSchema) { MSqlSchema p = (MSqlSchema) parentElement; if (p.getChildren() != null && p.getChildren().size() > 0) { List<INode> n = new ArrayList<INode>(); for (INode node : p.getChildren()) { if (node instanceof MTables) n.add(node); } return n.toArray(); } } return super.getChildren(parentElement); } @Override public boolean hasChildren(Object element) { if (element instanceof MSqlTable) return false; return super.hasChildren(element); } }); treeViewer.setLabelProvider(new ReportTreeLabelProvider()); GridData gd = new GridData(GridData.FILL_BOTH); gd.minimumHeight = 400; gd.minimumWidth = 400; treeViewer.getControl().setLayoutData(gd); treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { TreeSelection ts = (TreeSelection) treeViewer.getSelection(); Object el = ts.getFirstElement(); if (el instanceof MSqlTable) okPressed(); else { if (treeViewer.getExpandedState(el)) treeViewer.collapseToLevel(el, 1); else treeViewer.expandToLevel(el, 1); } } }); ColumnViewerToolTipSupport.enableFor(treeViewer); treeViewer.setInput(root); return cmp; }