1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
Andrew Gvozdev 2012-04-26 09:00:26 -04:00
parent 89a9259918
commit b4b53b3bc6
6 changed files with 391 additions and 508 deletions

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* 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 - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;

View file

@ -95,14 +95,15 @@ 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 = {
ADD_STR,
EDIT_STR,
DEL_STR,
null,
MOVEUP_STR,
MOVEDOWN_STR,
};
private final static String[] BUTTON_LABELS = new String[6];
{
BUTTON_LABELS[BUTTON_ADD] = ADD_STR;
BUTTON_LABELS[BUTTON_EDIT] = EDIT_STR;
BUTTON_LABELS[BUTTON_DELETE] = DEL_STR;
BUTTON_LABELS[BUTTON_MOVE_UP] = MOVEUP_STR;
BUTTON_LABELS[BUTTON_MOVE_DOWN] = MOVEDOWN_STR;
}
private static final String CLEAR_STR = Messages.LanguageSettingsProviderTab_Clear;
private Map<String, List<ILanguageSettingsProvider>> initialProvidersMap = new HashMap<String, List<ILanguageSettingsProvider>>();
@ -311,8 +312,21 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return provider.getSettingEntries(cfgDescription, rc, currentLanguageId);
}
private void createTreeForLanguages(Composite comp) {
treeLanguages = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
private void trackInitialSettings() {
if (!page.isForPrefs()) {
ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String cfgId = cfgDescription.getId();
List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
initialProvidersMap.put(cfgId, initialProviders);
}
}
}
}
private void createTreeForLanguages(Composite parent) {
treeLanguages = new Tree(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
treeLanguages.setLayoutData(new GridData(GridData.FILL_VERTICAL));
treeLanguages.setHeaderVisible(true);
@ -347,8 +361,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
});
}
private void createTreeForEntries(Composite comp) {
treeEntries = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
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));
treeEntries.setHeaderVisible(true);
treeEntries.setLinesVisible(true);
@ -394,43 +408,24 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
}
private void trackInitialSettings() {
if (page.isForPrefs()) {
// AG TODO
} else {
ICConfigurationDescription[] cfgDescriptions = page.getCfgsEditable();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
String cfgId = cfgDescription.getId();
List<ILanguageSettingsProvider> initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
initialProvidersMap.put(cfgId, initialProviders);
}
}
}
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);
}
@Override
public void createControls(Composite parent) {
super.createControls(parent);
currentLanguageId = null;
usercomp.setLayout(new GridLayout());
GridData gd = (GridData) usercomp.getLayoutData();
// 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;
}
trackInitialSettings();
createSashForm();
// Status line
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
// "Show built-ins" checkbox
private void createBuiltInsCheckBox() {
builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.FILL_HORIZONTAL);
builtInCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
@ -440,8 +435,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
});
builtInCheckBox.setSelection(true);
builtInCheckBox.setEnabled(true);
}
// "I want to try new scanner discovery" temporary checkbox
private void createEnableProvidersCheckBox() {
enableProvidersCheckBox = setupCheck(usercomp, Messages.CDTMainWizardPage_TrySD90, 2, GridData.FILL_HORIZONTAL);
enableProvidersCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
@ -473,28 +469,34 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
// display but disable the checkbox for file/folder resource
enableProvidersCheckBox.setEnabled(page.isForProject());
enableTabControls(enableProvidersCheckBox.getSelection());
}
@Override
public void createControls(Composite parent) {
super.createControls(parent);
currentLanguageId = null;
usercomp.setLayout(new GridLayout());
GridData gd = (GridData) usercomp.getLayoutData();
// 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;
}
trackInitialSettings();
createSashForm();
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
createBuiltInsCheckBox();
// "I want to try new scanner discovery" temporary checkbox
createEnableProvidersCheckBox();
initButtons(BUTTON_LABELS);
updateData(getResDesc());
}
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);
}
private void enableTabControls(boolean enable) {
sashFormEntries.setEnabled(enable);
treeLanguages.setEnabled(enable);
@ -778,16 +780,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
return provider;
}
private ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
ICLanguageSettingEntry selectedEntry = getSelectedEntry();
ICConfigurationDescription cfgDecsription = getConfigurationDescription();
LanguageSettingEntryDialog dlg = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDecsription, selectedEntry);
if (dlg.open()) {
return dlg.getEntries()[0];
}
return null;
}
private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) {
if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) {
ICConfigurationDescription cfgDecsription = getConfigurationDescription();
@ -1107,15 +1099,4 @@ providers: for (ILanguageSettingsProvider provider : oldProviders) {
return true;
}
/**
* Shortcut for setting setting entries for current context.
*
*/
private void setSettingEntries(ILanguageSettingsEditableProvider provider, List<ICLanguageSettingEntry> entries) {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
IResource rc = getResource();
if (currentLanguageId!=null)
provider.setSettingEntries(cfgDescription, rc, currentLanguageId, entries);
}
}

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* 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 - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
import java.net.MalformedURLException;

View file

@ -195,7 +195,6 @@ public class Messages extends NLS {
public static String LanguageSettingsProviderTab_Configure;
public static String LanguageSettingsProviderTab_ErrorPerformingDefaults;
public static String LanguageSettingsProviderTab_ProviderOptions;
// public static String LanguageSettingsProviderTab_Run;
public static String LanguageSettingsProviderTab_SettingEntries;
public static String LanguageSettingsProviderTab_SettingEntriesTooltip;
public static String LanguageSettingsProviderTab_ShowEntries;

View file

@ -174,7 +174,6 @@ LanguageSettingsProviderTab_Clear=Clear Entries
LanguageSettingsProviderTab_Configure=Configure
LanguageSettingsProviderTab_ErrorPerformingDefaults=Error restoring defaults for language settings providers
LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
#LanguageSettingsProviderTab_Run=Run
LanguageSettingsProviderTab_SettingEntries=Setting Entries
LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries
LanguageSettingsProviderTab_ShowEntries=Show Entries