difference between IAutoEditStrategy and CTRL+ALT+F [message #327128] |
Thu, 10 April 2008 16:16  |
Eclipse User |
|
|
|
hi all, I have to implement a formatting stratégy and after some
reschears, I found two solution, the IAuteditStrategy and a shortcut
CTRL ALT F.
my question is simple, is this one use the other?? or I have to
implement 2 thing who do exacly the same thing??
thanks
a++
|
|
|
|
|
|
|
Re: difference between IAutoEditStrategy and CTRL+ALT+F [message #327148 is a reply to message #327142] |
Fri, 11 April 2008 11:39   |
Eclipse User |
|
|
|
julien wrote:
> Daniel Megert a écrit :
>> julien wrote:
>>> Daniel Megert a écrit :
>>>> julien wrote:
>>>>> hi all, I have to implement a formatting stratégy and after some
>>>>> reschears, I found two solution, the IAuteditStrategy and a
>>>>> shortcut CTRL ALT F.
>>>>>
>>>>> my question is simple, is this one use the other?? or I have to
>>>>> implement 2 thing who do exacly the same thing??
>>>> The auto-edit strategy is not the right thing to use for
>>>> formatting. Not sure what you mean with CTRL ALT F.
>>>
>>> it's when I wanna reformat all the document.
>>> I found two choices
>>> getContentFormatter in the source viewer and menu :
>>> sources->format (CTRL+ALT+F) (with java plug) so with a action etc...
>> One mentions code and the other a user action - doesn't make much sense
>
> I ll take a other way.
> I wanna reformat all my document (open with my editor).
> What I have to do?
>
> My first idea was to implément the user action and go take the open
> document and reformat the all (all of this without pass by the
> getContentFormater)
>
> but I found a thing called getContentFormatter and I don't see the
> link between that and the user action. what is getContentFormater ??
You have to do both: you have to provide the action and you have to
provide a content formatter:
The action in your editor will look similar to this:
action= new
TextOperationAction(JavaEditorMessages.getBundleForConstruct edKeys(),
"Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds. FORMAT);
setAction("Format", action); //$NON-NLS-1$
markAsStateDependentAction("Format", true); //$NON-NLS-1$
markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(action,
IJavaHelpContextIds.FORMAT_ACTION);
Then you need to implement your content formatter and return it in your
source viewer config:
see:
org.eclipse.jface.text.source.SourceViewerConfiguration.getC ontentFormatter(ISourceViewer)
Besides that you have to define a 'format' command and contribute the
menu (both via plugin.xml).
I suggest you look how it is done in org.eclipse.jdt.ui plug-in.
Dani
>
>
> thanks a++
>
>> to me.
>>
>> Dani
>>>
>>>>
>>>> Dani
>>>>>
>>>>> thanks
>>>>>
>>>>> a++
>>>
>>> thanks a lot
>>>
>>> a+++
|
|
|
Re: difference between IAutoEditStrategy and CTRL+ALT+F [message #327174 is a reply to message #327148] |
Sun, 13 April 2008 02:11  |
Eclipse User |
|
|
|
Daniel Megert a écrit :
> julien wrote:
>> Daniel Megert a écrit :
>>> julien wrote:
>>>> Daniel Megert a écrit :
>>>>> julien wrote:
>>>>>> hi all, I have to implement a formatting stratégy and after some
>>>>>> reschears, I found two solution, the IAuteditStrategy and a
>>>>>> shortcut CTRL ALT F.
>>>>>>
>>>>>> my question is simple, is this one use the other?? or I have to
>>>>>> implement 2 thing who do exacly the same thing??
>>>>> The auto-edit strategy is not the right thing to use for
>>>>> formatting. Not sure what you mean with CTRL ALT F.
>>>>
>>>> it's when I wanna reformat all the document.
>>>> I found two choices
>>>> getContentFormatter in the source viewer and menu :
>>>> sources->format (CTRL+ALT+F) (with java plug) so with a action etc...
>>> One mentions code and the other a user action - doesn't make much sense
>>
>> I ll take a other way.
>> I wanna reformat all my document (open with my editor).
>> What I have to do?
>>
>> My first idea was to implément the user action and go take the open
>> document and reformat the all (all of this without pass by the
>> getContentFormater)
>>
>> but I found a thing called getContentFormatter and I don't see the
>> link between that and the user action. what is getContentFormater ??
> You have to do both: you have to provide the action and you have to
> provide a content formatter:
>
> The action in your editor will look similar to this:
>
> action= new
> TextOperationAction(JavaEditorMessages.getBundleForConstruct edKeys(),
> "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
> action.setActionDefinitionId(IJavaEditorActionDefinitionIds. FORMAT);
> setAction("Format", action); //$NON-NLS-1$
> markAsStateDependentAction("Format", true); //$NON-NLS-1$
> markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
> PlatformUI.getWorkbench().getHelpSystem().setHelp(action,
> IJavaHelpContextIds.FORMAT_ACTION);
>
> Then you need to implement your content formatter and return it in your
> source viewer config:
> see:
> org.eclipse.jface.text.source.SourceViewerConfiguration.getC ontentFormatter(ISourceViewer)
>
>
> Besides that you have to define a 'format' command and contribute the
> menu (both via plugin.xml).
>
> I suggest you look how it is done in org.eclipse.jdt.ui plug-in.
>
>
> Dani
>>
thanks, but there is something I always don't understand.
when the contentFormatter is called??
the source -> format is called when I click on that (easy)
buet when the content format is used in the jdt?? when I tape a simple
hello world by example. is there any moment when I use this property??
thanks
a+++
>>
>> thanks a++
>>
>>> to me.
>>>
>>> Dani
>>>>
>>>>>
>>>>> Dani
>>>>>>
>>>>>> thanks
>>>>>>
>>>>>> a++
>>>>
>>>> thanks a lot
>>>>
>>>> a+++
|
|
|
Powered by
FUDForum. Page generated in 0.04364 seconds