Search in sources :

Example 1 with ElementListPersistent

use of com.ramussoft.core.attribute.simple.ElementListPersistent in project ramus by Vitaliy-Yakovchuk.

the class ElistTable method getCellRenderer.

@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    row = convertRowIndexToModel(row);
    column = convertColumnIndexToModel(column);
    ElementListPersistent lp = (ElementListPersistent) getModel().getValueAt(row, column);
    if (lp == null)
        return textRenderer;
    if (cached != getAttribute())
        updateShowBoolean();
    if (showBoolean)
        return booleanRenderer;
    return textRenderer;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent)

Example 2 with ElementListPersistent

use of com.ramussoft.core.attribute.simple.ElementListPersistent in project ramus by Vitaliy-Yakovchuk.

the class QualifierPreferencesPanel method updateAttributesInOrder.

@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
    Attribute attributeId = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_ID);
    List<ElementListPersistent> list = (List<ElementListPersistent>) attributeEditor.getValue();
    List<Attribute> attributes = new ArrayList<Attribute>(list.size());
    for (ElementListPersistent pr : list) {
        Element element2 = engine.getElement(pr.getElement2Id());
        Long id2 = (Long) engine.getAttribute(element2, attributeId);
        Attribute attribute = engine.getAttribute(id2);
        attributes.add(attribute);
        if (qAttributes.indexOf(attribute) < 0)
            qAttributes.add(attribute);
    }
    List<Attribute> rem = new ArrayList<Attribute>();
    for (Attribute a : qAttributes) if (attributes.indexOf(a) < 0)
        rem.add(a);
    for (Attribute r : rem) qAttributes.remove(r);
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with ElementListPersistent

use of com.ramussoft.core.attribute.simple.ElementListPersistent in project ramus by Vitaliy-Yakovchuk.

the class ElistTabView method addRow.

private void addRow(ElistPanel elistPanel, Row row) {
    ElementListPersistent p = new ElementListPersistent();
    if (left == elistPanel) {
        p.setElement1Id(row.getElementId());
        p.setElement2Id(right.getSelectedRows().get(0).getElementId());
    } else {
        p.setElement1Id(left.getSelectedRows().get(0).getElementId());
        p.setElement2Id(row.getElementId());
    }
    if (value.indexOf(p) < 0)
        value.add(p);
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent)

Example 4 with ElementListPersistent

use of com.ramussoft.core.attribute.simple.ElementListPersistent in project ramus by Vitaliy-Yakovchuk.

the class ElistTableModel method getValueAt.

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Element element = left.getElement(rowIndex);
    List<ElementListPersistent> value = data.get(element);
    if (value == null) {
        value = new ArrayList<ElementListPersistent>();
        data.put(element, value);
    }
    Element c = top.getElement(columnIndex);
    for (ElementListPersistent p : value) {
        if (revert) {
            if (p.getElement1Id() == c.getId())
                return p;
        } else {
            if (p.getElement2Id() == c.getId())
                return p;
        }
    }
    return null;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Element(com.ramussoft.common.Element)

Example 5 with ElementListPersistent

use of com.ramussoft.core.attribute.simple.ElementListPersistent in project ramus by Vitaliy-Yakovchuk.

the class ElementListPlugin method syncElement.

@SuppressWarnings("unchecked")
@Override
public void syncElement(Engine engine, QualifierImporter importer, Element sourceElement, Attribute sourceAttribute) {
    List<ElementListPersistent> list = (List) importer.getSourceValue(sourceElement, sourceAttribute);
    List<ElementListPersistent> set = null;
    if (list != null) {
        for (ElementListPersistent p : list) if ((p != null) && (p.getElement1Id() == sourceElement.getId())) {
            if (set == null)
                set = new ArrayList<ElementListPersistent>(list.size());
            Element element1 = importer.getDestinationElement(p.getElement1Id());
            Element element2 = importer.getDestinationElement(p.getElement2Id());
            if ((element1 != null) && (element2 != null)) {
                ElementListPersistent d = new ElementListPersistent(element1.getId(), element2.getId());
                set.add(d);
            }
        }
    }
    if (set != null)
        engine.setAttribute(importer.getDestination(sourceElement), importer.getDestination(sourceAttribute), set);
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)14 Element (com.ramussoft.common.Element)8 ArrayList (java.util.ArrayList)8 List (java.util.List)6 Engine (com.ramussoft.common.Engine)4 Attribute (com.ramussoft.common.Attribute)3 Qualifier (com.ramussoft.common.Qualifier)3 ElementListPropertyPersistent (com.ramussoft.core.attribute.simple.ElementListPropertyPersistent)3 IEngine (com.ramussoft.common.IEngine)2 Row (com.ramussoft.database.common.Row)2 AccessRules (com.ramussoft.common.AccessRules)1 AttributeType (com.ramussoft.common.AttributeType)1 AttributeAdapter (com.ramussoft.common.event.AttributeAdapter)1 AttributeEvent (com.ramussoft.common.event.AttributeEvent)1 ElementAdapter (com.ramussoft.common.event.ElementAdapter)1 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)1 ElementEvent (com.ramussoft.common.event.ElementEvent)1 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)1 QualifierEvent (com.ramussoft.common.event.QualifierEvent)1 StreamAdapter (com.ramussoft.common.event.StreamAdapter)1