Search in sources :

Example 81 with Attribute

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

the class ModelParaleler method checkAttributes.

private void checkAttributes(Qualifier from, Qualifier to) {
    boolean update = false;
    List<Attribute> list = getAttributes(from.getAttributes());
    for (Attribute a : list) {
        if (to.getAttributes().indexOf(a) < 0) {
            to.getAttributes().add(a);
            update = true;
        }
    }
    if (update)
        toEngine.updateQualifier(to);
}
Also used : Attribute(com.ramussoft.common.Attribute)

Example 82 with Attribute

use of com.ramussoft.common.Attribute 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 83 with Attribute

use of com.ramussoft.common.Attribute 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)

Example 84 with Attribute

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

the class SetElementQualifierCommand method undo.

@Override
public void undo(IEngine iEngine) {
    Element element = iEngine.getElement(elementId);
    Element newElement = new Element(element.getId(), oldQualifierId, element.getName());
    ElementEvent event = new ElementEvent(engine, element, newElement, newQualifierId, true);
    engine.beforeElementDeleted(event);
    iEngine.setElementQualifier(elementId, oldQualifierId);
    engine.elementDeleted(event);
    event = new ElementEvent(engine, element, newElement, oldQualifierId, true);
    engine.elementCreated(event);
    Qualifier oldQualifier = iEngine.getQualifier(oldQualifierId);
    Qualifier newQualifier = iEngine.getQualifier(newQualifierId);
    List<Attribute> attrs = new ArrayList<Attribute>();
    addNotPresentAttributes(oldQualifier.getAttributes(), newQualifier.getAttributes(), attrs);
    addNotPresentAttributes(oldQualifier.getSystemAttributes(), newQualifier.getSystemAttributes(), attrs);
    List<Attribute> as = oldQualifier.getAttributes();
    as.addAll(oldQualifier.getSystemAttributes());
    int i = 0;
    for (Attribute a : as) {
        if (attrs.indexOf(a) >= 0) {
            iEngine.setBinaryAttribute(elementId, a.getId(), data[i]);
            i++;
        }
        Object object = engine.getAttribute(newElement, a);
        if (object != null) {
            AttributeEvent event2 = new AttributeEvent(engine, newElement, a, null, object, true);
            engine.attributeChanged(event2);
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) ElementEvent(com.ramussoft.common.event.ElementEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 85 with Attribute

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

the class UpdateAttributeCommand method readBody.

@Override
public void readBody(BinaryDataInput input) throws IOException {
    oldAttribute = new Attribute();
    newAttribute = new Attribute();
    loadAttribute(input, oldAttribute);
    loadAttribute(input, newAttribute);
}
Also used : Attribute(com.ramussoft.common.Attribute)

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