Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » My AbstractDecoratedTextEditor doesn't respond to forward delete
My AbstractDecoratedTextEditor doesn't respond to forward delete [message #536964] Mon, 31 May 2010 17:20 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
I discovered today my TextEditor (public class SceneEditor extends AbstractDecoratedTextEditor {... ) does not respond to the DEL key and to several other related commands (e.g.: CTRL+D).

I did not change anything from defaults (willingly, I mean!).
Nearest thing (copied from somewhere) is:

public SceneEditor(World world) {
super();
// make sure we inherit all the text editing commands (delete line etc).
setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
configureInsertMode(SMART_INSERT, false);
setSourceViewerConfiguration(new SceneConfiguration(world, getPreferenceStore()));
setDocumentProvider(new SceneDocumentProvider());
}

but that's not the problem since removing *all* customization I still have the same behavior.

I tried Snipped25 and Snippet165 and they both perform as expected (forward delete works).

Where should I look?
I have no idea how these things are implemented.

Thanks
Mauro
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #539949 is a reply to message #536964] Mon, 14 June 2010 11:20 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mauro Condarelli wrote:
> I discovered today my TextEditor (public class SceneEditor extends AbstractDecoratedTextEditor {... ) does not respond to the DEL key and to several other related commands (e.g.: CTRL+D).
>
I can understand that Ctrl+D is not working but Delete should always
work. Maybe you forgot to provide a correct action contributor class
when defining your editor in the plugin.xml, e.g.

contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "

Dani
> I did not change anything from defaults (willingly, I mean!).
> Nearest thing (copied from somewhere) is:
>
> public SceneEditor(World world) {
> super();
> // make sure we inherit all the text editing commands (delete line etc).
> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
> configureInsertMode(SMART_INSERT, false);
> setSourceViewerConfiguration(new SceneConfiguration(world, getPreferenceStore()));
> setDocumentProvider(new SceneDocumentProvider());
> }
>
> but that's not the problem since removing *all* customization I still have the same behavior.
>
> I tried Snipped25 and Snippet165 and they both perform as expected (forward delete works).
>
> Where should I look?
> I have no idea how these things are implemented.
>
> Thanks
> Mauro
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #539998 is a reply to message #539949] Mon, 14 June 2010 14:14 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 14/06/2010 13.20, Daniel Megert wrote:
> Mauro Condarelli wrote:
>> I discovered today my TextEditor (public class SceneEditor extends
>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key and
>> to several other related commands (e.g.: CTRL+D).
> I can understand that Ctrl+D is not working but Delete should always
> work. Maybe you forgot to provide a correct action contributor class
> when defining your editor in the plugin.xml, e.g.
> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "

Thanks,
I had a problem in that department.
Unfortunately adding:

<editor
class="it.condarelli.writer.editors.SceneEditor"
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
icon="icons/16/EditPages.png"
id="it.condarelli.writer.editors.SceneEditor"
name="Scene Editor">
</editor>

Does *not* change the behavior.
DEL key is not recognized.

I put a breakpoint at org.eclipse.ui.editors.text.TextEditorActionContributor()
This constructor is *not* called.

Any idea about what I can/should check?

I should note This is a rather peculiar TextEditor (public class SceneEditor extends AbstractDecoratedTextEditor) having a custom DocumentProvider (public class SceneDocumentProvider extends AbstractDocumentProvider) and a custom EditorInput (public class SceneEditorInput implements IEditorInput) because I'm editing a (possibly very long) String contained in my EMF Model.
Can this be related? (I could have forgotten something).

TiA
Mauro

>
> Dani
>> I did not change anything from defaults (willingly, I mean!).
>> Nearest thing (copied from somewhere) is:
>>
>> public SceneEditor(World world) {
>> super();
>> // make sure we inherit all the text editing commands (delete line etc).
>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>> }); //$NON-NLS-1$
>> configureInsertMode(SMART_INSERT, false);
>> setSourceViewerConfiguration(new SceneConfiguration(world,
>> getPreferenceStore()));
>> setDocumentProvider(new SceneDocumentProvider());
>> }
>>
>> but that's not the problem since removing *all* customization I still
>> have the same behavior.
>>
>> I tried Snipped25 and Snippet165 and they both perform as expected
>> (forward delete works).
>>
>> Where should I look?
>> I have no idea how these things are implemented.
>>
>> Thanks
>> Mauro
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #540009 is a reply to message #539998] Mon, 14 June 2010 14:47 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mauro Condarelli wrote:
> On 14/06/2010 13.20, Daniel Megert wrote:
>
>> Mauro Condarelli wrote:
>>
>>> I discovered today my TextEditor (public class SceneEditor extends
>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key and
>>> to several other related commands (e.g.: CTRL+D).
>>>
>> I can understand that Ctrl+D is not working but Delete should always
>> work. Maybe you forgot to provide a correct action contributor class
>> when defining your editor in the plugin.xml, e.g.
>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>
>
> Thanks,
> I had a problem in that department.
> Unfortunately adding:
>
> <editor
> class="it.condarelli.writer.editors.SceneEditor"
> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
> icon="icons/16/EditPages.png"
> id="it.condarelli.writer.editors.SceneEditor"
> name="Scene Editor">
> </editor>
>
> Does *not* change the behavior.
> DEL key is not recognized.
>
> I put a breakpoint at org.eclipse.ui.editors.text.TextEditorActionContributor()
> This constructor is *not* called.
>
If that's the case then something is badly broken. Are you sure the
latest code is used when you try it out? However, pressing 'Delete'
should even work without that contributor.

Dani
> Any idea about what I can/should check?
>
> I should note This is a rather peculiar TextEditor (public class SceneEditor extends AbstractDecoratedTextEditor) having a custom DocumentProvider (public class SceneDocumentProvider extends AbstractDocumentProvider) and a custom EditorInput (public class SceneEditorInput implements IEditorInput) because I'm editing a (possibly very long) String contained in my EMF Model.
> Can this be related? (I could have forgotten something).
>
> TiA
> Mauro
>
>
>> Dani
>>
>>> I did not change anything from defaults (willingly, I mean!).
>>> Nearest thing (copied from somewhere) is:
>>>
>>> public SceneEditor(World world) {
>>> super();
>>> // make sure we inherit all the text editing commands (delete line etc).
>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>> }); //$NON-NLS-1$
>>> configureInsertMode(SMART_INSERT, false);
>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>> getPreferenceStore()));
>>> setDocumentProvider(new SceneDocumentProvider());
>>> }
>>>
>>> but that's not the problem since removing *all* customization I still
>>> have the same behavior.
>>>
>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>> (forward delete works).
>>>
>>> Where should I look?
>>> I have no idea how these things are implemented.
>>>
>>> Thanks
>>> Mauro
>>>
>
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #540020 is a reply to message #540009] Mon, 14 June 2010 15:22 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 14/06/2010 16.47, Daniel Megert wrote:
> Mauro Condarelli wrote:
>> On 14/06/2010 13.20, Daniel Megert wrote:
>>> Mauro Condarelli wrote:
>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>> and to several other related commands (e.g.: CTRL+D).
>>> I can understand that Ctrl+D is not working but Delete should always
>>> work. Maybe you forgot to provide a correct action contributor class
>>> when defining your editor in the plugin.xml, e.g.
>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>
>>
>> Thanks,
>> I had a problem in that department.
>> Unfortunately adding:
>>
>> <editor
>> class="it.condarelli.writer.editors.SceneEditor"
>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>
>> icon="icons/16/EditPages.png"
>> id="it.condarelli.writer.editors.SceneEditor"
>> name="Scene Editor">
>> </editor>
>>
>> Does *not* change the behavior.
>> DEL key is not recognized.
>>
>> I put a breakpoint at
>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>> This constructor is *not* called.
> If that's the case then something is badly broken. Are you sure the
> latest code is used when you try it out? However, pressing 'Delete'
> should even work without that contributor.
>
> Dani

One thing that *might* be relevant:
As said I use this TextEditor as a sub-editor to edit a String.
Thus it is never instantiated from the normal workbench machinery.

I instantiate it explicitly while building a custom FormPage:

....
editor = new SceneEditor(world);
try {
IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
editor.init(site, editorInput);
editor.createPartControl(scrolledForm.getBody());

Object o = editor.getAdapter(StyledText.class);
styledText = (StyledText) o;
managedForm.getToolkit().paintBordersFor(styledText);
} catch (PartInitException e) {
Text txt = managedForm.getToolkit().createText(composite, "chapter", SWT.MULTI);
txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
StringBuilder sb = new StringBuilder();
sb.append(e.getMessage());
sb.append("\n\n");
StringWriter w = new StringWriter();
PrintWriter pw = new PrintWriter(w);
e.printStackTrace(pw);
sb.append(w.getBuffer());
txt.setText(sb.toString());
}
....

public class SceneEditor extends AbstractDecoratedTextEditor {

public static final String ID = "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$

public SceneEditor(World world) {
super();
// make sure we inherit all the text editing commands (delete line etc).
setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
configureInsertMode(SMART_INSERT, false);
setSourceViewerConfiguration(new SceneConfiguration(world, getPreferenceStore()));
setDocumentProvider(new SceneDocumentProvider());
}
....

I cleaned all the involved projects, deleted the run configurations and the runtime directories.
The behavior remains.

I have a rather cryptic .log file:

!SESSION 2010-06-14 17:15:35.275 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
Framework arguments: -product Writer.product
Command-line arguments: -product Writer.product -data C:\Users\mauro\workspace/../runtime-Writer.product -dev file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
!MESSAGE Reference item additions not found for action null

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>> Any idea about what I can/should check?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I' rather desperate by now.
This is my first non-token RCP project, so I might heve done *BIG* mistakes.


Thanks for Your patience.

Regards
Mauro


>>
>> I should note This is a rather peculiar TextEditor (public class
>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>> DocumentProvider (public class SceneDocumentProvider extends
>> AbstractDocumentProvider) and a custom EditorInput (public class
>> SceneEditorInput implements IEditorInput) because I'm editing a
>> (possibly very long) String contained in my EMF Model.
>> Can this be related? (I could have forgotten something).
>>
>> TiA
>> Mauro
>>
>>> Dani
>>>> I did not change anything from defaults (willingly, I mean!).
>>>> Nearest thing (copied from somewhere) is:
>>>>
>>>> public SceneEditor(World world) {
>>>> super();
>>>> // make sure we inherit all the text editing commands (delete line
>>>> etc).
>>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>>> }); //$NON-NLS-1$
>>>> configureInsertMode(SMART_INSERT, false);
>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>> getPreferenceStore()));
>>>> setDocumentProvider(new SceneDocumentProvider());
>>>> }
>>>>
>>>> but that's not the problem since removing *all* customization I
>>>> still have the same behavior.
>>>>
>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>> (forward delete works).
>>>>
>>>> Where should I look?
>>>> I have no idea how these things are implemented.
>>>>
>>>> Thanks
>>>> Mauro
>>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #540044 is a reply to message #540020] Mon, 14 June 2010 16:33 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mauro Condarelli wrote:
> On 14/06/2010 16.47, Daniel Megert wrote:
>
>> Mauro Condarelli wrote:
>>
>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>
>>>> Mauro Condarelli wrote:
>>>>
>>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>>
>>>> I can understand that Ctrl+D is not working but Delete should always
>>>> work. Maybe you forgot to provide a correct action contributor class
>>>> when defining your editor in the plugin.xml, e.g.
>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>
>>>>
>>> Thanks,
>>> I had a problem in that department.
>>> Unfortunately adding:
>>>
>>> <editor
>>> class="it.condarelli.writer.editors.SceneEditor"
>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>
>>> icon="icons/16/EditPages.png"
>>> id="it.condarelli.writer.editors.SceneEditor"
>>> name="Scene Editor">
>>> </editor>
>>>
>>> Does *not* change the behavior.
>>> DEL key is not recognized.
>>>
>>> I put a breakpoint at
>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>> This constructor is *not* called.
>>>
>> If that's the case then something is badly broken. Are you sure the
>> latest code is used when you try it out? However, pressing 'Delete'
>> should even work without that contributor.
>>
>> Dani
>>
>
> One thing that *might* be relevant:
> As said I use this TextEditor as a sub-editor to edit a String.
> Thus it is never instantiated from the normal workbench machinery.
>
But it's in a multi-page editor, right? In that case you need to make
sure that the correct contributor is uses when that page is active, see
MultiPageEditorActionBarContributor.

Dani
> I instantiate it explicitly while building a custom FormPage:
>
> ...
> editor = new SceneEditor(world);
> try {
> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
> editor.init(site, editorInput);
> editor.createPartControl(scrolledForm.getBody());
>
> Object o = editor.getAdapter(StyledText.class);
> styledText = (StyledText) o;
> managedForm.getToolkit().paintBordersFor(styledText);
> } catch (PartInitException e) {
> Text txt = managedForm.getToolkit().createText(composite, "chapter", SWT.MULTI);
> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
> StringBuilder sb = new StringBuilder();
> sb.append(e.getMessage());
> sb.append("\n\n");
> StringWriter w = new StringWriter();
> PrintWriter pw = new PrintWriter(w);
> e.printStackTrace(pw);
> sb.append(w.getBuffer());
> txt.setText(sb.toString());
> }
> ...
>
> public class SceneEditor extends AbstractDecoratedTextEditor {
>
> public static final String ID = "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>
> public SceneEditor(World world) {
> super();
> // make sure we inherit all the text editing commands (delete line etc).
> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
> configureInsertMode(SMART_INSERT, false);
> setSourceViewerConfiguration(new SceneConfiguration(world, getPreferenceStore()));
> setDocumentProvider(new SceneDocumentProvider());
> }
> ...
>
> I cleaned all the involved projects, deleted the run configurations and the runtime directories.
> The behavior remains.
>
> I have a rather cryptic .log file:
>
> !SESSION 2010-06-14 17:15:35.275 -----------------------------------------------
> eclipse.buildId=unknown
> java.version=1.6.0_20
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
> Framework arguments: -product Writer.product
> Command-line arguments: -product Writer.product -data C:\Users\mauro\workspace/../runtime-Writer.product -dev file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties -os win32 -ws win32 -arch x86
>
> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
> !MESSAGE Reference item additions not found for action null
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>
>>> Any idea about what I can/should check?
>>>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> I' rather desperate by now.
> This is my first non-token RCP project, so I might heve done *BIG* mistakes.
>
>
> Thanks for Your patience.
>
> Regards
> Mauro
>
>
>
>>> I should note This is a rather peculiar TextEditor (public class
>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>> DocumentProvider (public class SceneDocumentProvider extends
>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>> (possibly very long) String contained in my EMF Model.
>>> Can this be related? (I could have forgotten something).
>>>
>>> TiA
>>> Mauro
>>>
>>>
>>>> Dani
>>>>
>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>> Nearest thing (copied from somewhere) is:
>>>>>
>>>>> public SceneEditor(World world) {
>>>>> super();
>>>>> // make sure we inherit all the text editing commands (delete line
>>>>> etc).
>>>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>>>> }); //$NON-NLS-1$
>>>>> configureInsertMode(SMART_INSERT, false);
>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>> getPreferenceStore()));
>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>> }
>>>>>
>>>>> but that's not the problem since removing *all* customization I
>>>>> still have the same behavior.
>>>>>
>>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>>> (forward delete works).
>>>>>
>>>>> Where should I look?
>>>>> I have no idea how these things are implemented.
>>>>>
>>>>> Thanks
>>>>> Mauro
>>>>>
>
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #540195 is a reply to message #540044] Tue, 15 June 2010 10:44 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 14/06/2010 18.33, Daniel Megert wrote:
> Mauro Condarelli wrote:
>> On 14/06/2010 16.47, Daniel Megert wrote:
>>> Mauro Condarelli wrote:
>>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>>> Mauro Condarelli wrote:
>>>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>> I can understand that Ctrl+D is not working but Delete should
>>>>> always work. Maybe you forgot to provide a correct action
>>>>> contributor class when defining your editor in the plugin.xml, e.g.
>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>
>>>> Thanks,
>>>> I had a problem in that department.
>>>> Unfortunately adding:
>>>>
>>>> <editor
>>>> class="it.condarelli.writer.editors.SceneEditor"
>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>
>>>> icon="icons/16/EditPages.png"
>>>> id="it.condarelli.writer.editors.SceneEditor"
>>>> name="Scene Editor">
>>>> </editor>
>>>>
>>>> Does *not* change the behavior.
>>>> DEL key is not recognized.
>>>>
>>>> I put a breakpoint at
>>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>>> This constructor is *not* called.
>>> If that's the case then something is badly broken. Are you sure the
>>> latest code is used when you try it out? However, pressing 'Delete'
>>> should even work without that contributor.
>>>
>>> Dani
>>
>> One thing that *might* be relevant:
>> As said I use this TextEditor as a sub-editor to edit a String.
>> Thus it is never instantiated from the normal workbench machinery.
> But it's in a multi-page editor, right? In that case you need to make
> sure that the correct contributor is uses when that page is active, see
> MultiPageEditorActionBarContributor.

Uhm...
I begin to see my (probably huge) problem.
Please confirm:

I am using a whole editor (SceneEditor extends
AbstractDecoratedTextEditor) as a Composite in a FormPage among other
(simpler) widgets.
This apparently works (the page is displayed exactly as I need it and
the editor is mostly working, including partitioning, syntax
highlighting, content assistance, ...), but I fear I'm missing some
initialization.

For sure I do not do anything like a custom
MultiPageEditorActionBarContributor.

Is there a way to make it work or should I change everything? (I hope not!)

Regards
Mauro

>
> Dani
>> I instantiate it explicitly while building a custom FormPage:
>>
>> ...
>> editor = new SceneEditor(world);
>> try {
>> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
>> editor.init(site, editorInput);
>> editor.createPartControl(scrolledForm.getBody());
>>
>> Object o = editor.getAdapter(StyledText.class);
>> styledText = (StyledText) o;
>> managedForm.getToolkit().paintBordersFor(styledText);
>> } catch (PartInitException e) {
>> Text txt = managedForm.getToolkit().createText(composite, "chapter",
>> SWT.MULTI);
>> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
>> StringBuilder sb = new StringBuilder();
>> sb.append(e.getMessage());
>> sb.append("\n\n");
>> StringWriter w = new StringWriter();
>> PrintWriter pw = new PrintWriter(w);
>> e.printStackTrace(pw);
>> sb.append(w.getBuffer());
>> txt.setText(sb.toString());
>> }
>> ...
>>
>> public class SceneEditor extends AbstractDecoratedTextEditor {
>>
>> public static final String ID =
>> "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>>
>> public SceneEditor(World world) {
>> super();
>> // make sure we inherit all the text editing commands (delete line etc).
>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>> }); //$NON-NLS-1$
>> configureInsertMode(SMART_INSERT, false);
>> setSourceViewerConfiguration(new SceneConfiguration(world,
>> getPreferenceStore()));
>> setDocumentProvider(new SceneDocumentProvider());
>> }
>> ...
>>
>> I cleaned all the involved projects, deleted the run configurations
>> and the runtime directories.
>> The behavior remains.
>>
>> I have a rather cryptic .log file:
>>
>> !SESSION 2010-06-14 17:15:35.275
>> -----------------------------------------------
>> eclipse.buildId=unknown
>> java.version=1.6.0_20
>> java.vendor=Sun Microsystems Inc.
>> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
>> Framework arguments: -product Writer.product
>> Command-line arguments: -product Writer.product -data
>> C:\Users\mauro\workspace/../runtime-Writer.product -dev
>> file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties
>> -os win32 -ws win32 -arch x86
>>
>> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
>> !MESSAGE Reference item additions not found for action null
>>
>> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>>>> Any idea about what I can/should check?
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> I' rather desperate by now.
>> This is my first non-token RCP project, so I might heve done *BIG*
>> mistakes.
>>
>>
>> Thanks for Your patience.
>>
>> Regards
>> Mauro
>>
>>
>>>> I should note This is a rather peculiar TextEditor (public class
>>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>>> DocumentProvider (public class SceneDocumentProvider extends
>>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>>> (possibly very long) String contained in my EMF Model.
>>>> Can this be related? (I could have forgotten something).
>>>>
>>>> TiA
>>>> Mauro
>>>>
>>>>> Dani
>>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>>> Nearest thing (copied from somewhere) is:
>>>>>>
>>>>>> public SceneEditor(World world) {
>>>>>> super();
>>>>>> // make sure we inherit all the text editing commands (delete line
>>>>>> etc).
>>>>>> setKeyBindingScopes(new String[] {
>>>>>> "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>> getPreferenceStore()));
>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>> }
>>>>>>
>>>>>> but that's not the problem since removing *all* customization I
>>>>>> still have the same behavior.
>>>>>>
>>>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>>>> (forward delete works).
>>>>>>
>>>>>> Where should I look?
>>>>>> I have no idea how these things are implemented.
>>>>>>
>>>>>> Thanks
>>>>>> Mauro
>>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #540206 is a reply to message #540195] Tue, 15 June 2010 11:09 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Mauro Condarelli wrote:
> On 14/06/2010 18.33, Daniel Megert wrote:
>> Mauro Condarelli wrote:
>>> On 14/06/2010 16.47, Daniel Megert wrote:
>>>> Mauro Condarelli wrote:
>>>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>>>> Mauro Condarelli wrote:
>>>>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>>> I can understand that Ctrl+D is not working but Delete should
>>>>>> always work. Maybe you forgot to provide a correct action
>>>>>> contributor class when defining your editor in the plugin.xml, e.g.
>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>
>>>>>>
>>>>> Thanks,
>>>>> I had a problem in that department.
>>>>> Unfortunately adding:
>>>>>
>>>>> <editor
>>>>> class="it.condarelli.writer.editors.SceneEditor"
>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>
>>>>>
>>>>> icon="icons/16/EditPages.png"
>>>>> id="it.condarelli.writer.editors.SceneEditor"
>>>>> name="Scene Editor">
>>>>> </editor>
>>>>>
>>>>> Does *not* change the behavior.
>>>>> DEL key is not recognized.
>>>>>
>>>>> I put a breakpoint at
>>>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>>>> This constructor is *not* called.
>>>> If that's the case then something is badly broken. Are you sure the
>>>> latest code is used when you try it out? However, pressing 'Delete'
>>>> should even work without that contributor.
>>>>
>>>> Dani
>>>
>>> One thing that *might* be relevant:
>>> As said I use this TextEditor as a sub-editor to edit a String.
>>> Thus it is never instantiated from the normal workbench machinery.
>> But it's in a multi-page editor, right? In that case you need to make
>> sure that the correct contributor is uses when that page is active, see
>> MultiPageEditorActionBarContributor.
>
> Uhm...
> I begin to see my (probably huge) problem.
> Please confirm:
>
> I am using a whole editor (SceneEditor extends
> AbstractDecoratedTextEditor) as a Composite in a FormPage among other
> (simpler) widgets.
> This apparently works (the page is displayed exactly as I need it and
> the editor is mostly working, including partitioning, syntax
> highlighting, content assistance, ...), but I fear I'm missing some
> initialization.
>
> For sure I do not do anything like a custom
> MultiPageEditorActionBarContributor.
>
> Is there a way to make it work or should I change everything? (I hope
> not!)
Sure you can make it work: the PDE editors (e.g.
'org.eclipse.pde.internal.ui.editor.schema.SchemaEditor') also work that
way. The first thing you need to do is to read the Javadoc of
'org.eclipse.ui.part.MultiPageEditorPart' and understand how it works. ;-)

Dani
>
> Regards
> Mauro
>
>>
>> Dani
>>> I instantiate it explicitly while building a custom FormPage:
>>>
>>> ...
>>> editor = new SceneEditor(world);
>>> try {
>>> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
>>> editor.init(site, editorInput);
>>> editor.createPartControl(scrolledForm.getBody());
>>>
>>> Object o = editor.getAdapter(StyledText.class);
>>> styledText = (StyledText) o;
>>> managedForm.getToolkit().paintBordersFor(styledText);
>>> } catch (PartInitException e) {
>>> Text txt = managedForm.getToolkit().createText(composite, "chapter",
>>> SWT.MULTI);
>>> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
>>> StringBuilder sb = new StringBuilder();
>>> sb.append(e.getMessage());
>>> sb.append("\n\n");
>>> StringWriter w = new StringWriter();
>>> PrintWriter pw = new PrintWriter(w);
>>> e.printStackTrace(pw);
>>> sb.append(w.getBuffer());
>>> txt.setText(sb.toString());
>>> }
>>> ...
>>>
>>> public class SceneEditor extends AbstractDecoratedTextEditor {
>>>
>>> public static final String ID =
>>> "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>>>
>>> public SceneEditor(World world) {
>>> super();
>>> // make sure we inherit all the text editing commands (delete line
>>> etc).
>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>> }); //$NON-NLS-1$
>>> configureInsertMode(SMART_INSERT, false);
>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>> getPreferenceStore()));
>>> setDocumentProvider(new SceneDocumentProvider());
>>> }
>>> ...
>>>
>>> I cleaned all the involved projects, deleted the run configurations
>>> and the runtime directories.
>>> The behavior remains.
>>>
>>> I have a rather cryptic .log file:
>>>
>>> !SESSION 2010-06-14 17:15:35.275
>>> -----------------------------------------------
>>> eclipse.buildId=unknown
>>> java.version=1.6.0_20
>>> java.vendor=Sun Microsystems Inc.
>>> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
>>> Framework arguments: -product Writer.product
>>> Command-line arguments: -product Writer.product -data
>>> C:\Users\mauro\workspace/../runtime-Writer.product -dev
>>> file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties
>>>
>>> -os win32 -ws win32 -arch x86
>>>
>>> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
>>> !MESSAGE Reference item additions not found for action null
>>>
>>> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>>>>> Any idea about what I can/should check?
>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>
>>> I' rather desperate by now.
>>> This is my first non-token RCP project, so I might heve done *BIG*
>>> mistakes.
>>>
>>>
>>> Thanks for Your patience.
>>>
>>> Regards
>>> Mauro
>>>
>>>
>>>>> I should note This is a rather peculiar TextEditor (public class
>>>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>>>> DocumentProvider (public class SceneDocumentProvider extends
>>>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>>>> (possibly very long) String contained in my EMF Model.
>>>>> Can this be related? (I could have forgotten something).
>>>>>
>>>>> TiA
>>>>> Mauro
>>>>>
>>>>>> Dani
>>>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>>>> Nearest thing (copied from somewhere) is:
>>>>>>>
>>>>>>> public SceneEditor(World world) {
>>>>>>> super();
>>>>>>> // make sure we inherit all the text editing commands (delete line
>>>>>>> etc).
>>>>>>> setKeyBindingScopes(new String[] {
>>>>>>> "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
>>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>>> getPreferenceStore()));
>>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>>> }
>>>>>>>
>>>>>>> but that's not the problem since removing *all* customization I
>>>>>>> still have the same behavior.
>>>>>>>
>>>>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>>>>> (forward delete works).
>>>>>>>
>>>>>>> Where should I look?
>>>>>>> I have no idea how these things are implemented.
>>>>>>>
>>>>>>> Thanks
>>>>>>> Mauro
>>>
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #541345 is a reply to message #540206] Sun, 20 June 2010 10:24 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 15/06/2010 13.09, Daniel Megert wrote:
> Mauro Condarelli wrote:
>> On 14/06/2010 18.33, Daniel Megert wrote:
>>> Mauro Condarelli wrote:
>>>> On 14/06/2010 16.47, Daniel Megert wrote:
>>>>> Mauro Condarelli wrote:
>>>>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>>>>> Mauro Condarelli wrote:
>>>>>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>>>> I can understand that Ctrl+D is not working but Delete should
>>>>>>> always work. Maybe you forgot to provide a correct action
>>>>>>> contributor class when defining your editor in the plugin.xml, e.g.
>>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>>
>>>>>>>
>>>>>> Thanks,
>>>>>> I had a problem in that department.
>>>>>> Unfortunately adding:
>>>>>>
>>>>>> <editor
>>>>>> class="it.condarelli.writer.editors.SceneEditor"
>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>
>>>>>>
>>>>>> icon="icons/16/EditPages.png"
>>>>>> id="it.condarelli.writer.editors.SceneEditor"
>>>>>> name="Scene Editor">
>>>>>> </editor>
>>>>>>
>>>>>> Does *not* change the behavior.
>>>>>> DEL key is not recognized.
>>>>>>
>>>>>> I put a breakpoint at
>>>>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>>>>> This constructor is *not* called.
>>>>> If that's the case then something is badly broken. Are you sure the
>>>>> latest code is used when you try it out? However, pressing 'Delete'
>>>>> should even work without that contributor.
>>>>>
>>>>> Dani
>>>>
>>>> One thing that *might* be relevant:
>>>> As said I use this TextEditor as a sub-editor to edit a String.
>>>> Thus it is never instantiated from the normal workbench machinery.
>>> But it's in a multi-page editor, right? In that case you need to make
>>> sure that the correct contributor is uses when that page is active, see
>>> MultiPageEditorActionBarContributor.
>>
>> Uhm...
>> I begin to see my (probably huge) problem.
>> Please confirm:
>>
>> I am using a whole editor (SceneEditor extends
>> AbstractDecoratedTextEditor) as a Composite in a FormPage among other
>> (simpler) widgets.
>> This apparently works (the page is displayed exactly as I need it and
>> the editor is mostly working, including partitioning, syntax
>> highlighting, content assistance, ...), but I fear I'm missing some
>> initialization.
>>
>> For sure I do not do anything like a custom
>> MultiPageEditorActionBarContributor.
>>
>> Is there a way to make it work or should I change everything? (I hope
>> not!)
> Sure you can make it work: the PDE editors (e.g.
> 'org.eclipse.pde.internal.ui.editor.schema.SchemaEditor') also work that
> way. The first thing you need to do is to read the Javadoc of
> 'org.eclipse.ui.part.MultiPageEditorPart' and understand how it works. ;-)

Sorry, I failed (to understand how I can make it work for me).

I think the root of my problem is (WorldEditorContributor extends
MultiPageEditorActionBarContributor).setActivePage(IEditorPa rt part) is
always called with part == null.

This is consistent with the way part is built:

protected IEditorPart getEditor(int pageIndex) {
Item item = getItem(pageIndex);
if (item != null) {
Object data = item.getData();
if (data instanceof IEditorPart) {
return (IEditorPart) data;
}
}
return null;
}

Problem is my page (class SceneEditPage2 extends FormPage implements
ISelectionListener) is not an instanceof IEditorPart but it includes,
deep inside, as a normal widget, an instance of (class SceneEditor
extends AbstractDecoratedTextEditor).

This editor is orphan of an ActionBarContributor end hence malfunctioning.

I tried following
org.eclipse.pde.internal.ui.editor.schema.SchemaEditor, but I got lost.

Can You be a bit more explicit?

I'm currently trying to refactor my code so that SceneEditPage is an
IEditorPart. I am unsure if this is necessary and/or advisable, but I
see no other way.

Thanks in Advance
Mauro

>
> Dani
>>
>> Regards
>> Mauro
>>
>>>
>>> Dani
>>>> I instantiate it explicitly while building a custom FormPage:
>>>>
>>>> ...
>>>> editor = new SceneEditor(world);
>>>> try {
>>>> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
>>>> editor.init(site, editorInput);
>>>> editor.createPartControl(scrolledForm.getBody());
>>>>
>>>> Object o = editor.getAdapter(StyledText.class);
>>>> styledText = (StyledText) o;
>>>> managedForm.getToolkit().paintBordersFor(styledText);
>>>> } catch (PartInitException e) {
>>>> Text txt = managedForm.getToolkit().createText(composite, "chapter",
>>>> SWT.MULTI);
>>>> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
>>>> StringBuilder sb = new StringBuilder();
>>>> sb.append(e.getMessage());
>>>> sb.append("\n\n");
>>>> StringWriter w = new StringWriter();
>>>> PrintWriter pw = new PrintWriter(w);
>>>> e.printStackTrace(pw);
>>>> sb.append(w.getBuffer());
>>>> txt.setText(sb.toString());
>>>> }
>>>> ...
>>>>
>>>> public class SceneEditor extends AbstractDecoratedTextEditor {
>>>>
>>>> public static final String ID =
>>>> "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>>>>
>>>> public SceneEditor(World world) {
>>>> super();
>>>> // make sure we inherit all the text editing commands (delete line
>>>> etc).
>>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>>> }); //$NON-NLS-1$
>>>> configureInsertMode(SMART_INSERT, false);
>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>> getPreferenceStore()));
>>>> setDocumentProvider(new SceneDocumentProvider());
>>>> }
>>>> ...
>>>>
>>>> I cleaned all the involved projects, deleted the run configurations
>>>> and the runtime directories.
>>>> The behavior remains.
>>>>
>>>> I have a rather cryptic .log file:
>>>>
>>>> !SESSION 2010-06-14 17:15:35.275
>>>> -----------------------------------------------
>>>> eclipse.buildId=unknown
>>>> java.version=1.6.0_20
>>>> java.vendor=Sun Microsystems Inc.
>>>> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
>>>> Framework arguments: -product Writer.product
>>>> Command-line arguments: -product Writer.product -data
>>>> C:\Users\mauro\workspace/../runtime-Writer.product -dev
>>>> file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties
>>>>
>>>> -os win32 -ws win32 -arch x86
>>>>
>>>> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
>>>> !MESSAGE Reference item additions not found for action null
>>>>
>>>> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>>>>>> Any idea about what I can/should check?
>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>
>>>> I' rather desperate by now.
>>>> This is my first non-token RCP project, so I might heve done *BIG*
>>>> mistakes.
>>>>
>>>>
>>>> Thanks for Your patience.
>>>>
>>>> Regards
>>>> Mauro
>>>>
>>>>
>>>>>> I should note This is a rather peculiar TextEditor (public class
>>>>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>>>>> DocumentProvider (public class SceneDocumentProvider extends
>>>>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>>>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>>>>> (possibly very long) String contained in my EMF Model.
>>>>>> Can this be related? (I could have forgotten something).
>>>>>>
>>>>>> TiA
>>>>>> Mauro
>>>>>>
>>>>>>> Dani
>>>>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>>>>> Nearest thing (copied from somewhere) is:
>>>>>>>>
>>>>>>>> public SceneEditor(World world) {
>>>>>>>> super();
>>>>>>>> // make sure we inherit all the text editing commands (delete line
>>>>>>>> etc).
>>>>>>>> setKeyBindingScopes(new String[] {
>>>>>>>> "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
>>>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>>>> getPreferenceStore()));
>>>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>>>> }
>>>>>>>>
>>>>>>>> but that's not the problem since removing *all* customization I
>>>>>>>> still have the same behavior.
>>>>>>>>
>>>>>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>>>>>> (forward delete works).
>>>>>>>>
>>>>>>>> Where should I look?
>>>>>>>> I have no idea how these things are implemented.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Mauro
>>>>
>>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #541347 is a reply to message #541345] Sun, 20 June 2010 10:46 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 20/06/2010 12.24, Mauro Condarelli wrote:
> On 15/06/2010 13.09, Daniel Megert wrote:
>> Mauro Condarelli wrote:
>>> On 14/06/2010 18.33, Daniel Megert wrote:
>>>> Mauro Condarelli wrote:
>>>>> On 14/06/2010 16.47, Daniel Megert wrote:
>>>>>> Mauro Condarelli wrote:
>>>>>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>>>>>> Mauro Condarelli wrote:
>>>>>>>>> I discovered today my TextEditor (public class SceneEditor extends
>>>>>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL key
>>>>>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>>>>> I can understand that Ctrl+D is not working but Delete should
>>>>>>>> always work. Maybe you forgot to provide a correct action
>>>>>>>> contributor class when defining your editor in the plugin.xml, e.g.
>>>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Thanks,
>>>>>>> I had a problem in that department.
>>>>>>> Unfortunately adding:
>>>>>>>
>>>>>>> <editor
>>>>>>> class="it.condarelli.writer.editors.SceneEditor"
>>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> icon="icons/16/EditPages.png"
>>>>>>> id="it.condarelli.writer.editors.SceneEditor"
>>>>>>> name="Scene Editor">
>>>>>>> </editor>
>>>>>>>
>>>>>>> Does *not* change the behavior.
>>>>>>> DEL key is not recognized.
>>>>>>>
>>>>>>> I put a breakpoint at
>>>>>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>>>>>> This constructor is *not* called.
>>>>>> If that's the case then something is badly broken. Are you sure the
>>>>>> latest code is used when you try it out? However, pressing 'Delete'
>>>>>> should even work without that contributor.
>>>>>>
>>>>>> Dani
>>>>>
>>>>> One thing that *might* be relevant:
>>>>> As said I use this TextEditor as a sub-editor to edit a String.
>>>>> Thus it is never instantiated from the normal workbench machinery.
>>>> But it's in a multi-page editor, right? In that case you need to make
>>>> sure that the correct contributor is uses when that page is active, see
>>>> MultiPageEditorActionBarContributor.
>>>
>>> Uhm...
>>> I begin to see my (probably huge) problem.
>>> Please confirm:
>>>
>>> I am using a whole editor (SceneEditor extends
>>> AbstractDecoratedTextEditor) as a Composite in a FormPage among other
>>> (simpler) widgets.
>>> This apparently works (the page is displayed exactly as I need it and
>>> the editor is mostly working, including partitioning, syntax
>>> highlighting, content assistance, ...), but I fear I'm missing some
>>> initialization.
>>>
>>> For sure I do not do anything like a custom
>>> MultiPageEditorActionBarContributor.
>>>
>>> Is there a way to make it work or should I change everything? (I hope
>>> not!)
>> Sure you can make it work: the PDE editors (e.g.
>> 'org.eclipse.pde.internal.ui.editor.schema.SchemaEditor') also work that
>> way. The first thing you need to do is to read the Javadoc of
>> 'org.eclipse.ui.part.MultiPageEditorPart' and understand how it works.
>> ;-)
>
> Sorry, I failed (to understand how I can make it work for me).
>
> I think the root of my problem is (WorldEditorContributor extends
> MultiPageEditorActionBarContributor).setActivePage(IEditorPa rt part) is
> always called with part == null.
>
> This is consistent with the way part is built:
>
> protected IEditorPart getEditor(int pageIndex) {
> Item item = getItem(pageIndex);
> if (item != null) {
> Object data = item.getData();
> if (data instanceof IEditorPart) {
> return (IEditorPart) data;
> }
> }
> return null;
> }

UPDATE:
In the above code:
item is a CTabItem
data is null

I see nowhere a SceneEditPage2.
I am *very* confused: shouldn't the data field be handled automatically?
Should I do something about that??

TiA
Mauro

>
> Problem is my page (class SceneEditPage2 extends FormPage implements
> ISelectionListener) is not an instanceof IEditorPart but it includes,
> deep inside, as a normal widget, an instance of (class SceneEditor
> extends AbstractDecoratedTextEditor).
>
> This editor is orphan of an ActionBarContributor end hence malfunctioning.
>
> I tried following
> org.eclipse.pde.internal.ui.editor.schema.SchemaEditor, but I got lost.
>
> Can You be a bit more explicit?
>
> I'm currently trying to refactor my code so that SceneEditPage is an
> IEditorPart. I am unsure if this is necessary and/or advisable, but I
> see no other way.
>
> Thanks in Advance
> Mauro
>
>>
>> Dani
>>>
>>> Regards
>>> Mauro
>>>
>>>>
>>>> Dani
>>>>> I instantiate it explicitly while building a custom FormPage:
>>>>>
>>>>> ...
>>>>> editor = new SceneEditor(world);
>>>>> try {
>>>>> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
>>>>> editor.init(site, editorInput);
>>>>> editor.createPartControl(scrolledForm.getBody());
>>>>>
>>>>> Object o = editor.getAdapter(StyledText.class);
>>>>> styledText = (StyledText) o;
>>>>> managedForm.getToolkit().paintBordersFor(styledText);
>>>>> } catch (PartInitException e) {
>>>>> Text txt = managedForm.getToolkit().createText(composite, "chapter",
>>>>> SWT.MULTI);
>>>>> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
>>>>> StringBuilder sb = new StringBuilder();
>>>>> sb.append(e.getMessage());
>>>>> sb.append("\n\n");
>>>>> StringWriter w = new StringWriter();
>>>>> PrintWriter pw = new PrintWriter(w);
>>>>> e.printStackTrace(pw);
>>>>> sb.append(w.getBuffer());
>>>>> txt.setText(sb.toString());
>>>>> }
>>>>> ...
>>>>>
>>>>> public class SceneEditor extends AbstractDecoratedTextEditor {
>>>>>
>>>>> public static final String ID =
>>>>> "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>>>>>
>>>>> public SceneEditor(World world) {
>>>>> super();
>>>>> // make sure we inherit all the text editing commands (delete line
>>>>> etc).
>>>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>>>> }); //$NON-NLS-1$
>>>>> configureInsertMode(SMART_INSERT, false);
>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>> getPreferenceStore()));
>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>> }
>>>>> ...
>>>>>
>>>>> I cleaned all the involved projects, deleted the run configurations
>>>>> and the runtime directories.
>>>>> The behavior remains.
>>>>>
>>>>> I have a rather cryptic .log file:
>>>>>
>>>>> !SESSION 2010-06-14 17:15:35.275
>>>>> -----------------------------------------------
>>>>> eclipse.buildId=unknown
>>>>> java.version=1.6.0_20
>>>>> java.vendor=Sun Microsystems Inc.
>>>>> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
>>>>> Framework arguments: -product Writer.product
>>>>> Command-line arguments: -product Writer.product -data
>>>>> C:\Users\mauro\workspace/../runtime-Writer.product -dev
>>>>> file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties
>>>>>
>>>>>
>>>>> -os win32 -ws win32 -arch x86
>>>>>
>>>>> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
>>>>> !MESSAGE Reference item additions not found for action null
>>>>>
>>>>> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>>>>>>> Any idea about what I can/should check?
>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>
>>>>> I' rather desperate by now.
>>>>> This is my first non-token RCP project, so I might heve done *BIG*
>>>>> mistakes.
>>>>>
>>>>>
>>>>> Thanks for Your patience.
>>>>>
>>>>> Regards
>>>>> Mauro
>>>>>
>>>>>
>>>>>>> I should note This is a rather peculiar TextEditor (public class
>>>>>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>>>>>> DocumentProvider (public class SceneDocumentProvider extends
>>>>>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>>>>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>>>>>> (possibly very long) String contained in my EMF Model.
>>>>>>> Can this be related? (I could have forgotten something).
>>>>>>>
>>>>>>> TiA
>>>>>>> Mauro
>>>>>>>
>>>>>>>> Dani
>>>>>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>>>>>> Nearest thing (copied from somewhere) is:
>>>>>>>>>
>>>>>>>>> public SceneEditor(World world) {
>>>>>>>>> super();
>>>>>>>>> // make sure we inherit all the text editing commands (delete line
>>>>>>>>> etc).
>>>>>>>>> setKeyBindingScopes(new String[] {
>>>>>>>>> "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
>>>>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>>>>> getPreferenceStore()));
>>>>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> but that's not the problem since removing *all* customization I
>>>>>>>>> still have the same behavior.
>>>>>>>>>
>>>>>>>>> I tried Snipped25 and Snippet165 and they both perform as expected
>>>>>>>>> (forward delete works).
>>>>>>>>>
>>>>>>>>> Where should I look?
>>>>>>>>> I have no idea how these things are implemented.
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Mauro
>>>>>
>>>
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #541368 is a reply to message #541347] Sun, 20 June 2010 13:39 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
On 20/06/2010 12.46, Mauro Condarelli wrote:
> On 20/06/2010 12.24, Mauro Condarelli wrote:
>> On 15/06/2010 13.09, Daniel Megert wrote:
>>> Mauro Condarelli wrote:
>>>> On 14/06/2010 18.33, Daniel Megert wrote:
>>>>> Mauro Condarelli wrote:
>>>>>> On 14/06/2010 16.47, Daniel Megert wrote:
>>>>>>> Mauro Condarelli wrote:
>>>>>>>> On 14/06/2010 13.20, Daniel Megert wrote:
>>>>>>>>> Mauro Condarelli wrote:
>>>>>>>>>> I discovered today my TextEditor (public class SceneEditor
>>>>>>>>>> extends
>>>>>>>>>> AbstractDecoratedTextEditor {... ) does not respond to the DEL
>>>>>>>>>> key
>>>>>>>>>> and to several other related commands (e.g.: CTRL+D).
>>>>>>>>> I can understand that Ctrl+D is not working but Delete should
>>>>>>>>> always work. Maybe you forgot to provide a correct action
>>>>>>>>> contributor class when defining your editor in the plugin.xml,
>>>>>>>>> e.g.
>>>>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> I had a problem in that department.
>>>>>>>> Unfortunately adding:
>>>>>>>>
>>>>>>>> <editor
>>>>>>>> class="it.condarelli.writer.editors.SceneEditor"
>>>>>>>> contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> icon="icons/16/EditPages.png"
>>>>>>>> id="it.condarelli.writer.editors.SceneEditor"
>>>>>>>> name="Scene Editor">
>>>>>>>> </editor>
>>>>>>>>
>>>>>>>> Does *not* change the behavior.
>>>>>>>> DEL key is not recognized.
>>>>>>>>
>>>>>>>> I put a breakpoint at
>>>>>>>> org.eclipse.ui.editors.text.TextEditorActionContributor()
>>>>>>>> This constructor is *not* called.
>>>>>>> If that's the case then something is badly broken. Are you sure the
>>>>>>> latest code is used when you try it out? However, pressing 'Delete'
>>>>>>> should even work without that contributor.
>>>>>>>
>>>>>>> Dani
>>>>>>
>>>>>> One thing that *might* be relevant:
>>>>>> As said I use this TextEditor as a sub-editor to edit a String.
>>>>>> Thus it is never instantiated from the normal workbench machinery.
>>>>> But it's in a multi-page editor, right? In that case you need to make
>>>>> sure that the correct contributor is uses when that page is active,
>>>>> see
>>>>> MultiPageEditorActionBarContributor.
>>>>
>>>> Uhm...
>>>> I begin to see my (probably huge) problem.
>>>> Please confirm:
>>>>
>>>> I am using a whole editor (SceneEditor extends
>>>> AbstractDecoratedTextEditor) as a Composite in a FormPage among other
>>>> (simpler) widgets.
>>>> This apparently works (the page is displayed exactly as I need it and
>>>> the editor is mostly working, including partitioning, syntax
>>>> highlighting, content assistance, ...), but I fear I'm missing some
>>>> initialization.
>>>>
>>>> For sure I do not do anything like a custom
>>>> MultiPageEditorActionBarContributor.
>>>>
>>>> Is there a way to make it work or should I change everything? (I hope
>>>> not!)
>>> Sure you can make it work: the PDE editors (e.g.
>>> 'org.eclipse.pde.internal.ui.editor.schema.SchemaEditor') also work that
>>> way. The first thing you need to do is to read the Javadoc of
>>> 'org.eclipse.ui.part.MultiPageEditorPart' and understand how it works.
>>> ;-)
>>
>> Sorry, I failed (to understand how I can make it work for me).
>>
>> I think the root of my problem is (WorldEditorContributor extends
>> MultiPageEditorActionBarContributor).setActivePage(IEditorPa rt part) is
>> always called with part == null.
>>
>> This is consistent with the way part is built:
>>
>> protected IEditorPart getEditor(int pageIndex) {
>> Item item = getItem(pageIndex);
>> if (item != null) {
>> Object data = item.getData();
>> if (data instanceof IEditorPart) {
>> return (IEditorPart) data;
>> }
>> }
>> return null;
>> }
>
> UPDATE:
> In the above code:
> item is a CTabItem
> data is null
>
> I see nowhere a SceneEditPage2.
> I am *very* confused: shouldn't the data field be handled automatically?
> Should I do something about that??
>
> TiA
> Mauro
>

UPDATE2:
I managed to have this work (at least the forward-delete) by adding the
following code in my MultiPageEditorActionBarContributor:

public void setActivePage(IEditorPart part) {
if (part == null) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow ww = wb.getActiveWorkbenchWindow();
IWorkbenchPage wp = ww.getActivePage();
if (wp != null) {
IEditorPart ep = wp.getActiveEditor();
if (ep instanceof WorldEditor) {
WorldEditor we = (WorldEditor) ep;
IFormPage fp = we.getActivePageInstance();
if (fp instanceof SceneEditPage2) {
SceneEditPage2 sep = (SceneEditPage2) fp;
ITextEditor te = (ITextEditor)
sep.getAdapter(ITextEditor.class);
ep = te;
}
}
part = ep;
}
}

if (activeEditorPart == part)
return;

activeEditorPart = part;
...

But I do not understand if this is really necessary or if I'm trying to
twist the framework to do things in a wrong way (and thus asking for
trouble in the near future).

Can someone enlighten me, please

Thanks
Mauro


>>
>> Problem is my page (class SceneEditPage2 extends FormPage implements
>> ISelectionListener) is not an instanceof IEditorPart but it includes,
>> deep inside, as a normal widget, an instance of (class SceneEditor
>> extends AbstractDecoratedTextEditor).
>>
>> This editor is orphan of an ActionBarContributor end hence
>> malfunctioning.
>>
>> I tried following
>> org.eclipse.pde.internal.ui.editor.schema.SchemaEditor, but I got lost.
>>
>> Can You be a bit more explicit?
>>
>> I'm currently trying to refactor my code so that SceneEditPage is an
>> IEditorPart. I am unsure if this is necessary and/or advisable, but I
>> see no other way.
>>
>> Thanks in Advance
>> Mauro
>>
>>>
>>> Dani
>>>>
>>>> Regards
>>>> Mauro
>>>>
>>>>>
>>>>> Dani
>>>>>> I instantiate it explicitly while building a custom FormPage:
>>>>>>
>>>>>> ...
>>>>>> editor = new SceneEditor(world);
>>>>>> try {
>>>>>> IEditorSite site = new MultiPageEditorSite(getEditor(), editor);
>>>>>> editor.init(site, editorInput);
>>>>>> editor.createPartControl(scrolledForm.getBody());
>>>>>>
>>>>>> Object o = editor.getAdapter(StyledText.class);
>>>>>> styledText = (StyledText) o;
>>>>>> managedForm.getToolkit().paintBordersFor(styledText);
>>>>>> } catch (PartInitException e) {
>>>>>> Text txt = managedForm.getToolkit().createText(composite, "chapter",
>>>>>> SWT.MULTI);
>>>>>> txt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
>>>>>> 1));
>>>>>> StringBuilder sb = new StringBuilder();
>>>>>> sb.append(e.getMessage());
>>>>>> sb.append("\n\n");
>>>>>> StringWriter w = new StringWriter();
>>>>>> PrintWriter pw = new PrintWriter(w);
>>>>>> e.printStackTrace(pw);
>>>>>> sb.append(w.getBuffer());
>>>>>> txt.setText(sb.toString());
>>>>>> }
>>>>>> ...
>>>>>>
>>>>>> public class SceneEditor extends AbstractDecoratedTextEditor {
>>>>>>
>>>>>> public static final String ID =
>>>>>> "it.condarelli.writer.editors.SceneEditor"; //$NON-NLS-1$
>>>>>>
>>>>>> public SceneEditor(World world) {
>>>>>> super();
>>>>>> // make sure we inherit all the text editing commands (delete line
>>>>>> etc).
>>>>>> setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope"
>>>>>> }); //$NON-NLS-1$
>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>> getPreferenceStore()));
>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>> }
>>>>>> ...
>>>>>>
>>>>>> I cleaned all the involved projects, deleted the run configurations
>>>>>> and the runtime directories.
>>>>>> The behavior remains.
>>>>>>
>>>>>> I have a rather cryptic .log file:
>>>>>>
>>>>>> !SESSION 2010-06-14 17:15:35.275
>>>>>> -----------------------------------------------
>>>>>> eclipse.buildId=unknown
>>>>>> java.version=1.6.0_20
>>>>>> java.vendor=Sun Microsystems Inc.
>>>>>> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=it_IT
>>>>>> Framework arguments: -product Writer.product
>>>>>> Command-line arguments: -product Writer.product -data
>>>>>> C:\Users\mauro\workspace/../runtime-Writer.product -dev
>>>>>> file:C:/Users/mauro/workspace/.metadata/.plugins/org.eclipse .pde.core/Writer.product/dev.properties
>>>>>>
>>>>>>
>>>>>>
>>>>>> -os win32 -ws win32 -arch x86
>>>>>>
>>>>>> !ENTRY org.eclipse.ui 4 4 2010-06-14 17:15:51.276
>>>>>> !MESSAGE Reference item additions not found for action null
>>>>>>
>>>>>> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>>>>>>>> Any idea about what I can/should check?
>>>>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>>>
>>>>>> I' rather desperate by now.
>>>>>> This is my first non-token RCP project, so I might heve done *BIG*
>>>>>> mistakes.
>>>>>>
>>>>>>
>>>>>> Thanks for Your patience.
>>>>>>
>>>>>> Regards
>>>>>> Mauro
>>>>>>
>>>>>>
>>>>>>>> I should note This is a rather peculiar TextEditor (public class
>>>>>>>> SceneEditor extends AbstractDecoratedTextEditor) having a custom
>>>>>>>> DocumentProvider (public class SceneDocumentProvider extends
>>>>>>>> AbstractDocumentProvider) and a custom EditorInput (public class
>>>>>>>> SceneEditorInput implements IEditorInput) because I'm editing a
>>>>>>>> (possibly very long) String contained in my EMF Model.
>>>>>>>> Can this be related? (I could have forgotten something).
>>>>>>>>
>>>>>>>> TiA
>>>>>>>> Mauro
>>>>>>>>
>>>>>>>>> Dani
>>>>>>>>>> I did not change anything from defaults (willingly, I mean!).
>>>>>>>>>> Nearest thing (copied from somewhere) is:
>>>>>>>>>>
>>>>>>>>>> public SceneEditor(World world) {
>>>>>>>>>> super();
>>>>>>>>>> // make sure we inherit all the text editing commands (delete
>>>>>>>>>> line
>>>>>>>>>> etc).
>>>>>>>>>> setKeyBindingScopes(new String[] {
>>>>>>>>>> "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
>>>>>>>>>> configureInsertMode(SMART_INSERT, false);
>>>>>>>>>> setSourceViewerConfiguration(new SceneConfiguration(world,
>>>>>>>>>> getPreferenceStore()));
>>>>>>>>>> setDocumentProvider(new SceneDocumentProvider());
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> but that's not the problem since removing *all* customization I
>>>>>>>>>> still have the same behavior.
>>>>>>>>>>
>>>>>>>>>> I tried Snipped25 and Snippet165 and they both perform as
>>>>>>>>>> expected
>>>>>>>>>> (forward delete works).
>>>>>>>>>>
>>>>>>>>>> Where should I look?
>>>>>>>>>> I have no idea how these things are implemented.
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> Mauro
>>>>>>
>>>>
>>
>
Re: My AbstractDecoratedTextEditor doesn't respond to forward delete [message #653881 is a reply to message #541368] Fri, 11 February 2011 17:28 Go to previous message
Quanwen  is currently offline Quanwen Friend
Messages: 1
Registered: October 2010
Junior Member
I had the same problem and when I let the method in documentProvider return true, it works.

public boolean isModifiable(Object element) {
if (element instanceof IPathEditorInput) {
return true; // Allow to edit new files
}
return false;
}

[Updated on: Fri, 11 February 2011 17:28]

Report message to a moderator

Previous Topic:Spelling correction in hover
Next Topic:eclipse source build problem
Goto Forum:
  


Current Time: Wed Apr 24 20:47:49 GMT 2024

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

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

Back to the top