Merging mk branch revs. 587:589 (tool tips for statistics data fields), part 2
This commit is contained in:
parent
8e87ce1720
commit
0ec063bcff
@ -18,25 +18,28 @@ import eva2.gui.BeanInspector;
|
||||
public class StringSelection implements Serializable {
|
||||
private static final long serialVersionUID = -1512329288445831907L;
|
||||
private String[] strObjects;
|
||||
private String[] toolTips;
|
||||
boolean[] selStates;
|
||||
private transient HashMap<String,Integer> stringToIndexHash = null;
|
||||
private transient Class<? extends Enum> enumClass = null;
|
||||
|
||||
public StringSelection(String[] sArr) {
|
||||
public StringSelection(String[] sArr, String[] tips) {
|
||||
strObjects = sArr;
|
||||
toolTips=tips;
|
||||
selStates=new boolean[sArr.length];
|
||||
stringToIndexHash = null;
|
||||
enumClass = null;
|
||||
}
|
||||
|
||||
public StringSelection(String[] sArr, int initialSel) {
|
||||
this(sArr);
|
||||
public StringSelection(String[] sArr, String[] tips, int initialSel) {
|
||||
this(sArr, tips);
|
||||
if (initialSel<getLength()) setSelected(initialSel, true);
|
||||
enumClass = null;
|
||||
}
|
||||
|
||||
public StringSelection(Enum<?> e) {
|
||||
public StringSelection(Enum<?> e, String[] tips) {
|
||||
strObjects = new String[e.getClass().getEnumConstants().length];
|
||||
toolTips=tips;
|
||||
selStates = new boolean[strObjects.length];
|
||||
for (int i = 0; i < strObjects.length; i++) {
|
||||
strObjects[i] = e.getClass().getEnumConstants()[i].toString();
|
||||
@ -49,6 +52,7 @@ public class StringSelection implements Serializable {
|
||||
public StringSelection(StringSelection stringSelection) {
|
||||
strObjects = stringSelection.strObjects.clone();
|
||||
selStates = stringSelection.selStates.clone();
|
||||
toolTips = stringSelection.toolTips.clone();
|
||||
stringToIndexHash = null;
|
||||
enumClass = stringSelection.enumClass;
|
||||
}
|
||||
@ -60,9 +64,10 @@ public class StringSelection implements Serializable {
|
||||
* @param e
|
||||
* @param headerFields
|
||||
*/
|
||||
public StringSelection(Enum<?> e,
|
||||
List<String> headerFields) {
|
||||
this(ToolBox.appendEnumAndArray(e, headerFields.toArray(new String[headerFields.size()])));
|
||||
public StringSelection(Enum<?> e, String[] enumTips,
|
||||
List<String> headerFields, String[] addTips) {
|
||||
this(ToolBox.appendEnumAndArray(e, headerFields.toArray(new String[headerFields.size()])),
|
||||
ToolBox.appendArrays(enumTips, addTips));
|
||||
enumClass = e.getClass();
|
||||
}
|
||||
|
||||
@ -78,6 +83,11 @@ public class StringSelection implements Serializable {
|
||||
return strObjects[i];
|
||||
}
|
||||
|
||||
public String getElementInfo(int i) {
|
||||
if (toolTips!=null && (toolTips.length>i)) return toolTips[i];
|
||||
else return null;
|
||||
}
|
||||
|
||||
public String[] getStrings() {
|
||||
return strObjects;
|
||||
}
|
||||
|
@ -29,19 +29,44 @@ public class ToolBox {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append two String arrays. If both are null, null is returned.
|
||||
*
|
||||
* @param strArr1
|
||||
* @param strArr2
|
||||
* @return
|
||||
*/
|
||||
public static String[] appendArrays(String[] strArr1,
|
||||
String[] strArr2) {
|
||||
if (strArr1==null) return strArr2;
|
||||
if (strArr2==null) return strArr1;
|
||||
String[] ret = new String[strArr1.length + strArr2.length];
|
||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
||||
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Object[] appendArrays(Object[] strArr1,
|
||||
Object[] strArr2) {
|
||||
Object[] ret = new Object[strArr1.length + strArr2.length];
|
||||
public static String[] appendArrays(String[] strArr1,
|
||||
String str) {
|
||||
String[] ret = new String[strArr1.length+1];
|
||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
||||
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
||||
ret[ret.length-1]=str;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Object[] appendArrays(Object[] objArr1,
|
||||
Object o) {
|
||||
Object[] ret = new Object[objArr1.length + 1];
|
||||
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
||||
ret[ret.length-1]=o;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Object[] appendArrays(Object[] objArr1,
|
||||
Object[] objArr2) {
|
||||
Object[] ret = new Object[objArr1.length + objArr2.length];
|
||||
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
|
||||
System.arraycopy(objArr2, 0, ret, objArr1.length, objArr2.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user