use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class MMapViewController method createEditor.
public EditNodeBase createEditor(final NodeModel node, final EditNodeBase.IEditControl editControl, String text, final boolean editLong) {
final String htmlEditingOption = ResourceController.getResourceController().getProperty("html_editing_option");
final boolean editInternalWysiwyg = editLong && StringUtils.equals(htmlEditingOption, "internal-wysiwyg");
final boolean editExternal = editLong && StringUtils.equals(htmlEditingOption, "external");
if (!HtmlUtils.isHtmlNode(text)) {
text = HtmlUtils.plainToHTML(text);
}
if (editInternalWysiwyg) {
final EditNodeWYSIWYG editNodeWYSIWYG = new EditNodeWYSIWYG(node, text, editControl, true);
final ViewController viewController = Controller.getCurrentModeController().getController().getViewController();
if (EditedComponent.TEXT.equals(editControl.getEditType())) {
int preferredHeight = (int) (getComponent(node).getHeight() * 1.2);
preferredHeight = Math.max(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_height")));
preferredHeight = Math.min(preferredHeight, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_height")));
int preferredWidth = (int) (getComponent(node).getWidth() * 1.2);
preferredWidth = Math.max(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__min_default_window_width")));
preferredWidth = Math.min(preferredWidth, Integer.parseInt(ResourceController.getResourceController().getProperty("el__max_default_window_width")));
final Dimension preferredSize = new Dimension(preferredWidth, preferredHeight);
editNodeWYSIWYG.setPreferredSize(preferredSize);
}
final MainView mainView = (MainView) getComponent(node);
final NodeView nodeView = mainView.getNodeView();
if (EditedComponent.TEXT.equals(editControl.getEditType())) {
final Font font = getFont(node);
editNodeWYSIWYG.setTitle("edit_long_node");
editNodeWYSIWYG.setFont(font);
final Color nodeTextColor = getTextColor(node);
editNodeWYSIWYG.setTextColor(nodeTextColor);
editNodeWYSIWYG.setBackground(nodeView.getTextBackground());
} else if (EditedComponent.DETAIL.equals(editControl.getEditType())) {
final MapView map = nodeView.getMap();
editNodeWYSIWYG.setTitle("edit_details");
editNodeWYSIWYG.setFont(map.getDetailFont());
editNodeWYSIWYG.setTextColor(map.getDetailForeground());
editNodeWYSIWYG.setBackground(nodeView.getDetailBackground());
} else if (EditedComponent.NOTE.equals(editControl.getEditType())) {
final MapView map = nodeView.getMap();
editNodeWYSIWYG.setTitle("edit_note");
editNodeWYSIWYG.setFont(map.getDefaultNoteFont());
editNodeWYSIWYG.setBackground(Color.WHITE);
}
return editNodeWYSIWYG;
} else if (editExternal) {
return new EditNodeExternalApplication(node, text, editControl);
} else {
final EditNodeBase textfield = createEditor(node, editControl.getEditType(), text, editControl);
if (textfield != null)
return textfield;
}
return createEditor(node, editControl, text, true);
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class AEditStylesAction method init.
protected void init() {
this.controller = Controller.getCurrentController();
if (dialog != null) {
Controller.setCurrentController((Controller) dialog.getRootPane().getClientProperty(Controller.class));
return;
}
dialog = new JDialog(Controller.getCurrentController().getViewController().getJFrame());
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 controller = SModeControllerFactory.getInstance().createController(dialog);
modeController = (SModeController) controller.getModeController();
final ViewController viewController = controller.getViewController();
viewController.init(controller);
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);
mapViewManager.close(true);
Controller.setCurrentController(AEditStylesAction.this.controller);
super.componentHidden(e);
switch(modeController.getStatus()) {
case JOptionPane.OK_OPTION:
if (undoHandler.canUndo()) {
commit();
break;
}
case JOptionPane.CANCEL_OPTION:
rollback();
}
}
});
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class SetNoteWindowPosition method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ResourceController resourceController = ResourceController.getResourceController();
resourceController.setProperty("note_location", position);
final ViewController viewController = Controller.getCurrentModeController().getController().getViewController();
viewController.changeNoteWindowLocation();
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class UndoHandler method startActionFrame.
private void startActionFrame() {
if (actionFrameStarted == false) {
final ViewController viewController = Controller.getCurrentController().getViewController();
if (viewController.isDispatchThread()) {
actionFrameStarted = true;
viewController.invokeLater(new Runnable() {
public void run() {
actionFrameStarted = false;
}
});
}
}
}
use of org.freeplane.features.ui.ViewController in project freeplane by freeplane.
the class AttributeTable method setSelectedCellTypeInfo.
private void setSelectedCellTypeInfo() {
final int r = getSelectedRow();
final int c = getSelectedColumn();
if (r >= 0 && c >= 0) {
final Object value = getValueAt(r, c);
final ViewController viewController = Controller.getCurrentController().getViewController();
viewController.addObjectTypeInfo(value);
}
}
Aggregations