1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +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.LanguageSettingsManager;
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.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert;
@ -37,25 +36,17 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* Options page for TODO
*
* Options page for {@link AbstractBuiltinSpecsDetector}.
*/
public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button allocateConsoleCheckBox;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled();
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.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);
}

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.LanguageSettingsManager;
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.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert;
@ -43,9 +42,6 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button runOnceRadioButton;
private Button runEveryBuildRadioButton;
private Button expandRelativePathCheckBox;
private Button scopeProjectRadioButton;
@ -53,14 +49,8 @@ public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSetti
private Button scopeFileRadioButton;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled();
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.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);
}

View file

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

View file

@ -3372,7 +3372,7 @@
<page
name="Preprocessor Include Paths, Macros etc."
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">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IResource">
@ -4337,7 +4337,7 @@
name="Entries"
weight="010"
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"/>
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab"
@ -4345,7 +4345,7 @@
name="Providers"
weight="020"
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"/>
</extension>
<extension

View file

@ -1,12 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- 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>
<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>
<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>
</annotation>
@ -15,6 +15,9 @@
<appInfo>
<meta.element />
</appInfo>
<documentation>
This extension point is used to define appearance and behavior of Language Settings Providers in user interface.
</documentation>
</annotation>
<complexType>
<sequence>
@ -31,14 +34,14 @@
<attribute name="id" type="string">
<annotation>
<documentation>
ID of the extension point, not used
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
Name of the extension point, not used
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
@ -49,18 +52,23 @@
</element>
<element name="id-association">
<annotation>
<documentation>
The definition of UI elements associated with ID of language settings provider.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
ID of language settings provider for which appearance is being defined.
</documentation>
</annotation>
</attribute>
<attribute name="icon" type="string">
<annotation>
<documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation>
<appInfo>
<meta.attribute kind="resource"/>
@ -70,7 +78,7 @@
<attribute name="page" type="string">
<annotation>
<documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
@ -80,14 +88,14 @@
<attribute name="ui-edit-entries" type="boolean">
<annotation>
<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>
</annotation>
</attribute>
@ -95,11 +103,16 @@
</element>
<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>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
Class of language settings provider for which appearance is being defined.
</documentation>
<appInfo>
<meta.attribute kind="java"/>
@ -109,7 +122,7 @@
<attribute name="icon" type="string">
<annotation>
<documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation>
<appInfo>
<meta.attribute kind="resource"/>
@ -119,24 +132,24 @@
<attribute name="page" type="string">
<annotation>
<documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
</appInfo>
</annotation>
</attribute>
<attribute name="ui-clear-entries" type="boolean">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="ui-edit-entries" type="boolean">
<annotation>
<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>
</annotation>
</attribute>
@ -148,7 +161,7 @@
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
CDT 8.1
</documentation>
</annotation>
@ -157,7 +170,7 @@
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
For an example see definition for org.eclipse.cdt.ui.UserLanguageSettingsProvider.
</documentation>
</annotation>
@ -170,14 +183,18 @@
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
<meta.section type="copyright"/>
</appInfo>
<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>
</annotation>
</schema>

View file

@ -12,10 +12,19 @@ package org.eclipse.cdt.internal.ui.language.settings.providers;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
/**
* Abstract class to implement language settings providers Options page.
*/
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
protected LanguageSettingsProviderTab providerTab;
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) {
this.providerTab = providerTab;
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
* 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
*
* Contributors:
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
@ -52,6 +52,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private boolean clearValue;
private int kind;
private Composite compositeArea;
private Label iconComboKind;
private ImageCombo comboKind;
private ImageCombo comboPathCategory;
@ -70,7 +71,6 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private Button buttonOk;
private Button buttonCancel;
private static final int COMBO_INDEX_INCLUDE_PATH = 0;
private static final int COMBO_INDEX_MACRO = 1;
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;
final private String [] comboKindItems = {
"Include Directory",
"Preprocessor Macro",
"Include File",
"Preprocessor Macros File",
"Library Path",
"Library",
Messages.LanguageSettingEntryDialog_IncludeDirectory,
Messages.LanguageSettingEntryDialog_PreporocessorMacro,
Messages.LanguageSettingEntryDialog_IncludeFile,
Messages.LanguageSettingEntryDialog_PreprocessorMacroFile,
Messages.LanguageSettingEntryDialog_LibraryPath,
Messages.LanguageSettingEntryDialog_Library,
};
final private Image[] comboKindImages = {
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;
final private String [] pathCategories = {
"Project-Relative",
"Workspace Path",
"Filesystem",
Messages.LanguageSettingEntryDialog_ProjectRelative,
Messages.LanguageSettingEntryDialog_WorkspacePath,
Messages.LanguageSettingEntryDialog_Filesystem,
};
final private Image[] pathCategoryImages = {
CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT),
@ -110,13 +110,11 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM),
};
private ICLanguageSettingEntry[] entries;
private Composite comp1;
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, int kind) {
super(parent, "");
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = null;
@ -129,7 +127,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
* where provided entry is used as a template.
*/
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry, boolean clearValue) {
super(parent, "");
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = entry;
@ -199,26 +197,26 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
parent.setLayout(new GridLayout(4, false));
GridData gd;
// Composite comp1
comp1 = new Composite (parent, SWT.NONE);
// Composite for the dialog area
compositeArea = new Composite (parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 7;
comp1.setLayoutData(gd);
comp1.setLayout(new GridLayout(7, false));
compositeArea.setLayoutData(gd);
compositeArea.setLayout(new GridLayout(7, false));
// Icon for kind
iconComboKind = new Label (comp1, SWT.NONE);
iconComboKind = new Label (compositeArea, SWT.NONE);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.RIGHT;
iconComboKind.setLayoutData(gd);
iconComboKind.setText("Select Kind:");
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
int kindToComboIndex = kindToComboIndex(kind);
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
// 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++) {
comboKind.add(comboKindItems[i], comboKindImages[i]);
}
@ -238,24 +236,22 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
});
comboKind.setEnabled(clearValue);
//
// 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.verticalAlignment = SWT.TOP;
gd.widthHint = 15;
comboPathCategoryIcon.setLayoutData(gd);
comboPathCategoryIcon.setText("");
comboPathCategoryIcon.setText(""); //$NON-NLS-1$
// 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++) {
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
}
int pcindex = COMBO_PATH_INDEX_PROJECT;
if (entry!=null) {
if ( (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
if (entry != null) {
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
} else {
if (entry.getName().startsWith(SLASH)) {
@ -286,13 +282,13 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
});
// Dir/File/Name label
labelInput = new Label(comp1, SWT.NONE);
labelInput.setText("Dir:");
labelInput = new Label(compositeArea, SWT.NONE);
labelInput.setText(Messages.LanguageSettingEntryDialog_Directory);
gd = new GridData();
labelInput.setLayoutData(gd);
// Dir/File/Name input
inputName = new Text(comp1, SWT.SINGLE | SWT.BORDER);
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) {
inputName.setText(entry.getName());
}
@ -310,14 +306,14 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
inputName.setSelection(0, inputName.getText().length());
// Value label
checkBoxValue = new Label(comp1, SWT.NONE);
checkBoxValue.setText("Value:");
checkBoxValue = new Label(compositeArea, SWT.NONE);
checkBoxValue.setText(Messages.LanguageSettingEntryDialog_Value);
gd = new GridData();
checkBoxValue.setLayoutData(gd);
// Path button
buttonBrowse = new Button(comp1, SWT.PUSH);
buttonBrowse.setText("...");
buttonBrowse = new Button(compositeArea, SWT.PUSH);
buttonBrowse.setText("..."); //$NON-NLS-1$
buttonBrowse.setImage(pathCategoryImages[0]);
buttonBrowse.setLayoutData(new GridData());
buttonBrowse.addSelectionListener(new SelectionAdapter() {
@ -328,7 +324,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
});
// Variables button
buttonVars = new Button(comp1, SWT.PUSH);
buttonVars = new Button(compositeArea, SWT.PUSH);
buttonVars.setText(AbstractCPropertyTab.VARIABLESBUTTON_NAME);
buttonVars.setLayoutData(new GridData());
buttonVars.addSelectionListener(new SelectionAdapter() {
@ -340,15 +336,15 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Value input. Located after the other controls to get sufficient width
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
inputValue = new Text(comp1, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) {
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry != null && !clearValue) {
inputValue.setText(entry.getValue());
}
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
gd.widthHint = comboPathWidth;
inputValue.setLayoutData(gd);
if (entry!=null && kind==ICSettingEntry.MACRO && !clearValue) {
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) {
inputValue.setFocus();
inputValue.setSelection(0, inputValue.getText().length());
}
@ -363,18 +359,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Built-In"
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);
gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxBuiltIn.setLayoutData(gd);
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@ -383,18 +377,16 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
// Checkbox "Framework"
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);
gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@ -469,7 +461,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private void setButtons() {
int kindSelectionIndex = comboKind.getSelectionIndex();
boolean isMacroSelected = kindSelectionIndex==COMBO_INDEX_MACRO;
boolean isMacroSelected = (kindSelectionIndex == COMBO_INDEX_MACRO);
comboPathCategory.setVisible(!isMacroSelected);
buttonBrowse.setVisible(!isMacroSelected);
buttonVars.setVisible(!isMacroSelected);
@ -485,27 +477,27 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
switch (kindSelectionIndex) {
case COMBO_INDEX_INCLUDE_PATH:
case COMBO_INDEX_LIBRARY_PATH:
labelInput.setText("Path:");
labelInput.setText(Messages.LanguageSettingEntryDialog_Path);
break;
case COMBO_INDEX_INCLUDE_FILE:
case COMBO_INDEX_MACRO_FILE:
case COMBO_INDEX_LIBRARY_FILE:
labelInput.setText("File:");
labelInput.setText(Messages.LanguageSettingEntryDialog_File);
break;
case COMBO_INDEX_MACRO:
default:
labelInput.setText("Name:");
labelInput.setText(Messages.LanguageSettingEntryDialog_Name);
}
inputValue.setEnabled(isMacroSelected);
int indexPathKind = comboPathCategory.getSelectionIndex();
boolean isProjectSelected = indexPathKind==COMBO_PATH_INDEX_PROJECT;
boolean isWorkspaceSelected = indexPathKind==COMBO_PATH_INDEX_WORKSPACE;
boolean isFilesystemSelected = indexPathKind==COMBO_PATH_INDEX_FILESYSTEM;
boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
String path = inputName.getText();
if (path.trim().length()==0) {
if (path.trim().length() == 0) {
buttonOk.setEnabled(false);
} else {
buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
@ -514,12 +506,12 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
buttonVars.setEnabled(isFilesystemSelected);
comp1.layout(true);
compositeArea.layout(true);
}
@Override
public void buttonPressed(SelectionEvent e) {
String s=null;
String str = null;
if (e.widget.equals(buttonOk)) {
String name = inputName.getText();
text1 = name;
@ -586,39 +578,39 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
if (isDirectory) {
switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE:
s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, inputName.getText());
str = AbstractCPropertyTab.getWorkspaceDirDialog(shell, inputName.getText());
break;
case COMBO_PATH_INDEX_PROJECT:
s = AbstractCPropertyTab.getProjectDirDialog(shell, inputName.getText(), project);
str = AbstractCPropertyTab.getProjectDirDialog(shell, inputName.getText(), project);
break;
case COMBO_PATH_INDEX_FILESYSTEM:
s = AbstractCPropertyTab.getFileSystemDirDialog(shell, inputName.getText());
str = AbstractCPropertyTab.getFileSystemDirDialog(shell, inputName.getText());
break;
}
} else if (isFile) {
switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE:
s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, inputName.getText());
str = AbstractCPropertyTab.getWorkspaceFileDialog(shell, inputName.getText());
break;
case COMBO_PATH_INDEX_PROJECT:
s = AbstractCPropertyTab.getProjectFileDialog(shell, inputName.getText(), project);
str = AbstractCPropertyTab.getProjectFileDialog(shell, inputName.getText(), project);
break;
case COMBO_PATH_INDEX_FILESYSTEM:
s = AbstractCPropertyTab.getFileSystemFileDialog(shell, inputName.getText());
str = AbstractCPropertyTab.getFileSystemFileDialog(shell, inputName.getText());
break;
}
}
if (s != null) {
s = strip_wsp(s);
if (comboPathCategory.getSelectionIndex()==COMBO_PATH_INDEX_PROJECT && s.startsWith(SLASH+project.getName()+SLASH)) {
s=s.substring(project.getName().length()+2);
if (str != null) {
str = strip_wsp(str);
if (comboPathCategory.getSelectionIndex()==COMBO_PATH_INDEX_PROJECT && str.startsWith(SLASH+project.getName()+SLASH)) {
str=str.substring(project.getName().length()+2);
}
inputName.setText(s);
inputName.setText(str);
}
} else if (e.widget.equals(buttonVars)) {
s = AbstractCPropertyTab.getVariableDialog(shell, cfgDescription);
if (s != null) inputName.insert(s);
str = AbstractCPropertyTab.getVariableDialog(shell, cfgDescription);
if (str != null) inputName.insert(str);
}
}
@ -629,7 +621,7 @@ public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private void updateImages() {
int indexEntryKind = comboKind.getSelectionIndex();
int indexPathKind = comboPathCategory.getSelectionIndex();
shell.setText("Add " + comboKindItems[indexEntryKind]);
shell.setText(Messages.LanguageSettingEntryDialog_Add + comboKindItems[indexEntryKind]);
int kind = comboIndexToKind(indexEntryKind);
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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,7 +8,6 @@
* Contributors:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
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.StatusMessageLine;
/**
* This tab presents language settings entries categorized by language
* settings providers.
@ -79,14 +77,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private Tree treeLanguages;
private Tree treeEntries;
private TreeViewer treeEntriesViewer;
private static String currentLanguageIdGlobal = null;
private String currentLanguageId = null;
private static String currentLanguageIdGlobal = null;
private Button builtInCheckBox;
private Button enableProvidersCheckBox;
private StatusMessageLine fStatusLine;
private Page_LanguageSettingsProviders masterPropertyPage = null;
private LanguageSettingsProvidersPage masterPropertyPage = null;
private static final int BUTTON_ADD = 0;
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_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_EDIT] = EDIT_STR;
@ -108,25 +106,25 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
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 {
@Override
protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
String[] overlayKeys = super.getOverlayKeys(provider);
// if (LanguageSettingsManager.isWorkspaceProvider(provider))
// provider = LanguageSettingsManager.getRawWorkspaceProvider(provider.getId());
//
if (currentLanguageId != null) {
IResource rc = getResource();
List<ICLanguageSettingEntry> entries = getSettingEntries(provider);
if (entries == null && !(rc instanceof IProject)) {
List<ICLanguageSettingEntry> entriesParent = getSettingEntriesUpResourceTree(provider);
if (entriesParent != null /*&& entriesParent.size() > 0*/) {
if (entriesParent != null) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT;
}
} else if (provider instanceof ILanguageSettingsBroadcastingProvider && (page.isForFile() || page.isForFolder())) {
// 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);
if (entries != null && !entries.equals(entriesParent)) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
@ -134,10 +132,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
}
// TODO
ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
if (initialProviders!=null && !initialProviders.contains(provider)) {
if (initialProviders != null && !initialProviders.contains(provider)) {
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_EDITED;
}
return overlayKeys;
@ -146,8 +143,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
@Override
public Image getImage(Object element) {
if (element instanceof ICLanguageSettingEntry) {
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
return LanguageSettingsImages.getImage(entry);
ICConfigurationDescription cfgDescription = getConfigurationDescription();
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfgDescription);
}
return super.getImage(element);
@ -192,7 +189,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// convert to modifiable list
entriesList = new ArrayList<ICLanguageSettingEntry>(entriesList);
if (builtInCheckBox.getSelection()==false) {
if (builtInCheckBox.getSelection() == false) {
for (Iterator<ICLanguageSettingEntry> iter = entriesList.iterator(); iter.hasNext();) {
ICLanguageSettingEntry entry = iter.next();
if (entry.isBuiltIn()) {
@ -312,6 +309,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return provider.getSettingEntries(cfgDescription, rc, currentLanguageId);
}
/**
* Store original providers to be able to tell whether they were changed by user.
*/
private void trackInitialSettings() {
if (!page.isForPrefs()) {
ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable();
@ -325,6 +325,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
}
/**
* Create UI control for languages.
*/
private void createTreeForLanguages(Composite parent) {
treeLanguages = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
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) {
treeEntries = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
treeEntries.setLayoutData(new GridData(GridData.FILL_VERTICAL));
@ -408,23 +414,29 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
/**
* Create sash form.
*/
private void createSashForm() {
sashFormEntries = new SashForm(usercomp,SWT.HORIZONTAL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
gd.grabExcessVerticalSpace = true;
sashFormEntries.setLayoutData(gd);
GridLayout layout = new GridLayout();
sashFormEntries.setLayout(layout);
createTreeForLanguages(sashFormEntries);
createTreeForEntries(sashFormEntries);
sashFormEntries.setWeights(DEFAULT_ENTRIES_SASH_WEIGHTS);
}
/**
* Create check-box to control whether to show built-in entries or not.
*/
private void createBuiltInsCheckBox() {
builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.FILL_HORIZONTAL);
builtInCheckBox.addSelectionListener(new SelectionAdapter() {
@ -437,6 +449,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
builtInCheckBox.setEnabled(true);
}
/**
* Create check-box to allow disable/enable language settings providers functionality.
*/
private void createEnableProvidersCheckBox() {
enableProvidersCheckBox = setupCheck(usercomp, Messages.CDTMainWizardPage_TrySD90, 2, GridData.FILL_HORIZONTAL);
enableProvidersCheckBox.addSelectionListener(new SelectionAdapter() {
@ -446,20 +461,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (masterPropertyPage != null) {
masterPropertyPage.setLanguageSettingsProvidersEnabled(enabled);
}
if (!enabled) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
updateData(getResDesc());
}
}
enableTabControls(enabled);
updateStatusLine();
}
});
if (masterPropertyPage != null) {
// take the flag from master page if available (normally for resource properties)
enableProvidersCheckBox.setSelection(masterPropertyPage.isLanguageSettingsProvidersEnabled());
@ -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
gd.heightHint =1;
if (page instanceof Page_LanguageSettingsProviders) {
masterPropertyPage = (Page_LanguageSettingsProviders) page;
if (page instanceof LanguageSettingsProvidersPage) {
masterPropertyPage = (LanguageSettingsProvidersPage) page;
}
trackInitialSettings();
@ -497,6 +504,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
updateData(getResDesc());
}
/**
* Gray out or restore all controls except enabling check-box.
*/
private void enableTabControls(boolean enable) {
sashFormEntries.setEnabled(enable);
treeLanguages.setEnabled(enable);
@ -508,18 +518,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (enable) {
updateTreeForEntries();
} else {
disableButtons();
buttonSetEnabled(BUTTON_ADD, false);
buttonSetEnabled(BUTTON_EDIT, false);
buttonSetEnabled(BUTTON_DELETE, false);
buttonSetEnabled(BUTTON_MOVE_UP, false);
buttonSetEnabled(BUTTON_MOVE_DOWN, false);
}
}
private void disableButtons() {
buttonSetEnabled(BUTTON_ADD, false);
buttonSetEnabled(BUTTON_EDIT, false);
buttonSetEnabled(BUTTON_DELETE, false);
buttonSetEnabled(BUTTON_MOVE_UP, false);
buttonSetEnabled(BUTTON_MOVE_DOWN, false);
}
/**
* Updates state for all buttons. Called when table selection changes.
*/
@ -579,14 +585,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
boolean isAllowedEditing = provider instanceof ILanguageSettingsEditableProvider
&& LanguageSettingsProviderAssociationManager.isAllowedToEditEntries(provider);
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, msg);
status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Entries_Not_Editable);
}
}
if (status == null || status == Status.OK_STATUS) {
if (treeLanguages.getItemCount() <= 0) {
String msg = "Cannot determine toolchain languages.";
status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg);
status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages);
}
}
fStatusLine.setErrorStatus(status);
@ -640,6 +644,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return -1;
}
/**
* Find TreeItem associated with a provider.
*/
private TreeItem findProviderItem(String id) {
TreeItem[] providerItems = treeEntries.getItems();
for (TreeItem providerItem : providerItems) {
@ -654,26 +661,31 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
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();
for (TreeItem providerItem : providerItems) {
Object providerItemData = providerItem.getData();
if (providerItemData instanceof ILanguageSettingsProvider) {
ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData;
if (provider.getId().equals(id)) {
if (provider.getId().equals(providerId)) {
TreeItem[] entryItems = providerItem.getItems();
for (TreeItem entryItem : entryItems) {
Object entryItemData = entryItem.getData();
if (entryItemData==entry)
return entryItem;
}
// return providerItem;
}
}
}
return null;
}
/**
* Select language settings entry item in the tree.
*/
private void selectItem(String providerId, ICLanguageSettingEntry entry) {
TreeItem providerItem = findProviderItem(providerId);
if (providerItem != null) {
@ -689,6 +701,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
}
/**
* Add language settings entry.
*/
private void addEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry) {
if (provider != null && entry != null) {
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) {
if (provider instanceof ILanguageSettingsEditableProvider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
@ -740,6 +758,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return entries;
}
/**
* Call dialog to add settings entry.
*/
private void performAdd(ILanguageSettingsProvider selectedProvider) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
@ -748,7 +769,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (addDialog.open()) {
ICLanguageSettingEntry settingEntry = addDialog.getEntries()[0];
if (settingEntry != null) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider);
selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
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 it. If not, create a copy to be edited.
* Return working copy of the provider to edit in current session. If the supplied provider is already
* 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();
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
if (initialProviders.contains(provider)) {
@ -771,15 +792,18 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
providers.set(pos, provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
} 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 {
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;
}
/**
* Call dialog to edit settings entry.
*/
private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) {
ICConfigurationDescription cfgDecsription = getConfigurationDescription();
@ -787,7 +811,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (editDialog.open()) {
ICLanguageSettingEntry newEntry = editDialog.getEntries()[0];
if (newEntry != null) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider);
selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
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) {
if (provider != null && entry != null) {
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) {
if (provider != null && oldEntry != null && newEntry != null) {
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) {
if (provider != null) {
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) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider);
selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
if (selectedEntry != null) {
deleteEntry(selectedProvider, selectedEntry);
} 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) {
if (provider != null && entry != null) {
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) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider);
selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
moveEntry(selectedProvider, selectedEntry, true);
}
}
/**
* Move provider's entry down.
*/
private void performMoveDown(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) {
selectedProvider = getEditedCopy((ILanguageSettingsEditableProvider)selectedProvider);
selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider);
moveEntry(selectedProvider, selectedEntry, false);
}
}
@ -952,6 +997,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
/**
* Change selection of language.
*/
private void selectLanguage(String langId) {
currentLanguageId = langId;
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
public void updateData(ICResourceDescription rcDes) {
@ -1003,45 +1051,45 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// we use null for resetting file/folder resource which should be correct in most cases.
// Count that as a feature.
ICConfigurationDescription cfgDescription = getConfigurationDescription();
if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper))
if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) {
return;
}
boolean changed = false;
IResource rc = getResource();
List<ILanguageSettingsProvider> oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
List<ILanguageSettingsProvider> newProviders = new ArrayList<ILanguageSettingsProvider>(oldProviders.size());
// clear entries for a given resource for all languages where applicable
providers: for (ILanguageSettingsProvider provider : oldProviders) {
ILanguageSettingsEditableProvider providerCopy = null;
if (provider instanceof ILanguageSettingsEditableProvider) {
for (TreeItem langItems : treeLanguages.getItems()) {
String langId = (String)langItems.getData();
if (langId!=null) {
if (provider.getSettingEntries(cfgDescription, rc, langId)!=null) {
if (langId != null) {
if (provider.getSettingEntries(cfgDescription, rc, langId) != null) {
if (providerCopy == null) {
// copy providers to be able to "Cancel" in UI
providerCopy = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) provider, true);
if (providerCopy == null) {
continue providers;
}
providerCopy.setSettingEntries(cfgDescription, rc, langId, null);
changed = true;
}
providerCopy.setSettingEntries(cfgDescription, rc, langId, null);
changed = true;
}
}
}
}
if (providerCopy!=null)
if (providerCopy != null) {
newProviders.add(providerCopy);
else
} else {
newProviders.add(provider);
}
}
if (changed) {
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(newProviders);
// updateTreeEntries();
// updateData(getResDesc());
List<ILanguageSettingsProvider> tableItems = getProviders(currentLanguageId);
treeEntriesViewer.setInput(tableItems.toArray(new Object[tableItems.size()]));
updateTreeForEntries();
}
}
}
@ -1068,6 +1116,9 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) {
setLanguageSettingsProvidersFunctionalityEnablement();
}
/**
* TODO
*/
private void setLanguageSettingsProvidersFunctionalityEnablement() {
if (page.isForProject() && enableProvidersCheckBox != null) {
boolean enabled = enableProvidersCheckBox.getSelection();

View file

@ -17,7 +17,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement;
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.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 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_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_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
private static List<URL> loadedIcons = null;
private static Map<String, URL> fImagesUrlById = null;
private static Map<String, URL> fImagesUrlByClass = null;
private static List<String> fRegirestedIds = null;
private static List<String> fRegisteredClasses = null;
private static boolean isLoaded = false;
private static List<URL> loadedIcons = new ArrayList<URL>();
private static Map<String, URL> fImagesUrlById = new HashMap<String, URL>();
private static Map<String, URL> fImagesUrlByClass = new HashMap<String, URL>();
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>> fAssociationsByClass = null;
private static Map<String, Map<String, String>> fAssociationsById = new HashMap<String, Map<String, String>>();
private static Map<String, Map<String, String>> fAssociationsByClass = new HashMap<String, Map<String, String>>();
/**
* Load extensions into memory maps.
*/
private static void loadExtensions() {
if (loadedIcons!=null) {
if (isLoaded) {
return;
}
if (loadedIcons==null) loadedIcons = new ArrayList<URL>();
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>>();
isLoaded = true;
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) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@ -79,23 +83,23 @@ public class LanguageSettingsProviderAssociationManager {
fRegirestedIds.add(id);
Map<String, String> properties = new HashMap<String, String>();
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
sensiblePut(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_PAGE, cfgEl.getAttribute(ATTR_PAGE));
putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
fAssociationsById.put(id, properties);
} else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
String className = cfgEl.getAttribute(ATTR_CLASS);
URL url = getIconUrl(cfgEl);
fImagesUrlByClass.put(className, url);
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
if (pageClass!=null && pageClass.length()>0) {
if (pageClass != null && pageClass.length() > 0) {
fRegisteredClasses.add(className);
}
Map<String, String> properties = new HashMap<String, String>();
sensiblePut(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
sensiblePut(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_PAGE, cfgEl.getAttribute(ATTR_PAGE));
putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
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)
properties.put(key, value);
}
/**
* Find icon URL in its bundle.
*/
private static URL getIconUrl(IConfigurationElement config) {
URL url = null;
try {
@ -116,33 +126,42 @@ public class LanguageSettingsProviderAssociationManager {
if (iconName != null) {
URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
url = new URL(pluginInstallUrl, iconName);
if (loadedIcons.contains(url))
if (loadedIcons.contains(url)) {
return url;
}
}
} catch (MalformedURLException exception) {}
} catch (MalformedURLException e) {
CUIPlugin.log(e);
}
loadedIcons.add(url);
if (url!=null) {
if (url != null) {
CDTSharedImages.register(url);
}
return url;
}
public static URL getImageUrl(String id) {
if (fImagesUrlById==null) {
loadExtensions();
}
return fImagesUrlById.get(id);
/**
* 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();
return fImagesUrlById.get(providerId);
}
/**
* Create an Options page for language settings provider with given ID.
*/
private static ICOptionPage createOptionsPageById(String providerId) {
if (fRegirestedIds==null) {
loadExtensions();
}
loadExtensions();
if (fRegirestedIds.contains(providerId)) {
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) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@ -154,7 +173,7 @@ public class LanguageSettingsProviderAssociationManager {
String id = cfgEl.getAttribute(ATTR_ID);
if (providerId.equals(id)) {
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
if (pageClass!=null && pageClass.trim().length()>0) {
if (pageClass != null && pageClass.trim().length() > 0) {
ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
return page;
}
@ -170,13 +189,15 @@ public class LanguageSettingsProviderAssociationManager {
return null;
}
/**
* Create an Options page for language settings provider class by its name.
*/
private static ICOptionPage createOptionsPageByClass(String providerClassName) {
if (fRegisteredClasses==null) {
loadExtensions();
}
loadExtensions();
if (fRegisteredClasses.contains(providerClassName)) {
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) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@ -208,31 +229,35 @@ public class LanguageSettingsProviderAssociationManager {
* Returns Language Settings Provider image registered for closest superclass
* 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}
*/
public static URL getImage(Class<? extends ILanguageSettingsProvider> clazz) {
public static URL getImage(Class<? extends ILanguageSettingsProvider> providerClass) {
URL url = null;
outer: for (Class<?> cl=clazz;cl!=null;cl=cl.getSuperclass()) {
url = getImageURL(cl);
if (url!=null)
outer: for (Class<?> c = providerClass; c != null; c = c.getSuperclass()) {
url = getImageURL(c);
if (url != null) {
break;
}
// this does not check for superinterfaces, feel free to implement as needed
for (Class<?> in : cl.getInterfaces()) {
url = getImageURL(in);
if (url!=null)
// this does not check for super-interfaces, feel free to implement as needed
for (Class<?> i : c.getInterfaces()) {
url = getImageURL(i);
if (url != null) {
break outer;
}
}
}
return url;
}
/**
* Return image URL registered for the given class.
*/
private static URL getImageURL(Class<?> clazz) {
String className = clazz.getCanonicalName();
Set<Entry<String, URL>> entrySet = fImagesUrlByClass.entrySet();
for (Entry<String, URL> entry : entrySet) {
for (Entry<String, URL> entry : fImagesUrlByClass.entrySet()) {
if (entry.getKey().equals(className)) {
return entry.getValue();
}
@ -241,36 +266,42 @@ public class LanguageSettingsProviderAssociationManager {
}
/**
* Returns Language Settings Provider image registered for closest superclass.
* @param provider TODO
* @return image or {@code null}
* Returns language settings provider Options page registered for closest superclass.
*
* @param provider - instance of provider to create Options page for.
* @return image or {@code null}.
*/
public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) {
String id = provider.getId();
ICOptionPage optionsPage = createOptionsPageById(id);
if (optionsPage!=null) {
if (optionsPage != null) {
return optionsPage;
}
Class<? extends ILanguageSettingsProvider> clazz = provider.getClass();
outer: for (Class<?> cl=clazz;cl!=null;cl=cl.getSuperclass()) {
optionsPage = createOptionsPageByClass(cl);
if (optionsPage!=null)
outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) {
optionsPage = createOptionsPageByClass(c);
if (optionsPage != null) {
break;
}
// this does not check for superinterfaces, feel free to implement as needed
for (Class<?> in : cl.getInterfaces()) {
optionsPage = createOptionsPageByClass(in);
if (optionsPage!=null)
// this does not check for super-interfaces, feel free to implement as needed
for (Class<?> i : c.getInterfaces()) {
optionsPage = createOptionsPageByClass(i);
if (optionsPage != null) {
break outer;
}
}
}
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;
String className = c.getCanonicalName();
String className = clazz.getCanonicalName();
if (fRegisteredClasses.contains(className)) {
optionsPage = createOptionsPageByClass(className);
}
@ -278,9 +309,7 @@ public class LanguageSettingsProviderAssociationManager {
}
/**
* Returns TODO for id or closest superclass.
* @param provider TODO
* @return TODO
* Returns value of the attribute of the provider by id or closest superclass.
*/
private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) {
loadExtensions();
@ -292,16 +321,16 @@ public class LanguageSettingsProviderAssociationManager {
return Boolean.parseBoolean(properties.get(attr));
}
for (Class<?> clazz=provider.getClass();clazz!=null;clazz=clazz.getSuperclass()) {
String className = clazz.getCanonicalName();
for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) {
String className = c.getCanonicalName();
properties = fAssociationsByClass.get(className);
if (properties != null) {
return Boolean.parseBoolean(properties.get(attr));
}
// this does not check for superinterfaces, feel free to implement as needed
for (Class<?> iface : clazz.getInterfaces()) {
String interfaceName = iface.getCanonicalName();
for (Class<?> i : c.getInterfaces()) {
String interfaceName = i.getCanonicalName();
properties = fAssociationsByClass.get(interfaceName);
if (properties != null) {
return Boolean.parseBoolean(properties.get(attr));
@ -312,21 +341,21 @@ public class LanguageSettingsProviderAssociationManager {
}
/**
* Returns TODO for id or closest superclass.
* @param provider TODO
* @return TODO
*/
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
* Check if the user is allowed to edit language settings provider entries in UI.
* @param provider - language settings provider.
* @return {@code true} if editing is allowed or {@code false} if not.
*/
public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) {
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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,20 +8,19 @@
* Contributors:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
import java.net.URL;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
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.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.internal.ui.newui.Messages;
/**
* Label provider for language settings providers.
@ -40,17 +39,17 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
String id = provider.getId();
URL url = LanguageSettingsProviderAssociationManager.getImageUrl(id);
// try class-association
if (url==null) {
if (url == null) {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider!=null) {
if (rawProvider != null) {
url = LanguageSettingsProviderAssociationManager.getImage(rawProvider.getClass());
}
}
if (url!=null) {
if (url != null) {
imageKey = url.toString();
}
if (imageKey==null) {
if (imageKey == null) {
if (id.matches(TEST_PLUGIN_ID_PATTERN)) {
imageKey = CDTSharedImages.IMG_OBJS_CDT_TESTING;
} else {
@ -64,31 +63,7 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
* Returns keys for image overlays. Returning {@code null} is not allowed.
*/
protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
String[] overlayKeys = 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;
return new String[5];
}
@Override
@ -107,24 +82,15 @@ public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
if (element instanceof ILanguageSettingsProvider) {
ILanguageSettingsProvider provider = (ILanguageSettingsProvider) element;
String name = provider.getName();
if (name!=null) {
if (name != null) {
if (LanguageSettingsManager.isWorkspaceProvider(provider)) {
name = name + " [ Shared ]";
name = name + Messages.LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
}
return name;
}
String id = provider.getId();
return "[ Not accessible id="+id+" ]";
return NLS.bind(Messages.GeneralMessages_NonAccessibleID, provider.getId());
}
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
* 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
*
* Contributors:
* Intel Corporation - initial API and implementation
* Andrew Gvozdev - initial API and implementation
*******************************************************************************/
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;
/**
* Property page for language settings providers tabs.
*
* @noextend This class is not intended to be subclassed 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;
@Override
@ -26,6 +28,11 @@ public class Page_LanguageSettingsProviders extends AbstractPage {
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() {
if (isLanguageSettingsProvidersEnabled == null) {
isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(getProject());
@ -33,6 +40,11 @@ public class Page_LanguageSettingsProviders extends AbstractPage {
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) {
isLanguageSettingsProvidersEnabled = enable;
forEach(ICPropertyTab.UPDATE,getResDesc());

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.ui.newui;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
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.ICConfigurationDescription;
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.util.CDataUtil;
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}.
*/
public class LanguageSettingsImages {
// AG FIXME - replace usage with version taking cfgDescription
@Deprecated
public static Image getImage(int kind, int flags, boolean isProjectRelative) {
String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey!=null) {
// String overlayKey = getErrorOverlayKey(kind, flags, isProjectRelative);
// if (overlayKey!=null) {
// return getOverlaidImage(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
// }
if (imageKey != null) {
return CDTSharedImages.getImage(imageKey);
}
return null;
@ -48,17 +44,26 @@ public class LanguageSettingsImages {
/**
* Returns image for the given entry from internally managed repository including
* necessary overlays. This method is shortcut for {@link #getImage(ICLanguageSettingEntry, String, ICConfigurationDescription)}
* when no project is available.
* necessary overlays for given configuration description.
*
* @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.
*
* AG FIXME - replace usage with version taking cfgDescription
*/
@Deprecated
public static Image getImage(ICLanguageSettingEntry entry) {
return getImage(entry, null, null);
public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
String projectName = 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);
}
/**
@ -66,11 +71,11 @@ public class LanguageSettingsImages {
*/
public static String getImageKey(int kind, int flag, boolean isProjectRelative) {
String imageKey = null;
boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
boolean isBuiltin = (flag & ICSettingEntry.BUILTIN) != 0;
boolean isFramework = (flag & ICSettingEntry.FRAMEWORKS_MAC) != 0;
switch (kind) {
case ICSettingEntry.INCLUDE_PATH:
if (isWorkspacePath) {
@ -118,7 +123,7 @@ public class LanguageSettingsImages {
* @param cfgDescription - configuration description of the entry.
* @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 flags = entry.getFlags();
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_9;
public static String ErrorParsTab_error_IllegalCharacter;
public static String ErrorParsTab_error_NonAccessibleID;
public static String ErrorParsTab_error_NonEmptyName;
public static String ErrorParsTab_error_NonUniqueID;
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_movedown;
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_1;
public static String IncludeDialog_2;
@ -187,18 +188,42 @@ public class Messages extends NLS {
public static String IncludeTab_2;
public static String IncludeTab_export;
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_FolderDoesNotExist;
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
public static String LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
public static String LanguageSettingsProviderTab_AreYouSureToResetProviders;
public static String LanguageSettingsProviderTab_Clear;
public static String LanguageSettingsProviderTab_Configure;
public static String LanguageSettingsProviderTab_ErrorPerformingDefaults;
public static String LanguageSettingsProviderTab_LanguageSettingsProvidersOptions;
public static String LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab;
public static String LanguageSettingsProviderTab_ProviderOptions;
public static String LanguageSettingsProviderTab_Reset;
public static String LanguageSettingsProviderTab_SettingEntries;
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_WorkspaceSettings;
public static String LanguagesTab_0;
public static String LanguagesTab_1;
public static String LibraryPathTab_1;

View file

@ -166,18 +166,42 @@ IncludeDialog_0=Directory:
IncludeDialog_1=File:
IncludeDialog_2=Add to all configurations
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_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.
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_Clear=Clear Entries
LanguageSettingsProviderTab_Configure=Configure
LanguageSettingsProviderTab_ErrorPerformingDefaults=Error restoring defaults for language settings providers
LanguageSettingsProviderTab_LanguageSettingsProvidersOptions=Language Settings Provider Options
LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab=Options of global providers below can be changed in {0}, Discovery Tab.
LanguageSettingsProviderTab_Reset=Reset
LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
LanguageSettingsProviderTab_SettingEntries=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_WorkspaceSettings=Workspace Settings
LanguagesTab_0=Content type
LanguagesTab_1=Language
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_OnApplyingSettings=Error applying 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_label_EnterName=Enter name of new 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)
CProjectWizard_0=Add C 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_22=Build error
IncludeTab_export=Export Settings...

View file

@ -19,7 +19,6 @@ import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@ -242,7 +241,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
int index = table.getSelectionIndex();
if (index<0 || table.getSelectionIndices().length!=1)
return null;
return (ICLanguageSettingEntry)(table.getItem(index).getData());
}
@ -730,8 +729,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
ICConfigurationDescription cfg = getResDesc().getConfiguration();
IProject project = cfg.getProjectDescription().getProject();
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName(), cfg);
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfg);
}
return null;
}
@ -760,7 +758,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} else if (columnIndex == 0) {
return element.toString();
}
return null;
}

View file

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