Java Code Examples for org.eclipse.swt.widgets.Table#setLayoutData()
The following examples show how to use
org.eclipse.swt.widgets.Table#setLayoutData() .
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: 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 2
Source File: HistoryFilteredList.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Constructs a new filtered list. * * @param parent * the parent composite * @param style * the widget style * @param labelProvider * the label renderer * @param ignoreCase * specifies whether sorting and folding is case sensitive * @param allowDuplicates * specifies whether folding of duplicates is desired * @param matchEmptyString * specifies whether empty filter strings should filter * everything or nothing */ public HistoryFilteredList(Composite parent, int style, ILabelProvider labelProvider, boolean ignoreCase, boolean allowDuplicates, boolean matchEmptyString) { super(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; setLayout(layout); fList = new Table(this, style); fList.setLayoutData(new GridData(GridData.FILL_BOTH)); fList.setFont(parent.getFont()); fList.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { fLabelProvider.dispose(); if (fUpdateJob != null) { fUpdateJob.cancel(); } } }); fLabelProvider = labelProvider; fIgnoreCase = ignoreCase; fAllowDuplicates = allowDuplicates; fMatchEmptyString = matchEmptyString; }
Example 3
Source File: CompositeFactory.java From ermasterr with Apache License 2.0 | 5 votes |
public static Table createTable(final Composite parent, final int height) { final GridData gridData = new GridData(); gridData.heightHint = height; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; final Table table = new Table(parent, SWT.FULL_SELECTION | SWT.BORDER); table.setHeaderVisible(true); table.setLayoutData(gridData); table.setLinesVisible(false); return table; }
Example 4
Source File: RepositorySelectionPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Creates the table for the repositories */ protected TableViewer createTable(Composite parent, int span) { Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); data.horizontalSpan = span; table.setLayoutData(data); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(100, true)); table.setLayout(layout); TableColumn col = new TableColumn(table, SWT.NONE); col.setResizable(true); return new TableViewer(table); }
Example 5
Source File: KeyAssistDialog.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Creates a dialog area with a table of the partial matches for the current * key binding state. The table will be either the minimum width, or * <code>previousWidth</code> if it is not * <code>NO_REMEMBERED_WIDTH</code>. * * @param parent * The parent composite for the dialog area; must not be * <code>null</code>. * @param partialMatches * The lexicographically sorted map of partial matches for the * current state; must not be <code>null</code> or empty. */ private final void createTableDialogArea(final Composite parent) { // Layout the table. completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE); final GridData gridData = new GridData(GridData.FILL_BOTH); completionsTable.setLayoutData(gridData); completionsTable.setBackground(parent.getBackground()); completionsTable.setLinesVisible(true); // Initialize the columns and rows. bindings.clear(); final TableColumn columnCommandName = new TableColumn(completionsTable, SWT.LEFT, 0); final TableColumn columnKeySequence = new TableColumn(completionsTable, SWT.LEFT, 1); final Iterator itemsItr = keybindingToActionInfo.entrySet().iterator(); while (itemsItr.hasNext()) { final Map.Entry entry = (Entry) itemsItr.next(); final String sequence = (String) entry.getKey(); final ActionInfo actionInfo = (ActionInfo) entry.getValue(); final String[] text = { sequence, actionInfo.description }; final TableItem item = new TableItem(completionsTable, SWT.NULL); item.setText(text); item.setData("ACTION_INFO", actionInfo); bindings.add(actionInfo); } Dialog.applyDialogFont(parent); columnKeySequence.pack(); columnCommandName.pack(); /* * If you double-click on the table, it should execute the selected * command. */ completionsTable.addListener(SWT.DefaultSelection, new Listener() { @Override public final void handleEvent(final Event event) { executeKeyBinding(event); } }); }
Example 6
Source File: TBXMakerDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { Composite tparent = (Composite) super.createDialogArea(parent); // tparent.setLayout(new GridLayout()); GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent); GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent); createMenu(); createToolBar(tparent); table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite cmpStatus = new Composite(tparent, SWT.BORDER); cmpStatus.setLayout(new GridLayout(2, true)); cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); lblRowCount = new Label(cmpStatus, SWT.None); lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), 0)); lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); lblColCount = new Label(cmpStatus, SWT.None); lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), 0)); lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); tparent.layout(); getShell().layout(); return tparent; }
Example 7
Source File: InterfacesComponentProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new interfaces component inside the parent composite using the given model. * * @param interfacesContainingModel * A interface containing model * @param container * The component container */ public InterfacesComponent(InterfacesContainingModel interfacesContainingModel, WizardComponentContainer container) { super(container); this.model = interfacesContainingModel; Composite parent = getParentComposite(); Label interfacesLabel = new Label(parent, SWT.NONE); GridData interfacesLabelGridData = fillLabelDefaults(); interfacesLabelGridData.verticalAlignment = SWT.TOP; interfacesLabel.setLayoutData(interfacesLabelGridData); interfacesLabel.setText("Interfaces:"); interfacesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL); interfacesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite interfacesButtonsComposite = new Composite(parent, SWT.NONE); interfacesButtonsComposite.setLayoutData(GridDataFactory.fillDefaults().create()); interfacesButtonsComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).create()); interfacesAddButton = new Button(interfacesButtonsComposite, SWT.NONE); interfacesAddButton.setText("Add..."); interfacesAddButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); interfacesRemoveButton = new Button(interfacesButtonsComposite, SWT.NONE); interfacesRemoveButton.setText("Remove"); interfacesRemoveButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); setupBindings(); }
Example 8
Source File: EdgeMatcherTableControl.java From depan with Apache License 2.0 | 5 votes |
public EdgeMatcherTableControl(Composite parent) { super(parent, SWT.NONE); setLayout(Widgets.buildContainerLayout(1)); viewer = new TableViewer(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); // Layout embedded table Table relationTable = viewer.getTable(); relationTable.setLayoutData(Widgets.buildGrabFillData()); // initialize the table relationTable.setHeaderVisible(true); relationTable.setToolTipText("Edge Matcher Definition"); EditColTableDef.setupTable(TABLE_DEF, relationTable); CellEditor[] cellEditors = new CellEditor[TABLE_DEF.length]; cellEditors[INDEX_RELATION] = null; cellEditors[INDEX_FORWARD] = new CheckboxCellEditor(relationTable); cellEditors[INDEX_BACKWARD] = new CheckboxCellEditor(relationTable); // cell content viewer.setCellEditors(cellEditors); viewer.setLabelProvider(new CellLabelProvider()); viewer.setColumnProperties(EditColTableDef.getProperties(TABLE_DEF)); viewer.setCellModifier(new CellModifier()); viewer.setContentProvider(ArrayContentProvider.getInstance()); viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() { @Override public String getString(Object object) { if (object instanceof Relation) { return ((Relation) object).toString(); } return object.toString(); } })); }
Example 9
Source File: CategoryManageDialog.java From ermasterr with Apache License 2.0 | 5 votes |
private void createNodeGroup(final Composite composite) { final Group group = new Group(composite, SWT.NONE); group.setLayout(new GridLayout()); group.setText(ResourceString.getResourceString("label.category.object.message")); final GridData gridData = new GridData(); gridData.heightHint = GROUP_HEIGHT; group.setLayoutData(gridData); CompositeFactory.fillLine(group, 5); final GridData tableGridData = new GridData(); tableGridData.grabExcessVerticalSpace = true; tableGridData.verticalAlignment = GridData.FILL; nodeTable = new Table(group, SWT.BORDER | SWT.HIDE_SELECTION); nodeTable.setHeaderVisible(true); nodeTable.setLayoutData(tableGridData); nodeTable.setLinesVisible(true); final TableColumn tableColumn2 = new TableColumn(nodeTable, SWT.NONE); tableColumn2.setWidth(30); tableColumn2.setResizable(false); tableColumn2.setText(""); final TableColumn tableColumn3 = new TableColumn(nodeTable, SWT.NONE); tableColumn3.setWidth(80); tableColumn3.setResizable(false); tableColumn3.setText(ResourceString.getResourceString("label.object.type")); final TableColumn tableColumn4 = new TableColumn(nodeTable, SWT.NONE); tableColumn4.setWidth(200); tableColumn4.setResizable(false); tableColumn4.setText(ResourceString.getResourceString("label.object.name")); }
Example 10
Source File: TBXMakerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { Composite tparent = (Composite) super.createDialogArea(parent); // tparent.setLayout(new GridLayout()); GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent); GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent); createMenu(); createToolBar(tparent); table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite cmpStatus = new Composite(tparent, SWT.BORDER); cmpStatus.setLayout(new GridLayout(2, true)); cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); lblRowCount = new Label(cmpStatus, SWT.None); lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblRowCount"), 0)); lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); lblColCount = new Label(cmpStatus, SWT.None); lblColCount.setText(MessageFormat.format(Messages.getString("dialog.TBXMakerDialog.lblColCount"), 0)); lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); tparent.layout(); getShell().layout(); return tparent; }
Example 11
Source File: CSV2TMXConverterDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { Composite tparent = (Composite) super.createDialogArea(parent); GridLayoutFactory.swtDefaults().spacing(0, 0).numColumns(1).applyTo(tparent); GridDataFactory.fillDefaults().hint(750, 500).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tparent); createMenu(); createToolBar(tparent); table = new Table(tparent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite cmpStatus = new Composite(tparent, SWT.BORDER); cmpStatus.setLayout(new GridLayout(2, true)); cmpStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); lblRowCount = new Label(cmpStatus, SWT.None); lblRowCount.setText(MessageFormat.format(Messages.getString("dialog.CSV2TMXConverterDialog.lblRowCount"), 0)); lblRowCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); lblColCount = new Label(cmpStatus, SWT.None); lblColCount.setText(MessageFormat.format(Messages.getString("dialog.CSV2TMXConverterDialog.lblColCount"), 0)); lblColCount.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); tparent.layout(); getShell().layout(); return tparent; }
Example 12
Source File: CrosstabSortKeyBuilder.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void createMemberValuesGroup( Composite content ) { group = new Group( content, SWT.NONE ); group.setText( Messages.getString( "CrosstabSortKeyBuilder.Label.SelColumnMemberValue" ) ); //$NON-NLS-1$ group.setLayout( new GridLayout( ) ); memberValueTable = new Table( group, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION ); memberValueTable.setLinesVisible( true ); memberValueTable.setHeaderVisible( true ); memberValueTable.setLayoutData( new GridData( GridData.FILL_BOTH ) ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.heightHint = 150; gd.horizontalSpan = 3; group.setLayoutData( gd ); dynamicViewer = new TableViewer( memberValueTable ); TableColumn column = new TableColumn( memberValueTable, SWT.LEFT ); column.setText( columns[0] ); column.setWidth( 15 ); TableColumn column1 = new TableColumn( memberValueTable, SWT.LEFT ); column1.setResizable( columns[1] != null ); if ( columns[1] != null ) { column1.setText( columns[1] ); } column1.setWidth( 200 ); TableColumn column2 = new TableColumn( memberValueTable, SWT.LEFT ); column2.setResizable( columns[2] != null ); if ( columns[2] != null ) { column2.setText( columns[2] ); } column2.setWidth( 200 ); dynamicViewer.setColumnProperties( columns ); editor = new ExpressionValueCellEditor( dynamicViewer.getTable( ), SWT.READ_ONLY ); TextCellEditor textEditor = new TextCellEditor( dynamicViewer.getTable( ), SWT.READ_ONLY ); TextCellEditor textEditor2 = new TextCellEditor( dynamicViewer.getTable( ), SWT.READ_ONLY ); CellEditor[] cellEditors = new CellEditor[]{ textEditor, textEditor2, editor }; if ( handle != null ) { editor.setExpressionProvider( new ExpressionProvider( handle ) ); editor.setReportElement( (ExtendedItemHandle) handle ); } dynamicViewer.setCellEditors( cellEditors ); dynamicViewer.setContentProvider( contentProvider ); dynamicViewer.setLabelProvider( labelProvider ); dynamicViewer.setCellModifier( cellModifier ); dynamicViewer.addSelectionChangedListener( selectionChangeListener ); }
Example 13
Source File: ResolvablePropertiesDialog.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates the dialogs main contents. * * @param parent * the parent composite */ @Override protected Control createDialogArea(Composite parent) { // set the logo this.setTitleImage(CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.PLUGIN_LOGO)); this.setTitle(Messages.ResolvablePropertiesDialog_titleMessageArea); this.setMessage(Messages.ResolvablePropertiesDialog_msgAdditionalProperties); Composite composite = (Composite) super.createDialogArea(parent); Composite contents = new Composite(composite, SWT.NULL); contents.setLayout(new GridLayout(2, false)); GridData fd = new GridData(GridData.FILL_BOTH); contents.setLayoutData(fd); Table table = new Table(contents, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); table.setLayoutData(new GridData(GridData.FILL_BOTH)); table.setHeaderVisible(true); table.setLinesVisible(true); TableLayout tableLayout = new TableLayout(); table.setLayout(tableLayout); TableColumn column1 = new TableColumn(table, SWT.NULL); column1.setText(Messages.ResolvablePropertiesDialog_colName); tableLayout.addColumnData(new ColumnWeightData(50)); TableColumn column2 = new TableColumn(table, SWT.NULL); column2.setText(Messages.ResolvablePropertiesDialog_colValue); tableLayout.addColumnData(new ColumnWeightData(50)); mTableViewer = new EnhancedTableViewer(table); PropertiesLabelProvider multiProvider = new PropertiesLabelProvider(); mTableViewer.setLabelProvider(multiProvider); mTableViewer.setTableComparableProvider(multiProvider); mTableViewer.setTableSettingsProvider(multiProvider); mTableViewer.installEnhancements(); mTableViewer.setContentProvider(new ArrayContentProvider()); mTableViewer.addDoubleClickListener(mController); mTableViewer.getTable().addKeyListener(mController); Composite buttonBar = new Composite(contents, SWT.NULL); GridLayout layout = new GridLayout(1, false); layout.marginHeight = 0; layout.marginWidth = 0; buttonBar.setLayout(layout); GridData gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; buttonBar.setLayoutData(gd); mBtnAdd = new Button(buttonBar, SWT.PUSH); mBtnAdd.setText(Messages.ResolvablePropertiesDialog_btnAdd); mBtnAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mBtnAdd.addSelectionListener(mController); mBtnEdit = new Button(buttonBar, SWT.PUSH); mBtnEdit.setText(Messages.ResolvablePropertiesDialog_btnEdit); mBtnEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mBtnEdit.addSelectionListener(mController); mBtnRemove = new Button(buttonBar, SWT.PUSH); mBtnRemove.setText(Messages.ResolvablePropertiesDialog_btnRemove); mBtnRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mBtnRemove.addSelectionListener(mController); return composite; }
Example 14
Source File: UpdateNoteDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
@Override protected Control createDialogArea(Composite parent) { Composite tparent = (Composite) super.createDialogArea(parent); GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).extendedMargins(5, 5, 5, 5).applyTo(tparent); GridDataFactory.fillDefaults().hint(620, 250).grab(true, true).applyTo(tparent); Group noteGroup = new Group(tparent, SWT.None); noteGroup.setText(Messages.getString("dialog.UpdateNoteDialog.noteGroup")); GridDataFactory.fillDefaults().grab(true, true).applyTo(noteGroup); noteGroup.setLayout(new GridLayout()); tableViewer = new TableViewer(noteGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); Table table = tableViewer.getTable(); table.setLayoutData(new GridData(GridData.FILL_BOTH)); table.setHeaderVisible(true); table.setLinesVisible(true); String[] arrColName = new String[] { Messages.getString("dialog.UpdateNoteDialog.tableColumn1"), Messages.getString("dialog.UpdateNoteDialog.tableColumn2"), Messages.getString("dialog.UpdateNoteDialog.tableColumn3"), Messages.getString("dialog.UpdateNoteDialog.tableColumn4"), Messages.getString("dialog.UpdateNoteDialog.tableColumn5") }; int[] arrColWidth = new int[] { 40, 100, 100, 150, 120 }; for (int i = 0; i < arrColName.length; i++) { TableColumn column = new TableColumn(table, SWT.LEFT); column.setWidth(arrColWidth[i]); column.setText(arrColName[i]); } tableViewer.setLabelProvider(new TableViewerLabelProvider()); tableViewer.setContentProvider(new ArrayContentProvider()); Composite cmpBtn = new Composite(tparent, SWT.None); // cmpBtn.setLayout(new GridLayout()); GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(0, 0, 35, 5).applyTo(cmpBtn); cmpBtn.setLayoutData(new GridData(GridData.FILL_VERTICAL)); btnAdd = new Button(cmpBtn, SWT.NONE); btnAdd.setText(Messages.getString("dialog.UpdateNoteDialog.btnAdd")); btnAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnEdit = new Button(cmpBtn, SWT.NONE); btnEdit.setText(Messages.getString("dialog.UpdateNoteDialog.btnEdit")); btnEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnDelete = new Button(cmpBtn, SWT.NONE); btnDelete.setText(Messages.getString("dialog.UpdateNoteDialog.btnDelete")); btnDelete.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); initTable(); initListener(); return tparent; }
Example 15
Source File: ModelPropertiesDialog.java From erflute with Apache License 2.0 | 4 votes |
/** * This method initializes composite1 */ private void createTableComposite(Composite parent) { final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; final GridData gridData = new GridData(); gridData.heightHint = 320; final GridData tableGridData = new GridData(); tableGridData.horizontalSpan = 3; tableGridData.heightHint = 185; final Composite composite = new Composite(parent, SWT.BORDER); composite.setLayout(gridLayout); composite.setLayoutData(gridData); table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION); table.setHeaderVisible(true); table.setLayoutData(tableGridData); table.setLinesVisible(true); final TableColumn tableColumn0 = new TableColumn(table, SWT.NONE); tableColumn0.setWidth(200); tableColumn0.setText(DisplayMessages.getMessage("label.property.name")); final TableColumn tableColumn1 = new TableColumn(table, SWT.NONE); tableColumn1.setWidth(200); tableColumn1.setText(DisplayMessages.getMessage("label.property.value")); tableEditor = new TableEditor(table); tableEditor.grabHorizontal = true; table.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent event) { final int index = table.getSelectionIndex(); if (index == -1) { return; } final TableItem item = table.getItem(index); final Point selectedPoint = new Point(event.x, event.y); targetColumn = -1; for (int i = 0; i < table.getColumnCount(); i++) { final Rectangle rect = item.getBounds(i); if (rect.contains(selectedPoint)) { targetColumn = i; break; } } if (targetColumn == -1) { return; } edit(item, tableEditor); } }); }
Example 16
Source File: CodeAssistAdvancedConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void createSeparateViewer(Composite composite) { fSeparateViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER); Table table= fSeparateViewer.getTable(); table.setHeaderVisible(false); table.setLinesVisible(false); table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1)); TableColumn nameColumn= new TableColumn(table, SWT.NONE); nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title); nameColumn.setResizable(false); fSeparateViewer.setContentProvider(new ArrayContentProvider()); ITableLabelProvider labelProvider= new SeparateTableLabelProvider(); fSeparateViewer.setLabelProvider(labelProvider); fSeparateViewer.setInput(fModel.elements); final int ICON_AND_CHECKBOX_WITH= 50; final int HEADER_MARGIN= 20; int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN; for (int i= 0; i < fModel.elements.size(); i++) { minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH); } nameColumn.setWidth(minNameWidth); fSeparateViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { boolean checked= event.getChecked(); ModelElement element= (ModelElement) event.getElement(); element.setSeparateCommand(checked); } }); table.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleTableSelection(); } }); }
Example 17
Source File: Snippet1.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Executes the snippet. * * @param args * command-line args. */ public static void main(String[] args) { Display display = Display.getDefault(); final Shell shell = new Shell(display); shell.setText("Snippet1.java"); shell.setBounds(100, 100, 640, 480); shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.PUSH); button.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); button.setText("Print the table"); final Table table = new Table(shell, SWT.BORDER); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Set up Table widget with dummy data. for (int i = 0; i < 5; i++) new TableColumn(table, SWT.LEFT).setText("Column " + i); for (int row = 0; row < 100; row++) { TableItem item = new TableItem(table, SWT.NONE); for (int col = 0; col < 5; col++) item.setText(col, "Cell [" + col + ", " + row + "]"); } table.setHeaderVisible(true); TableColumn[] columns = table.getColumns(); for (int i = 0; i < columns.length; i++) columns[i].pack(); button.addListener(SWT.Selection, event -> { PrintDialog dialog = new PrintDialog(shell, SWT.NONE); PrinterData printerData = dialog.open(); if (printerData != null) { Print print = createPrint(table); PaperClips.print( new PrintJob("Snippet1.java", print).setMargins(72), printerData); } }); shell.setVisible(true); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); display.dispose(); }
Example 18
Source File: SelectionDialog.java From e4macs with Eclipse Public License 1.0 | 4 votes |
private final void createTableDialogArea(final Composite parent) { String[] inputKeys = getSelectableKeys(); int columnCount = 0; Point dimens = getColumnCount( parent, inputKeys, sizeHint.x); int count = dimens.x; GridLayout compositeLayout = new GridLayout(count,true); parent.setLayout(compositeLayout); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); Table table = new Table(parent, SWT.V_SCROLL | SWT.HORIZONTAL | SWT.WRAP | SWT.FULL_SELECTION); //| SWT.MULTI); GridData gridData = new GridData(GridData.FILL_BOTH); table.setLayoutData(gridData); table.setBackground(parent.getBackground()); table.setLinesVisible(true); table.setHeaderVisible(false); int columnWidth = (sizeHint.x - getSizeAdjustment()) / count; TableColumn[] columns = new TableColumn[count]; for (int i = 0; i < count; i++) { columns[i] = new TableColumn(table, SWT.LEFT, columnCount++); columns[i].setWidth(columnWidth); } TableColumnLayout layout = new TableColumnLayout(); for (int i = 0; i < count; i++) { layout.setColumnData(columns[i], new ColumnWeightData(100/count,columnWidth,false)); } parent.setLayout(layout); int len = inputKeys.length; int rowCount = len / columnCount; if ((len - rowCount * columnCount) > 0) { rowCount++; } for (int i = 0; i < rowCount; i++) { String[] row = new String[columnCount]; for (int j = 0; j < columnCount; j++) { int sourceIndex = i * columnCount + j; row[j] = (sourceIndex < len ? (String) inputKeys[sourceIndex] : ""); //$NON-NLS-1$ } TableItem item = new TableItem(table, SWT.NULL); item.setText(row); } table.pack(); sizeHint.y = Math.min(table.getBounds().height + getSizeAdjustment(),sizeHint.y); Dialog.applyDialogFont(parent); addTableListeners(table); }
Example 19
Source File: ExtractMethodComposite.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private Composite createArgumentsTable(Composite parent) { final Composite argumentsComposite = new Composite(parent, SWT.NONE); FormLayout compositeLayout = new FormLayout(); GridData compositeLData = new GridData(GridData.FILL_BOTH); argumentsComposite.setLayoutData(compositeLData); argumentsComposite.setLayout(compositeLayout); argumentsTable = new Table(argumentsComposite, SWT.BORDER | SWT.FULL_SELECTION); FormData tableLData = new FormData(); tableLData.bottom = new FormAttachment(1000, 1000, 0); tableLData.left = new FormAttachment(0, 1000, 0); tableLData.right = new FormAttachment(1000, 1000, -80); tableLData.top = new FormAttachment(0, 1000, 4); argumentsTable.setLayoutData(tableLData); argumentsTable.setHeaderVisible(true); argumentsTable.setLinesVisible(true); nameColumn = new TableColumn(argumentsTable, SWT.NONE); nameColumn.setText(Messages.extractMethodArgumentName); createArgumentsButton(argumentsComposite); argumentsComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle area = argumentsTable.getClientArea(); Point preferredSize = argumentsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * argumentsTable.getBorderWidth(); if (preferredSize.y > area.height + argumentsTable.getHeaderHeight()) { Point vBarSize = argumentsTable.getVerticalBar().getSize(); width -= vBarSize.x; } Point oldSize = argumentsTable.getSize(); if (oldSize.x > area.width) { nameColumn.setWidth(width); argumentsTable.setSize(area.width, area.height); } else { argumentsTable.setSize(area.width, area.height); nameColumn.setWidth(width); } } }); argumentsComposite.notifyListeners(SWT.CONTROL, new Event()); return argumentsComposite; }
Example 20
Source File: LayoutTable.java From birt with Eclipse Public License 1.0 | 4 votes |
public LayoutTable( Composite parent, ColumnsDescription columnsDescription, int style, boolean isFormStyle ) { super( parent, SWT.NONE ); formStyle = isFormStyle; Assert.isNotNull( columnsDescription ); this.columnDescription = columnsDescription; if ( formStyle ) setLayout( UIUtil.createGridLayoutWithMargin( 1 ) ); else setLayout( UIUtil.createGridLayoutWithoutMargin( ) ); if ( !formStyle ) table = new Table( this, style ); else table = FormWidgetFactory.getInstance( ).createTable( this, style ); table.setHeaderVisible( columnsDescription.headers != null ); table.setLinesVisible( columnsDescription.drawLines ); table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); int columnCount = columnDescription.isHeaderVisible( ) ? columnDescription.headers.length : columnDescription.columns.length; for ( int i = 0; i < columnCount; i++ ) { TableColumn column = new TableColumn( table, SWT.NONE ); if ( columnDescription.isHeaderVisible( ) ) { column.setText( columnDescription.headers[i] ); } column.setMoveable( false ); if ( i < columnsDescription.columns.length ) { column.setResizable( columnsDescription.columns[i].resizable ); } } addControlListener( new ControlAdapter( ) { public void controlResized( ControlEvent e ) { if ( table != null && !table.isDisposed( ) ) { Rectangle area = getClientArea( ); Point preferredSize = computeTableSize( table ); int width = area.width - 2 * table.getBorderWidth( ); if ( preferredSize.y > area.height ) { // Subtract the scrollbar width from the total column // width // if a vertical scrollbar will be required Point vBarSize = table.getVerticalBar( ).getSize( ); width -= vBarSize.x; } if ( formStyle ) width -= 2; layoutTable( width, area ); } } } ); }