Search in sources :

Example 16 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class MenuUtils method insertAsNodeModel.

private static NodeModel insertAsNodeModel(final NodeModel nodeModel, final DefaultMutableTreeNode treeNode, final MapController mapController) {
    final MenuEntry menuEntry = (MenuEntry) treeNode.getUserObject();
    final String text = menuEntry.getKeyStroke() == null ? menuEntry.getLabel() : menuEntry.getLabel() + ": " + MenuUtils.formatKeyStroke(menuEntry.getKeyStroke());
    final NodeModel newNodeModel = mapController.newNode(text, nodeModel.getMap());
    if (!treeNode.isLeaf()) {
        newNodeModel.setFolded(true);
    }
    if (menuEntry.getIconKey() != null) {
        final MindIcon mindIcon = menuEntry.createMindIcon();
        if (mindIcon != null)
            newNodeModel.addIcon(mindIcon);
    }
    nodeModel.insert(newNodeModel);
    return newNodeModel;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MindIcon(org.freeplane.features.icon.MindIcon)

Example 17 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class AttributeBuilder method registerBy.

/**
 */
public void registerBy(final ReadManager reader, final WriteManager writer) {
    reader.addElementHandler("attribute_registry", this);
    reader.addElementHandler(AttributeBuilder.XML_NODE_ATTRIBUTE, this);
    reader.addElementHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, this);
    reader.addElementHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE, this);
    writer.addExtensionElementWriter(NodeAttributeTableModel.class, new IExtensionElementWriter() {

        public void writeContent(final ITreeWriter writer, final Object node, final IExtension extension) throws IOException {
            final NodeAttributeTableModel attributes = (NodeAttributeTableModel) extension;
            save((NodeModel) node, attributes, writer);
        }
    });
    writer.addExtensionElementWriter(AttributeRegistry.class, new IExtensionElementWriter() {

        public void writeContent(final ITreeWriter writer, final Object node, final IExtension extension) throws IOException {
            final AttributeRegistry attributes = (AttributeRegistry) extension;
            attributes.write(writer);
        }
    });
    writer.addAttributeWriter(XML_NODE_ATTRIBUTE_LAYOUT, AttributeWriter.INSTANCE);
    registerAttributeHandlers(reader);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IExtension(org.freeplane.core.extension.IExtension) ITreeWriter(org.freeplane.core.io.ITreeWriter) IOException(java.io.IOException) IExtensionElementWriter(org.freeplane.core.io.IExtensionElementWriter)

Example 18 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class AddAttributeAction method actionPerformed.

public void actionPerformed(final ActionEvent arg0) {
    final Collection<NodeModel> nodes = Controller.getCurrentModeController().getMapController().getSelectedNodes();
    final int selection = UITools.showConfirmDialog(Controller.getCurrentController().getSelection().getSelected(), getPanel(), TextUtils.getText("attributes_AddAttributeAction.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    // OK button pressed
    if (selection == JOptionPane.OK_OPTION) {
        if (attributeNames.getSelectedItem() == null) {
            UITools.showAttributeEmptyStringErrorMessage();
            return;
        }
        final String name = attributeNames.getSelectedItem().toString();
        if (name.equals("")) {
            UITools.showAttributeEmptyStringErrorMessage();
            return;
        }
        final Object valueSelectedItem = attributeValues.getSelectedItem();
        final String value = valueSelectedItem != null ? valueSelectedItem.toString() : "";
        // Add attributes to nodes
        for (final NodeModel node : nodes) {
            final NodeAttributeTableModel attributes = attrContr.createAttributeTableModel(node);
            attrContr.performInsertRow(attributes, attributes.getRowCount(), name, value);
        }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 19 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class AttributeBuilder method endElement.

public void endElement(final Object parent, final String tag, final Object userObject, final XMLElement dom) {
    /* attributes */
    if (tag.equals(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME)) {
        final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) userObject;
        if (rap.visible) {
            AttributeRegistry.getRegistry(getMap()).getElement(rap.attributeName).setVisibility(true);
        }
        if (rap.restricted) {
            AttributeRegistry.getRegistry(getMap()).getElement(rap.attributeName).setRestriction(true);
        }
        if (rap.manual) {
            AttributeRegistry.getRegistry(getMap()).getElement(rap.attributeName).setManual(true);
        }
        return;
    }
    if (tag.equals(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE)) {
        final AttributeProperties ap = (AttributeProperties) userObject;
        final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) ap.parent;
        final Attribute attribute = new Attribute(rap.attributeName, ap.getValue());
        final AttributeRegistry r = AttributeRegistry.getRegistry(getMap());
        r.registry(attribute);
    }
    if (parent instanceof NodeModel) {
        final NodeModel node = (NodeModel) parent;
        if (tag.equals(AttributeBuilder.XML_NODE_ATTRIBUTE)) {
            final AttributeProperties ap = (AttributeProperties) userObject;
            final Attribute attribute = new Attribute(ap.attributeName, ap.getValue());
            attributeController.createAttributeTableModel(node);
            final NodeAttributeTableModel model = NodeAttributeTableModel.getModel(node);
            model.addRowNoUndo(attribute);
            return;
        }
        return;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 20 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class IconSelectionPlugin method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
    final Controller controller = Controller.getCurrentController();
    actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
    actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
    actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
    final MIconController mIconController = (MIconController) IconController.getController();
    for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
    final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(UITools.getCurrentFrame(), actions);
    final NodeModel selected = controller.getSelection().getSelected();
    controller.getMapViewManager().scrollNodeToVisible(selected);
    selectionDialog.pack();
    UITools.setDialogLocationRelativeTo(selectionDialog, selected);
    selectionDialog.setModal(true);
    selectionDialog.show();
    final int result = selectionDialog.getResult();
    if (result >= 0) {
        final Action action = (Action) actions.get(result);
        action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) NodeModel(org.freeplane.features.map.NodeModel) Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) IIconInformation(org.freeplane.features.icon.IIconInformation) ModeController(org.freeplane.features.mode.ModeController) IconSelectionPopupDialog(org.freeplane.core.ui.components.IconSelectionPopupDialog) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)408 ModeController (org.freeplane.features.mode.ModeController)89 MapModel (org.freeplane.features.map.MapModel)47 Controller (org.freeplane.features.mode.Controller)44 MapStyleModel (org.freeplane.features.styles.MapStyleModel)39 IMapSelection (org.freeplane.features.map.IMapSelection)34 MapController (org.freeplane.features.map.MapController)33 Point (java.awt.Point)32 MMapController (org.freeplane.features.map.mindmapmode.MMapController)31 IStyle (org.freeplane.features.styles.IStyle)31 IActor (org.freeplane.core.undo.IActor)30 NodeView (org.freeplane.view.swing.map.NodeView)22 ArrayList (java.util.ArrayList)20 Color (java.awt.Color)16 URI (java.net.URI)16 ResourceController (org.freeplane.core.resources.ResourceController)16 Component (java.awt.Component)15 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15 File (java.io.File)14