use of com.ramussoft.common.AttributeType in project ramus by Vitaliy-Yakovchuk.
the class Util method fillResult.
public void fillResult(long attributeId, Exception e, Element element) {
Object object = null;
e.printStackTrace();
Attribute attribute = engine.getAttribute(attributeId);
AttributeType attributeType = attribute.getAttributeType();
if (attributeType.getPluginName().equals("Core")) {
String typeName = attributeType.getTypeName();
if (typeName.equals("Text")) {
object = e.getLocalizedMessage();
}
}
engine.setAttribute(element, attribute, object);
}
use of com.ramussoft.common.AttributeType 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.AttributeType 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.AttributeType in project ramus by Vitaliy-Yakovchuk.
the class IDEF0ViewPlugin method importFromIdl.
protected void importFromIdl() {
JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
if (f.isFile()) {
if (f.getName().toLowerCase().endsWith(".idl"))
return true;
return false;
}
return true;
}
@Override
public String getDescription() {
return "*.idl";
}
});
if (fc.showOpenDialog(framework.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
try {
((Journaled) engine).startUserTransaction();
Qualifier qualifier = engine.createQualifier();
Attribute name = null;
String aName = ResourceLoader.getString("name");
for (Attribute a : engine.getAttributes()) {
if (a.getAttributeType().toString().equals("Core.Text")) {
if (aName.equals(a.getName()))
name = a;
}
}
if (name == null) {
name = engine.createAttribute(new AttributeType("Core", "Text", true));
name.setName(aName);
engine.updateAttribute(name);
}
qualifier.getAttributes().add(name);
qualifier.setAttributeForName(name.getId());
IDEF0Plugin.installFunctionAttributes(qualifier, engine);
DataPlugin plugin = NDataPluginFactory.getDataPlugin(qualifier, engine, rules);
File file = fc.getSelectedFile();
plugin.importFromIDL(plugin, "cp1251", new FileInputStream(file));
((Journaled) engine).commitUserTransaction();
OpenDiagram openDiagram = new OpenDiagram(qualifier, -1l);
framework.propertyChanged(OPEN_DIAGRAM, openDiagram);
} catch (Exception e) {
((Journaled) engine).rollbackUserTransaction();
e.printStackTrace();
JOptionPane.showMessageDialog(framework.getMainFrame(), "Формат выбранного вами файла IDL не поддерживается.");
}
}
}
use of com.ramussoft.common.AttributeType in project ramus by Vitaliy-Yakovchuk.
the class AttributePreferenciesDialog method updateAdditionalOptions.
protected void updateAdditionalOptions() {
this.editor = null;
AttributeType type = getAttributeType();
AttributePlugin attributePlugin = framework.findAttributePlugin(type);
if (attributePlugin == null) {
System.err.println("WARNING: Attribute plugin for type: " + type + " not found.");
return;
}
editor = attributePlugin.getAttributePreferenciesEditor();
boolean update = false;
if (this.component != null) {
update = true;
contentPanel.remove(this.component);
}
this.component = null;
if (editor != null) {
JComponent component = editor.createComponent(attribute, engine, accessRules);
if (component != null) {
update = true;
contentPanel.add(component, BorderLayout.CENTER);
this.component = component;
}
}
if (update) {
pack();
contentPanel.revalidate();
contentPanel.repaint();
}
}
Aggregations