use of org.freeplane.features.clipboard.ClipboardController in project freeplane by freeplane.
the class MMapController method convertCloneToNode.
private void convertCloneToNode(final NodeModel node) {
final MModeController mModeController = getMModeController();
final ClipboardController clipboardController = mModeController.getExtension(ClipboardController.class);
final NodeModel duplicate = clipboardController.duplicate(node, false);
IActor converter = new IActor() {
@Override
public void act() {
node.swapData(duplicate);
nodeChanged(node);
}
@Override
public void undo() {
node.swapData(duplicate);
nodeChanged(node);
}
@Override
public String getDescription() {
return "convertClonesToIndependentNodes";
}
};
final boolean shouldConvertChildNodes = node.subtreeClones().size() > 1;
mModeController.execute(converter, node.getMap());
if (shouldConvertChildNodes)
for (NodeModel child : node.getChildren()) convertCloneToNode(child);
}
use of org.freeplane.features.clipboard.ClipboardController in project freeplane by freeplane.
the class FModeControllerFactory method createModeController.
public static FModeController createModeController() {
final Controller controller = Controller.getCurrentController();
modeController = new FModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new FMapController(modeController);
UrlManager.install(new UrlManager());
MapIO.install(modeController);
new IconController(modeController).install(modeController);
NodeStyleController.install(new NodeStyleController(modeController));
EdgeController.install(new EdgeController(modeController));
new TextController(modeController).install(modeController);
LinkController.install(new LinkController(modeController));
CloudController.install(new CloudController(modeController));
ClipboardController.install(new ClipboardController());
LocationController.install(new LocationController());
LogicalStyleController.install(new LogicalStyleController(modeController));
MapStyle.install(true);
NodeStyleController.getController().addShapeGetter(new Integer(0), new IPropertyHandler<ShapeConfigurationModel, NodeModel>() {
public ShapeConfigurationModel getProperty(final NodeModel node, final ShapeConfigurationModel currentValue) {
return ShapeConfigurationModel.FORK;
}
});
modeController.addAction(new CenterAction());
modeController.addAction(new OpenPathAction());
userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getCurrentFilterController().getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
NodeHistory.install(modeController);
return modeController;
}
use of org.freeplane.features.clipboard.ClipboardController in project freeplane by freeplane.
the class SetLinkByTextFieldAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
final NodeModel selectedNode = modeController.getMapController().getSelectedNode();
String linkAsString = NodeLinks.getLinkAsString(selectedNode);
if (Compat.isWindowsOS() && linkAsString != null && linkAsString.startsWith("smb:")) {
final URI link = NodeLinks.getValidLink(selectedNode);
linkAsString = Compat.smbUri2unc(link);
}
if (linkAsString == null || "".equals(linkAsString)) {
linkAsString = "http://";
// if clipboard contains a valid uri use it
ClipboardController clipboardController = modeController.getExtension(ClipboardController.class);
Transferable t = clipboardController.getClipboardContents();
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
final String plainTextFromClipboard = t.getTransferData(DataFlavor.stringFlavor).toString().trim();
new URI(plainTextFromClipboard);
linkAsString = plainTextFromClipboard;
} catch (final Exception ex) {
}
}
}
final String inputValue = UITools.showInputDialog(Controller.getCurrentController().getSelection().getSelected(), TextUtils.getText("edit_link_manually"), linkAsString);
if (inputValue != null && !inputValue.matches("\\w+://")) {
final MLinkController linkController = (MLinkController) MLinkController.getController();
if (inputValue.equals("")) {
linkController.setLink(selectedNode, (URI) null, LinkController.LINK_ABSOLUTE);
return;
}
try {
final URI link = LinkController.createURI(inputValue.trim());
linkController.setLink(selectedNode, link, LinkController.LINK_ABSOLUTE);
} catch (final URISyntaxException e1) {
LogUtils.warn(e1);
UITools.errorMessage(TextUtils.format("invalid_uri", inputValue));
return;
}
}
}
use of org.freeplane.features.clipboard.ClipboardController in project freeplane by freeplane.
the class CutAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController mMindMapController = Controller.getCurrentModeController();
final Controller controller = Controller.getCurrentController();
final NodeModel root = controller.getMap().getRootNode();
if (controller.getSelection().isSelected(root)) {
UITools.errorMessage(TextUtils.getText("cannot_delete_root"));
return;
}
final int showResult = OptionalDontShowMeAgainDialog.show("really_cut_node", "confirmation", MClipboardController.RESOURCES_CUT_NODES_WITHOUT_QUESTION, OptionalDontShowMeAgainDialog.ONLY_OK_SELECTION_IS_STORED);
if (showResult != JOptionPane.OK_OPTION) {
return;
}
final MClipboardController clipboardController = (MClipboardController) mMindMapController.getExtension(ClipboardController.class);
clipboardController.cut(controller.getSelection().getSortedSelection(true));
controller.getMapViewManager().obtainFocusForSelected();
}
use of org.freeplane.features.clipboard.ClipboardController in project freeplane by freeplane.
the class BModeControllerFactory method createModeController.
public static BModeController createModeController() {
final Controller controller = Controller.getCurrentController();
modeController = new BModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MapController(modeController);
new IconController(modeController).install(modeController);
UrlManager.install(new UrlManager());
MapIO.install(modeController);
AttributeController.install(new AttributeController(modeController));
NodeStyleController.install(new NodeStyleController(modeController));
EdgeController.install(new EdgeController(modeController));
CloudController.install(new CloudController(modeController));
NoteController.install(new NoteController());
new TextController(modeController).install(modeController);
LinkController.install(new LinkController(modeController));
LogicalStyleController.install(new LogicalStyleController(modeController));
try {
ClipboardController.install(new ClipboardController());
} catch (final AccessControlException e) {
LogUtils.warn("can not access system clipboard, clipboard controller disabled");
}
LocationController.install(new LocationController());
SummaryNode.install();
FreeNode.install();
MapStyle.install(true);
final BToolbarContributor toolbarContributor = new BToolbarContributor();
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_url", toolbarContributor);
controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
FoldingController.install(new FoldingController());
new ViewerController();
EncryptionController.install(new EncryptionController(modeController));
new AutomaticLayoutController();
return modeController;
}
Aggregations