Search in sources :

Example 56 with Selection

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);
}
Also used : Selection(com.dexels.navajo.document.Selection)

Example 57 with Selection

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);
    }
}
Also used : Selection(com.dexels.navajo.document.Selection) ArrayList(java.util.ArrayList)

Example 58 with Selection

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());
}
Also used : Selection(com.dexels.navajo.document.Selection) ArrayList(java.util.ArrayList)

Example 59 with Selection

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;
}
Also used : Selection(com.dexels.navajo.document.Selection) ArrayList(java.util.ArrayList)

Example 60 with Selection

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;
    }
}
Also used : Selection(com.dexels.navajo.document.Selection) Property(com.dexels.navajo.document.Property)

Aggregations

Selection (com.dexels.navajo.document.Selection)78 Property (com.dexels.navajo.document.Property)36 Test (org.junit.Test)32 Message (com.dexels.navajo.document.Message)24 Navajo (com.dexels.navajo.document.Navajo)21 Access (com.dexels.navajo.script.api.Access)14 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)13 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)12 TipiLink (com.dexels.navajo.expression.api.TipiLink)12 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)12 ArrayList (java.util.ArrayList)12 Optional (java.util.Optional)12 Operand (com.dexels.navajo.document.Operand)11 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)11 List (java.util.List)8 NavajoException (com.dexels.navajo.document.NavajoException)6 UserException (com.dexels.navajo.script.api.UserException)4 Binary (com.dexels.navajo.document.types.Binary)3 FunctionClassification (com.dexels.navajo.expression.api.FunctionClassification)3 StringTokenizer (java.util.StringTokenizer)3