use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class UserInputListenerFactory method createMapActions.
private void createMapActions(final Entry mapsMenuEntry) {
final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
final ViewController viewController = Controller.getCurrentController().getViewController();
final List<? extends Component> mapViewVector = viewController.getMapViewVector();
if (mapViewVector == null) {
return;
}
EntryAccessor entryAccessor = new EntryAccessor();
for (final Component mapView : mapViewVector) {
final String displayName = mapView.getName();
Entry actionEntry = new Entry();
final MapsMenuAction action = new MapsMenuAction(displayName);
actionEntry.setName(action.getKey());
modeController.addActionIfNotAlreadySet(action);
entryAccessor.setAction(actionEntry, action);
final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
if (currentMapView != null) {
if (mapView == currentMapView) {
actionEntry.setAttribute("selected", true);
}
}
mapsMenuEntry.addChild(actionEntry);
}
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class ImportFolderStructureAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogTitle(TextUtils.getText("select_folder_for_importing"));
final ViewController viewController = Controller.getCurrentController().getViewController();
final int returnVal = chooser.showOpenDialog(viewController.getContentPane());
if (returnVal == JFileChooser.APPROVE_OPTION) {
final File folder = chooser.getSelectedFile();
viewController.out("Importing folder structure ...");
try {
importFolderStructure(folder, Controller.getCurrentModeController().getMapController().getSelectedNode(), /*redisplay=*/
true);
} catch (final Exception ex) {
LogUtils.severe(ex);
}
viewController.out("Folder structure imported.");
}
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class NodeProxy method setStatusInfo.
private void setStatusInfo(String text) {
final ViewController viewController = Controller.getCurrentController().getViewController();
viewController.out(text);
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class ControllerProxy method setStatusInfo.
public void setStatusInfo(final String info) {
final ViewController viewController = getViewController();
viewController.out(info);
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class MTextController method setImageByFileChooser.
public void setImageByFileChooser() {
boolean picturesAmongSelecteds = false;
final ModeController modeController = Controller.getCurrentModeController();
for (final NodeModel node : modeController.getMapController().getSelectedNodes()) {
final URI link = NodeLinks.getLink(node);
if (link != null) {
final String linkString = link.toString();
final String lowerCase = linkString.toLowerCase();
if (lowerCase.endsWith(".png") || lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") || lowerCase.endsWith(".gif")) {
picturesAmongSelecteds = true;
final String encodedLinkString = HtmlUtils.unicodeToHTMLUnicodeEntity(linkString);
final String strText = "<html><img src=\"" + encodedLinkString + "\">";
((MLinkController) LinkController.getController()).setLink(node, (URI) null, LinkController.LINK_ABSOLUTE);
setNodeText(node, strText);
}
}
}
if (picturesAmongSelecteds) {
return;
}
final Controller controller = modeController.getController();
final ViewController viewController = controller.getViewController();
final NodeModel selectedNode = modeController.getMapController().getSelectedNode();
final MapModel map = selectedNode.getMap();
final File file = map.getFile();
if (file == null && LinkController.getLinkType() == LinkController.LINK_RELATIVE_TO_MINDMAP) {
JOptionPane.showMessageDialog(viewController.getContentPane(), TextUtils.getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
return;
}
final ExampleFileFilter filter = new ExampleFileFilter();
filter.addExtension("jpg");
filter.addExtension("jpeg");
filter.addExtension("png");
filter.addExtension("gif");
filter.setDescription(TextUtils.getText("bitmaps"));
final UrlManager urlManager = (UrlManager) modeController.getExtension(UrlManager.class);
final JFileChooser chooser = urlManager.getFileChooser(null, false);
chooser.setFileFilter(filter);
chooser.setAcceptAllFileFilterUsed(false);
chooser.setAccessory(new BitmapImagePreview(chooser));
final int returnVal = chooser.showOpenDialog(viewController.getContentPane());
if (returnVal != JFileChooser.APPROVE_OPTION) {
return;
}
final File input = chooser.getSelectedFile();
URI uri = input.toURI();
if (uri == null) {
return;
}
// bad hack: try to interpret file as http link
if (!input.exists()) {
uri = LinkController.toRelativeURI(map.getFile(), input, LinkController.LINK_RELATIVE_TO_MINDMAP);
if (uri == null || !"http".equals(uri.getScheme())) {
UITools.errorMessage(TextUtils.format("file_not_found", input.toString()));
return;
}
} else if (LinkController.getLinkType() != LinkController.LINK_ABSOLUTE) {
uri = LinkController.toLinkTypeDependantURI(map.getFile(), input);
}
String uriString = uri.toString();
if (uriString.startsWith("http:/")) {
uriString = "http://" + uriString.substring("http:/".length());
}
final String strText = "<html><img src=\"" + uriString + "\">";
setNodeText(selectedNode, strText);
}
Aggregations