use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class EditStylesAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller currentController = Controller.getCurrentController();
final MapModel map = currentController.getMap();
final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map);
final MapModel styleMap = mapStyleModel.getStyleMap();
if (styleMap == null) {
UITools.errorMessage(TextUtils.getText("no_styles_found_in_map"));
return;
}
final IMapViewManager mapViewManager = currentController.getMapViewManager();
currentMapView = mapViewManager.getMapViewComponent();
mapViewManager.changeToMapView((Component) null);
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
undoHandler.startTransaction();
init();
SModeController modeController = getModeController();
modeController.getMapController().newMapView(styleMap);
Controller controller = modeController.getController();
Component mapViewComponent = controller.getMapViewManager().getMapViewComponent();
((DialogController) controller.getViewController()).setMapView(mapViewComponent);
dialog.setLocationRelativeTo(currentController.getViewController().getCurrentRootComponent());
dialog.setVisible(true);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class NewLevelStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final MapModel map = Controller.getCurrentController().getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
final String styleName = "AutomaticLayout.level," + levelStyleParentNode.getChildCount();
final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel node = new NodeModel(map);
node.setUserObject(styleObject);
mapController.insertNode(node, levelStyleParentNode, false, false, true);
mapController.select(node);
final IActor actor = new IActor() {
public void undo() {
styleModel.removeStyleNode(node);
}
public String getDescription() {
return "NewLevelStyle";
}
public void act() {
styleModel.addStyleNode(node);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class NewUserStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
if (styleName == null) {
return;
}
final Controller controller = Controller.getCurrentController();
final NodeModel selectedNode = controller.getSelection().getSelected();
final MapModel map = controller.getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
final IStyle style = StyleFactory.create(styleName);
if (null != styleModel.getStyleNode(style)) {
UITools.errorMessage(TextUtils.getText("style_already_exists"));
return;
}
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel newNode = new NodeModel(map);
newNode.setUserObject(style);
Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_USER_DEFINED);
if (userStyleParentNode == null) {
userStyleParentNode = new NodeModel(map);
userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
mapController.insertNode(userStyleParentNode, map.getRootNode(), false, false, true);
}
mapController.insertNode(newNode, userStyleParentNode, false, false, true);
mapController.select(newNode);
final IActor actor = new IActor() {
public void undo() {
styleModel.removeStyleNode(newNode);
}
public String getDescription() {
return "NewStyle";
}
public void act() {
styleModel.addStyleNode(newNode);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class SModeController method tryToCloseDialog.
void tryToCloseDialog() {
final IMapViewManager mapViewManager = getController().getMapViewManager();
final MapModel map = mapViewManager.getModel();
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
final Window dialog = ((DialogController) getController().getViewController()).getDialog();
if (!undoHandler.canUndo()) {
dialog.setVisible(false);
return;
}
final String text = TextUtils.getText("save_unsaved_styles");
final String title = TextUtils.getText("SaveAction.text");
final int returnVal = JOptionPane.showOptionDialog(dialog, text, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
if ((returnVal == JOptionPane.CANCEL_OPTION) || (returnVal == JOptionPane.CLOSED_OPTION)) {
return;
}
setStatus(returnVal == JOptionPane.YES_OPTION ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION);
dialog.setVisible(false);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class NodeList method exportSelectedRowsAndClose.
protected void exportSelectedRowsAndClose() {
final int[] selectedRows = tableView.getSelectedRows();
final List<NodeModel> selectedNodes = new ArrayList<NodeModel>();
for (int i = 0; i < selectedRows.length; i++) {
final int row = selectedRows[i];
selectedNodes.add(getMindMapNode(row));
}
final ModeController mindMapController = Controller.getCurrentModeController();
MFileManager.getController(mindMapController).newMapFromDefaultTemplate();
final MapModel newMap = Controller.getCurrentController().getMap();
for (final NodeModel node : selectedNodes) {
final NodeModel copy = ClipboardController.getController().duplicate(node, false);
if (copy != null) {
mindMapController.getMapController().insertNodeIntoWithoutUndo(copy, newMap.getRootNode());
}
}
disposeDialog();
}
Aggregations