use of com.ramussoft.core.attribute.simple.IconPersistent in project ramus by Vitaliy-Yakovchuk.
the class IconFactory method getDefaultIcons.
@SuppressWarnings("unchecked")
private static Hashtable<Long, ImageIcon> getDefaultIcons(Engine engine, String key, Attribute attribute) {
Hashtable<Long, ImageIcon> result = (Hashtable<Long, ImageIcon>) engine.getPluginProperty("Core", key);
if (result == null) {
result = new Hashtable<Long, ImageIcon>();
Qualifier qualifier = StandardAttributesPlugin.getIconsQualifier(engine);
List<Attribute> attributes = new ArrayList<Attribute>(2);
Attribute iconsAttribute = StandardAttributesPlugin.getIconsAttribute(engine);
attributes.add(iconsAttribute);
attributes.add(attribute);
Hashtable<Element, Object[]> res = engine.getElements(qualifier, attributes);
Enumeration<Element> keys = res.keys();
while (keys.hasMoreElements()) {
Element element = keys.nextElement();
Object[] objects = res.get(element);
if ((objects[0] != null) && (((IconPersistent) objects[0]).getIcon() != null) && (objects[1] != null)) {
StringTokenizer st = new StringTokenizer((String) objects[1]);
ImageIcon icon = new ImageIcon(((IconPersistent) objects[0]).getIcon());
while (st.hasMoreElements()) {
result.put(Long.parseLong(st.nextToken()), icon);
}
}
}
engine.setPluginProperty("Core", key, result);
}
return result;
}
use of com.ramussoft.core.attribute.simple.IconPersistent 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