Search in sources :

Example 1 with EditNodeBase

use of org.freeplane.features.text.mindmapmode.EditNodeBase 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);
}
Also used : MainView(org.freeplane.view.swing.map.MainView) EditNodeBase(org.freeplane.features.text.mindmapmode.EditNodeBase) Color(java.awt.Color) Dimension(java.awt.Dimension) EditNodeWYSIWYG(org.freeplane.features.text.mindmapmode.EditNodeWYSIWYG) NodeView(org.freeplane.view.swing.map.NodeView) Font(java.awt.Font) MapViewController(org.freeplane.view.swing.map.MapViewController) ViewController(org.freeplane.features.ui.ViewController) MapView(org.freeplane.view.swing.map.MapView)

Example 2 with EditNodeBase

use of org.freeplane.features.text.mindmapmode.EditNodeBase in project freeplane by freeplane.

the class AttributeTable method getCellEditor.

@SuppressWarnings("serial")
public TableCellEditor getCellEditor(final int row, final int col, EventObject e) {
    if (dce != null) {
        dce.stopCellEditing();
    }
    if (col == 1) {
        final MTextController textController = (MTextController) TextController.getController();
        if (e instanceof KeyEvent) {
            final KeyEvent kev = (KeyEvent) e;
            textController.getEventQueue().setFirstEvent(kev);
        }
        final IAttributeTableModel model = (IAttributeTableModel) getModel();
        final String text = getValueForEdit(row, col);
        final DialogTableCellEditor dialogTableCellEditor = new DialogTableCellEditor();
        EditNodeBase base = textController.getEditNodeBase(model.getNode(), text, dialogTableCellEditor.getEditControl(), false);
        if (base != null) {
            dialogTableCellEditor.setEditBase(base);
            return dialogTableCellEditor;
        }
    }
    final JComboBox comboBox;
    if (dce == null) {
        comboBox = new JComboBox();
        comboBox.addFocusListener(AttributeTable.focusListener);
        comboBox.getEditor().getEditorComponent().addFocusListener(AttributeTable.focusListener);
        comboBox.setRenderer(new TypedListCellRenderer());
        dce = new DefaultCellEditor(comboBox) {

            public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) {
                return super.getTableCellEditorComponent(table, ((AttributeTable) table).getValueForEdit(row, col), isSelected, row, col);
            }
        };
        dce.setClickCountToStart(CLICK_COUNT_TO_START);
    }
    return dce;
}
Also used : JComboBox(javax.swing.JComboBox) EditNodeBase(org.freeplane.features.text.mindmapmode.EditNodeBase) DefaultCellEditor(javax.swing.DefaultCellEditor) KeyEvent(java.awt.event.KeyEvent) TypedListCellRenderer(org.freeplane.core.ui.components.TypedListCellRenderer) JTable(javax.swing.JTable) IAttributeTableModel(org.freeplane.features.attribute.IAttributeTableModel) EventObject(java.util.EventObject) IFormattedObject(org.freeplane.features.format.IFormattedObject) MTextController(org.freeplane.features.text.mindmapmode.MTextController) EditedComponent(org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Aggregations

EditNodeBase (org.freeplane.features.text.mindmapmode.EditNodeBase)2 Color (java.awt.Color)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 KeyEvent (java.awt.event.KeyEvent)1 EventObject (java.util.EventObject)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 JComboBox (javax.swing.JComboBox)1 JComponent (javax.swing.JComponent)1 JTable (javax.swing.JTable)1 TypedListCellRenderer (org.freeplane.core.ui.components.TypedListCellRenderer)1 IAttributeTableModel (org.freeplane.features.attribute.IAttributeTableModel)1 IFormattedObject (org.freeplane.features.format.IFormattedObject)1 EditedComponent (org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent)1 EditNodeWYSIWYG (org.freeplane.features.text.mindmapmode.EditNodeWYSIWYG)1 MTextController (org.freeplane.features.text.mindmapmode.MTextController)1 ViewController (org.freeplane.features.ui.ViewController)1 MainView (org.freeplane.view.swing.map.MainView)1 MapView (org.freeplane.view.swing.map.MapView)1