Search in sources :

Example 6 with AttributeType

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

the class Util method fillResult.

public void fillResult(long attributeId, Exception e, Element element) {
    Object object = null;
    e.printStackTrace();
    Attribute attribute = engine.getAttribute(attributeId);
    AttributeType attributeType = attribute.getAttributeType();
    if (attributeType.getPluginName().equals("Core")) {
        String typeName = attributeType.getTypeName();
        if (typeName.equals("Text")) {
            object = e.getLocalizedMessage();
        }
    }
    engine.setAttribute(element, attribute, object);
}
Also used : Attribute(com.ramussoft.common.Attribute) AttributeType(com.ramussoft.common.AttributeType)

Example 7 with AttributeType

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

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

the class Application method patchData.

/*
     * Create all needed system qualifiers and attributes.
	 */
private void patchData(Engine engine) {
    Journaled journal = (Journaled) engine;
    journal.startUserTransaction();
    Attribute textAttribute1 = createAttribute(TEXT_ATTRIBUTE1, new AttributeType("Core", "Text"), engine);
    Attribute textAttribute2 = createAttribute(TEXT_ATTRIBUTE2, new AttributeType("Core", "Text"), engine);
    Attribute doubleAttribute1 = createAttribute(DOUBLE_ATTRIBUTE1, new AttributeType("Core", "Double"), engine);
    Qualifier qualifier1 = engine.getSystemQualifier(QUALIFIER1);
    if (qualifier1 == null) {
        qualifier1 = engine.createSystemQualifier();
        qualifier1.getAttributes().add(textAttribute1);
        qualifier1.getAttributes().add(textAttribute2);
        qualifier1.getAttributes().add(doubleAttribute1);
        qualifier1.setName(QUALIFIER1);
        engine.updateQualifier(qualifier1);
    }
    journal.commitUserTransaction();
    // User will not be able to undo these changes.
    journal.setNoUndoPoint();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Attribute(com.ramussoft.common.Attribute) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier)

Example 9 with AttributeType

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

the class IDEF0ViewPlugin method importFromIdl.

protected void importFromIdl() {
    JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File f) {
            if (f.isFile()) {
                if (f.getName().toLowerCase().endsWith(".idl"))
                    return true;
                return false;
            }
            return true;
        }

        @Override
        public String getDescription() {
            return "*.idl";
        }
    });
    if (fc.showOpenDialog(framework.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
        try {
            ((Journaled) engine).startUserTransaction();
            Qualifier qualifier = engine.createQualifier();
            Attribute name = null;
            String aName = ResourceLoader.getString("name");
            for (Attribute a : engine.getAttributes()) {
                if (a.getAttributeType().toString().equals("Core.Text")) {
                    if (aName.equals(a.getName()))
                        name = a;
                }
            }
            if (name == null) {
                name = engine.createAttribute(new AttributeType("Core", "Text", true));
                name.setName(aName);
                engine.updateAttribute(name);
            }
            qualifier.getAttributes().add(name);
            qualifier.setAttributeForName(name.getId());
            IDEF0Plugin.installFunctionAttributes(qualifier, engine);
            DataPlugin plugin = NDataPluginFactory.getDataPlugin(qualifier, engine, rules);
            File file = fc.getSelectedFile();
            plugin.importFromIDL(plugin, "cp1251", new FileInputStream(file));
            ((Journaled) engine).commitUserTransaction();
            OpenDiagram openDiagram = new OpenDiagram(qualifier, -1l);
            framework.propertyChanged(OPEN_DIAGRAM, openDiagram);
        } catch (Exception e) {
            ((Journaled) engine).rollbackUserTransaction();
            e.printStackTrace();
            JOptionPane.showMessageDialog(framework.getMainFrame(), "Формат выбранного вами файла IDL не поддерживается.");
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) FileInputStream(java.io.FileInputStream) ParseException(java.text.ParseException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) Journaled(com.ramussoft.common.journal.Journaled) JFileChooser(javax.swing.JFileChooser) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier) FileFilter(javax.swing.filechooser.FileFilter) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) File(java.io.File)

Example 10 with AttributeType

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

the class AttributePreferenciesDialog method updateAdditionalOptions.

protected void updateAdditionalOptions() {
    this.editor = null;
    AttributeType type = getAttributeType();
    AttributePlugin attributePlugin = framework.findAttributePlugin(type);
    if (attributePlugin == null) {
        System.err.println("WARNING: Attribute plugin for type: " + type + " not found.");
        return;
    }
    editor = attributePlugin.getAttributePreferenciesEditor();
    boolean update = false;
    if (this.component != null) {
        update = true;
        contentPanel.remove(this.component);
    }
    this.component = null;
    if (editor != null) {
        JComponent component = editor.createComponent(attribute, engine, accessRules);
        if (component != null) {
            update = true;
            contentPanel.add(component, BorderLayout.CENTER);
            this.component = component;
        }
    }
    if (update) {
        pack();
        contentPanel.revalidate();
        contentPanel.repaint();
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) AttributeType(com.ramussoft.common.AttributeType) JComponent(javax.swing.JComponent)

Aggregations

AttributeType (com.ramussoft.common.AttributeType)20 Attribute (com.ramussoft.common.Attribute)15 Qualifier (com.ramussoft.common.Qualifier)8 Element (com.ramussoft.common.Element)5 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)4 AttributeEvent (com.ramussoft.common.event.AttributeEvent)3 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)3 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)3 QualifierEvent (com.ramussoft.common.event.QualifierEvent)3 Journaled (com.ramussoft.common.journal.Journaled)3 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)3 ArrayList (java.util.ArrayList)3 Hashtable (java.util.Hashtable)3 Engine (com.ramussoft.common.Engine)2 IEngine (com.ramussoft.common.IEngine)2 ElementAdapter (com.ramussoft.common.event.ElementAdapter)2 ElementEvent (com.ramussoft.common.event.ElementEvent)2 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)2 JDBCTemplate (com.ramussoft.jdbc.JDBCTemplate)2 RowMapper (com.ramussoft.jdbc.RowMapper)2