use of org.apache.jmeter.gui.tree.JMeterTreeTransferHandler in project jmeter by apache.
the class MainFrame method makeTree.
/**
* Create and initialize the GUI representation of the test tree.
*
* @param treeModel
* the test tree model
* @param treeListener
* the test tree listener
*
* @return the initialized test tree GUI
*/
private JTree makeTree(TreeModel treeModel, JMeterTreeListener treeListener) {
JTree treevar = new JTree(treeModel) {
private static final long serialVersionUID = 240L;
@Override
public String getToolTipText(MouseEvent event) {
TreePath path = this.getPathForLocation(event.getX(), event.getY());
if (path != null) {
Object treeNode = path.getLastPathComponent();
if (treeNode instanceof DefaultMutableTreeNode) {
Object testElement = ((DefaultMutableTreeNode) treeNode).getUserObject();
if (testElement instanceof TestElement) {
String comment = ((TestElement) testElement).getComment();
if (comment != null && comment.length() > 0) {
return comment;
}
}
}
}
return null;
}
};
treevar.setToolTipText("");
treevar.setCellRenderer(getCellRenderer());
treevar.setRootVisible(false);
treevar.setShowsRootHandles(true);
treeListener.setJTree(treevar);
treevar.addTreeSelectionListener(treeListener);
treevar.addMouseListener(treeListener);
treevar.addKeyListener(treeListener);
// enable drag&drop, install a custom transfer handler
treevar.setDragEnabled(true);
treevar.setDropMode(DropMode.ON_OR_INSERT);
treevar.setTransferHandler(new JMeterTreeTransferHandler());
addQuickComponentHotkeys(treevar);
return treevar;
}
Aggregations