Search in sources :

Example 11 with AttributeRegistry

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel)

Example 12 with AttributeRegistry

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) MapModel(org.freeplane.features.map.MapModel) HierarchyListener(java.awt.event.HierarchyListener) EtchedBorder(javax.swing.border.EtchedBorder) TypedListCellRenderer(org.freeplane.core.ui.components.TypedListCellRenderer) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) HierarchyEvent(java.awt.event.HierarchyEvent) ItemListener(java.awt.event.ItemListener) ClonedComboBoxModel(org.freeplane.features.attribute.mindmapmode.AssignAttributeDialog.ClonedComboBoxModel) Component(java.awt.Component) ClonedComboBoxModel(org.freeplane.features.attribute.mindmapmode.AssignAttributeDialog.ClonedComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel)

Example 13 with AttributeRegistry

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) JComboBox(javax.swing.JComboBox) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) EventObject(java.util.EventObject) IFormattedObject(org.freeplane.features.format.IFormattedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel)

Example 14 with AttributeRegistry

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);
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 15 with AttributeRegistry

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel)

Aggregations

AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)19 MapModel (org.freeplane.features.map.MapModel)17 IActor (org.freeplane.core.undo.IActor)13 NodeModel (org.freeplane.features.map.NodeModel)7 NoSuchElementException (java.util.NoSuchElementException)6 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)6 ModeController (org.freeplane.features.mode.ModeController)6 ComboBoxModel (javax.swing.ComboBoxModel)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)3 JComboBox (javax.swing.JComboBox)2 AttributeController (org.freeplane.features.attribute.AttributeController)2 ClonedComboBoxModel (org.freeplane.features.attribute.mindmapmode.AssignAttributeDialog.ClonedComboBoxModel)2 Controller (org.freeplane.features.mode.Controller)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 HierarchyEvent (java.awt.event.HierarchyEvent)1 HierarchyListener (java.awt.event.HierarchyListener)1