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;
}
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);
}
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);
}
}
}
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;
}
}
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()));
}
}
Aggregations