use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class SetElementQualifierCommand method undo.
@Override
public void undo(IEngine iEngine) {
Element element = iEngine.getElement(elementId);
Element newElement = new Element(element.getId(), oldQualifierId, element.getName());
ElementEvent event = new ElementEvent(engine, element, newElement, newQualifierId, true);
engine.beforeElementDeleted(event);
iEngine.setElementQualifier(elementId, oldQualifierId);
engine.elementDeleted(event);
event = new ElementEvent(engine, element, newElement, oldQualifierId, true);
engine.elementCreated(event);
Qualifier oldQualifier = iEngine.getQualifier(oldQualifierId);
Qualifier newQualifier = iEngine.getQualifier(newQualifierId);
List<Attribute> attrs = new ArrayList<Attribute>();
addNotPresentAttributes(oldQualifier.getAttributes(), newQualifier.getAttributes(), attrs);
addNotPresentAttributes(oldQualifier.getSystemAttributes(), newQualifier.getSystemAttributes(), attrs);
List<Attribute> as = oldQualifier.getAttributes();
as.addAll(oldQualifier.getSystemAttributes());
int i = 0;
for (Attribute a : as) {
if (attrs.indexOf(a) >= 0) {
iEngine.setBinaryAttribute(elementId, a.getId(), data[i]);
i++;
}
Object object = engine.getAttribute(newElement, a);
if (object != null) {
AttributeEvent event2 = new AttributeEvent(engine, newElement, a, null, object, true);
engine.attributeChanged(event2);
}
}
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class DeleteElementCommand method redo.
@Override
public void redo(IEngine iEngine) {
Element old = iEngine.getElement(elementId);
ElementEvent event = new ElementEvent(engine, old, null, qualifierId, true);
engine.beforeElementDeleted(event);
iEngine.deleteElement(elementId);
engine.elementDeleted(event);
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class TransactionStorageCommand method setAttribute.
private void setAttribute(Transaction transaction, IEngine iEngine) {
Element element = iEngine.getElement(elementId);
Attribute attribute = iEngine.getAttribute(attributeId);
Object oldValue = engine.getAttribute(element, attribute);
iEngine.setBinaryAttribute(elementId, attributeId, transaction);
Object newValue = engine.getAttribute(element, attribute);
if (element != null) {
long qId = engine.getQualifierIdForElement(elementId);
Qualifier q = engine.getQualifier(qId);
if (q.getAttributeForName() == attributeId) {
element.setName((newValue == null) ? "" : newValue.toString());
}
}
AttributeEvent event = new AttributeEvent(engine, element, attribute, oldValue, newValue, true);
engine.attributeChanged(event);
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class CreateElementCommand method redo.
@Override
public void redo(IEngine iEngine) {
Element element = iEngine.createElement(qualifierId, elementId);
ElementEvent event = new ElementEvent(engine, null, element, qualifierId, true);
engine.elementCreated(event);
}
use of com.ramussoft.common.Element 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();
}
Aggregations