composite.layout( true, true ); final TableEditor editor = new TableEditor( table ); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor( composite, item, 2 );
/** * Specify the Control that is to be displayed and the cell in the table that it is to be positioned above. * * <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control * specified in the TableEditor constructor. * * @param editor the Control that is displayed above the cell being edited * @param item the TableItem for the row of the cell being tracked by this editor * @param column the zero based index of the column of the cell being tracked by this editor */ public void setEditor (Control editor, TableItem item, int column) { setItem(item); setColumn(column); setEditor(editor); } public void layout () {
text.addListener(SWT.FocusOut, textListener); text.addListener(SWT.Traverse, textListener); editor.setEditor(text, item, column); text.setText(item.getText(column)); text.selectAll();
public EditListener(Table table, boolean edit){ this.table = table; this.edit = edit; editor = new TableEditor(table); editor.horizontalAlignment = SWT.LEFT; editor.grabHorizontal = true; } public EditListener(Table table, boolean edit, boolean multiline){
@Override public void run() { layout (); } };
private Button createPermissionEditor(Table table, TableItem item, int index) { Button button = new Button(table, SWT.CHECK); button.pack(); TableEditor editor = new TableEditor(table); editor.grabVertical = true; editor.verticalAlignment = SWT.CENTER; editor.minimumWidth = button.getSize().x; editor.setEditor(button, item, index); editor.getEditor(); return button; }
/** * Specifies the <code>TableItem</code> that is to be edited. * * @param item the item to be edited */ public void setItem (TableItem item) { this.item = item; resize(); } public void setEditor (Control editor) {
nameEditor = new TableEditor (table); comboEditor = new TableEditor (table); widthEditor = new TableEditor (table); heightEditor = new TableEditor (table); excludeEditor = new TableEditor (table); table.addMouseListener(MouseListener.mouseDownAdapter(e -> { resetEditors(); if (newItem == null) return; TableItem oldItem = comboEditor.getItem(); if (newItem == oldItem || newItem != lastSelected) { lastSelected = newItem; excludeEditor.grabHorizontal = true; excludeEditor.minimumWidth = 50; excludeEditor.setEditor(exclude, newItem, EXCLUDE_COL); exclude.addTraverseListener(traverseListener);
/** * Creates the widgets in the "child" group. */ @Override void createChildWidgets () { /* Add common controls */ super.createChildWidgets (); /* Add TableEditors */ comboEditor = new TableEditor (table); nameEditor = new TableEditor (table); table.addMouseListener(MouseListener.mouseDownAdapter(e -> { resetEditors(); index = table.getSelectionIndex(); if (index == -1) return; TableItem oldItem = comboEditor.getItem(); newItem = table.getItem(index); if (newItem == oldItem || newItem != lastSelected) { lastSelected = newItem; return; } table.showSelection(); combo = new CCombo(table, SWT.READ_ONLY); createComboEditor(combo, comboEditor); nameText = new Text(table, SWT.SINGLE); nameText.setText(data.get(index)[NAME_COL]); createTextEditor(nameText, nameEditor, NAME_COL); })); }
/** * Specify the Control that is to be displayed and the cell in the table that it is to be positioned above. * * <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control * specified in the TableEditor constructor. * * @param editor the Control that is displayed above the cell being edited * @param item the TableItem for the row of the cell being tracked by this editor * @param column the zero based index of the column of the cell being tracked by this editor */ public void setEditor (Control editor, TableItem item, int column) { setItem(item); setColumn(column); setEditor(editor); } public void layout () {
@Override protected void setEditor(Control w, Item item, int columnNumber) { tableEditor.setEditor(w, (TableItem) item, columnNumber); }
public EditListener(Table table, boolean edit, boolean multiline){ this.table = table; this.edit = edit; this.multiline = multiline; editor = new TableEditor(table); editor.horizontalAlignment = SWT.LEFT; editor.grabHorizontal = true; } @Override
@Override public void controlMoved(ControlEvent e){ layout (); } @Override
/** * Specifies the <code>TableItem</code> that is to be edited. * * @param item the item to be edited */ public void setItem (TableItem item) { this.item = item; resize(); } public void setEditor (Control editor) {
comboEditor = new TableEditor(table); nameEditor = new TableEditor(table); table.addMouseListener(MouseListener.mouseDownAdapter(e -> { resetEditors(); TableItem oldItem = comboEditor.getItem(); newItem = table.getItem(index); if (newItem == oldItem || newItem != lastSelected) {
/** * Specify the Control that is to be displayed and the cell in the table that it is to be positioned above. * * <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control * specified in the TableEditor constructor. * * @param editor the Control that is displayed above the cell being edited * @param item the TableItem for the row of the cell being tracked by this editor * @param column the zero based index of the column of the cell being tracked by this editor */ public void setEditor (Control editor, TableItem item, int column) { setItem(item); setColumn(column); setEditor(editor); } @Override
@Override protected void setEditor(Control w, Item item, int columnNumber) { tableEditor.setEditor(w, (TableItem) item, columnNumber); }
TableEditor editor = new TableEditor(table); editor.setEditor(button, item, 0);