|
Re: How to get TableViewer to select cell, not row [message #725322 is a reply to message #723737] |
Wed, 14 September 2011 14:06 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
This may not be quite what you were looking for, but could probably help
with what you want. The snippets below demonstrate how to do this at
the swt level, including how to get the clicked column index.
-
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet3.java
-
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java
HTH,
Grant
On 9/9/2011 5:49 AM, Yo wrote:
> Hi,
> I have implemented a context menu for a TableViewer and configured a
> command handler to process when a specific item in the menu is
> right-clicked. My plan is to implemented cell copy a la Ctrl-C.
>
> The selection event gives me the whole role but I need to know which
> cell in that row was selected at the time (ie, which cell was
> right-clicked.
>
> Do I need to set things up differently?
>
> Here is the set up in the viewer class:
>
> MenuManager menuManager = new MenuManager();
> Menu menu = menuManager.createContextMenu(viewer.getTable());
>
> viewer.getTable().setMenu(menu);
> getSite().registerContextMenu(menuManager, viewer);
>
> Here is my handler. The data in the event (Object element, below) is a
> String[] of the row's content:
>
> public Object execute(ExecutionEvent event) throws ExecutionException {
> ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).
> getActivePage().getSelection();
> if (selection != null & selection instanceof IStructuredSelection) {
> IStructuredSelection strucSel = (IStructuredSelection) selection;
> for (Iterator<?> iterator = strucSel.iterator();
> iterator.hasNext();) {
> Object element = iterator.next();
> System.out.println(element.toString());
> }
> }
> return null;
> }
>
> How do i get an event indicating the specific cell?
>
> Thanks,
> y
|
|
|
Re: How to get TableViewer to select cell, not row [message #728672 is a reply to message #725322] |
Fri, 23 September 2011 15:56 |
Yo Messages: 10 Registered: July 2009 |
Junior Member |
|
|
Hi Grant,
Your tip saved me! Working! Thanks very, very much!
Yo
On 9/14/2011 4:06 PM, Grant Gayed wrote:
> Hi,
>
> This may not be quite what you were looking for, but could probably help
> with what you want. The snippets below demonstrate how to do this at the
> swt level, including how to get the clicked column index.
>
> -
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet3.java
>
> -
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java
>
>
> HTH,
> Grant
>
>
> On 9/9/2011 5:49 AM, Yo wrote:
>> Hi,
>> I have implemented a context menu for a TableViewer and configured a
>> command handler to process when a specific item in the menu is
>> right-clicked. My plan is to implemented cell copy a la Ctrl-C.
>>
>> The selection event gives me the whole role but I need to know which
>> cell in that row was selected at the time (ie, which cell was
>> right-clicked.
>>
>> Do I need to set things up differently?
>>
>> Here is the set up in the viewer class:
>>
>> MenuManager menuManager = new MenuManager();
>> Menu menu = menuManager.createContextMenu(viewer.getTable());
>>
>> viewer.getTable().setMenu(menu);
>> getSite().registerContextMenu(menuManager, viewer);
>>
>> Here is my handler. The data in the event (Object element, below) is a
>> String[] of the row's content:
>>
>> public Object execute(ExecutionEvent event) throws ExecutionException {
>> ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).
>> getActivePage().getSelection();
>> if (selection != null & selection instanceof IStructuredSelection) {
>> IStructuredSelection strucSel = (IStructuredSelection) selection;
>> for (Iterator<?> iterator = strucSel.iterator();
>> iterator.hasNext();) {
>> Object element = iterator.next();
>> System.out.println(element.toString());
>> }
>> }
>> return null;
>> }
>>
>> How do i get an event indicating the specific cell?
>>
>> Thanks,
>> y
>
|
|
|
Powered by
FUDForum. Page generated in 0.03305 seconds