Search in sources :

Example 71 with Element

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

the class ElistTableModel method getValueAt.

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Element element = left.getElement(rowIndex);
    List<ElementListPersistent> value = data.get(element);
    if (value == null) {
        value = new ArrayList<ElementListPersistent>();
        data.put(element, value);
    }
    Element c = top.getElement(columnIndex);
    for (ElementListPersistent p : value) {
        if (revert) {
            if (p.getElement1Id() == c.getId())
                return p;
        } else {
            if (p.getElement2Id() == c.getId())
                return p;
        }
    }
    return null;
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Element(com.ramussoft.common.Element)

Example 72 with Element

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

the class ElementListPlugin method syncElement.

@SuppressWarnings("unchecked")
@Override
public void syncElement(Engine engine, QualifierImporter importer, Element sourceElement, Attribute sourceAttribute) {
    List<ElementListPersistent> list = (List) importer.getSourceValue(sourceElement, sourceAttribute);
    List<ElementListPersistent> set = null;
    if (list != null) {
        for (ElementListPersistent p : list) if ((p != null) && (p.getElement1Id() == sourceElement.getId())) {
            if (set == null)
                set = new ArrayList<ElementListPersistent>(list.size());
            Element element1 = importer.getDestinationElement(p.getElement1Id());
            Element element2 = importer.getDestinationElement(p.getElement2Id());
            if ((element1 != null) && (element2 != null)) {
                ElementListPersistent d = new ElementListPersistent(element1.getId(), element2.getId());
                set.add(d);
            }
        }
    }
    if (set != null)
        engine.setAttribute(importer.getDestination(sourceElement), importer.getDestination(sourceAttribute), set);
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) List(java.util.List)

Example 73 with Element

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

the class OtherElementPlugin method syncElement.

@Override
public void syncElement(Engine engine, QualifierImporter importer, Element sourceElement, Attribute sourceAttribute) {
    Long id = (Long) importer.getSourceValue(sourceElement, sourceAttribute);
    if (id == null)
        return;
    Element dest = importer.getDestinationElement(id);
    if (dest != null)
        engine.setAttribute(importer.getDestination(sourceElement), importer.getDestination(sourceAttribute), dest.getId());
    else {
        Element sourceElementValue = importer.getSource().getElement(id);
        if (sourceElementValue == null)
            return;
        Qualifier sq = importer.getSource().getQualifier(sourceElementValue.getQualifierId());
        Qualifier qualifier = importer.getDestination(sq);
        if (qualifier == null) {
            qualifier = engine.getQualifierByName(sq.getName());
        }
        if (qualifier == null)
            return;
        Element d = engine.getElement(sourceElementValue.getName(), qualifier.getId());
        if (d == null)
            return;
        engine.setAttribute(importer.getDestination(sourceElement), importer.getDestination(sourceAttribute), d.getId());
    }
}
Also used : Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 74 with Element

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

the class SectorRowsEditor method getRowSelectDialog.

private SelectRowDialog getRowSelectDialog() {
    if (rowSelectDialog == null) {
        rowSelectDialog = new SelectRowDialog(dialog) {
        };
        rowSelectDialog.init(framework, dataPlugin, accessRules);
        List<Element> hide = new ArrayList<Element>(1);
        hide.add(((com.ramussoft.database.common.Row) dataPlugin.getBaseFunction()).getElement());
        rowSelectDialog.setQuaifierHideElements(hide);
    }
    return rowSelectDialog;
}
Also used : Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) SelectRowDialog(com.ramussoft.pb.frames.SelectRowDialog)

Example 75 with Element

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

the class TableChartAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor oldAttributeEditor) {
    return new AbstractAttributeEditor() {

        @Override
        public Object setValue(Object value) {
            return null;
        }

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

        @Override
        public JComponent getComponent() {
            ChartDataFramework chartDataFramework = ChartDataFramework.getChartDataFramework(engine);
            ChartSource source = new ChartSource(engine) {

                @Override
                public List<Element> getElements() {
                    List<Element> res = new ArrayList<Element>();
                    for (QualifierSource source : qualifierSources) {
                        if (QualifierSource.ELEMENTS_LOAD_TYPE_ALL.equals(source.getElementsLoadType())) {
                            FilterSource filterSource = source.getFilterSources().get(0);
                            Qualifier qualifier = source.getQualifier();
                            if (StandardAttributesPlugin.isTableQualifier(qualifier) && filterSource.getAttribute().equals(StandardAttributesPlugin.getTableElementIdAttribute(engine))) {
                                res.addAll(StandardAttributesPlugin.getOrderedTableElements(engine, StandardAttributesPlugin.getAttributeForTable(engine, qualifier), element));
                            } else
                                res.addAll(engine.findElements(qualifier.getId(), filterSource.getAttribute(), Long.parseLong(filterSource.getValue())));
                        } else
                            for (ElementSource elementSource : source.getElementSources()) res.add(elementSource.getElement());
                    }
                    return res;
                }
            };
            TableChartPersistent tcp = (TableChartPersistent) engine.getAttribute(null, attribute);
            Element chartElement = engine.getElement(tcp.getOtherElementId());
            source.load(chartElement);
            ChartDataPlugin chartDataPlugin = chartDataFramework.getChartDataPlugin(source.getChartType());
            JFreeChart freeChart = chartDataPlugin.createChart(element, source);
            return new ChartPanel(freeChart);
        }
    };
}
Also used : FilterSource(com.ramussoft.chart.FilterSource) ChartPanel(org.jfree.chart.ChartPanel) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) ChartDataFramework(com.ramussoft.chart.ChartDataFramework) JFreeChart(org.jfree.chart.JFreeChart) QualifierSource(com.ramussoft.chart.QualifierSource) ChartDataPlugin(com.ramussoft.chart.ChartDataPlugin) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) ChartSource(com.ramussoft.chart.ChartSource) TableChartPersistent(com.ramussoft.chart.core.TableChartPersistent) Qualifier(com.ramussoft.common.Qualifier) ElementSource(com.ramussoft.chart.ElementSource)

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