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 {
|
public class StringSelection implements Serializable {
|
||||||
private static final long serialVersionUID = -1512329288445831907L;
|
private static final long serialVersionUID = -1512329288445831907L;
|
||||||
private String[] strObjects;
|
private String[] strObjects;
|
||||||
|
private String[] toolTips;
|
||||||
boolean[] selStates;
|
boolean[] selStates;
|
||||||
private transient HashMap<String,Integer> stringToIndexHash = null;
|
private transient HashMap<String,Integer> stringToIndexHash = null;
|
||||||
private transient Class<? extends Enum> enumClass = null;
|
private transient Class<? extends Enum> enumClass = null;
|
||||||
|
|
||||||
public StringSelection(String[] sArr) {
|
public StringSelection(String[] sArr, String[] tips) {
|
||||||
strObjects = sArr;
|
strObjects = sArr;
|
||||||
|
toolTips=tips;
|
||||||
selStates=new boolean[sArr.length];
|
selStates=new boolean[sArr.length];
|
||||||
stringToIndexHash = null;
|
stringToIndexHash = null;
|
||||||
enumClass = null;
|
enumClass = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringSelection(String[] sArr, int initialSel) {
|
public StringSelection(String[] sArr, String[] tips, int initialSel) {
|
||||||
this(sArr);
|
this(sArr, tips);
|
||||||
if (initialSel<getLength()) setSelected(initialSel, true);
|
if (initialSel<getLength()) setSelected(initialSel, true);
|
||||||
enumClass = null;
|
enumClass = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringSelection(Enum<?> e) {
|
public StringSelection(Enum<?> e, String[] tips) {
|
||||||
strObjects = new String[e.getClass().getEnumConstants().length];
|
strObjects = new String[e.getClass().getEnumConstants().length];
|
||||||
|
toolTips=tips;
|
||||||
selStates = new boolean[strObjects.length];
|
selStates = new boolean[strObjects.length];
|
||||||
for (int i = 0; i < strObjects.length; i++) {
|
for (int i = 0; i < strObjects.length; i++) {
|
||||||
strObjects[i] = e.getClass().getEnumConstants()[i].toString();
|
strObjects[i] = e.getClass().getEnumConstants()[i].toString();
|
||||||
@ -49,6 +52,7 @@ public class StringSelection implements Serializable {
|
|||||||
public StringSelection(StringSelection stringSelection) {
|
public StringSelection(StringSelection stringSelection) {
|
||||||
strObjects = stringSelection.strObjects.clone();
|
strObjects = stringSelection.strObjects.clone();
|
||||||
selStates = stringSelection.selStates.clone();
|
selStates = stringSelection.selStates.clone();
|
||||||
|
toolTips = stringSelection.toolTips.clone();
|
||||||
stringToIndexHash = null;
|
stringToIndexHash = null;
|
||||||
enumClass = stringSelection.enumClass;
|
enumClass = stringSelection.enumClass;
|
||||||
}
|
}
|
||||||
@ -60,9 +64,10 @@ public class StringSelection implements Serializable {
|
|||||||
* @param e
|
* @param e
|
||||||
* @param headerFields
|
* @param headerFields
|
||||||
*/
|
*/
|
||||||
public StringSelection(Enum<?> e,
|
public StringSelection(Enum<?> e, String[] enumTips,
|
||||||
List<String> headerFields) {
|
List<String> headerFields, String[] addTips) {
|
||||||
this(ToolBox.appendEnumAndArray(e, headerFields.toArray(new String[headerFields.size()])));
|
this(ToolBox.appendEnumAndArray(e, headerFields.toArray(new String[headerFields.size()])),
|
||||||
|
ToolBox.appendArrays(enumTips, addTips));
|
||||||
enumClass = e.getClass();
|
enumClass = e.getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +83,11 @@ public class StringSelection implements Serializable {
|
|||||||
return strObjects[i];
|
return strObjects[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getElementInfo(int i) {
|
||||||
|
if (toolTips!=null && (toolTips.length>i)) return toolTips[i];
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getStrings() {
|
public String[] getStrings() {
|
||||||
return strObjects;
|
return strObjects;
|
||||||
}
|
}
|
||||||
|
@ -29,19 +29,44 @@ public class ToolBox {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append two String arrays. If both are null, null is returned.
|
||||||
|
*
|
||||||
|
* @param strArr1
|
||||||
|
* @param strArr2
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String[] appendArrays(String[] strArr1,
|
public static String[] appendArrays(String[] strArr1,
|
||||||
String[] strArr2) {
|
String[] strArr2) {
|
||||||
|
if (strArr1==null) return strArr2;
|
||||||
|
if (strArr2==null) return strArr1;
|
||||||
String[] ret = new String[strArr1.length + strArr2.length];
|
String[] ret = new String[strArr1.length + strArr2.length];
|
||||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
||||||
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] appendArrays(Object[] strArr1,
|
public static String[] appendArrays(String[] strArr1,
|
||||||
Object[] strArr2) {
|
String str) {
|
||||||
Object[] ret = new Object[strArr1.length + strArr2.length];
|
String[] ret = new String[strArr1.length+1];
|
||||||
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user