diff --git a/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/AttributeTable.java b/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/AttributeTable.java index 58f15bc761..5edf120aaa 100644 --- a/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/AttributeTable.java +++ b/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/AttributeTable.java @@ -100,9 +100,9 @@ import org.freeplane.features.styles.MapStyleModel; import org.freeplane.features.text.TextController; import org.freeplane.features.text.mindmapmode.EditNodeBase; +import org.freeplane.features.text.mindmapmode.MTextController; import org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent; import org.freeplane.features.text.mindmapmode.EditNodeBase.IEditControl; -import org.freeplane.features.text.mindmapmode.MTextController; import org.freeplane.features.ui.ViewController; import org.freeplane.view.swing.map.FreeplaneTooltip; import org.freeplane.view.swing.map.MapView; @@ -591,16 +591,29 @@ float getZoom() { /** */ public void insertRow(final int row) { + int actuallyInsertedRow = row; if (getModel() instanceof ExtendedAttributeTableModelDecorator) { final ExtendedAttributeTableModelDecorator model = (ExtendedAttributeTableModelDecorator) getModel(); - if (isEditing() && getCellEditor() != null && !getCellEditor().stopCellEditing()) { - return; - } - model.insertRow(row); - changeSelection(row, 0, false, false); - if (editCellAt(row, 0)) { - getEditorComponent().requestFocusInWindow(); + if (isEditing()) { + final int editingRow = getEditingRow(); + final int rowCount = getRowCount(); + if (!getCellEditor().stopCellEditing()) { + return; + } + final int updatedRowCount = getRowCount(); + if(updatedRowCount < rowCount && row >= editingRow) { + actuallyInsertedRow--; + } } + insertRow(model, actuallyInsertedRow); + } + } + + private void insertRow(final ExtendedAttributeTableModelDecorator model, final int row) { + model.insertRow(row); + changeSelection(row, 0, false, false); + if (editCellAt(row, 0)) { + getEditorComponent().requestFocusInWindow(); } } @@ -793,7 +806,6 @@ public void setOptimalColumnWidths() { Component comp = null; int maxCellWidth = 2 * (int) (Math.ceil(getFont().getSize2D() / UITools.FONT_SCALE_FACTOR + EXTRA_HEIGHT)); int rowCount = getRowCount(); - boolean isInsideNodeView = getNodeViewAncestor() != null; if(rowCount > 0) { for (int col = 0; col < 2; col++) { for (int row = 0; row < rowCount; row++) { diff --git a/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/ExtendedAttributeTableModelDecorator.java b/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/ExtendedAttributeTableModelDecorator.java index bd55fdb2ce..da7fe22eb9 100644 --- a/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/ExtendedAttributeTableModelDecorator.java +++ b/freeplane/src/main/java/org/freeplane/view/swing/map/attribute/ExtendedAttributeTableModelDecorator.java @@ -23,6 +23,7 @@ import javax.swing.event.TableModelEvent; import org.freeplane.features.attribute.Attribute; +import org.freeplane.features.attribute.NodeAttributeTableModel; /** * @author Dimitry Polivaev @@ -72,13 +73,15 @@ public int getRowCount() { @Override public Object getValueAt(final int row, final int col) { - if (row < newRow) { - return getNodeAttributeModel().getValueAt(row, col); - } - if (row == newRow) { + final NodeAttributeTableModel attributes = getNodeAttributeModel(); + if (row == newRow || row >= attributes.getRowCount()) { return ""; } - return getNodeAttributeModel().getValueAt(row - 1, col); + else if (row < newRow) { + return attributes.getValueAt(row, col); + } + else + return attributes.getValueAt(row - 1, col); } public void insertRow(final int index) {