1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 18:35:32 +02:00
This commit is contained in:
Andrew Gvozdev 2012-04-30 09:53:06 -04:00
parent 2876909d25
commit 7104c92f7f
17 changed files with 1069 additions and 995 deletions

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage; import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
@ -37,25 +36,17 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
/** /**
* Options page for TODO * Options page for {@link AbstractBuiltinSpecsDetector}.
*
*/ */
public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage { public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable; private boolean fEditable;
private Text inputCommand; private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button allocateConsoleCheckBox; private Button allocateConsoleCheckBox;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
public void createControl(Composite parent) { public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled(); fEditable = parent.isEnabled();
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
@ -126,93 +117,8 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
} }
} }
}); });
} }
// {
// final Button button = new Button(composite, SWT.PUSH);
// button.setFont(parent.getFont());
// String text = fProvider.isEmpty() ? "Run Now (TODO)" : "Clear";
// button.setText(text);
//// button.addSelectionListener(this);
// GridData data = new GridData();
// data.horizontalSpan = 2;
//// data.horizontalAlignment = GridData.BEGINNING;
//// data.widthHint = 60;
// button.setLayoutData(data);
// // TODO
// button.setEnabled(fEditable && !fProvider.isEmpty());
//
// button.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent evt) {
// if (fProvider.isEmpty()) {
// // TODO
// } else {
// fProvider.clear();
// }
// // TODO
// button.setEnabled(fEditable && !fProvider.isEmpty());
// String text = fProvider.isEmpty() ? "Run Now (TODO)" : "Clear";
// button.setText(text);
// button.pack();
// }
//
// });
//
// }
// // Compiler specs command
// {
// Label label = ControlFactory.createLabel(composite, "Parsing rules:");
// GridData gd = new GridData();
// gd.horizontalSpan = 2;
// label.setLayoutData(gd);
//// Label newLabel = new Label(composite, SWT.NONE);
////// ((GridData) newLabel.getLayoutData()).horizontalSpan = 1;
//// newLabel.setText("Command to get compiler specs:");
// }
// createPatternsTable(group, composite);
// Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
// group.setText(DialogsMessages.RegexErrorParserOptionPage_Title);
//
// GridLayout gridLayout = new GridLayout(2, true);
// gridLayout.makeColumnsEqualWidth = false;
// gridLayout.marginRight = -10;
// gridLayout.marginLeft = -4;
// group.setLayout(gridLayout);
// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
// Composite composite = new Composite(group, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 1;
// layout.marginHeight = 1;
// layout.marginRight = 1;
// composite.setLayout(layout);
// composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Dialog.applyDialogFont(composite);
//
// if (!fEditable)
// createLinkToPreferences(composite);
//
// createPatternsTable(group, composite);
//
// if (fEditable) {
// createButtons(composite);
// }
{ {
allocateConsoleCheckBox = new Button(composite, SWT.CHECK); allocateConsoleCheckBox = new Button(composite, SWT.CHECK);
allocateConsoleCheckBox.setText("Allocate console in the Console View"); allocateConsoleCheckBox.setText("Allocate console in the Console View");
@ -239,13 +145,6 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
} }
// // Status line
// if (fEditable) {
// fStatusLine = new StatusMessageLine(composite, SWT.LEFT, 2);
// IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "Note that currently not all options are persisted (FIXME)");
// fStatusLine.setErrorStatus(status);
// }
setControl(composite); setControl(composite);
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage; import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser;
import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
@ -43,9 +42,6 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
private Text inputCommand; private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button runOnceRadioButton;
private Button runEveryBuildRadioButton;
private Button expandRelativePathCheckBox; private Button expandRelativePathCheckBox;
private Button scopeProjectRadioButton; private Button scopeProjectRadioButton;
@ -53,14 +49,8 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
private Button scopeFileRadioButton; private Button scopeFileRadioButton;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override @Override
public void createControl(Composite parent) { public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled(); fEditable = parent.isEnabled();
final Composite composite = new Composite(parent, SWT.NONE); final Composite composite = new Composite(parent, SWT.NONE);
@ -116,21 +106,6 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
}); });
} }
// {
// Button button = ControlFactory.createPushButton(composite, "Browse...");
// button.setEnabled(fEditable);
// button.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent evt) {
//// handleAddr2LineButtonSelected();
// //updateLaunchConfigurationDialog();
// }
//
// });
//
// }
{ {
expandRelativePathCheckBox = new Button(composite, SWT.CHECK); expandRelativePathCheckBox = new Button(composite, SWT.CHECK);
expandRelativePathCheckBox.setText("Use heuristics to resolve paths"); expandRelativePathCheckBox.setText("Use heuristics to resolve paths");
@ -265,13 +240,6 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
} }
// // Status line
// if (fEditable) {
// fStatusLine = new StatusMessageLine(composite, SWT.LEFT, 2);
// IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "Note that currently not all options are persisted (FIXME)");
// fStatusLine.setErrorStatus(status);
// }
setControl(composite); setControl(composite);
} }

View file

@ -226,7 +226,7 @@ The value "true" of this attribute is meaningful only for providers ca
<meta.section type="since"/> <meta.section type="since"/>
</appInfo> </appInfo>
<documentation> <documentation>
CDT 9.0 CDT 8.1
</documentation> </documentation>
</annotation> </annotation>

View file

@ -3372,7 +3372,7 @@
<page <page
name="Preprocessor Include Paths, Macros etc." name="Preprocessor Include Paths, Macros etc."
id="org.eclipse.cdt.ui.language.settings" id="org.eclipse.cdt.ui.language.settings"
class="org.eclipse.cdt.internal.ui.language.settings.providers.Page_LanguageSettingsProviders" class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
category="org.eclipse.cdt.ui.newui.Page_head_general"> category="org.eclipse.cdt.ui.newui.Page_head_general">
<enabledWhen> <enabledWhen>
<adapt type="org.eclipse.core.resources.IResource"> <adapt type="org.eclipse.core.resources.IResource">
@ -4337,7 +4337,7 @@
name="Entries" name="Entries"
weight="010" weight="010"
helpId="FIXME cdt_u_prop_pns_inc" helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.Page_LanguageSettingsProviders" parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
tooltip="%AllLanguageSettingEntries.tooltip"/> tooltip="%AllLanguageSettingEntries.tooltip"/>
<tab <tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab" class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab"
@ -4345,7 +4345,7 @@
name="Providers" name="Providers"
weight="020" weight="020"
helpId="FIXME cdt_u_prop_pns_inc" helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.Page_LanguageSettingsProviders" parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
tooltip="%AllLanguageSettingEntries.tooltip"/> tooltip="%AllLanguageSettingEntries.tooltip"/>
</extension> </extension>
<extension <extension

View file

@ -1,12 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.make.ui" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appInfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.make.ui" id="LanguageSettingsProviderAssociation" name="Language Settings Provider UI"/> <meta.schema plugin="org.eclipse.cdt.ui" id="LanguageSettingsProviderAssociation" name="Language Settings Provider UI Associations"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter description of this extension point.] This extension point defines appearance and behavior of UI controls for Language Settings Providers defined with extension point &lt;samp&gt;org.eclipse.cdt.core.LanguageSettingsProvider&lt;/samp&gt;.
</documentation> </documentation>
</annotation> </annotation>
@ -15,6 +15,9 @@
<appInfo> <appInfo>
<meta.element /> <meta.element />
</appInfo> </appInfo>
<documentation>
This extension point is used to define appearance and behavior of Language Settings Providers in user interface.
</documentation>
</annotation> </annotation>
<complexType> <complexType>
<sequence> <sequence>
@ -31,14 +34,14 @@
<attribute name="id" type="string"> <attribute name="id" type="string">
<annotation> <annotation>
<documentation> <documentation>
ID of the extension point, not used
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="name" type="string"> <attribute name="name" type="string">
<annotation> <annotation>
<documentation> <documentation>
Name of the extension point, not used
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
@ -49,18 +52,23 @@
</element> </element>
<element name="id-association"> <element name="id-association">
<annotation>
<documentation>
The definition of UI elements associated with ID of language settings provider.
</documentation>
</annotation>
<complexType> <complexType>
<attribute name="id" type="string" use="required"> <attribute name="id" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
ID of language settings provider for which appearance is being defined.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="icon" type="string"> <attribute name="icon" type="string">
<annotation> <annotation>
<documentation> <documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="resource"/> <meta.attribute kind="resource"/>
@ -70,7 +78,7 @@
<attribute name="page" type="string"> <attribute name="page" type="string">
<annotation> <annotation>
<documentation> <documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
@ -80,14 +88,14 @@
<attribute name="ui-edit-entries" type="boolean"> <attribute name="ui-edit-entries" type="boolean">
<annotation> <annotation>
<documentation> <documentation>
Defines if user is allowed to edit provider&apos;s entries in UI.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="ui-clear-entries" type="boolean"> <attribute name="ui-clear-entries" type="boolean">
<annotation> <annotation>
<documentation> <documentation>
Defines if user is allowed to clear provider&apos;s entries in UI. For some providers like compiler specs detectors that may trigger automatic rerun.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -95,11 +103,16 @@
</element> </element>
<element name="class-association"> <element name="class-association">
<annotation>
<documentation>
The definition of UI elements associated with type of language settings provider. Providers subclassed from this type will inherit characteristics from closest super-type (unless exact ID association is defined).
</documentation>
</annotation>
<complexType> <complexType>
<attribute name="class" type="string" use="required"> <attribute name="class" type="string" use="required">
<annotation> <annotation>
<documentation> <documentation>
Class of language settings provider for which appearance is being defined.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java"/> <meta.attribute kind="java"/>
@ -109,7 +122,7 @@
<attribute name="icon" type="string"> <attribute name="icon" type="string">
<annotation> <annotation>
<documentation> <documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="resource"/> <meta.attribute kind="resource"/>
@ -119,24 +132,24 @@
<attribute name="page" type="string"> <attribute name="page" type="string">
<annotation> <annotation>
<documentation> <documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation> </documentation>
<appInfo> <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/> <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
</appInfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="ui-clear-entries" type="boolean">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="ui-edit-entries" type="boolean"> <attribute name="ui-edit-entries" type="boolean">
<annotation> <annotation>
<documentation> <documentation>
Defines if user is allowed to edit provider&apos;s entries in UI.
</documentation>
</annotation>
</attribute>
<attribute name="ui-clear-entries" type="boolean">
<annotation>
<documentation>
Defines if user is allowed to clear provider&apos;s entries in UI. For some providers like compiler specs detectors that may trigger automatic rerun.
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -148,7 +161,7 @@
<meta.section type="since"/> <meta.section type="since"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter the first release in which this extension point appears.] CDT 8.1
</documentation> </documentation>
</annotation> </annotation>
@ -157,7 +170,7 @@
<meta.section type="examples"/> <meta.section type="examples"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter extension point usage example here.] For an example see definition for org.eclipse.cdt.ui.UserLanguageSettingsProvider.
</documentation> </documentation>
</annotation> </annotation>
@ -170,14 +183,18 @@
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appInfo> <appInfo>
<meta.section type="implementation"/> <meta.section type="copyright"/>
</appInfo> </appInfo>
<documentation> <documentation>
[Enter information about supplied implementation of this extension point.] Copyright (c) 2010, 2012 Andrew Gvozdev and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
</documentation> </documentation>
</annotation> </annotation>
</schema> </schema>

View file

@ -12,10 +12,19 @@ package org.eclipse.cdt.internal.ui.language.settings.providers;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
/**
* Abstract class to implement language settings providers Options page.
*/
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage { public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
protected LanguageSettingsProviderTab providerTab; protected LanguageSettingsProviderTab providerTab;
protected String providerId; protected String providerId;
/**
* Initialize the options page with the owning tab and provider ID.
*
* @param providerTab - provider tab which owns the options page.
* @param providerId - ID of the provider the options page is for.
*/
protected void init(LanguageSettingsProviderTab providerTab, String providerId) { protected void init(LanguageSettingsProviderTab providerTab, String providerId) {
this.providerTab = providerTab; this.providerTab = providerTab;
this.providerId = providerId; this.providerId = providerId;

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2010 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation * Andrew Gvozdev - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers; package org.eclipse.cdt.internal.ui.language.settings.providers;
@ -52,6 +52,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private boolean clearValue; private boolean clearValue;
private int kind; private int kind;
private Composite compositeArea;
private Label iconComboKind; private Label iconComboKind;
private ImageCombo comboKind; private ImageCombo comboKind;
private ImageCombo comboPathCategory; private ImageCombo comboPathCategory;
@ -70,7 +71,6 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private Button buttonOk; private Button buttonOk;
private Button buttonCancel; private Button buttonCancel;
private static final int COMBO_INDEX_INCLUDE_PATH = 0; private static final int COMBO_INDEX_INCLUDE_PATH = 0;
private static final int COMBO_INDEX_MACRO = 1; private static final int COMBO_INDEX_MACRO = 1;
private static final int COMBO_INDEX_INCLUDE_FILE = 2; private static final int COMBO_INDEX_INCLUDE_FILE = 2;
@ -79,12 +79,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private static final int COMBO_INDEX_LIBRARY_FILE = 5; private static final int COMBO_INDEX_LIBRARY_FILE = 5;
final private String [] comboKindItems = { final private String [] comboKindItems = {
"Include Directory", Messages.LanguageSettingEntryDialog_IncludeDirectory,
"Preprocessor Macro", Messages.LanguageSettingEntryDialog_PreporocessorMacro,
"Include File", Messages.LanguageSettingEntryDialog_IncludeFile,
"Preprocessor Macros File", Messages.LanguageSettingEntryDialog_PreprocessorMacroFile,
"Library Path", Messages.LanguageSettingEntryDialog_LibraryPath,
"Library", Messages.LanguageSettingEntryDialog_Library,
}; };
final private Image[] comboKindImages = { final private Image[] comboKindImages = {
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER), CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER),
@ -100,9 +100,9 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private static final int COMBO_PATH_INDEX_FILESYSTEM = 2; private static final int COMBO_PATH_INDEX_FILESYSTEM = 2;
final private String [] pathCategories = { final private String [] pathCategories = {
"Project-Relative", Messages.LanguageSettingEntryDialog_ProjectRelative,
"Workspace Path", Messages.LanguageSettingEntryDialog_WorkspacePath,
"Filesystem", Messages.LanguageSettingEntryDialog_Filesystem,
}; };
final private Image[] pathCategoryImages = { final private Image[] pathCategoryImages = {
CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT), CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT),
@ -110,13 +110,11 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM), CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM),
}; };
private ICLanguageSettingEntry[] entries; private ICLanguageSettingEntry[] entries;
private Composite comp1;
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, int kind) { public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, int kind) {
super(parent, ""); super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription; this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject(); this.project = cfgDescription.getProjectDescription().getProject();
this.entry = null; this.entry = null;
@ -129,7 +127,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
* where provided entry is used as a template. * where provided entry is used as a template.
*/ */
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry, boolean clearValue) { public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry, boolean clearValue) {
super(parent, ""); super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription; this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject(); this.project = cfgDescription.getProjectDescription().getProject();
this.entry = entry; this.entry = entry;
@ -199,26 +197,26 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
parent.setLayout(new GridLayout(4, false)); parent.setLayout(new GridLayout(4, false));
GridData gd; GridData gd;
// Composite comp1 // Composite for the dialog area
comp1 = new Composite (parent, SWT.NONE); compositeArea = new Composite (parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP; gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 7; gd.horizontalSpan = 7;
comp1.setLayoutData(gd); compositeArea.setLayoutData(gd);
comp1.setLayout(new GridLayout(7, false)); compositeArea.setLayout(new GridLayout(7, false));
// Icon for kind // Icon for kind
iconComboKind = new Label (comp1, SWT.NONE); iconComboKind = new Label (compositeArea, SWT.NONE);
gd = new GridData(); gd = new GridData();
gd.verticalAlignment = SWT.TOP; gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.RIGHT; gd.horizontalAlignment = SWT.RIGHT;
iconComboKind.setLayoutData(gd); iconComboKind.setLayoutData(gd);
iconComboKind.setText("Select Kind:"); iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
int kindToComboIndex = kindToComboIndex(kind); int kindToComboIndex = kindToComboIndex(kind);
iconComboKind.setImage(comboKindImages[kindToComboIndex]); iconComboKind.setImage(comboKindImages[kindToComboIndex]);
// Combo for the setting entry kind // Combo for the setting entry kind
comboKind = new ImageCombo(comp1, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); comboKind = new ImageCombo(compositeArea, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < comboKindItems.length; i++) { for (int i = 0; i < comboKindItems.length; i++) {
comboKind.add(comboKindItems[i], comboKindImages[i]); comboKind.add(comboKindItems[i], comboKindImages[i]);
} }
@ -238,18 +236,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
}); });
comboKind.setEnabled(clearValue); comboKind.setEnabled(clearValue);
//
// Icon for path category // Icon for path category
final Label comboPathCategoryIcon = new Label (comp1, SWT.NONE); final Label comboPathCategoryIcon = new Label (compositeArea, SWT.NONE);
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END); gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
gd.verticalAlignment = SWT.TOP; gd.verticalAlignment = SWT.TOP;
gd.widthHint = 15; gd.widthHint = 15;
comboPathCategoryIcon.setLayoutData(gd); comboPathCategoryIcon.setLayoutData(gd);
comboPathCategoryIcon.setText(""); comboPathCategoryIcon.setText(""); //$NON-NLS-1$
// Combo for path category // Combo for path category
comboPathCategory = new ImageCombo(comp1, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); comboPathCategory = new ImageCombo(compositeArea, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < pathCategories.length; i++) { for (int i = 0; i < pathCategories.length; i++) {
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]); comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
} }
@ -286,13 +282,13 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
}); });
// Dir/File/Name label // Dir/File/Name label
labelInput = new Label(comp1, SWT.NONE); labelInput = new Label(compositeArea, SWT.NONE);
labelInput.setText("Dir:"); labelInput.setText(Messages.LanguageSettingEntryDialog_Directory);
gd = new GridData(); gd = new GridData();
labelInput.setLayoutData(gd); labelInput.setLayoutData(gd);
// Dir/File/Name input // Dir/File/Name input
inputName = new Text(comp1, SWT.SINGLE | SWT.BORDER); inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) { if (entry!=null && !clearValue) {
inputName.setText(entry.getName()); inputName.setText(entry.getName());
} }
@ -310,14 +306,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
inputName.setSelection(0, inputName.getText().length()); inputName.setSelection(0, inputName.getText().length());
// Value label // Value label
checkBoxValue = new Label(comp1, SWT.NONE); checkBoxValue = new Label(compositeArea, SWT.NONE);
checkBoxValue.setText("Value:"); checkBoxValue.setText(Messages.LanguageSettingEntryDialog_Value);
gd = new GridData(); gd = new GridData();
checkBoxValue.setLayoutData(gd); checkBoxValue.setLayoutData(gd);
// Path button // Path button
buttonBrowse = new Button(comp1, SWT.PUSH); buttonBrowse = new Button(compositeArea, SWT.PUSH);
buttonBrowse.setText("..."); buttonBrowse.setText("..."); //$NON-NLS-1$
buttonBrowse.setImage(pathCategoryImages[0]); buttonBrowse.setImage(pathCategoryImages[0]);
buttonBrowse.setLayoutData(new GridData()); buttonBrowse.setLayoutData(new GridData());
buttonBrowse.addSelectionListener(new SelectionAdapter() { buttonBrowse.addSelectionListener(new SelectionAdapter() {
@ -328,7 +324,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
}); });
// Variables button // Variables button
buttonVars = new Button(comp1, SWT.PUSH); buttonVars = new Button(compositeArea, SWT.PUSH);
buttonVars.setText(AbstractCPropertyTab.VARIABLESBUTTON_NAME); buttonVars.setText(AbstractCPropertyTab.VARIABLESBUTTON_NAME);
buttonVars.setLayoutData(new GridData()); buttonVars.setLayoutData(new GridData());
buttonVars.addSelectionListener(new SelectionAdapter() { buttonVars.addSelectionListener(new SelectionAdapter() {
@ -340,7 +336,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Value input. Located after the other controls to get sufficient width // Value input. Located after the other controls to get sufficient width
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x; int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
inputValue = new Text(comp1, SWT.SINGLE | SWT.BORDER); inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry != null && !clearValue) { if (entry != null && !clearValue) {
inputValue.setText(entry.getValue()); inputValue.setText(entry.getValue());
} }
@ -363,18 +359,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Built-In" // Checkbox "Built-In"
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK); checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
checkBoxBuiltIn.setText("Treat as Built-In (Ignore during build)"); checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag);
checkBoxBuiltIn.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.BUILTIN)!=0); checkBoxBuiltIn.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.BUILTIN)!=0);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxBuiltIn.setLayoutData(gd); checkBoxBuiltIn.setLayoutData(gd);
checkBoxBuiltIn.addSelectionListener(new SelectionListener() { checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateImages(); updateImages();
setButtons(); setButtons();
} }
@Override @Override
public void widgetDefaultSelected(SelectionEvent e) { public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e); widgetSelected(e);
@ -383,18 +377,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Framework" // Checkbox "Framework"
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK); checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
checkBoxFramework.setText("Framework folder (Mac only)"); checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
checkBoxFramework.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.FRAMEWORKS_MAC)!=0); checkBoxFramework.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.FRAMEWORKS_MAC)!=0);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxFramework.setLayoutData(gd); checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() { checkBoxFramework.addSelectionListener(new SelectionListener() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
updateImages(); updateImages();
setButtons(); setButtons();
} }
@Override @Override
public void widgetDefaultSelected(SelectionEvent e) { public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e); widgetSelected(e);
@ -469,7 +461,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private void setButtons() { private void setButtons() {
int kindSelectionIndex = comboKind.getSelectionIndex(); int kindSelectionIndex = comboKind.getSelectionIndex();
boolean isMacroSelected = kindSelectionIndex==COMBO_INDEX_MACRO; boolean isMacroSelected = (kindSelectionIndex == COMBO_INDEX_MACRO);
comboPathCategory.setVisible(!isMacroSelected); comboPathCategory.setVisible(!isMacroSelected);
buttonBrowse.setVisible(!isMacroSelected); buttonBrowse.setVisible(!isMacroSelected);
buttonVars.setVisible(!isMacroSelected); buttonVars.setVisible(!isMacroSelected);
@ -485,24 +477,24 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
switch (kindSelectionIndex) { switch (kindSelectionIndex) {
case COMBO_INDEX_INCLUDE_PATH: case COMBO_INDEX_INCLUDE_PATH:
case COMBO_INDEX_LIBRARY_PATH: case COMBO_INDEX_LIBRARY_PATH:
labelInput.setText("Path:"); labelInput.setText(Messages.LanguageSettingEntryDialog_Path);
break; break;
case COMBO_INDEX_INCLUDE_FILE: case COMBO_INDEX_INCLUDE_FILE:
case COMBO_INDEX_MACRO_FILE: case COMBO_INDEX_MACRO_FILE:
case COMBO_INDEX_LIBRARY_FILE: case COMBO_INDEX_LIBRARY_FILE:
labelInput.setText("File:"); labelInput.setText(Messages.LanguageSettingEntryDialog_File);
break; break;
case COMBO_INDEX_MACRO: case COMBO_INDEX_MACRO:
default: default:
labelInput.setText("Name:"); labelInput.setText(Messages.LanguageSettingEntryDialog_Name);
} }
inputValue.setEnabled(isMacroSelected); inputValue.setEnabled(isMacroSelected);
int indexPathKind = comboPathCategory.getSelectionIndex(); int indexPathKind = comboPathCategory.getSelectionIndex();
boolean isProjectSelected = indexPathKind==COMBO_PATH_INDEX_PROJECT; boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
boolean isWorkspaceSelected = indexPathKind==COMBO_PATH_INDEX_WORKSPACE; boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
boolean isFilesystemSelected = indexPathKind==COMBO_PATH_INDEX_FILESYSTEM; boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
String path = inputName.getText(); String path = inputName.getText();
if (path.trim().length() == 0) { if (path.trim().length() == 0) {
@ -514,12 +506,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
buttonVars.setEnabled(isFilesystemSelected); buttonVars.setEnabled(isFilesystemSelected);
comp1.layout(true); compositeArea.layout(true);
} }
@Override @Override
public void buttonPressed(SelectionEvent e) { public void buttonPressed(SelectionEvent e) {
String s=null; String str = null;
if (e.widget.equals(buttonOk)) { if (e.widget.equals(buttonOk)) {
String name = inputName.getText(); String name = inputName.getText();
text1 = name; text1 = name;
@ -586,39 +578,39 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
if (isDirectory) { if (isDirectory) {
switch (comboPathCategory.getSelectionIndex()) { switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE: case COMBO_PATH_INDEX_WORKSPACE:
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, inputName.getText()); str = AbstractCPropertyTab.getWorkspaceDirDialog(shell, inputName.getText());
break; break;
case COMBO_PATH_INDEX_PROJECT: case COMBO_PATH_INDEX_PROJECT:
s = AbstractCPropertyTab.getProjectDirDialog(shell, inputName.getText(), project); str = AbstractCPropertyTab.getProjectDirDialog(shell, inputName.getText(), project);
break; break;
case COMBO_PATH_INDEX_FILESYSTEM: case COMBO_PATH_INDEX_FILESYSTEM:
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, inputName.getText()); str = AbstractCPropertyTab.getFileSystemDirDialog(shell, inputName.getText());
break; break;
} }
} else if (isFile) { } else if (isFile) {
switch (comboPathCategory.getSelectionIndex()) { switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE: case COMBO_PATH_INDEX_WORKSPACE:
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, inputName.getText()); str = AbstractCPropertyTab.getWorkspaceFileDialog(shell, inputName.getText());
break; break;
case COMBO_PATH_INDEX_PROJECT: case COMBO_PATH_INDEX_PROJECT:
s = AbstractCPropertyTab.getProjectFileDialog(shell, inputName.getText(), project); str = AbstractCPropertyTab.getProjectFileDialog(shell, inputName.getText(), project);
break; break;
case COMBO_PATH_INDEX_FILESYSTEM: case COMBO_PATH_INDEX_FILESYSTEM:
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, inputName.getText()); str = AbstractCPropertyTab.getFileSystemFileDialog(shell, inputName.getText());
break; break;
} }
} }
if (s != null) { if (str != null) {
s = strip_wsp(s); str = strip_wsp(str);
if (comboPathCategory.getSelectionIndex()==COMBO_PATH_INDEX_PROJECT && s.startsWith(SLASH+project.getName()+SLASH)) { if (comboPathCategory.getSelectionIndex()==COMBO_PATH_INDEX_PROJECT && str.startsWith(SLASH+project.getName()+SLASH)) {
s=s.substring(project.getName().length()+2); str=str.substring(project.getName().length()+2);
} }
inputName.setText(s); inputName.setText(str);
} }
} else if (e.widget.equals(buttonVars)) { } else if (e.widget.equals(buttonVars)) {
s = AbstractCPropertyTab.getVariableDialog(shell, cfgDescription); str = AbstractCPropertyTab.getVariableDialog(shell, cfgDescription);
if (s != null) inputName.insert(s); if (str != null) inputName.insert(str);
} }
} }
@ -629,7 +621,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private void updateImages() { private void updateImages() {
int indexEntryKind = comboKind.getSelectionIndex(); int indexEntryKind = comboKind.getSelectionIndex();
int indexPathKind = comboPathCategory.getSelectionIndex(); int indexPathKind = comboPathCategory.getSelectionIndex();
shell.setText("Add " + comboKindItems[indexEntryKind]); shell.setText(Messages.LanguageSettingEntryDialog_Add + comboKindItems[indexEntryKind]);
int kind = comboIndexToKind(indexEntryKind); int kind = comboIndexToKind(indexEntryKind);
int flagBuiltin = checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0; int flagBuiltin = checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,7 +8,6 @@
* Contributors: * Contributors:
* Andrew Gvozdev - Initial API and implementation * Andrew Gvozdev - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers; package org.eclipse.cdt.internal.ui.language.settings.providers;
import java.util.ArrayList; import java.util.ArrayList;
@ -64,7 +63,6 @@ import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine; import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
/** /**
* This tab presents language settings entries categorized by language * This tab presents language settings entries categorized by language
* settings providers. * settings providers.
@ -79,14 +77,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private Tree treeLanguages; private Tree treeLanguages;
private Tree treeEntries; private Tree treeEntries;
private TreeViewer treeEntriesViewer; private TreeViewer treeEntriesViewer;
private static String currentLanguageIdGlobal = null;
private String currentLanguageId = null; private String currentLanguageId = null;
private static String currentLanguageIdGlobal = null;
private Button builtInCheckBox; private Button builtInCheckBox;
private Button enableProvidersCheckBox; private Button enableProvidersCheckBox;
private StatusMessageLine fStatusLine; private StatusMessageLine fStatusLine;
private Page_LanguageSettingsProviders masterPropertyPage = null; private LanguageSettingsProvidersPage masterPropertyPage = null;
private static final int BUTTON_ADD = 0; private static final int BUTTON_ADD = 0;
private static final int BUTTON_EDIT = 1; private static final int BUTTON_EDIT = 1;
@ -95,7 +93,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private static final int BUTTON_MOVE_UP = 4; private static final int BUTTON_MOVE_UP = 4;
private static final int BUTTON_MOVE_DOWN = 5; private static final int BUTTON_MOVE_DOWN = 5;
private final static String[] BUTTON_LABELS = new String[6]; private static final String[] BUTTON_LABELS = new String[6];
{ {
BUTTON_LABELS[BUTTON_ADD] = ADD_STR; BUTTON_LABELS[BUTTON_ADD] = ADD_STR;
BUTTON_LABELS[BUTTON_EDIT] = EDIT_STR; BUTTON_LABELS[BUTTON_EDIT] = EDIT_STR;
@ -108,25 +106,25 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private Map<String, List<ILanguageSettingsProvider>> initialProvidersMap = new HashMap<String, List<ILanguageSettingsProvider>>(); private Map<String, List<ILanguageSettingsProvider>> initialProvidersMap = new HashMap<String, List<ILanguageSettingsProvider>>();
/**
* Label provider for language settings providers displayed by this tab.
*/
private class EntriesTreeLabelProvider extends LanguageSettingsProvidersLabelProvider { private class EntriesTreeLabelProvider extends LanguageSettingsProvidersLabelProvider {
@Override @Override
protected String[] getOverlayKeys(ILanguageSettingsProvider provider) { protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
String[] overlayKeys = super.getOverlayKeys(provider); String[] overlayKeys = super.getOverlayKeys(provider);
// if (LanguageSettingsManager.isWorkspaceProvider(provider))
// provider = LanguageSettingsManager.getRawWorkspaceProvider(provider.getId());
//
if (currentLanguageId != null) { if (currentLanguageId != null) {
IResource rc = getResource(); IResource rc = getResource();
List<ICLanguageSettingEntry> entries = getSettingEntries(provider); List<ICLanguageSettingEntry> entries = getSettingEntries(provider);
if (entries == null && !(rc instanceof IProject)) { if (entries == null && !(rc instanceof IProject)) {
List<ICLanguageSettingEntry> entriesParent = getSettingEntriesUpResourceTree(provider); List<ICLanguageSettingEntry> entriesParent = getSettingEntriesUpResourceTree(provider);
if (entriesParent != null /*&& entriesParent.size() > 0*/) { if (entriesParent != null) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT; overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT;
} }
} else if (provider instanceof ILanguageSettingsBroadcastingProvider && (page.isForFile() || page.isForFolder())) { } else if (provider instanceof ILanguageSettingsBroadcastingProvider && (page.isForFile() || page.isForFolder())) {
// Assuming that the default entries for a resource are always null. // Assuming that the default entries for a resource are always null.
// Using that for performance reasons. See note in PerformDefaults(). // Using that for performance reasons. See note in performDefaults().
List<ICLanguageSettingEntry> entriesParent = provider.getSettingEntries(null, null, currentLanguageId); List<ICLanguageSettingEntry> entriesParent = provider.getSettingEntries(null, null, currentLanguageId);
if (entries != null && !entries.equals(entriesParent)) { if (entries != null && !entries.equals(entriesParent)) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING; overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
@ -134,7 +132,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
// TODO
ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId()); List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
if (initialProviders != null && !initialProviders.contains(provider)) { if (initialProviders != null && !initialProviders.contains(provider)) {
@ -146,8 +143,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
if (element instanceof ICLanguageSettingEntry) { if (element instanceof ICLanguageSettingEntry) {
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element; ICConfigurationDescription cfgDescription = getConfigurationDescription();
return LanguageSettingsImages.getImage(entry); return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfgDescription);
} }
return super.getImage(element); return super.getImage(element);
@ -312,6 +309,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return provider.getSettingEntries(cfgDescription, rc, currentLanguageId); return provider.getSettingEntries(cfgDescription, rc, currentLanguageId);
} }
/**
* Store original providers to be able to tell whether they were changed by user.
*/
private void trackInitialSettings() { private void trackInitialSettings() {
if (!page.isForPrefs()) { if (!page.isForPrefs()) {
ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable(); ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable();
@ -325,6 +325,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Create UI control for languages.
*/
private void createTreeForLanguages(Composite parent) { private void createTreeForLanguages(Composite parent) {
treeLanguages = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL); treeLanguages = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
treeLanguages.setLayoutData(new GridData(GridData.FILL_VERTICAL)); treeLanguages.setLayoutData(new GridData(GridData.FILL_VERTICAL));
@ -361,6 +364,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}); });
} }
/**
* Create tree for providers and their entries.
*/
private void createTreeForEntries(Composite parent) { private void createTreeForEntries(Composite parent) {
treeEntries = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); treeEntries = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
treeEntries.setLayoutData(new GridData(GridData.FILL_VERTICAL)); treeEntries.setLayoutData(new GridData(GridData.FILL_VERTICAL));
@ -408,6 +414,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
/**
* Create sash form.
*/
private void createSashForm() { private void createSashForm() {
sashFormEntries = new SashForm(usercomp,SWT.HORIZONTAL); sashFormEntries = new SashForm(usercomp,SWT.HORIZONTAL);
@ -425,6 +434,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
sashFormEntries.setWeights(DEFAULT_ENTRIES_SASH_WEIGHTS); sashFormEntries.setWeights(DEFAULT_ENTRIES_SASH_WEIGHTS);
} }
/**
* Create check-box to control whether to show built-in entries or not.
*/
private void createBuiltInsCheckBox() { private void createBuiltInsCheckBox() {
builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.FILL_HORIZONTAL); builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.FILL_HORIZONTAL);
builtInCheckBox.addSelectionListener(new SelectionAdapter() { builtInCheckBox.addSelectionListener(new SelectionAdapter() {
@ -437,6 +449,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
builtInCheckBox.setEnabled(true); builtInCheckBox.setEnabled(true);
} }
/**
* Create check-box to allow disable/enable language settings providers functionality.
*/
private void createEnableProvidersCheckBox() { private void createEnableProvidersCheckBox() {
enableProvidersCheckBox = setupCheck(usercomp, Messages.CDTMainWizardPage_TrySD90, 2, GridData.FILL_HORIZONTAL); enableProvidersCheckBox = setupCheck(usercomp, Messages.CDTMainWizardPage_TrySD90, 2, GridData.FILL_HORIZONTAL);
enableProvidersCheckBox.addSelectionListener(new SelectionAdapter() { enableProvidersCheckBox.addSelectionListener(new SelectionAdapter() {
@ -447,14 +462,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
masterPropertyPage.setLanguageSettingsProvidersEnabled(enabled); masterPropertyPage.setLanguageSettingsProvidersEnabled(enabled);
} }
if (!enabled) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
updateData(getResDesc());
}
}
enableTabControls(enabled); enableTabControls(enabled);
updateStatusLine(); updateStatusLine();
} }
@ -481,8 +488,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// Discourage settings entry table from trying to show all its items at once, see bug 264330 // Discourage settings entry table from trying to show all its items at once, see bug 264330
gd.heightHint =1; gd.heightHint =1;
if (page instanceof Page_LanguageSettingsProviders) { if (page instanceof LanguageSettingsProvidersPage) {
masterPropertyPage = (Page_LanguageSettingsProviders) page; masterPropertyPage = (LanguageSettingsProvidersPage) page;
} }
trackInitialSettings(); trackInitialSettings();
@ -497,6 +504,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
updateData(getResDesc()); updateData(getResDesc());
} }
/**
* Gray out or restore all controls except enabling check-box.
*/
private void enableTabControls(boolean enable) { private void enableTabControls(boolean enable) {
sashFormEntries.setEnabled(enable); sashFormEntries.setEnabled(enable);
treeLanguages.setEnabled(enable); treeLanguages.setEnabled(enable);
@ -508,17 +518,13 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (enable) { if (enable) {
updateTreeForEntries(); updateTreeForEntries();
} else { } else {
disableButtons();
}
}
private void disableButtons() {
buttonSetEnabled(BUTTON_ADD, false); buttonSetEnabled(BUTTON_ADD, false);
buttonSetEnabled(BUTTON_EDIT, false); buttonSetEnabled(BUTTON_EDIT, false);
buttonSetEnabled(BUTTON_DELETE, false); buttonSetEnabled(BUTTON_DELETE, false);
buttonSetEnabled(BUTTON_MOVE_UP, false); buttonSetEnabled(BUTTON_MOVE_UP, false);
buttonSetEnabled(BUTTON_MOVE_DOWN, false); buttonSetEnabled(BUTTON_MOVE_DOWN, false);
} }
}
/** /**
* Updates state for all buttons. Called when table selection changes. * Updates state for all buttons. Called when table selection changes.
@ -579,14 +585,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
boolean isAllowedEditing = provider instanceof ILanguageSettingsEditableProvider boolean isAllowedEditing = provider instanceof ILanguageSettingsEditableProvider
&& LanguageSettingsProviderAssociationManager.isAllowedToEditEntries(provider); && LanguageSettingsProviderAssociationManager.isAllowedToEditEntries(provider);
if (!isAllowedEditing) { if (!isAllowedEditing) {
String msg = "Setting entries for this provider are supplied by the system and are not editable."; status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Entries_Not_Editable);
status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, msg);
} }
} }
if (status == null || status == Status.OK_STATUS) { if (status == null || status == Status.OK_STATUS) {
if (treeLanguages.getItemCount() <= 0) { if (treeLanguages.getItemCount() <= 0) {
String msg = "Cannot determine toolchain languages."; status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages);
status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg);
} }
} }
fStatusLine.setErrorStatus(status); fStatusLine.setErrorStatus(status);
@ -640,6 +644,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return -1; return -1;
} }
/**
* Find TreeItem associated with a provider.
*/
private TreeItem findProviderItem(String id) { private TreeItem findProviderItem(String id) {
TreeItem[] providerItems = treeEntries.getItems(); TreeItem[] providerItems = treeEntries.getItems();
for (TreeItem providerItem : providerItems) { for (TreeItem providerItem : providerItems) {
@ -654,26 +661,31 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return null; return null;
} }
private TreeItem findEntryItem(String id, ICLanguageSettingEntry entry) { /**
* Find TreeItem associated with a provider's entry.
*/
private TreeItem findEntryItem(String providerId, ICLanguageSettingEntry entry) {
TreeItem[] providerItems = treeEntries.getItems(); TreeItem[] providerItems = treeEntries.getItems();
for (TreeItem providerItem : providerItems) { for (TreeItem providerItem : providerItems) {
Object providerItemData = providerItem.getData(); Object providerItemData = providerItem.getData();
if (providerItemData instanceof ILanguageSettingsProvider) { if (providerItemData instanceof ILanguageSettingsProvider) {
ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData; ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData;
if (provider.getId().equals(id)) { if (provider.getId().equals(providerId)) {
TreeItem[] entryItems = providerItem.getItems(); TreeItem[] entryItems = providerItem.getItems();
for (TreeItem entryItem : entryItems) { for (TreeItem entryItem : entryItems) {
Object entryItemData = entryItem.getData(); Object entryItemData = entryItem.getData();
if (entryItemData==entry) if (entryItemData==entry)
return entryItem; return entryItem;
} }
// return providerItem;
} }
} }
} }
return null; return null;
} }
/**
* Select language settings entry item in the tree.
*/
private void selectItem(String providerId, ICLanguageSettingEntry entry) { private void selectItem(String providerId, ICLanguageSettingEntry entry) {
TreeItem providerItem = findProviderItem(providerId); TreeItem providerItem = findProviderItem(providerId);
if (providerItem != null) { if (providerItem != null) {
@ -689,6 +701,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Add language settings entry.
*/
private void addEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry) { private void addEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry) {
if (provider != null && entry != null) { if (provider != null && entry != null) {
String providerId = provider.getId(); String providerId = provider.getId();
@ -705,6 +720,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Save entries into provider considering resource parent.
*/
private void saveEntries(ILanguageSettingsProvider provider, List<ICLanguageSettingEntry> entries) { private void saveEntries(ILanguageSettingsProvider provider, List<ICLanguageSettingEntry> entries) {
if (provider instanceof ILanguageSettingsEditableProvider) { if (provider instanceof ILanguageSettingsEditableProvider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICConfigurationDescription cfgDescription = getConfigurationDescription();
@ -740,6 +758,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return entries; return entries;
} }
/**
* Call dialog to add settings entry.
*/
private void performAdd(ILanguageSettingsProvider selectedProvider) { private void performAdd(ILanguageSettingsProvider selectedProvider) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) { if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICConfigurationDescription cfgDescription = getConfigurationDescription();
@ -748,7 +769,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (addDialog.open()) { if (addDialog.open()) {
ICLanguageSettingEntry settingEntry = addDialog.getEntries()[0]; ICLanguageSettingEntry settingEntry = addDialog.getEntries()[0];
if (settingEntry != null) { if (settingEntry != null) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider); selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
addEntry(selectedProvider, settingEntry); addEntry(selectedProvider, settingEntry);
} }
} }
@ -756,10 +777,10 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
/** /**
* Return provider copy being edited in current session. If the supplied provider is already the edited copy * Return working copy of the provider to edit in current session. If the supplied provider is already
* return it. If not, create a copy to be edited. * the working copy return it. If not, create a copy to be edited.
*/ */
private ILanguageSettingsEditableProvider getEditedCopy(ILanguageSettingsEditableProvider provider) { private ILanguageSettingsEditableProvider getWorkingCopy(ILanguageSettingsEditableProvider provider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId()); List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
if (initialProviders.contains(provider)) { if (initialProviders.contains(provider)) {
@ -771,15 +792,18 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
providers.set(pos, provider); providers.set(pos, provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
CUIPlugin.log("Internal Error: cannot clone provider "+provider.getId(), e); CUIPlugin.log("Internal Error: cannot clone provider "+provider.getId(), e); //$NON-NLS-1$
} }
} else { } else {
CUIPlugin.getDefault().logErrorMessage("Internal Error: cannot find provider "+provider.getId()); CUIPlugin.log("Internal Error: cannot find provider "+provider.getId(), new Exception()); //$NON-NLS-1$
} }
} }
return provider; return provider;
} }
/**
* Call dialog to edit settings entry.
*/
private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) { if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) {
ICConfigurationDescription cfgDecsription = getConfigurationDescription(); ICConfigurationDescription cfgDecsription = getConfigurationDescription();
@ -787,7 +811,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (editDialog.open()) { if (editDialog.open()) {
ICLanguageSettingEntry newEntry = editDialog.getEntries()[0]; ICLanguageSettingEntry newEntry = editDialog.getEntries()[0];
if (newEntry != null) { if (newEntry != null) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider); selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
replaceEntry(selectedProvider, selectedEntry, newEntry); replaceEntry(selectedProvider, selectedEntry, newEntry);
} }
} }
@ -795,6 +819,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Delete provider's entry and update UI.
*/
private void deleteEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry) { private void deleteEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry) {
if (provider != null && entry != null) { if (provider != null && entry != null) {
String providerId = provider.getId(); String providerId = provider.getId();
@ -815,6 +842,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Replace provider's entry and update UI.
*/
private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry, ICLanguageSettingEntry newEntry) { private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry, ICLanguageSettingEntry newEntry) {
if (provider != null && oldEntry != null && newEntry != null) { if (provider != null && oldEntry != null && newEntry != null) {
String providerId = provider.getId(); String providerId = provider.getId();
@ -830,6 +860,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Clear all provider's entries for the given resource and update UI.
*/
private void clearProvider(ILanguageSettingsProvider provider) { private void clearProvider(ILanguageSettingsProvider provider) {
if (provider != null) { if (provider != null) {
String providerId = provider.getId(); String providerId = provider.getId();
@ -842,9 +875,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Clear provider's entries for the given resource or remove one entry depending on selection.
*/
private void performDelete(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { private void performDelete(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) { if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider); selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
if (selectedEntry != null) { if (selectedEntry != null) {
deleteEntry(selectedProvider, selectedEntry); deleteEntry(selectedProvider, selectedEntry);
} else { } else {
@ -853,6 +889,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Move provider's entry up or down.
*/
private void moveEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry, boolean up) { private void moveEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry, boolean up) {
if (provider != null && entry != null) { if (provider != null && entry != null) {
String providerId = provider.getId(); String providerId = provider.getId();
@ -869,16 +908,22 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
} }
/**
* Move provider's entry up.
*/
private void performMoveUp(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { private void performMoveUp(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) { if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider); selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
moveEntry(selectedProvider, selectedEntry, true); moveEntry(selectedProvider, selectedEntry, true);
} }
} }
/**
* Move provider's entry down.
*/
private void performMoveDown(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { private void performMoveDown(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) { if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider); selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
moveEntry(selectedProvider, selectedEntry, false); moveEntry(selectedProvider, selectedEntry, false);
} }
} }
@ -952,6 +997,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
/**
* Change selection of language.
*/
private void selectLanguage(String langId) { private void selectLanguage(String langId) {
currentLanguageId = langId; currentLanguageId = langId;
currentLanguageIdGlobal = currentLanguageId; currentLanguageIdGlobal = currentLanguageId;
@ -965,7 +1013,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
} }
/** /**
* Called when configuration changed Refreshes languages list entries tree. * Update the tab. Called when configuration changes.
*/ */
@Override @Override
public void updateData(ICResourceDescription rcDes) { public void updateData(ICResourceDescription rcDes) {
@ -1003,14 +1051,16 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// we use null for resetting file/folder resource which should be correct in most cases. // we use null for resetting file/folder resource which should be correct in most cases.
// Count that as a feature. // Count that as a feature.
ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) {
return; return;
}
boolean changed = false; boolean changed = false;
IResource rc = getResource(); IResource rc = getResource();
List<ILanguageSettingsProvider> oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); List<ILanguageSettingsProvider> oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(oldProviders.size()); List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(oldProviders.size());
// clear entries for a given resource for all languages where applicable
providers: for (ILanguageSettingsProvider provider : oldProviders) { providers: for (ILanguageSettingsProvider provider : oldProviders) {
ILanguageSettingsEditableProvider providerCopy = null; ILanguageSettingsEditableProvider providerCopy = null;
if (provider instanceof ILanguageSettingsEditableProvider) { if (provider instanceof ILanguageSettingsEditableProvider) {
@ -1024,24 +1074,22 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) {
if (providerCopy == null) { if (providerCopy == null) {
continue providers; continue providers;
} }
}
providerCopy.setSettingEntries(cfgDescription, rc, langId, null); providerCopy.setSettingEntries(cfgDescription, rc, langId, null);
changed = true; changed = true;
} }
} }
} }
} }
} if (providerCopy != null) {
if (providerCopy!=null)
newProviders.add(providerCopy); newProviders.add(providerCopy);
else } else {
newProviders.add(provider); newProviders.add(provider);
} }
}
if (changed) { if (changed) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders);
// updateTreeEntries(); updateTreeForEntries();
// updateData(getResDesc());
List<ILanguageSettingsProvider> tableItems = getProviders(currentLanguageId);
treeEntriesViewer.setInput(tableItems.toArray(new Object[tableItems.size()]));
} }
} }
} }
@ -1068,6 +1116,9 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) {
setLanguageSettingsProvidersFunctionalityEnablement(); setLanguageSettingsProvidersFunctionalityEnablement();
} }
/**
* TODO
*/
private void setLanguageSettingsProvidersFunctionalityEnablement() { private void setLanguageSettingsProvidersFunctionalityEnablement() {
if (page.isForProject() && enableProvidersCheckBox != null) { if (page.isForProject() && enableProvidersCheckBox != null) {
boolean enabled = enableProvidersCheckBox.getSelection(); boolean enabled = enableProvidersCheckBox.getSelection();

View file

@ -17,7 +17,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
@ -30,8 +29,16 @@ import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.ICOptionPage; import org.eclipse.cdt.ui.dialogs.ICOptionPage;
/**
* This class manages extensions of extension point org.eclipse.cdt.core.LanguageSettingsProvider
* which defines appearance and behavior of UI controls for Language Settings Providers.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class LanguageSettingsProviderAssociationManager { public class LanguageSettingsProviderAssociationManager {
public static final String LANGUAGE_SETTINGS_PROVIDER_UI = "LanguageSettingsProviderAssociation"; //$NON-NLS-1$ /** Name of the extension point for contributing language settings provider associations */
private static final String PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID = "LanguageSettingsProviderAssociation"; //$NON-NLS-1$
private static final String ELEM_ID_ASSOCIATION = "id-association"; //$NON-NLS-1$ private static final String ELEM_ID_ASSOCIATION = "id-association"; //$NON-NLS-1$
private static final String ELEM_CLASS_ASSOCIATION = "class-association"; //$NON-NLS-1$ private static final String ELEM_CLASS_ASSOCIATION = "class-association"; //$NON-NLS-1$
@ -42,30 +49,27 @@ public class LanguageSettingsProviderAssociationManager {
private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$ private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$
private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$ private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
private static List<URL> loadedIcons = null; private static boolean isLoaded = false;
private static Map<String, URL> fImagesUrlById = null; private static List<URL> loadedIcons = new ArrayList<URL>();
private static Map<String, URL> fImagesUrlByClass = null; private static Map<String, URL> fImagesUrlById = new HashMap<String, URL>();
private static List<String> fRegirestedIds = null; private static Map<String, URL> fImagesUrlByClass = new HashMap<String, URL>();
private static List<String> fRegisteredClasses = null; private static List<String> fRegirestedIds = new ArrayList<String>();
private static List<String> fRegisteredClasses = new ArrayList<String>();
private static Map<String, Map<String, String>> fAssociationsById = null; private static Map<String, Map<String, String>> fAssociationsById = new HashMap<String, Map<String, String>>();
private static Map<String, Map<String, String>> fAssociationsByClass = null; private static Map<String, Map<String, String>> fAssociationsByClass = new HashMap<String, Map<String, String>>();
/**
* Load extensions into memory maps.
*/
private static void loadExtensions() { private static void loadExtensions() {
if (loadedIcons!=null) { if (isLoaded) {
return; return;
} }
if (loadedIcons==null) loadedIcons = new ArrayList<URL>(); isLoaded = true;
if (fImagesUrlById==null) fImagesUrlById = new HashMap<String, URL>();
if (fImagesUrlByClass==null) fImagesUrlByClass = new HashMap<String, URL>();
if (fRegirestedIds==null) fRegirestedIds = new ArrayList<String>();
if (fRegisteredClasses==null) fRegisteredClasses = new ArrayList<String>();
if (fAssociationsById==null) fAssociationsById = new HashMap<String, Map<String, String>>();
if (fAssociationsByClass==null) fAssociationsByClass = new HashMap<String, Map<String, String>>();
IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, LANGUAGE_SETTINGS_PROVIDER_UI); IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) { if (extension != null) {
IExtension[] extensions = extension.getExtensions(); IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) { for (IExtension ext : extensions) {
@ -79,9 +83,9 @@ public class LanguageSettingsProviderAssociationManager {
fRegirestedIds.add(id); fRegirestedIds.add(id);
Map<String, String> properties = new HashMap<String, String>(); Map<String, String> properties = new HashMap<String, String>();
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE)); putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES)); putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES)); putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
fAssociationsById.put(id, properties); fAssociationsById.put(id, properties);
} else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) { } else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
String className = cfgEl.getAttribute(ATTR_CLASS); String className = cfgEl.getAttribute(ATTR_CLASS);
@ -93,9 +97,9 @@ public class LanguageSettingsProviderAssociationManager {
} }
Map<String, String> properties = new HashMap<String, String>(); Map<String, String> properties = new HashMap<String, String>();
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE)); putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
sensiblePut(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES)); putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
sensiblePut(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES)); putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
fAssociationsByClass.put(className, properties); fAssociationsByClass.put(className, properties);
} }
} }
@ -104,11 +108,17 @@ public class LanguageSettingsProviderAssociationManager {
} }
private static void sensiblePut(Map<String, String> properties, String key, String value) { /**
* Put value into properties ignoring nulls.
*/
private static void putNotEmpty(Map<String, String> properties, String key, String value) {
if (value != null) if (value != null)
properties.put(key, value); properties.put(key, value);
} }
/**
* Find icon URL in its bundle.
*/
private static URL getIconUrl(IConfigurationElement config) { private static URL getIconUrl(IConfigurationElement config) {
URL url = null; URL url = null;
try { try {
@ -116,10 +126,13 @@ public class LanguageSettingsProviderAssociationManager {
if (iconName != null) { if (iconName != null) {
URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$ URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
url = new URL(pluginInstallUrl, iconName); url = new URL(pluginInstallUrl, iconName);
if (loadedIcons.contains(url)) if (loadedIcons.contains(url)) {
return url; return url;
} }
} catch (MalformedURLException exception) {} }
} catch (MalformedURLException e) {
CUIPlugin.log(e);
}
loadedIcons.add(url); loadedIcons.add(url);
if (url != null) { if (url != null) {
@ -129,20 +142,26 @@ public class LanguageSettingsProviderAssociationManager {
return url; return url;
} }
public static URL getImageUrl(String id) { /**
if (fImagesUrlById==null) { * Get image URL for language settings provider with the given ID.
*
* @param providerId - ID of language settings provider.
* @return image URL or {@code null}.
*/
public static URL getImageUrl(String providerId) {
loadExtensions(); loadExtensions();
} return fImagesUrlById.get(providerId);
return fImagesUrlById.get(id);
} }
/**
* Create an Options page for language settings provider with given ID.
*/
private static ICOptionPage createOptionsPageById(String providerId) { private static ICOptionPage createOptionsPageById(String providerId) {
if (fRegirestedIds==null) {
loadExtensions(); loadExtensions();
}
if (fRegirestedIds.contains(providerId)) { if (fRegirestedIds.contains(providerId)) {
IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, LANGUAGE_SETTINGS_PROVIDER_UI); IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) { if (extension != null) {
IExtension[] extensions = extension.getExtensions(); IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) { for (IExtension ext : extensions) {
@ -170,13 +189,15 @@ public class LanguageSettingsProviderAssociationManager {
return null; return null;
} }
/**
* Create an Options page for language settings provider class by its name.
*/
private static ICOptionPage createOptionsPageByClass(String providerClassName) { private static ICOptionPage createOptionsPageByClass(String providerClassName) {
if (fRegisteredClasses==null) {
loadExtensions(); loadExtensions();
}
if (fRegisteredClasses.contains(providerClassName)) { if (fRegisteredClasses.contains(providerClassName)) {
IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, LANGUAGE_SETTINGS_PROVIDER_UI); IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) { if (extension != null) {
IExtension[] extensions = extension.getExtensions(); IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) { for (IExtension ext : extensions) {
@ -208,31 +229,35 @@ public class LanguageSettingsProviderAssociationManager {
* Returns Language Settings Provider image registered for closest superclass * Returns Language Settings Provider image registered for closest superclass
* or interface. * or interface.
* *
* @param clazz - class to find Language Settings Provider image. * @param providerClass - class to find Language Settings Provider image.
* @return image or {@code null} * @return image or {@code null}
*/ */
public static URL getImage(Class<? extends ILanguageSettingsProvider> clazz) { public static URL getImage(Class<? extends ILanguageSettingsProvider> providerClass) {
URL url = null; URL url = null;
outer: for (Class<?> cl=clazz;cl!=null;cl=cl.getSuperclass()) { outer: for (Class<?> c = providerClass; c != null; c = c.getSuperclass()) {
url = getImageURL(cl); url = getImageURL(c);
if (url!=null) if (url != null) {
break; break;
}
// this does not check for superinterfaces, feel free to implement as needed // this does not check for super-interfaces, feel free to implement as needed
for (Class<?> in : cl.getInterfaces()) { for (Class<?> i : c.getInterfaces()) {
url = getImageURL(in); url = getImageURL(i);
if (url!=null) if (url != null) {
break outer; break outer;
} }
} }
}
return url; return url;
} }
/**
* Return image URL registered for the given class.
*/
private static URL getImageURL(Class<?> clazz) { private static URL getImageURL(Class<?> clazz) {
String className = clazz.getCanonicalName(); String className = clazz.getCanonicalName();
Set<Entry<String, URL>> entrySet = fImagesUrlByClass.entrySet(); for (Entry<String, URL> entry : fImagesUrlByClass.entrySet()) {
for (Entry<String, URL> entry : entrySet) {
if (entry.getKey().equals(className)) { if (entry.getKey().equals(className)) {
return entry.getValue(); return entry.getValue();
} }
@ -241,9 +266,10 @@ public class LanguageSettingsProviderAssociationManager {
} }
/** /**
* Returns Language Settings Provider image registered for closest superclass. * Returns language settings provider Options page registered for closest superclass.
* @param provider TODO *
* @return image or {@code null} * @param provider - instance of provider to create Options page for.
* @return image or {@code null}.
*/ */
public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) { public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) {
String id = provider.getId(); String id = provider.getId();
@ -253,24 +279,29 @@ public class LanguageSettingsProviderAssociationManager {
} }
Class<? extends ILanguageSettingsProvider> clazz = provider.getClass(); Class<? extends ILanguageSettingsProvider> clazz = provider.getClass();
outer: for (Class<?> cl=clazz;cl!=null;cl=cl.getSuperclass()) { outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) {
optionsPage = createOptionsPageByClass(cl); optionsPage = createOptionsPageByClass(c);
if (optionsPage!=null) if (optionsPage != null) {
break; break;
}
// this does not check for superinterfaces, feel free to implement as needed // this does not check for super-interfaces, feel free to implement as needed
for (Class<?> in : cl.getInterfaces()) { for (Class<?> i : c.getInterfaces()) {
optionsPage = createOptionsPageByClass(in); optionsPage = createOptionsPageByClass(i);
if (optionsPage!=null) if (optionsPage != null) {
break outer; break outer;
} }
} }
}
return optionsPage; return optionsPage;
} }
private static ICOptionPage createOptionsPageByClass(Class<?> c) { /**
* Create an Options page for language settings provider class.
*/
private static ICOptionPage createOptionsPageByClass(Class<?> clazz) {
ICOptionPage optionsPage = null; ICOptionPage optionsPage = null;
String className = c.getCanonicalName(); String className = clazz.getCanonicalName();
if (fRegisteredClasses.contains(className)) { if (fRegisteredClasses.contains(className)) {
optionsPage = createOptionsPageByClass(className); optionsPage = createOptionsPageByClass(className);
} }
@ -278,9 +309,7 @@ public class LanguageSettingsProviderAssociationManager {
} }
/** /**
* Returns TODO for id or closest superclass. * Returns value of the attribute of the provider by id or closest superclass.
* @param provider TODO
* @return TODO
*/ */
private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) { private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) {
loadExtensions(); loadExtensions();
@ -292,16 +321,16 @@ public class LanguageSettingsProviderAssociationManager {
return Boolean.parseBoolean(properties.get(attr)); return Boolean.parseBoolean(properties.get(attr));
} }
for (Class<?> clazz=provider.getClass();clazz!=null;clazz=clazz.getSuperclass()) { for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) {
String className = clazz.getCanonicalName(); String className = c.getCanonicalName();
properties = fAssociationsByClass.get(className); properties = fAssociationsByClass.get(className);
if (properties != null) { if (properties != null) {
return Boolean.parseBoolean(properties.get(attr)); return Boolean.parseBoolean(properties.get(attr));
} }
// this does not check for superinterfaces, feel free to implement as needed // this does not check for superinterfaces, feel free to implement as needed
for (Class<?> iface : clazz.getInterfaces()) { for (Class<?> i : c.getInterfaces()) {
String interfaceName = iface.getCanonicalName(); String interfaceName = i.getCanonicalName();
properties = fAssociationsByClass.get(interfaceName); properties = fAssociationsByClass.get(interfaceName);
if (properties != null) { if (properties != null) {
return Boolean.parseBoolean(properties.get(attr)); return Boolean.parseBoolean(properties.get(attr));
@ -312,21 +341,21 @@ public class LanguageSettingsProviderAssociationManager {
} }
/** /**
* Returns TODO for id or closest superclass. * Check if the user is allowed to edit language settings provider entries in UI.
* @param provider TODO * @param provider - language settings provider.
* @return TODO * @return {@code true} if editing is allowed or {@code false} if not.
*/
public static boolean isAllowedToClear(ILanguageSettingsProvider provider) {
return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES);
}
/**
* Returns TODO for id or closest superclass.
* @param provider TODO
* @return TODO
*/ */
public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) { public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) {
return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES); return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES);
} }
/**
* Check if the user is allowed to clear language settings provider entries in UI.
* @param provider - language settings provider.
* @return {@code true} if clearing is allowed or {@code false} if not.
*/
public static boolean isAllowedToClear(ILanguageSettingsProvider provider) {
return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Andrew Gvozdev and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,20 +8,19 @@
* Contributors: * Contributors:
* Andrew Gvozdev - Initial API and implementation * Andrew Gvozdev - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers; package org.eclipse.cdt.internal.ui.language.settings.providers;
import java.net.URL; import java.net.URL;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.internal.ui.newui.Messages;
/** /**
* Label provider for language settings providers. * Label provider for language settings providers.
@ -64,31 +63,7 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
* Returns keys for image overlays. Returning {@code null} is not allowed. * Returns keys for image overlays. Returning {@code null} is not allowed.
*/ */
protected String[] getOverlayKeys(ILanguageSettingsProvider provider) { protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
String[] overlayKeys = new String[5]; return new String[5];
if (isDebugging()) { // TODO temporary for debugging
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider instanceof LanguageSettingsSerializableProvider) {
if (((LanguageSettingsSerializableProvider)rawProvider).isEmpty()) {
overlayKeys[IDecoration.BOTTOM_RIGHT] = CDTSharedImages.IMG_OVR_EMPTY;
}
}
if (LanguageSettingsManager.isWorkspaceProvider(provider)) {
overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_GLOBAL;
// overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_REFERENCE;
// overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT;
// overlayKeys[IDecoration.BOTTOM_RIGHT] = CDTSharedImages.IMG_OVR_LINK;
} else {
// overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_CONFIGURATION;
// overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_INDEXED;
// overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_CONTEXT;
// overlayKeys[IDecoration.TOP_LEFT] = CDTSharedImages.IMG_OVR_PROJECT;
}
}
return overlayKeys;
} }
@Override @Override
@ -109,22 +84,13 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
String name = provider.getName(); String name = provider.getName();
if (name != null) { if (name != null) {
if (LanguageSettingsManager.isWorkspaceProvider(provider)) { if (LanguageSettingsManager.isWorkspaceProvider(provider)) {
name = name + " [ Shared ]"; name = name + Messages.LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
} }
return name; return name;
} }
String id = provider.getId(); return NLS.bind(Messages.GeneralMessages_NonAccessibleID, provider.getId());
return "[ Not accessible id="+id+" ]";
} }
return OOPS; return OOPS;
} }
/**
* Temporary method for debugging only
*/
@Deprecated
private boolean isDebugging() {
return false;
// return true;
}
} }

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others. * Copyright (c) 2010, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - initial API and implementation * Andrew Gvozdev - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers; package org.eclipse.cdt.internal.ui.language.settings.providers;
@ -15,10 +15,12 @@ import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.ICPropertyTab; import org.eclipse.cdt.ui.newui.ICPropertyTab;
/** /**
* Property page for language settings providers tabs.
*
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class Page_LanguageSettingsProviders extends AbstractPage { public class LanguageSettingsProvidersPage extends AbstractPage {
private Boolean isLanguageSettingsProvidersEnabled = null; private Boolean isLanguageSettingsProvidersEnabled = null;
@Override @Override
@ -26,6 +28,11 @@ public class Page_LanguageSettingsProviders extends AbstractPage {
return false; return false;
} }
/**
* Check if language settings providers functionality is enabled for a current project.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public boolean isLanguageSettingsProvidersEnabled() { public boolean isLanguageSettingsProvidersEnabled() {
if (isLanguageSettingsProvidersEnabled == null) { if (isLanguageSettingsProvidersEnabled == null) {
isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(getProject()); isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(getProject());
@ -33,6 +40,11 @@ public class Page_LanguageSettingsProviders extends AbstractPage {
return isLanguageSettingsProvidersEnabled; return isLanguageSettingsProvidersEnabled;
} }
/**
* Enable or disable language settings providers functionality for a current project.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public void setLanguageSettingsProvidersEnabled(boolean enable) { public void setLanguageSettingsProvidersEnabled(boolean enable) {
isLanguageSettingsProvidersEnabled = enable; isLanguageSettingsProvidersEnabled = enable;
forEach(ICPropertyTab.UPDATE,getResDesc()); forEach(ICPropertyTab.UPDATE,getResDesc());

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.ui.newui; package org.eclipse.cdt.internal.ui.newui;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -23,6 +24,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.settings.model.ACPathEntry; import org.eclipse.cdt.core.settings.model.ACPathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CDTSharedImages;
@ -32,15 +34,9 @@ import org.eclipse.cdt.ui.CUIPlugin;
* Helper class to provide unified images for {@link ICLanguageSettingEntry}. * Helper class to provide unified images for {@link ICLanguageSettingEntry}.
*/ */
public class LanguageSettingsImages { public class LanguageSettingsImages {
// AG FIXME - replace usage with version taking cfgDescription
@Deprecated
public static Image getImage(int kind, int flags, boolean isProjectRelative) { public static Image getImage(int kind, int flags, boolean isProjectRelative) {
String imageKey = getImageKey(kind, flags, isProjectRelative); String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey != null) { if (imageKey != null) {
// String overlayKey = getErrorOverlayKey(kind, flags, isProjectRelative);
// if (overlayKey!=null) {
// return getOverlaidImage(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
// }
return CDTSharedImages.getImage(imageKey); return CDTSharedImages.getImage(imageKey);
} }
return null; return null;
@ -48,17 +44,26 @@ public class LanguageSettingsImages {
/** /**
* Returns image for the given entry from internally managed repository including * Returns image for the given entry from internally managed repository including
* necessary overlays. This method is shortcut for {@link #getImage(ICLanguageSettingEntry, String, ICConfigurationDescription)} * necessary overlays for given configuration description.
* when no project is available.
* *
* @param entry - language settings entry to get an image for. * @param entry - language settings entry to get an image for.
* @param cfgDescription - configuration description of the entry.
* @return the image for the entry with appropriate overlays. * @return the image for the entry with appropriate overlays.
*
* AG FIXME - replace usage with version taking cfgDescription
*/ */
@Deprecated public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
public static Image getImage(ICLanguageSettingEntry entry) { String projectName = null;
return getImage(entry, null, null);
if (cfgDescription != null) {
ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
if (prjDescription != null) {
IProject project = prjDescription.getProject();
if (project != null) {
projectName = project.getName();
}
}
}
return getImage(entry, projectName, cfgDescription);
} }
/** /**
@ -118,7 +123,7 @@ public class LanguageSettingsImages {
* @param cfgDescription - configuration description of the entry. * @param cfgDescription - configuration description of the entry.
* @return the image for the entry with appropriate overlays. * @return the image for the entry with appropriate overlays.
*/ */
public static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) { private static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
int kind = entry.getKind(); int kind = entry.getKind();
int flags = entry.getFlags(); int flags = entry.getFlags();
boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0; boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;

View file

@ -139,7 +139,6 @@ public class Messages extends NLS {
public static String EnvironmentTab_8; public static String EnvironmentTab_8;
public static String EnvironmentTab_9; public static String EnvironmentTab_9;
public static String ErrorParsTab_error_IllegalCharacter; public static String ErrorParsTab_error_IllegalCharacter;
public static String ErrorParsTab_error_NonAccessibleID;
public static String ErrorParsTab_error_NonEmptyName; public static String ErrorParsTab_error_NonEmptyName;
public static String ErrorParsTab_error_NonUniqueID; public static String ErrorParsTab_error_NonUniqueID;
public static String ErrorParsTab_error_OnApplyingSettings; public static String ErrorParsTab_error_OnApplyingSettings;
@ -175,6 +174,8 @@ public class Messages extends NLS {
public static String FileListControl_editdialog_title; public static String FileListControl_editdialog_title;
public static String FileListControl_movedown; public static String FileListControl_movedown;
public static String FileListControl_moveup; public static String FileListControl_moveup;
public static String GeneralMessages_InternalError_ReportLogToCdtTeam;
public static String GeneralMessages_NonAccessibleID;
public static String IncludeDialog_0; public static String IncludeDialog_0;
public static String IncludeDialog_1; public static String IncludeDialog_1;
public static String IncludeDialog_2; public static String IncludeDialog_2;
@ -187,18 +188,42 @@ public class Messages extends NLS {
public static String IncludeTab_2; public static String IncludeTab_2;
public static String IncludeTab_export; public static String IncludeTab_export;
public static String IncludeTab_import; public static String IncludeTab_import;
public static String LanguageSettingEntryDialog_Add;
public static String LanguageSettingEntryDialog_BuiltInFlag;
public static String LanguageSettingEntryDialog_Directory;
public static String LanguageSettingEntryDialog_File;
public static String LanguageSettingEntryDialog_Filesystem;
public static String LanguageSettingEntryDialog_FrameworkFolder;
public static String LanguageSettingEntryDialog_IncludeDirectory;
public static String LanguageSettingEntryDialog_IncludeFile;
public static String LanguageSettingEntryDialog_Library;
public static String LanguageSettingEntryDialog_LibraryPath;
public static String LanguageSettingEntryDialog_Name;
public static String LanguageSettingEntryDialog_Path;
public static String LanguageSettingEntryDialog_PreporocessorMacro;
public static String LanguageSettingEntryDialog_PreprocessorMacroFile;
public static String LanguageSettingEntryDialog_ProjectRelative;
public static String LanguageSettingEntryDialog_SelectKind;
public static String LanguageSettingEntryDialog_Value;
public static String LanguageSettingEntryDialog_WorkspacePath;
public static String LanguageSettingsEntriesTab_Cannot_Determine_Languages;
public static String LanguageSettingsEntriesTab_Entries_Not_Editable;
public static String LanguageSettingsImages_FileDoesNotExist; public static String LanguageSettingsImages_FileDoesNotExist;
public static String LanguageSettingsImages_FolderDoesNotExist; public static String LanguageSettingsImages_FolderDoesNotExist;
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended; public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
public static String LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
public static String LanguageSettingsProviderTab_AreYouSureToResetProviders; public static String LanguageSettingsProviderTab_AreYouSureToResetProviders;
public static String LanguageSettingsProviderTab_Clear; public static String LanguageSettingsProviderTab_Clear;
public static String LanguageSettingsProviderTab_Configure; public static String LanguageSettingsProviderTab_LanguageSettingsProvidersOptions;
public static String LanguageSettingsProviderTab_ErrorPerformingDefaults; public static String LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab;
public static String LanguageSettingsProviderTab_ProviderOptions; public static String LanguageSettingsProviderTab_ProviderOptions;
public static String LanguageSettingsProviderTab_Reset;
public static String LanguageSettingsProviderTab_SettingEntries; public static String LanguageSettingsProviderTab_SettingEntries;
public static String LanguageSettingsProviderTab_SettingEntriesTooltip; public static String LanguageSettingsProviderTab_SettingEntriesTooltip;
public static String LanguageSettingsProviderTab_ShowEntries; public static String LanguageSettingsProviderTab_ShareProviders;
public static String LanguageSettingsProviderTab_StoreEntriesInsideProject;
public static String LanguageSettingsProviderTab_TitleResetProviders; public static String LanguageSettingsProviderTab_TitleResetProviders;
public static String LanguageSettingsProviderTab_WorkspaceSettings;
public static String LanguagesTab_0; public static String LanguagesTab_0;
public static String LanguagesTab_1; public static String LanguagesTab_1;
public static String LibraryPathTab_1; public static String LibraryPathTab_1;

View file

@ -166,18 +166,42 @@ IncludeDialog_0=Directory:
IncludeDialog_1=File: IncludeDialog_1=File:
IncludeDialog_2=Add to all configurations IncludeDialog_2=Add to all configurations
IncludeDialog_3=Add to all languages IncludeDialog_3=Add to all languages
LanguageSettingEntryDialog_Add=Add
LanguageSettingEntryDialog_BuiltInFlag=Treat as Built-In (Ignore during build)
LanguageSettingEntryDialog_Directory=Dir:
LanguageSettingEntryDialog_File=File:
LanguageSettingEntryDialog_Filesystem=Filesystem
LanguageSettingEntryDialog_FrameworkFolder=Framework folder (Mac only)
LanguageSettingEntryDialog_IncludeDirectory=Include Directory
LanguageSettingEntryDialog_IncludeFile=Include File
LanguageSettingEntryDialog_Library=Library
LanguageSettingEntryDialog_LibraryPath=Library Path
LanguageSettingEntryDialog_Name=Name:
LanguageSettingEntryDialog_Path=Path:
LanguageSettingEntryDialog_PreporocessorMacro=Preprocessor Macro
LanguageSettingEntryDialog_PreprocessorMacroFile=Preprocessor Macros File
LanguageSettingEntryDialog_ProjectRelative=Project-Relative
LanguageSettingEntryDialog_SelectKind=Select Kind:
LanguageSettingEntryDialog_Value=Value:
LanguageSettingEntryDialog_WorkspacePath=Workspace Path
LanguageSettingsEntriesTab_Cannot_Determine_Languages=Cannot determine toolchain languages.
LanguageSettingsEntriesTab_Entries_Not_Editable=Setting entries for this provider are supplied by the system and are not editable.
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible. LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible. LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects. LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
LanguageSettingsProvidersLabelProvider_TextDecorator_Shared=\ \ \ [ Shared ]
LanguageSettingsProviderTab_AreYouSureToResetProviders=Are you sure you want to reset all customized language settings providers?\nPlease note that providers may regain entries on their own schedule. LanguageSettingsProviderTab_AreYouSureToResetProviders=Are you sure you want to reset all customized language settings providers?\nPlease note that providers may regain entries on their own schedule.
LanguageSettingsProviderTab_Clear=Clear Entries LanguageSettingsProviderTab_Clear=Clear Entries
LanguageSettingsProviderTab_Configure=Configure LanguageSettingsProviderTab_LanguageSettingsProvidersOptions=Language Settings Provider Options
LanguageSettingsProviderTab_ErrorPerformingDefaults=Error restoring defaults for language settings providers LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab=Options of global providers below can be changed in {0}, Discovery Tab.
LanguageSettingsProviderTab_Reset=Reset
LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
LanguageSettingsProviderTab_SettingEntries=Setting Entries LanguageSettingsProviderTab_SettingEntries=Setting Entries
LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries
LanguageSettingsProviderTab_ShowEntries=Show Entries LanguageSettingsProviderTab_ShareProviders=Share setting entries between projects (global provider)
LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project miration)
LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers
LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings
LanguagesTab_0=Content type LanguagesTab_0=Content type
LanguagesTab_1=Language LanguagesTab_1=Language
LibraryPathTab_1=Add... LibraryPathTab_1=Add...
@ -216,7 +240,6 @@ ErrorParsTab_error_NonEmptyName=Specify non empty name
ErrorParsTab_error_NonUniqueID=Error parser ID is not unique, specify different name ErrorParsTab_error_NonUniqueID=Error parser ID is not unique, specify different name
ErrorParsTab_error_OnApplyingSettings=Error applying Error Parser Tab settings ErrorParsTab_error_OnApplyingSettings=Error applying Error Parser Tab settings
ErrorParsTab_error_OnRestoring=Error restoring default Error Parser Tab settings ErrorParsTab_error_OnRestoring=Error restoring default Error Parser Tab settings
ErrorParsTab_error_NonAccessibleID=[ Not accessible id={0} ]
ErrorParsTab_error_IllegalCharacter=Special character ''{0}'' is not allowed ErrorParsTab_error_IllegalCharacter=Special character ''{0}'' is not allowed
ErrorParsTab_label_EnterName=Enter name of new error parser: ErrorParsTab_label_EnterName=Enter name of new error parser:
ErrorParsTab_label_DefaultRegexErrorParserName=Regex Error Parser ErrorParsTab_label_DefaultRegexErrorParserName=Regex Error Parser
@ -284,6 +307,8 @@ CDTMainWizardPage_1=Project category is selected. Expand the category and select
CDTMainWizardPage_TrySD90=I want to try new upcoming version of Scanner Discovery in CDT 9.0 (sd90 v.0.9.0) CDTMainWizardPage_TrySD90=I want to try new upcoming version of Scanner Discovery in CDT 9.0 (sd90 v.0.9.0)
CProjectWizard_0=Add C Project Nature CProjectWizard_0=Add C Project Nature
CCProjectWizard_0=Add CC Project Nature CCProjectWizard_0=Add CC Project Nature
GeneralMessages_InternalError_ReportLogToCdtTeam=Internal error happened, report application log to CDT team.
GeneralMessages_NonAccessibleID=[ Not accessible id={0} ]
WorkingSetConfigAction_21=Building project WorkingSetConfigAction_21=Building project
WorkingSetConfigAction_22=Build error WorkingSetConfigAction_22=Build error
IncludeTab_export=Export Settings... IncludeTab_export=Export Settings...

View file

@ -19,7 +19,6 @@ import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IFontProvider; import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
@ -730,8 +729,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
public Image getColumnImage(Object element, int columnIndex) { public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) { if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
ICConfigurationDescription cfg = getResDesc().getConfiguration(); ICConfigurationDescription cfg = getResDesc().getConfiguration();
IProject project = cfg.getProjectDescription().getProject(); return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfg);
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName(), cfg);
} }
return null; return null;
} }

View file

@ -166,7 +166,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
return name; return name;
} }
} }
return NLS.bind(Messages.ErrorParsTab_error_NonAccessibleID, id); return NLS.bind(Messages.GeneralMessages_NonAccessibleID, id);
} }
return OOPS; return OOPS;
} }