I'd like to develop a plugin (tool bar buttons) for Eclipse CDT where users can easily switch between 8 and 4 spaces tabs and turn on/off soft tabs. (Why bother you asked? Thanks to the coding guideline in my org for tabbing difference between C/C++ legacy and new codes)
I managed to create toolbar buttons but I couldn't find information to modify Editor Preferences (The ones you normally find in Workspace preferences General->Editors->Text Editors).
The question 4587572 seems to cover a bit but I'm still very new to Plug-in dev so I don't really understand.
I guess I want to modify EDITOR_TAB_WIDTH and EDITOR_SPACES_FOR_TABS properties of org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants for the running text Editor.
Not only modifying, I couldn't even read the properties with following code. Just returns me default value:30 I provided.
int width = Platform.getPreferencesService().getInt(
"org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants",
"EDITOR_TAB_WIDTH", 30, null);
My question in summary is: How do I modify tab settings of a running Editor from my plugin?
Much appreciate for your help.
You can use code similar to the following to get and set preferences in any plugin.
IPreferenceStore s = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.ui");
ss.setValue("SHOW_MEMORY_MONITOR", true);