Bug 123654 - [Viewers] Why not give ListViewer a copy() API?
Summary: [Viewers] Why not give ListViewer a copy() API?
Status: RESOLVED DUPLICATE of bug 121782
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-12 15:17 EST by benson margulies CLA
Modified: 2007-06-26 16:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description benson margulies CLA 2006-01-12 15:17:52 EST
We all know what the copy action for a list viewer is, it's to accumulate the text in the selected item(s) and put it on the clipboard. So, why not provide it  once and for all. (Yes, of course, someone might want a more complex version that uses more of the interior structure for more data). The following is nearly the generic implementation, except that I didn't just use the label provider to get the text.


ISelection viewerSelection = tmListViewer.getSelection();
				IStructuredSelection iss = (IStructuredSelection)viewerSelection;
				Clipboard clipboard = new Clipboard(getControl().getDisplay());
				String textData = "";
				
				StringBuffer tb = new StringBuffer();
				Iterator it = iss.iterator();
				while(it.hasNext()) {
					TMMatchSet.Match element = (TMMatchSet.Match)it.next();
					tb.append(element.text);
					tb.append("\n");
				}
				textData = tb.toString();
				
				TextTransfer textTransfer = TextTransfer.getInstance();
				Transfer[] transfers = new Transfer[] { textTransfer };
				Object[] data = new Object[] { textData };
				clipboard.setContents(data, transfers);
				clipboard.dispose();
Comment 1 Boris Bokowski CLA 2007-06-26 16:18:27 EDT

*** This bug has been marked as a duplicate of bug 121782 ***