Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » CopyPaste option in GridViewer
CopyPaste option in GridViewer [message #38914] Thu, 23 August 2007 11:21 Go to next message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello,
I need the copy paste functionality in NebulaGridViewer like MSExcel.
As cell selection is possible in GridViewer i need to copy some selected
cell and then paste it in the same table like MSexcel.

I had a look into clipboard functionality in eclipse where we can do
copypaste but copying the multiple cell and pasting in the same table I am
not getting how to proceed.Also how to enable contextmenu after selecting
multiple cell.

Or Nebula is providing any feature for copypaste?

can anybody help me in this regard?



Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #39147 is a reply to message #38914] Tue, 28 August 2007 16:52 Go to previous messageGo to next message
Peter Centgraf is currently offline Peter CentgrafFriend
Messages: 52
Registered: July 2009
Member
I haven't worked with Grid, but I have worked with Table and the
clipboard. Someone else will have to correct me if Grid has special
support I don't know about.

A widget like Grid typically does not interact with the clipboard on
your behalf. Your application must provide the appropriate actions to
trigger the clipboard operations, and it must also respond to those
actions by manipulating the clipboard and/or the widget.

In your case, you would need to define and respond to a Copy action.
Your code should loop over the selection within the Grid, copy the
appropriate data into a data structure, and push that data structure
onto the clipboard. You must define exactly what the "appropriate data"
is and what the "data structure" will be. If you only need to move data
within your running application, simple Java object references might be
sufficient. If you want to move data between applications, you will
need to serialize a full representation of the objects. If you want to
exchange data with Excel, you'll have to represent the data in a
clipboard format Excel can understand.

.... Then you must do the reverse, so you can respond to the Paste action.

Currently, the org.eclipse.swt.dnd package includes support for Text,
URL, RTF, HTML, and File Transfers. JFace adds a LocalSelectionTransfer
for moving an ISelection inside an application. The RCP UI adds an
EditorInputTransfer. There is a Windows-specific Transfer subclass for
the standard Win32 clipboard image format. Anything else you might like
to move must be rendered down to a byte array in a custom subclass of
ByteArrayTransfer.

--
Peter
Re: CopyPaste option in GridViewer [message #39301 is a reply to message #39147] Tue, 04 September 2007 06:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

hello Mr Peter Centgraf,
Thanks for ur reply.
But i need some more clarification.Do I really need to create my own
context menu?can't i get the System menu like what it is coming in the
eclipse problem view.

Also in a GridTableViewer i am creating a combo in a particular column.and
also i need to create in a particular column some textbox and some combo.
but as far as i am concerned we can create one widget type in one column.
either combo or button or simple text.but i need the combination of combo
and text in one column.

If it is a combo my labelprovider is returning a single string i,e
getColumnText.But i need arrays of String which will update my combo
through label provider.

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #39363 is a reply to message #39301] Tue, 04 September 2007 06:12 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
DebasisMishra schrieb:
> hello Mr Peter Centgraf,
> Thanks for ur reply.
> But i need some more clarification.Do I really need to create my own
> context menu?can't i get the System menu like what it is coming in the
> eclipse problem view.
>
> Also in a GridTableViewer i am creating a combo in a particular
> column.and also i need to create in a particular column some textbox and
> some combo.
> but as far as i am concerned we can create one widget type in one column.
> either combo or button or simple text.but i need the combination of
> combo and text in one column.
>

In the same row? If yes, then you need to implement your own CellEditor
which is a Composite and has 2 controls below it. The only problem I see
is how you know when editing is finished?

If you mean ***not*** in the same row or better cell at the same time
and you use the new EditingSupport-API you can do that without problems.

> If it is a combo my labelprovider is returning a single string i,e
> getColumnText.But i need arrays of String which will update my combo
> through label provider.
>

Why are you updating your Combo/Text with values from the LabelProvider?
The value the editors are set to are the ones you return from
EditingSupport or ICellModifier and you can return an Object from there.
The real problem you have to solve is the above one.

Another possibility is to use a DialogCellEditor!

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: CopyPaste option in GridViewer [message #39394 is a reply to message #39363] Wed, 05 September 2007 06:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
Thanks a lot.I implemented ur suggestion.Now i am populating my combo
through cellmodifier not through labelprovider.

I am also trying to create my combo/text/button in my modifier class.but
it is not creating.because the creation is done only at gridcreation.

This is my code snippet below
editors[3]= new ComboCellEditor(confGridViewer.getGrid());it is creating
the combo.

but is it feasible to create the combo/text in a particular column in my
modifier class.but if i will set the cellEditors as ComboCellEditor during
grid creation then i am wondering how it will create text/button for that
particular column in the modifier class?

but eclipse properties view is having the feature of creating the
combo/text/button in a single column on demand.


Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #39425 is a reply to message #39394] Wed, 05 September 2007 07:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Don't use the ICellModifier interface, use the new JFace-API which
requests the appropriate widget from you.

Here's an example for TableViewer:
http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet034Ce llEditorPerRowNewAPI

There's also an example how this could be achieved using the old API
http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet033Ce llEditorPerRowPre33
but because you have to use 3.3 to get the GridViewer I suggest to use
the new API. IMHO this is far the better one but I'm a bit biased
because I'm one of the designers of the new API.

Tom

DebasisMishra schrieb:
> Hello Mr Tom,
> Thanks a lot.I implemented ur suggestion.Now i am populating my combo
> through cellmodifier not through labelprovider.
>
> I am also trying to create my combo/text/button in my modifier class.but
> it is not creating.because the creation is done only at gridcreation.
>
> This is my code snippet below
> editors[3]= new ComboCellEditor(confGridViewer.getGrid());it is
> creating the combo.
>
> but is it feasible to create the combo/text in a particular column in my
> modifier class.but if i will set the cellEditors as ComboCellEditor
> during grid creation then i am wondering how it will create text/button
> for that particular column in the modifier class?
>
> but eclipse properties view is having the feature of creating the
> combo/text/button in a single column on demand.
>
>
> Thanks in advance
> Debasis
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: CopyPaste option in GridViewer [message #39455 is a reply to message #39425] Wed, 05 September 2007 11:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
Thanks a lot for the link.Thanks a lot for the very quick reply.

I tried out all the snippet.It is simple in eclipse 3.3 by using
EditingSupport.currently i am also using eclipse europa and
NebulaGridTableViewer.I will implement this in my project.

one more clarification i need that- is NebulaGridTableViewer providing
any option for CopyPaste?.Actually i need to copy some selected cell and i
need to paste it in different cell(means my domain object i need to copy
what i am displaying in the table.)

Can I enable the context menu(i,e global context menu for
copy,paste,delete,select all,properties).I will not create my own context
menu.is there any way to get the context menu from workbench.mean to say
is there any contribution form eclipse?

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #39486 is a reply to message #39455] Wed, 05 September 2007 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
I am trying to get the context menu in my tableviewer through
MenuManager.but not getting that.
The code snippet is given below
MenuManager mgr = new MenuManager();
mgr.add(
new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)
); // needed for later contributions


problemViewer.getTable().setMenu(mgr.createContextMenu(probl emViewer.getTable()));


Could u please tell me if am missing something any where.?

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #39517 is a reply to message #39486] Wed, 05 September 2007 14:49 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Your menu has no items, so it won't be displayed.

Tom

DebasisMishra schrieb:
> Hello Mr Tom,
> I am trying to get the context menu in my tableviewer through
> MenuManager.but not getting that.
> The code snippet is given below
> MenuManager mgr = new MenuManager(); mgr.add( new
> GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS) ); // needed for
> later contributions
>
> problemViewer.getTable().setMenu(mgr.createContextMenu(probl emViewer.getTable()));
>
>
> Could u please tell me if am missing something any where.?
>
> Thanks in advance
> Debasis
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: CopyPaste option in GridViewer [message #584299 is a reply to message #38914] Tue, 28 August 2007 16:52 Go to previous message
Peter Centgraf is currently offline Peter CentgrafFriend
Messages: 52
Registered: July 2009
Member
I haven't worked with Grid, but I have worked with Table and the
clipboard. Someone else will have to correct me if Grid has special
support I don't know about.

A widget like Grid typically does not interact with the clipboard on
your behalf. Your application must provide the appropriate actions to
trigger the clipboard operations, and it must also respond to those
actions by manipulating the clipboard and/or the widget.

In your case, you would need to define and respond to a Copy action.
Your code should loop over the selection within the Grid, copy the
appropriate data into a data structure, and push that data structure
onto the clipboard. You must define exactly what the "appropriate data"
is and what the "data structure" will be. If you only need to move data
within your running application, simple Java object references might be
sufficient. If you want to move data between applications, you will
need to serialize a full representation of the objects. If you want to
exchange data with Excel, you'll have to represent the data in a
clipboard format Excel can understand.

.... Then you must do the reverse, so you can respond to the Paste action.

Currently, the org.eclipse.swt.dnd package includes support for Text,
URL, RTF, HTML, and File Transfers. JFace adds a LocalSelectionTransfer
for moving an ISelection inside an application. The RCP UI adds an
EditorInputTransfer. There is a Windows-specific Transfer subclass for
the standard Win32 clipboard image format. Anything else you might like
to move must be rendered down to a byte array in a custom subclass of
ByteArrayTransfer.

--
Peter
Re: CopyPaste option in GridViewer [message #584374 is a reply to message #39147] Tue, 04 September 2007 06:02 Go to previous message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

hello Mr Peter Centgraf,
Thanks for ur reply.
But i need some more clarification.Do I really need to create my own
context menu?can't i get the System menu like what it is coming in the
eclipse problem view.

Also in a GridTableViewer i am creating a combo in a particular column.and
also i need to create in a particular column some textbox and some combo.
but as far as i am concerned we can create one widget type in one column.
either combo or button or simple text.but i need the combination of combo
and text in one column.

If it is a combo my labelprovider is returning a single string i,e
getColumnText.But i need arrays of String which will update my combo
through label provider.

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #584403 is a reply to message #39301] Tue, 04 September 2007 06:12 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
DebasisMishra schrieb:
> hello Mr Peter Centgraf,
> Thanks for ur reply.
> But i need some more clarification.Do I really need to create my own
> context menu?can't i get the System menu like what it is coming in the
> eclipse problem view.
>
> Also in a GridTableViewer i am creating a combo in a particular
> column.and also i need to create in a particular column some textbox and
> some combo.
> but as far as i am concerned we can create one widget type in one column.
> either combo or button or simple text.but i need the combination of
> combo and text in one column.
>

In the same row? If yes, then you need to implement your own CellEditor
which is a Composite and has 2 controls below it. The only problem I see
is how you know when editing is finished?

If you mean ***not*** in the same row or better cell at the same time
and you use the new EditingSupport-API you can do that without problems.

> If it is a combo my labelprovider is returning a single string i,e
> getColumnText.But i need arrays of String which will update my combo
> through label provider.
>

Why are you updating your Combo/Text with values from the LabelProvider?
The value the editors are set to are the ones you return from
EditingSupport or ICellModifier and you can return an Object from there.
The real problem you have to solve is the above one.

Another possibility is to use a DialogCellEditor!

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: CopyPaste option in GridViewer [message #584425 is a reply to message #39363] Wed, 05 September 2007 06:14 Go to previous message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
Thanks a lot.I implemented ur suggestion.Now i am populating my combo
through cellmodifier not through labelprovider.

I am also trying to create my combo/text/button in my modifier class.but
it is not creating.because the creation is done only at gridcreation.

This is my code snippet below
editors[3]= new ComboCellEditor(confGridViewer.getGrid());it is creating
the combo.

but is it feasible to create the combo/text in a particular column in my
modifier class.but if i will set the cellEditors as ComboCellEditor during
grid creation then i am wondering how it will create text/button for that
particular column in the modifier class?

but eclipse properties view is having the feature of creating the
combo/text/button in a single column on demand.


Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #584436 is a reply to message #39394] Wed, 05 September 2007 07:33 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Don't use the ICellModifier interface, use the new JFace-API which
requests the appropriate widget from you.

Here's an example for TableViewer:
http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet034Ce llEditorPerRowNewAPI

There's also an example how this could be achieved using the old API
http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet033Ce llEditorPerRowPre33
but because you have to use 3.3 to get the GridViewer I suggest to use
the new API. IMHO this is far the better one but I'm a bit biased
because I'm one of the designers of the new API.

Tom

DebasisMishra schrieb:
> Hello Mr Tom,
> Thanks a lot.I implemented ur suggestion.Now i am populating my combo
> through cellmodifier not through labelprovider.
>
> I am also trying to create my combo/text/button in my modifier class.but
> it is not creating.because the creation is done only at gridcreation.
>
> This is my code snippet below
> editors[3]= new ComboCellEditor(confGridViewer.getGrid());it is
> creating the combo.
>
> but is it feasible to create the combo/text in a particular column in my
> modifier class.but if i will set the cellEditors as ComboCellEditor
> during grid creation then i am wondering how it will create text/button
> for that particular column in the modifier class?
>
> but eclipse properties view is having the feature of creating the
> combo/text/button in a single column on demand.
>
>
> Thanks in advance
> Debasis
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: CopyPaste option in GridViewer [message #584447 is a reply to message #39425] Wed, 05 September 2007 11:02 Go to previous message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
Thanks a lot for the link.Thanks a lot for the very quick reply.

I tried out all the snippet.It is simple in eclipse 3.3 by using
EditingSupport.currently i am also using eclipse europa and
NebulaGridTableViewer.I will implement this in my project.

one more clarification i need that- is NebulaGridTableViewer providing
any option for CopyPaste?.Actually i need to copy some selected cell and i
need to paste it in different cell(means my domain object i need to copy
what i am displaying in the table.)

Can I enable the context menu(i,e global context menu for
copy,paste,delete,select all,properties).I will not create my own context
menu.is there any way to get the context menu from workbench.mean to say
is there any contribution form eclipse?

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #584461 is a reply to message #39455] Wed, 05 September 2007 14:48 Go to previous message
Eclipse UserFriend
Originally posted by: Debasis.Mishra.in.bosch.com

Hello Mr Tom,
I am trying to get the context menu in my tableviewer through
MenuManager.but not getting that.
The code snippet is given below
MenuManager mgr = new MenuManager();
mgr.add(
new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)
); // needed for later contributions


problemViewer.getTable().setMenu(mgr.createContextMenu(probl emViewer.getTable()));


Could u please tell me if am missing something any where.?

Thanks in advance
Debasis
Re: CopyPaste option in GridViewer [message #584470 is a reply to message #39486] Wed, 05 September 2007 14:49 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Your menu has no items, so it won't be displayed.

Tom

DebasisMishra schrieb:
> Hello Mr Tom,
> I am trying to get the context menu in my tableviewer through
> MenuManager.but not getting that.
> The code snippet is given below
> MenuManager mgr = new MenuManager(); mgr.add( new
> GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS) ); // needed for
> later contributions
>
> problemViewer.getTable().setMenu(mgr.createContextMenu(probl emViewer.getTable()));
>
>
> Could u please tell me if am missing something any where.?
>
> Thanks in advance
> Debasis
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Hiding and unhiding the columns
Next Topic:How to insert CalendarableItem in DayEditor?
Goto Forum:
  


Current Time: Fri Mar 29 01:44:53 GMT 2024

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

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

Back to the top