Search in sources :

Example 31 with Element

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

the class CreateChartDialog method onOk.

@Override
protected void onOk() {
    Engine engine = framework.getEngine();
    try {
        ((Journaled) engine).startUserTransaction();
        Element element = chartsView.createChartElement(name.getText());
        editor.save(element);
        ((Journaled) engine).commitUserTransaction();
    } catch (Exception e) {
        ((Journaled) engine).rollbackUserTransaction();
        e.printStackTrace();
        JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
    }
    super.onOk();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Element(com.ramussoft.common.Element) Engine(com.ramussoft.common.Engine)

Example 32 with Element

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

the class PieChartDataPlugin method createChart.

@Override
public JFreeChart createChart(Element element, ChartSource source) {
    Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
    Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
    if ((key == null) || (value == null))
        throw new ChartNotSetupedException();
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Element element2 : source.getElements()) {
        Object v1 = engine.getAttribute(element2, key);
        Object v2 = engine.getAttribute(element2, value);
        if ((v1 != null) && (v2 != null))
            dataset.setValue(toString(v1), toDouble(v2));
    }
    return ChartFactory.createPieChart(element.getName(), dataset, true, true, false);
}
Also used : DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ChartNotSetupedException(com.ramussoft.chart.exception.ChartNotSetupedException)

Example 33 with Element

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

the class ChartPlugin method createChartLink.

public static Element createChartLink(Engine engine) {
    ChartPlugin plugin = getChartPlugin(engine);
    Element element = engine.createElement(plugin.chartLinks.getId());
    return element;
}
Also used : Element(com.ramussoft.common.Element)

Example 34 with Element

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

the class ChartPlugin method getChartLink.

public static Element getChartLink(Engine engine, Element chartSet, Element chart) {
    ChartPlugin plugin = getChartPlugin(engine);
    Long id = chart.getId();
    for (Element element : engine.findElements(plugin.chartLinks.getId(), plugin.chartSet, chartSet.getId())) {
        if (id.equals(engine.getAttribute(element, plugin.chart))) {
            return element;
        }
    }
    return null;
}
Also used : Element(com.ramussoft.common.Element)

Example 35 with Element

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

the class QualifierImporterImpl method createQualifier.

private Qualifier createQualifier(Qualifier sourceQualifier, Row row) {
    Qualifier res = engine.getQualifierByName(sourceQualifier.getName());
    if (res == null) {
        Qualifier q = StandardAttributesPlugin.getQualifiersQualifier(engine);
        RowSet rs = new RowSet(engine, q, new Attribute[] {});
        Row parent = findParent(rs, row.getParent());
        if ((parent != null) && (parent.getElement() == null))
            parent = null;
        if ((parent != null) && (engine.getElements(StandardAttributesPlugin.getQualifier(engine, parent.getElement()).getId()).size() > 0))
            parent = null;
        Element element = rs.createRow(parent).getElement();
        res = StandardAttributesPlugin.getQualifier(engine, element);
        res.setName(sourceQualifier.getName());
        engine.updateQualifier(res);
        rs.close();
    }
    return res;
}
Also used : Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.database.common.Row)

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