Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » merging generic text editor preferences into custom editor preferences
merging generic text editor preferences into custom editor preferences [message #333275] Wed, 03 December 2008 04:19 Go to next message
Eclipse UserFriend
Originally posted by: marc.esher.comcast.net

Greetings all,
Question about custom editors and preference stores. Sometimes, I want
to use the default Text Editors preferences in my custom editor... things
like undo history size, drag/drop, etc. i.e. I do not want to duplicate
those preferences in my custom editor preference page. The problem is that
in the editor, I have to set the preference store to my editor's preference
store and so for those preferences which aren't duplicated, the settings
take on their default value and not the value of the generic "TextEditor"
preference.

My question is this: what's the preferred way of "mixing and matching" the
general text editor preferences with custom preferences? I found myself
going down the path of copying preferences from the general store into my
custom editor store and that feels not-so-Eclipse-like. If that's the way I
have to go, then that's cool. I just don't want to do it the lame way if
there's a preferred method of handling this scenario

Advice appreciated.

many thanks.

marc
Re: merging generic text editor preferences into custom editor preferences [message #333282 is a reply to message #333275] Wed, 03 December 2008 12:07 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Marc E wrote:
> Greetings all,
> Question about custom editors and preference stores. Sometimes, I
> want to use the default Text Editors preferences in my custom
> editor... things like undo history size, drag/drop, etc. i.e. I do not
> want to duplicate those preferences in my custom editor preference
> page. The problem is that in the editor, I have to set the preference
> store to my editor's preference store and so for those preferences
> which aren't duplicated, the settings take on their default value and
> not the value of the generic "TextEditor" preference.
>
> My question is this: what's the preferred way of "mixing and
> matching" the general text editor preferences with custom preferences?
Do this:

IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
combinedPreferenceStore= new ChainedPreferenceStore(new
IPreferenceStore[] { yourPreferenceStore, generalTextStore });

Dani
> I found myself going down the path of copying preferences from the
> general store into my custom editor store and that feels
> not-so-Eclipse-like. If that's the way I have to go, then that's
> cool. I just don't want to do it the lame way if there's a preferred
> method of handling this scenario
>
> Advice appreciated.
>
> many thanks.
>
> marc
Re: merging generic text editor preferences into custom editor preferences [message #333311 is a reply to message #333282] Wed, 03 December 2008 21:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marc.esher.comcast.net

Dude. You are the man.

Thanks!



"Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
news:gh5spa$pl7$1@build.eclipse.org...
> Marc E wrote:
>> Greetings all,
>> Question about custom editors and preference stores. Sometimes, I want
>> to use the default Text Editors preferences in my custom editor... things
>> like undo history size, drag/drop, etc. i.e. I do not want to duplicate
>> those preferences in my custom editor preference page. The problem is
>> that in the editor, I have to set the preference store to my editor's
>> preference store and so for those preferences which aren't duplicated,
>> the settings take on their default value and not the value of the generic
>> "TextEditor" preference.
>>
>> My question is this: what's the preferred way of "mixing and matching"
>> the general text editor preferences with custom preferences?
> Do this:
>
> IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
> combinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[]
> { yourPreferenceStore, generalTextStore });
>
> Dani
>> I found myself going down the path of copying preferences from the
>> general store into my custom editor store and that feels
>> not-so-Eclipse-like. If that's the way I have to go, then that's cool. I
>> just don't want to do it the lame way if there's a preferred method of
>> handling this scenario
>>
>> Advice appreciated.
>>
>> many thanks.
>>
>> marc
Re: merging generic text editor preferences into custom editor preferences [message #333318 is a reply to message #333282] Thu, 04 December 2008 02:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marc.esher.comcast.net

Hey Daniel,
one more question: I have a preference which I removed from my plugin.
However, it's still returning a value when doing store.getString() on the
preference name. I stepped through, and it's coming from the Default node,
not the instance node. I see the big list of default properties in the
debugger, along with the removed one... but I can't figure out why it's
still in there. I've scoured the site for any references to it and can't
find any. Even if I deliberately reset the property to a value in the
preference manager's setDefaults(), the preference still shows up as
"false". I even commented out every call to setDefault in the preference
manager, but the damn thing still shows up in the default preferences when I
step through.

I do a store.contains() on this preference, and sure enough it's there,
though it should not be. the preference in question is an old
"lineNumberRuler" preference that my editor was originally using but which
I've removed in favor of the default text editor's lineNumberRuler
preference.

Any idea how this preference could be staying in the default store?

Many thanks.

Marc


"Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
news:gh5spa$pl7$1@build.eclipse.org...
> Marc E wrote:
>> Greetings all,
>> Question about custom editors and preference stores. Sometimes, I want
>> to use the default Text Editors preferences in my custom editor... things
>> like undo history size, drag/drop, etc. i.e. I do not want to duplicate
>> those preferences in my custom editor preference page. The problem is
>> that in the editor, I have to set the preference store to my editor's
>> preference store and so for those preferences which aren't duplicated,
>> the settings take on their default value and not the value of the generic
>> "TextEditor" preference.
>>
>> My question is this: what's the preferred way of "mixing and matching"
>> the general text editor preferences with custom preferences?
> Do this:
>
> IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
> combinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[]
> { yourPreferenceStore, generalTextStore });
>
> Dani
>> I found myself going down the path of copying preferences from the
>> general store into my custom editor store and that feels
>> not-so-Eclipse-like. If that's the way I have to go, then that's cool. I
>> just don't want to do it the lame way if there's a preferred method of
>> handling this scenario
>>
>> Advice appreciated.
>>
>> many thanks.
>>
>> marc
Re: merging generic text editor preferences into custom editor preferences [message #333326 is a reply to message #333318] Thu, 04 December 2008 08:08 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Marc E wrote:
> Hey Daniel,
> one more question: I have a preference which I removed from my
> plugin. However, it's still returning a value when doing
> store.getString() on the preference name. I stepped through, and it's
> coming from the Default node, not the instance node. I see the big
> list of default properties in the debugger, along with the removed
> one... but I can't figure out why it's still in there. I've scoured
> the site for any references to it and can't find any. Even if I
> deliberately reset the property to a value in the preference manager's
> setDefaults(), the preference still shows up as "false". I even
> commented out every call to setDefault in the preference manager, but
> the damn thing still shows up in the default preferences when I step
> through.
>
> I do a store.contains() on this preference, and sure enough it's
> there, though it should not be. the preference in question is an old
> "lineNumberRuler" preference that my editor was originally using but
> which I've removed in favor of the default text editor's
> lineNumberRuler preference.
>
> Any idea how this preference could be staying in the default store?
Use org.eclipse.jface.preference.IPreferenceStore.setToDefault(S tring)
to remove it completely.

Dani
>
> Many thanks.
>
> Marc
>
>
> "Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
> news:gh5spa$pl7$1@build.eclipse.org...
>> Marc E wrote:
>>> Greetings all,
>>> Question about custom editors and preference stores. Sometimes, I
>>> want to use the default Text Editors preferences in my custom
>>> editor... things like undo history size, drag/drop, etc. i.e. I do
>>> not want to duplicate those preferences in my custom editor
>>> preference page. The problem is that in the editor, I have to set
>>> the preference store to my editor's preference store and so for
>>> those preferences which aren't duplicated, the settings take on
>>> their default value and not the value of the generic "TextEditor"
>>> preference.
>>>
>>> My question is this: what's the preferred way of "mixing and
>>> matching" the general text editor preferences with custom preferences?
>> Do this:
>>
>> IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
>> combinedPreferenceStore= new ChainedPreferenceStore(new
>> IPreferenceStore[] { yourPreferenceStore, generalTextStore });
>>
>> Dani
>>> I found myself going down the path of copying preferences from the
>>> general store into my custom editor store and that feels
>>> not-so-Eclipse-like. If that's the way I have to go, then that's
>>> cool. I just don't want to do it the lame way if there's a preferred
>>> method of handling this scenario
>>>
>>> Advice appreciated.
>>>
>>> many thanks.
>>>
>>> marc
>
Re: merging generic text editor preferences into custom editor preferences [message #333329 is a reply to message #333326] Thu, 04 December 2008 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marc.esher.comcast.net

See, that's the thing: it's not living in the instance store but in the
default store. When I look at the actual prefs file, it isn't there. But it
is in the in-memory default store. I can't figure out for the life of me why
it'd be living in that default store when there's nothing currently setting
that preference any more. In fact, up until the editor is created, the value
isn't in the default preference store. it's something happening in between
the time I doubleclick to open a file and when the editor is finished
opening.

thanks Dani.

Marc



"Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
news:gh835b$2te$2@build.eclipse.org...
> Marc E wrote:
>> Hey Daniel,
>> one more question: I have a preference which I removed from my plugin.
>> However, it's still returning a value when doing store.getString() on the
>> preference name. I stepped through, and it's coming from the Default
>> node, not the instance node. I see the big list of default properties in
>> the debugger, along with the removed one... but I can't figure out why
>> it's still in there. I've scoured the site for any references to it and
>> can't find any. Even if I deliberately reset the property to a value in
>> the preference manager's setDefaults(), the preference still shows up as
>> "false". I even commented out every call to setDefault in the preference
>> manager, but the damn thing still shows up in the default preferences
>> when I step through.
>>
>> I do a store.contains() on this preference, and sure enough it's there,
>> though it should not be. the preference in question is an old
>> "lineNumberRuler" preference that my editor was originally using but
>> which I've removed in favor of the default text editor's lineNumberRuler
>> preference.
>>
>> Any idea how this preference could be staying in the default store?
> Use org.eclipse.jface.preference.IPreferenceStore.setToDefault(S tring) to
> remove it completely.
>
> Dani
>>
>> Many thanks.
>>
>> Marc
>>
>>
>> "Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
>> news:gh5spa$pl7$1@build.eclipse.org...
>>> Marc E wrote:
>>>> Greetings all,
>>>> Question about custom editors and preference stores. Sometimes, I
>>>> want to use the default Text Editors preferences in my custom editor...
>>>> things like undo history size, drag/drop, etc. i.e. I do not want to
>>>> duplicate those preferences in my custom editor preference page. The
>>>> problem is that in the editor, I have to set the preference store to my
>>>> editor's preference store and so for those preferences which aren't
>>>> duplicated, the settings take on their default value and not the value
>>>> of the generic "TextEditor" preference.
>>>>
>>>> My question is this: what's the preferred way of "mixing and matching"
>>>> the general text editor preferences with custom preferences?
>>> Do this:
>>>
>>> IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
>>> combinedPreferenceStore= new ChainedPreferenceStore(new
>>> IPreferenceStore[] { yourPreferenceStore, generalTextStore });
>>>
>>> Dani
>>>> I found myself going down the path of copying preferences from the
>>>> general store into my custom editor store and that feels
>>>> not-so-Eclipse-like. If that's the way I have to go, then that's cool.
>>>> I just don't want to do it the lame way if there's a preferred method
>>>> of handling this scenario
>>>>
>>>> Advice appreciated.
>>>>
>>>> many thanks.
>>>>
>>>> marc
>>
Re: merging generic text editor preferences into custom editor preferences [message #333331 is a reply to message #333329] Thu, 04 December 2008 11:16 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Marc E wrote:
> See, that's the thing: it's not living in the instance store but in
> the default store. When I look at the actual prefs file, it isn't there.
Sure. The pref file only has non-defaults.
> But it is in the in-memory default store.
Defaults are set on first access by the owning plug-in. You should not
mess with those ;-)

Dani
> I can't figure out for the life of me why it'd be living in that
> default store when there's nothing currently setting that preference
> any more. In fact, up until the editor is created, the value isn't in
> the default preference store. it's something happening in between the
> time I doubleclick to open a file and when the editor is finished
> opening.
>
> thanks Dani.
>
> Marc
>
>
>
> "Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
> news:gh835b$2te$2@build.eclipse.org...
>> Marc E wrote:
>>> Hey Daniel,
>>> one more question: I have a preference which I removed from my
>>> plugin. However, it's still returning a value when doing
>>> store.getString() on the preference name. I stepped through, and
>>> it's coming from the Default node, not the instance node. I see the
>>> big list of default properties in the debugger, along with the
>>> removed one... but I can't figure out why it's still in there. I've
>>> scoured the site for any references to it and can't find any. Even
>>> if I deliberately reset the property to a value in the preference
>>> manager's setDefaults(), the preference still shows up as "false". I
>>> even commented out every call to setDefault in the preference
>>> manager, but the damn thing still shows up in the default
>>> preferences when I step through.
>>>
>>> I do a store.contains() on this preference, and sure enough it's
>>> there, though it should not be. the preference in question is an old
>>> "lineNumberRuler" preference that my editor was originally using but
>>> which I've removed in favor of the default text editor's
>>> lineNumberRuler preference.
>>>
>>> Any idea how this preference could be staying in the default store?
>> Use
>> org.eclipse.jface.preference.IPreferenceStore.setToDefault(S tring) to
>> remove it completely.
>>
>> Dani
>>>
>>> Many thanks.
>>>
>>> Marc
>>>
>>>
>>> "Daniel Megert" <daniel_megert@ch.ibm.com> wrote in message
>>> news:gh5spa$pl7$1@build.eclipse.org...
>>>> Marc E wrote:
>>>>> Greetings all,
>>>>> Question about custom editors and preference stores. Sometimes,
>>>>> I want to use the default Text Editors preferences in my custom
>>>>> editor... things like undo history size, drag/drop, etc. i.e. I do
>>>>> not want to duplicate those preferences in my custom editor
>>>>> preference page. The problem is that in the editor, I have to set
>>>>> the preference store to my editor's preference store and so for
>>>>> those preferences which aren't duplicated, the settings take on
>>>>> their default value and not the value of the generic "TextEditor"
>>>>> preference.
>>>>>
>>>>> My question is this: what's the preferred way of "mixing and
>>>>> matching" the general text editor preferences with custom
>>>>> preferences?
>>>> Do this:
>>>>
>>>> IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
>>>> combinedPreferenceStore= new ChainedPreferenceStore(new
>>>> IPreferenceStore[] { yourPreferenceStore, generalTextStore });
>>>>
>>>> Dani
>>>>> I found myself going down the path of copying preferences from the
>>>>> general store into my custom editor store and that feels
>>>>> not-so-Eclipse-like. If that's the way I have to go, then that's
>>>>> cool. I just don't want to do it the lame way if there's a
>>>>> preferred method of handling this scenario
>>>>>
>>>>> Advice appreciated.
>>>>>
>>>>> many thanks.
>>>>>
>>>>> marc
>>>
>
Re: merging generic text editor preferences into custom editor preferences [message #333336 is a reply to message #333331] Thu, 04 December 2008 13:03 Go to previous message
Marc Esher is currently offline Marc EsherFriend
Messages: 14
Registered: July 2009
Junior Member
Hey Dani,
I found the culprit. Inside the plugin's
initializeDefaultPluginPreferences method, there was this:
TextEditorPreferenceConstants
.initializeDefaultValues(getPreferenceStore());

that was putting the offending preference into the default store.

this isn't my code, but someone else's, so I didn't know about this.

thanks for all your help.

marc
Previous Topic:MessageDialog constructor not showing image on titlebox for Linux???
Next Topic:Java SWTBuilder : declarative interfaces for SWT/JFace
Goto Forum:
  


Current Time: Tue Nov 19 14:46:59 GMT 2024

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

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

Back to the top