Search in sources :

Example 1 with OtherElementPropertyPersistent

use of com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent in project ramus by Vitaliy-Yakovchuk.

the class OtherElementAttributeViewer method printAttribute.

@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
    Engine engine = dataPlugin.getEngine();
    Long id = (Long) engine.getAttribute(element, attribute);
    if (id != null) {
        Element element2 = engine.getElement(id);
        if (element2 != null) {
            OtherElementPropertyPersistent pp = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
            Attribute other = engine.getAttribute(pp.getQualifierAttribute());
            if (other != null) {
                callback.beforePrint(printStream);
                printLinkToElement(element2, engine.getAttribute(element2, other), parser, printStream);
                callback.afterPrint(printStream);
            }
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Engine(com.ramussoft.common.Engine) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent)

Example 2 with OtherElementPropertyPersistent

use of com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent in project ramus by Vitaliy-Yakovchuk.

the class IDEF0Plugin method init.

@Override
public void init(final Engine engine, AccessRules accessor) {
    super.init(engine, accessor);
    engine.setPluginProperty(IDEF0, PLUGIN, this);
    Qualifier crosspoints = getQualifier(CROSSPOINTS);
    if (crosspoints != null) {
        List<Element> elements = engine.getElements(crosspoints.getId());
        Attribute crosspointId = getSysteAttribute(CROSSPOINT_ID_ATTRIBUTE);
        if (elements.size() > 0) {
            Element element = elements.get(0);
            try {
                long long1 = (Long) engine.getAttribute(element, crosspointId);
                while ((long1 > engine.nextValue(CROSSPOINTS_SEQUENCE))) ;
            } catch (NullPointerException e) {
            }
            engine.deleteElement(element.getId());
        }
        crosspoints.getSystemAttributes().clear();
        engine.updateQualifier(crosspoints);
        try {
            engine.deleteAttribute(crosspointId.getId());
        } catch (Exception e) {
        }
        engine.deleteQualifier(crosspoints.getId());
    }
    functionAttributes.add(createAttribute(F_VISUAL_DATA, new AttributeType(IDEF0, "VisualData", false)));
    functionAttributes.add(createAttribute(F_PAGE_SIZE, new AttributeType("Core", "Text", true)));
    functionAttributes.add(createAttribute(F_BACKGROUND, new AttributeType(IDEF0, "Color", false)));
    functionAttributes.add(createAttribute(F_FOREGROUND, new AttributeType(IDEF0, "Color", false)));
    functionAttributes.add(createAttribute(F_BOUNDS, new AttributeType(IDEF0, "FRectangle", false)));
    functionAttributes.add(createAttribute(F_FONT, new AttributeType(IDEF0, "Font", false)));
    functionAttributes.add(createAttribute(F_STATUS, new AttributeType(IDEF0, "Status", false)));
    functionAttributes.add(createAttribute(F_TYPE, new AttributeType(IDEF0, "Type", false)));
    functionAttributes.add(createAttribute(F_OUNER_ID, new AttributeType(IDEF0, "OunerId", false)));
    functionAttributes.add(createAttribute(F_DECOMPOSITION_TYPE, new AttributeType(IDEF0, "DecompositionType", false)));
    functionAttributes.add(createAttribute(F_AUTHOR, new AttributeType("Core", "Text", true)));
    functionAttributes.add(createAttribute(F_CREATE_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_REV_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_SYSTEM_REV_DATE, new AttributeType("Core", "Date", false)));
    functionAttributes.add(createAttribute(F_LINK, new AttributeType("Core", "Long", false)));
    Attribute sectorFunction = createAttribute(F_SECTOR_FUNCTION, new AttributeType("Core", "OtherElement", false));
    Attribute sStream = createAttribute(F_SECTOR_STREAM, new AttributeType("Core", "OtherElement", false));
    Attribute sPoints = createAttribute(F_SECTOR_POINTS, new AttributeType(IDEF0, "SectorPoint", false));
    Attribute sProperties = createAttribute(F_SECTOR_PROPERTIES, new AttributeType(IDEF0, "SectorProperties", false));
    Attribute sStreamName = createAttribute(F_STREAM_NAME, new AttributeType("Core", "Text", true));
    Attribute aSector = createAttribute(F_SECTOR_ATTRIBUTE, new AttributeType(IDEF0, "Sector", false));
    Attribute aSectorBorderStart = createAttribute(F_SECTOR_BORDER_START, new AttributeType(IDEF0, "SectorBorder", false));
    Attribute aSectorBorderEnd = createAttribute(F_SECTOR_BORDER_END, new AttributeType(IDEF0, "SectorBorder", false));
    Attribute aStreamAdded = createAttribute(F_STREAM_ADDED, new AttributeType(IDEF0, "AnyToAny", false));
    baseFunctionQualifierId = createAttribute(F_BASE_FUNCTION_QUALIFIER_ID, new AttributeType("Core", "Long", true));
    visualAttributes.add(getAttribute(engine, F_BOUNDS));
    visualAttributes.add(getAttribute(engine, F_FONT));
    visualAttributes.add(getAttribute(engine, F_BACKGROUND));
    visualAttributes.add(getAttribute(engine, F_FOREGROUND));
    Qualifier sectors = createQualifier(F_SECTORS);
    if (justCreated) {
        sectors.getSystemAttributes().add(aSector);
        sectors.getSystemAttributes().add(aSectorBorderStart);
        sectors.getSystemAttributes().add(aSectorBorderEnd);
        sectors.getSystemAttributes().add(sectorFunction);
    }
    Qualifier streams = createQualifier(F_STREAMS);
    boolean updateSectors = false;
    if (justCreated) {
        Attribute hierarchical = (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE);
        OtherElementPropertyPersistent p = new OtherElementPropertyPersistent();
        p.setQualifier(sectors.getId());
        p.setQualifierAttribute(sStreamName.getId());
        engine.setAttribute(null, sStream, p);
        streams.getSystemAttributes().add(aStreamAdded);
        streams.getSystemAttributes().add(hierarchical);
        streams.getSystemAttributes().add(sStreamName);
        streams.setAttributeForName(sStreamName.getId());
        engine.updateQualifier(streams);
        sectors.getSystemAttributes().add(0, sStream);
        sectors.getSystemAttributes().add(hierarchical);
        updateSectors = true;
    }
    if (sectors.getSystemAttributes().indexOf(sStream) != 0) {
        sectors.getSystemAttributes().remove(sStream);
        sectors.getSystemAttributes().add(0, sStream);
        updateSectors = true;
    }
    if (sectors.getSystemAttributes().indexOf(sPoints) < 0) {
        sectors.getSystemAttributes().add(sPoints);
        sectors.getSystemAttributes().add(sProperties);
        updateSectors = true;
    }
    if (updateSectors)
        engine.updateQualifier(sectors);
    projectPreferencesAttrtibute = createAttribute(F_PROJECT_PREFERENCES, new AttributeType(IDEF0, "ProjectPreferences", false));
    baseFunctions = createQualifier(F_BASE_FUNCTIONS);
    if (justCreated) {
        baseFunctions.getSystemAttributes().add(baseFunctionQualifierId);
        baseFunctions.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
        baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
        engine.updateQualifier(baseFunctions);
        installFunctionAttributes(baseFunctions, engine);
    } else {
        if (baseFunctions.getSystemAttributes().indexOf(projectPreferencesAttrtibute) < 0) {
            baseFunctions.getSystemAttributes().add(projectPreferencesAttrtibute);
            engine.updateQualifier(baseFunctions);
        }
        checkIDEF0Attributes(engine, baseFunctions);
    }
    Qualifier modelTree = createQualifier(F_MODEL_TREE);
    final Attribute name = StandardAttributesPlugin.getAttributeNameAttribute(engine);
    if (justCreated) {
        modelTree.getSystemAttributes().add((Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE));
        modelTree.getSystemAttributes().add(StandardAttributesPlugin.getAttributeQualifierId(engine));
        modelTree.getAttributes().add(name);
        modelTree.setAttributeForName(name.getId());
        engine.updateQualifier(modelTree);
        checkModelTree(modelTree);
    }
    if (!StandardAttributesPlugin.isDisableAutoupdate(engine)) {
        engine.addElementAttributeListener(modelTree, new ElementAttributeListener() {

            @Override
            public void attributeChanged(AttributeEvent event) {
                if (event.isJournaled())
                    return;
                if (name.equals(event.getAttribute())) {
                    Long id = (Long) engine.getAttribute(event.getElement(), StandardAttributesPlugin.getAttributeQualifierId(engine));
                    if (id != null) {
                        Qualifier model = engine.getQualifier(id);
                        if (model != null) {
                            model.setName(String.valueOf(event.getNewValue()));
                            engine.updateQualifier(model);
                        }
                    }
                }
            }
        });
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementAttributeListener(com.ramussoft.common.event.ElementAttributeListener) Element(com.ramussoft.common.Element) AttributeEvent(com.ramussoft.common.event.AttributeEvent) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier)

Example 3 with OtherElementPropertyPersistent

use of com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent in project ramus by Vitaliy-Yakovchuk.

the class ComplexImport method getOtherElemetQualifierId.

public long getOtherElemetQualifierId(Attribute attribute) {
    Long long1 = otherElemetsQualifierId.get(attribute);
    if (long1 == null) {
        OtherElementPropertyPersistent pp = (OtherElementPropertyPersistent) rowSet.getEngine().getAttribute(null, attribute);
        long1 = pp.getQualifier();
        otherElemetsQualifierId.put(attribute, long1);
    }
    return long1;
}
Also used : OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent)

Example 4 with OtherElementPropertyPersistent

use of com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent in project ramus by Vitaliy-Yakovchuk.

the class OtherElementPlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, String propertiesPrefix, AttributeEditor old) {
    if (old != null) {
        if ((old == otherElementEditor) && (this.attribute.equals(attribute)))
            return otherElementEditor;
        else
            old.close();
    }
    OtherElementPropertyPersistent p = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
    final Qualifier qualifier = engine.getQualifier(p.getQualifier());
    this.attribute = attribute;
    otherElementEditor = new OtherElementEditor(engine, rules, qualifier, framework, propertiesPrefix);
    return otherElementEditor;
}
Also used : Qualifier(com.ramussoft.common.Qualifier) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent)

Example 5 with OtherElementPropertyPersistent

use of com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent in project ramus by Vitaliy-Yakovchuk.

the class OtherElementPlugin method getAttributePreferenciesEditor.

@Override
public AttributePreferenciesEditor getAttributePreferenciesEditor() {
    return new AttributePreferenciesEditor() {

        private JComboBox qualifierBox = new JComboBox();

        private JComboBox attributeBox = new JComboBox();

        @Override
        public void apply(Attribute attribute, Engine engine, AccessRules accessRules) {
            OtherElementPropertyPersistent p = new OtherElementPropertyPersistent();
            p.setQualifier(((Qualifier) qualifierBox.getSelectedItem()).getId());
            p.setQualifierAttribute(((Attribute) attributeBox.getSelectedItem()).getId());
            engine.setAttribute(null, attribute, p);
        }

        @Override
        public boolean canApply() {
            return (qualifierBox.getSelectedItem() != null) && (attributeBox.getSelectedItem() != null);
        }

        @Override
        public JComponent createComponent(Attribute attribute, Engine engine, AccessRules accessRules) {
            double[][] size = { { 5, TableLayout.FILL, 5, TableLayout.FILL, 5 }, { 5, TableLayout.MINIMUM, 5, TableLayout.MINIMUM, 5 } };
            JPanel panel = new JPanel(new TableLayout(size));
            panel.add(new JLabel(GlobalResourcesManager.getString("OtherElement.Qualifier")), "1, 1");
            panel.add(new JLabel(GlobalResourcesManager.getString("OtherElement.Attribute")), "3, 1");
            for (Qualifier qualifier : engine.getQualifiers()) {
                qualifierBox.addItem(qualifier);
            }
            if (attribute != null) {
                OtherElementPropertyPersistent p = (OtherElementPropertyPersistent) engine.getAttribute(null, attribute);
                qualifierBox.setSelectedItem(engine.getQualifier(p.getQualifier()));
                long attributeId = p.getQualifierAttribute();
                if (attributeId >= 0)
                    attributeBox.setSelectedItem(engine.getAttribute(attributeId));
                qualifierBox.setEnabled(false);
            }
            qualifierBox.addItemListener(new ItemListener() {

                @Override
                public void itemStateChanged(ItemEvent e) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        loadAttributes();
                    }
                }
            });
            loadAttributes();
            panel.add(qualifierBox, "1, 3");
            panel.add(attributeBox, "3, 3");
            return panel;
        }

        private void loadAttributes() {
            attributeBox.removeAllItems();
            Qualifier qualifier = (Qualifier) qualifierBox.getSelectedItem();
            if (qualifier == null)
                return;
            for (Attribute attribute : qualifier.getAttributes()) {
                attributeBox.addItem(attribute);
            }
        }
    };
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) JComboBox(javax.swing.JComboBox) Attribute(com.ramussoft.common.Attribute) JLabel(javax.swing.JLabel) AttributePreferenciesEditor(com.ramussoft.gui.common.AttributePreferenciesEditor) OtherElementPropertyPersistent(com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent) AccessRules(com.ramussoft.common.AccessRules) Qualifier(com.ramussoft.common.Qualifier) ItemListener(java.awt.event.ItemListener) TableLayout(info.clearthought.layout.TableLayout) Engine(com.ramussoft.common.Engine)

Aggregations

OtherElementPropertyPersistent (com.ramussoft.core.attribute.simple.OtherElementPropertyPersistent)8 Attribute (com.ramussoft.common.Attribute)6 Qualifier (com.ramussoft.common.Qualifier)6 Element (com.ramussoft.common.Element)2 Engine (com.ramussoft.common.Engine)2 AccessRules (com.ramussoft.common.AccessRules)1 AttributeType (com.ramussoft.common.AttributeType)1 AttributeEvent (com.ramussoft.common.event.AttributeEvent)1 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)1 RowSet (com.ramussoft.database.common.RowSet)1 AttributePreferenciesEditor (com.ramussoft.gui.common.AttributePreferenciesEditor)1 TableLayout (info.clearthought.layout.TableLayout)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1