use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class CreateOrEditElementListDialog method init.
private void init() {
double[][] size = { { DIV_SPACE, TableLayout.MINIMUM, DIV_SPACE, TableLayout.FILL, DIV_SPACE }, { DIV_SPACE, TableLayout.FILL, DIV_SPACE } };
JPanel panel = new JPanel(new TableLayout(size));
panel.add(new JLabel(GlobalResourcesManager.getString("ElementListName")), "1, 1");
panel.add(nameField, "3, 1");
Attribute attribute = getAttribute();
if (attribute != null)
nameField.setText(attribute.getName());
JPanel main = new JPanel(new BorderLayout());
main.add(panel, BorderLayout.NORTH);
AttributePlugin attributePlugin = framework.findAttributePlugin(getAttributeType());
editor = (ElementListPreferenciesEditor) attributePlugin.getAttributePreferenciesEditor();
JPanel panel2 = new JPanel(new BorderLayout());
panel2.add(editor.createComponent(getAttribute(), engine, rules), BorderLayout.CENTER);
main.add(panel2, BorderLayout.CENTER);
setMainPane(main);
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class ElistComponent method canDeleteAttribute.
private boolean canDeleteAttribute(int row) {
int index = table.convertRowIndexToModel(row);
Attribute attribute = list.get(index);
if (!rules.canDeleteAttribute(attribute.getId()))
return false;
ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
if (!rules.canUpdateQualifier(p.getQualifier1()))
return false;
if (!rules.canUpdateQualifier(p.getQualifier2()))
return false;
return true;
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class ElistComponent method deleteElement.
private void deleteElement(int row) {
int index = table.convertRowIndexToModel(row);
Attribute attribute = list.get(index);
ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
Qualifier q1 = engine.getQualifier(p.getQualifier1());
if (q1 != null) {
q1.getAttributes().remove(attribute);
engine.updateQualifier(q1);
}
Qualifier q2 = engine.getQualifier(p.getQualifier2());
if (q2 != null) {
q2.getAttributes().remove(attribute);
engine.updateQualifier(q2);
}
engine.deleteAttribute(attribute.getId());
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class CurrencyAttributePlugin method getAttributePreferenciesEditor.
@Override
public AttributePreferenciesEditor getAttributePreferenciesEditor() {
return new AttributePreferenciesEditor() {
private JComboBox comboBox = new JComboBox();
@Override
public JComponent createComponent(Attribute attribute, Engine engine, AccessRules accessRules) {
CurrencyPropertyPersistent p = null;
if (attribute != null)
p = (CurrencyPropertyPersistent) engine.getAttribute(null, attribute);
comboBox.addItem(GlobalResourcesManager.getString("ByDefault"));
int i = 1;
int index = 0;
for (Currency currency : getCurrencies()) {
comboBox.addItem(currency);
if ((p != null) && (p.getCode() != null) && (p.getCode().equals(currency.getCurrencyCode())))
index = i;
i++;
}
comboBox.setSelectedIndex(index);
double[][] size = { { 5, TableLayout.MINIMUM, 5, TableLayout.FILL, 5 }, { 5, TableLayout.MINIMUM, 5 } };
TableLayout layout = new TableLayout(size);
JPanel panel = new JPanel(layout);
panel.add(new JLabel(GlobalResourcesManager.getString("Attribute.CurrencyCode")), "1,1");
panel.add(comboBox, "3,1");
return panel;
}
@Override
public boolean canApply() {
return true;
}
@Override
public void apply(Attribute attribute, Engine engine, AccessRules accessRules) {
if (comboBox.getSelectedIndex() == 0) {
engine.setAttribute(null, attribute, null);
} else {
CurrencyPropertyPersistent p = new CurrencyPropertyPersistent();
p.setCode(((Currency) comboBox.getSelectedItem()).getCurrencyCode());
engine.setAttribute(null, attribute, p);
}
}
};
}
use of com.ramussoft.common.Attribute in project ramus by Vitaliy-Yakovchuk.
the class ElementAttributesEditor method createComponent.
@Override
public JComponent createComponent() {
JScrollPane pane = new JScrollPane();
table = new Table();
pane.setViewportView(table);
listSelectionListener = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
int row = table.getSelectedRow();
if (row >= 0) {
row = table.convertRowIndexToModel(row);
Attribute attribute = attributes.get(row).attribute;
AttributeEditorView.ElementAttribute elementAttribute = new AttributeEditorView.ElementAttribute(currentElement, attribute);
framework.propertyChanged(ACTIVATE_ATTRIBUTE, elementAttribute, metadata);
}
}
};
table.getSelectionModel().addListSelectionListener(listSelectionListener);
return pane;
}
Aggregations