Refactoring of Grid#showColumn. Added component.xml
diff --git a/bundles/org.eclipse.rap.nebula.widgets.grid.snippets/src/org/eclipse/rap/nebula/widgets/grid/snippets/GridSnippet.java b/bundles/org.eclipse.rap.nebula.widgets.grid.snippets/src/org/eclipse/rap/nebula/widgets/grid/snippets/GridSnippet.java
index c3d6464..c75a46d 100644
--- a/bundles/org.eclipse.rap.nebula.widgets.grid.snippets/src/org/eclipse/rap/nebula/widgets/grid/snippets/GridSnippet.java
+++ b/bundles/org.eclipse.rap.nebula.widgets.grid.snippets/src/org/eclipse/rap/nebula/widgets/grid/snippets/GridSnippet.java
@@ -38,6 +38,7 @@
createGrid( parent );
createAddRemoveItemButton( parent );
createTopIndexButton( parent );
+ createShowColumn( parent );
}
@Override
@@ -143,6 +144,7 @@
Composite composite = new Composite( parent, SWT.NONE );
composite.setLayout( new GridLayout( 2, false ) );
Button addButton = new Button( composite, SWT.PUSH );
+ addButton.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
addButton.setText( "Add item" );
addButton.addSelectionListener( new SelectionAdapter() {
@Override
@@ -169,6 +171,7 @@
}
} );
Button removeButton = new Button( composite, SWT.PUSH );
+ removeButton.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
removeButton.setText( "Remove item" );
removeButton.addSelectionListener( new SelectionAdapter() {
@Override
@@ -187,10 +190,12 @@
Composite composite = new Composite( parent, SWT.NONE );
composite.setLayout( new GridLayout( 3, false ) );
Label topIndexLabel = new Label( composite, SWT.NONE );
+ topIndexLabel.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
topIndexLabel.setText( "Top index" );
final Text topIndexText = new Text( composite, SWT.BORDER );
- topIndexText.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
+ topIndexText.setLayoutData( new GridData( 50, SWT.DEFAULT ) );
Button button = new Button( composite, SWT.PUSH );
+ button.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
button.setText( "Change" );
button.addSelectionListener( new SelectionAdapter() {
@Override
@@ -205,6 +210,32 @@
} );
}
+ private void createShowColumn( Composite parent ) {
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayout( new GridLayout( 3, false ) );
+ Label showColumnLabel = new Label( composite, SWT.NONE );
+ showColumnLabel.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
+ showColumnLabel.setText( "Show column" );
+ final Text showColumnText = new Text( composite, SWT.BORDER );
+ showColumnText.setLayoutData( new GridData( 50, SWT.DEFAULT ) );
+ Button button = new Button( composite, SWT.PUSH );
+ button.setLayoutData( new GridData( 100, SWT.DEFAULT ) );
+ button.setText( "Show" );
+ button.addSelectionListener( new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent event ) {
+ int index = -1;
+ try {
+ index = Integer.parseInt( showColumnText.getText() );
+ } catch( NumberFormatException e ) {
+ }
+ if( index >= 0 && index < grid.getColumnCount() ) {
+ grid.showColumn( grid.getColumn( index ) );
+ }
+ }
+ } );
+ }
+
private void updateItemsText( int startIndex ) {
for( int index = startIndex; index < grid.getItemCount(); index++ ) {
GridItem item = grid.getItem( index );
diff --git a/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java b/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java
index c405eb5..ef897dc 100644
--- a/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java
+++ b/bundles/org.eclipse.rap.nebula.widgets.grid/src/org/eclipse/nebula/widgets/grid/Grid.java
@@ -2021,16 +2021,10 @@
int offset = hScroll.getSelection();
int x = getColumnHeaderXPosition( column );
if( x < 0 || x + column.getWidth() > getClientArea().width ) {
- if( x < 0 ) {
- hScroll.setSelection( offset + x );
- } else {
- if( column.getWidth() > getClientArea().width ) {
- hScroll.setSelection( offset + x );
- } else {
- x -= getClientArea().width - column.getWidth();
- hScroll.setSelection( offset + x );
- }
+ if( x >= 0 && column.getWidth() <= getClientArea().width ) {
+ x -= getClientArea().width - column.getWidth();
}
+ hScroll.setSelection( offset + x );
}
}
}
diff --git a/component.xml b/component.xml
new file mode 100644
index 0000000..3cbc1d1
--- /dev/null
+++ b/component.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component>
+ <name>
+ Nebula Grid widget for RAP
+ </name>
+ <maintainer>
+ Ivan Furnadjiev
+ </maintainer>
+ <description>
+ <p>
+ The Grid widget is a spreadsheet/table component for RAP that offers features not currently
+ available in the base SWT Tree/Table like row and column spanning, checkboxes on multiple
+ columns, column grouping and more.
+ </p>
+ </description>
+</component>
\ No newline at end of file