Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem TableEditor - Buttons in TableItem
Problem TableEditor - Buttons in TableItem [message #1068120] Fri, 12 July 2013 09:40
Moritz Wilde is currently offline Moritz WildeFriend
Messages: 3
Registered: May 2013
Junior Member
Hey,

I have ab simple Table with 9 columns. In the table are listed some Server with names, location_names, id's, etc. In the 9th column there are one button for every row. Every row is represented by a server class where I can access the parameters with get-functions. I have the choice to filter the view of the table. When I type in a textfield "- DE -", the table shall show just servers, which have a location_name with this key inside. So I have to click on a button "update table" and the programm will execute a new rendering of the table and also put the associated buttons in the last columns. When I click on the buttons in the rows, the associated server names shall paste in a tree. Every button gets with "setData(Object data)" a different server object.
So I start the programm and without filtering the table, the function to paste the names in the tree works fine.
When I use the filter "- DE -", the update table function works fine. But when I use the button, a wrong server name will be pasted in the tree. That means, that in the table are the wrong buttons. Code debugging brings the awareness that the TableEditor get the correct parameters in the setEditor function. It means that the correct buttons will be deliver.


private void fillTableFirstTime()
{
	for (Iterator<SServer> serveriterator = model.getAllServersAsList(databaseconnection.getConnection()).iterator(); serveriterator.hasNext();) {
			SServer server = (SServer) serveriterator.next();
			TableItem tableitem = new TableItem(table, SWT.NONE);
			int c = 0;
			tableitem.setText(c++, server.getName());
			tableitem.setText(c++, server.getLocation_name());
			tableitem.setText(c++, server.getSsh_name());
			tableitem.setText(c++, server.getSsh_job());
			tableitem.setText(c++, server.getScp_job());
			if ("".equals(server.getCrontab()) || null == server.getCrontab()) {
				tableitem.setText(c++, "n.a.");
			}
			else {
				tableitem.setText(c++, server.getCrontab());
			}
			if ("".equals(server.getCommunity_name()) || null == server.getCommunity_name()) {
				tableitem.setText(c++, "n.a.");
			}
			else {
				tableitem.setText(c++, server.getCommunity_name());
			}
			tableitem.setText(c++, server.getLast_check());
			TableEditor editor = new TableEditor(table);
			tableitem.setData(editor);
			Button checkButton = new Button(table, SWT.NONE);
			checkButton.setText("select");
			checkButton.setData(server);
			checkButton.addSelectionListener(new CheckButtonListener(view.getChosenServerTree()));
			checkButton.pack();
			model.addButtonToMap(server.getSsh_name(), checkButton);
			editor.minimumWidth = 50;
			editor.setEditor(model.getButtonMap().get(server.getSsh_name()), tableitem, c++);
			editor.layout();
		}
	}


public void updateServerTable()
	{
		String filterString = model.getFilterString();
		table.removeAll();
		table.update();
		for (Iterator<SServer> iterator = model.getAllServersAsList(databaseconnection.getConnection()).iterator(); iterator.hasNext();) {

			SServer server = (SServer) iterator.next();
			int c = 0;
			if (server.getLocation_name().contains(filterString)) {
				TableItem item = new TableItem(table, SWT.NONE);
				item.setText(c++, server.getName());
				item.setText(c++, server.getLocation_name());
				item.setText(c++, server.getSsh_name());
				item.setText(c++, server.getSsh_job());
				item.setText(c++, server.getScp_job());
				if ("".equals(server.getCrontab()) || null == server.getCrontab()) {
					item.setText(c++, "n.a.");
				}
				else {
					item.setText(c++, server.getCrontab());
				}
				if ("".equals(server.getCommunity_name()) || null == server.getCommunity_name()) {
					item.setText(c++, "n.a.");
				}
				else {
					item.setText(c++, server.getCommunity_name());
				}
				item.setText(c++, server.getLast_check());
				TableEditor editor = new TableEditor(table);
				item.setData(editor);
				editor.minimumWidth = 50;
				Button b = model.getButtonMap().get(server.getSsh_name());
				SServer ss = (SServer) b.getData();
				
				System.out.println(ss.getLocation_name());
				if (ss.getLocation_name().contains(filterString)) {
					editor.setEditor(b, item, c++);
				}
				editor.layout();
			}
			
		}
	}


-> b is the correct button

Where is my problem?
LG
Previous Topic:Disposing a Composite will cause SWT.Activate
Next Topic:Remove boarder around the button
Goto Forum:
  


Current Time: Fri Apr 26 22:21:53 GMT 2024

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

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

Back to the top