mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 562997 - Switch CDT doxygen to use new Equinox preferences API
Switched from "org.eclipse.cdt.core.options" to "org.eclipse.core.runtime.preferences" Change-Id: Ie01d955079a7a54875270bb2d259c9232d30e7ea Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
1d38d997dc
commit
73982472ee
9 changed files with 59 additions and 50 deletions
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.doxygen;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The metadata for options to configure doxygen
|
* The metadata for options to configure doxygen
|
||||||
|
@ -30,7 +30,7 @@ public interface DoxygenMetadata {
|
||||||
*
|
*
|
||||||
* @see DoxygenOptions#useBriefTags()
|
* @see DoxygenOptions#useBriefTags()
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> useBriefTagOption();
|
PreferenceMetadata<Boolean> useBriefTagOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the "Use structural commands" option, must not return <code>null</code>.
|
* Returns the metadata for the "Use structural commands" option, must not return <code>null</code>.
|
||||||
|
@ -39,7 +39,7 @@ public interface DoxygenMetadata {
|
||||||
*
|
*
|
||||||
* @see DoxygenOptions#useStructuralCommands()
|
* @see DoxygenOptions#useStructuralCommands()
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> useStructuralCommandsOption();
|
PreferenceMetadata<Boolean> useStructuralCommandsOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the "Use javadoc style for tags" option, must not return <code>null</code>.
|
* Returns the metadata for the "Use javadoc style for tags" option, must not return <code>null</code>.
|
||||||
|
@ -48,7 +48,7 @@ public interface DoxygenMetadata {
|
||||||
*
|
*
|
||||||
* @see DoxygenOptions#useJavadocStyle()
|
* @see DoxygenOptions#useJavadocStyle()
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> useJavadocStyleOption();
|
PreferenceMetadata<Boolean> useJavadocStyleOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the "Add new line after brief tag" option, must not return <code>null</code>.
|
* Returns the metadata for the "Add new line after brief tag" option, must not return <code>null</code>.
|
||||||
|
@ -57,7 +57,7 @@ public interface DoxygenMetadata {
|
||||||
*
|
*
|
||||||
* @see DoxygenOptions#newLineAfterBrief()
|
* @see DoxygenOptions#newLineAfterBrief()
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> newLineAfterBriefOption();
|
PreferenceMetadata<Boolean> newLineAfterBriefOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the "Add pre/post tags to functions" option, must not return <code>null</code>.
|
* Returns the metadata for the "Add pre/post tags to functions" option, must not return <code>null</code>.
|
||||||
|
@ -66,13 +66,13 @@ public interface DoxygenMetadata {
|
||||||
*
|
*
|
||||||
* @see DoxygenOptions#usePrePostTag()
|
* @see DoxygenOptions#usePrePostTag()
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> usePrePostTagOption();
|
PreferenceMetadata<Boolean> usePrePostTagOption();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of available boolean options to be shown in UI, must not return <code>null</code>.
|
* Returns the list of available boolean options to be shown in UI, must not return <code>null</code>.
|
||||||
*
|
*
|
||||||
* @return the list of boolean options
|
* @return the list of boolean options
|
||||||
*/
|
*/
|
||||||
List<OptionMetadata<Boolean>> booleanOptions();
|
List<PreferenceMetadata<Boolean>> booleanOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.doxygen.core;
|
package org.eclipse.cdt.doxygen.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
|
|
||||||
public interface DoxygenPreferences {
|
public interface DoxygenPreferences {
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public interface DoxygenPreferences {
|
||||||
*
|
*
|
||||||
* @return the workspace storage for doxygen options
|
* @return the workspace storage for doxygen options
|
||||||
*/
|
*/
|
||||||
OptionStorage workspaceStorage();
|
IPreferenceMetadataStore workspaceStorage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the project-specific storage for doxygen options to be used in UI, must not return <code>null</code>
|
* Returns the project-specific storage for doxygen options to be used in UI, must not return <code>null</code>
|
||||||
|
@ -32,7 +32,7 @@ public interface DoxygenPreferences {
|
||||||
* @param project scope for the storage, must not be <code>null</code>
|
* @param project scope for the storage, must not be <code>null</code>
|
||||||
* @return the project-specific storage for doxygen options
|
* @return the project-specific storage for doxygen options
|
||||||
*/
|
*/
|
||||||
OptionStorage projectStorage(IProject project);
|
IPreferenceMetadataStore projectStorage(IProject project);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the metadata for the options to be used in UI, must not return <code>null</code>
|
* Return the metadata for the options to be used in UI, must not return <code>null</code>
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class DoxygenCoreMessages extends NLS {
|
||||||
public static String DoxygenMetadataDefaults_use_pre_post_tags_name;
|
public static String DoxygenMetadataDefaults_use_pre_post_tags_name;
|
||||||
public static String DoxygenMetadataDefaults_use_structured_commands_description;
|
public static String DoxygenMetadataDefaults_use_structured_commands_description;
|
||||||
public static String DoxygenMetadataDefaults_use_structured_commands_name;
|
public static String DoxygenMetadataDefaults_use_structured_commands_name;
|
||||||
|
public static String DoxygenPreferenceAccess_e_get_preferences;
|
||||||
public static String DoxygenPreferenceAccess_e_null_project;
|
public static String DoxygenPreferenceAccess_e_null_project;
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
|
|
|
@ -22,4 +22,5 @@ DoxygenMetadataDefaults_use_pre_post_tags_description=Use always pre/post tags i
|
||||||
DoxygenMetadataDefaults_use_pre_post_tags_name=Add pre/post tags to functions
|
DoxygenMetadataDefaults_use_pre_post_tags_name=Add pre/post tags to functions
|
||||||
DoxygenMetadataDefaults_use_structured_commands_description=Use always structured commands in auto-generation of doxygen comment
|
DoxygenMetadataDefaults_use_structured_commands_description=Use always structured commands in auto-generation of doxygen comment
|
||||||
DoxygenMetadataDefaults_use_structured_commands_name=Use structural commands
|
DoxygenMetadataDefaults_use_structured_commands_name=Use structural commands
|
||||||
|
DoxygenPreferenceAccess_e_get_preferences=Unable to get preferences for node: {0}.{1}
|
||||||
DoxygenPreferenceAccess_e_null_project=Project must not be null
|
DoxygenPreferenceAccess_e_null_project=Project must not be null
|
||||||
|
|
|
@ -16,33 +16,32 @@ package org.eclipse.cdt.doxygen.internal.core;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.BaseOption;
|
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
|
|
||||||
final class DoxygenMetadataDefaults implements DoxygenMetadata {
|
final class DoxygenMetadataDefaults implements DoxygenMetadata {
|
||||||
|
|
||||||
private final OptionMetadata<Boolean> useBriefTagOption;
|
private final PreferenceMetadata<Boolean> useBriefTagOption;
|
||||||
private final OptionMetadata<Boolean> useStructuralCommandsOption;
|
private final PreferenceMetadata<Boolean> useStructuralCommandsOption;
|
||||||
private final OptionMetadata<Boolean> useJavadocStyleOption;
|
private final PreferenceMetadata<Boolean> useJavadocStyleOption;
|
||||||
private final OptionMetadata<Boolean> newLineAfterBriefOption;
|
private final PreferenceMetadata<Boolean> newLineAfterBriefOption;
|
||||||
private final OptionMetadata<Boolean> usePrePostTagOption;
|
private final PreferenceMetadata<Boolean> usePrePostTagOption;
|
||||||
private final List<OptionMetadata<Boolean>> booleanOptions;
|
private final List<PreferenceMetadata<Boolean>> booleanOptions;
|
||||||
|
|
||||||
public DoxygenMetadataDefaults() {
|
public DoxygenMetadataDefaults() {
|
||||||
this.useBriefTagOption = new BaseOption<>(Boolean.class, "doxygen_use_brief_tag", false, //$NON-NLS-1$
|
this.useBriefTagOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_brief_tag", false, //$NON-NLS-1$
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_name,
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_name,
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_description);
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_description);
|
||||||
this.useStructuralCommandsOption = new BaseOption<>(Boolean.class, "doxygen_use_structural_commands", false, //$NON-NLS-1$
|
this.useStructuralCommandsOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_structural_commands", //$NON-NLS-1$
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_name,
|
false, DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_name,
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_description);
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_description);
|
||||||
this.useJavadocStyleOption = new BaseOption<>(Boolean.class, "doxygen_use_javadoc_tags", true, //$NON-NLS-1$
|
this.useJavadocStyleOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_javadoc_tags", true, //$NON-NLS-1$
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_name,
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_name,
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_description);
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_description);
|
||||||
this.newLineAfterBriefOption = new BaseOption<>(Boolean.class, "doxygen_new_line_after_brief", true, //$NON-NLS-1$
|
this.newLineAfterBriefOption = new PreferenceMetadata<>(Boolean.class, "doxygen_new_line_after_brief", true, //$NON-NLS-1$
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_name,
|
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_name,
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_description);
|
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_description);
|
||||||
this.usePrePostTagOption = new BaseOption<>(Boolean.class, "doxygen_use_pre_tag", false, //$NON-NLS-1$
|
this.usePrePostTagOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_pre_tag", false, //$NON-NLS-1$
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_name,
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_name,
|
||||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_description);
|
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_description);
|
||||||
this.booleanOptions = new ArrayList<>();
|
this.booleanOptions = new ArrayList<>();
|
||||||
|
@ -54,32 +53,32 @@ final class DoxygenMetadataDefaults implements DoxygenMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> useBriefTagOption() {
|
public PreferenceMetadata<Boolean> useBriefTagOption() {
|
||||||
return useBriefTagOption;
|
return useBriefTagOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> useStructuralCommandsOption() {
|
public PreferenceMetadata<Boolean> useStructuralCommandsOption() {
|
||||||
return useStructuralCommandsOption;
|
return useStructuralCommandsOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> useJavadocStyleOption() {
|
public PreferenceMetadata<Boolean> useJavadocStyleOption() {
|
||||||
return useJavadocStyleOption;
|
return useJavadocStyleOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> newLineAfterBriefOption() {
|
public PreferenceMetadata<Boolean> newLineAfterBriefOption() {
|
||||||
return newLineAfterBriefOption;
|
return newLineAfterBriefOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> usePrePostTagOption() {
|
public PreferenceMetadata<Boolean> usePrePostTagOption() {
|
||||||
return usePrePostTagOption;
|
return usePrePostTagOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OptionMetadata<Boolean>> booleanOptions() {
|
public List<PreferenceMetadata<Boolean>> booleanOptions() {
|
||||||
return new ArrayList<>(booleanOptions);
|
return new ArrayList<>(booleanOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,16 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.doxygen.internal.core;
|
package org.eclipse.cdt.doxygen.internal.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
||||||
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
|
|
||||||
final class DoxygenOptionsAccess implements DoxygenOptions {
|
final class DoxygenOptionsAccess implements DoxygenOptions {
|
||||||
|
|
||||||
private final OptionStorage optionStorage;
|
private final IPreferenceMetadataStore optionStorage;
|
||||||
private final DoxygenMetadata doxygenMetadata;
|
private final DoxygenMetadata doxygenMetadata;
|
||||||
|
|
||||||
public DoxygenOptionsAccess(OptionStorage optionStorage, DoxygenMetadata doxygenMetadata) {
|
public DoxygenOptionsAccess(IPreferenceMetadataStore optionStorage, DoxygenMetadata doxygenMetadata) {
|
||||||
this.optionStorage = optionStorage;
|
this.optionStorage = optionStorage;
|
||||||
this.doxygenMetadata = doxygenMetadata;
|
this.doxygenMetadata = doxygenMetadata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,20 +14,22 @@
|
||||||
package org.eclipse.cdt.doxygen.internal.core;
|
package org.eclipse.cdt.doxygen.internal.core;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
|
||||||
import org.eclipse.cdt.core.options.OsgiPreferenceStorage;
|
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
||||||
import org.eclipse.cdt.doxygen.core.DoxygenConfiguration;
|
import org.eclipse.cdt.doxygen.core.DoxygenConfiguration;
|
||||||
import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
|
import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.OsgiPreferenceMetadataStore;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
import org.osgi.service.prefs.Preferences;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPreferences {
|
public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPreferences {
|
||||||
|
@ -39,14 +41,14 @@ public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPre
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionStorage workspaceStorage() {
|
public IPreferenceMetadataStore workspaceStorage() {
|
||||||
return new OsgiPreferenceStorage(preferences(InstanceScope.INSTANCE));
|
return new OsgiPreferenceMetadataStore(preferences(InstanceScope.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionStorage projectStorage(IProject project) {
|
public IPreferenceMetadataStore projectStorage(IProject project) {
|
||||||
Objects.requireNonNull(DoxygenCoreMessages.DoxygenPreferenceAccess_e_null_project);
|
Objects.requireNonNull(DoxygenCoreMessages.DoxygenPreferenceAccess_e_null_project);
|
||||||
return new OsgiPreferenceStorage(preferences(new ProjectScope(project)));
|
return new OsgiPreferenceMetadataStore(preferences(new ProjectScope(project)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,8 +67,14 @@ public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPre
|
||||||
return new DoxygenOptionsAccess(projectStorage(project), doxygenMetadata);
|
return new DoxygenOptionsAccess(projectStorage(project), doxygenMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences preferences(IScopeContext scope) {
|
private IEclipsePreferences preferences(IScopeContext scope) {
|
||||||
return scope.getNode(nodeQualifier()).node(nodePath());
|
return Optional.ofNullable(scope.getNode(nodeQualifier()))//
|
||||||
|
.map(n -> n.node(nodePath()))//
|
||||||
|
.filter(IEclipsePreferences.class::isInstance)//
|
||||||
|
.map(IEclipsePreferences.class::cast)//
|
||||||
|
.orElseThrow(() -> new IllegalStateException(//
|
||||||
|
NLS.bind(DoxygenCoreMessages.DoxygenPreferenceAccess_e_get_preferences, //
|
||||||
|
nodeQualifier(), nodePath())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String nodeQualifier() {
|
private String nodeQualifier() {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
|
@ -38,6 +37,7 @@ import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
|
||||||
import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenMultilineAutoEditStrategy;
|
import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenMultilineAutoEditStrategy;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
|
@ -52,7 +52,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
||||||
private HashMap<String, String> fOptions;
|
private HashMap<String, String> fOptions;
|
||||||
protected ICProject fCProject;
|
protected ICProject fCProject;
|
||||||
private DoxygenPreferences doxygenPreferences;
|
private DoxygenPreferences doxygenPreferences;
|
||||||
private OptionStorage workspaceStorage;
|
private IPreferenceMetadataStore workspaceStorage;
|
||||||
private DoxygenMetadata doxygenMetadata;
|
private DoxygenMetadata doxygenMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,13 +18,13 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
|
||||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||||
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
|
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
|
||||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
import org.eclipse.jface.layout.GridDataFactory;
|
import org.eclipse.jface.layout.GridDataFactory;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
|
@ -44,7 +44,7 @@ public class DocCommentOwnerArea {
|
||||||
private final Combo combo;
|
private final Combo combo;
|
||||||
private final IDocCommentOwner owners[];
|
private final IDocCommentOwner owners[];
|
||||||
|
|
||||||
private final Map<OptionMetadata<Boolean>, Button> buttons;
|
private final Map<PreferenceMetadata<Boolean>, Button> buttons;
|
||||||
|
|
||||||
public DocCommentOwnerArea(Composite pane, DoxygenMetadata metadata, String descriptionText,
|
public DocCommentOwnerArea(Composite pane, DoxygenMetadata metadata, String descriptionText,
|
||||||
String comboLabelText) {
|
String comboLabelText) {
|
||||||
|
@ -73,7 +73,7 @@ public class DocCommentOwnerArea {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createCheckBox(Composite parent, OptionMetadata<Boolean> option) {
|
private Button createCheckBox(Composite parent, PreferenceMetadata<Boolean> option) {
|
||||||
Button checkBox = new Button(parent, SWT.CHECK);
|
Button checkBox = new Button(parent, SWT.CHECK);
|
||||||
checkBox.setText(option.name());
|
checkBox.setText(option.name());
|
||||||
checkBox.setToolTipText(option.description());
|
checkBox.setToolTipText(option.description());
|
||||||
|
@ -98,7 +98,7 @@ public class DocCommentOwnerArea {
|
||||||
return result.toArray(new IDocCommentOwner[result.size()]);
|
return result.toArray(new IDocCommentOwner[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(IDocCommentOwner initial, OptionStorage storage) {
|
public void initialize(IDocCommentOwner initial, IPreferenceMetadataStore storage) {
|
||||||
selectDocumentOwner(initial, combo);
|
selectDocumentOwner(initial, combo);
|
||||||
buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
|
buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class DocCommentOwnerArea {
|
||||||
return index == 0 ? NullDocCommentOwner.INSTANCE : owners[index - 1];
|
return index == 0 ? NullDocCommentOwner.INSTANCE : owners[index - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply(OptionStorage storage) {
|
public void apply(IPreferenceMetadataStore storage) {
|
||||||
buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
|
buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue