IDEA-19061 Integrate the Rearranger-plugin into core-IDE

Performing tree modification via the tree model (the goal is to propagate the modification events to the tree ui)
This commit is contained in:
Denis.Zhdanov
2012-08-20 22:26:09 +04:00
parent 9899440429
commit f1679987b8
5 changed files with 68 additions and 36 deletions
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.Nullable
import org.junit.Test
import javax.swing.tree.DefaultMutableTreeNode
import javax.swing.tree.DefaultTreeModel
import static org.junit.Assert.assertEquals
/**
@@ -50,7 +51,7 @@ four = '4'()
'1' {
'4'()
}
def rowMappings = ArrangementConfigUtil.replace(one, four, replacement)
def rowMappings = doReplace(initial, one, four, replacement)
// Check
def expected = new TreeNodeBuilder().
@@ -108,8 +109,8 @@ four = '4'()
}
'5'()
}
ArrangementConfigUtil.insert(initial, 0, toAdd)
doInsert(initial, 0, toAdd)
assertNodesEqual(expected, initial)
}
@@ -145,7 +146,7 @@ four = '4'()
'5'()
}
ArrangementConfigUtil.insert(initial, 1, toAdd)
doInsert(initial, 1, toAdd)
assertNodesEqual(expected, initial)
}
@@ -181,7 +182,7 @@ four = '4'()
'5'()
}
ArrangementConfigUtil.insert(initial, 2, toAdd)
doInsert(initial, 2, toAdd)
assertNodesEqual(expected, initial)
}
@@ -221,10 +222,18 @@ four = '4'()
}
}
ArrangementConfigUtil.insert(initial, 3, toAdd)
doInsert(initial, 3, toAdd)
assertNodesEqual(expected, initial)
}
private static def doReplace(initial, from, to, replacement) {
ArrangementConfigUtil.replace(from, to, replacement, new DefaultTreeModel(initial))
}
private static def doInsert(parent, i, child) {
ArrangementConfigUtil.insert(parent, i, child, new DefaultTreeModel(ArrangementConfigUtil.getRoot(parent)))
}
private static void assertNodesEqual(@NotNull DefaultMutableTreeNode expected, @NotNull DefaultMutableTreeNode actual) {
assertEquals(expected.userObject, actual.userObject)
assertEquals(expected.childCount, actual.childCount)