Search in sources :

Example 96 with Element

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

the class ReportViewPlugin method addOpenReportEditorListener.

private void addOpenReportEditorListener() {
    framework.addActionListener(OPEN_SCRIPT_REPORT, new ActionListener() {

        @Override
        public void onAction(final ActionEvent event) {
            if (framework.openView(event))
                return;
            final Data data = new Data();
            data.element = (Element) event.getValue();
            data.attributeListener = new ElementAttributeListener() {

                @Override
                public void attributeChanged(AttributeEvent event) {
                    Object value = event.getNewValue();
                    if ((value instanceof String) && (event.getElement().equals(data.element))) {
                        ViewTitleEvent e = new ViewTitleEvent(data.view, value.toString());
                        data.view.titleChanged(e);
                    }
                }
            };
            data.elementListener = new ElementAdapter() {

                @Override
                public void elementDeleted(ElementEvent event) {
                    if (event.getOldElement().equals(data.element)) {
                        data.view.close();
                    }
                }
            };
            engine.addElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
            engine.addElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
            String type = (String) engine.getAttribute(data.element, ReportPlugin.getReportTypeAttribute(engine));
            if (ReportPlugin.TYPE_JSSP.equals(type))
                data.view = new ScriptReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            else if (ReportPlugin.TYPE_JSSP_DOC_BOOK.equals(type))
                data.view = new DocBookScriptReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            else
                data.view = new XMLReportEditorView(framework, data.element) {

                    @Override
                    public void close() {
                        super.close();
                        engine.removeElementListener(ReportPlugin.getReportsQualifier(engine), data.elementListener);
                        engine.removeElementAttributeListener(ReportPlugin.getReportsQualifier(engine), data.attributeListener);
                        TabbedEvent tEvent = new TabbedEvent("TabbedTableView", this);
                        tabRemoved(tEvent);
                    }

                    @Override
                    public String getTitle() {
                        return data.element.getName();
                    }
                };
            TabbedEvent tEvent = new TabbedEvent(REPORTS_TAB_VIEW, data.view);
            tabCreated(tEvent);
        }
    });
}
Also used : ElementAdapter(com.ramussoft.common.event.ElementAdapter) ActionEvent(com.ramussoft.gui.common.event.ActionEvent) ElementAttributeListener(com.ramussoft.common.event.ElementAttributeListener) Element(com.ramussoft.common.Element) ElementEvent(com.ramussoft.common.event.ElementEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent) TabbedEvent(com.ramussoft.gui.common.event.TabbedEvent) XMLReportEditorView(com.ramussoft.report.editor.XMLReportEditorView) DocBookScriptReportEditorView(com.ramussoft.report.editor.DocBookScriptReportEditorView) ViewTitleEvent(com.ramussoft.gui.common.event.ViewTitleEvent) ActionListener(com.ramussoft.gui.common.event.ActionListener) ScriptReportEditorView(com.ramussoft.report.editor.ScriptReportEditorView) DocBookScriptReportEditorView(com.ramussoft.report.editor.DocBookScriptReportEditorView)

Example 97 with Element

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

the class QueryView method getQuery.

public Query getQuery() {
    if (selectableTableView == null)
        return null;
    Query query = new Query(new HashMap<String, String>(0));
    List<Row> rows = selectableTableView.getSelectedRows();
    ArrayList<Element> elements = new ArrayList<Element>(rows.size());
    for (Row row : rows) elements.add(row.getElement());
    query.setElements(elements);
    return query;
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Query(com.ramussoft.report.Query) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Row(com.ramussoft.database.common.Row)

Example 98 with Element

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

the class NewProjectDialog method showModal.

public void showModal(final Engine engine, final AccessRules accessRules, final GUIFramework framework) {
    ((Journaled) engine).setNoUndoPoint();
    final Properties name_author = new DefaultProperties(new Property[] { new DefaultProperty(AUTOR, Property.TEXT_FIELD), new DefaultProperty(PROJECT_NAME, Property.TEXT_FIELD), new DefaultProperty(MODEL_NAME, Property.TEXT_FIELD) }, Factory.getString("name_author.Describe"));
    final Properties used_at = new DefaultProperties(new Property[] { new DefaultProperty(USED_AT, Property.TEXT_FIELD) }, Factory.getString("used_at.Describe"));
    final Properties def = new DefaultProperties(new Property[] { new DefaultProperty(DEFINITION, Property.TEXT) }, Factory.getString("describe.Describe"));
    final Properties clasificators = new DefaultProperties(new Property[] { new DefaultProperty(CLASIFICATOR1, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR2, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR3, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR4, Property.TEXT_FIELD), new DefaultProperty(CLASIFICATOR5, Property.TEXT_FIELD) }, Factory.getString("Clasificators.Describe"));
    masterModel = new DefaultMasterModel(new Properties[] { name_author, used_at, def, clasificators });
    mainPanel = new MainPanel(new PanelCreator(masterModel)) {

        @Override
        public boolean cancel() {
            if (super.cancel()) {
                NewProjectDialog.this.setVisible(false);
                finish();
                return true;
            }
            return false;
        }

        @Override
        protected void finish() {
            super.finish();
            ((Journaled) engine).startUserTransaction();
            final Qualifier baseFunction = engine.createQualifier();
            String modelName = getValue(MODEL_NAME);
            if ((modelName == null) || (modelName.length() == 0))
                baseFunction.setName(ResourceLoader.getString("base_function"));
            else
                baseFunction.setName(modelName);
            Attribute name = engine.createAttribute(new AttributeType("Core", "Text", true));
            name.setName(ResourceLoader.getString("name"));
            engine.updateAttribute(name);
            java.util.Properties ps = engine.getProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES);
            ps.setProperty(AutochangePlugin.AUTO_ADD_ATTRIBUTE_IDS, Long.toString(name.getId()));
            ps.setProperty(AutochangePlugin.ATTRIBUTE_FOR_NAME, Long.toString(name.getId()));
            engine.setProperties(AutochangePlugin.AUTO_ADD_ATTRIBUTES, ps);
            baseFunction.getAttributes().add(name);
            baseFunction.setAttributeForName(name.getId());
            IDEF0Plugin.installFunctionAttributes(baseFunction, engine);
            Element element = engine.createElement(IDEF0Plugin.getModelTree(engine).getId());
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(engine), baseFunction.getId());
            HierarchicalPersistent hp = new HierarchicalPersistent();
            hp.setParentElementId(-1l);
            hp.setPreviousElementId(-1l);
            engine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(engine), baseFunction.getName());
            engine.setAttribute(element, StandardAttributesPlugin.getHierarchicalAttribute(engine), hp);
            DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(baseFunction, engine, accessRules);
            if (dfd.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFD);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            else if (dfds.isSelected())
                dataPlugin.getBaseFunction().setDecompositionType(MovingArea.DIAGRAM_TYPE_DFDS);
            ProjectOptions projectOptions = new ProjectOptions();
            projectOptions.setProjectAutor(getValue(AUTOR));
            projectOptions.setProjectName(getValue(PROJECT_NAME));
            projectOptions.setDefinition(getValue(DEFINITION));
            projectOptions.setUsedAt(getValue(USED_AT));
            NewProjectDialog.this.setVisible(false);
            final String[] cls = getClasifiactors();
            final StringBuffer ounersIds = new StringBuffer();
            for (final String c : cls) {
                Row row = dataPlugin.createRow(null, false);
                Qualifier qualifier = engine.getQualifier(StandardAttributesPlugin.getQualifierId(engine, row.getElement().getId()));
                qualifier.setName(c);
                engine.updateQualifier(qualifier);
                if (ouners.indexOf(c) >= 0) {
                    ounersIds.append(qualifier.getId());
                    ounersIds.append(' ');
                }
            }
            dataPlugin.setProperty(DataPlugin.PROPERTY_OUNERS, ounersIds.toString());
            dataPlugin.getBaseFunction().setProjectOptions(projectOptions);
            ((Journaled) engine).commitUserTransaction();
            ((Journaled) engine).setNoUndoPoint();
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    framework.propertyChanged("ShowWorkspace", "Workspace.IDEF0");
                    OpenDiagram open = new OpenDiagram(baseFunction, -1l);
                    framework.propertyChanged(IDEF0ViewPlugin.OPEN_DIAGRAM, open);
                }
            });
        }
    };
    setContentPane(mainPanel);
    pack();
    Dimension size = this.getSize();
    setMinimumSize(new Dimension(size.width, size.height + 30));
    setLocationRelativeTo(null);
    setVisible(true);
    frame.repaint();
}
Also used : DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Dimension(java.awt.Dimension) DefaultProperties(com.ramussoft.pb.master.model.DefaultProperties) Properties(com.ramussoft.pb.master.model.Properties) DefaultProperty(com.ramussoft.pb.master.model.DefaultProperty) Journaled(com.ramussoft.common.journal.Journaled) MainPanel(com.ramussoft.pb.master.gui.MainPanel) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) AttributeType(com.ramussoft.common.AttributeType) DefaultPanelCreator(com.ramussoft.pb.master.gui.DefaultPanelCreator) OpenDiagram(com.ramussoft.idef0.OpenDiagram) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin) DefaultMasterModel(com.ramussoft.pb.master.model.DefaultMasterModel) ProjectOptions(com.dsoft.pb.idef.elements.ProjectOptions)

Example 99 with Element

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

the class ElementListAttributeViewer method printAttribute.

@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
    Engine engine = dataPlugin.getEngine();
    Qualifier qualifier = engine.getQualifier(element.getQualifierId());
    List<ElementListPersistent> list = (List<ElementListPersistent>) engine.getAttribute(element, attribute);
    ElementListPropertyPersistent pp = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
    boolean left = qualifier.getId() == pp.getQualifier2();
    if (list.size() > 0) {
        callback.beforePrint(printStream);
        printStream.println("<br>");
        for (ElementListPersistent p : list) {
            long id;
            if (left)
                id = p.getElement1Id();
            else
                id = p.getElement2Id();
            Element element2 = engine.getElement(id);
            if (element2 != null) {
                printLinkToElement(element2, parser, printStream);
                printStream.println("<br>");
            }
        }
        callback.afterPrint(printStream);
    }
}
Also used : ElementListPersistent(com.ramussoft.core.attribute.simple.ElementListPersistent) Element(com.ramussoft.common.Element) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) Qualifier(com.ramussoft.common.Qualifier) List(java.util.List) Engine(com.ramussoft.common.Engine)

Example 100 with Element

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

the class ChartSource method getElements.

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), engine.getElement(Long.parseLong(filterSource.getValue()))));
            } 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;
}
Also used : Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier)

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