Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14270dc

Browse files
AlexanderYeremeyevAlexanderYeremeyev
authored andcommitted
extract navigatorTree from navigator
1 parent abcdd7e commit 14270dc

File tree

2 files changed

+53
-44
lines changed

2 files changed

+53
-44
lines changed

soapui/src/main/java/com/eviware/soapui/ui/navigator/Navigator.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -117,50 +117,6 @@ private Component buildToolbar() {
117117
return toolbar;
118118
}
119119

120-
private static class NavigatorTree extends JTree implements Autoscroll {
121-
public NavigatorTree(SoapUITreeModel treeModel) {
122-
super(treeModel);
123-
}
124-
125-
private static final int AUTOSCROLL_MARGIN = 12;
126-
127-
public void autoscroll(Point pt) {
128-
// Figure out which row we�re on.
129-
int nRow = getRowForLocation(pt.x, pt.y);
130-
131-
// If we are not on a row then ignore this autoscroll request
132-
if (nRow < 0) {
133-
return;
134-
}
135-
136-
Rectangle raOuter = getBounds();
137-
// Now decide if the row is at the top of the screen or at the
138-
// bottom. We do this to make the previous row (or the next
139-
// row) visible as appropriate. If we�re at the absolute top or
140-
// bottom, just return the first or last row respectively.
141-
142-
nRow = (pt.y + raOuter.y <= AUTOSCROLL_MARGIN) // Is row at top of
143-
// screen?
144-
? (nRow <= 0 ? 0 : nRow - 1) // Yes, scroll up one row
145-
: (nRow < getRowCount() - 1 ? nRow + 1 : nRow); // No,
146-
// scroll
147-
// down one
148-
// row
149-
150-
scrollRowToVisible(nRow);
151-
}
152-
153-
// Calculate the insets for the *JTREE*, not the viewport
154-
// the tree is in. This makes it a bit messy.
155-
public Insets getAutoscrollInsets() {
156-
Rectangle raOuter = getBounds();
157-
Rectangle raInner = getParent().getBounds();
158-
return new Insets(raInner.y - raOuter.y + AUTOSCROLL_MARGIN, raInner.x - raOuter.x + AUTOSCROLL_MARGIN,
159-
raOuter.height - raInner.height - raInner.y + raOuter.y + AUTOSCROLL_MARGIN, raOuter.width
160-
- raInner.width - raInner.x + raOuter.x + AUTOSCROLL_MARGIN);
161-
}
162-
}
163-
164120
public Project getCurrentProject() {
165121
TreePath path = mainTree.getSelectionPath();
166122
if (path == null) {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.eviware.soapui.ui.navigator;
2+
3+
import com.eviware.soapui.model.tree.SoapUITreeModel;
4+
5+
import javax.swing.JTree;
6+
import java.awt.Insets;
7+
import java.awt.Point;
8+
import java.awt.Rectangle;
9+
import java.awt.dnd.Autoscroll;
10+
11+
class NavigatorTree extends JTree implements Autoscroll {
12+
public NavigatorTree(SoapUITreeModel treeModel) {
13+
super(treeModel);
14+
}
15+
16+
private static final int AUTOSCROLL_MARGIN = 12;
17+
18+
public void autoscroll(Point pt) {
19+
// Figure out which row we�re on.
20+
int nRow = getRowForLocation(pt.x, pt.y);
21+
22+
// If we are not on a row then ignore this autoscroll request
23+
if (nRow < 0) {
24+
return;
25+
}
26+
27+
Rectangle raOuter = getBounds();
28+
// Now decide if the row is at the top of the screen or at the
29+
// bottom. We do this to make the previous row (or the next
30+
// row) visible as appropriate. If we�re at the absolute top or
31+
// bottom, just return the first or last row respectively.
32+
33+
nRow = (pt.y + raOuter.y <= AUTOSCROLL_MARGIN) // Is row at top of
34+
// screen?
35+
? (nRow <= 0 ? 0 : nRow - 1) // Yes, scroll up one row
36+
: (nRow < getRowCount() - 1 ? nRow + 1 : nRow); // No,
37+
// scroll
38+
// down one
39+
// row
40+
41+
scrollRowToVisible(nRow);
42+
}
43+
44+
// Calculate the insets for the *JTREE*, not the viewport
45+
// the tree is in. This makes it a bit messy.
46+
public Insets getAutoscrollInsets() {
47+
Rectangle raOuter = getBounds();
48+
Rectangle raInner = getParent().getBounds();
49+
return new Insets(raInner.y - raOuter.y + AUTOSCROLL_MARGIN, raInner.x - raOuter.x + AUTOSCROLL_MARGIN,
50+
raOuter.height - raInner.height - raInner.y + raOuter.y + AUTOSCROLL_MARGIN, raOuter.width
51+
- raInner.width - raInner.x + raOuter.x + AUTOSCROLL_MARGIN);
52+
}
53+
}

0 commit comments

Comments
 (0)