1
/*******************************************************************************
2
* Copyright (c) 2007, 2009 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - initial API and implementation
11
*******************************************************************************/
12
package org.eclipse.cdt.ui.newui;
14
import java.util.Collections;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.accessibility.AccessibleAdapter;
18
import org.eclipse.swt.accessibility.AccessibleEvent;
19
import org.eclipse.swt.widgets.TableColumn;
21
import org.eclipse.cdt.core.model.util.CDTListComparator;
22
import org.eclipse.cdt.core.settings.model.CMacroEntry;
23
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
24
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
27
* @noextend This class is not intended to be subclassed by clients.
29
public class SymbolTab extends AbstractLangsListTab {
31
public void additionalTableSet() {
32
TableColumn tc = new TableColumn(table, SWT.LEFT);
33
tc.setText(UIMessages.getString("SymbolTab.0")); //$NON-NLS-1$
35
tc = new TableColumn(table, SWT.LEFT);
36
tc.setText(UIMessages.getString("SymbolTab.1")); //$NON-NLS-1$
38
table.getAccessible().addAccessibleListener(
39
new AccessibleAdapter() {
41
public void getName(AccessibleEvent e) {
42
e.result = UIMessages.getString("SymbolTab.0"); //$NON-NLS-1$
49
public ICLanguageSettingEntry doAdd() {
50
SymbolDialog dlg = new SymbolDialog(
51
usercomp.getShell(), true,
52
UIMessages.getString("SymbolTab.2"), EMPTY_STR, EMPTY_STR, getResDesc()); //$NON-NLS-1$
53
if (dlg.open() && dlg.text1.trim().length() > 0 ) {
54
toAllCfgs = dlg.check1;
55
toAllLang = dlg.check3;
56
return new CMacroEntry(dlg.text1, dlg.text2, 0);
62
public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
63
SymbolDialog dlg = new SymbolDialog(
64
usercomp.getShell(), false,
65
UIMessages.getString("SymbolTab.3"), ent.getName(), //$NON-NLS-1$
66
ent.getValue(), getResDesc());
68
return new CMacroEntry(dlg.text1, dlg.text2, 0);
73
public int getKind() {
74
return ICSettingEntry.MACRO;
77
// Specific version of "update()" for Symbols tab only
79
public void update() {
81
int x = table.getSelectionIndex();
84
shownEntries = getIncs();
85
Collections.sort(shownEntries, CDTListComparator.getInstance());
86
tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
87
if (table.getItemCount() > x)
88
table.setSelection(x);
89
else if (table.getItemCount() > 0)
90
table.setSelection(0);