mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Work on Tree
This commit is contained in:
+3
@@ -96,6 +96,9 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getEdgeSize() {
|
||||
return Math.max(5, ((JComponent)getCellRenderer()).getPreferredSize().height / 2 - 3);
|
||||
}
|
||||
|
||||
private void installCellRenderer() {
|
||||
setCellRenderer(new ColoredTreeCellRenderer() {
|
||||
|
||||
+4
@@ -36,13 +36,17 @@ public final class ComponentTreeBuilder extends AbstractTreeBuilder implements C
|
||||
|
||||
public ComponentTreeBuilder(ComponentTree tree, DesignerEditorPanel designer) {
|
||||
super(tree, (DefaultTreeModel)tree.getModel(), new TreeContentProvider(designer), null);
|
||||
|
||||
initRootNode();
|
||||
|
||||
myTreeSelectionModel = getTree().getSelectionModel();
|
||||
mySurfaceArea = designer.getSurfaceArea();
|
||||
myTreeArea = new TreeEditableArea(tree, this);
|
||||
myGlassLayer = new TreeGlassLayer(tree, designer.getToolProvider(), myTreeArea);
|
||||
|
||||
// TODO: restore expanded state
|
||||
select(mySurfaceArea.getSelection().toArray(), null);
|
||||
|
||||
addListeners();
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -184,14 +184,16 @@ public final class TreeEditableArea implements EditableArea, FeedbackTreeLayer {
|
||||
|
||||
@Override
|
||||
public void mark(RadComponent component, int feedback) {
|
||||
// TODO: INSERT_BEFORE - ensure visible up component
|
||||
// TODO: INSERT_AFTER - ensure visible down component
|
||||
|
||||
if (component != null && feedback == INSERT_SELECTION) {
|
||||
if (component != null) {
|
||||
TreePath path = getPath(component);
|
||||
myTree.scrollPathToVisible(path);
|
||||
if (!myTree.isExpanded(path)) {
|
||||
myTreeBuilder.expand(component, null);
|
||||
if (feedback == INSERT_SELECTION) {
|
||||
myTree.scrollPathToVisible(path);
|
||||
if (!myTree.isExpanded(path)) {
|
||||
myTreeBuilder.expand(component, null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myTree.scrollRowToVisible(myTree.getRowForPath(path) + (feedback == INSERT_BEFORE ? -1 : 1));
|
||||
}
|
||||
}
|
||||
myTree.mark(component, feedback);
|
||||
@@ -200,12 +202,12 @@ public final class TreeEditableArea implements EditableArea, FeedbackTreeLayer {
|
||||
@Override
|
||||
public boolean isBeforeLocation(RadComponent component, int x, int y) {
|
||||
Rectangle bounds = myTree.getPathBounds(getPath(component));
|
||||
return bounds != null && y - bounds.y < 15;
|
||||
return bounds != null && y - bounds.y < myTree.getEdgeSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAfterLocation(RadComponent component, int x, int y) {
|
||||
Rectangle bounds = myTree.getPathBounds(getPath(component));
|
||||
return bounds != null && bounds.getMaxY() - y < 15;
|
||||
return bounds != null && bounds.getMaxY() - y < myTree.getEdgeSize();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user