mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Bug 176909: No way to change order of include directories
This commit is contained in:
parent
9051537052
commit
4eb3deed35
2 changed files with 109 additions and 37 deletions
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
@ -66,10 +67,16 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
// protected boolean showBI = false;
|
// protected boolean showBI = false;
|
||||||
// boolean savedShowBI = false;
|
// boolean savedShowBI = false;
|
||||||
protected ICLanguageSetting lang;
|
protected ICLanguageSetting lang;
|
||||||
protected List incs;
|
protected LinkedList incs;
|
||||||
protected List exported;
|
protected ArrayList exported;
|
||||||
protected SashForm sashForm;
|
protected SashForm sashForm;
|
||||||
|
|
||||||
|
protected final static String[] BUTTONS = {ADD_STR, EDIT_STR, DEL_STR,
|
||||||
|
NewUIMessages.getResourceString("AbstractLangsListTab.2"), //$NON-NLS-1$
|
||||||
|
null, MOVEUP_STR, MOVEDOWN_STR };
|
||||||
|
protected final static String[] BUTTSYM = {ADD_STR, EDIT_STR, DEL_STR,
|
||||||
|
NewUIMessages.getResourceString("AbstractLangsListTab.2")}; //$NON-NLS-1$
|
||||||
|
|
||||||
private final static Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
|
private final static Image IMG_FS = CPluginImages.get(CPluginImages.IMG_FILESYSTEM);
|
||||||
private final static Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
|
private final static Image IMG_WS = CPluginImages.get(CPluginImages.IMG_WORKSPACE);
|
||||||
private final static Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
|
private final static Image IMG_MK = CPluginImages.get(CPluginImages.IMG_OBJS_MACRO);
|
||||||
|
@ -149,27 +156,38 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
additionalTableSet();
|
additionalTableSet();
|
||||||
initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR, NewUIMessages.getResourceString("AbstractLangsListTab.2")}); //$NON-NLS-1$
|
initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS);
|
||||||
updateData(getResDesc());
|
updateData(getResDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates state of add/edit/delete buttons
|
* Updates state for all buttons
|
||||||
* Called when table selection changes.
|
* Called when table selection changes.
|
||||||
*/
|
*/
|
||||||
public void updateButtons() {
|
public void updateButtons() {
|
||||||
int i = table.getSelectionIndex();
|
int index = table.getSelectionIndex();
|
||||||
boolean x = i != -1;
|
boolean canAdd = langTree.getItemCount() > 0;
|
||||||
boolean y = x;
|
boolean canExport = index != -1;
|
||||||
if (x) {
|
boolean canEdit = canExport;
|
||||||
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)(table.getItem(i).getData());
|
boolean canDelete = canEdit;
|
||||||
if (ent.isReadOnly()) x = false;
|
if (canExport) {
|
||||||
if (ent.isBuiltIn() || ent.isReadOnly()) y = false;
|
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)(table.getItem(index).getData());
|
||||||
|
if (ent.isReadOnly()) canEdit = false;
|
||||||
|
if (ent.isBuiltIn() || ent.isReadOnly()) canDelete = false;
|
||||||
}
|
}
|
||||||
buttonSetEnabled(0, langTree.getItemCount() > 0);
|
boolean canMoveUp = canDelete && index > 0;
|
||||||
buttonSetEnabled(1, x);
|
boolean canMoveDown = canDelete && (index < table.getItemCount() - 1);
|
||||||
buttonSetEnabled(2, y);
|
if (canMoveDown && showBIButton.getSelection()) {
|
||||||
|
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)(table.getItem(index+1).getData());
|
||||||
|
if (ent.isBuiltIn()) canMoveDown = false; // cannot exchange with built in
|
||||||
|
}
|
||||||
|
buttonSetEnabled(0, canAdd); // add
|
||||||
|
buttonSetEnabled(1, canEdit); // edit
|
||||||
|
buttonSetEnabled(2, canDelete); // delete
|
||||||
|
buttonSetEnabled(3, canExport); // export
|
||||||
|
// there is a separator instead of button #4
|
||||||
|
buttonSetEnabled(5, canMoveUp); // up
|
||||||
|
buttonSetEnabled(6, canMoveDown); // down
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tree addTree(Composite comp) {
|
private Tree addTree(Composite comp) {
|
||||||
|
@ -212,29 +230,37 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() { update(0); }
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
ArrayList lst = new ArrayList();
|
incs = new LinkedList();
|
||||||
|
List lst = lang.getSettingEntriesList(getKind());
|
||||||
incs = lang.getSettingEntriesList(getKind());
|
if (lst != null) {
|
||||||
if (incs == null) incs = new ArrayList(0);
|
Iterator it = lst.iterator();
|
||||||
Iterator it = incs.iterator();
|
|
||||||
boolean userOnly = !showBIButton.getSelection();
|
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)it.next();
|
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)it.next();
|
||||||
|
if (!ent.isBuiltIn()) incs.add(ent);
|
||||||
if (ent.isBuiltIn() && userOnly)
|
|
||||||
continue; // do not show built-in values
|
|
||||||
lst.add(ent);
|
|
||||||
}
|
}
|
||||||
Collections.sort(lst, CDTListComparator.getInstance());
|
if (showBIButton.getSelection()) {
|
||||||
tv.setInput(lst.toArray(new Object[lst.size()]));
|
ArrayList lstS = new ArrayList();
|
||||||
|
it = lst.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)it.next();
|
||||||
|
if (ent.isBuiltIn()) lstS.add(ent);
|
||||||
|
}
|
||||||
|
Collections.sort(lstS, CDTListComparator.getInstance());
|
||||||
|
incs.addAll(lstS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tv.setInput(incs.toArray(new Object[incs.size()]));
|
||||||
if (table.getItemCount() > x) table.select(x);
|
if (table.getItemCount() > x) table.select(x);
|
||||||
else if (table.getItemCount() > 0) table.select(0);
|
else if (table.getItemCount() > 0) table.select(0);
|
||||||
}
|
}
|
||||||
|
@ -285,7 +311,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Unified "Add/Edit/Delete" buttons handler
|
* Unified buttons handler
|
||||||
*/
|
*/
|
||||||
public void buttonPressed(int i) {
|
public void buttonPressed(int i) {
|
||||||
ICLanguageSettingEntry ent;
|
ICLanguageSettingEntry ent;
|
||||||
|
@ -312,8 +338,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
if (old.isReadOnly()) return;
|
if (old.isReadOnly()) return;
|
||||||
ent = doEdit(old);
|
ent = doEdit(old);
|
||||||
if (ent != null) {
|
if (ent != null) {
|
||||||
incs.remove(old);
|
int toModify = incs.indexOf(old);
|
||||||
incs.add(ent);
|
incs.remove(toModify);
|
||||||
|
incs.add(toModify, ent);
|
||||||
lang.setSettingEntries(getKind(), incs);
|
lang.setSettingEntries(getKind(), incs);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -332,6 +359,23 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||||
page.getResDesc().getConfiguration().createExternalSetting(new String[] {lang.getId()}, null, null, new ICLanguageSettingEntry[] {old});
|
page.getResDesc().getConfiguration().createExternalSetting(new String[] {lang.getId()}, null, null, new ICLanguageSettingEntry[] {old});
|
||||||
updateExport();
|
updateExport();
|
||||||
update();
|
update();
|
||||||
|
break;
|
||||||
|
// there is a separator instead of button #4
|
||||||
|
case 5: // move up
|
||||||
|
case 6: // move down
|
||||||
|
old = (ICLanguageSettingEntry)(table.getItem(n).getData());
|
||||||
|
int x = incs.indexOf(old);
|
||||||
|
if (x < 0) break;
|
||||||
|
if (i == 6) x++; // "down" simply means "up underlying item"
|
||||||
|
old = (ICLanguageSettingEntry)incs.get(x);
|
||||||
|
ICLanguageSettingEntry old2 = (ICLanguageSettingEntry)incs.get(x - 1);
|
||||||
|
incs.remove(x);
|
||||||
|
incs.remove(x - 1);
|
||||||
|
incs.add(x - 1, old);
|
||||||
|
incs.add(x, old2);
|
||||||
|
lang.setSettingEntries(getKind(), incs);
|
||||||
|
update(i == 5 ? -1 : 1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.newui;
|
package org.eclipse.cdt.ui.newui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
|
@ -18,7 +23,6 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
|
||||||
public class SymbolTab extends AbstractLangsListTab {
|
public class SymbolTab extends AbstractLangsListTab {
|
||||||
|
|
||||||
public void additionalTableSet() {
|
public void additionalTableSet() {
|
||||||
TableColumn tc = new TableColumn(table, SWT.LEFT);
|
TableColumn tc = new TableColumn(table, SWT.LEFT);
|
||||||
tc.setText(NewUIMessages.getResourceString("SymbolTab.0")); //$NON-NLS-1$
|
tc.setText(NewUIMessages.getResourceString("SymbolTab.0")); //$NON-NLS-1$
|
||||||
|
@ -51,4 +55,28 @@ public class SymbolTab extends AbstractLangsListTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getKind() { return ICSettingEntry.MACRO; }
|
public int getKind() { return ICSettingEntry.MACRO; }
|
||||||
|
|
||||||
|
// Specific version of "update()" for Symbols tab only
|
||||||
|
public void update() {
|
||||||
|
if (lang != null) {
|
||||||
|
int x = table.getSelectionIndex();
|
||||||
|
if (x == -1) x = 0;
|
||||||
|
|
||||||
|
ArrayList lst = new ArrayList();
|
||||||
|
incs = new LinkedList(lang.getSettingEntriesList(getKind()));
|
||||||
|
if (incs != null) {
|
||||||
|
Iterator it = incs.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ICLanguageSettingEntry ent = (ICLanguageSettingEntry)it.next();
|
||||||
|
if (!(ent.isBuiltIn() && (!showBIButton.getSelection()))) lst.add(ent);
|
||||||
|
}
|
||||||
|
Collections.sort(lst, CDTListComparator.getInstance());
|
||||||
|
}
|
||||||
|
tv.setInput(lst.toArray(new Object[lst.size()]));
|
||||||
|
if (table.getItemCount() > x) table.select(x);
|
||||||
|
else if (table.getItemCount() > 0) table.select(0);
|
||||||
|
}
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue