1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Fixed bug when entries for global language even if not in the list were

shown
This commit is contained in:
Andrew Gvozdev 2012-04-13 13:08:24 -04:00
parent 2aadaa0262
commit 01c3e2f0f5

View file

@ -69,8 +69,8 @@ import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
* This tab presents language settings entries categorized by language * This tab presents language settings entries categorized by language
* settings providers. * settings providers.
* *
*@noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*@noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private static final int[] DEFAULT_ENTRIES_SASH_WEIGHTS = new int[] { 10, 30 }; private static final int[] DEFAULT_ENTRIES_SASH_WEIGHTS = new int[] { 10, 30 };
@ -79,7 +79,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private Tree treeLanguages; private Tree treeLanguages;
private Tree treeEntries; private Tree treeEntries;
private TreeViewer treeEntriesViewer; private TreeViewer treeEntriesViewer;
private static String currentLanguageId = null; private static String currentLanguageIdGlobal = null;
private String currentLanguageId = null;
private Button builtInCheckBox; private Button builtInCheckBox;
private Button enableProvidersCheckBox; private Button enableProvidersCheckBox;
@ -322,6 +323,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
TreeItem[] items = treeLanguages.getSelection(); TreeItem[] items = treeLanguages.getSelection();
if (items.length > 0) { if (items.length > 0) {
currentLanguageId = (String) items[0].getData(); currentLanguageId = (String) items[0].getData();
currentLanguageIdGlobal = currentLanguageId;
updateTreeEntries(); updateTreeEntries();
updateButtons(); updateButtons();
} }
@ -375,6 +377,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
treeEntries.addSelectionListener(new SelectionAdapter() { treeEntries.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (treeLanguages.getSelectionCount() == 0) {
selectLanguage(currentLanguageId);
}
updateStatusLine(); updateStatusLine();
updateButtons(); updateButtons();
} }
@ -405,6 +410,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
@Override @Override
public void createControls(Composite parent) { public void createControls(Composite parent) {
super.createControls(parent); super.createControls(parent);
currentLanguageId = null;
usercomp.setLayout(new GridLayout()); usercomp.setLayout(new GridLayout());
GridData gd = (GridData) usercomp.getLayoutData(); GridData gd = (GridData) usercomp.getLayoutData();
// Discourage settings entry table from trying to show all its items at once, see bug 264330 // Discourage settings entry table from trying to show all its items at once, see bug 264330
@ -904,7 +911,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
private void updateTreeLanguages(ICResourceDescription rcDes) { private void updateTreeLanguages(ICResourceDescription rcDes) {
treeLanguages.removeAll(); treeLanguages.removeAll();
TreeItem selectedLanguageItem = null; currentLanguageId = null;
List<String> languageIds = LanguageSettingsManager.getLanguages(rcDes); List<String> languageIds = LanguageSettingsManager.getLanguages(rcDes);
Collections.sort(languageIds); Collections.sort(languageIds);
@ -920,20 +927,27 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
TreeItem t = new TreeItem(treeLanguages, SWT.NONE); TreeItem t = new TreeItem(treeLanguages, SWT.NONE);
t.setText(0, langName); t.setText(0, langName);
t.setData(langId); t.setData(langId);
if (selectedLanguageItem == null) { if (currentLanguageIdGlobal != null && currentLanguageIdGlobal.equals(langId)) {
if (currentLanguageId!=null) { currentLanguageId = currentLanguageIdGlobal;
if (currentLanguageId.equals(langId)) { treeLanguages.setSelection(t);
selectedLanguageItem = t; } else if (currentLanguageId == null) {
} // this selects first language on first round
} else { // do not select the tree item and global language selection here, only on actual click
selectedLanguageItem = t; currentLanguageId = langId;
currentLanguageId = langId;
}
} }
} }
if (selectedLanguageItem != null) { }
treeLanguages.setSelection(selectedLanguageItem);
private void selectLanguage(String langId) {
currentLanguageId = langId;
currentLanguageIdGlobal = currentLanguageId;
for (TreeItem t : treeLanguages.getItems()) {
if (t.getData().equals(langId)) {
treeLanguages.setSelection(t);
break;
}
} }
} }