Skip to main content



      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 08:38 Go to next message
Eclipse UserFriend
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 08:40] by 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 09:40 Go to previous message
Eclipse UserFriend
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: Tue Jul 01 12:59:53 EDT 2025

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

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

Back to the top