use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class DeleteUserStyleAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
final Controller controller = modeController.getController();
final NodeModel selected = controller.getSelection().getSelected();
if (selected.depth() < 2) {
UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
return;
}
final MapModel map = selected.getMap();
final MapStyleModel styleModel = MapStyleModel.getExtension(map);
final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
if (!((StyleTranslatedObject) styleNodeGroup.getUserObject()).getObject().equals("styles.user-defined")) {
UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
return;
}
final MMapController mapController = (MMapController) modeController.getMapController();
mapController.deleteNode(selected);
final IActor actor = new IActor() {
public void undo() {
styleModel.addStyleNode(selected);
}
public String getDescription() {
return "DeleteStyle";
}
public void act() {
styleModel.removeStyleNode(selected);
}
};
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class LastOpenedList method selectLastVisitedNode.
private boolean selectLastVisitedNode(RecentFile recentFile) {
if (recentFile != null && recentFile.lastVisitedNodeId != null) {
final MapModel map = Controller.getCurrentController().getMap();
final NodeModel node = map.getNodeForID(recentFile.lastVisitedNodeId);
if (node != null && node.hasVisibleContent()) {
IMapSelection selection = Controller.getCurrentController().getSelection();
// don't override node selection done by UriManager.loadURI()
if (selection.isSelected(map.getRootNode()))
selection.selectAsTheOnlyOneSelected(node);
return true;
}
}
return false;
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class EditStylesAction method init.
private void init() {
this.mainController = Controller.getCurrentController();
if (dialog != null) {
Controller.setCurrentController((Controller) dialog.getRootPane().getClientProperty(Controller.class));
return;
}
dialog = new JDialog(UITools.getCurrentFrame());
final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
windowConfigurationStorage.restoreDialogPositions(dialog);
dialog.setModal(true);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
getModeController().tryToCloseDialog();
}
});
Controller styleDialogController = SModeControllerFactory.getInstance().createController(dialog);
modeController = (SModeController) styleDialogController.getModeController();
final ViewController viewController = styleDialogController.getViewController();
viewController.init(styleDialogController);
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(final ComponentEvent e) {
final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
windowConfigurationStorage.storeDialogPositions(dialog);
final IMapViewManager mapViewManager = modeController.getController().getMapViewManager();
final MapModel map = mapViewManager.getModel();
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
modeController.getMapController().closeWithoutSaving(map);
Controller.setCurrentController(mainController);
super.componentHidden(e);
mainController.getMapViewManager().changeToMapView(currentMapView);
currentMapView = null;
switch(modeController.getStatus()) {
case JOptionPane.OK_OPTION:
if (undoHandler.canUndo()) {
commit();
break;
}
// $FALL-THROUGH$
case JOptionPane.CANCEL_OPTION:
rollback();
}
}
});
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class EditStylesAction method commit.
void commit() {
final Controller currentController = Controller.getCurrentController();
final MapModel currentMap = currentController.getMap();
LogicalStyleController.getController().refreshMap(currentMap);
final ModeController currentModeController = Controller.getCurrentModeController();
currentModeController.commit();
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class ShowNotesInMapAction method setSelected.
@Override
public void setSelected() {
final MapModel map = Controller.getCurrentController().getMap();
final boolean notesShown = map != null && NoteController.getController().showNotesInMap(map);
setSelected(notesShown);
}
Aggregations