use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class MAttributeController method performRemoveAttributeValue.
@Override
public void performRemoveAttributeValue(final String name, final Object value) {
final IVisitor remover = new AttributeValueRemover(name, value);
final Iterator iterator = new Iterator(remover);
ModeController modeController = Controller.getCurrentModeController();
final NodeModel root = modeController.getMapController().getRootNode();
iterator.iterate(root);
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
final IActor unregistryActor = new UnregistryAttributeValueActor(attributeRegistry.getElement(name), value);
Controller.getCurrentModeController().execute(unregistryActor, map);
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class AddAttributeAction method getPanel.
/**
* This method creates the input dialog
*
* @return : the input dialog
*/
private JPanel getPanel() {
final JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.setBorder(new EtchedBorder());
final GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.CENTER;
gridBagConstraints.insets = new Insets(20, 10, 2, 10);
// Size of JComboBoxes
final String pattern = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
final JLabel patternLabel = new JLabel(pattern);
final Dimension comboBoxMaximumSize = patternLabel.getPreferredSize();
comboBoxMaximumSize.width += 4;
comboBoxMaximumSize.height += 10;
// Label: name
final JLabel nameLabel = new JLabel(TextUtils.getText("attribute_name"));
panel.add(nameLabel, gridBagConstraints);
gridBagConstraints.gridx++;
// Label: value
final JLabel valueLabel = new JLabel(TextUtils.getText("attribute_value"));
panel.add(valueLabel, gridBagConstraints);
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy++;
// Attribute name combo-box
gridBagConstraints.insets = new Insets(2, 10, 20, 10);
attributeNames = new JComboBox();
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
final ComboBoxModel names = attributes.getComboBoxModel();
attributeNames.setModel(new ClonedComboBoxModel(names));
attributeNames.setEditable(true);
attributeNames.setMaximumSize(comboBoxMaximumSize);
attributeNames.setPreferredSize(comboBoxMaximumSize);
attributeNames.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
selectedAttributeChanged(e.getItem(), attributeValues);
}
});
panel.add(attributeNames, gridBagConstraints);
// Attribute value combo-box
attributeValues = new JComboBox();
attributeValues.setRenderer(new TypedListCellRenderer());
attributeValues.setMaximumSize(comboBoxMaximumSize);
attributeValues.setPreferredSize(comboBoxMaximumSize);
gridBagConstraints.gridx++;
panel.add(attributeValues, gridBagConstraints);
// set focus to attributeNames
panel.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent e) {
final Component component = e.getComponent();
if (component.isShowing()) {
attributeNames.requestFocus();
component.removeHierarchyListener(this);
}
}
});
return panel;
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class AttributeTable method prepareEditor.
@Override
public Component prepareEditor(final TableCellEditor tce, final int row, final int col) {
if (tce instanceof DialogTableCellEditor) {
return super.prepareEditor(tce, row, col);
}
final JComboBox comboBox = (JComboBox) ((DefaultCellEditor) tce).getComponent();
final NodeModel node = getAttributeTableModel().getNode();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(node.getMap());
final ComboBoxModel model;
switch(col) {
case 0:
model = attributes.getComboBoxModel();
comboBox.setEditable(!attributes.isRestricted());
break;
case 1:
final String attrName = getAttributeTableModel().getValueAt(row, 0).toString();
model = attributes.getDefaultComboBoxModel(attrName);
comboBox.setEditable(!attributes.isRestricted(attrName));
break;
default:
model = AttributeTable.getDefaultComboBoxModel();
}
final Object[] items = new Object[model.getSize()];
for (int i = 0; i < items.length; i++) {
items[i] = model.getElementAt(i);
}
final DefaultComboBoxModel currentModel = new DefaultComboBoxModel(items);
comboBox.setModel(currentModel);
updateFontSize(comboBox, getZoom());
return super.prepareEditor(tce, row, col);
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class MAttributeController method performSetRestriction.
@Override
public void performSetRestriction(final int index, final boolean isRestricted) {
boolean currentValue;
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
if (index == AttributeRegistry.GLOBAL) {
currentValue = registry.isRestricted();
} else {
currentValue = registry.getElement(index).isRestricted();
}
if (currentValue == isRestricted) {
return;
}
final IActor actor = new SetAttributeRestrictedActor(registry, index, isRestricted);
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class MAttributeController method performRemoveAttributeValue.
@Override
public void performRemoveAttributeValue(final String name, final String value) {
final IVisitor remover = new AttributeValueRemover(name, value);
final Iterator iterator = new Iterator(remover);
ModeController modeController = Controller.getCurrentModeController();
final NodeModel root = modeController.getMapController().getRootNode();
iterator.iterate(root);
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
final IActor unregistryActor = new UnregistryAttributeValueActor(attributeRegistry.getElement(name), value);
Controller.getCurrentModeController().execute(unregistryActor, map);
}
Aggregations