use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class SaveAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final boolean success = ((MModeController) Controller.getCurrentModeController()).save();
final Controller controller = Controller.getCurrentController();
if (success) {
controller.getViewController().out(TextUtils.getText("saved"));
} else {
controller.getViewController().out(TextUtils.getText("saving_canceled"));
}
controller.getMapViewManager().setTitle();
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class FreeplaneGUIStarter method createController.
public Controller createController() {
try {
Controller controller = new Controller(applicationResourceController);
Controller.setCurrentController(controller);
Compat.macAppChanges();
controller.addAction(new QuitAction());
applicationResourceController.init();
LogUtils.createLogger();
FreeplaneGUIStarter.showSysInfo();
final String lookandfeel = System.getProperty("lookandfeel", applicationResourceController.getProperty("lookandfeel"));
FrameController.setLookAndFeel(lookandfeel);
final JFrame frame;
USE_RIBBONS_MENU = UITools.useRibbonsMenu();
if (USE_RIBBONS_MENU) {
frame = new JRibbonFrame("Freeplane");
initIcons(applicationResourceController);
} else {
frame = new JFrame("Freeplane");
}
frame.setName(UITools.MAIN_FREEPLANE_FRAME);
splash = new FreeplaneSplashModern(frame);
if (!System.getProperty("org.freeplane.nosplash", "false").equals("true")) {
splash.setVisible(true);
}
final MMapViewController mapViewController = new MMapViewController(controller);
viewController = new ApplicationViewController(controller, mapViewController, frame);
System.setSecurityManager(new FreeplaneSecurityManager());
mapViewController.addMapViewChangeListener(applicationResourceController.getLastOpenedList());
FilterController.install();
PrintController.install();
FormatController.install(new FormatController());
final ScannerController scannerController = new ScannerController();
ScannerController.install(scannerController);
scannerController.addParsersForStandardFormats();
ModelessAttributeController.install();
TextController.install();
TimeController.install();
LinkController.install();
IconController.install();
HelpController.install();
controller.addAction(new UpdateCheckAction());
controller.addAction(new NextNodeAction(Direction.FORWARD));
controller.addAction(new NextNodeAction(Direction.BACK));
controller.addAction(new NextNodeAction(Direction.FORWARD_N_FOLD));
controller.addAction(new NextNodeAction(Direction.BACK_N_FOLD));
controller.addAction(new NextPresentationItemAction());
controller.addAction(new ShowSelectionAsRectangleAction());
controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
FilterController.getCurrentFilterController().getConditionFactory().addConditionController(70, new LogicalStyleFilterController());
MapController.install();
NodeHistory.install(controller);
return controller;
} catch (final Exception e) {
LogUtils.severe(e);
throw new RuntimeException(e);
}
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class FreeplaneGUIStarter method createFrame.
public void createFrame(final String[] args) {
Controller controller = Controller.getCurrentController();
ModeController modeController = controller.getModeController(MModeController.MODENAME);
controller.selectModeForBuild(modeController);
Compat.macMenuChanges();
new UserPropertiesUpdater().importOldDefaultStyle();
EventQueue.invokeLater(new Runnable() {
public void run() {
final Options options = CommandLineParser.parse(args);
viewController.init(Controller.getCurrentController());
splash.toBack();
final Frame frame = viewController.getFrame();
final int extendedState = frame.getExtendedState();
Container contentPane = viewController.getContentPane();
contentPane.setVisible(false);
splash.dispose();
splash = null;
frame.setVisible(true);
if (extendedState != frame.getExtendedState()) {
frame.setExtendedState(extendedState);
}
loadMaps(options.getFilesToOpenAsArray());
focusCurrentView();
viewController.getContentPane().setVisible(true);
frame.toFront();
startupFinished = true;
System.setProperty("nonInteractive", Boolean.toString(options.isNonInteractive()));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
MenuUtils.executeMenuItems(options.getMenuItemsToExecute());
}
private void focusCurrentView() {
final MapView currentMapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
if (currentMapView != null) {
viewController.focusTo(currentMapView);
}
}
});
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class MFileManager method createActions.
private void createActions() {
final Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
controller.addAction(new OpenAction());
controller.addAction(new OpenURLMapAction());
controller.addAction(new NewMapAction());
final File userTemplates = defaultUserTemplateDir();
userTemplates.mkdir();
modeController.addAction(new NewMapFromTemplateAction("new_map_from_user_templates", userTemplates));
modeController.addAction(new SaveAction());
modeController.addAction(new SaveAsAction());
modeController.addAction(new ExportBranchAction());
modeController.addAction(new ImportBranchAction());
modeController.addAction(new ImportLinkedBranchAction());
modeController.addAction(new ImportLinkedBranchWithoutRootAction());
modeController.addAction(new ImportExplorerFavoritesAction());
modeController.addAction(new ImportFolderStructureAction());
modeController.addAction(new RevertAction());
modeController.addAction(new OpenUserDirAction());
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class MFileManager method newMapFromTemplate.
/**
*@deprecated -- use MMapIO
*/
@Deprecated
public MapModel newMapFromTemplate(final File startFile) {
final File file;
if (startFile == null) {
file = getLastCurrentDir();
} else if (startFile.isDirectory()) {
final JFileChooser chooser = getFileChooser(true);
chooser.setCurrentDirectory(startFile);
final int returnVal = chooser.showOpenDialog(Controller.getCurrentController().getMapViewManager().getMapViewComponent());
if (returnVal != JFileChooser.APPROVE_OPTION) {
return null;
}
file = chooser.getSelectedFile();
} else {
file = startFile;
}
try {
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
mapController.newUntitledMap(Compat.fileToUrl(file));
final Controller controller = Controller.getCurrentController();
final MapModel map = controller.getMap();
final Object rootText = map.getRootNode().getUserObject();
if (rootText instanceof NamedObject) {
map.getRootNode().setText(rootText.toString());
}
controller.getModeController().getMapController().setSaved(map, true);
return map;
} catch (Exception e) {
handleLoadingException(e);
}
return null;
}
Aggregations