List of usage examples for org.eclipse.jface.viewers TableViewer TableViewer
public TableViewer(Composite parent, int style)
From source file:ch.ntb.inf.deep.eclipse.ui.view.MSRView.java
License:Apache License
/** * This is a callback that will allow us to create the viewer and initialize * it./*from w ww . j a v a2s . c o m*/ */ public void createPartControl(Composite parent) { // Create Viewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.FULL_SELECTION); // Create Columns String[] titels = { "Register", "Value" }; int[] bounds = { 60, 230 }; for (int i = 0; i < titels.length; i++) { TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[i]); column.getColumn().setWidth(bounds[i]); column.getColumn().setResizable(true); column.getColumn().setMoveable(false); } Table table = viewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); // Set Providers after table init viewer.setLabelProvider(new ViewLabelProvider()); viewer.setContentProvider(new ViewContentProvider()); viewer.setSorter(null); // set input after init Providers update();// needs to init model viewer.setInput(getViewSite()); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), helpContextId); createActions(); hookContextMenu(); contributeToActionBars(); }
From source file:ch.ntb.inf.deep.eclipse.ui.view.TargetOperationView.java
License:Apache License
@Override public void createPartControl(Composite parent) { prefs = InstanceScope.INSTANCE.getNode(DeepPlugin.PLUGIN_ID); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); String[] titels = { "Operation", "Descriptor", "Value", "MemAddr", "", "", "Error Message" }; int[] bounds = { 100, 100, 100, 100, 18, 18, 250 }; TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[0]); column.getColumn().setWidth(bounds[0]); column.getColumn().setResizable(true); column.getColumn().setMoveable(false); column.setEditingSupport(new OperationEditingSupport(viewer)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[1]); column.getColumn().setWidth(bounds[1]); column.getColumn().setResizable(true); column.getColumn().setMoveable(false); column.setEditingSupport(new DescriptorEditingSupport(viewer)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[2]); column.getColumn().setWidth(bounds[2]); column.getColumn().setResizable(true); column.getColumn().setMoveable(false); column.setEditingSupport(new ValueEditingSupport(viewer)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[3]); column.getColumn().setWidth(bounds[3]); column.getColumn().setResizable(false); column.getColumn().setMoveable(false); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[4]); column.getColumn().setWidth(bounds[4]); column.getColumn().setResizable(false); column.getColumn().setMoveable(false); column.setEditingSupport(new RefreshEditingSupport(viewer)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[5]); column.getColumn().setWidth(bounds[5]); column.getColumn().setResizable(false); column.getColumn().setMoveable(false); column.setEditingSupport(new DownloadEditingSupport(viewer)); column = new TableViewerColumn(viewer, SWT.NONE); column.getColumn().setText(titels[6]); column.getColumn().setWidth(bounds[6]); column.getColumn().setResizable(false); column.getColumn().setMoveable(false); final Table table = viewer.getTable(); table.setHeaderVisible(true);// w w w .j a v a 2s .c om table.setLinesVisible(true); table.setLayoutData(new GridData(GridData.FILL_BOTH)); viewer.setColumnProperties(titels); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); getSite().setSelectionProvider(viewer); String storedOperations = prefs.get("storedTargetOperations", ""); String[] vars = storedOperations.split(";"); // Get the content for the viewer, setInput will call getElements in the // contentProvider elements = new TargetOpObject[32]; if (vars.length > 1) { for (int i = 0; i < vars.length && i < elements.length; i++) { String[] obj = vars[i].split(","); if (obj.length > 1) { elements[i] = new TargetOpObject(Integer.decode(obj[0]), obj[1]); } else { elements[i] = new TargetOpObject(); } } } else { for (int i = 0; i < 32; i++) { elements[i] = new TargetOpObject(); } } viewer.setInput(elements); createActions(); hookContextMenu(); }
From source file:clustere.dialogs.PluginManage.java
License:Open Source License
public void open() { FormData group1LData = new FormData(); group1LData.left = new FormAttachment(0, 1000, 12); group1LData.top = new FormAttachment(0, 1000, 255); group1LData.width = 466;//from w w w . ja v a 2 s. c o m group1LData.height = 155; FormData button2LData = new FormData(); try { Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MODELESS); Display display = dialogShell.getDisplay(); dialogShell.setLayout(new FormLayout()); dialogShell.setText("Plugin-in Management"); // dialogShell.setImage(new Image(display, "icos/open.ico")); { group1 = new Group(dialogShell, SWT.NONE); FillLayout group1Layout = new FillLayout(org.eclipse.swt.SWT.HORIZONTAL); group1.setLayout(group1Layout); group1.setText("Detail"); group1.setLayoutData(group1LData); { text1 = new Text(group1, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); text1.setEditable(false); } } { button2 = new Button(dialogShell, SWT.PUSH | SWT.CENTER); button2.setText("Close"); button2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub dialogShell.dispose(); } }); } { button1 = new Button(dialogShell, SWT.PUSH | SWT.CENTER); button1.setText("Import New"); button1.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // TODO Auto-generated method stub // MenuControllor.pluginImport(); } }); } { tv = new TableViewer(dialogShell, SWT.FULL_SELECTION | SWT.BORDER); FormData tvLData = new FormData(); tvLData.left = new FormAttachment(0, 1000, 6); tvLData.top = new FormAttachment(0, 1000, 10); tvLData.width = 458; tvLData.height = 186; tv.getControl().setLayoutData(tvLData); table1 = tv.getTable(); table1.setLinesVisible(true); table1.setHeaderVisible(true); { tableColumn1 = new TableColumn(table1, SWT.NONE); tableColumn1.setText("Plugin-in"); tableColumn1.setWidth(200); } { tableColumn2 = new TableColumn(table1, SWT.NONE); tableColumn2.setText("Style"); tableColumn2.setWidth(315); } tv.setContentProvider(new PluginInfoContentProvider()); tv.setLabelProvider(new PluginInfoLabelProvider()); tv.setInput(LoaderServer.PluginInfo); table1.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int index = table1.getSelectionIndex(); PluginVo p = (PluginVo) tv.getElementAt(index); showPluginInfo(text1, p); } }); } button2LData.left = new FormAttachment(0, 1000, 383); button2LData.top = new FormAttachment(0, 1000, 220); button2LData.width = 57; button2LData.height = 23; button2.setLayoutData(button2LData); FormData button1LData = new FormData(); button1LData.left = new FormAttachment(0, 1000, 256); button1LData.top = new FormAttachment(0, 1000, 220); button1LData.width = 84; button1LData.height = 23; button1.setLayoutData(button1LData); Menu menu = new Menu(dialogShell, SWT.POP_UP); //table1.setMenu(menu); MenuItem item1 = new MenuItem(menu, SWT.PUSH); item1.setText("Detail"); item1.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { // TODO Auto-generated method stub int index = table1.getSelectionIndex(); PluginVo p = (PluginVo) tv.getElementAt(index); showPluginInfo(text1, p); } }); dialogShell.layout(); dialogShell.setSize(500, 480); dialogShell.setLocation(getParent().toDisplay(300, 50)); dialogShell.open(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:cn.dockerfoundry.ide.eclipse.explorer.ui.views.DockerContainersView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize * it.//from w w w. j av a2s .c o m */ public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData fileSelectionData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); composite.setLayoutData(fileSelectionData); GridLayout fileSelectionLayout = new GridLayout(); fileSelectionLayout.numColumns = 1; fileSelectionLayout.makeColumnsEqualWidth = false; fileSelectionLayout.marginWidth = 0; fileSelectionLayout.marginHeight = 0; composite.setLayout(fileSelectionLayout); final Text searchText = new Text(composite, SWT.BORDER | SWT.SEARCH); searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); viewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); // Layout the viewer GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.horizontalSpan = 1; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; viewer.getControl().setLayoutData(gridData); comparator = new DockerContainerViewerComparator(); viewer.setComparator(comparator); // New to support the search searchText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { searchFilter.setSearchString(searchText.getText()); viewer.refresh(); } }); searchFilter = new DockerContainerViewerFilter(); viewer.addFilter(searchFilter); table = viewer.getTable(); table.setLinesVisible(false); table.setHeaderVisible(true); createColumns(parent, viewer); getSite().setSelectionProvider(viewer); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "cn.dockerfoundry.ide.eclipse.explorer.ui.viewer"); makeActions(); hookContextMenu(); hookSingleClickAction(); hookDoubleClickAction(); contributeToActionBars(); }
From source file:cn.dockerfoundry.ide.eclipse.explorer.ui.views.DockerImagesView.java
License:Open Source License
/** * This is a callback that will allow us to create the viewer and initialize * it./* w w w. ja v a 2 s . c om*/ */ public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData fileSelectionData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); composite.setLayoutData(fileSelectionData); GridLayout fileSelectionLayout = new GridLayout(); fileSelectionLayout.numColumns = 1; fileSelectionLayout.makeColumnsEqualWidth = false; fileSelectionLayout.marginWidth = 0; fileSelectionLayout.marginHeight = 0; composite.setLayout(fileSelectionLayout); final Text searchText = new Text(composite, SWT.BORDER | SWT.SEARCH); searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); viewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); // Layout the viewer GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.horizontalSpan = 1; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; viewer.getControl().setLayoutData(gridData); comparator = new DockerImageViewerComparator(); viewer.setComparator(comparator); // New to support the search searchText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { searchFilter.setSearchString(searchText.getText()); viewer.refresh(); } }); searchFilter = new DockerImageViewerFilter(); viewer.addFilter(searchFilter); table = viewer.getTable(); table.setLinesVisible(false); table.setHeaderVisible(true); createColumns(parent, viewer); getSite().setSelectionProvider(viewer); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "cn.dockerfoundry.ide.eclipse.explorer.ui.viewer"); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
From source file:cn.dockerfoundry.ide.eclipse.explorer.ui.wizards.DockerSearchWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData fileSelectionData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); composite.setLayoutData(fileSelectionData); GridLayout fileSelectionLayout = new GridLayout(); fileSelectionLayout.numColumns = 3;//from w w w. jav a2 s . co m fileSelectionLayout.makeColumnsEqualWidth = false; fileSelectionLayout.marginWidth = 0; fileSelectionLayout.marginHeight = 0; composite.setLayout(fileSelectionLayout); setControl(composite); searchField = new Text(composite, SWT.SINGLE | SWT.BORDER); GridData layoutData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 2; searchField.setLayoutData(layoutData); goButton = new Button(composite, SWT.PUSH); goButton.setText("Search"); // layoutData = new GridData(GridData.GRAB_HORIZONTAL // | GridData.FILL_HORIZONTAL); // layoutData.horizontalSpan = 1; // goButton.setLayoutData(layoutData); goButton.setAlignment(SWT.RIGHT); goButton.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (getClient() != null) { String term = searchField.getText(); List<ImageSearchResult> result = new ArrayList<ImageSearchResult>(); try { AuthConfig authConfig = AuthConfig.builder().email("osswangxining@163.com") .username("osswangxining").password("").build(); result = getClient().searchImages(term); } catch (DockerException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(result.size()); viewer.setInput(result); viewer.refresh(true); } } @Override public void keyReleased(KeyEvent arg0) { keyPressed(arg0); } }); viewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); viewer.setContentProvider(new ViewContentProvider()); viewer.setLabelProvider(new ViewLabelProvider()); // Layout the viewer GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.horizontalSpan = 3; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; viewer.getControl().setLayoutData(gridData); table = viewer.getTable(); table.setLinesVisible(false); table.setHeaderVisible(true); createColumns(parent, viewer); composite.moveAbove(null); addListener(); }
From source file:cn.ieclipse.adt.ext.wizards.ElementTableSelector.java
License:Apache License
public ElementTableSelector(final Composite composite, GridData gridData, final String groupDescr, final String selectionMessage, final Object[] elements) { this.elements = elements; Group intentGroup = new Group(composite, SWT.NONE); intentGroup.setLayout(new GridLayout(2, false)); intentGroup.setLayoutData(gridData); intentGroup.setText(groupDescr);//ww w . j ava 2s . co m tv = new TableViewer(intentGroup, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION); table = tv.getTable(); table.setHeaderVisible(false); table.setLinesVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Menu menu = new Menu(tv.getControl()); MenuItem add = new MenuItem(menu, SWT.PUSH); add.setText("&Add Custom"); add.setImage(ADD_IMG); add.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { addModel(new Model("custom")); tv.refresh(); } }); MenuItem up = new MenuItem(menu, SWT.PUSH); up.setText("&Up"); up.setImage(UP_IMG); up.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Model m = (Model) sel.getFirstElement(); int idx = selectedElements.indexOf(m); if (idx > 0) { Model n = selectedElements.get(idx - 1); selectedElements.set(idx, n); selectedElements.set(idx - 1, m); tv.refresh(); } } } }); MenuItem down = new MenuItem(menu, SWT.PUSH); down.setText("&Down"); down.setImage(DOWN_IMG); down.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { Model m = (Model) sel.getFirstElement(); int idx = selectedElements.indexOf(m); if (idx < selectedElements.size() - 1) { Model n = selectedElements.get(idx + 1); selectedElements.set(idx, n); selectedElements.set(idx + 1, m); tv.refresh(); } } } }); table.setMenu(menu); tv.setContentProvider(new MyContentProvider()); ColumnViewerToolTipSupport.enableFor(tv, ToolTip.NO_RECREATE); // TableViewerFocusCellManager focusCellManager = new // TableViewerFocusCellManager( // tv, new FocusBorderCellHighlighter(tv)); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(tv) { protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; TableViewerEditor.create(tv, null, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); final TableViewerColumn col = new TableViewerColumn(tv, SWT.NONE); col.setLabelProvider(new MyCellLabelProvider()); col.setEditingSupport(new MyEditingSupport(tv)); // tv.getTable(). col.getColumn().setWidth(300); table.addControlListener(new ControlListener() { public void controlResized(ControlEvent e) { int w = table.getClientArea().width; if (w > 0) { col.getColumn().setWidth(w); } } public void controlMoved(ControlEvent e) { } }); tv.setInput(selectedElements); Composite buttonComp = new Composite(intentGroup, SWT.NONE); buttonComp.setLayout(new FillLayout(SWT.VERTICAL)); addButton = new Button(buttonComp, SWT.NONE); addButton.setText("Add..."); addButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { showSelectionDialog(composite, selectionMessage); } public void widgetDefaultSelected(SelectionEvent e) { } }); removeButton = new Button(buttonComp, SWT.NONE); removeButton.setText("Remove..."); removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int[] selection = table.getSelectionIndices(); if (selection != null) { IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); if (!sel.isEmpty()) { for (Object object : sel.toArray()) { selectedElements.remove(object); } } tv.refresh(); } } }); }
From source file:com.adobe.granite.ide.eclipse.ui.wizards.np.AdvancedSettingsComponent.java
License:Apache License
public void createAdvancedSection(Composite container) { Label label;//from ww w . j ava 2 s . c om GridData gd; label = new Label(container, SWT.NULL); label.setText("&Version:"); version = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); version.setLayoutData(gd); version.setText("0.0.1-SNAPSHOT"); version.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { wizardPage.dialogChanged(); } }); label = new Label(container, SWT.NULL); label.setText("&Package:"); javaPackage = new Text(container, SWT.BORDER | SWT.SINGLE); gd = new GridData(GridData.FILL_HORIZONTAL); javaPackage.setLayoutData(gd); javaPackageModified = false; javaPackage.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { javaPackageModified = true; } }); javaPackage.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { wizardPage.dialogChanged(); } }); label = new Label(container, SWT.NULL); gd = new GridData(SWT.LEFT, SWT.TOP, false, false); label.setLayoutData(gd); label.setText("&Parameters:"); propertiesViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); propertiesTable = propertiesViewer.getTable(); propertiesTable.setLinesVisible(true); propertiesTable.setHeaderVisible(true); propertiesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2)); CellNavigationStrategy strategy = new CellNavigationStrategy(); TableViewerFocusCellManager focusCellMgr = new TableViewerFocusCellManager(propertiesViewer, new FocusCellOwnerDrawHighlighter(propertiesViewer), strategy); ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy( propertiesViewer) { @Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; } }; int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK; TableViewerEditor.create(propertiesViewer, focusCellMgr, actSupport, features); TableColumn propertiesTableNameColumn = new TableColumn(propertiesTable, SWT.NONE); propertiesTableNameColumn.setWidth(180); propertiesTableNameColumn.setText("Name"); TableColumn propertiesTableValueColumn = new TableColumn(propertiesTable, SWT.NONE); propertiesTableValueColumn.setWidth(300); propertiesTableValueColumn.setText("Value"); propertiesViewer.setColumnProperties(new String[] { KEY_PROPERTY, VALUE_PROPERTY }); propertiesViewer.setCellEditors(new CellEditor[] { null /* cannot edit the name */, new TextCellEditor(propertiesTable, SWT.NONE) }); propertiesViewer.setCellModifier(new ICellModifier() { public boolean canModify(Object element, String property) { return true; } public void modify(Object element, String property, Object value) { if (element instanceof TableItem) { ((TableItem) element).setText(getTextIndex(property), String.valueOf(value)); wizardPage.dialogChanged(); } } public Object getValue(Object element, String property) { if (element instanceof TableItem) { return ((TableItem) element).getText(getTextIndex(property)); } return null; } }); }
From source file:com.aerospike.aql.plugin.views.ResultView.java
License:Apache License
/** * This is a callback that will allow us * to create the viewer and initialize it. *//*from w w w . j a va 2s. c o m*/ public void createPartControl(Composite parent) { SashForm sashForm = new SashForm(parent, SWT.NONE); sashForm.setOrientation(SWT.VERTICAL); messageText = new Text(sashForm, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI); messageText.setLayoutData(new GridData(GridData.FILL_BOTH)); recordTableViewer = new TableViewer(sashForm, SWT.BORDER | SWT.FULL_SELECTION); recordTable = recordTableViewer.getTable(); recordTable.setLinesVisible(true); recordTable.setHeaderVisible(true); recordTable.setBounds(0, 0, 18, 81); TableViewerColumn recordTTLColumn = new TableViewerColumn(recordTableViewer, SWT.NONE); TableColumn tblclmnTtl = recordTTLColumn.getColumn(); tblclmnTtl.setWidth(100); tblclmnTtl.setText("TTL"); TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(recordTableViewer, SWT.NONE); TableColumn tblclmnGeneration = tableViewerColumn_1.getColumn(); tblclmnGeneration.setWidth(100); tblclmnGeneration.setText("Generation"); sashForm.setWeights(new int[] { 3, 20 }); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); }
From source file:com.agynamix.simidude.clipboard.ClipboardTable.java
License:Open Source License
private TableViewer createTableViewer(final Composite parent) { tableParent = parent;// w ww . j ava 2 s. co m final TableViewer tableViewer = new TableViewer(tableParent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.FLAT | SWT.BORDER | SWT.V_SCROLL); tableViewer.getTable().setLinesVisible(true); tableViewer.getTable().setHeaderVisible(false); ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); final OptimizedIndexSearcher searcher = new OptimizedIndexSearcher(); itemColumn = new TableViewerColumn(tableViewer, SWT.LEFT, NAME_COL); itemColumn.getColumn().setText("Item"); itemColumn.setLabelProvider(new ColumnLabelProvider() { boolean even = true; Color oddColor = null; @Override public String getText(Object element) { String text = ""; IClipboardItem item = (IClipboardItem) element; text = item.getShortDescription(); return text; } @Override /** * Display an icon depending of the type of clipboard entry. */ public Image getImage(Object element) { return ((IClipboardItem) element).getImage(); } public Color getBackground(Object element) { if (even) { return null; } else { if (oddColor == null) { oddColor = PlatformColors.get(PlatformColors.TRANSFER_TABLE_ALT_COLOR); } return oddColor; } } public String getToolTipText(Object element) { IClipboardItem item = (IClipboardItem) element; return item.getTooltip(); } public Point getToolTipShift(Object object) { return new Point(5, 5); } public int getToolTipDisplayDelayTime(Object object) { return 200; } public int getToolTipTimeDisplayed(Object object) { return 10000; } public void update(ViewerCell cell) { even = searcher.isEven((TableItem) cell.getItem()); super.update(cell); } }); tableViewer.setContentProvider(new ClipboardTableContentProvider()); // tableViewer.setLabelProvider(new ClipboardTableLabelProvider()); tableParent.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { adjustTableSize(); } }); tableViewer.getTable().setMenu(createPopupMenu(tableViewer)); hookListeners(tableViewer); return tableViewer; }