CopyAction [message #179563] |
Thu, 28 April 2005 16:21 |
Eclipse User |
|
|
|
Originally posted by: sidus68.yahoo.com
Hi!
I have been looking at copy/paste based on suggestions from previous
postings... and have a slight problem:
if I include the following code in the createActions method of my editor:
action = new CopyAction ((IWorkbenchPart) this);
registry.registerAction (action);
getSelectionActions().add (action.getId());
I get the following:
java.lang.ClassCastException: net.ibs.forms.editor.actions.CopyAction
at
net.ibs.forms.editor.FormModelEditor$6.hookPaletteViewer(For mModelEditor.java:367)
at
org.eclipse.gef.ui.palette.PaletteViewerProvider.createPalet teViewer(PaletteViewerProvider.java:59)
at
org.eclipse.gef.ui.palette.FlyoutPaletteComposite.setState(F lyoutPaletteComposite.java:510)
at
org.eclipse.gef.ui.palette.FlyoutPaletteComposite.<init>(FlyoutPaletteComposite.java:178)
at
org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette.cr eatePartControl(GraphicalEditorWithFlyoutPalette.java:75)
at org.eclipse.ui.internal.PartPane$2.run(PartPane.java:137)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at org.eclipse.ui.internal.PartPane.createChildControl(PartPane .java:133)
at org.eclipse.ui.internal.PartPane.createControl(PartPane.java :205)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:939)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:921)
at org.eclipse.ui.internal.EditorStack.setSelection(EditorStack .java:196)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:10 20)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:290)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:121 )
at
org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:59)
at
org.eclipse.ui.internal.EditorAreaHelper.openEditor(EditorAr eaHelper.java:266)
at org.eclipse.ui.internal.EditorManager$4.run(EditorManager.ja va:694)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:683)
at
org.eclipse.ui.internal.EditorManager.openInternalEditor(Edi torManager.java:779)
at org.eclipse.ui.internal.EditorManager.access$12(EditorManage r.java:763)
at org.eclipse.ui.internal.EditorManager$9.run(EditorManager.ja va:948)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at
org.eclipse.ui.internal.EditorManager.busyRestoreEditor(Edit orManager.java:922)
at org.eclipse.ui.internal.EditorManager$8.run(EditorManager.ja va:915)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
at
org.eclipse.ui.internal.EditorManager.restoreEditor(EditorMa nager.java:911)
at
org.eclipse.ui.internal.EditorManager.restoreEditorState(Edi torManager.java:1487)
at
org.eclipse.ui.internal.EditorManager.restoreState(EditorMan ager.java:874)
at
org.eclipse.ui.internal.WorkbenchPage.restoreState(Workbench Page.java:2470)
at
org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1372)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1224)
at org.eclipse.ui.internal.Workbench.access$10(Workbench.java:1 185)
at org.eclipse.ui.internal.Workbench$13.run(Workbench.java:1096 )
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1029)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigurer.java:167)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:652)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:819)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1325)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:704)
at org.eclipse.core.launcher.Main.main(Main.java:688)
!ENTRY org.eclipse.core.runtime 4 2 Apr 28, 2005 18:14:39.816
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.core.runtime".
!STACK 0
java.lang.NullPointerException
at
org.eclipse.gef.ui.actions.ActionBarContributor.setActiveEdi tor(ActionBarContributor.java:139)
at
org.eclipse.ui.internal.EditorActionBars.partChanged(EditorA ctionBars.java:297)
at org.eclipse.ui.internal.WorkbenchPage$2.run(WorkbenchPage.ja va:476)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at
org.eclipse.ui.internal.WorkbenchPage.activatePart(Workbench Page.java:468)
at
org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPa ge.java:2080)
at
org.eclipse.ui.internal.WorkbenchWindow$4.run(WorkbenchWindo w.java:1858)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
at
org.eclipse.ui.internal.WorkbenchWindow.setActivePage(Workbe nchWindow.java:1845)
at
org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1409)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1224)
at org.eclipse.ui.internal.Workbench.access$10(Workbench.java:1 185)
at org.eclipse.ui.internal.Workbench$13.run(Workbench.java:1096 )
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1029)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigurer.java:167)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:652)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:819)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1325)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:704)
at org.eclipse.core.launcher.Main.main(Main.java:688)
(It seems the null pointer is being caused by the following line of code
in
org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(I EditorPart),
which returns null:
ActionRegistry registry =
(ActionRegistry)editor.getAdapter(ActionRegistry.class);
--- but assume that is irrelevant as it is most likely that the original
ClassCastException is causing the 2nd problme)
Any suggestions as to where I ahve gone wrong?
Many Thanks!
|
|
|
|
Re: CopyAction [message #179926 is a reply to message #179887] |
Mon, 02 May 2005 08:17 |
Eclipse User |
|
|
|
Originally posted by: sidus68.yahoo.com
hi, pratik!
my apologies. I have been coding for many years and my intention here is
to try to understand the mechanisms involved for myself, not have the
problem solved for me. I had tried to determine what was causing the
problem but was making no progress. this is exacerbated by the fact that I
am still trying to come to grips with GEF and how to define actions, etc.
my experience is more in system processes than user interface. I had taken
suggestions from earlier postings as my starting point for implementing
copy/paste (not templates as in the logic example). my CopyAction is
rather skeletal, based on code found in suggestions posted.
Kind Regards,
|
|
|
Re: CopyAction [message #179938 is a reply to message #179926] |
Mon, 02 May 2005 10:13 |
Eclipse User |
|
|
|
Originally posted by: sidney.lee.ibs.net
Anyway, problem solved (conflicts with CopyTemplateAction - am not sure
I understand the purpose of copying templates, its uses, etc.)
Have two further questions:
(i) Are there any patterns or general practices w.r.t. copy/paste? For
example, when editing window components and one selects a component
which has children (a group box, for example), do we copy the container
only or its children too? (if the latter, would this be compatible with
the selection of the container and some (but not all) of its children
for copying?)
(ii) When copying the selected edit parts to the clipboard, I assume the
CloneCommand in the logic example is a good starting point. However, is
a copy command necessary or would it suffice to perform the necessary
tasks within my CopyAction?
Many Thanks!
|
|
|
Re: CopyAction [message #179954 is a reply to message #179938] |
Mon, 02 May 2005 11:43 |
Pratik Shah Messages: 1077 Registered: July 2009 |
Senior Member |
|
|
"Sidney Lee" <sidney.lee@ibs.net> wrote in message
news:d54unu$6o3$1@news.eclipse.org...
> Anyway, problem solved (conflicts with CopyTemplateAction - am not sure
> I understand the purpose of copying templates, its uses, etc.)
That action is used to copy/paste from the palette. That provides an
accessible way of using the GEF palette.
>
> Have two further questions:
> (i) Are there any patterns or general practices w.r.t. copy/paste? For
> example, when editing window components and one selects a component
> which has children (a group box, for example), do we copy the container
> only or its children too? (if the latter, would this be compatible with
> the selection of the container and some (but not all) of its children
> for copying?)
Depends on your application. Most would copy the contents as well.
> (ii) When copying the selected edit parts to the clipboard, I assume the
> CloneCommand in the logic example is a good starting point. However, is
> a copy command necessary or would it suffice to perform the necessary
> tasks within my CopyAction?
Have your action do the copying. A command would modify the command stack.
>
> Many Thanks!
|
|
|
Re: CopyAction [message #180771 is a reply to message #179954] |
Tue, 10 May 2005 13:45 |
Eclipse User |
|
|
|
Originally posted by: sidney.lee.ibs.net
Hi, Pratik! (or anyone else who may have some ideas)
a few issues I forgot to mention last time:
(i) when copying to the clipboard, do we copy the EditPart or the model
object (EdtPart.getModel())? If the EditPart, is there anything I should
be aware of or take into consideration when introducing a copy() method
on my EditPart subclass?
(ii) when pasting, I have adopted the same approach as adding during a
move (orphan/add). However, XYLayoutEditPolicy.getAddCommand() applies
contraints and translations. So, I was wondering (assuming I would need
to do likewise and given that my understanding of the uses of
constraints, etc. is limited at best) how I would do so given the
inherent support within in the XYLayoutEditPolicy but which is not
available in my PasteAction (extends SelectionAction)?
Many Thanks!
|
|
|
Re: CopyAction [message #180778 is a reply to message #179954] |
Tue, 10 May 2005 13:49 |
Eclipse User |
|
|
|
Originally posted by: sidney.lee.ibs.net
Hi, Pratik! (or anyone else who may have some ideas)
a few issues I forgot to mention last time:
(i) when copying to the clipboard, do we copy the EditPart or the model
object (EdtPart.getModel())? If the EditPart, is there anything I should
be aware of or take into consideration when introducing a copy() method
on my EditPart subclass?
(ii) when pasting, I have adopted the same approach as adding during a
move (orphan/add). However, XYLayoutEditPolicy.getAddCommand() applies
contraints and translations. So, I was wondering (assuming I would need
to do likewise and given that my understanding of the uses of
constraints, etc. is limited at best) how I would do so given the
inherent support within in the XYLayoutEditPolicy but which is not
available in my PasteAction (extends SelectionAction)?
Many Thanks!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03436 seconds