copy & paste [message #46801] |
Tue, 12 September 2006 15:09  |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
Hi all,
Copy and Paste worked out of the box. However I have the following problem:
Pasting works only if the target is the diagram itself. I cannot seem to
paste into a compartment (it has the ContainerEditPolicy installed). So
basically, if I copy smth from one compartment and paste it into another,
it doesn't work.
This is what I know so far:
In PasteCommand the method below
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
/* Paste on the target */
if (data != null && data.length > 0) {
List allViews = new ArrayList();
for (int j = 0; j < data.length; j++) {
/* Get the string from the clipboard data */
String xml = new String(data[j].getData());
/* Paste the xml on to the target view's diagram */
List views = pasteFromString(getViewContext(),xml);
allViews.addAll(views);
}
return CommandResult.newOKCommandResult(allViews);
}
return CommandResult.newOKCommandResult();
}
when the target is anything other then the diagram itself, the 'views'
variable is always an empty list, the xml string has the same value when
pasting the same element.
I'm looking forward to some suggestions, please help!
vlad
|
|
|
Re: copy & paste [message #48161 is a reply to message #46801] |
Thu, 14 September 2006 12:21   |
Eclipse User |
|
|
|
I had the same problem. Forget about pasting into compartments - GMF's
diagrams are flat and don't support elements nesting almost at all.
If you need such behavior you have to write copy/paste actions by yourself.
First, you need to implement extension for
org.eclipse.gmf.runtime.common.ui.services.action.globalActi onHandlerProviders
which will return your own implementation of
'AbstractGlobalActionHandler'
Look at their
'DiagramGlobalActionHandler'
And for God's sake DON'T use serialization for copy/paste like they did! I
don't think you're gona use your diagram objects in different applications.
Pick standard clipboard functionality provided by 'EditingDomain' - just put
duplicates of your selected entities (with no references to outside objects
or think out something) in that collection.
Good luck
"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2006.09.12.19.09.17.591580@uwaterloo.ca...
> Hi all,
>
> Copy and Paste worked out of the box. However I have the following
> problem:
>
> Pasting works only if the target is the diagram itself. I cannot seem to
> paste into a compartment (it has the ContainerEditPolicy installed). So
> basically, if I copy smth from one compartment and paste it into another,
> it doesn't work.
>
> This is what I know so far:
>
> In PasteCommand the method below
>
> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
> IAdaptable info)
> throws ExecutionException {
>
> /* Paste on the target */
> if (data != null && data.length > 0) {
> List allViews = new ArrayList();
> for (int j = 0; j < data.length; j++) {
> /* Get the string from the clipboard data */
> String xml = new String(data[j].getData());
>
> /* Paste the xml on to the target view's diagram */
> List views = pasteFromString(getViewContext(),xml);
> allViews.addAll(views);
> }
> return CommandResult.newOKCommandResult(allViews);
> }
> return CommandResult.newOKCommandResult();
> }
>
> when the target is anything other then the diagram itself, the 'views'
> variable is always an empty list, the xml string has the same value when
> pasting the same element.
>
> I'm looking forward to some suggestions, please help!
>
> vlad
>
>
>
>
|
|
|
Re: copy & paste [message #49941 is a reply to message #48161] |
Mon, 18 September 2006 09:53  |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
It's good to know I'm not the only one in this position. Thanks for the
advice, I'll keep you posted when I get it done.
cheers
vlad
On Thu, 14 Sep 2006 11:21:08 -0500, Vyacheslav Zakovyrya wrote:
> I had the same problem. Forget about pasting into compartments - GMF's
> diagrams are flat and don't support elements nesting almost at all.
> If you need such behavior you have to write copy/paste actions by yourself.
> First, you need to implement extension for
> org.eclipse.gmf.runtime.common.ui.services.action.globalActi onHandlerProviders
> which will return your own implementation of
> 'AbstractGlobalActionHandler'
>
> Look at their
>
> 'DiagramGlobalActionHandler'
>
> And for God's sake DON'T use serialization for copy/paste like they did! I
> don't think you're gona use your diagram objects in different applications.
> Pick standard clipboard functionality provided by 'EditingDomain' - just put
> duplicates of your selected entities (with no references to outside objects
> or think out something) in that collection.
>
> Good luck
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2006.09.12.19.09.17.591580@uwaterloo.ca...
>> Hi all,
>>
>> Copy and Paste worked out of the box. However I have the following
>> problem:
>>
>> Pasting works only if the target is the diagram itself. I cannot seem to
>> paste into a compartment (it has the ContainerEditPolicy installed). So
>> basically, if I copy smth from one compartment and paste it into another,
>> it doesn't work.
>>
>> This is what I know so far:
>>
>> In PasteCommand the method below
>>
>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>> IAdaptable info)
>> throws ExecutionException {
>>
>> /* Paste on the target */
>> if (data != null && data.length > 0) {
>> List allViews = new ArrayList();
>> for (int j = 0; j < data.length; j++) {
>> /* Get the string from the clipboard data */
>> String xml = new String(data[j].getData());
>>
>> /* Paste the xml on to the target view's diagram */
>> List views = pasteFromString(getViewContext(),xml);
>> allViews.addAll(views);
>> }
>> return CommandResult.newOKCommandResult(allViews);
>> }
>> return CommandResult.newOKCommandResult();
>> }
>>
>> when the target is anything other then the diagram itself, the 'views'
>> variable is always an empty list, the xml string has the same value when
>> pasting the same element.
>>
>> I'm looking forward to some suggestions, please help!
>>
>> vlad
>>
>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.07629 seconds