use of com.ramussoft.common.Element 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();
}
}
use of com.ramussoft.common.Element 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.Element in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method createElement.
public void createElement(Qualifier qualifier) {
Element element = engine.createElement(IDEF0Plugin.getModelTree(engine).getId());
engine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(engine), qualifier.getId());
Row row = tree.getRowSet().createRow(null, element);
row.setName(qualifier.getName());
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class NDataPluginFactory method createDataPlugin.
private DataPlugin createDataPlugin() {
DataPlugin plugin = (DataPlugin) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { DataPlugin.class }, new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
String name = method.getName();
if ("getBaseFunction".equals(name)) {
if (rowBaseFunction == null) {
rowBaseFunction = getBaseFunction(dataPlugin, baseFunction);
}
return rowBaseFunction;
}
if ("getBaseFunctionQualifier".equals(name))
return baseFunction;
if ("isReadOnly".equals(name))
return !dataPlugin.getAccessRules().canUpdateQualifier(baseFunction.getId());
if ("createRow".equals(name)) {
com.ramussoft.pb.Row parent = (com.ramussoft.pb.Row) args[0];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent);
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ("createFunction".equals(name)) {
com.ramussoft.pb.Function parent = (com.ramussoft.pb.Function) args[0];
final Integer type = (Integer) args[1];
RowSet set = dataPlugin.getRowSet(baseFunction.getId());
if (parent instanceof Function) {
Row row = set.createRow((Row) parent, new ElementCreationCallback() {
@Override
public void created(Element element) {
Engine engine = dataPlugin.getEngine();
Attribute attribute = IDEF0Plugin.getFunctionTypeAttribute(engine);
engine.setAttribute(element, attribute, type);
}
});
((NFunction) row).setDefaultValues();
((NFunction) row).setDecompositionType(((Function) parent).getDecompositionType());
return row;
}
} else if ((("getChilds".equals(name)) || ("getRecChilds".equals(name))) && (args[0] == null) && (((Boolean) args[1]) == false)) {
Vector v = (Vector) method.invoke(dataPlugin, args);
v.add(0, dataPlugin.getBaseStream());
v.add(0, getBaseFunction(dataPlugin, baseFunction));
return v;
}
if ("getProjectOptions".equals(name))
return getProjectOptions();
if ("setProjectOptions".equals(name))
return setProjectOptions((ProjectOptions) args[0]);
if ("refresh".equals(name)) {
fullRefrash((GUIFramework) args[0]);
return null;
}
return method.invoke(dataPlugin, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
private Row getBaseFunction(final NDataPlugin dataPlugin, final Qualifier baseFunction) {
return dataPlugin.getNBaseFunction(baseFunction.getId());
}
protected Object setProjectOptions(ProjectOptions projectOptions) {
getBaseFunction(dataPlugin, baseFunction).setAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()), projectOptions);
return null;
}
protected Object getProjectOptions() {
return getBaseFunction(dataPlugin, baseFunction).getAttribute(IDEF0Plugin.getProjectPreferencesAttrtibute(dataPlugin.getEngine()));
}
});
plugin.getBaseFunction();
return plugin;
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class ModelParaleler method createParalel.
public void createParalel(final Function function, final boolean createAllRows) {
ModelParaleler.this.function = function;
if (createAllRows)
createAllRows();
Qualifier qualifier = toEngine.createQualifier();
copyQualifier(function.getQualifier(), qualifier);
IDEF0Plugin.installFunctionAttributes(qualifier, toEngine);
Qualifier q = IDEF0Plugin.getModelTree(toEngine);
Element element = toEngine.createElement(q.getId());
toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeQualifierId(toEngine), qualifier.getId());
toEngine.setAttribute(element, StandardAttributesPlugin.getAttributeNameAttribute(toEngine), function.getName());
toDataPlugin = NDataPluginFactory.getDataPlugin(qualifier, toEngine, toDataPlugin.getAccessRules());
ModelParaleler.this.base = toDataPlugin.getBaseFunction();
Vector<Row> childs = fromDataPlugin.getRecChilds(function, true);
ProjectOptions projectOptions = toDataPlugin.getBaseFunction().getProjectOptions();
projectOptions.getDeligate().setDiagramSize(function.getProjectOptions().getDeligate().getDiagramSize());
toDataPlugin.getBaseFunction().setProjectOptions(projectOptions);
for (Row row : childs) {
NFunction dest = (NFunction) getRow(row);
showMessageAnimation(dest.toString());
}
NFunction func = null;
Vector<Row> v = toDataPlugin.getChilds(base, true);
if (v.size() > 0)
func = (NFunction) v.get(0);
createSectorsOnUpperLevel(func);
}
Aggregations