use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class FreeplaneGUIStarter method loadMaps.
private void loadMaps(final String[] args) {
final Controller controller = Controller.getCurrentController();
final boolean alwaysLoadLastMaps = ResourceController.getResourceController().getBooleanProperty("always_load_last_maps");
if (alwaysLoadLastMaps && !dontLoadLastMaps) {
loadLastMaps();
}
loadMaps(controller, args);
if (controller.getMap() != null) {
return;
}
if (!alwaysLoadLastMaps && !dontLoadLastMaps) {
final AddOnsController addonsController = AddOnsController.getController();
addonsController.setAutoInstallEnabled(false);
loadLastMaps();
addonsController.setAutoInstallEnabled(true);
}
if (firstRun && !dontLoadLastMaps) {
final File baseDir = new File(FreeplaneGUIStarter.getResourceBaseDir()).getAbsoluteFile().getParentFile();
final String map = ResourceController.getResourceController().getProperty("first_start_map");
final File absolutFile = ConfigurationUtils.getLocalizedFile(new File[] { baseDir }, map, Locale.getDefault().getLanguage());
if (absolutFile != null)
loadMaps(controller, new String[] { absolutFile.getAbsolutePath() });
}
if (null != controller.getMap()) {
return;
}
controller.selectMode(MModeController.MODENAME);
final MModeController modeController = (MModeController) controller.getModeController();
MFileManager.getController(modeController).newMapFromDefaultTemplate();
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class LastOpenedList method createOpenLastMapActionList.
public List<AFreeplaneAction> createOpenLastMapActionList() {
Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
int i = 0;
int maxEntries = getMaxMenuEntries();
List<AFreeplaneAction> openMapActions = new ArrayList<AFreeplaneAction>(maxEntries);
for (final String key : lastOpenedList) {
if (i == 0 && (!modeController.getModeName().equals(MModeController.MODENAME) || controller.getMap() == null || controller.getMap().getURL() == null)) {
i++;
maxEntries++;
}
if (i == maxEntries) {
break;
}
final AFreeplaneAction openMapAction = new OpenLastOpenedAction(i++, this, key);
createOpenMapItemName(openMapAction, key);
openMapActions.add(openMapAction);
}
return openMapActions;
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class LastOpenedList method updateMenus.
private void updateMenus() {
Controller controller = Controller.getCurrentController();
final ModeController modeController = controller.getModeController();
if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
menuBuilder.removeChildElements(MENU_CATEGORY);
List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
for (AFreeplaneAction openMapAction : openMapActions) {
final IFreeplaneAction acceleratableAction = menuBuilder.acceleratableAction(openMapAction);
final JMenuItem item = new JFreeplaneMenuItem(acceleratableAction);
item.setMnemonic(0);
menuBuilder.addMenuItem(MENU_CATEGORY, item, MENU_CATEGORY + '/' + openMapAction.getKey(), UIBuilder.AS_CHILD);
}
}
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class SaveAll method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller controller = Controller.getCurrentController();
final Component initialMapView = controller.getMapViewManager().getMapViewComponent();
final Map<String, MapModel> mapViews = getMapViews();
final Iterator<Entry<String, MapModel>> iterator = mapViews.entrySet().iterator();
while (iterator.hasNext()) {
final Entry<String, MapModel> entry = iterator.next();
controller.getMapViewManager().changeToMapView(entry.getKey());
final ModeController modeController = controller.getModeController();
if (modeController instanceof MModeController) {
((MModeController) modeController).save();
}
}
if (initialMapView != null) {
controller.getMapViewManager().changeToMapView(initialMapView);
}
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class UrlManager method load.
/**
*@deprecated -- use {@link MapIO#load(URL url, MapModel map)}
*/
@Deprecated
public InputStreamReader load(final URL url, final MapModel map) throws IOException, XMLException {
InputStreamReader urlStreamReader;
setURL(map, url);
InputStream inputStream = getLocation(url).openStream();
urlStreamReader = new InputStreamReader(inputStream);
final ModeController modeController = Controller.getCurrentModeController();
modeController.getMapController().getMapReader().createNodeTreeFromXml(map, urlStreamReader, Mode.FILE);
return urlStreamReader;
}
Aggregations