package com.traxel.lumbermill.filter;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.swing.tree.TreePath;
class TreeControl extends MouseAdapter
implements FilterControl {
private final TreePanel TREE_PANEL;
private final TreeView TREE_VIEW;
private final SeverityListView POPUP = new SeverityListView();
TREE_PANEL = new TreePanel();
TREE_VIEW = TREE_PANEL.TREE_VIEW;
TREE_VIEW.addMouseListener(this);
}
TREE_PANEL = new TreePanel(tree);
TREE_VIEW = TREE_PANEL.TREE_VIEW;
TREE_VIEW.addMouseListener(this);
}
return TREE_VIEW;
}
@Override
final TreePath[] paths;
final Collection nodes;
Node node;
final List actions;
final Point location;
POPUP.setVisible(false);
if (MouseEvent.BUTTON3 == e.getButton()) {
final TreePath path = TREE_VIEW.getPathForLocation(e.getX(), e.getY());
TREE_VIEW.setSelectionPath(path);
paths = TREE_VIEW.getSelectionPaths();
if ((paths == null) || (paths.length == 0)) {
return;
}
nodes = new ArrayList();
for (int i = 0; i < paths.length; i++) {
node = (Node)paths[i].getLastPathComponent();
nodes.add(node);
}
actions = SeverityAction.getActions(nodes);
location = getScreenLocation();
final Point locP = TREE_PANEL.getLocationOnScreen();
showPopup(actions, (int)(e.getX() + locP.getX()), (int)(e.getY() + locP.getY() + 5));
}
}
@Override
return getFilterView().getFilter();
}
@Override
return TREE_PANEL;
}
private synchronized void (final List actions, final int x, final int y) {
POPUP.setVisible(false);
POPUP.setActions(actions);
POPUP.pack();
POPUP.setLocation(x, y);
POPUP.setVisible(true);
}
final List locations;
Component parent;
locations = new ArrayList();
parent = TREE_VIEW;
while (parent != null) {
locations.add(parent.getLocation());
parent = parent.getParent();
}
return locations;
}
final List locations;
final Iterator it;
Point location;
int screenX = 0;
int screenY = 0;
locations = getLocations();
it = locations.iterator();
while (it.hasNext()) {
location = (Point)it.next();
if (location != null) {
screenX += location.getX();
screenY += location.getY();
}
}
return new Point(screenX, screenY);
}
}