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();
}
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();
}
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();
}
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);
}
};
}
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();
}
Aggregations