Search in sources :

Example 1 with ElementListPropertyPersistent

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

the class ElistTable method updateShowBoolean.

private void updateShowBoolean() {
    Engine engine = getEngine();
    ElementListPropertyPersistent pp = (ElementListPropertyPersistent) engine.getAttribute(null, getAttribute());
    String connectionTypes = pp.getConnectionTypes();
    showBoolean = connectionTypes == null || connectionTypes.trim().length() == 0;
    cached = getAttribute();
}
Also used : ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) Engine(com.ramussoft.common.Engine)

Example 2 with ElementListPropertyPersistent

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

the class ElistComponent method canDeleteAttribute.

private boolean canDeleteAttribute(int row) {
    int index = table.convertRowIndexToModel(row);
    Attribute attribute = list.get(index);
    if (!rules.canDeleteAttribute(attribute.getId()))
        return false;
    ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
    if (!rules.canUpdateQualifier(p.getQualifier1()))
        return false;
    if (!rules.canUpdateQualifier(p.getQualifier2()))
        return false;
    return true;
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent)

Example 3 with ElementListPropertyPersistent

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

the class ElistComponent method deleteElement.

private void deleteElement(int row) {
    int index = table.convertRowIndexToModel(row);
    Attribute attribute = list.get(index);
    ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
    Qualifier q1 = engine.getQualifier(p.getQualifier1());
    if (q1 != null) {
        q1.getAttributes().remove(attribute);
        engine.updateQualifier(q1);
    }
    Qualifier q2 = engine.getQualifier(p.getQualifier2());
    if (q2 != null) {
        q2.getAttributes().remove(attribute);
        engine.updateQualifier(q2);
    }
    engine.deleteAttribute(attribute.getId());
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) Qualifier(com.ramussoft.common.Qualifier)

Example 4 with ElementListPropertyPersistent

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

the class ElementListPlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(Engine engine, AccessRules rules, Element element, Attribute attribute, String propertiesPrefix, AttributeEditor old) {
    ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
    long qId = element.getQualifierId();
    Qualifier qualifier;
    boolean left;
    if (p.getQualifier1() == qId) {
        qualifier = engine.getQualifier(p.getQualifier2());
        left = false;
    } else {
        qualifier = engine.getQualifier(p.getQualifier1());
        left = true;
    }
    if (old != null) {
        if ((old == elementListAttributeEditor) && (this.attribute.equals(attribute)) && (this.left == left)) {
            elementListAttributeEditor.setElement(element);
            return elementListAttributeEditor;
        } else
            old.close();
    }
    this.attribute = attribute;
    this.left = left;
    elementListAttributeEditor = new ElementListAttributeEditor(framework, qualifier, left, propertiesPrefix);
    elementListAttributeEditor.setElement(element);
    return elementListAttributeEditor;
}
Also used : ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) Qualifier(com.ramussoft.common.Qualifier)

Example 5 with ElementListPropertyPersistent

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

the class ElementListPreferenciesEditor method createComponent.

@Override
public JComponent createComponent(Attribute attribute, Engine engine, AccessRules accessRules) {
    JPanel basePanel = new JPanel(new BorderLayout());
    double[][] size = { { 5, TableLayout.FILL, 5 }, { 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5, TableLayout.FILL, 5 } };
    JPanel panel = new JPanel(new TableLayout(size));
    panel.add(new JLabel(GlobalResourcesManager.getString("ElementList.Qualifier1")), "1, 1");
    panel.add(box1, "1, 3");
    panel.add(new JLabel(GlobalResourcesManager.getString("ElementList.Qualifier2")), "1, 5");
    panel.add(box2, "1, 7");
    panel.add(new JLabel(GlobalResourcesManager.getString("ElementList.Variants")), "1, 9");
    for (Qualifier qualifier : engine.getQualifiers()) {
        if (accessRules.canUpdateQualifier(qualifier.getId())) {
            box1.addItem(qualifier);
            box2.addItem(qualifier);
        }
    }
    if (attribute != null) {
        ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
        box1.setSelectedItem(engine.getQualifier(p.getQualifier1()));
        box2.setSelectedItem(engine.getQualifier(p.getQualifier2()));
        box1.setEnabled(false);
        box2.setEnabled(false);
        if (p.getConnectionTypes() != null)
            variantsArea.setText(p.getConnectionTypes());
    }
    basePanel.add(panel, BorderLayout.NORTH);
    basePanel.add(new JScrollPane(variantsArea), BorderLayout.CENTER);
    return basePanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) JLabel(javax.swing.JLabel) Qualifier(com.ramussoft.common.Qualifier) TableLayout(info.clearthought.layout.TableLayout)

Aggregations

ElementListPropertyPersistent (com.ramussoft.core.attribute.simple.ElementListPropertyPersistent)12 Attribute (com.ramussoft.common.Attribute)6 Qualifier (com.ramussoft.common.Qualifier)6 Engine (com.ramussoft.common.Engine)4 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)3 List (java.util.List)3 BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 AccessRules (com.ramussoft.common.AccessRules)1 AttributeType (com.ramussoft.common.AttributeType)1 Element (com.ramussoft.common.Element)1 IEngine (com.ramussoft.common.IEngine)1 SelectType (com.ramussoft.gui.qualifier.table.SelectType)1 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)1 SelectionEvent (com.ramussoft.gui.qualifier.table.event.SelectionEvent)1 Row (com.ramussoft.pb.Row)1 NRow (com.ramussoft.pb.data.negine.NRow)1 TableLayout (info.clearthought.layout.TableLayout)1 AdjustmentEvent (java.awt.event.AdjustmentEvent)1 AdjustmentListener (java.awt.event.AdjustmentListener)1