1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 23:35:48 +02:00

bug 274684: Indicators of string list modes for multi-configuration edits look like debug texts

This commit is contained in:
Andrew Gvozdev 2010-11-09 17:40:52 +00:00
parent b1132c434c
commit 4ec4353e88
5 changed files with 187 additions and 124 deletions

View file

@ -20,11 +20,18 @@ public class Messages extends NLS {
public static String AbstractExportTab_1; public static String AbstractExportTab_1;
public static String AbstractExportTab_2; public static String AbstractExportTab_2;
public static String AbstractExportTab_3; public static String AbstractExportTab_3;
public static String AbstractLangsListTab_0; public static String AbstractLangsListTab_ShowBuiltin;
public static String AbstractLangsListTab_1; public static String AbstractLangsListTab_Languages;
public static String AbstractLangsListTab_2; public static String AbstractLangsListTab_Export;
public static String AbstractLangsListTab_3; public static String AbstractLangsListTab_ExportIndicator;
public static String AbstractLangsListTab_4; public static String AbstractLangsListTab_Unexport;
public static String AbstractLangsListTab_Conjunction;
public static String AbstractLangsListTab_Disjunction;
public static String AbstractLangsListTab_Modify;
public static String AbstractLangsListTab_MultiConfigStringListModeLinkHint;
public static String AbstractLangsListTab_Replace;
public static String AbstractLangsListTab_StringListMode;
public static String AbstractLangsListTab_UnknownMode;
public static String AbstractPage_0; public static String AbstractPage_0;
public static String AbstractPage_10; public static String AbstractPage_10;
public static String AbstractPage_11; public static String AbstractPage_11;

View file

@ -100,11 +100,18 @@ AbstractPage_8=Cannot apply
AbstractPage_9=Internal error AbstractPage_9=Internal error
AbstractPage_rebuildIndex_question=Changes to the include search paths or defined symbols will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now? AbstractPage_rebuildIndex_question=Changes to the include search paths or defined symbols will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now?
AbstractLangsListTab_0=Show built-in values AbstractLangsListTab_ShowBuiltin=Show built-in values
AbstractLangsListTab_1=Languages AbstractLangsListTab_Languages=Languages
AbstractLangsListTab_2=Export AbstractLangsListTab_Export=Export
AbstractLangsListTab_3=\ [exp] AbstractLangsListTab_ExportIndicator=\ [exp]
AbstractLangsListTab_4=Unexport AbstractLangsListTab_Unexport=Unexport
AbstractLangsListTab_Conjunction=Conjunction
AbstractLangsListTab_Disjunction=Disjunction
AbstractLangsListTab_Modify=Modify
AbstractLangsListTab_MultiConfigStringListModeLinkHint=Multiple configurations string list mode. Click on link to change or for more info.
AbstractLangsListTab_Replace=Replace
AbstractLangsListTab_StringListMode=String List Mode:
AbstractLangsListTab_UnknownMode=Unknown
AbstractExportTab_0=[All] AbstractExportTab_0=[All]
AbstractExportTab_1=[List] AbstractExportTab_1=[List]
AbstractExportTab_2=Create... AbstractExportTab_2=Create...

View file

@ -67,7 +67,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
* It is a parent for all standard property tabs * It is a parent for all standard property tabs
* in new CDT model. * in new CDT model.
* *
* Although it's enougth for new tabs to implement * Although it's enough for new tabs to implement
* ICPropertyTab interface only, it would be better * ICPropertyTab interface only, it would be better
* to extend them from this class. * to extend them from this class.
* *
@ -667,6 +667,14 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
background.setText(s == null ? BACKGROUND_TEXT_DEFAULT : s); background.setText(s == null ? BACKGROUND_TEXT_DEFAULT : s);
} }
/**
* Used to display double-clickable buttons for multiple configurations
* string list mode (see Multiple Configurations Edit Preference page).
*
* @deprecated as of CDT 8.0. This functionality is presented as links
* to the preference page, see {@link AbstractLangsListTab#updateStringListModeControl()}
*/
@Deprecated
protected void updateLbs(Label lb1, Label lb2) { protected void updateLbs(Label lb1, Label lb2) {
if (page.isMultiCfg()) { if (page.isMultiCfg()) {
if (lb1 != null) { if (lb1 != null) {

View file

@ -25,12 +25,11 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
@ -44,12 +43,14 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.cdt.core.model.ILanguageDescriptor; import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.model.LanguageManager;
@ -73,6 +74,8 @@ import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.Messages;
public abstract class AbstractLangsListTab extends AbstractCPropertyTab { public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private static final String STRING_LIST_MODE_PREFERENCE_PAGE = "org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_MultiConfig"; //$NON-NLS-1$
protected Table table; protected Table table;
protected TableViewer tv; protected TableViewer tv;
protected Tree langTree; protected Tree langTree;
@ -80,17 +83,21 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
protected Button showBIButton; protected Button showBIButton;
protected boolean toAllCfgs = false; protected boolean toAllCfgs = false;
protected boolean toAllLang = false; protected boolean toAllLang = false;
protected Label lb1, lb2; /** @deprecated as of CDT 8.0. {@code linkStringListMode} is used instead. */
protected TableColumn columnToFit = null; @Deprecated
protected Label lb1, lb2;
private Link linkStringListMode;
protected TableColumn columnToFit = null;
protected ICLanguageSetting lang; protected ICLanguageSetting lang;
protected LinkedList<ICLanguageSettingEntry> shownEntries; protected LinkedList<ICLanguageSettingEntry> shownEntries;
/** A set of resolved exported entries */ /** A set of resolved exported entries */
protected ArrayList<ICSettingEntry> exported; protected ArrayList<ICSettingEntry> exported;
protected SashForm sashForm; protected SashForm sashForm;
protected ICLanguageSetting [] ls; // all languages known protected ICLanguageSetting [] ls; // all languages known
private boolean fHadSomeModification; private boolean fHadSomeModification;
private static final int BUTTON_ADD = 0; private static final int BUTTON_ADD = 0;
private static final int BUTTON_EDIT = 1; private static final int BUTTON_EDIT = 1;
private static final int BUTTON_DELETE = 2; private static final int BUTTON_DELETE = 2;
@ -102,8 +109,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
protected final static String[] BUTTONS = { protected final static String[] BUTTONS = {
ADD_STR, ADD_STR,
EDIT_STR, EDIT_STR,
DEL_STR, DEL_STR,
Messages.AbstractLangsListTab_2, Messages.AbstractLangsListTab_Export,
null, null,
MOVEUP_STR, MOVEUP_STR,
MOVEDOWN_STR MOVEDOWN_STR
@ -111,35 +118,35 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
protected final static String[] BUTTSYM = { protected final static String[] BUTTSYM = {
ADD_STR, ADD_STR,
EDIT_STR, EDIT_STR,
DEL_STR, DEL_STR,
Messages.AbstractLangsListTab_2 Messages.AbstractLangsListTab_Export
}; };
private static final Comparator<Object> comp = CDTListComparator.getInstance(); private static final Comparator<Object> comp = CDTListComparator.getInstance();
private final static Image IMG_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER); private final static Image IMG_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER);
private final static Image IMG_INCLUDES_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER); private final static Image IMG_INCLUDES_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
private final static Image IMG_BUILTIN_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM); private final static Image IMG_BUILTIN_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
private final static Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); private final static Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE);
private final static Image IMG_INCLUDES_FOLDER_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE); private final static Image IMG_INCLUDES_FOLDER_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
private final static Image IMG_MACRO = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO); private final static Image IMG_MACRO = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO);
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 }; private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 };
@Override @Override
public void createControls(Composite parent) { public void createControls(Composite parent) {
super.createControls(parent); super.createControls(parent);
usercomp.setLayout(new GridLayout(2, true)); usercomp.setLayout(new GridLayout(2, false));
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
gd.heightHint =1; gd.heightHint =1;
// Create the sash form // Create the sash form
sashForm = new SashForm(usercomp, SWT.NONE); sashForm = new SashForm(usercomp, SWT.NONE);
sashForm.setOrientation(SWT.HORIZONTAL); sashForm.setOrientation(SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_BOTH); gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
sashForm.setLayoutData(gd); sashForm.setLayoutData(gd);
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.numColumns = 2; layout.numColumns = 2;
layout.marginHeight = 5; layout.marginHeight = 5;
@ -154,7 +161,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
table.setLinesVisible(true); table.setLinesVisible(true);
sashForm.setWeights(DEFAULT_SASH_WEIGHTS); sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
sashForm.addListener(SWT.Selection, new Listener() { sashForm.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) { public void handleEvent(Event event) {
if (event.detail == SWT.DRAG) return; if (event.detail == SWT.DRAG) return;
@ -209,21 +216,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
setColumnToFit(); setColumnToFit();
}}); }});
setupLabel(usercomp, EMPTY_STR, 1, 0); showBIButton = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.GRAB_HORIZONTAL);
gd = (GridData) showBIButton.getLayoutData();
lb1 = new Label(usercomp, SWT.BORDER | SWT.CENTER);
lb1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
lb1.setToolTipText(Messages.EnvironmentTab_15);
lb1.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
CDTPrefUtil.spinDMode();
update();
}
});
showBIButton = setupCheck(usercomp,
Messages.AbstractLangsListTab_0, 1, GridData.FILL_HORIZONTAL);
showBIButton.addSelectionListener(new SelectionAdapter() { showBIButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
@ -231,22 +225,74 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
}); });
lb2 = new Label(usercomp, SWT.BORDER | SWT.CENTER); createLinkToPreferences(usercomp, 1);
lb2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
lb2.setToolTipText(Messages.EnvironmentTab_23);
lb2.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
CDTPrefUtil.spinWMode();
updateLbs(null, lb2);
}
});
additionalTableSet(); additionalTableSet();
initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS); initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS);
updateData(getResDesc()); updateData(getResDesc());
} }
private void createLinkToPreferences(final Composite parent, int span) {
linkStringListMode = new Link(parent, SWT.NONE);
updateStringListModeLink(linkStringListMode);
linkStringListMode.setToolTipText(Messages.AbstractLangsListTab_MultiConfigStringListModeLinkHint);
linkStringListMode.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
// Use event.text to tell which link was used
int result = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), STRING_LIST_MODE_PREFERENCE_PAGE, null, null).open();
if (result!=Window.CANCEL) {
updateStringListModeControl();
}
}
});
GridData gridData = new GridData(SWT.RIGHT, SWT.NONE, true, false);
gridData.horizontalSpan = span;
linkStringListMode.setLayoutData(gridData);
}
/**
* Used to display UI control for multiple configurations string list mode
* (see Multiple Configurations Edit Preference page).
*
* @since 5.3
*/
protected void updateStringListModeControl() {
updateStringListModeLink(linkStringListMode);
}
private void updateStringListModeLink(Link link) {
boolean isMultiCfg = page.isMultiCfg();
linkStringListMode.setVisible(isMultiCfg);
if (isMultiCfg) {
String modeUnknown = Messages.AbstractLangsListTab_UnknownMode;
String modeDisplay = modeUnknown;
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DMODE)) {
case CDTPrefUtil.DMODE_CONJUNCTION:
modeDisplay = Messages.AbstractLangsListTab_Conjunction;
break;
case CDTPrefUtil.DMODE_DISJUNCTION:
modeDisplay = Messages.AbstractLangsListTab_Disjunction;
break;
}
String modeWrite = modeUnknown;
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE)) {
case CDTPrefUtil.WMODE_MODIFY:
modeWrite = Messages.AbstractLangsListTab_Modify;
break;
case CDTPrefUtil.WMODE_REPLACE:
modeWrite = Messages.AbstractLangsListTab_Replace;
break;
}
linkStringListMode.setText(Messages.AbstractLangsListTab_StringListMode +
" <a href=\"workspace-settings\">"+modeDisplay+"</a> + <a href=\"workspace-settings\">"+modeWrite+"</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
linkStringListMode.getParent().layout();
}
/** /**
* Updates state for all buttons * Updates state for all buttons
* Called when table selection changes. * Called when table selection changes.
@ -265,11 +311,11 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (ent.isReadOnly()) canEdit = false; if (ent.isReadOnly()) canEdit = false;
if (ent.isReadOnly()) canDelete = false; if (ent.isReadOnly()) canDelete = false;
if (exported.contains(resolve(ent))) if (exported.contains(resolve(ent)))
buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_4); buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Unexport);
else else
buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_2); buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Export);
} else { } else {
buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_2); buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Export);
} }
boolean canMoveUp = false; boolean canMoveUp = false;
boolean canMoveDown = false; boolean canMoveDown = false;
@ -288,7 +334,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
buttonSetEnabled(BUTTON_MOVE_UP, canMoveUp && !page.isMultiCfg()); buttonSetEnabled(BUTTON_MOVE_UP, canMoveUp && !page.isMultiCfg());
buttonSetEnabled(BUTTON_MOVE_DOWN, canMoveDown && !page.isMultiCfg()); buttonSetEnabled(BUTTON_MOVE_DOWN, canMoveDown && !page.isMultiCfg());
} }
private Tree addTree(Composite comp) { private Tree addTree(Composite comp) {
langTree = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL); langTree = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
langTree.setLayoutData(new GridData(GridData.FILL_VERTICAL)); langTree.setLayoutData(new GridData(GridData.FILL_VERTICAL));
@ -316,48 +362,43 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}); });
langCol = new TreeColumn(langTree, SWT.NONE); langCol = new TreeColumn(langTree, SWT.NONE);
langCol.setText(Messages.AbstractLangsListTab_1); langCol.setText(Messages.AbstractLangsListTab_Languages);
langCol.setWidth(200); langCol.setWidth(200);
langCol.setResizable(false); langCol.setResizable(false);
langCol.setToolTipText(Messages.AbstractLangsListTab_1); langCol.setToolTipText(Messages.AbstractLangsListTab_Languages);
// langTree.getAccessible().addAccessibleListener(new AccessibleAdapter() {
// @Override
// public void getName(AccessibleEvent e) {
// e.result = UIMessages.AbstractLangsListTab_1; //$NON-NLS-1$
// }
// });
return langTree; return langTree;
} }
/* /*
* Methods to be implemented in descendants * Methods to be implemented in descendants
*/ */
public abstract int getKind(); public abstract int getKind();
public abstract ICLanguageSettingEntry doAdd(); public abstract ICLanguageSettingEntry doAdd();
public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent); public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent);
public void additionalTableSet() {} // may be not overwritten public void additionalTableSet() {} // may be not overwritten
/** /**
* Called when language changed or item added/edited/removed. * Called when language changed or item added/edited/removed.
* Refreshes whole table contwnts * Refreshes whole table contwnts
* *
* Note, this method is rewritten in Symbols tab. * Note, this method is rewritten in Symbols tab.
*/ */
public void update() { update(0); } public void update() { update(0); }
public void update(int shift) { public void update(int shift) {
if (lang != null) { if (lang != null) {
int x = table.getSelectionIndex(); int x = table.getSelectionIndex();
if (x == -1) x = 0; if (x == -1) x = 0;
else x += shift; // used only for UP/DOWN else x += shift; // used only for UP/DOWN
shownEntries = getIncs(); shownEntries = getIncs();
tv.setInput(shownEntries.toArray(new Object[shownEntries.size()])); tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
if (table.getItemCount() > x) table.setSelection(x); if (table.getItemCount() > x) table.setSelection(x);
else if (table.getItemCount() > 0) table.setSelection(0); else if (table.getItemCount() > 0) table.setSelection(0);
} }
updateLbs(lb1, lb2); updateStringListModeControl();
updateButtons(); updateButtons();
} }
@ -366,19 +407,19 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
List<ICLanguageSettingEntry> lst = getSettingEntriesList(getKind()); List<ICLanguageSettingEntry> lst = getSettingEntriesList(getKind());
if (lst != null) { if (lst != null) {
for (ICLanguageSettingEntry ent : lst) { for (ICLanguageSettingEntry ent : lst) {
if (!ent.isBuiltIn()) if (!ent.isBuiltIn())
l.add(ent); l.add(ent);
} }
if (showBIButton.getSelection()) { if (showBIButton.getSelection()) {
for (ICLanguageSettingEntry ent : lst) for (ICLanguageSettingEntry ent : lst)
if (ent.isBuiltIn()) if (ent.isBuiltIn())
l.add(ent); l.add(ent);
} }
} }
return l; return l;
} }
/** /**
* Called when configuration changed * Called when configuration changed
* Refreshes languages list and calls table refresh. * Refreshes languages list and calls table refresh.
@ -408,7 +449,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
langId = langSetting.getName(); langId = langSetting.getName();
t.setText(0, langId); t.setText(0, langId);
t.setData(langSetting); t.setData(langSetting);
if (firstItem == null) { if (firstItem == null) {
firstItem = t; firstItem = t;
lang = langSetting; lang = langSetting;
} }
@ -421,7 +462,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
update(); update();
} }
private void updateExport() { private void updateExport() {
exported = new ArrayList<ICSettingEntry>(); exported = new ArrayList<ICSettingEntry>();
ICExternalSetting[] extSettings = getResDesc().getConfiguration().getExternalSettings(); ICExternalSetting[] extSettings = getResDesc().getConfiguration().getExternalSettings();
@ -434,7 +475,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
} }
} }
private void performAdd(ICLanguageSettingEntry entry) { private void performAdd(ICLanguageSettingEntry entry) {
if (entry != null) { if (entry != null) {
fHadSomeModification= true; fHadSomeModification= true;
@ -471,7 +512,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
/** /**
* Add and/or delete entries in the case of multi-configuration selection in the drop-down box.<br/> * Add and/or delete entries in the case of multi-configuration selection in the drop-down box.<br/>
* Hint: {@code lang} keeps the selected language for each one of the selected configurations. * Hint: {@code lang} keeps the selected language for each one of the selected configurations.
* *
* @param ent - entry to add * @param ent - entry to add
* @param del - entry to delete * @param del - entry to delete
*/ */
@ -480,10 +521,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSetting[] langSettings = (ICLanguageSetting[])ms.getItems(); ICLanguageSetting[] langSettings = (ICLanguageSetting[])ms.getItems();
ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind()); ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind());
for (int i=0; i<langSettings.length; i++) { for (int i=0; i<langSettings.length; i++) {
List<ICLanguageSettingEntry> entries = List<ICLanguageSettingEntry> entries =
new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i])); new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i]));
if (del != null) { if (del != null) {
for (ICLanguageSettingEntry entry : entries) { for (ICLanguageSettingEntry entry : entries) {
if (entry.getName().equals(del.getName())) { if (entry.getName().equals(del.getName())) {
entries.remove(entry); entries.remove(entry);
break; break;
@ -495,7 +536,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
langSettings[i].setSettingEntries(getKind(), entries); langSettings[i].setSettingEntries(getKind(), entries);
} }
} }
private void performEdit(int n) { private void performEdit(int n) {
if (n == -1) return; if (n == -1) return;
ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(n).getData()); ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(n).getData());
@ -507,7 +548,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
performMulti(ent, old); performMulti(ent, old);
} else { } else {
ICLanguageSettingEntry[] del = null; ICLanguageSettingEntry[] del = null;
if (!ent.getName().equals(old.getName()) || ent.getFlags() != old.getFlags()) { if (!ent.getName().equals(old.getName()) || ent.getFlags() != old.getFlags()) {
del = new ICLanguageSettingEntry[] { old }; del = new ICLanguageSettingEntry[] { old };
} }
@ -516,7 +557,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
update(); update();
} }
} }
private void performDelete(int n) { private void performDelete(int n) {
if (n == -1) return; if (n == -1) return;
fHadSomeModification= true; fHadSomeModification= true;
@ -536,7 +577,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
changeIt(null, del); changeIt(null, del);
} }
update(); update();
} }
/** /**
* Unified buttons handler * Unified buttons handler
@ -546,7 +587,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSettingEntry old; ICLanguageSettingEntry old;
int n = table.getSelectionIndex(); int n = table.getSelectionIndex();
int ids[] = table.getSelectionIndices(); int ids[] = table.getSelectionIndices();
switch (buttonIndex) { switch (buttonIndex) {
case BUTTON_ADD: case BUTTON_ADD:
toAllCfgs = false; toAllCfgs = false;
@ -584,10 +625,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
shownEntries.remove(x - 1); shownEntries.remove(x - 1);
shownEntries.add(x - 1, old); shownEntries.add(x - 1, old);
shownEntries.add(x, old2); shownEntries.add(x, old2);
setSettingEntries(getKind(), shownEntries, false); setSettingEntries(getKind(), shownEntries, false);
update(buttonIndex == BUTTON_MOVE_UP ? -1 : 1); update(buttonIndex == BUTTON_MOVE_UP ? -1 : 1);
break; break;
default: default:
break; break;
} }
@ -616,10 +657,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (entries[j].equalsByName(ent)) { if (entries[j].equalsByName(ent)) {
ICSettingEntry[] arr = new ICSettingEntry[entries.length - 1]; ICSettingEntry[] arr = new ICSettingEntry[entries.length - 1];
int index = 0; int index = 0;
for (int k=0; k<entries.length; k++) for (int k=0; k<entries.length; k++)
if (k != j) arr[index++] = entries[k]; if (k != j) arr[index++] = entries[k];
cfg.removeExternalSetting(extSetting); cfg.removeExternalSetting(extSetting);
cfg.createExternalSetting(extSetting.getCompatibleLanguageIds(), cfg.createExternalSetting(extSetting.getCompatibleLanguageIds(),
extSetting.getCompatibleContentTypeIds(), extSetting.getCompatibleContentTypeIds(),
extSetting.getCompatibleExtensions(), extSetting.getCompatibleExtensions(),
arr); arr);
@ -629,18 +670,18 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
} }
} }
/** /**
* Adds entry to all configurations * Adds entry to all configurations
* @param ent - entry to add * @param ent - entry to add
*/ */
private void addToAll(ICLanguageSettingEntry ent) { private void addToAll(ICLanguageSettingEntry ent) {
ICResourceDescription curRcDes = page.getResDesc(); ICResourceDescription curRcDes = page.getResDesc();
String id = lang.getName(); // getLanguageId() sometimes returns null. String id = lang.getName(); // getLanguageId() sometimes returns null.
for (ICConfigurationDescription cfgDes : page.getCfgsEditable()) { for (ICConfigurationDescription cfgDes : page.getCfgsEditable()) {
ICResourceDescription rcDes = page.getResDesc(cfgDes); ICResourceDescription rcDes = page.getResDesc(cfgDes);
if (rcDes == null) if (rcDes == null)
continue; continue;
if (!toAllCfgs && !(curRcDes.equals(rcDes))) if (!toAllCfgs && !(curRcDes.equals(rcDes)))
continue; continue;
@ -653,7 +694,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
} }
} }
@Override @Override
protected void performApply(ICResourceDescription src, ICResourceDescription dst) { protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
fHadSomeModification= false; fHadSomeModification= false;
@ -662,7 +703,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (dst instanceof ICMultiItemsHolder) { if (dst instanceof ICMultiItemsHolder) {
for (Object item : ((ICMultiItemsHolder)dst).getItems()) { for (Object item : ((ICMultiItemsHolder)dst).getItems()) {
if (item instanceof ICResourceDescription) { if (item instanceof ICResourceDescription) {
ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)item); ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)item);
if (ds == null || sr.length != ds.length) return; if (ds == null || sr.length != ds.length) return;
for (int i=0; i<sr.length; i++) { for (int i=0; i<sr.length; i++) {
ICLanguageSettingEntry[] ents = null; ICLanguageSettingEntry[] ents = null;
@ -681,9 +722,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ents = sr[i].getSettingEntries(getKind()); ents = sr[i].getSettingEntries(getKind());
ds[i].setSettingEntries(getKind(), ents); ds[i].setSettingEntries(getKind(), ents);
} }
} }
} }
@Override @Override
protected void performDefaults() { protected void performDefaults() {
fHadSomeModification= true; fHadSomeModification= true;
@ -696,7 +737,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
updateData(this.getResDesc()); updateData(this.getResDesc());
} }
// Extended label provider // Extended label provider
private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{ private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
public RichLabelProvider(){} public RichLabelProvider(){}
@ -739,17 +780,17 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (columnIndex == 0) { if (columnIndex == 0) {
String s = le.getName(); String s = le.getName();
if (exported.contains(resolve(le))) if (exported.contains(resolve(le)))
s = s + Messages.AbstractLangsListTab_3; s = s + Messages.AbstractLangsListTab_ExportIndicator;
return s; return s;
} }
if (le.getKind() == ICSettingEntry.MACRO) { if (le.getKind() == ICSettingEntry.MACRO) {
switch (columnIndex) { switch (columnIndex) {
case 1: return le.getValue(); case 1: return le.getValue();
} }
} }
return EMPTY_STR; return EMPTY_STR;
} }
public Font getFont(Object element) { public Font getFont(Object element) {
if (! (element instanceof ICLanguageSettingEntry)) return null; if (! (element instanceof ICLanguageSettingEntry)) return null;
ICLanguageSettingEntry le = (ICLanguageSettingEntry) element; ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
@ -769,7 +810,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICFolderDescription foDes = (ICFolderDescription)rcDes; ICFolderDescription foDes = (ICFolderDescription)rcDes;
if (foDes instanceof ICMultiFolderDescription) { if (foDes instanceof ICMultiFolderDescription) {
return getLS((ICMultiFolderDescription)foDes); return getLS((ICMultiFolderDescription)foDes);
} }
return foDes.getLanguageSettings(); return foDes.getLanguageSettings();
case ICSettingBase.SETTING_FILE: case ICSettingBase.SETTING_FILE:
ICFileDescription fiDes = (ICFileDescription)rcDes; ICFileDescription fiDes = (ICFileDescription)rcDes;
@ -778,10 +819,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
return null; return null;
} }
private ICLanguageSetting[] getLS(ICMultiFolderDescription foDes) { private ICLanguageSetting[] getLS(ICMultiFolderDescription foDes) {
ICLanguageSetting[] lsets; ICLanguageSetting[] lsets;
ICLanguageSetting[][] lsArray2D = foDes.getLanguageSettingsM(comp); ICLanguageSetting[][] lsArray2D = foDes.getLanguageSettingsM(comp);
ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(lsArray2D, comp)); ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(lsArray2D, comp));
lsets = new ICLanguageSetting[fs.length]; lsets = new ICLanguageSetting[fs.length];
@ -800,7 +841,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
return lsets; return lsets;
} }
@Override @Override
public boolean canBeVisible() { public boolean canBeVisible() {
if (getResDesc() == null) return true; if (getResDesc() == null) return true;
@ -812,7 +853,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
return false; return false;
} }
private void setSettingEntries(int kind, List<ICLanguageSettingEntry> incs, boolean toAll) { private void setSettingEntries(int kind, List<ICLanguageSettingEntry> incs, boolean toAll) {
if (page.isMultiCfg()) { if (page.isMultiCfg()) {
((ICMultiResourceDescription)getResDesc()).setSettingEntries(lang, kind, incs, toAll); ((ICMultiResourceDescription)getResDesc()).setSettingEntries(lang, kind, incs, toAll);
@ -826,10 +867,10 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSettingEntry[] out = new ICLanguageSettingEntry[res.length]; ICLanguageSettingEntry[] out = new ICLanguageSettingEntry[res.length];
System.arraycopy(res, 0, out, 0, res.length); System.arraycopy(res, 0, out, 0, res.length);
return Arrays.asList(out); return Arrays.asList(out);
} }
return lang.getSettingEntriesList(kind); return lang.getSettingEntriesList(kind);
} }
private ICLanguageSetting[] conv2LS(Object[] ob) { private ICLanguageSetting[] conv2LS(Object[] ob) {
ICLanguageSetting[] se = new ICLanguageSetting[ob.length]; ICLanguageSetting[] se = new ICLanguageSetting[ob.length];
System.arraycopy(ob, 0, se, 0, ob.length); System.arraycopy(ob, 0, se, 0, ob.length);
@ -846,14 +887,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
/** /**
* Returns whether the tab was modified by the user in any way. The flag is * Returns whether the tab was modified by the user in any way. The flag is
* cleared after pressing apply or ok. * cleared after pressing apply or ok.
* @since 5.1 * @since 5.1
*/ */
protected final boolean hadSomeModification() { protected final boolean hadSomeModification() {
return fHadSomeModification; return fHadSomeModification;
} }
@Override @Override
protected final boolean isIndexerAffected() { protected final boolean isIndexerAffected() {
switch(getKind()) { switch(getKind()) {

View file

@ -94,7 +94,7 @@ public class SymbolTab extends AbstractLangsListTab {
else if (table.getItemCount() > 0) else if (table.getItemCount() > 0)
table.setSelection(0); table.setSelection(0);
} }
updateLbs(lb1, lb2); updateStringListModeControl();
updateButtons(); updateButtons();
} }