org.eclipse.swt.widgets.TableColumn Java Examples
The following examples show how to use
org.eclipse.swt.widgets.TableColumn.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelationByExistingColumnsDialog.java From ermaster-b with Apache License 2.0 | 6 votes |
private void createComparisonTable(Composite composite) { GridData tableGridData = new GridData(); tableGridData.horizontalSpan = 2; tableGridData.heightHint = 100; tableGridData.horizontalAlignment = GridData.FILL; tableGridData.grabExcessHorizontalSpace = true; this.comparisonTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); this.comparisonTable.setLayoutData(tableGridData); this.comparisonTable.setHeaderVisible(true); this.comparisonTable.setLinesVisible(true); TableColumn referencedColumn = new TableColumn(this.comparisonTable, SWT.NONE); referencedColumn.setWidth(COLUMN_WIDTH); referencedColumn.setText(ResourceString .getResourceString("label.reference.column")); TableColumn foreignKeyColumn = new TableColumn(this.comparisonTable, SWT.NONE); foreignKeyColumn.setWidth(COLUMN_WIDTH); foreignKeyColumn.setText(ResourceString .getResourceString("label.foreign.key")); }
Example #2
Source File: IndexTabWrapper.java From ermasterr with Apache License 2.0 | 6 votes |
private void initTable(final Composite parent) { final GridData gridData = new GridData(); gridData.horizontalSpan = 3; gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; gridData.heightHint = 200; indexTable = new Table(parent, SWT.BORDER | SWT.HIDE_SELECTION); indexTable.setHeaderVisible(true); indexTable.setLayoutData(gridData); indexTable.setLinesVisible(true); CompositeFactory.createTableColumn(indexTable, "label.column.name", -1); final TableColumn separatorColumn = CompositeFactory.createTableColumn(indexTable, "", 3); separatorColumn.setResizable(false); }
Example #3
Source File: UsersWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void addUserNameColumn(final StructuredViewer viewer) { final TableViewerColumn column = new TableViewerColumn((TableViewer) viewer, SWT.FILL); final TableColumn usernameColumn = column.getColumn(); column.getColumn().setText(Messages.userName); column.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(final Object element) { return ((User) element).getUserName(); } }); column.getColumn().setWidth(90); column.getColumn().setMoveable(false); column.getColumn().setResizable(true); final TableColumnSorter sorter = new TableColumnSorter((TableViewer) viewer); sorter.setColumn(usernameColumn); }
Example #4
Source File: TBXMakerDialog.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 设置列属性 ; */ private void setColumnType() { if (cols < 2) { MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"), Messages.getString("dialog.TBXMakerDialog.msg2")); return; } Vector<ColProperties> colTypes = new Vector<ColProperties>(cols); for (int i = 0; i < cols; i++) { colTypes.add((ColProperties) table.getColumn(i).getData()); } ColumnTypeDialog selector = new ColumnTypeDialog(getShell(), colTypes, template, imagePath); if (selector.open() == IDialogConstants.OK_ID) { for (int i = 0; i < cols; i++) { TableColumn col = table.getColumn(i); ColProperties type = colTypes.get(i); if (!type.getColName().equals("") && !type.getLanguage().equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ col.setText(type.getColName()); } } } }
Example #5
Source File: SWTTable.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public void adjustColumnWidth(TableColumn column) { int minimumWidth = 0; String headerText = column.getText(); if( headerText != null && headerText.length() > 0 ) { GC gc = new GC(this.getControl()); minimumWidth = (gc.stringExtent(headerText).x + (TABLE_COLUMN_MARGIN * 2)); gc.dispose(); } column.pack(); if( column.getWidth() < minimumWidth ) { column.setWidth(minimumWidth); } }
Example #6
Source File: AbstractSegmentStoreTableViewer.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
private void addPackListener() { getControl().addListener(SWT.SetData, new Listener() { @Override public void handleEvent(@Nullable Event event) { // Remove the listener before the pack getControl().removeListener(SWT.SetData, this); // Pack the column the first time data is set TableViewer tableViewer = getTableViewer(); if (tableViewer != null) { for (TableColumn col : tableViewer.getTable().getColumns()) { col.pack(); } } } }); }
Example #7
Source File: NodeKindTableControl.java From depan with Apache License 2.0 | 6 votes |
private void setSortColumn( TableColumn column, int colIndex, int direction) { ITableLabelProvider labelProvider = (ITableLabelProvider) kindViewer.getLabelProvider(); ViewerComparator sorter = new AlphabeticSorter( new LabelProviderToString(labelProvider, colIndex)); if (SWT.UP == direction) { sorter = new InverseSorter(sorter); } Table tableControl = (Table) kindViewer.getControl(); kindViewer.setComparator(sorter); tableControl.setSortColumn(column); tableControl.setSortDirection(direction); }
Example #8
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Pack the columns. * * @return true if this is the first call to pack columns * * @since 2.0 */ protected boolean packColumns() { boolean packDone = fPackDone; fTable.setRedraw(false); try { int horizontalPos = fTable.getHorizontalBar().getSelection(); TableColumn tableColumns[] = fTable.getColumns(); for (int i = 0; i < tableColumns.length; i++) { final TableColumn column = tableColumns[i]; if (Objects.equals(column.getData(Key.WIDTH), SWT.DEFAULT)) { packSingleColumn(i, column); } } if (!IS_WIN32) { /* Bug 410369: Cannot programmatically scroll on Windows */ fTable.getHorizontalBar().setSelection(horizontalPos); } } finally { // Make sure that redraw is always enabled. fTable.setRedraw(true); } fPackDone = true; return !packDone; }
Example #9
Source File: TableCombo.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Defines what columns the drop down table will have. * @param columnHeaders * @param columnBounds */ private void defineColumnsInternal(String[] columnHeaders, int[] columnBounds, int totalColumnsToBeCreated) { checkWidget(); int totalColumnHeaders = columnHeaders == null ? 0 : columnHeaders.length; int totalColBounds = columnBounds == null ? 0 : columnBounds.length; if (totalColumnsToBeCreated > 0) { for (int index = 0; index < totalColumnsToBeCreated; index++) { TableColumn column = new TableColumn(table, SWT.NONE); if (index < totalColumnHeaders) { column.setText(columnHeaders[index]); } if (index < totalColBounds) { column.setWidth(columnBounds[index]); } column.setResizable(true); column.setMoveable(true); } } }
Example #10
Source File: MedicationViewerHelper.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static TableViewerColumn createDosageColumn(TableViewer viewer, TableColumnLayout layout, int columnIndex){ TableViewerColumn ret = new TableViewerColumn(viewer, SWT.NONE); ret.setLabelProvider(new MedicationCellLabelProvider() { @Override public String getText(Object element){ MedicationTableViewerItem pres = (MedicationTableViewerItem) element; String dosis = pres.getDosis(); return (dosis.equals(StringConstants.ZERO) ? Messages.MedicationComposite_stopped : dosis); } }); TableColumn tblclmnDosage = ret.getColumn(); tblclmnDosage.setToolTipText(Messages.TherapieplanComposite_tblclmnDosage_toolTipText); tblclmnDosage.addSelectionListener(getSelectionAdapter(viewer, tblclmnDosage, columnIndex)); layout.setColumnData(tblclmnDosage, new ColumnPixelData(60, true, true)); ret.getColumn().setText(Messages.TherapieplanComposite_tblclmnDosage_text); return ret; }
Example #11
Source File: EnhancedTableViewer.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Saves the sorting state to the dialog settings. */ private void saveState() { IDialogSettings settings = mSettingsProvider != null ? mSettingsProvider.getTableSettings() : null; if (settings == null) { return; } settings.put(TAG_COLUMN_INDEX, mSortedColumnIndex); settings.put(TAG_SORT_DIRECTION, mSortDirection); // store the column widths TableColumn[] columns = this.getTable().getColumns(); for (int i = 0, size = columns.length; i < size; i++) { int width = columns[i].getWidth(); if (width > 0) { settings.put(TAG_COLUMN_WIDTH + i, width); } } // store the selection settings.put(TAG_CURRENT_SELECTION, this.getTable().getSelectionIndex()); }
Example #12
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Returns true if the column is expanded to take extra available space. * This is the last non-zero-width visible column in the column order on * Linux. This column's width should not be persisted. * * @param column * the column * @return true if the column is expanded. */ private static boolean isExpanded(TableColumn column) { if (IS_LINUX) { Table table = column.getParent(); int[] order = table.getColumnOrder(); for (int i = order.length - 1; i >= 0; i--) { TableColumn col = table.getColumn(order[i]); if (col == column) { return true; } if (col.getWidth() > 0) { return false; } } } return false; }
Example #13
Source File: MedicationViewerHelper.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static TableViewerColumn createStopColumn(TableViewer viewer, TableColumnLayout layout, int columnIndex){ TableViewerColumn ret = new TableViewerColumn(viewer, SWT.CENTER); TableColumn tblclmnStop = ret.getColumn(); ColumnPixelData stopColumnPixelData = new ColumnPixelData(60, true, true); layout.setColumnData(tblclmnStop, stopColumnPixelData); tblclmnStop.setImage(Images.resize(Images.IMG_ARROWSTOP_WO_SHADOW.getImage(), ImageSize._12x12_TableColumnIconSize)); tblclmnStop.setToolTipText(Messages.MedicationComposite_column_sortBy + " " + Messages.MedicationComposite_column_endDate); tblclmnStop.addSelectionListener(getSelectionAdapter(viewer, tblclmnStop, columnIndex)); ret.setLabelProvider(new MedicationCellLabelProvider() { @Override public String getText(Object element){ MedicationTableViewerItem pres = (MedicationTableViewerItem) element; if (pres.getEntryType() != EntryType.RECIPE && pres.getEntryType() != EntryType.SELF_DISPENSED) { return pres.getEndDate(); } return ""; } }); return ret; }
Example #14
Source File: HistoryTableProvider.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void setColumnWidth(TableLayout layout, DisposeListener disposeListener, TableColumn col, int defaultWidth) { String columnWidth = null; if (id != null) columnWidth = settings.get("HistoryTableProvider." + id + "." + col.getText()); //$NON-NLS-1$ //$NON-NLS-1$ if (columnWidth == null || columnWidth.equals("0")) layout.addColumnData(new ColumnWeightData(defaultWidth, true)); //$NON-NLS-1$ else layout.addColumnData(new ColumnPixelData(Integer.parseInt(columnWidth), true)); if (id != null) col.addDisposeListener(disposeListener); }
Example #15
Source File: EnvironmentVariablesTable.java From Eclipse-Environment-Variables with MIT License | 5 votes |
private TableColumn createColumn(final Table table, final TableColumnLayout columnLayout, final String text) { final TableColumn column = new TableColumn(table, SWT.NONE); column.setText(text); column.setMoveable(true); columnLayout.setColumnData(column, new ColumnWeightData(50, true)); return column; }
Example #16
Source File: DefinesViewer.java From cmake4eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Creates a table viewer column for the table. */ private TableViewerColumn createTableViewerColumn(final TableViewer viewer, String title, int colWidth, final int colNumber) { final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = viewerColumn.getColumn(); column.setText(title); column.setWidth(colWidth); column.setResizable(true); column.setMoveable(true); column.addSelectionListener(createSelectionAdapter(column, colNumber)); return viewerColumn; }
Example #17
Source File: TableViewerSorter.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void tableColumnClicked(TableColumn column){ Table table = column.getParent(); if (column.equals(table.getSortColumn())) { table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP); } else { table.setSortColumn(column); table.setSortDirection(SWT.UP); } tableViewer.refresh(); }
Example #18
Source File: TableView.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private String getSelectedText() { String selection = ""; for ( int c = 1; c < table.getColumnCount(); c++ ) { TableColumn tc = table.getColumn( c ); if ( c > 1 ) { selection += CLIPBOARD_DELIMITER; } selection += tc.getText(); } selection += Const.CR; TableItem[] items = table.getSelection(); if ( items.length == 0 ) { return null; } for ( int r = 0; r < items.length; r++ ) { TableItem ti = items[r]; for ( int c = 1; c < table.getColumnCount(); c++ ) { if ( c > 1 ) { selection += CLIPBOARD_DELIMITER; } selection += ti.getText( c ); } selection += Const.CR; } return selection; }
Example #19
Source File: ExpressionCollectionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void updateColumns() { editingSupports.clear(); for (final TableColumn c : viewer.getTable().getColumns()) { c.dispose(); } if (getNbRows() > 0) { for (int i = 0; i < Math.max(minNbCol, getNbCols()); i++) { addColumnToViewer(i); } refresh(); } }
Example #20
Source File: BlockTableViewer.java From offspring with MIT License | 5 votes |
private void createColumns() { for (int id : BlockTable.getColumns()) { TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE); TableColumn column = viewerColumn.getColumn(); viewerColumn.setLabelProvider(BlockTable.createLabelProvider(id)); column.setText(BlockTable.getColumnLabel(id)); column.setAlignment(BlockTable.getColumnAlignment(id)); column.setResizable(BlockTable.getColumnResizable(id)); column.setWidth(BlockTable.getColumnWidth(id)); } }
Example #21
Source File: IndexTabWrapper.java From ermaster-b with Apache License 2.0 | 5 votes |
public void restruct() { this.clearButtonAndEditor(); while (this.indexTable.getColumnCount() > 2) { TableColumn tableColumn = this.indexTable.getColumn(2); tableColumn.dispose(); } this.indexTable.removeAll(); this.resutuctIndexData(); this.setTableData(); }
Example #22
Source File: Snippet1.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static Print createPrint(Table table) { // Create GridPrint with all columns at default size. DefaultGridLook look = new DefaultGridLook(); look.setCellBorder(new LineBorder()); RGB background = table.getDisplay() .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB(); look.setHeaderBackground(background); look.setFooterBackground(background); GridPrint grid = new GridPrint(look); // Add header and footer to match table column names. TableColumn[] columns = table.getColumns(); for (int i = 0; i < columns.length; i++) { TableColumn col = columns[i]; // Add the column to the grid with alignment applied, default width, // no // weight grid.addColumn(new GridColumn(col.getAlignment(), SWT.DEFAULT, 0)); Print cell = createCell(col.getImage(), col.getText(), SWT.CENTER); grid.addHeader(cell); grid.addFooter(cell); } // Add content rows TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableItem item = items[i]; for (int j = 0; j < columns.length; j++) grid.add(createCell(item.getImage(j), item.getText(j), columns[j].getAlignment())); } return grid; }
Example #23
Source File: TableColumnSorter.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void widgetSelected(SelectionEvent e) { TableColumnSorter sorter = (TableColumnSorter) TableColumnSorter.this.viewer.getComparator(); Assert.isTrue(TableColumnSorter.this == sorter); TableColumn selectedColumn = (TableColumn) e.widget; Assert.isTrue(TableColumnSorter.this.viewer.getTable() == selectedColumn.getParent()); TableColumnSorter.this.setColumn(selectedColumn); }
Example #24
Source File: GenerericTableViewer.java From offspring with MIT License | 5 votes |
private SelectionAdapter getSelectionAdapter(final TableColumn column, final IGenericTableColumn c) { SelectionAdapter selectionAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { comparator.setColumn(c); int dir = comparator.getDirection(); getTable().setSortDirection(dir); getTable().setSortColumn(column); refresh(); } }; return selectionAdapter; }
Example #25
Source File: XPathExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) { mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(new GridLayout(2, true)); viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); final TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(100, false)); viewer.getTable().setLayout(layout); viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = columnViewer.getColumn(); column.setText(Messages.name); final TableColumnSorter sorter = new TableColumnSorter(viewer); sorter.setColumn(column); viewer.getTable().setHeaderVisible(true); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new DataStyledTreeLabelProvider()); viewer.addPostSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { if (!event.getSelection().isEmpty()) { xsdViewer.expandAll(); XPathExpressionEditor.this.fireSelectionChanged(); } } }); createXPathChooser(mainComposite); createReturnTypeComposite(parent); return mainComposite; }
Example #26
Source File: TestDataDialog.java From ermasterr with Apache License 2.0 | 5 votes |
private void createSelectedTableTable(final Composite composite) { final GridData gridData = new GridData(); gridData.verticalSpan = 2; gridData.grabExcessVerticalSpace = true; gridData.verticalAlignment = GridData.FILL; final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; final Group group = new Group(composite, SWT.NONE); group.setText(ResourceString.getResourceString("label.testdata.table.list")); group.setLayout(gridLayout); group.setLayoutData(gridData); final GridData tableGridData = new GridData(); tableGridData.grabExcessVerticalSpace = true; tableGridData.verticalAlignment = GridData.FILL; tableGridData.widthHint = 300; tableGridData.verticalSpan = 2; selectedTableTable = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI); selectedTableTable.setHeaderVisible(false); selectedTableTable.setLayoutData(tableGridData); selectedTableTable.setLinesVisible(false); final TableColumn tableColumn = new TableColumn(selectedTableTable, SWT.CENTER); tableColumn.setWidth(200); tableColumn.setText(ResourceString.getResourceString("label.testdata.table.name")); final TableColumn numColumn = new TableColumn(selectedTableTable, SWT.CENTER); numColumn.setWidth(80); numColumn.setText(ResourceString.getResourceString("label.testdata.table.test.num")); }
Example #27
Source File: ExternalizeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Control createTable(Composite parent) { Composite c= new Composite(parent, SWT.NONE); GridLayout gl= new GridLayout(); gl.numColumns= 2; gl.marginWidth= 0; gl.marginHeight= 0; c.setLayout(gl); fTable= new Table(c, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.BORDER); fTable.setFont(parent.getFont()); GridData tableGD= new GridData(GridData.FILL_BOTH); tableGD.heightHint= SWTUtil.getTableHeightHint(fTable, ROW_COUNT); //tableGD.widthHint= 40; fTable.setLayoutData(tableGD); fTable.setLinesVisible(true); TableLayout layout= new TableLayout(); fTable.setLayout(layout); fTable.setHeaderVisible(true); ColumnLayoutData[] columnLayoutData= new ColumnLayoutData[SIZE]; columnLayoutData[STATE_PROP]= new ColumnPixelData(18, false, true); columnLayoutData[KEY_PROP]= new ColumnWeightData(40, true); columnLayoutData[VAL_PROP]= new ColumnWeightData(40, true); for (int i= 0; i < fgTitles.length; i++) { TableColumn tc= new TableColumn(fTable, SWT.NONE, i); tc.setText(fgTitles[i]); layout.addColumnData(columnLayoutData[i]); tc.setResizable(columnLayoutData[i].resizable); } createButtonComposite(c); return c; }
Example #28
Source File: SortTableColumnSelectionListener.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected Table getParent(SelectionEvent e) { // 1) Get table column which fire this selection event TableColumn tableColumn = (TableColumn) e.getSource(); // 2) Get the owner table return tableColumn.getParent(); }
Example #29
Source File: AllRenderersPaginationTableAtHandExample.java From nebula with Eclipse Public License 2.0 | 5 votes |
private static TableViewerColumn createTableViewerColumn( TableViewer viewer, String title, int bound) { final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); final TableColumn column = viewerColumn.getColumn(); column.setText(title); column.setWidth(bound); column.setResizable(true); column.setMoveable(true); return viewerColumn; }
Example #30
Source File: SWTTable.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void setColumnName(int column, String name) { if( column >= 0 && column < this.getColumns() ) { this.getControl().setHeaderVisible(true); TableColumn tableColumn = this.getControl().getColumn(column); tableColumn.setText(name); if( this.isVisible() ) { this.updateManager.setUpdateRequired(); } } }