use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class MAttributeController method performRegistryAttributeValue.
@Override
public void performRegistryAttributeValue(final String name, final String value, boolean manual) {
if (name.equals("")) {
return;
}
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
try {
final AttributeRegistryElement element = attributeRegistry.getElement(name);
if (element.getValues().contains(value)) {
return;
}
final IActor actor = new RegistryAttributeValueActor(element, value, manual);
Controller.getCurrentModeController().execute(actor, map);
return;
} catch (final NoSuchElementException ex) {
final IActor nameActor = new RegistryAttributeActor(name, true, false, attributeRegistry, map);
Controller.getCurrentModeController().execute(nameActor, map);
final AttributeRegistryElement element = attributeRegistry.getElement(name);
final IActor valueActor = new RegistryAttributeValueActor(element, value, false);
Controller.getCurrentModeController().execute(valueActor, map);
}
}
use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class MAttributeController method performSetValueAt.
@Override
public void performSetValueAt(final NodeAttributeTableModel model, final Object o, final int row, final int col) {
final Attribute attribute = model.getAttribute(row);
final MapModel map = model.getNode().getMap();
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
switch(col) {
case 0:
{
final String name = o.toString().trim();
final String oldName = attribute.getName();
if (oldName.equals(name)) {
return;
}
final IActor nameActor = new SetAttributeNameActor(model, name, oldName, row);
Controller.getCurrentModeController().execute(nameActor, map);
try {
final AttributeRegistryElement element = registry.getElement(name);
final String value = model.getValueAt(row, 1).toString();
final int index = element.getValues().getIndexOf(value);
if (index == -1) {
final IActor valueActor = new SetAttributeValueActor(model, row, element.getValues().firstElement());
Controller.getCurrentModeController().execute(valueActor, map);
}
} catch (final NoSuchElementException ex) {
final IActor registryActor = new RegistryAttributeActor(name, false, false, registry, map);
Controller.getCurrentModeController().execute(registryActor, map);
}
break;
}
case 1:
{
if (attribute.getValue().equals(o)) {
return;
}
final IActor actor = new SetAttributeValueActor(model, row, o);
Controller.getCurrentModeController().execute(actor, map);
final String name = model.getValueAt(row, 0).toString();
final AttributeRegistryElement element = registry.getElement(name);
final int index = element.getValues().getIndexOf(o);
if (index == -1) {
final IActor registryActor = new RegistryAttributeValueActor(element, o, false);
Controller.getCurrentModeController().execute(registryActor, map);
}
break;
}
}
}
use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class AddAttributeAction method selectedAttributeChanged.
protected void selectedAttributeChanged(final Object selectedAttributeName, final JComboBox values) {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
try {
final AttributeRegistryElement element = attributes.getElement(selectedAttributeName.toString());
final ComboBoxModel selectedValues = element.getValues();
values.setModel(new ClonedComboBoxModel(selectedValues));
try {
final Object firstValue = selectedValues.getElementAt(0);
values.setSelectedItem(firstValue);
} catch (final ArrayIndexOutOfBoundsException ex) {
}
values.setEditable(!element.isRestricted());
} catch (final NoSuchElementException ex) {
values.setEditable(!selectedAttributeName.toString().equals(""));
}
}
use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class AssignAttributeDialog method selectedAttributeChanged.
private void selectedAttributeChanged(final Object selectedAttributeName, final JComboBox values) {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
try {
final AttributeRegistryElement element = attributes.getElement(selectedAttributeName.toString());
final ComboBoxModel selectedValues = element.getValues();
values.setModel(new ClonedComboBoxModel(selectedValues));
try {
final Object firstValue = selectedValues.getElementAt(0);
values.setSelectedItem(firstValue);
} catch (final ArrayIndexOutOfBoundsException ex) {
}
values.setEditable(!element.isRestricted());
} catch (final NoSuchElementException ex) {
values.setEditable(!selectedAttributeName.toString().equals(""));
}
}
use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class ImportAttributesDialog method createAttributeSubTrees.
private void createAttributeSubTrees(final DefaultMutableTreeNode mapInfo, final AttributeRegistry attributes) {
if (attributes == null) {
return;
}
for (int i = 0; i < attributes.size(); i++) {
final AttributeRegistryElement element = attributes.getElement(i);
final TreeNodeInfo treeNodeInfo = new AttributeTreeNodeInfo(element.getKey().toString(), element.isRestricted());
final DefaultMutableTreeNode attributeInfo = new DefaultMutableTreeNode(treeNodeInfo);
createValueSubTrees(attributeInfo, element, currentAttributes);
if (attributeInfo.getChildCount() != 0) {
mapInfo.add(attributeInfo);
}
}
}
Aggregations