use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class MapViewScrollPane method setScrollbarsVisiblilty.
private void setScrollbarsVisiblilty() {
final ViewController viewController = Controller.getCurrentController().getViewController();
boolean areScrollbarsVisible = viewController.areScrollbarsVisible();
setHorizontalScrollBarPolicy(areScrollbarsVisible ? JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS : JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
setVerticalScrollBarPolicy(areScrollbarsVisible ? JScrollPane.VERTICAL_SCROLLBAR_ALWAYS : JScrollPane.VERTICAL_SCROLLBAR_NEVER);
final boolean isFullScreenEnabled = !UITools.getCurrentFrame().isResizable();
setBorder(isFullScreenEnabled && !areScrollbarsVisible ? null : defaultBorder);
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class EditStylesAction method init.
private void init() {
this.mainController = Controller.getCurrentController();
if (dialog != null) {
Controller.setCurrentController((Controller) dialog.getRootPane().getClientProperty(Controller.class));
return;
}
dialog = new JDialog(UITools.getCurrentFrame());
final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
windowConfigurationStorage.restoreDialogPositions(dialog);
dialog.setModal(true);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
getModeController().tryToCloseDialog();
}
});
Controller styleDialogController = SModeControllerFactory.getInstance().createController(dialog);
modeController = (SModeController) styleDialogController.getModeController();
final ViewController viewController = styleDialogController.getViewController();
viewController.init(styleDialogController);
dialog.addComponentListener(new ComponentAdapter() {
@Override
public void componentHidden(final ComponentEvent e) {
final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
windowConfigurationStorage.storeDialogPositions(dialog);
final IMapViewManager mapViewManager = modeController.getController().getMapViewManager();
final MapModel map = mapViewManager.getModel();
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
modeController.getMapController().closeWithoutSaving(map);
Controller.setCurrentController(mainController);
super.componentHidden(e);
mainController.getMapViewManager().changeToMapView(currentMapView);
currentMapView = null;
switch(modeController.getStatus()) {
case JOptionPane.OK_OPTION:
if (undoHandler.canUndo()) {
commit();
break;
}
// $FALL-THROUGH$
case JOptionPane.CANCEL_OPTION:
rollback();
}
}
});
}
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 IconSelectionPlugin method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
final Controller controller = Controller.getCurrentController();
final MapModel map = controller.getMap();
final IconRegistry iconRegistry = map.getIconRegistry();
final ListModel usedIcons = iconRegistry.getIconsAsListModel();
for (int i = 0; i < usedIcons.getSize(); i++) {
final Object icon = usedIcons.getElementAt(i);
if (icon instanceof MindIcon) {
actions.add(new IconAction((MindIcon) icon));
}
}
final MIconController mIconController = (MIconController) IconController.getController();
for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
final ViewController viewController = controller.getViewController();
final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(viewController.getJFrame(), actions);
final NodeModel selected = controller.getSelection().getSelected();
controller.getMapViewManager().scrollNodeToVisible(selected);
selectionDialog.pack();
UITools.setDialogLocationRelativeTo(selectionDialog, selected);
selectionDialog.setModal(true);
selectionDialog.show();
final int result = selectionDialog.getResult();
if (result >= 0) {
final Action action = (Action) actions.get(result);
action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
}
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class MTextController method edit.
public void edit(final NodeModel nodeModel, final NodeModel prevSelectedModel, final boolean isNewNode, final boolean parentFolded, final boolean editLong) {
if (nodeModel == null || mCurrentEditDialog != null) {
return;
}
final Controller controller = Controller.getCurrentController();
if (controller.getMap() != nodeModel.getMap()) {
return;
}
final IMapViewManager viewController = controller.getMapViewManager();
final Component map = viewController.getMapViewComponent();
map.validate();
map.invalidate();
final Component node = viewController.getComponent(nodeModel);
if (node == null) {
return;
}
node.requestFocus();
stopEditing();
if (isNewNode && !eventQueue.isActive() && !ResourceController.getResourceController().getBooleanProperty("display_inline_editor_for_all_new_nodes")) {
keyEventDispatcher = new EditEventDispatcher(Controller.getCurrentModeController(), nodeModel, prevSelectedModel, isNewNode, parentFolded, editLong);
keyEventDispatcher.install();
return;
}
;
final IEditControl editControl = new IEditControl() {
public void cancel() {
if (isNewNode && nodeModel.getMap().equals(controller.getMap())) {
if (nodeModel.getParentNode() != null) {
controller.getSelection().selectAsTheOnlyOneSelected(nodeModel);
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
modeController.undo();
modeController.resetRedo();
}
final MapController mapController = Controller.getCurrentModeController().getMapController();
mapController.select(prevSelectedModel);
if (parentFolded) {
mapController.setFolded(prevSelectedModel, true);
}
}
stop();
}
private void stop() {
Controller.getCurrentModeController().setBlocked(false);
viewController.obtainFocusForSelected();
mCurrentEditDialog = null;
}
public void ok(final String text) {
String processedText = makePlainIfNoFormattingFound(text);
setGuessedNodeObject(nodeModel, processedText);
stop();
}
public void split(final String newText, final int position) {
splitNode(nodeModel, position, newText);
viewController.obtainFocusForSelected();
stop();
}
public boolean canSplit() {
return true;
}
public EditedComponent getEditType() {
return EditedComponent.TEXT;
}
};
mCurrentEditDialog = createEditor(nodeModel, editControl, nodeModel.getText(), isNewNode, editLong, true);
final JFrame frame = controller.getViewController().getJFrame();
mCurrentEditDialog.show(frame);
}
Aggregations