Search in sources :

Example 76 with Element

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

the class TcpClientEngine method getQualifierIdForElement.

@Override
public long getQualifierIdForElement(long elementId) {
    Long res = qualifirsForElements.get(elementId);
    if (res != null)
        return res.longValue();
    Element element1 = engine.getElement(elementId);
    if (element1 == null) {
        qualifirsForElements.put(elementId, -1l);
        return -1l;
    }
    long id = element1.getQualifierId();
    if (id >= 0) {
        List<Element> list = engine.getElements(id);
        for (Element element : list) qualifirsForElements.put(element.getId(), element.getQualifierId());
    }
    return id;
}
Also used : Element(com.ramussoft.common.Element)

Example 77 with Element

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

the class LogPlugin method modify.

@Override
public Action[] modify(Action[] actions, final TableEditor tableEditor) {
    actions = Arrays.copyOf(actions, actions.length + 1);
    actions[actions.length - 1] = new AbstractAction("Log", new ImageIcon(getClass().getResource("/com/ramussoft/client/log/log.png"))) {

        /**
         */
        private static final long serialVersionUID = 8698485078278772063L;

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableEditor.getFramework();
            Engine engine = framework.getEngine();
            long qId = StandardAttributesPlugin.getTableQualifierForAttribute(engine, tableEditor.getAttribute()).getId();
            List<Event> events = ((ILog) engine).getEventsWithParams(new String[] { EngineLogExtension.QUALIFIER_ID }, new Object[] { qId }, 750);
            List<Event> events2 = new ArrayList<Event>();
            Attribute attribute = StandardAttributesPlugin.getTableElementIdAttribute(engine);
            Element el = tableEditor.getElement();
            for (Event event : events) {
                Long elementId = (Long) event.getAttribute("element_id");
                if (elementId != null) {
                    Element element = engine.getElement(elementId);
                    if (element != null) {
                        Long l = (Long) engine.getAttribute(element, attribute);
                        if (l != null && l.equals(el.getId()))
                            events2.add(event);
                    }
                }
            }
            ElementLogDialog dialog = new ElementLogDialog(events2, engine);
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));
            Options.loadOptions(dialog);
            dialog.setVisible(true);
            Options.saveOptions(dialog);
        }
    };
    return actions;
}
Also used : ImageIcon(javax.swing.ImageIcon) Attribute(com.ramussoft.common.Attribute) ActionEvent(java.awt.event.ActionEvent) GUIFramework(com.ramussoft.gui.common.GUIFramework) Element(com.ramussoft.common.Element) Event(com.ramussoft.common.logger.Event) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) List(java.util.List) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine)

Example 78 with Element

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

the class CachedEngine method loadCachedElement.

private CachedElement loadCachedElement(Long id) {
    Element element = deligate.getElement(id);
    if (element == null)
        return null;
    getCachedQualifier(element.getQualifierId());
    return elements.get(id);
}
Also used : Element(com.ramussoft.common.Element)

Example 79 with Element

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

the class ModelParaleler method getRow.

private Row getRow(long rowId) {
    if (rowId < 0l)
        return null;
    Row res = rowHash.get(rowId);
    if (res == null) {
        Row row = fromDataPlugin.findRowByGlobalId(rowId);
        if (row == null)
            return null;
        Element element = row.getElement();
        if (!((row instanceof Stream) && (element.getName().equals("")))) {
            Qualifier qualifier = null;
            if (row instanceof Stream)
                qualifier = IDEF0Plugin.getBaseStreamQualifier(toEngine);
            else
                qualifier = getQualifier(element.getQualifierId());
            if (qualifier == null)
                return null;
            Element e = toEngine.getElement(element.getName(), qualifier.getId());
            if (e != null) {
                Row row2 = toDataPlugin.findRowByGlobalId(e.getId());
                rowHash.put(e.getId(), row2);
                return row2;
            }
        }
        Row r = fromDataPlugin.findRowByGlobalId(rowId);
        res = toDataPlugin.createRow(getRow(getParentRow(r)), r.isElement());
        rowHash.put(r.getElement().getId(), res);
        copyRow(r, res);
    }
    return res;
}
Also used : Element(com.ramussoft.common.Element) Stream(com.ramussoft.pb.Stream) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row)

Example 80 with Element

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

the class StreamAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private SectorRowsEditor sectorRowsEditor;

        private SectorNameEditor sectorNameEditor;

        private PaintSector.Pin pin;

        private DataPlugin dataPlugin;

        private PaintSector sector;

        private JTabbedPane component;

        {
            dataPlugin = NDataPluginFactory.getDataPlugin(null, engine, rules);
            Sector sector = dataPlugin.findSectorByGlobalId(GlobalId.create(element.getId()));
            if (sector != null) {
                dataPlugin = NDataPluginFactory.getDataPlugin(engine.getQualifier(sector.getFunction().getElement().getQualifierId()), engine, rules);
                component = new JTabbedPane();
                sectorRowsEditor = new SectorRowsEditor(dataPlugin, framework, rules);
                sectorNameEditor = new SectorNameEditor(dataPlugin, framework, rules) {

                    @Override
                    public Stream getStream() {
                        return sectorRowsEditor.getStream();
                    }
                };
                sectorRowsEditor.setSectorNameEditor(sectorNameEditor);
                component.addTab(ResourceLoader.getString("stream"), null, sectorRowsEditor, null);
                component.addTab(ResourceLoader.getString("name"), null, sectorNameEditor, null);
                ResourceLoader.setJComponentsText(sectorRowsEditor);
                ResourceLoader.setJComponentsText(sectorNameEditor);
            }
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            sector = pin.getSector();
            sectorNameEditor.setSector(sector.getSector());
            sectorRowsEditor.setSector(sector.getSector());
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public JComponent getComponent() {
            if (component == null)
                return new JPanel();
            return component;
        }

        @Override
        public JComponent getLastComponent() {
            return component;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            sector.setShowText(sectorNameEditor.getBox().isSelected());
            sector.setAlternativeText(sectorNameEditor.getAlternativeTextField().getText());
            Stream stream = sectorRowsEditor.getStream();
            if (stream == null) {
                stream = sectorNameEditor.findStreamByName();
                if (stream == null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            final String t = sectorNameEditor.getArrowName();
            if (!t.equals("")) {
                if (!t.equals(stream.getName()) && sectorNameEditor.findStreamByName(stream.getName()) != null) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                }
            }
            if (t.equals("")) {
                if (!stream.isEmptyName()) {
                    stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
                    stream.setEmptyName(true);
                }
            } else
                stream.setName(t);
            final Row[] added = stream.getAdded();
            stream.setRows(sectorRowsEditor.getRows());
            sector.setStream(stream, sectorNameEditor.getReplaceStreamType());
            stream = sector.getStream();
            stream.setRows(added);
            // sector.setStreamAddedByRefactor(false);
            final Row[] rs = sectorRowsEditor.getRows();
            sector.setRows(rs);
            sector.createTexts();
            PaintSector.save(sector, new DataLoader.MemoryData(), engine);
            sector.getMovingArea().getRefactor().setUndoPoint();
            sectorNameEditor.setChanged(false);
        }

        @Override
        public boolean canApply() {
            final boolean b = isSave();
            if (b) {
                if (!isOkStreamName()) {
                    if (JOptionPane.showConfirmDialog(component, ResourceLoader.getString("you_entered_exists_stream_continue"), ResourceLoader.getString("warning"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
                        return false;
                }
            } else {
                JOptionPane.showMessageDialog(component, ResourceLoader.getString("you_should_enter_name_or_at_least_on_added_elemen"));
                return false;
            }
            return b;
        }

        private boolean isSave() {
            final Row[] rs = sectorRowsEditor.getRows();
            final boolean b = rs.length > 0 || !sectorNameEditor.getArrowName().equals("");
            return b;
        }

        private boolean isOkStreamName() {
            final Stream stream = sectorNameEditor.findStreamByName();
            if (stream != null)
                return stream.equals(sectorNameEditor.getNullStream());
            return true;
        }

        @Override
        public boolean isSaveAnyway() {
            return sectorRowsEditor.isChanged() || sectorNameEditor.isChanged();
        }

        @Override
        public void close() {
            super.close();
            sectorRowsEditor.dispose();
        }
    };
}
Also used : JPanel(javax.swing.JPanel) Attribute(com.ramussoft.common.Attribute) Sector(com.ramussoft.pb.Sector) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) JTabbedPane(javax.swing.JTabbedPane) Element(com.ramussoft.common.Element) SectorNameEditor(com.ramussoft.pb.idef.frames.SectorNameEditor) DataLoader(com.dsoft.utils.DataLoader) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) SectorRowsEditor(com.ramussoft.pb.idef.frames.SectorRowsEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Stream(com.ramussoft.pb.Stream) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) Engine(com.ramussoft.common.Engine)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6