// TODO move in childAll list
@Override
public int moveConfig(IConfig config, int newPos) throws MException {
if (!(config instanceof HashConfig))
throw new MException("not a hashconfig");
LinkedList<HashConfig> list = children.get(config.getName());
if (list == null || list.size() == 0 || !list.contains(config))
throw new MException("config not in my list");
if (list.size() == 1) {
if (newPos == MOVE_FIRST || newPos == MOVE_LAST || newPos == 0)
return 0;
throw new MException("out of range");
}
if (newPos == MOVE_FIRST) {
list.remove(config);
list.add(0, (HashConfig) config);
return 0;
}
if(newPos == MOVE_LAST) {
list.remove(config);
list.add((HashConfig) config);
return list.size()-1;
}
if (newPos == MOVE_DOWN) {
int pos = list.indexOf(config);
if (pos == list.size()-1)
throw new MException("out of range");
list.remove(config);
list.add(pos+1,(HashConfig) config);
return pos+1;
}
if (newPos == MOVE_UP) {
int pos = list.indexOf(config);
if (pos == 0)
throw new MException("out of range");
list.remove(config);
list.add(pos-1,(HashConfig) config);
return pos-1;
}
if (newPos < 0 || newPos >= list.size())
throw new MException("out of range");
list.remove(config);
list.add(newPos,(HashConfig) config);
return newPos;