use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class QualifierHistorySetupEditor method load.
@Override
public void load(Engine engine, Qualifier qualifier) {
List<Long> attrIds = new ArrayList<Long>();
for (int i = 0; i < this.attrs.size(); i++) if (boxs.size() > i) {
JCheckBox box = boxs.get(i);
if (box.isSelected())
attrIds.add(this.attrs.get(i).getId());
}
List<Long> l = StandardAttributesPlugin.getHistoryQualifiers(engine).get(qualifier.getId());
boolean loadHistory = false;
if (panel.getComponentCount() == 0)
loadHistory = true;
panel.removeAll();
boxs.clear();
attrs.clear();
for (Attribute attribute : qualifier.getAttributes()) {
if (attribute.getAttributeType().isHistorySupport())
attrs.add(attribute);
}
for (Attribute attribute : attrs) {
JCheckBox box = new JCheckBox(attribute.getName());
if (attrIds.indexOf(attribute.getId()) >= 0)
box.setSelected(true);
if ((loadHistory) && (l != null) && (l.indexOf(attribute.getId()) >= 0))
box.setSelected(true);
panel.add(box);
boxs.add(box);
}
panel.revalidate();
panel.repaint();
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class QualifierPreferencesPanel method updateAttributesInOrder.
@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
Attribute attributeId = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_ID);
List<ElementListPersistent> list = (List<ElementListPersistent>) attributeEditor.getValue();
List<Attribute> attributes = new ArrayList<Attribute>(list.size());
for (ElementListPersistent pr : list) {
Element element2 = engine.getElement(pr.getElement2Id());
Long id2 = (Long) engine.getAttribute(element2, attributeId);
Attribute attribute = engine.getAttribute(id2);
attributes.add(attribute);
if (qAttributes.indexOf(attribute) < 0)
qAttributes.add(attribute);
}
List<Attribute> rem = new ArrayList<Attribute>();
for (Attribute a : qAttributes) if (attributes.indexOf(a) < 0)
rem.add(a);
for (Attribute r : rem) qAttributes.remove(r);
}
use of com.ramussoft.common.Attribute 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.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class QualifierView method getAttributes.
@Override
protected Attribute[] getAttributes() {
List<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(nameAttribute);
for (Attribute attribute : qualifier.getAttributes()) attributes.add(attribute);
return attributes.toArray(new Attribute[attributes.size()]);
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class AttributeOrderEditPanel method down.
protected void down() {
int[] is = list.getSelectedRows();
final ArrayList<Integer> nSel = new ArrayList<Integer>();
for (int i = 0; i < is.length; i++) {
final int index = is[i];
if (index + 1 < attributes.size()) {
final Attribute obj = attributes.get(index);
attributes.remove(index);
final int j = index + 1;
attributes.add(j, obj);
nSel.add(j);
} else
is[i] = -1;
}
is = new int[nSel.size()];
for (int i = 0; i < is.length; i++) is[i] = nSel.get(i);
list.getSelectionModel().clearSelection();
for (int i : is) list.getSelectionModel().addSelectionInterval(i, i);
}
Aggregations