use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class TreeModel method valueForPathChanged.
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
Object o = path.getLastPathComponent();
Row row = (Row) o;
((Journaled) row.getEngine()).startUserTransaction();
row.setName(String.valueOf(newValue));
((Journaled) row.getEngine()).commitUserTransaction();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class TableEditorModel method removeElements.
public void removeElements(List<Element> list) {
((Journaled) engine).startUserTransaction();
for (Element element : list) {
engine.deleteElement(element.getId());
}
((Journaled) engine).commitUserTransaction();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class XMLReportEditorView method save.
public void save() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
disableUpdates = true;
editorView.saveReportToStream(stream);
((Journaled) framework.getEngine()).startUserTransaction();
framework.getEngine().setUndoableStream(getXMLReportPath(), stream.toByteArray());
((Journaled) framework.getEngine()).commitUserTransaction();
} catch (IOException e) {
JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
e.printStackTrace();
} finally {
disableUpdates = false;
}
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class Application method patchData.
/*
* Create all needed system qualifiers and attributes.
*/
private void patchData(Engine engine) {
Journaled journal = (Journaled) engine;
journal.startUserTransaction();
Attribute textAttribute1 = createAttribute(TEXT_ATTRIBUTE1, new AttributeType("Core", "Text"), engine);
Attribute textAttribute2 = createAttribute(TEXT_ATTRIBUTE2, new AttributeType("Core", "Text"), engine);
Attribute doubleAttribute1 = createAttribute(DOUBLE_ATTRIBUTE1, new AttributeType("Core", "Double"), engine);
Qualifier qualifier1 = engine.getSystemQualifier(QUALIFIER1);
if (qualifier1 == null) {
qualifier1 = engine.createSystemQualifier();
qualifier1.getAttributes().add(textAttribute1);
qualifier1.getAttributes().add(textAttribute2);
qualifier1.getAttributes().add(doubleAttribute1);
qualifier1.setName(QUALIFIER1);
engine.updateQualifier(qualifier1);
}
journal.commitUserTransaction();
// User will not be able to undo these changes.
journal.setNoUndoPoint();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class LightClient method getEngine.
@Override
protected Engine getEngine(PluginFactory factory, PersistentFactory persistentFactory) {
try {
Journal journal = new Journal(null, -1l);
journal.setEnable(false);
final JournaledEngine journaledEngine = new JournaledEngine(factory, impl, persistentFactory.getRows(), new DirectoryJournalFactory(null), accessor);
Engine engine = (Engine) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Engine.class, Journaled.class }, new InvocationHandler() {
private Journaled journaled = new Journaled() {
boolean started = false;
@Override
public void undoUserTransaction() {
}
@Override
public void startUserTransaction() {
started = true;
}
@Override
public void setNoUndoPoint() {
}
@Override
public void setEnable(boolean b) {
}
@Override
public void rollbackUserTransaction() {
started = false;
}
@Override
public void removeJournalListener(JournalListener listener) {
}
@Override
public void redoUserTransaction() {
}
@Override
public boolean isUserTransactionStarted() {
return started;
}
@Override
public boolean isEnable() {
return false;
}
@Override
public JournalListener[] getJournalListeners() {
return new JournalListener[] {};
}
@Override
public void commitUserTransaction() {
started = false;
}
@Override
public void close() {
}
@Override
public boolean canUndo() {
return false;
}
@Override
public boolean canRedo() {
return false;
}
@Override
public void addJournalListener(JournalListener listener) {
}
@Override
public long getBranch() {
return -1l;
}
};
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getDeclaringClass().equals(Journaled.class))
return method.invoke(journaled, args);
return method.invoke(journaledEngine, args);
}
});
return engine;
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
Aggregations