mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug 559067 - Rework DocCommentOwnerComposite and mark it for deletion
Added org.eclipse.cdt.internal.ui.dialogs.DocCommentOwnerArea Deprecated org.eclipse.cdt.ui.dialogs.DocCommentOwnerComposite and marked it for deletion Change-Id: I6ec1266fa0a7bce2e3fee43d1c4c2c0b3ba11ef7 Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
59d42d466a
commit
73a7ac3642
6 changed files with 179 additions and 101 deletions
|
@ -0,0 +1,141 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2020 ArSysOp and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public class DocCommentOwnerArea {
|
||||
|
||||
private final Label desc;
|
||||
private final Label comboLabel;
|
||||
private final Group group;
|
||||
|
||||
private final Combo combo;
|
||||
private final IDocCommentOwner owners[];
|
||||
|
||||
private final Map<OptionMetadata<Boolean>, Button> buttons;
|
||||
|
||||
public DocCommentOwnerArea(Composite pane, DoxygenMetadata metadata, String descriptionText,
|
||||
String comboLabelText) {
|
||||
owners = getNontestOwners();
|
||||
buttons = new LinkedHashMap<>();
|
||||
group = ControlFactory.createGroup(pane, Messages.DocCommentOwnerArea_group_doctool, 2);
|
||||
group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
|
||||
desc = new Label(group, SWT.WRAP);
|
||||
desc.setText(descriptionText);
|
||||
desc.setLayoutData(
|
||||
GridDataFactory.fillDefaults().grab(false, false).span(2, 1).hint(150, SWT.DEFAULT).create());
|
||||
comboLabel = new Label(group, SWT.NONE);
|
||||
comboLabel.setText(comboLabelText);
|
||||
combo = createCombo(group);
|
||||
combo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> recheckButtons()));
|
||||
metadata.booleanOptions().forEach(o -> createCheckBox(group, o));
|
||||
}
|
||||
|
||||
private Combo createCombo(Composite parent) {
|
||||
String[] items = new String[owners.length + 1];
|
||||
items[0] = Messages.DocCommentOwnerArea_doctool_none;
|
||||
for (int i = 0; i < owners.length; i++) {
|
||||
items[i + 1] = owners[i].getName();
|
||||
}
|
||||
Combo created = ControlFactory.createSelectCombo(parent, items, Messages.DocCommentOwnerArea_doctool_none);
|
||||
return created;
|
||||
}
|
||||
|
||||
private Button createCheckBox(Composite parent, OptionMetadata<Boolean> option) {
|
||||
Button checkBox = new Button(parent, SWT.CHECK);
|
||||
checkBox.setText(option.name());
|
||||
checkBox.setToolTipText(option.description());
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalIndent = 0;
|
||||
gd.horizontalSpan = 2;
|
||||
checkBox.setLayoutData(gd);
|
||||
buttons.put(option, checkBox);
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the array of registered doc-comment owners, filtering out those from the
|
||||
* test plug-in.
|
||||
*/
|
||||
private IDocCommentOwner[] getNontestOwners() {
|
||||
List<IDocCommentOwner> result = new ArrayList<>();
|
||||
for (IDocCommentOwner owner : DocCommentOwnerManager.getInstance().getRegisteredOwners()) {
|
||||
if (owner.getID().indexOf(".test.") == -1) //$NON-NLS-1$
|
||||
result.add(owner);
|
||||
}
|
||||
return result.toArray(new IDocCommentOwner[result.size()]);
|
||||
}
|
||||
|
||||
public void initialize(IDocCommentOwner initial, OptionStorage storage) {
|
||||
selectDocumentOwner(initial, combo);
|
||||
buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
|
||||
}
|
||||
|
||||
private void selectDocumentOwner(IDocCommentOwner owner, Combo created) {
|
||||
for (int i = 0; i < owners.length; i++) {
|
||||
if (owners[i].getID().equals(owner.getID())) {
|
||||
created.select(i + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
created.select(0);
|
||||
//no selection event here for some reason, need to force re-check
|
||||
recheckButtons();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
desc.setEnabled(enabled);
|
||||
comboLabel.setEnabled(enabled);
|
||||
combo.setEnabled(enabled);
|
||||
group.setEnabled(enabled);
|
||||
recheckButtons();
|
||||
}
|
||||
|
||||
void recheckButtons() {
|
||||
boolean doxygenEnabled = combo.isEnabled()
|
||||
&& DocCommentOwnerManager.DOXYGEN_CDT_DOC_ONWER_ID.equals(getSelectedDocCommentOwner().getID());
|
||||
buttons.values().forEach(b -> b.setEnabled(doxygenEnabled));
|
||||
}
|
||||
|
||||
public IDocCommentOwner getSelectedDocCommentOwner() {
|
||||
int index = combo.getSelectionIndex();
|
||||
return index == 0 ? NullDocCommentOwner.INSTANCE : owners[index - 1];
|
||||
}
|
||||
|
||||
public void apply(OptionStorage storage) {
|
||||
buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Google, Inc and others.
|
||||
* Copyright (c) 2014, 2020 Google, Inc and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -9,13 +9,17 @@
|
|||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 559067
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
class Messages extends NLS {
|
||||
|
||||
public static String DocCommentOwnerArea_doctool_none;
|
||||
public static String DocCommentOwnerArea_group_doctool;
|
||||
public static String FormattingScopeDialog_do_not_ask_again;
|
||||
public static String FormattingScopeDialog_format_file;
|
||||
public static String FormattingScopeDialog_format_statement;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2014 Google, Inc and others.
|
||||
# Copyright (c) 2014, 2020 Google, Inc and others.
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -9,8 +9,12 @@
|
|||
# SPDX-License-Identifier: EPL-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Sergey Prigogin (Google) - initial API and implementation
|
||||
# Sergey Prigogin (Google) - initial API and implementation
|
||||
# Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 559067
|
||||
###############################################################################
|
||||
|
||||
DocCommentOwnerArea_doctool_none=None
|
||||
DocCommentOwnerArea_group_doctool=Documentation tool comments
|
||||
FormattingScopeDialog_title=Select Formatting Scope
|
||||
FormattingScopeDialog_format_file=The entire &file\u0020
|
||||
FormattingScopeDialog_format_statement=The &statement on the current line
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134, Bug 559193
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - ongoing support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.preferences;
|
||||
|
||||
|
@ -28,18 +28,17 @@ import java.util.ArrayList;
|
|||
|
||||
import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.DocCommentOwnerArea;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
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.ui.PreferenceConstants;
|
||||
import org.eclipse.cdt.ui.dialogs.DocCommentOwnerComposite;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.jface.preference.ColorSelector;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceConverter;
|
||||
|
@ -87,7 +86,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
|
|||
private List fAppearanceColorList;
|
||||
private ColorSelector fAppearanceColorEditor;
|
||||
private Button fAppearanceColorDefault;
|
||||
private DocCommentOwnerComposite fDocCommentOwnerComposite;
|
||||
private DocCommentOwnerArea docCommentOwnerArea;
|
||||
// TODO(sprigogin): Remove once compatibility with Platform 4.4 is no longer required.
|
||||
private final boolean formattingScopeForEmptySelectionSupported;
|
||||
private final DoxygenPreferences doxygenPreferences;
|
||||
|
@ -352,13 +351,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
|
|||
|
||||
String dsc = PreferencesMessages.CEditorPreferencePage_SelectDocToolDescription;
|
||||
String msg = PreferencesMessages.CEditorPreferencePage_WorkspaceDefaultLabel;
|
||||
IDocCommentOwner workspaceOwner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
|
||||
fDocCommentOwnerComposite = new DocCommentOwnerComposite(contents, workspaceOwner, dsc, msg);
|
||||
fDocCommentOwnerComposite.setDoxygenMetadata(doxygenPreferences.metadata());
|
||||
fDocCommentOwnerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
|
||||
|
||||
docCommentOwnerArea = new DocCommentOwnerArea(contents, doxygenPreferences.metadata(), dsc, msg);
|
||||
initialize();
|
||||
|
||||
return contents;
|
||||
}
|
||||
|
||||
|
@ -373,14 +367,14 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
|
|||
fAppearanceColorList.select(0);
|
||||
handleAppearanceColorListSelection();
|
||||
});
|
||||
fDocCommentOwnerComposite.initialize(doxygenPreferences.workspaceStorage());
|
||||
IDocCommentOwner workspaceOwner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
|
||||
docCommentOwnerArea.initialize(workspaceOwner, doxygenPreferences.workspaceStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
DocCommentOwnerManager.getInstance()
|
||||
.setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
|
||||
fDocCommentOwnerComposite.apply(doxygenPreferences.workspaceStorage());
|
||||
DocCommentOwnerManager.getInstance().setWorkspaceCommentOwner(docCommentOwnerArea.getSelectedDocCommentOwner());
|
||||
docCommentOwnerArea.apply(doxygenPreferences.workspaceStorage());
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,12 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Marco Stornelli <marco.stornelli@gmail.com> - Bug 333134
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - Bug 333134, Bug 559193
|
||||
* Alexander Fedorov <alexander.fedorov@arsysop.ru> - ongoing support
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.DocCommentOwnerArea;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
@ -45,12 +46,17 @@ import org.osgi.framework.FrameworkUtil;
|
|||
public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
||||
private static String EDITOR_PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* @deprecated will throw {@link NullPointerException} on attempt to access
|
||||
*/
|
||||
@Deprecated
|
||||
protected DocCommentOwnerComposite fDocComboComposite;
|
||||
protected DocCommentOwnerManager fManager;
|
||||
|
||||
protected Button fCheckbox;
|
||||
protected Link fLink;
|
||||
|
||||
private DocCommentOwnerArea docCommentOwnerArea;
|
||||
private final DoxygenPreferences doxygenPreferences;
|
||||
|
||||
public DocCommentOwnerBlock() {
|
||||
|
@ -61,7 +67,7 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
|||
}
|
||||
|
||||
void handleCheckBox() {
|
||||
fDocComboComposite.setEnabled(fCheckbox.getSelection());
|
||||
docCommentOwnerArea.setEnabled(fCheckbox.getSelection());
|
||||
fLink.setVisible(!fCheckbox.getSelection());
|
||||
}
|
||||
|
||||
|
@ -96,15 +102,11 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
|||
|
||||
String dsc = DialogsMessages.DocCommentOwnerBlock_SelectDocToolDescription;
|
||||
String msg = DialogsMessages.DocCommentOwnerBlock_DocToolLabel;
|
||||
|
||||
IProject project = getProject();
|
||||
IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(project);
|
||||
fDocComboComposite = new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
|
||||
fDocComboComposite.setDoxygenMetadata(doxygenPreferences.metadata());
|
||||
fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
|
||||
|
||||
docCommentOwnerArea = new DocCommentOwnerArea(pane, doxygenPreferences.metadata(), dsc, msg);
|
||||
fCheckbox.setSelection(fManager.projectDefinesOwnership(project));
|
||||
fDocComboComposite.initialize(doxygenPreferences.projectStorage(project));
|
||||
IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(project);
|
||||
docCommentOwnerArea.initialize(prjOwner, doxygenPreferences.projectStorage(project));
|
||||
handleCheckBox();
|
||||
}
|
||||
|
||||
|
@ -114,10 +116,10 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
|
|||
if (!fCheckbox.getSelection())
|
||||
fManager.setCommentOwner(project, null, true);
|
||||
else {
|
||||
IDocCommentOwner newOwner = fDocComboComposite.getSelectedDocCommentOwner();
|
||||
IDocCommentOwner newOwner = docCommentOwnerArea.getSelectedDocCommentOwner();
|
||||
fManager.setCommentOwner(project, newOwner, true);
|
||||
}
|
||||
fDocComboComposite.apply(doxygenPreferences.projectStorage(project));
|
||||
docCommentOwnerArea.apply(doxygenPreferences.projectStorage(project));
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
|
|
|
@ -16,23 +16,17 @@
|
|||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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.internal.ui.dialogs.DocCommentOwnerArea;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
|
@ -43,7 +37,9 @@ 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.
|
||||
* @deprecated scheduled for deletion, replaced with {@link DocCommentOwnerArea}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DocCommentOwnerComposite extends Composite {
|
||||
/**
|
||||
* @deprecated will throw {@link NullPointerException} on attempt to access
|
||||
|
@ -57,12 +53,9 @@ public class DocCommentOwnerComposite extends Composite {
|
|||
private Combo combo;
|
||||
private final IDocCommentOwner fOwners[];
|
||||
|
||||
private final Map<OptionMetadata<Boolean>, Button> buttons;
|
||||
|
||||
public DocCommentOwnerComposite(Composite parent, IDocCommentOwner initialOwner, String description, String label) {
|
||||
super(parent, SWT.NONE);
|
||||
fOwners = getNontestOwners();
|
||||
buttons = new LinkedHashMap<>();
|
||||
GridLayout gl = new GridLayout();
|
||||
gl.marginHeight = gl.marginWidth = 0;
|
||||
setLayout(gl);
|
||||
|
@ -79,12 +72,11 @@ public class DocCommentOwnerComposite extends Composite {
|
|||
|
||||
comboLabel = new Label(group, SWT.NONE);
|
||||
comboLabel.setText(label);
|
||||
combo = createCombo(group, initialOwner);
|
||||
combo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> recheckButtons()));
|
||||
combo = createCombo(group);
|
||||
selectDocumentOwner(initialOwner, combo);
|
||||
}
|
||||
|
||||
private Combo createCombo(Composite parent, IDocCommentOwner initialOwner) {
|
||||
private Combo createCombo(Composite parent) {
|
||||
String[] items = new String[fOwners.length + 1];
|
||||
items[0] = DialogsMessages.DocCommentOwnerCombo_None;
|
||||
for (int i = 0; i < fOwners.length; i++) {
|
||||
|
@ -117,76 +109,17 @@ public class DocCommentOwnerComposite extends Composite {
|
|||
return result.toArray(new IDocCommentOwner[result.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates widgets required to represent doxygen options, extracted from constructor to keep it unchanged.
|
||||
* Needs to be invoked only once just after the constructor
|
||||
*
|
||||
* @param metadata the doxygen metadata to use for checkbox creation
|
||||
*
|
||||
* @since 6.7
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void setDoxygenMetadata(DoxygenMetadata metadata) {
|
||||
metadata.booleanOptions().forEach(o -> createCheckBox(group, o));
|
||||
}
|
||||
|
||||
private Button createCheckBox(Composite parent, OptionMetadata<Boolean> option) {
|
||||
Button checkBox = new Button(parent, SWT.CHECK);
|
||||
checkBox.setText(option.name());
|
||||
checkBox.setToolTipText(option.description());
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalIndent = 0;
|
||||
gd.horizontalSpan = 2;
|
||||
checkBox.setLayoutData(gd);
|
||||
buttons.put(option, checkBox);
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
public IDocCommentOwner getSelectedDocCommentOwner() {
|
||||
int index = combo.getSelectionIndex();
|
||||
return index == 0 ? NullDocCommentOwner.INSTANCE : fOwners[index - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes widget values from the given option storage instance
|
||||
*
|
||||
* @param storage the option storage to initialize from
|
||||
*
|
||||
* @since 6.7
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void initialize(OptionStorage storage) {
|
||||
buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply widget values to the given option storage instance
|
||||
*
|
||||
* @param storage the option storage to apply to
|
||||
*
|
||||
* @since 6.7
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
public void apply(OptionStorage storage) {
|
||||
buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
desc.setEnabled(enabled);
|
||||
comboLabel.setEnabled(enabled);
|
||||
combo.setEnabled(enabled);
|
||||
group.setEnabled(enabled);
|
||||
recheckButtons();
|
||||
}
|
||||
|
||||
void recheckButtons() {
|
||||
boolean doxygenEnabled = combo.isEnabled()
|
||||
&& DocCommentOwnerManager.DOXYGEN_CDT_DOC_ONWER_ID.equals(getSelectedDocCommentOwner().getID());
|
||||
buttons.values().forEach(b -> b.setEnabled(doxygenEnabled));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue