use of com.ramussoft.core.attribute.simple.HierarchicalPersistent in project ramus by Vitaliy-Yakovchuk.
the class QualifierView method moveElements.
private void moveElements(Row row, long parentElementId, long prevParentId, Qualifier dest) {
long qualifierId = StandardAttributesPlugin.getQualifierId(engine, row.getElement());
framework.propertyChanged("CloseQualifier", qualifierId);
Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(engine);
List<Element> elements = engine.getElements(qualifierId);
for (Element element : elements) {
engine.setElementQualifier(element.getId(), dest.getId());
element.setQualifierId(dest.getId());
HierarchicalPersistent hp = (HierarchicalPersistent) engine.getAttribute(element, hAttribute);
if ((hp != null) && (hp.getParentElementId() == -1l)) {
hp.setParentElementId(row.getElementId());
engine.setAttribute(element, hAttribute, hp);
}
}
long prevId = -1l;
for (Row row2 : toArray(row.getChildren())) {
moveElements(row2, row.getElementId(), prevId, dest);
prevId = row2.getId();
}
String name = row.getName();
engine.setElementQualifier(row.getElementId(), dest.getId());
HierarchicalPersistent hp = new HierarchicalPersistent();
hp.setPreviousElementId(prevParentId);
hp.setParentElementId(parentElementId);
engine.setAttribute(row.getElement(), hAttribute, hp);
Attribute nameAttribute = engine.getAttribute(dest.getAttributeForName());
if (nameAttribute != null)
engine.setAttribute(row.getElement(), nameAttribute, name);
}
use of com.ramussoft.core.attribute.simple.HierarchicalPersistent in project ramus by Vitaliy-Yakovchuk.
the class NFunction method sortChilds.
private synchronized void sortChilds() {
final NFunction[] os = children.toArray(new NFunction[children.size()]);
if (os.length < 1)
return;
Arrays.sort(os, new Comparator<NFunction>() {
public int compare(final NFunction o1, final NFunction o2) {
return ((NFunction) o1).getFId() - ((NFunction) o2).getFId();
}
});
HierarchicalPersistent hp = os[0].getHierarchicalPersistent();
if (hp.getPreviousElementId() != -1l) {
hp.setPreviousElementId(-1l);
os[0].setHierarchicalPersistent(hp);
}
for (int i = 1; i < os.length; i++) {
hp = os[i].getHierarchicalPersistent();
if (hp.getPreviousElementId() != os[i - 1].getElementId()) {
hp.setPreviousElementId(os[i - 1].getElementId());
os[i].setHierarchicalPersistent(hp);
}
}
}
use of com.ramussoft.core.attribute.simple.HierarchicalPersistent in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Plugin method installFunctionAttributes.
public static void installFunctionAttributes(Qualifier qualifier, Engine engine) {
if (isFunction(qualifier))
throw new RuntimeException("Qualifier is allready function.");
IDEF0Plugin plugin = (IDEF0Plugin) engine.getPluginProperty(IDEF0, PLUGIN);
for (Attribute a : plugin.functionAttributes) {
qualifier.getSystemAttributes().add(a);
}
engine.updateQualifier(qualifier);
Element e = engine.createElement(plugin.baseFunctions.getId());
engine.setAttribute(e, plugin.baseFunctionQualifierId, qualifier.getId());
engine.setAttribute(e, (Attribute) engine.getPluginProperty("Core", HierarchicalPlugin.HIERARHICAL_ATTRIBUTE), new HierarchicalPersistent());
}
use of com.ramussoft.core.attribute.simple.HierarchicalPersistent in project ramus by Vitaliy-Yakovchuk.
the class Row method setParent.
public void setParent(Row parent) {
HierarchicalPersistent hp = getHierarchicalPersistent();
if (hp == null)
hp = new HierarchicalPersistent();
hp.setParentElementId(parent.getElementId());
hp.setPreviousElementId(-1l);
if (parent.getChildCount() > 0) {
hp.setPreviousElementId(parent.getChildAt(parent.getChildCount() - 1).getElementId());
}
parent.children.add(this);
this.setHierarchicalPersistent(hp);
}
use of com.ramussoft.core.attribute.simple.HierarchicalPersistent in project ramus by Vitaliy-Yakovchuk.
the class RowSet method attributeChanged.
protected void attributeChanged(AttributeEvent event) {
synchronized (STATIC_LOCK) {
if (currentThread == Thread.currentThread())
return;
}
if (event.getAttribute().equals(getHAttribute())) {
HierarchicalPersistent old = (HierarchicalPersistent) event.getOldValue();
HierarchicalPersistent p = (HierarchicalPersistent) event.getNewValue();
Element e = event.getElement();
Row row = findRow(e.getId());
if (row != null) {
if (old != null) {
Row parent = row.getParent();
if (parent != null) {
int index = parent.getChildren().indexOf(row);
parent.getChildren().remove(row);
removedFromChildren(parent, row, index);
}
}
if (p == null)
return;
Row parent = findRow(p.getParentElementId());
if (parent == null)
parent = root;
List<Row> children = parent.getChildren();
children.remove(row);
row.setNativeParent(parent);
int index = 0;
int size = children.size();
for (int i = 0; i < size; i++) {
Row row2 = children.get(i);
if (row2.getElementId() == p.getPreviousElementId()) {
index = i + 1;
break;
}
}
if (!filter(row.getElement())) {
children.add(index, row);
added(parent, row, index);
}
} else {
System.err.println("Warning! Unregister with current rowset row where changed. Element id: " + e.getId() + ", Name: " + e.getName());
return;
}
}
for (int i = 0; i < attributesWithH.length; i++) {
if (attributesWithH[i].equals(event.getAttribute())) {
Row row = findRow(event.getElement().getId());
if (row == null)
return;
row.updateObject(i, event.getNewValue());
attributeChanged(row, event.getAttribute(), event.getNewValue(), event.getOldValue(), event.isJournaled());
}
}
if (event.getAttribute().getId() == qualifier.getAttributeForName()) {
Row row = findRow(event.getElement().getId());
row.updateElement();
}
}
Aggregations