Search in sources :

Example 6 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class QualifierHistorySetupEditor method load.

@Override
public void load(Engine engine, Qualifier qualifier) {
    List<Long> attrIds = new ArrayList<Long>();
    for (int i = 0; i < this.attrs.size(); i++) if (boxs.size() > i) {
        JCheckBox box = boxs.get(i);
        if (box.isSelected())
            attrIds.add(this.attrs.get(i).getId());
    }
    List<Long> l = StandardAttributesPlugin.getHistoryQualifiers(engine).get(qualifier.getId());
    boolean loadHistory = false;
    if (panel.getComponentCount() == 0)
        loadHistory = true;
    panel.removeAll();
    boxs.clear();
    attrs.clear();
    for (Attribute attribute : qualifier.getAttributes()) {
        if (attribute.getAttributeType().isHistorySupport())
            attrs.add(attribute);
    }
    for (Attribute attribute : attrs) {
        JCheckBox box = new JCheckBox(attribute.getName());
        if (attrIds.indexOf(attribute.getId()) >= 0)
            box.setSelected(true);
        if ((loadHistory) && (l != null) && (l.indexOf(attribute.getId()) >= 0))
            box.setSelected(true);
        panel.add(box);
        boxs.add(box);
    }
    panel.revalidate();
    panel.repaint();
}
Also used : JCheckBox(javax.swing.JCheckBox) Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList)

Example 7 with Attribute

use of com.ramussoft.common.Attribute 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 8 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class QualifierView method moveElements.

private void moveElements(Row row, long parentElementId, long prevParentId, Qualifier dest) {
    long qualifierId = StandardAttributesPlugin.getQualifierId(engine, row.getElement());
    framework.propertyChanged("CloseQualifier", qualifierId);
    Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(engine);
    List<Element> elements = engine.getElements(qualifierId);
    for (Element element : elements) {
        engine.setElementQualifier(element.getId(), dest.getId());
        element.setQualifierId(dest.getId());
        HierarchicalPersistent hp = (HierarchicalPersistent) engine.getAttribute(element, hAttribute);
        if ((hp != null) && (hp.getParentElementId() == -1l)) {
            hp.setParentElementId(row.getElementId());
            engine.setAttribute(element, hAttribute, hp);
        }
    }
    long prevId = -1l;
    for (Row row2 : toArray(row.getChildren())) {
        moveElements(row2, row.getElementId(), prevId, dest);
        prevId = row2.getId();
    }
    String name = row.getName();
    engine.setElementQualifier(row.getElementId(), dest.getId());
    HierarchicalPersistent hp = new HierarchicalPersistent();
    hp.setPreviousElementId(prevParentId);
    hp.setParentElementId(parentElementId);
    engine.setAttribute(row.getElement(), hAttribute, hp);
    Attribute nameAttribute = engine.getAttribute(dest.getAttributeForName());
    if (nameAttribute != null)
        engine.setAttribute(row.getElement(), nameAttribute, name);
}
Also used : Attribute(com.ramussoft.common.Attribute) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Element(com.ramussoft.common.Element) Row(com.ramussoft.database.common.Row) RootRow(com.ramussoft.database.common.RowSet.RootRow)

Example 9 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class QualifierView method getAttributes.

@Override
protected Attribute[] getAttributes() {
    List<Attribute> attributes = new ArrayList<Attribute>();
    attributes.add(nameAttribute);
    for (Attribute attribute : qualifier.getAttributes()) attributes.add(attribute);
    return attributes.toArray(new Attribute[attributes.size()]);
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList)

Example 10 with Attribute

use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.

the class AttributeOrderEditPanel method down.

protected void down() {
    int[] is = list.getSelectedRows();
    final ArrayList<Integer> nSel = new ArrayList<Integer>();
    for (int i = 0; i < is.length; i++) {
        final int index = is[i];
        if (index + 1 < attributes.size()) {
            final Attribute obj = attributes.get(index);
            attributes.remove(index);
            final int j = index + 1;
            attributes.add(j, obj);
            nSel.add(j);
        } else
            is[i] = -1;
    }
    is = new int[nSel.size()];
    for (int i = 0; i < is.length; i++) is[i] = nSel.get(i);
    list.getSelectionModel().clearSelection();
    for (int i : is) list.getSelectionModel().addSelectionInterval(i, i);
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList)

Aggregations

Attribute (com.ramussoft.common.Attribute)203 Qualifier (com.ramussoft.common.Qualifier)72 Element (com.ramussoft.common.Element)70 ArrayList (java.util.ArrayList)53 Engine (com.ramussoft.common.Engine)32 List (java.util.List)20 Row (com.ramussoft.database.common.Row)19 Hashtable (java.util.Hashtable)19 SQLException (java.sql.SQLException)16 AttributeType (com.ramussoft.common.AttributeType)15 FindObject (com.ramussoft.common.attribute.FindObject)11 AttributeEvent (com.ramussoft.common.event.AttributeEvent)11 ResultSet (java.sql.ResultSet)11 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)10 AccessRules (com.ramussoft.common.AccessRules)9 Transaction (com.ramussoft.common.persistent.Transaction)9 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)9 RowMapper (com.ramussoft.jdbc.RowMapper)9 Row (com.ramussoft.pb.Row)9 ImageIcon (javax.swing.ImageIcon)9