use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method addSelection.
@Override
public final void addSelection(Selection s) {
int max = selectionList.size();
boolean selected = s.isSelected();
for (int i = 0; i < max; i++) {
Selection t = selectionList.get(i);
if (t.getName().equals(s.getName())) {
selected = t.isSelected();
selectionList.remove(i);
max--;
}
}
((BaseSelectionImpl) s).setParent(this);
if (selected) {
s.setSelected(true);
}
selectionList.add((BaseSelectionImpl) s);
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method setSelected.
@Override
public void setSelected(Selection s, boolean selected) {
List<Selection> l = new ArrayList<>(getAllSelectedSelections());
for (Selection selection : getAllSelections()) {
if (selection.equals(s)) {
s.setSelected(selected);
} else {
if (!"+".equals(getCardinality())) {
selection.setSelected(false);
}
}
}
List<Selection> l2 = getAllSelectedSelections();
if (!l.equals(l2)) {
firePropertyChanged(l, l2);
}
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method setSelected.
@Override
public final void setSelected(List<String> al) {
List<Selection> old = new ArrayList<>(getAllSelectedSelections());
setAllSelected(false);
for (int i = 0; i < al.size(); i++) {
String s = al.get(i);
Selection sl = getSelectionByValue(s);
sl.setSelected(true);
}
firePropertyChanged("selection", old, getAllSelectedSelections());
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method getAllSelectedSelections.
@Override
public final List<Selection> getAllSelectedSelections() {
List<Selection> list = new ArrayList<Selection>() {
private static final long serialVersionUID = -2914783936108056853L;
@Override
public String toString() {
if (size() == 0) {
return Selection.DUMMY_ELEMENT;
}
if (size() == 1) {
return get(0).getValue();
}
int index = 0;
StringBuilder sb = new StringBuilder();
for (Selection s : this) {
sb.append(s.getValue());
if (index < size() - 1) {
sb.append(',');
}
index++;
}
return sb.toString();
}
};
ArrayList<Selection> al = getAllSelections();
for (int i = 0; i < al.size(); i++) {
BaseSelectionImpl s = (BaseSelectionImpl) al.get(i);
if (s.isSelected()) {
list.add(s);
}
}
return list;
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method cloneWithoutValue.
@Override
public Property cloneWithoutValue() {
if (isListType) {
BasePropertyImpl prop = new BasePropertyImpl(getRootDoc(), getName(), cardinality, getDescription(), getDirection());
ArrayList<Selection> ap = getAllSelections();
for (int i = 0; i < ap.size(); i++) {
Selection s = ap.get(i);
Selection newS = NavajoFactory.getInstance().createSelection(getRootDoc(), s.getName(), s.getValue(), s.isSelected());
prop.addSelection(newS);
}
return prop;
} else {
Property prop = new BasePropertyImpl(getRootDoc(), getName(), getType(), null, getLength(), getDescription(), getDirection());
if (getSubtype() != null) {
prop.setSubType(getSubType());
}
if (getKey() != null) {
prop.setKey(getKey());
}
if (getReference() != null) {
prop.setReference(getReference());
}
if (getExtends() != null) {
prop.setExtends(getExtends());
}
if (getBind() != null) {
prop.setBind(getBind());
}
if (getMethod() != null) {
prop.setMethod(getMethod());
}
return prop;
}
}
Aggregations