1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Unexport feature added

This commit is contained in:
Oleg Krasilnikov 2007-04-20 12:48:09 +00:00
parent f7d244ff58
commit 82d511bba1
3 changed files with 65 additions and 2 deletions

View file

@ -240,6 +240,12 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
*/
protected void buttonPressed(int i) {}
/**
* Checks state of existing button.
*
* @param i - button index
* @return - true if button exists and enabled
*/
protected boolean buttonIsEnabled(int i) {
if (buttons == null || buttons.length <= i )
return false;
@ -247,10 +253,29 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
return buttons[i].isEnabled();
}
/**
* Changes state of existing button.
* Does nothing if index is invalid
*
* @param i - button index
* @param state - required state
*/
protected void buttonSetEnabled(int i, boolean state) {
if (buttons == null || buttons.length <= i ) return;
buttons[i].setEnabled(state);
}
/**
* Changes text of existing button
* Does nothing if index is invalid
*
* @param i - button index
* @param text - text to display
*/
protected void buttonSetText(int i, String text) {
if (buttons == null || buttons.length <= i ) return;
buttons[i].setText(text);
}
/**********************************************
* Utility methods for unified widget creation

View file

@ -176,6 +176,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)(table.getItem(index).getData());
if (ent.isBuiltIn() || ent.isReadOnly()) canEdit = false;
if (ent.isReadOnly()) canDelete = false;
if (exported.contains(ent))
buttonSetText(3, UIMessages.getString("AbstractLangsListTab.4")); //$NON-NLS-1$
else
buttonSetText(3, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$
} else {
buttonSetText(3, UIMessages.getString("AbstractLangsListTab.2")); //$NON-NLS-1$
}
boolean canMoveUp = canDelete && index > 0;
boolean canMoveDown = canDelete && (index < table.getItemCount() - 1);
@ -367,10 +373,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
lang.setSettingEntries(getKind(), incs);
update();
break;
case 3: // export
case 3: // toggle export
if (n == -1) return;
old = (ICLanguageSettingEntry)(table.getItem(n).getData());
page.getResDesc().getConfiguration().createExternalSetting(new String[] {lang.getId()}, null, null, new ICLanguageSettingEntry[] {old});
if (exported.contains(old)) {
deleteExportSetting(old);
} else {
page.getResDesc().getConfiguration().createExternalSetting(new String[] {lang.getId()}, null, null, new ICLanguageSettingEntry[] {old});
}
updateExport();
update();
break;
@ -395,6 +405,33 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
}
}
private void deleteExportSetting(ICSettingEntry ent) {
// if (ent.isReadOnly() || ent.isBuiltIn()) continue;
ICConfigurationDescription cfg = getResDesc().getConfiguration();
ICExternalSetting[] vals = cfg.getExternalSettings();
if (!(vals == null || vals.length == 0)) {
for (int i=0; i<vals.length; i++) {
ICSettingEntry[] ents = vals[i].getEntries(getKind());
if (ents == null || ents.length == 0) continue;
for (int j=0; j<ents.length; j++) {
if (ents[j].equalsByName(ent)) {
ICSettingEntry[] arr = new ICSettingEntry[ents.length - 1];
int index = 0;
for (int k=0; k<ents.length; k++)
if (k != j) arr[index++] = ents[k];
cfg.removeExternalSetting(vals[i]);
cfg.createExternalSetting(vals[i].getCompatibleLanguageIds(),
vals[i].getCompatibleContentTypeIds(),
vals[i].getCompatibleExtensions(),
arr);
return;
}
}
}
}
}
/**
* Adds entry to all configurations
* @param ent - entry to add

View file

@ -406,6 +406,7 @@ AbstractLangsListTab.0=Show built-in values
AbstractLangsListTab.1=Languages
AbstractLangsListTab.2=Export
AbstractLangsListTab.3=\ [exp]
AbstractLangsListTab.4=Unexport
AbstractPrefPage.0=Preference settings will be applied to new projects\n
AbstractPrefPage.1=only in case when there was no toolchains selected.
AbstractExportTab.0=[All]