use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.
the class MModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, UITools.useRibbonsMenu());
final IMouseListener nodeMouseMotionListener = new MNodeMotionListener();
userInputListenerFactory.setNodeMouseMotionListener(nodeMouseMotionListener);
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
if (userInputListenerFactory.useRibbonMenu()) {
RibbonBuilder builder = userInputListenerFactory.getMenuBuilder(RibbonBuilder.class);
final RibbonMapChangeAdapter mapChangeAdapter = builder.getMapChangeAdapter();
modeController.getMapController().addNodeSelectionListener(mapChangeAdapter);
modeController.getMapController().addNodeChangeListener(mapChangeAdapter);
modeController.getMapController().addMapChangeListener(mapChangeAdapter);
controller.getMapViewManager().addMapSelectionListener(mapChangeAdapter);
}
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
IconController.install(new MIconController(modeController));
new ProgressFactory().installActions(modeController);
final MapController mapController = modeController.getMapController();
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final MTextController textController = new MTextController(modeController);
TextController.install(textController);
LinkController.install(new MLinkController());
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
userInputListenerFactory.setNodeDragListener(new MNodeDragListener());
userInputListenerFactory.setNodeDropTargetListener(new MNodeDropListener());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
userInputListenerFactory.setNodeKeyListener(new DefaultNodeKeyListener(new IEditHandler() {
public void edit(final KeyEvent e, final FirstAction action, final boolean editLong) {
((MTextController) MTextController.getController(modeController)).getEventQueue().activate(e);
textController.edit(action, editLong);
}
}));
userInputListenerFactory.setNodeMotionListener(new MNodeMotionListener());
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
final FreeplaneToolBar toolbar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
final FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolbar, "toolbarVisible");
if (!userInputListenerFactory.useRibbonMenu()) {
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolbar);
}
userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, frameController.getStatusBar());
final JTabbedPane formattingPanel = new JTabbedPane();
Box resisableTabs = new CollapseableBoxBuilder(frameController).setPropertyNameBase("styleScrollPaneVisible").createBox(formattingPanel, Direction.RIGHT);
modeController.getUserInputListenerFactory().addToolBar("/format", ViewController.RIGHT, resisableTabs);
KeyBindingProcessor keyProcessor = new KeyBindingProcessor();
modeController.addExtension(KeyBindingProcessor.class, keyProcessor);
keyProcessor.addKeyStrokeProcessor(userInputListenerFactory.getAcceleratorManager());
final FButtonBar fButtonToolBar = new FButtonBar(frameController.getRootPaneContainer().getRootPane(), keyProcessor);
UIComponentVisibilityDispatcher.install(frameController, fButtonToolBar, "fbarVisible");
fButtonToolBar.setVisible(ResourceController.getResourceController().getBooleanProperty("fbarVisible"));
userInputListenerFactory.addToolBar("/fbuttons", ViewController.TOP, fButtonToolBar);
controller.addAction(new ToggleToolbarAction("ToggleFBarAction", "/fbuttons"));
SModeControllerFactory.install();
modeController.addAction(new SetAcceleratorOnNextClickAction());
modeController.addAction(new ShowNotesInMapAction());
// userInputListenerFactory.getMenuBuilder().setAcceleratorChangeListener(fButtonToolBar);
userInputListenerFactory.getAcceleratorManager().addAcceleratorChangeListener(fButtonToolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
new RevisionPlugin();
FoldingController.install(new FoldingController());
uiFactory = new MUIFactory();
mapController.addNodeChangeListener(uiFactory);
mapController.addNodeSelectionListener(uiFactory);
mapController.addMapChangeListener(uiFactory);
controller.getMapViewManager().addMapSelectionListener(uiFactory);
final MToolbarContributor menuContributor = new MToolbarContributor(uiFactory);
modeController.addExtension(MUIFactory.class, uiFactory);
modeController.addMenuContributor(menuContributor);
new CloneStateIconSupplier().registerStateIconProvider();
// IconController.getController(modeController).addStateIconProvider(new IStateIconProvider() {
// public UIIcon getStateIcon(NodeModel node) {
// final URI link = NodeLinks.getLink(node);
// return wrapIcon(LinkController.getLinkIcon(link, node));
// }
//
// private UIIcon wrapIcon(final Icon linkIcon) {
// UIIcon icon = null;
// if(linkIcon != null) {
// if(linkIcon instanceof UIIcon) {
// icon = (UIIcon) linkIcon;
// }
// else {
// icon = new UIIcon("ownIcon", null) {
// public Icon getIcon() {
// return linkIcon;
// }
// };
// }
// }
// return icon;
// }
// });
}
use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.
the class SModeControllerFactory method createController.
Controller createController(final JDialog dialog) {
final Controller controller = new Controller(ResourceController.getResourceController());
Controller.setCurrentController(controller);
final MapViewController mapViewController = new MMapViewController(controller);
final DialogController viewController = new DialogController(controller, mapViewController, dialog);
controller.setViewController(viewController);
FilterController.install();
TextController.install();
controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
controller.addAction(new ShowSelectionAsRectangleAction());
modeController = new SModeController(controller);
controller.selectModeForBuild(modeController);
modeController.addAction(new NewUserStyleAction());
modeController.addAction(new DeleteUserStyleAction());
modeController.addAction(new NewLevelStyleAction());
modeController.addAction(new DeleteLevelStyleAction());
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
userInputListenerFactory.setNodeMouseMotionListener(new DefaultNodeMouseMotionListener());
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addExtension(ModelessAttributeController.class, new ModelessAttributeController());
new MMapController(modeController);
userInputListenerFactory.getMenuBuilder(RibbonBuilder.class).setEnabled(false);
TextController.install(new MTextController(modeController));
SpellCheckerController.install(modeController);
IconController.install(new MIconController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
LinkController.install(new MLinkController());
MFileManager.install(new MFileManager());
MMapIO.install(modeController);
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
logicalStyleController.initS();
LogicalStyleController.install(logicalStyleController);
AttributeController.install(new MAttributeController(modeController));
FormatController.install(new FormatController());
final ScannerController scannerController = new ScannerController();
ScannerController.install(scannerController);
scannerController.addParsersForStandardFormats();
modeController.addAction(new EditAttributesAction());
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
UIComponentVisibilityDispatcher.install(viewController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
MapStyle.install(false);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
final SModeController modeController = this.modeController;
final StyleEditorPanel styleEditorPanel = new StyleEditorPanel(modeController, null, false);
final MapController mapController = modeController.getMapController();
mapController.addNodeSelectionListener(new INodeSelectionListener() {
public void onSelect(final NodeModel node) {
final IMapSelection selection = controller.getSelection();
if (selection == null) {
return;
}
if (selection.size() == 1 && node.depth() >= 2) {
return;
}
final NodeModel nextSelection;
if (node.depth() < 2) {
if (node.depth() == 1 && node.hasChildren()) {
nextSelection = (NodeModel) node.getChildAt(0);
} else {
nextSelection = (NodeModel) (node.getMap().getRootNode().getChildAt(0).getChildAt(0));
}
} else {
nextSelection = node;
}
EventQueue.invokeLater(new Runnable() {
public void run() {
selection.selectAsTheOnlyOneSelected(nextSelection);
}
});
}
public void onDeselect(final NodeModel node) {
}
});
mapController.addNodeChangeListener(new INodeChangeListener() {
public void nodeChanged(NodeChangeEvent event) {
final NodeModel node = event.getNode();
if (node.getUserObject().equals(MapStyleModel.DEFAULT_STYLE)) {
mapController.fireMapChanged(new MapChangeEvent(this, node.getMap(), MapStyle.MAP_STYLES, null, null));
}
}
});
final JScrollPane styleScrollPane = new JScrollPane(styleEditorPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
UITools.setScrollbarIncrement(styleScrollPane);
// styleEditorPanel.setPreferredSize(new Dimension(200, 200));
userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, styleScrollPane);
modeController.addExtension(MUIFactory.class, new MUIFactory());
final Set<String> emptySet = Collections.emptySet();
modeController.updateMenus("/xml/stylemodemenu.xml", emptySet);
this.modeController = null;
return controller;
}
use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.
the class HeadlessMModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
IconController.install(new MIconController(modeController));
new ProgressFactory().installActions(modeController);
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
final MTextController textController = new MTextController(modeController);
TextController.install(textController);
LinkController.install(new MLinkController());
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
new RevisionPlugin();
FoldingController.install(new FoldingController());
}
use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.
the class AddOnInstallerPanel method createInstallActionListener.
private ActionListener createInstallActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Controller controller = Controller.getCurrentController();
try {
LogUtils.info("installing add-on from " + urlField.getText());
controller.getViewController().setWaitingCursor(true);
final URL url = toURL(urlField.getText());
setStatusInfo(getText("status.installing"));
final ModeController modeController = controller.getModeController(MModeController.MODENAME);
final MFileManager fileManager = (MFileManager) MFileManager.getController(modeController);
MapModel newMap = new MMapModel();
if (!fileManager.loadCatchExceptions(url, newMap)) {
LogUtils.warn("can not load " + url);
return;
}
controller.getModeController().getMapController().fireMapCreated(newMap);
AddOnProperties addOn = (AddOnProperties) ScriptingEngine.executeScript(newMap.getRootNode(), getInstallScriptSource(), ScriptingPermissions.getPermissiveScriptingPermissions());
if (addOn != null) {
setStatusInfo(getText("status.success", addOn.getName()));
AddOnsController.getController().registerInstalledAddOn(addOn);
final ManageAddOnsPanel managementPanel = addOn.isTheme() ? manageThemesPanel : manageAddOnsPanel;
managementPanel.getTableModel().addAddOn(addOn);
urlField.setText("");
((JTabbedPane) getParent()).setSelectedComponent(managementPanel);
selectLastAddOn(managementPanel);
}
} catch (Exception ex) {
UITools.errorMessage(getText("error", ex.toString()));
} finally {
controller.getViewController().setWaitingCursor(false);
}
}
private String getInstallScriptSource() throws IOException {
final ResourceController resourceController = ResourceController.getResourceController();
final File scriptDir = new File(resourceController.getInstallationBaseDir(), "scripts");
final File installScript = new File(scriptDir, "installScriptAddOn.groovy");
if (!installScript.exists())
throw new RuntimeException("internal error: installer not found at " + installScript);
return FileUtils.slurpFile(installScript);
}
private URL toURL(String urlText) throws MalformedURLException {
try {
return new URL(urlText);
} catch (Exception e2) {
return new File(urlText).toURI().toURL();
}
}
};
}
use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.
the class MMapController method newMap.
/**
*@throws XMLException
* @deprecated -- use MMapIO
*/
@Deprecated
@Override
public boolean newMap(URL url) throws FileNotFoundException, IOException, URISyntaxException, XMLException {
// load as documentation map if necessary
if (getMModeController().containsExtension(DocuMapAttribute.class)) {
return newDocumentationMap(url);
}
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
if (mapViewManager.tryToChangeToMapView(url))
return false;
if (AddOnsController.getController().installIfAppropriate(url))
return false;
URL alternativeURL = null;
try {
final File file = Compat.urlToFile(url);
if (file == null) {
alternativeURL = url;
} else {
if (file.exists()) {
final MFileManager fileManager = MFileManager.getController(getMModeController());
File alternativeFile = fileManager.getAlternativeFile(file, AlternativeFileMode.AUTOSAVE);
if (alternativeFile != null) {
alternativeURL = Compat.fileToUrl(alternativeFile);
} else
return false;
} else {
alternativeURL = url;
}
}
} catch (MalformedURLException e) {
} catch (URISyntaxException e) {
}
if (alternativeURL == null)
return false;
Controller.getCurrentController().getViewController().setWaitingCursor(true);
try {
final MapModel newModel = new MMapModel();
final MFileManager fileManager = MFileManager.getController(getMModeController());
fileManager.loadAndLock(alternativeURL, newModel);
newModel.setURL(url);
newModel.setSaved(alternativeURL.equals(url));
fireMapCreated(newModel);
newMapView(newModel);
return true;
} finally {
Controller.getCurrentController().getViewController().setWaitingCursor(false);
}
}
Aggregations