use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class ComplexImport method fill.
private void fill(Element element, Cell cell, Attribute attribute, ImportRule rule) {
Engine engine = rowSet.getEngine();
String type = attribute.getAttributeType().toString();
if (cell == null) {
try {
engine.setAttribute(element, attribute, sheetName);
} catch (Exception e) {
}
} else {
try {
EObject object = null;
if (cell.getCellType() == Cell.CELL_TYPE_STRING)
object = new EObject(cell.getStringCellValue());
else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
object = new EObject(cell.getNumericCellValue());
else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
object = new EObject(cell.getDateCellValue());
else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
object = new EObject(cell.getDateCellValue());
if (object == null)
try {
object = new EObject(cell.getStringCellValue());
} catch (Exception e) {
}
if (object == null)
try {
object = new EObject(cell.getNumericCellValue());
} catch (Exception e) {
}
if (object == null)
try {
object = new EObject(cell.getDateCellValue());
} catch (Exception e) {
}
if (object == null)
return;
if (("".equals(object.getValue())) && (engine.getAttribute(element, attribute) != null)) {
setAttribute(engine, element, attribute, null, rule);
return;
}
if ((object.getValue() == null) && (engine.getAttribute(element, attribute) != null)) {
setAttribute(engine, element, attribute, null, rule);
return;
}
if (("Core.Double".equals(type)) || ("Core.Currency".equals(type))) {
setAttribute(engine, element, attribute, object.doubleValue(), rule);
} else if (("Core.Text".equals(type)) || ("Core.Variant".equals(type))) {
setAttribute(engine, element, attribute, object.stringValue(), rule);
} else if ("Core.Date".equals(type)) {
setAttribute(engine, element, attribute, object.dateValue(), rule);
} else if ("Core.Long".equals(type)) {
setAttribute(engine, element, attribute, object.longValue(), rule);
} else if ("Core.OtherElement".equals(type)) {
long qId = getOtherElemetQualifierId(attribute);
String s = object.stringValue();
if ((s != null) && (s.length() > 0)) {
Element element2 = engine.getElement(s.trim(), qId);
if (element2 == null) {
Qualifier qualifier = engine.getQualifier(qId);
Attribute name = engine.getAttribute(qualifier.getAttributeForName());
if (name == null)
return;
element2 = engine.createElement(qId);
setAttribute(engine, element2, name, s, rule);
}
setAttribute(engine, element, attribute, element2.getId(), rule);
}
} else {
setAttribute(engine, element, attribute, object.getValue(), rule);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method getIDEF0Kod.
/**
* Метод визначає код функціонального блоку у відповідності до стандарту
* IDEF0
*
* @param function Функціональний блок, для якого буде визначений його код.
* @return Код функціонального блока у відповідності до стандарту IDEF0.
*/
public static String getIDEF0Kod(Row function) {
Engine engine = function.getEngine();
Integer integer = (Integer) function.getAttribute(IDEF0Plugin.getDecompositionTypeAttribute(engine));
if (integer != null && integer.intValue() == MovingArea.DIAGRAM_TYPE_DFDS)
return function.getNativeCode();
Qualifier qualifier = engine.getQualifier(function.getElement().getQualifierId());
DataPlugin dataPlugin = NDataPluginFactory.getDataPlugin(qualifier, engine, null);
com.ramussoft.pb.Row f1 = dataPlugin.findRowByGlobalId(function.getElementId());
if (f1 != null)
function = (Row) f1;
final com.ramussoft.database.common.Row f = function.getParent();
if (function instanceof Function) {
ProjectOptions po = ((Function) function).getProjectOptions();
String letter = po.getDeligate().getModelLetter();
if (letter != null && letter.length() > 0) {
if (f == null)
return letter + "-0";
if (f.getParent() == null)
return letter + "0";
return letter + getRecIDEF0Kod(function);
}
}
if (f == null)
return "A-0";
if (f.getParent() == null)
return "A0";
return "A" + getRecIDEF0Kod(function);
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class FunctionOptionsDialog method apptype.
private void apptype() {
Engine e = dataPlugin.getEngine();
if (e instanceof Journaled)
((Journaled) e).startUserTransaction();
function.setFont(getJFontChooser().getSelFont());
function.setBackground(getJColorChooser().getColor());
function.setForeground(getJColorChooser1().getColor());
final JList jList = selectOwner.getJList();
if (jList.getSelectedIndex() == 0)
function.setOwner(null);
else {
function.setOwner((Row) jList.getSelectedValue());
}
function.setType(functionType.getType());
AccessRules rules = dataPlugin.getAccessRules();
Element element = ((NFunction) function).getElement();
for (int index = attributes.size() - 1; index >= 0; index--) {
Attribute attribute = attributes.get(index);
if (rules.canUpdateElement(element.getId(), attribute.getId())) {
Object value = attributeEditors.get(index).getValue();
if (!equals(value, values.get(index)))
e.setAttribute(element, attribute, value);
}
}
if (e instanceof Journaled)
((Journaled) e).commitUserTransaction();
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class FunctionOptionsDialog method load.
private void load() {
Engine e = dataPlugin.getEngine();
Qualifier qualifier = function.getQualifier();
attributes = new ArrayList<Attribute>(qualifier.getAttributes());
for (int i = attributes.size() - 1; i >= 0; i--) {
Attribute attribute = attributes.get(i);
AttributePlugin plugin = framework.findAttributePlugin(attribute.getAttributeType());
Element element = ((NFunction) function).getElement();
AttributeEditor editor = plugin.getAttributeEditor(e, dataPlugin.getAccessRules(), element, attribute, "function", null);
if (editor == null)
continue;
attributeEditors.add(0, editor);
JComponent component = editor.getComponent();
JPanel panel = new JPanel(new BorderLayout());
panel.add(component, BorderLayout.CENTER);
Action[] actions = editor.getActions();
if (actions.length > 0) {
JToolBar bar = new JToolBar();
for (Action a : actions) {
JButton b = bar.add(a);
b.setFocusable(false);
bar.add(b);
}
panel.add(bar, BorderLayout.NORTH);
}
getJTabbedPane().insertTab(attribute.getName(), null, panel, null, 0);
Object value = e.getAttribute(element, attribute);
editor.setValue(value);
values.add(0, value);
}
getJColorChooser().setColor(function.getBackground());
getJColorChooser1().setColor(function.getForeground());
getJFontChooser().setSelFont(function.getFont());
functionType.setFunction(function);
selectOwner.setFunction(function);
}
use of com.ramussoft.common.Engine in project ramus by Vitaliy-Yakovchuk.
the class DiagramOptionsDialog method onOk.
@Override
protected void onOk() {
Engine engine = framework.getEngine();
((Journaled) engine).startUserTransaction();
function.setStatus(statusPanel.getStatus());
if (!function.getCreateDate().equals(createDate.getDate()))
function.setCreateDate(createDate.getDate());
if (!function.getRevDate().equals(revDate.getDate()))
function.setRevDate(revDate.getDate());
if (!function.getAuthor().equals(author.getText()))
function.setAuthor(author.getText());
String newSize = String.valueOf(sizesBox.getSelectedItem());
if (horizontalPageCountBox.getSelectedIndex() != 0)
newSize += "x" + horizontalPageCountBox.getSelectedItem();
if (!newSize.equals(function.getPageSize())) {
function.setPageSize(newSize);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
framework.propertyChanged(IDEF0TabView.UPDATE_SIZES);
}
});
}
((Journaled) engine).commitUserTransaction();
super.onOk();
}
Aggregations