Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to identify the selected column in a FULL_SELECTION TableViewer
How to identify the selected column in a FULL_SELECTION TableViewer [message #644308] Fri, 10 December 2010 13:38 Go to next message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
I am trying to open a dialog to show the detail content of the selected cell in a FULL_SELECTION TableViewer, this is especially useful if the text content in the cell is too long to get entirely displayed. However, I can't determine which property value of the model object to return if I can't identify the column index, or the column header label, whatever can be mapped to the property.

[Updated on: Fri, 10 December 2010 13:40]

Report message to a moderator

Re: How to identify the selected column in a FULL_SELECTION TableViewer [message #644330 is a reply to message #644308] Fri, 10 December 2010 14:40 Go to previous message
Carusyte Missing name is currently offline Carusyte Missing nameFriend
Messages: 27
Registered: July 2009
Junior Member
I've done some google search and learning from the jface api doc, after a few experiments and I found a relatively "easy" approach to achieve this:
		log_tv.getTable().addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				ViewerCell cell = log_tv.getCell(new Point(e.x, e.y));
				if (cell == null)
					return;
				int col = cell.getColumnIndex();
				LogEntry entry = (LogEntry) cell.getElement();
				String val = null;
				switch (col) {
				case 1:
					val = entry.getId();
					break;
				case 2:
					val = entry.getTimeStamp().toString();
					break;
				case 3:
					val = entry.getEvent();
					break;
				case 4:
					val = entry.getDetail();
					break;
				}
				// open the undone detail dialog populated with val
			}
		});


I am not sure if this is an elegant way, or if there's any pitfall in this approach. I hope this can help any other developer who has the same need. If there's any better approach that you would like to share, please feel free to post.
Previous Topic:How to identify the selected column in a FULL_SELECTION TableViewer
Next Topic:PropertyTesters Tiutorial please
Goto Forum:
  


Current Time: Thu Apr 25 05:16:10 GMT 2024

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

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

Back to the top