Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Buttons not removed from Table
Buttons not removed from Table [message #1060664] Mon, 27 May 2013 15:05 Go to next message
Christian Orth is currently offline Christian OrthFriend
Messages: 1
Registered: May 2013
Junior Member
setup
the roject is mavenized; libs are RAP, eclipselink,slf4j,mysql-connector,junit
the following is used for rap:

		<dependency>
			<groupId>org.eclipse.rap</groupId>
			<artifactId>org.eclipse.rap.rwt</artifactId>
			<version>2.1.0-M2</version>
		</dependency>


Problem:
I am using a Table. This table should only display 24 Items in 4 Columns.
I cant delete the Buttons in the Table!

	public Table table;
	private TableColumn tblclmnStellplatz;
	private TableColumn tblclmnReserviert;
	private TableColumn tblclmnVonWem;
	private TableColumn tblclmnWofr;


i try to update the view by deleting all elements in that table.

	private void updateTableView() {
		// TODO remove bug
		table.clearAll();
	table.removeAll();
		table.update();
		table.redraw();
		logge("number of items in table : " + table.getItemCount());
		StoringPosition storingposition;
		for (int position = testlab.getNumberOfStoringPositions(); position >= 1; position--) {
			table.update();
			storingposition = testlab.getStoringPosition(position);
			TableItem tableitem = new TableItem(table, 0, 0);
			tableitem.setText(0,
					Integer.toString(storingposition.getPosition()));
			if (storingposition.isReserved()) {
				tableitem.setText(1, "yes");
				String reservist = storingposition.getReservist();
				tableitem.setText(2, reservist);
				tableitem.setText(3, storingposition.getEndDate());
				TableEditor te = new TableEditor(table);
				te.minimumWidth = 50;
				tableitem.setData(te);
				Button b = new Button(table, 0);
				b.addSelectionListener(deletebuttonlistener);
				logge(" int to string sp.getPosition : "
						+ Integer.toString(storingposition.getPosition()));
				b.setData(position + "");
				b.setText("del");
				te.setEditor(b, tableitem, 4);
				te.layout();
			} else {
				tableitem.setText(1, "no");
				tableitem.setText(2, "");
				tableitem.setText(3, "");
				tableitem.setText(4, "");
			}
			table.update();
		}
	}

the Listener:
DeleteButtonListener implements SelectionListener
public void widgetSelected(SelectionEvent arg0) {

		Button button;
		button = (Button) arg0.getSource();
		int position = Integer.parseInt((String) button
				.getData());
		button.setEnabled(false);
		button.setVisible(false);
		button.dispose();
		mainComposite.table.remove(position);
		mainComposite.deleteReservation(position);
		mainComposite.redraw(); 
// Now a little chaos after trying all ideas :(
	}


as you can see my idea is to remove all elements from the table and fill it with all 24 elements.

I tried clearAll and removeAll and i tried also removing by index. (remove(int index)
I also tried dispose for the Buttons ...
Thought after all Buttons are dereferenced they should vanish...

Am i misunderstanding Table and TableEditor or is this a bug in the Webclient?
Re: Buttons not removed from Table [message #1060818 is a reply to message #1060664] Tue, 28 May 2013 13:55 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Christian,
I can't find any problem with button (editor) disposal. Tested with RAP
2.1 RC1. I've created a simple snippet that works form me:
....
public class SimpleEntryPoint extends AbstractEntryPoint {

private static final int COLUMN_NUM = 4;

@Override
public void createContents( Composite parent ) {
parent.setLayout( new FillLayout() );
final Table table = new Table( parent, SWT.NONE );
table.setHeaderVisible( true );
for( int i = 0; i < COLUMN_NUM; i++ ) {
TableColumn column = new TableColumn( table, SWT.NONE );
column.setText( "Column " + i );
column.setWidth( 100 );
}
Listener deleteListener = new Listener() {
@Override
public void handleEvent( Event event ) {
Button button = ( Button )event.widget;
TableEditor editor = ( TableEditor )button.getData();
editor.getItem().dispose();
editor.getEditor().dispose();
editor.dispose();
for( TableItem item : table.getItems() ) {
( ( TableEditor )item.getData() ).layout();
}
}
};
for( int i = 0; i < 20; i++ ) {
TableItem item = new TableItem( table, SWT.NONE );
for( int j = 0; j < COLUMN_NUM - 1; j++ ) {
item.setText( j, "Item " + i + "." + j );
}
TableEditor editor = new TableEditor( table );
editor.grabHorizontal = true;
editor.minimumWidth = 50;
Button deleteButton = new Button( table, SWT.NONE );
deleteButton.addListener( SWT.Selection, deleteListener );
deleteButton.setData( editor );
deleteButton.setText( "Delete" );
editor.setEditor( deleteButton, item, 3 );
item.setData( editor );
}
}

}
....
HTH,
Ivan

On 5/27/2013 6:15 PM, Christian Orth wrote:
> setup
> the roject is mavenized; libs are RAP,
> eclipselink,slf4j,mysql-connector,junit
> the following is used for rap:
>
>
> <dependency>
> <groupId>org.eclipse.rap</groupId>
> <artifactId>org.eclipse.rap.rwt</artifactId>
> <version>2.1.0-M2</version>
> </dependency>
>
>
> Problem:
> I am using a Table. This table should only display 24 Items in 4 Columns.
> I cant delete the Buttons in the Table!
>
>
> public Table table;
> private TableColumn tblclmnStellplatz;
> private TableColumn tblclmnReserviert;
> private TableColumn tblclmnVonWem;
> private TableColumn tblclmnWofr;
>
>
> i try to update the view by deleting all elements in that table.
>
>
> private void updateTableView() {
> // TODO remove bug
> table.clearAll();
> table.removeAll();
> table.update();
> table.redraw();
> logge("number of items in table : " + table.getItemCount());
> StoringPosition storingposition;
> for (int position = testlab.getNumberOfStoringPositions();
> position >= 1; position--) {
> table.update();
> storingposition = testlab.getStoringPosition(position);
> TableItem tableitem = new TableItem(table, 0, 0);
> tableitem.setText(0,
> Integer.toString(storingposition.getPosition()));
> if (storingposition.isReserved()) {
> tableitem.setText(1, "yes");
> String reservist = storingposition.getReservist();
> tableitem.setText(2, reservist);
> tableitem.setText(3, storingposition.getEndDate());
> TableEditor te = new TableEditor(table);
> te.minimumWidth = 50;
> tableitem.setData(te);
> Button b = new Button(table, 0);
> b.addSelectionListener(deletebuttonlistener);
> logge(" int to string sp.getPosition : "
> +
> Integer.toString(storingposition.getPosition()));
> b.setData(position + "");
> b.setText("del");
> te.setEditor(b, tableitem, 4);
> te.layout();
> } else {
> tableitem.setText(1, "no");
> tableitem.setText(2, "");
> tableitem.setText(3, "");
> tableitem.setText(4, "");
> }
> table.update();
> }
> }
>
> the Listener:
>
> DeleteButtonListener implements SelectionListener
> public void widgetSelected(SelectionEvent arg0) {
>
> Button button;
> button = (Button) arg0.getSource();
> int position = Integer.parseInt((String) button
> .getData());
> button.setEnabled(false);
> button.setVisible(false);
> button.dispose();
> mainComposite.table.remove(position);
> mainComposite.deleteReservation(position);
> mainComposite.redraw(); // Now a little chaos after trying all
> ideas :(
> }
>
>
> as you can see my idea is to remove all elements from the table and
> fill it with all 24 elements.
>
> I tried clearAll and removeAll and i tried also removing by index.
> (remove(int index)
> I also tried dispose for the Buttons ...
> Thought after all Buttons are dereferenced they should vanish...
>
> Am i misunderstanding Table and TableEditor or is this a bug in the
> Webclient?
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:RAP and Tabris
Next Topic:deploying on tomcat6
Goto Forum:
  


Current Time: Wed Oct 27 13:49:03 GMT 2021

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

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

Back to the top