Search in sources :

Example 6 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin 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 7 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin in project ramus by Vitaliy-Yakovchuk.

the class ElementAttributesEditor method getCellEditor.

private TableCellEditor getCellEditor(int aRow) {
    Attribute attribute = attributes.get(aRow).attribute;
    AttributePlugin plugin = framework.findAttributePlugin(attribute);
    TableCellEditor cellEditor = plugin.getTableCellEditor(framework.getEngine(), framework.getAccessRules(), attribute);
    if (cellEditor == null) {
        saveValues[aRow] = false;
        cellEditor = new DialogedTableCellEditor(framework.getEngine(), framework.getAccessRules(), attribute, plugin, framework);
    } else
        saveValues[aRow] = plugin.isCellEditable();
    return cellEditor;
}
Also used : TabledAttributePlugin(com.ramussoft.gui.qualifier.table.TabledAttributePlugin) AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) TableCellEditor(javax.swing.table.TableCellEditor) DialogedTableCellEditor(com.ramussoft.gui.qualifier.table.DialogedTableCellEditor) DialogedTableCellEditor(com.ramussoft.gui.qualifier.table.DialogedTableCellEditor)

Example 8 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin in project ramus by Vitaliy-Yakovchuk.

the class TableEditorTable method setModel.

@Override
public void setModel(TableModel dataModel) {
    super.setModel(dataModel);
    if (!(dataModel instanceof TableEditorModel))
        return;
    TableEditorModel model = (TableEditorModel) dataModel;
    Engine engine = framework.getEngine();
    AccessRules rules = framework.getAccessRules();
    for (int i = 0; i < plugins.length; i++) {
        AttributePlugin plugin = framework.findAttributePlugin(attributes.get(i));
        plugins[i] = plugin;
        cellEditors[i] = plugin.getTableCellEditor(engine, rules, attributes.get(i));
        if (cellEditors[i] == null) {
            cellEditors[i] = new DialogedTableCellEditor(engine, rules, attributes.get(i), plugins[i], framework);
            model.setSaveValue(i, false);
        }
        cellRenderers[i] = plugin.getTableCellRenderer(engine, rules, attributes.get(i));
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) AccessRules(com.ramussoft.common.AccessRules) Engine(com.ramussoft.common.Engine) DialogedTableCellEditor(com.ramussoft.gui.qualifier.table.DialogedTableCellEditor)

Example 9 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin in project ramus by Vitaliy-Yakovchuk.

the class QualifierImporterImpl method importQualifiers.

public void importQualifiers(int elementImportType, boolean importTableAttributes) {
    int i = 0;
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = createQualifier(sourceQualifier, sourceRows[i]);
        qualifiers.put(sourceQualifier, qualifier);
        i++;
    }
    if (importTableAttributes)
        createTableAttributes();
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = getDestination(sourceQualifier);
        Attribute attributeForDestName = null;
        for (Attribute sourceAttribute : sourceQualifier.getAttributes()) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute == null) {
                AttributePlugin plugin = framework.findAttributePlugin(sourceAttribute.getAttributeType());
                if (plugin != null) {
                    destAttribute = plugin.createSyncAttribute(engine, this, sourceAttribute);
                    if (destAttribute != null) {
                        attributes.put(sourceAttribute, destAttribute);
                    }
                }
            }
            if (destAttribute != null) {
                if (qualifier.getAttributes().indexOf(destAttribute) < 0) {
                    qualifier.getAttributes().add(destAttribute);
                }
                if (sourceQualifier.getAttributeForName() == sourceAttribute.getId())
                    attributeForDestName = destAttribute;
            }
        }
        if (attributeForDestName != null)
            qualifier.setAttributeForName(attributeForDestName.getId());
        engine.updateQualifier(qualifier);
    }
    for (Qualifier sourceQualifier : sourceQualifiers) {
        for (Attribute sourceAttribute : sourceQualifier.getAttributes()) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute != null) {
                AttributePlugin plugin = framework.findAttributePlugin(sourceAttribute.getAttributeType());
                if (plugin != null) {
                    plugin.syncAttribute(engine, this, sourceAttribute);
                }
            }
        }
    }
    for (Qualifier sourceQualifier : sourceQualifiers) {
        Qualifier qualifier = getDestination(sourceQualifier);
        List<Element> sourceElements = source.getElements(sourceQualifier.getId());
        List<Element> destElements = engine.getElements(qualifier.getId());
        for (Element sourceElement : sourceElements) {
            Element dest = createElement(sourceElement, destElements, qualifier.getId());
            elements.put(sourceElement, dest);
        }
    }
    if (importTableAttributes)
        setupTableElements();
    Attribute hAttribute = StandardAttributesPlugin.getHierarchicalAttribute(source);
    for (Qualifier sourceQualifier : sourceQualifiers) {
        List<Element> sourceElements = source.getElements(sourceQualifier.getId());
        boolean h = sourceQualifier.getSystemAttributes().indexOf(hAttribute) >= 0;
        for (Element sourceElement : sourceElements) {
            Element dest = getDestination(sourceElement);
            if (h && (createdElemets.get(sourceElement) != null)) {
                HierarchicalPersistent hp = (HierarchicalPersistent) getSourceValue(sourceElement, hAttribute);
                Element prev = source.getElement(hp.getPreviousElementId());
                Element parent = source.getElement(hp.getParentElementId());
                HierarchicalPersistent set = new HierarchicalPersistent();
                if (prev == null)
                    set.setPreviousElementId(-1l);
                else
                    set.setPreviousElementId(getDestination(prev).getId());
                if (parent == null) {
                    set.setParentElementId(-1l);
                } else {
                    Element destination = getDestination(parent);
                    if (destination != null)
                        set.setParentElementId(destination.getId());
                    else
                        set.setParentElementId(-1l);
                }
                engine.setAttribute(dest, StandardAttributesPlugin.getHierarchicalAttribute(engine), set);
            }
        }
        Attribute[] attributes = sourceQualifier.getAttributes().toArray(new Attribute[sourceQualifier.getAttributes().size()]);
        Arrays.sort(attributes, new Comparator<Attribute>() {

            @Override
            public int compare(Attribute o1, Attribute o2) {
                AttributePlugin plugin1 = framework.findAttributePlugin(o1.getAttributeType());
                AttributePlugin plugin2 = framework.findAttributePlugin(o1.getAttributeType());
                if (plugin1 == null) {
                    if (plugin2 == null)
                        return 0;
                    else
                        return -1;
                }
                if (plugin2 == null)
                    return 1;
                if (plugin1.getSyncPriority() > plugin2.getSyncPriority())
                    return 1;
                if (plugin1.getSyncPriority() < plugin2.getSyncPriority())
                    return -1;
                return 0;
            }
        });
        for (Attribute sourceAttribute : attributes) {
            Attribute destAttribute = getDestination(sourceAttribute);
            if (destAttribute != null) {
                AttributePlugin plugin = framework.findAttributePlugin(destAttribute.getAttributeType());
                for (Element sourceElement : sourceElements) {
                    if ((createdElemets.get(sourceElement) != null) || (elementImportType == ELEMENT_IMPORT_TYPE_UPDATE)) {
                        if (plugin != null)
                            plugin.syncElement(engine, this, sourceElement, sourceAttribute);
                    }
                }
            }
        }
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) Attribute(com.ramussoft.common.Attribute) HierarchicalPersistent(com.ramussoft.core.attribute.simple.HierarchicalPersistent) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 10 with AttributePlugin

use of com.ramussoft.gui.common.AttributePlugin in project ramus by Vitaliy-Yakovchuk.

the class AttributePreferenciesDialog method updateAdditionalOptions.

protected void updateAdditionalOptions() {
    this.editor = null;
    AttributeType type = getAttributeType();
    AttributePlugin attributePlugin = framework.findAttributePlugin(type);
    if (attributePlugin == null) {
        System.err.println("WARNING: Attribute plugin for type: " + type + " not found.");
        return;
    }
    editor = attributePlugin.getAttributePreferenciesEditor();
    boolean update = false;
    if (this.component != null) {
        update = true;
        contentPanel.remove(this.component);
    }
    this.component = null;
    if (editor != null) {
        JComponent component = editor.createComponent(attribute, engine, accessRules);
        if (component != null) {
            update = true;
            contentPanel.add(component, BorderLayout.CENTER);
            this.component = component;
        }
    }
    if (update) {
        pack();
        contentPanel.revalidate();
        contentPanel.repaint();
    }
}
Also used : AttributePlugin(com.ramussoft.gui.common.AttributePlugin) AttributeType(com.ramussoft.common.AttributeType) JComponent(javax.swing.JComponent)

Aggregations

AttributePlugin (com.ramussoft.gui.common.AttributePlugin)15 Attribute (com.ramussoft.common.Attribute)10 Engine (com.ramussoft.common.Engine)5 AttributeType (com.ramussoft.common.AttributeType)4 Qualifier (com.ramussoft.common.Qualifier)4 BorderLayout (java.awt.BorderLayout)4 JPanel (javax.swing.JPanel)4 AccessRules (com.ramussoft.common.AccessRules)3 Element (com.ramussoft.common.Element)3 JLabel (javax.swing.JLabel)3 AttributeEditor (com.ramussoft.gui.common.AttributeEditor)2 GUIFramework (com.ramussoft.gui.common.GUIFramework)2 DialogedTableCellEditor (com.ramussoft.gui.qualifier.table.DialogedTableCellEditor)2 RowRootCreater (com.ramussoft.gui.qualifier.table.RowRootCreater)2 RowTreeTableComponent (com.ramussoft.gui.qualifier.table.RowTreeTableComponent)2 RowTreeTableModel (com.ramussoft.gui.qualifier.table.RowTreeTableModel)2 TabledAttributePlugin (com.ramussoft.gui.qualifier.table.TabledAttributePlugin)2 IDEF0Object (com.ramussoft.pb.idef.visual.IDEF0Object)2 TableLayout (info.clearthought.layout.TableLayout)2 KeyEvent (java.awt.event.KeyEvent)2