use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class SelectableTableView method getSelectedElements.
public List<Element> getSelectedElements() {
List<Row> rows = getSelectedRows();
List<Element> result = new ArrayList<Element>(rows.size());
for (Row r : rows) result.add(r.getElement());
return result;
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class TableTabView method convertFirstLevelToQualifiers.
public void convertFirstLevelToQualifiers() {
Qualifier qq = StandardAttributesPlugin.getQualifiersQualifier(engine);
HierarchicalPersistent hp = new HierarchicalPersistent();
Element element = StandardAttributesPlugin.getElement(engine, getQualifier().getId());
hp.setParentElementId(element.getId());
hp.setPreviousElementId(-1l);
Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(engine);
Attribute nameAttribute = StandardAttributesPlugin.getAttributeNameAttribute(engine);
for (Row row : toArray(component.getRowSet().getRoot().getChildren())) {
String name = row.getName();
Row[] children = toArray(row.getChildren());
engine.setElementQualifier(row.getElementId(), qq.getId());
row.getElement().setQualifierId(qq.getId());
engine.setAttribute(row.getElement(), hAttribute, hp);
engine.setAttribute(row.getElement(), nameAttribute, name);
hp.setPreviousElementId(row.getElementId());
Qualifier qualifier = StandardAttributesPlugin.getQualifier(engine, row.getElement());
for (Attribute attribute : getQualifier().getAttributes()) {
if (qualifier.getAttributes().indexOf(attribute) < 0)
qualifier.getAttributes().add(attribute);
}
engine.updateQualifier(qualifier);
for (Row row2 : children) {
moveRows(row2, qualifier.getId());
HierarchicalPersistent h = (HierarchicalPersistent) engine.getAttribute(row2.getElement(), hAttribute);
h.setParentElementId(-1l);
row2.setAttribute(hAttribute, h);
}
}
Attribute nameAttr = null;
for (Attribute attribute : qualifier.getAttributes()) if (attribute.getId() == qualifier.getAttributeForName())
nameAttr = attribute;
getQualifier().getAttributes().clear();
if (nameAttr != null)
getQualifier().getAttributes().add(nameAttr);
engine.updateQualifier(getQualifier());
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method createEditFrame.
@Override
protected void createEditFrame() {
final GUIFramework framework = movingArea.getPanel().getFramework();
final Engine engine = framework.getEngine();
long id = getFunction().getLink();
Element element2 = null;
if (id >= 0)
element2 = engine.getElement(id);
if (element2 == null)
element2 = getFunction().getElement();
final Element element = element2;
Qualifier qualifier = engine.getQualifier(element.getQualifierId());
Attribute name = null;
if (qualifier.getAttributeForName() >= 0)
name = engine.getAttribute(qualifier.getAttributeForName());
if (name == null) {
JOptionPane.showMessageDialog(framework.getMainFrame(), ResourceLoader.getString("NameAttributeNotSet"));
return;
}
final Attribute nameAttribute = name;
AttributePlugin plugin = framework.findAttributePlugin(name);
final AttributeEditor editor = plugin.getAttributeEditor(engine, framework.getAccessRules(), element, name, "activity_name", null);
setTextComponent(new JScrollPane(editor.getLastComponent()));
final Object value = engine.getAttribute(element, name);
editor.setValue(value);
final Rectangle r = movingArea.getIBounds(getBounds());
final JTextArea textArea = (JTextArea) editor.getLastComponent();
processTextArea(textArea);
// textArea.setBackground(getFunction().getBackground());
// textArea.setForeground(getFunction().getForeground());
// textArea.setFont(movingArea.getFont(getFont()));
// textArea.setCaretColor(getFunction().getForeground());
final JPopupMenu menu = textArea.getComponentPopupMenu();
textArea.setComponentPopupMenu(null);
movingArea.getPanel().setActionDisable(true);
textArea.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER && e.isControlDown()) {
stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
cancelEdit(editor, textArea, menu);
}
});
textArea.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
}
@Override
public void focusGained(FocusEvent e) {
}
});
movingArea.add(getTextComponent());
movingArea.setbImage(null);
getTextComponent().setBounds(r);
movingArea.revalidate();
movingArea.repaint();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
textArea.requestFocus();
}
});
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method deleteElement.
@Override
public void deleteElement(long id) {
qualifirsForElements.remove(id);
Element element = getElement(id);
long qualifierId = getQualifierIdForElement(id);
Transaction[] data = getAttributeWhatWillBeDeleted(id);
ElementEvent event = new ElementEvent(this, element, null, qualifierId);
try {
beforeElementDeleted(event);
} catch (Exception e) {
e.printStackTrace();
}
deligate.deleteElement(id);
synchronized (swithJournalLock) {
journal.store(new DeleteElementCommand(this, qualifierId, id, data));
}
elementDeleted(event);
}
use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method getElements.
@Override
public List<Element> getElements(long qualifierId) {
List<Element> list = deligate.getElements(qualifierId);
Long id = qualifierId;
for (Element e : list) qualifirsForElements.put(e.getId(), id);
return list;
}
Aggregations