Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » problem with the height of TableViewerColumn and ComboBoxCellEditor
problem with the height of TableViewerColumn and ComboBoxCellEditor [message #126400] Mon, 30 March 2009 13:57 Go to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030207050105040003070708
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

i have a little problem with the height of a TableViewerColumn when I'm
using a ComboBoxCellEditor.

When I doubleclick a cell, the value of the cell is not correctly
displayed. Look at the attachment.

The cell seems to be too small, but I can't set another size.

here is a snippet to reproduce:

public class Test implements IEntryPoint {

private TableViewer tableViewer;
private Table table;
private List<String> list;

public int createUI() {
Display display = PlatformUI.createDisplay();
Shell container = new Shell( display, SWT.SHELL_TRIM );
container.setSize( 500, 500 );
container.setLayout( new GridLayout() );

tableViewer = new TableViewer( container, SWT.NONE );
tableViewer.setUseHashlookup( true );
tableViewer.setContentProvider( new ContentProvider() );
tableViewer.setLabelProvider( new LabelProvider() );

table = tableViewer.getTable();
table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
table.setHeaderVisible( true );
table.setLinesVisible( true );

TableViewerColumn keyColumn = new TableViewerColumn( tableViewer,
SWT.NONE );
keyColumn.setLabelProvider( new LabelProvider() );
keyColumn.setEditingSupport( new CellEditingSupport( tableViewer ) );
TableColumn column = keyColumn.getColumn();
column.setText( "Key" );
column.setWidth( 200 );

list = new ArrayList<String>();
list.add( "key3" );
list.add( "key2" );
list.add( "key1" );

ColumnViewerEditorActivationStrategy activationStrategy = new
ColumnViewerEditorActivationStrategy( tableViewer ) {
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event ) {
return event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON;
}
};

TableViewerEditor.create( tableViewer, activationStrategy,
ColumnViewerEditor.TABBING_HORIZONTAL |
ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR );

tableViewer.setInput( list );

container.open();

while ( !container.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
return 0;
}

private static final class ContentProvider implements
IStructuredContentProvider {
private Object[] elements;
public Object[] getElements( Object inputElement ) {
return elements;
}
public void inputChanged( Viewer viewer, Object oldInput, Object
newInput ) {
if ( newInput == null ) {
elements = new Object[0];
} else {
List<String> list = (List<String>) newInput;
elements = list.toArray();
}
}
public void dispose() {}
}

private static final class LabelProvider extends CellLabelProvider {
public void update( final ViewerCell cell ) {
cell.setText( (String) cell.getElement() );
}
}

private final class CellEditingSupport extends EditingSupport {
private final CellEditor cellEditor;
private String[] keys = { "key1", "key2", "key3" };
public CellEditingSupport( TableViewer viewer ) {
super( viewer );
cellEditor = new ComboBoxCellEditor( viewer.getTable(), keys );
}
@Override
protected boolean canEdit( Object element ) {
return true;
}
@Override
protected CellEditor getCellEditor( Object element ) {
return cellEditor;
}
@Override
protected Object getValue( Object element ) {
for ( int i = 0; i < keys.length; i++ ) {
if ( element.equals( keys[i] ) )
return i;
}
return null;
}
@Override
protected void setValue( Object element, Object value ) {
element = keys[((Integer) value).intValue()];
getViewer().update( element, null );
}
}
}

Roland

--------------030207050105040003070708
Content-Type: image/png;
name="tableviewer.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="tableviewer.png"

iVBORw0KGgoAAAANSUhEUgAAATAAAAC2CAMAAABpuyGwAAAAAXNSR0IArs4c 6QAAAARnQU1B
AACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgA ABdwnLpRPAAA
AwBQTFRFAAAAAABIAABSAAB0AAB+RQAASAAATAAAcQAAdAAARQBISABIRQB0 SAB0cQBIdABI
cQB0dAB0RUUAcXF0dHR0AEWcAEicAE2cAHG/AHS/MWrFMWrPMWrZXmrFO6kp AIDABoTBEojE
HI7HKJPKMYfZM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jENxPiUeNcr4CuwWaX3 A1gbzcJhQEp8
d2TBHQbDz49hU+AqoIWZF0yT3tw4nWEeJr6V0RZgkeE2KnKK9LI0rQiDSRm4 pO5KAiy9s/we
CJgmS7tunQmCviYFjeb2lajX/NuKOvqQwvSLkn8IYnpPwv135Qu44g+SgMUz UloQMAKmSUCz
OTmMgGkS0GxODiNgmgQ0m5PDzADLZfGzKztFDjPjMM1es2hOp0aaFAkYAdMk oNmcHEbANAlo
Ns+pwyIXSgaHlcFznTQRqc3zCkzdy1YPUUl16J29OLfA5Ce9tHyuUWfHnOpV BEwTHwEjYJoE
NJuTwywCFv8wO82DzaJ5rh0mXShJeVj7dztyoSQBSwSscaFkc2BdKW7mcqPB VVn+hZLksGQO
8/J9OjWKm68SPi4xrhsD/8/1LBn7BFMDQOK6zCuwZM+XjDs6A//PKbCEH7NF ymaR11n6h9b1
wohHlALiQrhsZimfyGFFDrz1WAoBC5XNygOsVb0wzmEETNzQQw5rP1Zap11J HcYfnVYry4hc
8c+1o4l9QmBw92cpgQWP2NMckni7bDmBCWK6MYzfX1xSYF4sIoclCvrejeja DsOb2EvqMP/G
ak2H4S3ZpRySglcHDnPdUgLjR90hsFLmYf55ju4s2XhdWTLXjjP9cNmsNMBa 1gvbZ/pl4RN/
nAlnSQMVVeu67PYViIUDSsA03zICRsA0CWg2J4dpAvsfachI8QOepYQAAAAA SUVORK5CYII=
--------------030207050105040003070708--
Re: problem with the height of TableViewerColumn and ComboBoxCellEditor [message #126414 is a reply to message #126400] Mon, 30 March 2009 15:29 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Roland,

the current implementation of cell editors uses Combo control. There is
a bug related to this issue:

264225: [Combo] Omit border if used as celleditor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=264225

Since 1.2M6 we have an implementation of CCombo which is originally used
in the Cell Editors (see comment 2).

Best,
Ivan

Roland Siebert wrote:
> Hi,
>
> i have a little problem with the height of a TableViewerColumn when
> I'm using a ComboBoxCellEditor.
>
> When I doubleclick a cell, the value of the cell is not correctly
> displayed. Look at the attachment.
>
> The cell seems to be too small, but I can't set another size.
>
> here is a snippet to reproduce:
>
> public class Test implements IEntryPoint {
>
> private TableViewer tableViewer;
> private Table table;
> private List<String> list;
>
> public int createUI() {
> Display display = PlatformUI.createDisplay();
> Shell container = new Shell( display, SWT.SHELL_TRIM );
> container.setSize( 500, 500 );
> container.setLayout( new GridLayout() );
>
> tableViewer = new TableViewer( container, SWT.NONE );
> tableViewer.setUseHashlookup( true );
> tableViewer.setContentProvider( new ContentProvider() );
> tableViewer.setLabelProvider( new LabelProvider() );
>
> table = tableViewer.getTable();
> table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
> true ) );
> table.setHeaderVisible( true );
> table.setLinesVisible( true );
>
> TableViewerColumn keyColumn = new TableViewerColumn(
> tableViewer, SWT.NONE );
> keyColumn.setLabelProvider( new LabelProvider() );
> keyColumn.setEditingSupport( new CellEditingSupport(
> tableViewer ) );
> TableColumn column = keyColumn.getColumn();
> column.setText( "Key" );
> column.setWidth( 200 );
>
> list = new ArrayList<String>();
> list.add( "key3" );
> list.add( "key2" );
> list.add( "key1" );
>
> ColumnViewerEditorActivationStrategy activationStrategy = new
> ColumnViewerEditorActivationStrategy( tableViewer ) {
> protected boolean isEditorActivationEvent(
> ColumnViewerEditorActivationEvent event ) {
> return event.eventType ==
> ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTI ON;
> }
> };
>
> TableViewerEditor.create( tableViewer, activationStrategy,
> ColumnViewerEditor.TABBING_HORIZONTAL |
> ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR );
>
> tableViewer.setInput( list );
>
> container.open();
>
> while ( !container.isDisposed() ) {
> if ( !display.readAndDispatch() ) {
> display.sleep();
> }
> }
> return 0;
> }
>
> private static final class ContentProvider implements
> IStructuredContentProvider {
> private Object[] elements;
> public Object[] getElements( Object inputElement ) {
> return elements;
> }
> public void inputChanged( Viewer viewer, Object oldInput,
> Object newInput ) {
> if ( newInput == null ) {
> elements = new Object[0];
> } else {
> List<String> list = (List<String>) newInput;
> elements = list.toArray();
> }
> }
> public void dispose() {}
> }
>
> private static final class LabelProvider extends CellLabelProvider {
> public void update( final ViewerCell cell ) {
> cell.setText( (String) cell.getElement() );
> }
> }
>
> private final class CellEditingSupport extends EditingSupport {
> private final CellEditor cellEditor;
> private String[] keys = { "key1", "key2", "key3" };
> public CellEditingSupport( TableViewer viewer ) {
> super( viewer );
> cellEditor = new ComboBoxCellEditor( viewer.getTable(),
> keys );
> }
> @Override
> protected boolean canEdit( Object element ) {
> return true;
> }
> @Override
> protected CellEditor getCellEditor( Object element ) {
> return cellEditor;
> }
> @Override
> protected Object getValue( Object element ) {
> for ( int i = 0; i < keys.length; i++ ) {
> if ( element.equals( keys[i] ) )
> return i;
> }
> return null;
> }
> @Override
> protected void setValue( Object element, Object value ) {
> element = keys[((Integer) value).intValue()];
> getViewer().update( element, null );
> }
> }
> }
>
> Roland
>
> ------------------------------------------------------------ ------------
>
Previous Topic:HTTP Status 404 - ProxyServlet:
Next Topic:Working example of RAP Menu Bar
Goto Forum:
  


Current Time: Mon Dec 06 03:44:46 GMT 2021

Powered by FUDForum. Page generated in 0.02141 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top