Search in sources :

Example 61 with Qualifier

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

the class ModelParaleler method copyRow.

private void copyRow(Row source, Row destination) {
    if (source.isElement()) {
        Qualifier qualifier = fromEngine.getQualifier(source.getElement().getQualifierId());
        Qualifier to = toEngine.getQualifier(destination.getElement().getQualifierId());
        checkAttributes(qualifier, to);
        copyAttributes(qualifier.getAttributes(), source.getElement(), destination.getElement());
        copyAttributes(qualifier.getSystemAttributes(), source.getElement(), destination.getElement());
        if (source instanceof NFunction)
            copyFunction((NFunction) source, (NFunction) destination);
    } else {
        Qualifier s = StandardAttributesPlugin.getQualifier(fromEngine, source.getElement());
        Qualifier d = StandardAttributesPlugin.getQualifier(toEngine, destination.getElement());
        copyQualifier(s, d);
    }
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Qualifier(com.ramussoft.common.Qualifier)

Example 62 with Qualifier

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

the class ModelParaleler method createParalel.

public void createParalel(final Function function, final boolean createAllRows) {
    ModelParaleler.this.function = function;
    if (createAllRows)
        createAllRows();
    Qualifier qualifier = toEngine.createQualifier();
    copyQualifier(function.getQualifier(), qualifier);
    IDEF0Plugin.installFunctionAttributes(qualifier, toEngine);
    Qualifier q = IDEF0Plugin.getModelTree(toEngine);
    Element element = toEngine.createElement(q.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(toEngine), qualifier.getId());
    toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(toEngine), function.getName());
    toDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, toEngine, toDataPlugin.getAccessRules());
    ModelParaleler.this.base = toDataPlugin.getBaseFunction();
    Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
    ProjectOptions projectOptions = toDataPlugin.getBaseFunction().getProjectOptions();
    projectOptions.getDeligate().setDiagramSize(function.getProjectOptions().getDeligate().getDiagramSize());
    toDataPlugin.getBaseFunction().setProjectOptions(projectOptions);
    for (Row row : childs) {
        NFunction dest = (NFunction) getRow(row);
        showMessageAnimation(dest.toString());
    }
    NFunction func = null;
    Vector<Row> v = toDataPlugin.getChilds(base, true);
    if (v.size() > 0)
        func = (NFunction) v.get(0);
    createSectorsOnUpperLevel(func);
}
Also used : NFunction(com.ramussoft.pb.data.negine.NFunction) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 63 with Qualifier

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

the class ModelParaleler method init.

@SuppressWarnings("deprecation")
private void init() {
    Vector<Row> v = fromDataPlugin.getRecChilds(null, false);
    for (Row r : v) {
        long qualifierId = StandardAttributesPlugin.getQualifierId(fromEngine, r.getElement());
        rowForQualifiers.put(qualifierId, r);
    }
    Qualifier bs = IDEF0Plugin.getBaseStreamQualifier(fromEngine);
    rowForQualifiers.put(bs.getId(), fromDataPlugin.getBaseStream());
    List<Attribute> attrs = fromEngine.getSystemAttributes();
    List<Attribute> dAttrs = toEngine.getSystemAttributes();
    Hashtable<String, Attribute> hash = new Hashtable<String, Attribute>();
    for (Attribute attribute : dAttrs) hash.put(attribute.getName(), attribute);
    for (Attribute a : attrs) {
        Attribute d = hash.get(a.getName());
        if (d == null)
            System.err.println("WARNING: System attribute not found in destination engine: " + a.getName() + " type: " + a.getAttributeType());
        else
            attrHash.put(a.getId(), d);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 64 with Qualifier

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

the class TableTabView method convertFirstLevelToQualifiers.

public void convertFirstLevelToQualifiers() {
    Qualifier qq = StandardAttributesPlugin.getQualifiersQualifier(engine);
    HierarchicalPersistent hp = new HierarchicalPersistent();
    Element element = StandardAttributesPlugin.getElement(engine, getQualifier().getId());
    hp.setParentElementId(element.getId());
    hp.setPreviousElementId(-1l);
    Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(engine);
    Attribute nameAttribute = StandardAttributesPlugin.getAttributeNameAttribute(engine);
    for (Row row : toArray(component.getRowSet().getRoot().getChildren())) {
        String name = row.getName();
        Row[] children = toArray(row.getChildren());
        engine.setElementQualifier(row.getElementId(), qq.getId());
        row.getElement().setQualifierId(qq.getId());
        engine.setAttribute(row.getElement(), hAttribute, hp);
        engine.setAttribute(row.getElement(), nameAttribute, name);
        hp.setPreviousElementId(row.getElementId());
        Qualifier qualifier = StandardAttributesPlugin.getQualifier(engine, row.getElement());
        for (Attribute attribute : getQualifier().getAttributes()) {
            if (qualifier.getAttributes().indexOf(attribute) < 0)
                qualifier.getAttributes().add(attribute);
        }
        engine.updateQualifier(qualifier);
        for (Row row2 : children) {
            moveRows(row2, qualifier.getId());
            HierarchicalPersistent h = (HierarchicalPersistent) engine.getAttribute(row2.getElement(), hAttribute);
            h.setParentElementId(-1l);
            row2.setAttribute(hAttribute, h);
        }
    }
    Attribute nameAttr = null;
    for (Attribute attribute : qualifier.getAttributes()) if (attribute.getId() == qualifier.getAttributeForName())
        nameAttr = attribute;
    getQualifier().getAttributes().clear();
    if (nameAttr != null)
        getQualifier().getAttributes().add(nameAttr);
    engine.updateQualifier(getQualifier());
}
Also used : HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

Example 65 with Qualifier

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

the class IDEF0Object method createEditFrame.

@Override
protected void createEditFrame() {
    final GUIFramework framework = movingArea.getPanel().getFramework();
    final Engine engine = framework.getEngine();
    long id = getFunction().getLink();
    Element element2 = null;
    if (id >= 0)
        element2 = engine.getElement(id);
    if (element2 == null)
        element2 = getFunction().getElement();
    final Element element = element2;
    Qualifier qualifier = engine.getQualifier(element.getQualifierId());
    Attribute name = null;
    if (qualifier.getAttributeForName() >= 0)
        name = engine.getAttribute(qualifier.getAttributeForName());
    if (name == null) {
        JOptionPane.showMessageDialog(framework.getMainFrame(), ResourceLoader.getString("NameAttributeNotSet"));
        return;
    }
    final Attribute nameAttribute = name;
    AttributePlugin plugin = framework.findAttributePlugin(name);
    final AttributeEditor editor = plugin.getAttributeEditor(engine, framework.getAccessRules(), element, name, "activity_name", null);
    setTextComponent(new JScrollPane(editor.getLastComponent()));
    final Object value = engine.getAttribute(element, name);
    editor.setValue(value);
    final Rectangle r = movingArea.getIBounds(getBounds());
    final JTextArea textArea = (JTextArea) editor.getLastComponent();
    processTextArea(textArea);
    // textArea.setBackground(getFunction().getBackground());
    // textArea.setForeground(getFunction().getForeground());
    // textArea.setFont(movingArea.getFont(getFont()));
    // textArea.setCaretColor(getFunction().getForeground());
    final JPopupMenu menu = textArea.getComponentPopupMenu();
    textArea.setComponentPopupMenu(null);
    movingArea.getPanel().setActionDisable(true);
    textArea.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER && e.isControlDown()) {
                stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                cancelEdit(editor, textArea, menu);
        }
    });
    textArea.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });
    movingArea.add(getTextComponent());
    movingArea.setbImage(null);
    getTextComponent().setBounds(r);
    movingArea.revalidate();
    movingArea.repaint();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            textArea.requestFocus();
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) GUIFramework(com.ramussoft.gui.common.GUIFramework) Element(com.ramussoft.common.Element) KeyAdapter(java.awt.event.KeyAdapter) Rectangle(java.awt.Rectangle) FRectangle(com.dsoft.pb.types.FRectangle) FocusEvent(java.awt.event.FocusEvent) JPopupMenu(javax.swing.JPopupMenu) KeyEvent(java.awt.event.KeyEvent) AttributeEditor(com.ramussoft.gui.common.AttributeEditor) Qualifier(com.ramussoft.common.Qualifier) FocusListener(java.awt.event.FocusListener) Engine(com.ramussoft.common.Engine)

Aggregations

Qualifier (com.ramussoft.common.Qualifier)157 Attribute (com.ramussoft.common.Attribute)72 Element (com.ramussoft.common.Element)59 ArrayList (java.util.ArrayList)45 Engine (com.ramussoft.common.Engine)22 Row (com.ramussoft.database.common.Row)17 Row (com.ramussoft.pb.Row)14 List (java.util.List)12 Hashtable (java.util.Hashtable)11 QualifierEvent (com.ramussoft.common.event.QualifierEvent)10 ResultSet (java.sql.ResultSet)9 SQLException (java.sql.SQLException)9 AttributeType (com.ramussoft.common.AttributeType)8 RowSet (com.ramussoft.database.common.RowSet)8 DataPlugin (com.ramussoft.pb.DataPlugin)8 NFunction (com.ramussoft.pb.data.negine.NFunction)8 AttributeEvent (com.ramussoft.common.event.AttributeEvent)7 Journaled (com.ramussoft.common.journal.Journaled)7 RowMapper (com.ramussoft.jdbc.RowMapper)7 IEngine (com.ramussoft.common.IEngine)6