use of com.ramussoft.gui.common.QualifierSetupEditor in project ramus by Vitaliy-Yakovchuk.
the class QualifierPreferencesPanel method ok.
public boolean ok() {
if (box.getSelectedItem() == null) {
JOptionPane.showMessageDialog(this, GlobalResourcesManager.getString("Error.SetAttributeForName"));
return false;
}
String[] errors = new String[] {};
for (QualifierSetupEditor editor : editors) {
String[] add = editor.getErrors();
int start = errors.length;
errors = Arrays.copyOf(errors, errors.length + add.length);
for (int i = start; i < errors.length; i++) {
errors[i] = add[i - start];
}
}
if (errors.length > 0) {
StringBuffer sb = new StringBuffer();
sb.append("<html><body>");
for (String error : errors) {
sb.append(error);
sb.append("<br>");
}
sb.append("</body></html>");
JOptionPane.showMessageDialog(this, sb.toString());
return false;
}
if (engine instanceof Journaled) {
((Journaled) engine).startUserTransaction();
}
engine.setAttribute(element, attribute, attributeEditor.getValue());
long id = (Long) engine.getAttribute(element, (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.QUALIFIER_ID));
Qualifier qualifier = engine.getQualifier(id);
updateAttributesInOrder(attributeOrderEditPanel.getAttributes());
qualifier.setAttributes(attributeOrderEditPanel.getAttributes());
if (box.getSelectedItem() == null) {
qualifier.setAttributeForName(-1l);
} else {
Attribute attributeId = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_ID);
Long id2 = (Long) engine.getAttribute((Element) box.getSelectedItem(), attributeId);
Attribute a = engine.getAttribute(id2);
qualifier.setAttributeForName(a.getId());
}
engine.updateQualifier(qualifier);
IconPersistent selectedValue = open.getSelectedValue();
if (selectedValue != null)
IconFactory.setOpenIcon(engine, selectedValue, qualifier);
selectedValue = leaf.getSelectedValue();
if (selectedValue != null)
IconFactory.setLeafIcon(engine, selectedValue, qualifier);
selectedValue = closed.getSelectedValue();
if (selectedValue != null)
IconFactory.setClosedIcon(engine, selectedValue, qualifier);
for (QualifierSetupEditor editor : editors) {
editor.save(engine, qualifier);
}
if (engine instanceof Journaled) {
((Journaled) engine).commitUserTransaction();
}
return true;
}
Aggregations