List of usage examples for org.eclipse.jface.viewers TableViewer setContentProvider
@Override public void setContentProvider(IContentProvider provider)
AbstractTableViewer
. From source file:org.eclipse.birt.report.designer.ui.dialogs.ExpressionBuilder.java
License:Open Source License
private void initTable(TableViewer tableViewer, boolean leafOnly) { final Table table = tableViewer.getTable(); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 150;//from w w w. j a v a 2 s. c om table.setLayoutData(gd); table.setToolTipText(null); final TableColumn column = new TableColumn(table, SWT.NONE); column.setWidth(200); table.getShell().addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Display.getCurrent().asyncExec(new Runnable() { public void run() { if (column != null && !column.isDisposed()) { column.setWidth(table.getSize().x > 204 ? table.getSize().x - 4 : 200); } } }); } }); table.addMouseTrackListener(new MouseTrackAdapter() { public void mouseHover(MouseEvent event) { Widget widget = event.widget; if (widget == table) { Point pt = new Point(event.x, event.y); TableItem item = table.getItem(pt); if (item == null) { table.setToolTipText(null); } else { table.setToolTipText(provider.getTooltipText(item.getData())); } } } }); tableViewer.setLabelProvider(new ExpressionLabelProvider()); tableViewer.setContentProvider(new TableContentProvider(tableViewer, leafOnly)); tableViewer.addSelectionChangedListener(selectionListener); tableViewer.addDoubleClickListener(doubleClickListener); }
From source file:org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage.java
License:Open Source License
private void createInterfaceWidget(Composite fClient, ProcessType current, final IManagedForm managedForm, String title, String description, boolean isInbound) { // Set column names String[] columnNames = new String[] { // "Partner Link (click on entry to open definition)", "Partner Link", "Associated Port", "Related Service", "Binding Used" }; Section section = toolkit.createSection(fClient, Section.TWISTIE | Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR); section.setText(title);/* w w w . j a v a 2s. com*/ section.setDescription(description); section.marginHeight = 5; Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); final Table t = toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); TableColumn tc1 = new TableColumn(t, SWT.CENTER); tc1.setText(columnNames[0]); TableColumn tc2 = new TableColumn(t, SWT.CENTER); tc2.setText(columnNames[1]); TableColumn tc3 = new TableColumn(t, SWT.CENTER); tc3.setText(columnNames[2]); TableColumn tc4 = new TableColumn(t, SWT.CENTER); tc4.setText(columnNames[3]); t.setHeaderVisible(true); t.setLinesVisible(true); GridData gd = new GridData(GridData.FILL_BOTH); t.setLayoutData(gd); toolkit.paintBordersFor(client); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); URI deployDescriptorURI = current.eResource().getURI(); IFile ddFile = DeployUtils.getIFileForURI(deployDescriptorURI); TableViewer viewer = new TableViewer(t); viewer.setUseHashlookup(true); viewer.setColumnProperties(columnNames); viewer.setContentProvider(new PortTypeContentProvider(isInbound)); viewer.setLabelProvider( new PortTypeLabelProvider(ddFile.getProject(), current.eResource().getResourceSet())); viewer.setInput(current); for (int i = 0, n = t.getColumnCount(); i < n; i++) { t.getColumn(i).pack(); } // Create the cell editors CellEditor[] editors = new CellEditor[columnNames.length]; // TODO: Column 1 : HyperLink Listener // final TableEditor editor = new TableEditor(t); // editor.horizontalAlignment = SWT.LEFT; // editor.grabHorizontal = true; // IWorkbenchPage wbPage= getEditor().getSite().getPage(); // InterfaceTableListener tableListener = new // InterfaceTableListener(current, t, editor, toolkit, wbPage, // isInbound); // t.addListener(SWT.MouseDown, tableListener); // Column 2 : Associate Service (ComboBox) ServiceCellEditor sCellEditor = new ServiceCellEditor(t, ddFile.getProject(), current.eResource().getResourceSet()); editors[1] = sCellEditor; // Assign the cell editors to the viewer viewer.setCellEditors(editors); // Set the cell modifier for the viewer viewer.setCellModifier(new InterfaceWidgetCellModifier(viewer, columnNames)); }
From source file:org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage.java
License:Open Source License
private void createDataSourceSection(Composite fClient, ProcessType current, final IManagedForm managedForm, String title, String description) { // Set column names String[] columnNames = new String[] { "Name", "Address", "Type", "Subtype", "Language", "Data format", "User name", "Password" }; int[] bounds = { 75, 175, 50, 50, 50, 50, 50, 50 }; Section section = toolkit.createSection(fClient, Section.TWISTIE | Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR); section.setText(title);// w w w . java 2 s .co m section.setDescription(description); section.marginHeight = 5; Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); final Table table = toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); GridData gd = new GridData(GridData.FILL_BOTH); table.setLayoutData(gd); toolkit.paintBordersFor(client); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); final TableViewer viewer = new TableViewer(table); for (int i = 0; i < columnNames.length; i++) { final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = viewerColumn.getColumn(); column.setText(columnNames[i]); column.setWidth(bounds[i]); column.setResizable(true); column.setMoveable(true); } table.setHeaderVisible(true); table.setLinesVisible(true); viewer.setContentProvider(new DataSourceContentProvider()); viewer.setLabelProvider(new DataSourceLabelProvider()); viewer.setInput(processType.getDatasources()); Composite buttonComp = toolkit.createComposite(client, SWT.WRAP); GridLayout bLayout = new GridLayout(); layout.marginWidth = 2; layout.marginHeight = 2; layout.numColumns = 3; buttonComp.setLayout(bLayout); final Button btnNew = toolkit.createButton(buttonComp, "New", SWT.PUSH); btnNew.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub AddDataSourceDialog dialog = new AddDataSourceDialog(Display.getDefault().getActiveShell(), processType); dialog.open(); if (dialog.getDatasource().getDataSourceName() != null) { Command addDataSourceCommand = AddCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Datasources(), dialog.getDatasource()); domain.getCommandStack().execute(addDataSourceCommand); // Updating the display in the view viewer.refresh(); } } }); final Button btnEdit = toolkit.createButton(buttonComp, "Edit", SWT.PUSH); btnEdit.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub ISelection selection = viewer.getSelection(); if (selection != null && selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; if (sel.size() == 1) { TDatasource datasource = (TDatasource) sel.getFirstElement(); EditDataSourceDialog dialog = new EditDataSourceDialog( Display.getDefault().getActiveShell(), datasource, processType); dialog.open(); if (dialog.getDatasource().getDataSourceName() != null) { Command removeDataSourceCommand = RemoveCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Datasources(), datasource); domain.getCommandStack().execute(removeDataSourceCommand); Command addDataSourceCommand = AddCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Datasources(), dialog.getDatasource()); domain.getCommandStack().execute(addDataSourceCommand); } } // Updating the display in the view viewer.refresh(); } } }); final Button btnDelete = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); btnDelete.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub ISelection selection = viewer.getSelection(); if (selection != null && selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; for (Iterator<TDatasource> iterator = sel.iterator(); iterator.hasNext();) { TDatasource datasource = iterator.next(); Command removeDataSourceCommand = RemoveCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_Datasources(), datasource); domain.getCommandStack().execute(removeDataSourceCommand); } viewer.refresh(); } } }); }
From source file:org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage.java
License:Open Source License
private void createActivityMappingSection(Composite fClient, ProcessType current, final IManagedForm managedForm, String title, String description) { // Save the current ProcessType object in a final copy to // work with it in the inner classes (SelectionListener) final ProcessType pt = current; // Set column names String[] columnNames = new String[] { "Activity", "Policy (local path)", "Strategy" }; int[] bounds = { 150, 250, 100 }; Section section = toolkit.createSection(fClient, Section.TWISTIE | Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR); section.setText(title);//from w ww. jav a 2 s .c om section.setDescription(description); section.marginHeight = 5; Composite client = toolkit.createComposite(section, SWT.WRAP); GridLayout layout = new GridLayout(); layout.marginWidth = 2; layout.marginHeight = 2; client.setLayout(layout); final Table table = toolkit.createTable(client, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); GridData gd = new GridData(GridData.FILL_BOTH); table.setLayoutData(gd); toolkit.paintBordersFor(client); section.setClient(client); final SectionPart spart = new SectionPart(section); managedForm.addPart(spart); final TableViewer viewer = new TableViewer(table); for (int i = 0; i < columnNames.length; i++) { final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = viewerColumn.getColumn(); column.setText(columnNames[i]); column.setWidth(bounds[i]); column.setResizable(true); column.setMoveable(true); } table.setHeaderVisible(true); table.setLinesVisible(true); viewer.setContentProvider(new MappingContentProvider()); viewer.setLabelProvider(new MappingLabelProvider()); viewer.setInput(processType.getActivityMappings()); Composite buttonComp = toolkit.createComposite(client, SWT.WRAP); GridLayout bLayout = new GridLayout(); layout.marginWidth = 2; layout.marginHeight = 2; layout.numColumns = 3; buttonComp.setLayout(bLayout); final Button btnNew = toolkit.createButton(buttonComp, "New", SWT.PUSH); btnNew.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub AddMappingDialog dialog = new AddMappingDialog(Display.getDefault().getActiveShell(), pt); dialog.open(); if (dialog.getMapping() != null) { Command addMappingCommand = AddCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_ActivityMappings(), dialog.getMapping()); domain.getCommandStack().execute(addMappingCommand); // Updating the display in the view viewer.refresh(); } } }); final Button btnEdit = toolkit.createButton(buttonComp, "Edit", SWT.PUSH); btnEdit.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub ISelection selection = viewer.getSelection(); if (selection != null && selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; if (sel.size() == 1) { TActivityMapping mapping = (TActivityMapping) sel.getFirstElement(); Command removeMappingCommand = RemoveCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_ActivityMappings(), mapping); domain.getCommandStack().execute(removeMappingCommand); EditMappingDialog dialog = new EditMappingDialog(Display.getDefault().getActiveShell(), pt, mapping); dialog.open(); Command addMappingCommand = AddCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_ActivityMappings(), dialog.getMapping()); domain.getCommandStack().execute(addMappingCommand); } // Updating the display in the view viewer.refresh(); } } }); final Button btnDelete = toolkit.createButton(buttonComp, "Remove", SWT.PUSH); btnDelete.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub widgetSelected(e); } @SuppressWarnings("unchecked") @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub ISelection selection = viewer.getSelection(); if (selection != null && selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; for (Iterator<TActivityMapping> iterator = sel.iterator(); iterator.hasNext();) { TActivityMapping mapping = iterator.next(); Command removeMappingCommand = RemoveCommand.create(domain, processType, ddPackage.eINSTANCE.getProcessType_ActivityMappings(), mapping); domain.getCommandStack().execute(removeMappingCommand); } viewer.refresh(); } } }); }
From source file:org.eclipse.cdt.debug.internal.ui.sourcelookup.PathMappingDialog.java
License:Open Source License
private TableViewer createViewer(Composite parent) { TableViewer viewer = new TableViewer(parent); viewer.setContentProvider(new ContentProvider()); viewer.setLabelProvider(new PathMappingLabelProvider()); return viewer; }
From source file:org.eclipse.cdt.examples.dsf.dataviewer.ACPMSumDataViewer.java
License:Open Source License
/** * The entry point for the example.//w w w .jav a 2 s . c o m * @param args Program arguments. */ public static void main(String[] args) { // Create the shell to hold the viewer. Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new GridLayout()); GridData data = new GridData(GridData.FILL_BOTH); shell.setLayoutData(data); Font font = new Font(display, "Courier", 10, SWT.NORMAL); // Create the table viewer. TableViewer tableViewer = new TableViewer(shell, SWT.BORDER | SWT.VIRTUAL); tableViewer.getControl().setLayoutData(data); DsfExecutor executor = new DefaultDsfExecutor("Example executor"); // Create the data generator. final IDataGenerator[] generators = new IDataGenerator[5]; for (int i = 0; i < generators.length; i++) { generators[i] = new DataGeneratorWithExecutor(executor); } final IDataGenerator sumGenerator = new ACPMSumDataGenerator(executor, generators); // Create the content provider which will populate the viewer. ACPMSumDataViewer contentProvider = new ACPMSumDataViewer(tableViewer, new ImmediateInDsfExecutor(executor), generators, sumGenerator); tableViewer.setContentProvider(contentProvider); tableViewer.setInput(new Object()); // Open the shell and service the display dispatch loop until user // closes the shell. shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // The IDataGenerator.shutdown() method is asynchronous, this requires // using a query again in order to wait for its completion. Query<Object> shutdownQuery = new Query<Object>() { @Override protected void execute(DataRequestMonitor<Object> rm) { CountingRequestMonitor crm = new CountingRequestMonitor(ImmediateExecutor.getInstance(), rm); for (int i = 0; i < generators.length; i++) { generators[i].shutdown(crm); } sumGenerator.shutdown(crm); crm.setDoneCount(generators.length); } }; executor.execute(shutdownQuery); try { shutdownQuery.get(); } catch (Exception e) { } // Shut down the display. font.dispose(); display.dispose(); }
From source file:org.eclipse.cdt.examples.dsf.dataviewer.AsyncDataViewer.java
License:Open Source License
public static void main(String[] args) { // Create the shell to hold the viewer. Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new GridLayout()); GridData data = new GridData(GridData.FILL_BOTH); shell.setLayoutData(data);/* w w w . j av a 2 s . c o m*/ Font font = new Font(display, "Courier", 10, SWT.NORMAL); // Create the table viewer. TableViewer tableViewer = new TableViewer(shell, SWT.BORDER | SWT.VIRTUAL); tableViewer.getControl().setLayoutData(data); // Create the data generator. final IDataGenerator generator = new DataGeneratorWithExecutor(); // Create the content provider which will populate the viewer. AsyncDataViewer contentProvider = new AsyncDataViewer(tableViewer, generator); tableViewer.setContentProvider(contentProvider); tableViewer.setInput(new Object()); // Open the shell and service the display dispatch loop until user // closes the shell. shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // The IDataGenerator.shutdown() method is asynchronous, this requires // using a query again in order to wait for its completion. Query<Object> shutdownQuery = new Query<Object>() { @Override protected void execute(DataRequestMonitor<Object> rm) { generator.shutdown(rm); } }; ImmediateExecutor.getInstance().execute(shutdownQuery); try { shutdownQuery.get(); } catch (Exception e) { } // Shut down the display. font.dispose(); display.dispose(); }
From source file:org.eclipse.cdt.examples.dsf.dataviewer.AsyncSumDataViewer.java
License:Open Source License
/** * The entry point for the example.//from w w w.ja v a 2 s . c om * @param args Program arguments. */ public static void main(String[] args) { // Create the shell to hold the viewer. Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new GridLayout()); GridData data = new GridData(GridData.FILL_BOTH); shell.setLayoutData(data); Font font = new Font(display, "Courier", 10, SWT.NORMAL); // Create the table viewer. TableViewer tableViewer = new TableViewer(shell, SWT.BORDER | SWT.VIRTUAL); tableViewer.getControl().setLayoutData(data); // Single executor (and single thread) is used by all data generators, // including the sum generator. DsfExecutor executor = new DefaultDsfExecutor("Example executor"); // Create the data generator. final IDataGenerator[] generators = new IDataGenerator[5]; for (int i = 0; i < generators.length; i++) { generators[i] = new DataGeneratorWithExecutor(executor); } final IDataGenerator sumGenerator = new AsyncSumDataGenerator(executor, generators); // Create the content provider which will populate the viewer. AsyncSumDataViewer contentProvider = new AsyncSumDataViewer(tableViewer, generators, sumGenerator); tableViewer.setContentProvider(contentProvider); tableViewer.setInput(new Object()); // Open the shell and service the display dispatch loop until user // closes the shell. shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // The IDataGenerator.shutdown() method is asynchronous, this requires // using a query again in order to wait for its completion. Query<Object> shutdownQuery = new Query<Object>() { @Override protected void execute(DataRequestMonitor<Object> rm) { CountingRequestMonitor crm = new CountingRequestMonitor(ImmediateExecutor.getInstance(), rm); for (int i = 0; i < generators.length; i++) { generators[i].shutdown(crm); } sumGenerator.shutdown(crm); crm.setDoneCount(generators.length); } }; executor.execute(shutdownQuery); try { shutdownQuery.get(); } catch (Exception e) { } // Shut down the display. font.dispose(); display.dispose(); }
From source file:org.eclipse.cdt.examples.dsf.dataviewer.SyncDataViewer.java
License:Open Source License
/** * The entry point for the example./* w w w. ja va 2 s .co m*/ * @param args Program arguments. */ public static void main(String[] args) { // Create the shell to hold the viewer. Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new GridLayout()); GridData data = new GridData(GridData.FILL_BOTH); shell.setLayoutData(data); Font font = new Font(display, "Courier", 10, SWT.NORMAL); // Create the table viewer. TableViewer tableViewer = new TableViewer(shell, SWT.BORDER); tableViewer.getControl().setLayoutData(data); // Create the data generator. //#ifdef exercises // TODO Exercise 5 - Use the DataGeneratorWithExecutor() instead. final IDataGenerator generator = new DataGeneratorWithThread(); //#else //# final IDataGenerator generator = new DataGeneratorWithExecutor(); //#endif // Create the content provider which will populate the viewer. SyncDataViewer contentProvider = new SyncDataViewer(tableViewer, generator); tableViewer.setContentProvider(contentProvider); tableViewer.setInput(new Object()); // Open the shell and service the display dispatch loop until user // closes the shell. shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // The IDataGenerator.shutdown() method is asynchronous, this requires // using a query again in order to wait for its completion. Query<Object> shutdownQuery = new Query<Object>() { @Override protected void execute(DataRequestMonitor<Object> rm) { generator.shutdown(rm); } }; ImmediateExecutor.getInstance().execute(shutdownQuery); try { shutdownQuery.get(); } catch (Exception e) { } // Shut down the display. font.dispose(); display.dispose(); }
From source file:org.eclipse.cdt.internal.ui.search.CSearchViewPage.java
License:Open Source License
@Override protected void configureTableViewer(TableViewer viewer) { createColumns(viewer);/* w w w . j a v a 2 s . com*/ contentProvider = new CSearchListContentProvider(this); viewer.setComparator(new SearchViewerComparator()); viewer.setContentProvider((CSearchListContentProvider) contentProvider); }