Search in sources :

Example 1 with Journaled

use of com.ramussoft.common.journal.Journaled 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 2 with Journaled

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

the class NFunction method setDefaultValues.

public void setDefaultValues() {
    boolean inTransaction = false;
    if (engine instanceof Journaled) {
        inTransaction = ((Journaled) engine).isUserTransactionStarted();
        if (!inTransaction)
            ((Journaled) engine).startUserTransaction();
    }
    setSectorData(new byte[0]);
    setBackground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_COLOR", Color.white));
    setForeground(Options.getColor("DEFAULD_FUNCTIONAL_BLOCK_TEXT_COLOR", Color.black));
    setBounds(new FRectangle(IDEFPanel.DEFAULT_X, IDEFPanel.DEFAULT_Y, IDEFPanel.DEFAULT_WIDTH * 1.2, IDEFPanel.DEFAULT_HEIGHT * 1.2));
    setFont(Options.getFont("DEFAULT_FUNCTIONAL_BLOCK_FONT", new Font("Dialog", 0, 10)));
    setStatus(new Status());
    if (engine instanceof Journaled)
        if (!inTransaction)
            ((Journaled) engine).commitUserTransaction();
}
Also used : Status(com.dsoft.pb.idef.elements.Status) Journaled(com.ramussoft.common.journal.Journaled) FRectangle(com.dsoft.pb.types.FRectangle) Font(java.awt.Font)

Example 3 with Journaled

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

the class AbstractDataPlugin method loadFromParalel.

public void loadFromParalel(final DataPlugin dataPlugin, final Function base, final File file, final GUIFramework framework) throws IOException {
    Thread t = new Thread("Paralel-DataLoader") {

        @Override
        public void run() {
            try {
                framework.showAnimation(ResourceLoader.getString("Wait.Message"));
                MemoryDatabase md = new MemoryDatabase() {

                    protected String getJournalDirectoryName(String tmp) {
                        return null;
                    }

                    @Override
                    protected File getFile() {
                        return file;
                    }
                };
                LoadFromParalelDialog dialog = new LoadFromParalelDialog(framework.getMainFrame(), md.getEngine("idef0"));
                if (dialog.showModal()) {
                    ((Journaled) getEngine()).startUserTransaction();
                    try {
                        framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, false);
                        framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, true);
                        DataPlugin fdp = NDataPluginFactory.getDataPlugin(null, md.getEngine("idef0"), md.getAccessRules("idef0"));
                        ModelParaleler paraleler = new ModelParaleler(fdp, dataPlugin, framework);
                        paraleler.loadFromParalel(base, dialog.isImportAll(), dialog.getSelected());
                    } finally {
                        framework.propertyChanged(IDEF0TabView.DISABLE_SILENT_REFRESH, false);
                        ((Journaled) getEngine()).commitUserTransaction();
                        framework.propertyChanged(ModelsView.SET_UPDATE_ALL_MODELS, true);
                        framework.propertyChanged(ModelsView.REFRESH_ALL_MODELS);
                    }
                }
                FileIEngineImpl impl = (FileIEngineImpl) md.getEngine("idef0").getDeligate();
                impl.close();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                framework.hideAnimation();
            }
        }
    };
    t.start();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ModelParaleler(com.ramussoft.idef0.ModelParaleler) LoadFromParalelDialog(com.ramussoft.pb.idef.frames.LoadFromParalelDialog) MemoryDatabase(com.ramussoft.database.MemoryDatabase) DataPlugin(com.ramussoft.pb.DataPlugin) NDataPlugin(com.ramussoft.pb.data.negine.NDataPlugin) IOException(java.io.IOException)

Example 4 with Journaled

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

the class LineStyleAttributePlugin method getTableCellEditor.

@Override
public TableCellEditor getTableCellEditor(final Engine engine, final AccessRules rules, final Attribute attribute) {
    final JComboBox box = new JComboBox();
    box.setRenderer(comboBoxRenderer);
    for (Stroke stroke : LineStyleChooser.getStrokes()) {
        box.addItem(stroke);
    }
    return new DefaultCellEditor(box) {

        private Pin pin;

        @Override
        public boolean stopCellEditing() {
            if (box.getSelectedItem() instanceof Stroke) {
                ((Journaled) engine).startUserTransaction();
                apply((BasicStroke) box.getSelectedItem(), pin);
                return super.stopCellEditing();
            }
            return false;
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            pin = (Pin) ((MetadataGetter) table).getMetadata();
            return super.getTableCellEditorComponent(table, value, isSelected, row, column);
        }
    };
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) JComboBox(javax.swing.JComboBox) Pin(com.ramussoft.pb.idef.elements.PaintSector.Pin) MetadataGetter(com.ramussoft.gui.qualifier.table.MetadataGetter) JTable(javax.swing.JTable) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 5 with Journaled

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

the class SectorCorrector method run.

public void run(Engine engine, AccessRules accessRules) {
    ((Journaled) engine).startUserTransaction();
    log("Loading data");
    List<Qualifier> list = IDEF0Plugin.getBaseQualifiers(engine);
    for (Qualifier q : list) {
        DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(q, engine, accessRules);
        Vector<Row> v = dataPlugin.getRecChilds(dataPlugin.getBaseFunction(), true);
        for (Row r : v) {
            if (r.getChildCount() == 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                while (sr.getSectorsCount() > 0) {
                    sr.getSector(0).remove();
                }
                sr.saveToFunction();
                log("Function " + r + " clean");
            }
        }
        for (Row r : v) {
            if (r.getChildCount() != 0) {
                Function function = (Function) r;
                MovingArea area = new MovingArea(dataPlugin, function);
                area.setDataPlugin(dataPlugin);
                SectorRefactor sr = area.getRefactor();
                sr.loadFromFunction(function, false);
                for (int i = 0; i < sr.getSectorsCount(); i++) {
                    PaintSector ps = sr.getSector(i);
                    if ((ps.getSector().getStart().getFunction() != null) && (ps.getSector().getStart().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, true);
                    if ((ps.getSector().getEnd().getFunction() != null) && (ps.getSector().getEnd().getFunction().getChildCount() == 0))
                        sr.createSectorOnIn(ps, false);
                }
                log("Function " + r + " done");
            }
        }
    }
    ((Journaled) engine).commitUserTransaction();
}
Also used : MovingArea(com.ramussoft.pb.idef.visual.MovingArea) Journaled(com.ramussoft.common.journal.Journaled) Function(com.ramussoft.pb.Function) SectorRefactor(com.ramussoft.pb.idef.elements.SectorRefactor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) DataPlugin(com.ramussoft.pb.DataPlugin)

Aggregations

Journaled (com.ramussoft.common.journal.Journaled)34 Engine (com.ramussoft.common.Engine)9 Attribute (com.ramussoft.common.Attribute)7 Element (com.ramussoft.common.Element)7 Qualifier (com.ramussoft.common.Qualifier)7 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 Row (com.ramussoft.database.common.Row)5 DataPlugin (com.ramussoft.pb.DataPlugin)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)4 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)4 AttributeType (com.ramussoft.common.AttributeType)3 MemoryDatabase (com.ramussoft.database.MemoryDatabase)3 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 Function (com.ramussoft.pb.Function)3 Row (com.ramussoft.pb.Row)3 TreePath (javax.swing.tree.TreePath)3 AccessRules (com.ramussoft.common.AccessRules)2 IEngine (com.ramussoft.common.IEngine)2