CopyAction [message #179563] |
Thu, 28 April 2005 12: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 #179938 is a reply to message #179926] |
Mon, 02 May 2005 06: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 07:43   |
Eclipse User |
|
|
|
"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 #180829 is a reply to message #180771] |
Tue, 10 May 2005 14:05  |
Eclipse User |
|
|
|
My Copy action copies only the model. Paste 'adds' the copied model to the
parent similar to the way its done when you select a model tool from the
palette to add to your 'diagram'. The edit part mechanism will create a
new edit part for the newly pasted model object during the refresh
process.
The only problem i'm having is that i'm unable to determine the mouse
click location when i try to paste the new model. This is because the
default SelectTool does not store the latest right mouse click location or
atleast i could not find it. So, my paste always adds the new model to
point (10, 10) - which is ugly.
sapna
|
|
|
Powered by
FUDForum. Page generated in 0.29068 seconds