Search in sources :

Example 71 with Attribute

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

the class Util method decompileValue.

protected String decompileValue(final Element element, String oldName) {
    MetaValue value = toMetaValue(oldName);
    Attribute attribute = engine.getAttribute(value.getAttributeId());
    if ((element != null) && (value.getElementId() == element.getId())) {
        return toCanonicalValue(attribute.getName());
    } else {
        Element e = engine.getElement(value.getElementId());
        if (e.getName().length() == 0)
            return toCanonicalValue(ELEMENT_PREFIX + e.getId() + "." + attribute.getName());
        if ((element != null) && (e.getQualifierId() == element.getQualifierId())) {
            return toCanonicalValue(e.getName() + "." + attribute.getName());
        } else {
            Qualifier qualifier = engine.getQualifier(e.getQualifierId());
            return toCanonicalValue(replaceDots(qualifier.getName()) + "." + replaceDots(e.getName()) + "." + replaceDots(attribute.getName()));
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 72 with Attribute

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

the class Util method getAttributes.

public List<Attribute> getAttributes(Qualifier qualifier, Eval eval) {
    List<Attribute> result = new ArrayList<Attribute>();
    String[] values = eval.getValues();
    for (String value : values) {
        for (Attribute attr : qualifier.getAttributes()) {
            if (value.equals(getAttributeEId(attr.getId()))) {
                result.add(attr);
            }
        }
    }
    return result;
}
Also used : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList)

Example 73 with Attribute

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

the class Util method compile.

public String compile(Qualifier qualifier, String userFunction) {
    List<Attribute> attrs = qualifier.getAttributes();
    final Hashtable<String, String> hash = new Hashtable<String, String>(attrs.size());
    for (Attribute attr : attrs) {
        AttributeType type = attr.getAttributeType();
        if (type.toString().equals("Core.Table")) {
            Qualifier table = engine.getSystemQualifier("TableQualifier_" + attr.getId());
            for (Attribute tAttr : table.getAttributes()) {
                hash.put(toCanonicalValue(attr.getName() + "." + tAttr.getName()), getAttributeEId(attr.getId(), tAttr.getId()));
            }
        }
        hash.put(toCanonicalValue(attr.getName()), getAttributeEId(attr.getId()));
    }
    Eval eval = new Eval(userFunction);
    eval.replaceValueNames(new Replacementable() {

        @Override
        public String getNewName(String oldName) {
            if ("ELEMENT".equals(oldName))
                return oldName;
            String name = hash.get(oldName);
            if (name == null) {
                name = compileValue(null, oldName);
            }
            return name;
        }
    });
    return eval.toString();
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier)

Example 74 with Attribute

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

the class SectorFontAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private JFontChooser component;

        private Font font;

        {
            component = new JFontChooser();
            ResourceLoader.setJComponentsText(component);
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            font = pin.getSector().getFont();
            component.setSelFont(font);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            PaintSector sector = pin.getSector();
            sector.setFont(component.getSelFont());
            sector.copyVisual(Sector.VISUAL_COPY_ADDED);
            pin.getSector().getMovingArea().getRefactor().setUndoPoint();
        }

        @Override
        public boolean isSaveAnyway() {
            return !font.equals(component.getSelFont());
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) JFontChooser(com.ramussoft.pb.frames.components.JFontChooser) Element(com.ramussoft.common.Element) Font(java.awt.Font) Engine(com.ramussoft.common.Engine)

Example 75 with Attribute

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

the class ModelPropertiesDialog method updateAttributesInOrder.

@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
    List<Row> list = view.getSelectedRows();
    List<Attribute> attributes = new ArrayList<Attribute>(list.size());
    for (Row pr : list) {
        Attribute attribute = StandardAttributesPlugin.getAttribute(engine, pr.getElement());
        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 : Attribute(com.ramussoft.common.Attribute) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

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