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);
}
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;
}
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));
}
}
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);
}
}
}
}
}
}
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();
}
}
Aggregations