use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class Util method decompileValue.
protected String decompileValue(final Element element, String oldName) {
MetaValue value = toMetaValue(oldName);
Attribute attribute = engine.getAttribute(value.getAttributeId());
if ((element != null) && (value.getElementId() == element.getId())) {
return toCanonicalValue(attribute.getName());
} else {
Element e = engine.getElement(value.getElementId());
if (e.getName().length() == 0)
return toCanonicalValue(ELEMENT_PREFIX + e.getId() + "." + attribute.getName());
if ((element != null) && (e.getQualifierId() == element.getQualifierId())) {
return toCanonicalValue(e.getName() + "." + attribute.getName());
} else {
Qualifier qualifier = engine.getQualifier(e.getQualifierId());
return toCanonicalValue(replaceDots(qualifier.getName()) + "." + replaceDots(e.getName()) + "." + replaceDots(attribute.getName()));
}
}
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class Util method getAttributes.
public List<Attribute> getAttributes(Qualifier qualifier, Eval eval) {
List<Attribute> result = new ArrayList<Attribute>();
String[] values = eval.getValues();
for (String value : values) {
for (Attribute attr : qualifier.getAttributes()) {
if (value.equals(getAttributeEId(attr.getId()))) {
result.add(attr);
}
}
}
return result;
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class Util method compile.
public String compile(Qualifier qualifier, String userFunction) {
List<Attribute> attrs = qualifier.getAttributes();
final Hashtable<String, String> hash = new Hashtable<String, String>(attrs.size());
for (Attribute attr : attrs) {
AttributeType type = attr.getAttributeType();
if (type.toString().equals("Core.Table")) {
Qualifier table = engine.getSystemQualifier("TableQualifier_" + attr.getId());
for (Attribute tAttr : table.getAttributes()) {
hash.put(toCanonicalValue(attr.getName() + "." + tAttr.getName()), getAttributeEId(attr.getId(), tAttr.getId()));
}
}
hash.put(toCanonicalValue(attr.getName()), getAttributeEId(attr.getId()));
}
Eval eval = new Eval(userFunction);
eval.replaceValueNames(new Replacementable() {
@Override
public String getNewName(String oldName) {
if ("ELEMENT".equals(oldName))
return oldName;
String name = hash.get(oldName);
if (name == null) {
name = compileValue(null, oldName);
}
return name;
}
});
return eval.toString();
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class SectorFontAttributePlugin method getAttributeEditor.
@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
if (old != null)
old.close();
return new AbstractAttributeEditor() {
private PaintSector.Pin pin;
private JFontChooser component;
private Font font;
{
component = new JFontChooser();
ResourceLoader.setJComponentsText(component);
}
@Override
public Object setValue(Object value) {
this.pin = (PaintSector.Pin) value;
font = pin.getSector().getFont();
component.setSelFont(font);
return value;
}
@Override
public Object getValue() {
return pin;
}
@Override
public JComponent getComponent() {
return component;
}
@Override
public void apply(Engine engine, Element element, Attribute attribute, Object value) {
PaintSector sector = pin.getSector();
sector.setFont(component.getSelFont());
sector.copyVisual(Sector.VISUAL_COPY_ADDED);
pin.getSector().getMovingArea().getRefactor().setUndoPoint();
}
@Override
public boolean isSaveAnyway() {
return !font.equals(component.getSelFont());
}
};
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class ModelPropertiesDialog method updateAttributesInOrder.
@SuppressWarnings("unchecked")
private void updateAttributesInOrder(List<Attribute> qAttributes) {
List<Row> list = view.getSelectedRows();
List<Attribute> attributes = new ArrayList<Attribute>(list.size());
for (Row pr : list) {
Attribute attribute = StandardAttributesPlugin.getAttribute(engine, pr.getElement());
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);
}
Aggregations