Search in sources :

Example 6 with QualifierAdapter

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

the class AutochangePlugin method init.

@Override
public void init(final Engine engine, AccessRules accessor) {
    super.init(engine, accessor);
    engine.addQualifierListener(new QualifierAdapter() {

        @Override
        public void qualifierCreated(QualifierEvent event) {
            if (event.isJournaled())
                return;
            if (StandardAttributesPlugin.isDisableAutoupdate(engine))
                return;
            Qualifier qualifier = event.getNewQualifier();
            if (!qualifier.isSystem()) {
                Properties ps = engine.getProperties(AUTO_ADD_ATTRIBUTES);
                String ids = ps.getProperty(AUTO_ADD_ATTRIBUTE_IDS);
                String attributeForName = ps.getProperty(ATTRIBUTE_FOR_NAME);
                if (ids == null)
                    ids = "";
                StringTokenizer st = new StringTokenizer(ids, " ,");
                boolean added = false;
                while (st.hasMoreElements()) {
                    String s = st.nextToken();
                    long id = Long.parseLong(s);
                    Attribute attr = engine.getAttribute(id);
                    if (attr != null) {
                        added = true;
                        qualifier.getAttributes().add(attr);
                        if (s.equals(attributeForName))
                            qualifier.setAttributeForName(attr.getId());
                    }
                }
                if (added) {
                    engine.updateQualifier(qualifier);
                }
            }
        }
    });
}
Also used : QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) StringTokenizer(java.util.StringTokenizer) Attribute(com.ramussoft.common.Attribute) QualifierEvent(com.ramussoft.common.event.QualifierEvent) Qualifier(com.ramussoft.common.Qualifier) Properties(java.util.Properties)

Example 7 with QualifierAdapter

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

the class HierarchicalPlugin method init.

@Override
public void init(final Engine engine, AccessRules accessor) {
    super.init(engine, accessor);
    hierarhicalAttribute = engine.getSystemAttribute(HIERARHICAL_ATTRIBUTE);
    if (hierarhicalAttribute == null) {
        hierarhicalAttribute = engine.createSystemAttribute(new AttributeType(getName(), getTypeName(), true));
        hierarhicalAttribute.setName(HIERARHICAL_ATTRIBUTE);
        engine.updateAttribute(hierarhicalAttribute);
    }
    engine.setPluginProperty(getName(), HIERARHICAL_ATTRIBUTE, hierarhicalAttribute);
    engine.addQualifierListener(new QualifierAdapter() {

        @Override
        public void qualifierCreated(QualifierEvent event) {
            if (event.isJournaled())
                return;
            if (StandardAttributesPlugin.isDisableAutoupdate(engine))
                return;
            Qualifier qualifier = event.getNewQualifier();
            if (qualifier.isSystem())
                return;
            qualifier.getSystemAttributes().add(hierarhicalAttribute);
            engine.updateQualifier(qualifier);
        }
    });
}
Also used : QualifierAdapter(com.ramussoft.common.event.QualifierAdapter) AttributeType(com.ramussoft.common.AttributeType) QualifierEvent(com.ramussoft.common.event.QualifierEvent) Qualifier(com.ramussoft.common.Qualifier)

Aggregations

QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)7 QualifierEvent (com.ramussoft.common.event.QualifierEvent)7 Qualifier (com.ramussoft.common.Qualifier)5 Attribute (com.ramussoft.common.Attribute)3 AttributeType (com.ramussoft.common.AttributeType)3 ElementAdapter (com.ramussoft.common.event.ElementAdapter)3 ElementEvent (com.ramussoft.common.event.ElementEvent)3 Element (com.ramussoft.common.Element)2 Engine (com.ramussoft.common.Engine)2 IEngine (com.ramussoft.common.IEngine)2 AttributeEvent (com.ramussoft.common.event.AttributeEvent)2 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)2 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)2 ActionEvent (com.ramussoft.gui.common.event.ActionEvent)2 ActionListener (com.ramussoft.gui.common.event.ActionListener)2 TabbedEvent (com.ramussoft.gui.common.event.TabbedEvent)2 ViewTitleEvent (com.ramussoft.gui.common.event.ViewTitleEvent)2 JDBCTemplate (com.ramussoft.jdbc.JDBCTemplate)2 RowMapper (com.ramussoft.jdbc.RowMapper)2 ResultSet (java.sql.ResultSet)2