mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-09 11:33:20 +02:00
bug 274684: Indicators of string list modes for multi-configuration edits look like debug texts
Added higher level getter and setter for dealing with the string list properties in consistent way
This commit is contained in:
parent
b9c7e81375
commit
7047d32a98
6 changed files with 98 additions and 34 deletions
|
@ -82,16 +82,14 @@ public class PropertyMultiCfgTab extends AbstractCPropertyTab {
|
||||||
w_1 = new Button(wGrp, SWT.RADIO);
|
w_1 = new Button(wGrp, SWT.RADIO);
|
||||||
w_1.setText(Messages.PropertyMultiCfgTab_11);
|
w_1.setText(Messages.PropertyMultiCfgTab_11);
|
||||||
|
|
||||||
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DMODE)) {
|
switch (CDTPrefUtil.getMultiCfgStringListDisplayMode()) {
|
||||||
case CDTPrefUtil.DMODE_CONJUNCTION: d_1.setSelection(true); break;
|
case CDTPrefUtil.DMODE_CONJUNCTION: d_1.setSelection(true); break;
|
||||||
case CDTPrefUtil.DMODE_DISJUNCTION: d_2.setSelection(true); break;
|
case CDTPrefUtil.DMODE_DISJUNCTION: d_2.setSelection(true); break;
|
||||||
default: d_1.setSelection(true); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE)) {
|
switch (CDTPrefUtil.getMultiCfgStringListWriteMode()) {
|
||||||
case CDTPrefUtil.WMODE_MODIFY: w_0.setSelection(true); break;
|
case CDTPrefUtil.WMODE_MODIFY: w_0.setSelection(true); break;
|
||||||
case CDTPrefUtil.WMODE_REPLACE: w_1.setSelection(true); break;
|
case CDTPrefUtil.WMODE_REPLACE: w_1.setSelection(true); break;
|
||||||
default: w_0.setSelection(true); break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,13 +100,13 @@ public class PropertyMultiCfgTab extends AbstractCPropertyTab {
|
||||||
x = CDTPrefUtil.DMODE_CONJUNCTION;
|
x = CDTPrefUtil.DMODE_CONJUNCTION;
|
||||||
else if (d_2.getSelection())
|
else if (d_2.getSelection())
|
||||||
x = CDTPrefUtil.DMODE_DISJUNCTION;
|
x = CDTPrefUtil.DMODE_DISJUNCTION;
|
||||||
CDTPrefUtil.setInt(CDTPrefUtil.KEY_DMODE, x);
|
CDTPrefUtil.setMultiCfgStringListDisplayMode(x);
|
||||||
|
|
||||||
if (w_0.getSelection())
|
if (w_0.getSelection())
|
||||||
x = CDTPrefUtil.WMODE_MODIFY;
|
x = CDTPrefUtil.WMODE_MODIFY;
|
||||||
else if (w_1.getSelection())
|
else if (w_1.getSelection())
|
||||||
x = CDTPrefUtil.WMODE_REPLACE;
|
x = CDTPrefUtil.WMODE_REPLACE;
|
||||||
CDTPrefUtil.setInt(CDTPrefUtil.KEY_WMODE, x);
|
CDTPrefUtil.setMultiCfgStringListWriteMode(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class CPropertyVarsTab extends AbstractCPropertyTab {
|
||||||
private void replaceMacros() {
|
private void replaceMacros() {
|
||||||
if (!page.isMultiCfg() ||
|
if (!page.isMultiCfg() ||
|
||||||
cfgd == null ||
|
cfgd == null ||
|
||||||
CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE) != CDTPrefUtil.WMODE_REPLACE)
|
CDTPrefUtil.getMultiCfgStringListWriteMode() != CDTPrefUtil.WMODE_REPLACE)
|
||||||
return;
|
return;
|
||||||
ICdtVariable[] vars = getVariables();
|
ICdtVariable[] vars = getVariables();
|
||||||
for (int i=0; i<vars.length; i++)
|
for (int i=0; i<vars.length; i++)
|
||||||
|
|
|
@ -705,7 +705,7 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
|
||||||
* entries are preserved.
|
* entries are preserved.
|
||||||
*/
|
*/
|
||||||
protected boolean isWModifyMode() {
|
protected boolean isWModifyMode() {
|
||||||
int wmode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE);
|
int wmode = CDTPrefUtil.getMultiCfgStringListWriteMode();
|
||||||
return (wmode == CDTPrefUtil.WMODE_MODIFY);
|
return (wmode == CDTPrefUtil.WMODE_MODIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,18 @@ public class CDTPrefUtil {
|
||||||
public static final int DISC_NAMING_ALWAYS_IDS = 3;
|
public static final int DISC_NAMING_ALWAYS_IDS = 3;
|
||||||
public static final int DISC_NAMING_DEFAULT = DISC_NAMING_UNIQUE_OR_BOTH;
|
public static final int DISC_NAMING_DEFAULT = DISC_NAMING_UNIQUE_OR_BOTH;
|
||||||
|
|
||||||
|
/** Property key used for string list display mode for multi-configuration edits (conjunction/disjunction) */
|
||||||
public static final String KEY_DMODE = "properties.multi.displ.mode"; //$NON-NLS-1$
|
public static final String KEY_DMODE = "properties.multi.displ.mode"; //$NON-NLS-1$
|
||||||
|
/** Conjunction implies showing only common elements (intersection) */
|
||||||
public static final int DMODE_CONJUNCTION = 1;
|
public static final int DMODE_CONJUNCTION = 1;
|
||||||
|
/** Disjunction implies showing all elements (union) */
|
||||||
public static final int DMODE_DISJUNCTION = 2;
|
public static final int DMODE_DISJUNCTION = 2;
|
||||||
|
|
||||||
|
/** Property key used for string list write mode for multi-configuration edits (modify/replace) */
|
||||||
public static final String KEY_WMODE = "properties.multi.write.mode"; //$NON-NLS-1$
|
public static final String KEY_WMODE = "properties.multi.write.mode"; //$NON-NLS-1$
|
||||||
|
/** Modify implies changing only given elements and not changing any others */
|
||||||
public static final int WMODE_MODIFY = 4;
|
public static final int WMODE_MODIFY = 4;
|
||||||
|
/** Replace implies replacing the whole list with the given one, overwriting old entries */
|
||||||
public static final int WMODE_REPLACE = 8;
|
public static final int WMODE_REPLACE = 8;
|
||||||
|
|
||||||
public static final String NULL = "NULL"; //$NON-NLS-1$
|
public static final String NULL = "NULL"; //$NON-NLS-1$
|
||||||
|
@ -115,17 +121,69 @@ public class CDTPrefUtil {
|
||||||
setStr(KEY_PREFTC, b.toString().trim());
|
setStr(KEY_PREFTC, b.toString().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns string list display mode for multi-configuration edits (conjunction/disjunction).
|
||||||
|
*
|
||||||
|
* @return the mode which can be either {@link CDTPrefUtil#DMODE_CONJUNCTION} (default value)
|
||||||
|
* or else {@link CDTPrefUtil#DMODE_DISJUNCTION}.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static int getMultiCfgStringListDisplayMode() {
|
||||||
|
int mode = getInt(KEY_DMODE);
|
||||||
|
if (mode!=DMODE_CONJUNCTION && mode!=DMODE_DISJUNCTION) {
|
||||||
|
mode = DMODE_CONJUNCTION;
|
||||||
|
}
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets string list display mode for multi-configuration edits (conjunction/disjunction).
|
||||||
|
*
|
||||||
|
* @param mode must be either {@link CDTPrefUtil#DMODE_CONJUNCTION}
|
||||||
|
* or {@link CDTPrefUtil#DMODE_DISJUNCTION}.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static void setMultiCfgStringListDisplayMode(int mode) {
|
||||||
|
setInt(KEY_DMODE, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns string list write mode for multi-configuration edits (modify/replace).
|
||||||
|
*
|
||||||
|
* @return the mode which can be either {@link CDTPrefUtil#WMODE_MODIFY} (default value)
|
||||||
|
* or else {@link CDTPrefUtil#WMODE_REPLACE}.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static int getMultiCfgStringListWriteMode() {
|
||||||
|
int mode = getInt(KEY_WMODE);
|
||||||
|
if (mode!=WMODE_MODIFY && mode!=WMODE_REPLACE) {
|
||||||
|
mode = WMODE_MODIFY;
|
||||||
|
}
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets string list write mode for multi-configuration edits (modify/replace).
|
||||||
|
*
|
||||||
|
* @param mode must be either {@link CDTPrefUtil#WMODE_MODIFY}
|
||||||
|
* or {@link CDTPrefUtil#WMODE_REPLACE}.
|
||||||
|
*
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static void setMultiCfgStringListWriteMode(int mode) {
|
||||||
|
setInt(KEY_WMODE, mode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
|
* @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("fallthrough")
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getDMode() {
|
public static String getDMode() {
|
||||||
String s = null;
|
String s = null;
|
||||||
switch(getInt(KEY_DMODE)) {
|
switch(getMultiCfgStringListDisplayMode()) {
|
||||||
default:
|
|
||||||
setInt(KEY_DMODE, DMODE_CONJUNCTION);
|
|
||||||
// fallthrough
|
|
||||||
case DMODE_CONJUNCTION:
|
case DMODE_CONJUNCTION:
|
||||||
s = Messages.EnvironmentTab_17;
|
s = Messages.EnvironmentTab_17;
|
||||||
break;
|
break;
|
||||||
|
@ -139,14 +197,10 @@ public class CDTPrefUtil {
|
||||||
/**
|
/**
|
||||||
* @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
|
* @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("fallthrough")
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getWMode() {
|
public static String getWMode() {
|
||||||
String s = null;
|
String s = null;
|
||||||
switch(getInt(KEY_WMODE)) {
|
switch(getMultiCfgStringListWriteMode()) {
|
||||||
default:
|
|
||||||
setInt(KEY_WMODE, WMODE_MODIFY);
|
|
||||||
// fallthrough
|
|
||||||
case WMODE_MODIFY:
|
case WMODE_MODIFY:
|
||||||
s = Messages.EnvironmentTab_24;
|
s = Messages.EnvironmentTab_24;
|
||||||
break;
|
break;
|
||||||
|
@ -157,33 +211,45 @@ public class CDTPrefUtil {
|
||||||
return Messages.EnvironmentTab_22 + s;
|
return Messages.EnvironmentTab_22 + s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle string list display mode: conjunction <-> disjunction.
|
||||||
|
*/
|
||||||
public static void spinDMode() {
|
public static void spinDMode() {
|
||||||
setInt(KEY_DMODE,
|
int mode = getMultiCfgStringListDisplayMode();
|
||||||
((getInt(KEY_DMODE) == DMODE_CONJUNCTION) ?
|
if (mode==DMODE_CONJUNCTION) {
|
||||||
DMODE_DISJUNCTION :
|
mode = DMODE_DISJUNCTION;
|
||||||
DMODE_CONJUNCTION));
|
} else {
|
||||||
|
mode = DMODE_CONJUNCTION;
|
||||||
|
}
|
||||||
|
setMultiCfgStringListDisplayMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle string list display mode: modify <-> replace.
|
||||||
|
*/
|
||||||
public static void spinWMode() {
|
public static void spinWMode() {
|
||||||
setInt(KEY_WMODE,
|
int mode = getMultiCfgStringListWriteMode();
|
||||||
((getInt(KEY_WMODE) == WMODE_MODIFY) ?
|
if (mode==WMODE_MODIFY) {
|
||||||
WMODE_REPLACE :
|
mode = WMODE_REPLACE;
|
||||||
WMODE_MODIFY));
|
} else {
|
||||||
|
mode = WMODE_MODIFY;
|
||||||
|
}
|
||||||
|
setMultiCfgStringListWriteMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String[] getStrListForDisplay(String[][] input) {
|
public static final String[] getStrListForDisplay(String[][] input) {
|
||||||
return getStrListForDisplay(input, getInt(KEY_DMODE));
|
return getStrListForDisplay(input, getMultiCfgStringListDisplayMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] getStrListForDisplay(String[][] input, int mode) {
|
private static final String[] getStrListForDisplay(String[][] input, int mode) {
|
||||||
Object[] ob = getListForDisplay(input, getInt(KEY_DMODE), null);
|
Object[] ob = getListForDisplay(input, getMultiCfgStringListDisplayMode(), null);
|
||||||
String[] ss = new String[ob.length];
|
String[] ss = new String[ob.length];
|
||||||
System.arraycopy(ob, 0, ss, 0, ob.length);
|
System.arraycopy(ob, 0, ss, 0, ob.length);
|
||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Object[] getListForDisplay(Object[][] input, Comparator<Object> cmp) {
|
public static final Object[] getListForDisplay(Object[][] input, Comparator<Object> cmp) {
|
||||||
return getListForDisplay(input, getInt(KEY_DMODE), cmp);
|
return getListForDisplay(input, getMultiCfgStringListDisplayMode(), cmp);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Utility method forms string list
|
* Utility method forms string list
|
||||||
|
@ -205,7 +271,7 @@ public class CDTPrefUtil {
|
||||||
if (s1 == null ||
|
if (s1 == null ||
|
||||||
s1.length == 0)
|
s1.length == 0)
|
||||||
return EMPTY_ARRAY;
|
return EMPTY_ARRAY;
|
||||||
if (getInt(KEY_DMODE) == DMODE_CONJUNCTION)
|
if (getMultiCfgStringListDisplayMode() == DMODE_CONJUNCTION)
|
||||||
{
|
{
|
||||||
ArrayList<Object> lst = new ArrayList<Object>();
|
ArrayList<Object> lst = new ArrayList<Object>();
|
||||||
for (int i=0; i<s1.length; i++) {
|
for (int i=0; i<s1.length; i++) {
|
||||||
|
|
|
@ -164,12 +164,12 @@ public class MultiCfgContributedEnvironment implements IContributedEnvironment {
|
||||||
|
|
||||||
private int getDispMode(ICConfigurationDescription des) {
|
private int getDispMode(ICConfigurationDescription des) {
|
||||||
if (isMulti && des instanceof MultiItemsHolder)
|
if (isMulti && des instanceof MultiItemsHolder)
|
||||||
return CDTPrefUtil.getInt(CDTPrefUtil.KEY_DMODE);
|
return CDTPrefUtil.getMultiCfgStringListDisplayMode();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isModifyMode() {
|
private boolean isModifyMode() {
|
||||||
int wmode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE);
|
int wmode = CDTPrefUtil.getMultiCfgStringListWriteMode();
|
||||||
return (wmode == CDTPrefUtil.WMODE_MODIFY);
|
return (wmode == CDTPrefUtil.WMODE_MODIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class StringListModeControl {
|
||||||
if (isMultiCfg) {
|
if (isMultiCfg) {
|
||||||
String modeUnknown = Messages.AbstractLangsListTab_UnknownMode;
|
String modeUnknown = Messages.AbstractLangsListTab_UnknownMode;
|
||||||
String modeDisplay = modeUnknown;
|
String modeDisplay = modeUnknown;
|
||||||
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DMODE)) {
|
switch (CDTPrefUtil.getMultiCfgStringListDisplayMode()) {
|
||||||
case CDTPrefUtil.DMODE_CONJUNCTION:
|
case CDTPrefUtil.DMODE_CONJUNCTION:
|
||||||
modeDisplay = Messages.AbstractLangsListTab_Conjunction;
|
modeDisplay = Messages.AbstractLangsListTab_Conjunction;
|
||||||
break;
|
break;
|
||||||
|
@ -116,7 +116,7 @@ public class StringListModeControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
String modeWrite = modeUnknown;
|
String modeWrite = modeUnknown;
|
||||||
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_WMODE)) {
|
switch (CDTPrefUtil.getMultiCfgStringListWriteMode()) {
|
||||||
case CDTPrefUtil.WMODE_MODIFY:
|
case CDTPrefUtil.WMODE_MODIFY:
|
||||||
modeWrite = Messages.AbstractLangsListTab_Modify;
|
modeWrite = Messages.AbstractLangsListTab_Modify;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue