mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-09 19:43:27 +02:00
Bug 333134 - Add options to configure doxygen behavior
Reworked UI code to its natural contract. Switched java 8 to compact the code Encapsulated scope inside the DoxygenPreferences Change-Id: I534b8d4f7c2d6e7674b132a10ef3514e61f2c1ed Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
4909e9632f
commit
830bf8074c
8 changed files with 182 additions and 174 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2015 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2020 Wind River Systems, Inc. and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -12,11 +12,12 @@
|
|||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.text.doctools.doxygen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
|
@ -64,15 +65,13 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
super.setUp();
|
||||
fOptions = CCorePlugin.getOptions();
|
||||
fCProject = CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null);
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
|
||||
DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
|
||||
}
|
||||
|
||||
|
@ -695,8 +694,8 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
// */
|
||||
//void foo() {}
|
||||
public void testAutoDocCommentBrief() throws CoreException {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
|
@ -708,9 +707,9 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
// */
|
||||
//void foo() {}
|
||||
public void testAutoDocCommentBriefNoNewLine() throws CoreException {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF, false);
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF, false);
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
|
@ -722,8 +721,8 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
// */
|
||||
//void foo() {}
|
||||
public void testAutoDocCommentStructured() throws CoreException {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS, true);
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS, true);
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
|
@ -736,9 +735,9 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
// */
|
||||
//void foo() {}
|
||||
public void testAutoDocCommentNoJavadoc() throws CoreException {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, false);
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, false);
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
|
@ -753,9 +752,9 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
// */
|
||||
//void foo() {}
|
||||
public void testAutoDocCommentPrePostTags() throws CoreException {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.empty());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, true);
|
||||
DoxygenPreferences pref = new DoxygenPreferences();
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
|
||||
pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, true);
|
||||
assertAutoEditBehaviour();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2014 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2020 IBM Corporation and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -14,6 +14,8 @@
|
|||
* Anton Leherbauer (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
||||
|
@ -30,6 +32,7 @@ import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey
|
|||
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
|
||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.dialogs.DocCommentOwnerComposite;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
|
@ -85,11 +88,13 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
|
|||
private DocCommentOwnerComposite fDocCommentOwnerComposite;
|
||||
// TODO(sprigogin): Remove once compatibility with Platform 4.4 is no longer required.
|
||||
private final boolean formattingScopeForEmptySelectionSupported;
|
||||
private final DoxygenPreferences doxygenPreferences;
|
||||
|
||||
public CEditorPreferencePage() {
|
||||
super();
|
||||
Bundle jfaceText = Platform.getBundle("org.eclipse.jface.text"); //$NON-NLS-1$
|
||||
formattingScopeForEmptySelectionSupported = jfaceText.getVersion().compareTo(new Version(3, 10, 0)) >= 0;
|
||||
doxygenPreferences = new DoxygenPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -363,14 +368,14 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
|
|||
fAppearanceColorList.select(0);
|
||||
handleAppearanceColorListSelection();
|
||||
});
|
||||
fDocCommentOwnerComposite.loadValues();
|
||||
fDocCommentOwnerComposite.initialize(doxygenPreferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
DocCommentOwnerManager.getInstance()
|
||||
.setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
|
||||
fDocCommentOwnerComposite.performOk();
|
||||
fDocCommentOwnerComposite.apply(doxygenPreferences);
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Marco Stornelli
|
||||
* Copyright (c) 2020 Marco Stornelli and others
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -10,101 +10,136 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Marco Stornelli - Initial implementation
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.doctools;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class DoxygenPreferences {
|
||||
/**
|
||||
* Encapsulates access to the Doxygen-related preferences according to the current scope
|
||||
|
||||
* @since 6.7
|
||||
*
|
||||
*/
|
||||
public final class DoxygenPreferences {
|
||||
/**
|
||||
* Use always brief tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String DOXYGEN_USE_BRIEF_TAG = "doxygen_use_brief_tag"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Use always structured commands in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String DOXYGEN_USE_STRUCTURAL_COMMANDS = "doxygen_use_structural_commands"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Use always javadoc tag style in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String DOXYGEN_USE_JAVADOC_TAGS = "doxygen_use_javadoc_tags"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Use always a new line after brief tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String DOXYGEN_NEW_LINE_AFTER_BRIEF = "doxygen_new_line_after_brief"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Use always a pre tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String DOXYGEN_USE_PRE_POST_TAGS = "doxygen_use_pre_tag"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Default use always brief tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final boolean DEF_DOXYGEN_USE_BRIEF_TAG = false;
|
||||
|
||||
/**
|
||||
* Default use always structured commands in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final boolean DEF_DOXYGEN_USE_STRUCTURED_COMMANDS = false;
|
||||
|
||||
/**
|
||||
* Default use always javadoc tag style in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final boolean DEF_DOXYGEN_USE_JAVADOC_TAGS = true;
|
||||
|
||||
/**
|
||||
* Default use always a new line after brief tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final boolean DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF = true;
|
||||
|
||||
/**
|
||||
* Default use always a pre tag in auto-generation of doxygen comment
|
||||
* @since 6.7
|
||||
* @noreference This field is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final boolean DEF_DOXYGEN_USE_PRE_POST_TAGS = false;
|
||||
|
||||
private static final String QUALIFIER = CCorePlugin.PLUGIN_ID;
|
||||
private static final String WORKSPACE_DOXYGEN_NODE = "doxygen"; //$NON-NLS-1$
|
||||
private final Preferences preferences;
|
||||
|
||||
private Optional<IProject> project;
|
||||
public DoxygenPreferences() {
|
||||
this(InstanceScope.INSTANCE);
|
||||
}
|
||||
|
||||
public DoxygenPreferences(Optional<IProject> project) {
|
||||
this.project = project;
|
||||
public DoxygenPreferences(IProject project) {
|
||||
this(new ProjectScope(project));
|
||||
}
|
||||
|
||||
public DoxygenPreferences(IScopeContext scope) {
|
||||
this.preferences = scope.getNode(getNodeQualifier()).node(getNodePath());
|
||||
}
|
||||
|
||||
private String getNodeQualifier() {
|
||||
return CCorePlugin.PLUGIN_ID;
|
||||
}
|
||||
|
||||
private String getNodePath() {
|
||||
return "doxygen"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Get boolean preferences
|
||||
* Get boolean preference value
|
||||
* @param key A preference key
|
||||
* @param defaultValue A default value
|
||||
* @return The preference value
|
||||
*
|
||||
* @since 6.7
|
||||
*/
|
||||
public boolean getBooleanPref(String key, boolean defaultValue) {
|
||||
Preferences prefs = project.isPresent()
|
||||
? new ProjectScope(project.get()).getNode(QUALIFIER).node(WORKSPACE_DOXYGEN_NODE)
|
||||
: InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOXYGEN_NODE);
|
||||
return prefs.getBoolean(key, defaultValue);
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
return preferences.getBoolean(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put boolean preferences
|
||||
* Put boolean preference value
|
||||
* @param key A preference key
|
||||
* @param defaultValue A default value
|
||||
*
|
||||
* @since 6.7
|
||||
*/
|
||||
public void putBooleanPref(String key, boolean value) {
|
||||
Preferences prefs = project.isPresent()
|
||||
? new ProjectScope(project.get()).getNode(QUALIFIER).node(WORKSPACE_DOXYGEN_NODE)
|
||||
: InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOXYGEN_NODE);
|
||||
prefs.putBoolean(key, value);
|
||||
public void putBoolean(String key, boolean value) {
|
||||
preferences.putBoolean(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2020 Symbian Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -9,11 +9,14 @@
|
|||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -87,12 +90,14 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
|||
String dsc = DialogsMessages.DocCommentOwnerBlock_SelectDocToolDescription;
|
||||
String msg = DialogsMessages.DocCommentOwnerBlock_DocToolLabel;
|
||||
|
||||
IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
|
||||
IProject project = getProject();
|
||||
IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(project);
|
||||
fDocComboComposite = new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
|
||||
fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
|
||||
|
||||
fCheckbox.setSelection(fManager.projectDefinesOwnership(getProject()));
|
||||
fDocComboComposite.loadValues(getProject());
|
||||
fCheckbox.setSelection(fManager.projectDefinesOwnership(project));
|
||||
DoxygenPreferences preferences = new DoxygenPreferences(project);
|
||||
fDocComboComposite.initialize(preferences);
|
||||
handleCheckBox();
|
||||
}
|
||||
|
||||
|
@ -105,7 +110,8 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
|||
IDocCommentOwner newOwner = fDocComboComposite.getSelectedDocCommentOwner();
|
||||
fManager.setCommentOwner(project, newOwner, true);
|
||||
}
|
||||
fDocComboComposite.performOk(project);
|
||||
DoxygenPreferences preferences = new DoxygenPreferences(project);
|
||||
fDocComboComposite.apply(preferences);
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2020 Symbian Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -9,7 +9,9 @@
|
|||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2020 Symbian Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -9,20 +9,32 @@
|
|||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.Optional;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS;
|
||||
import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
|
@ -37,33 +49,18 @@ import org.eclipse.swt.widgets.Label;
|
|||
* @noextend This class is not intended to be subclassed by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
*/
|
||||
public class DocCommentOwnerComposite extends Composite implements SelectionListener {
|
||||
public class DocCommentOwnerComposite extends Composite {
|
||||
protected DocCommentOwnerCombo fDocCombo;
|
||||
protected Label desc, comboLabel;
|
||||
protected Group group;
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
protected Button useBriefTag;
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
protected Button useStructuralCommands;
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
protected Button useJavadocStyle;
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
protected Button newLineAfterBrief;
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
protected Button usePrePostTag;
|
||||
|
||||
private final Map<String, Button> buttons;
|
||||
private final Map<String, Boolean> defaults;
|
||||
|
||||
public DocCommentOwnerComposite(Composite parent, IDocCommentOwner initialOwner, String description, String label) {
|
||||
super(parent, SWT.NONE);
|
||||
buttons = new LinkedHashMap<>();
|
||||
defaults = new LinkedHashMap<>();
|
||||
GridLayout gl = new GridLayout();
|
||||
gl.marginHeight = gl.marginWidth = 0;
|
||||
setLayout(gl);
|
||||
|
@ -85,21 +82,28 @@ public class DocCommentOwnerComposite extends Composite implements SelectionList
|
|||
};
|
||||
gd = GridDataFactory.fillDefaults().grab(true, false).create();
|
||||
fDocCombo.setLayoutData(gd);
|
||||
fDocCombo.addSelectionListener(this);
|
||||
useBriefTag = addCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseBriefTagTitle);
|
||||
useStructuralCommands = addCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseStructuralCommandsTitle);
|
||||
useJavadocStyle = addCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseTagJavadocStyleTitle);
|
||||
newLineAfterBrief = addCheckBox(group, DialogsMessages.DocCommentOwnerComposite_NewLineAfterBriefTitle);
|
||||
usePrePostTag = addCheckBox(group, DialogsMessages.DocCommentOwnerComposite_AddPrePostTagsTitle);
|
||||
fDocCombo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> recheckButtons()));
|
||||
createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseBriefTagTitle, DOXYGEN_USE_BRIEF_TAG,
|
||||
DEF_DOXYGEN_USE_BRIEF_TAG);
|
||||
createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseStructuralCommandsTitle,
|
||||
DOXYGEN_USE_STRUCTURAL_COMMANDS, DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
|
||||
createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseTagJavadocStyleTitle,
|
||||
DOXYGEN_USE_JAVADOC_TAGS, DEF_DOXYGEN_USE_JAVADOC_TAGS);
|
||||
createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_NewLineAfterBriefTitle,
|
||||
DOXYGEN_NEW_LINE_AFTER_BRIEF, DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
|
||||
createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_AddPrePostTagsTitle, DOXYGEN_USE_PRE_POST_TAGS,
|
||||
DEF_DOXYGEN_USE_PRE_POST_TAGS);
|
||||
}
|
||||
|
||||
private Button addCheckBox(Composite parent, String label) {
|
||||
private Button createCheckBox(Composite parent, String label, String key, boolean value) {
|
||||
Button checkBox = new Button(parent, SWT.CHECK);
|
||||
checkBox.setText(label);
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalIndent = 0;
|
||||
gd.horizontalSpan = 2;
|
||||
checkBox.setLayoutData(gd);
|
||||
buttons.put(key, checkBox);
|
||||
defaults.put(key, value);
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
|
@ -107,51 +111,34 @@ public class DocCommentOwnerComposite extends Composite implements SelectionList
|
|||
return fDocCombo.getSelectedDocCommentOwner();
|
||||
}
|
||||
|
||||
private void initialize(Button button, DoxygenPreferences pref, String key, boolean defaultValue) {
|
||||
button.setSelection(pref.getBooleanPref(key, defaultValue));
|
||||
/**
|
||||
* Initializes widget values from the given preference instance
|
||||
*
|
||||
* @param preferences the preferences to initialize from
|
||||
*
|
||||
* @since 6.7
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void initialize(DoxygenPreferences preferences) {
|
||||
buttons.entrySet().stream().forEach(e -> initialize(e.getValue(), preferences, e.getKey()));
|
||||
}
|
||||
|
||||
void initialize(Button button, DoxygenPreferences pref, String key) {
|
||||
button.setSelection(pref.getBoolean(key, defaults.get(key)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply widget values to the given preference instance
|
||||
*
|
||||
* @param preferences the preferences to apply to
|
||||
*
|
||||
* @since 6.7
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void loadValues(IProject project) {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.ofNullable(project));
|
||||
initialize(newLineAfterBrief, pref, DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
|
||||
DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
|
||||
initialize(useBriefTag, pref, DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
|
||||
initialize(useJavadocStyle, pref, DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
|
||||
initialize(usePrePostTag, pref, DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
|
||||
initialize(useStructuralCommands, pref, DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
public void loadValues() {
|
||||
loadValues(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
public void performOk(IProject project) {
|
||||
DoxygenPreferences pref = new DoxygenPreferences(Optional.ofNullable(project));
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF, newLineAfterBrief.getSelection());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, useBriefTag.getSelection());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, useJavadocStyle.getSelection());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, usePrePostTag.getSelection());
|
||||
pref.putBooleanPref(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS, useStructuralCommands.getSelection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 6.7
|
||||
*/
|
||||
public void performOk() {
|
||||
performOk(null);
|
||||
public void apply(DoxygenPreferences preferences) {
|
||||
buttons.entrySet().stream().forEach(e -> preferences.putBoolean(e.getKey(), e.getValue().getSelection()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,45 +147,13 @@ public class DocCommentOwnerComposite extends Composite implements SelectionList
|
|||
comboLabel.setEnabled(enabled);
|
||||
fDocCombo.setEnabled(enabled);
|
||||
group.setEnabled(enabled);
|
||||
if (fDocCombo.isEnabled() && DocCommentOwnerManager.DOXYGEN_CDT_DOC_ONWER_ID
|
||||
.equals(fDocCombo.getSelectedDocCommentOwner().getID())) {
|
||||
useBriefTag.setEnabled(true);
|
||||
useStructuralCommands.setEnabled(true);
|
||||
useJavadocStyle.setEnabled(true);
|
||||
newLineAfterBrief.setEnabled(true);
|
||||
usePrePostTag.setEnabled(true);
|
||||
} else {
|
||||
useBriefTag.setEnabled(false);
|
||||
useStructuralCommands.setEnabled(false);
|
||||
useJavadocStyle.setEnabled(false);
|
||||
newLineAfterBrief.setEnabled(false);
|
||||
usePrePostTag.setEnabled(false);
|
||||
}
|
||||
recheckButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (DocCommentOwnerManager.DOXYGEN_CDT_DOC_ONWER_ID.equals(fDocCombo.getSelectedDocCommentOwner().getID())) {
|
||||
useBriefTag.setEnabled(true);
|
||||
useStructuralCommands.setEnabled(true);
|
||||
useJavadocStyle.setEnabled(true);
|
||||
newLineAfterBrief.setEnabled(true);
|
||||
usePrePostTag.setEnabled(true);
|
||||
} else {
|
||||
useBriefTag.setEnabled(false);
|
||||
useStructuralCommands.setEnabled(false);
|
||||
useJavadocStyle.setEnabled(false);
|
||||
newLineAfterBrief.setEnabled(false);
|
||||
usePrePostTag.setEnabled(false);
|
||||
}
|
||||
void recheckButtons() {
|
||||
boolean doxygenEnabled = fDocCombo.isEnabled() && DocCommentOwnerManager.DOXYGEN_CDT_DOC_ONWER_ID
|
||||
.equals(fDocCombo.getSelectedDocCommentOwner().getID());
|
||||
buttons.values().forEach(b -> b.setEnabled(doxygenEnabled));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
useBriefTag.setEnabled(false);
|
||||
useStructuralCommands.setEnabled(false);
|
||||
useJavadocStyle.setEnabled(false);
|
||||
newLineAfterBrief.setEnabled(false);
|
||||
usePrePostTag.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2015 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2020 Symbian Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -11,6 +11,8 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.text.doctools;
|
||||
|
||||
|
@ -93,8 +95,9 @@ public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrateg
|
|||
* @since 6.7
|
||||
*/
|
||||
protected Optional<IProject> getProject() {
|
||||
if (fProject != null)
|
||||
if (fProject != null) {
|
||||
return Optional.of(fProject.getProject());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2020 Symbian Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -11,6 +11,8 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.text.doctools.doxygen;
|
||||
|
||||
|
@ -99,16 +101,17 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
|
|||
|
||||
private void refreshPreferences() {
|
||||
Optional<IProject> project = getProject();
|
||||
DoxygenPreferences pref = new DoxygenPreferences(project);
|
||||
newLineAfterBrief = pref.getBooleanPref(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
|
||||
DoxygenPreferences pref = project.isPresent() ? new DoxygenPreferences(project.get())
|
||||
: new DoxygenPreferences();
|
||||
newLineAfterBrief = pref.getBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
|
||||
DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
|
||||
useBriefTag = pref.getBooleanPref(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG,
|
||||
useBriefTag = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
|
||||
useJavadocStyle = pref.getBooleanPref(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS,
|
||||
useJavadocStyle = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
|
||||
usePrePostTag = pref.getBooleanPref(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS,
|
||||
usePrePostTag = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
|
||||
useStructuralCommands = pref.getBooleanPref(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
|
||||
useStructuralCommands = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
|
||||
DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue