Search in sources :

Example 91 with Attribute

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);
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) JLabel(javax.swing.JLabel) TableLayout(info.clearthought.layout.TableLayout)

Example 92 with Attribute

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;
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent)

Example 93 with Attribute

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());
}
Also used : Attribute(com.ramussoft.common.Attribute) ElementListPropertyPersistent(com.ramussoft.core.attribute.simple.ElementListPropertyPersistent) Qualifier(com.ramussoft.common.Qualifier)

Example 94 with Attribute

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);
            }
        }
    };
}
Also used : CurrencyPropertyPersistent(com.ramussoft.core.attribute.simple.CurrencyPropertyPersistent) JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) Attribute(com.ramussoft.common.Attribute) Currency(java.util.Currency) AccessRules(com.ramussoft.common.AccessRules) JLabel(javax.swing.JLabel) TableLayout(info.clearthought.layout.TableLayout) AttributePreferenciesEditor(com.ramussoft.gui.common.AttributePreferenciesEditor) Engine(com.ramussoft.common.Engine)

Example 95 with Attribute

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) ElementsTable(com.ramussoft.gui.qualifier.table.ElementsTable) JXTable(org.jdesktop.swingx.JXTable) Attribute(com.ramussoft.common.Attribute) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener)

Aggregations

Attribute (com.ramussoft.common.Attribute)203 Qualifier (com.ramussoft.common.Qualifier)72 Element (com.ramussoft.common.Element)70 ArrayList (java.util.ArrayList)53 Engine (com.ramussoft.common.Engine)32 List (java.util.List)20 Row (com.ramussoft.database.common.Row)19 Hashtable (java.util.Hashtable)19 SQLException (java.sql.SQLException)16 AttributeType (com.ramussoft.common.AttributeType)15 FindObject (com.ramussoft.common.attribute.FindObject)11 AttributeEvent (com.ramussoft.common.event.AttributeEvent)11 ResultSet (java.sql.ResultSet)11 AttributePlugin (com.ramussoft.gui.common.AttributePlugin)10 AccessRules (com.ramussoft.common.AccessRules)9 Transaction (com.ramussoft.common.persistent.Transaction)9 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)9 RowMapper (com.ramussoft.jdbc.RowMapper)9 Row (com.ramussoft.pb.Row)9 ImageIcon (javax.swing.ImageIcon)9