use of javax.swing.tree.TreePath in project adempiere by adempiere.
the class PropagatePreservingUncheckTreeCheckingMode method uncheckPath.
@Override
public void uncheckPath(TreePath path) {
// uncheck is propagated to children
this.model.uncheckSubTree(path);
TreePath parentPath = path;
// check all the ancestors with subtrees checked
while ((parentPath = parentPath.getParentPath()) != null) {
switch(this.model.getChildrenChecking(parentPath)) {
case HALF_CHECKED:
this.model.addToCheckedPathsSet(parentPath);
this.model.addToGreyedPathsSet(parentPath);
break;
case ALL_UNCHECKED:
this.model.removeFromCheckedPathsSet(parentPath);
this.model.removeFromGreyedPathsSet(parentPath);
break;
case ALL_CHECKED:
System.err.println("This should not happen (PropagatePreservingUncheckTreeCheckingMode)");
break;
default:
case NO_CHILDREN:
System.err.println("This should not happen (PropagatePreservingCheckTreeCheckingMode)");
break;
}
}
}
use of javax.swing.tree.TreePath in project adempiere by adempiere.
the class VTreeTransferHandler method importData.
public boolean importData(TransferHandler.TransferSupport info) {
if (!canImport(info))
return false;
JTree tree = (JTree) info.getComponent();
AdempiereTreeModel model = (AdempiereTreeModel) tree.getModel();
Transferable t = info.getTransferable();
MTreeNode to = null;
MTreeNode from = null;
int index;
try {
from = (MTreeNode) t.getTransferData(TransferableTreeNode.TREE_NODE_FLAVOR);
} catch (Exception e) {
return false;
}
if (info.isDrop()) {
JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation();
to = (MTreeNode) dl.getPath().getLastPathComponent();
if (from == to)
return false;
index = dl.getChildIndex();
if (index == -1)
// insert as first child
index = 0;
} else {
// it's a paste
MTreeNode selected = (MTreeNode) tree.getSelectionPath().getLastPathComponent();
if (selected.isLeaf()) {
to = (MTreeNode) selected.getParent();
// insert after selected
index = to.getIndex(selected) + 1;
} else {
to = selected;
index = 0;
}
}
model.insertNodeInto(from, to, index);
// display from's new location
tree.scrollPathToVisible(new TreePath(from.getPath()));
model.saveChangedNodes(from, to);
return true;
}
use of javax.swing.tree.TreePath in project jmeter by apache.
the class ViewResultsFullVisualizer method updateGui.
/**
* Update the visualizer with new data.
*/
private void updateGui() {
synchronized (buffer) {
if (!dataChanged) {
return;
}
root.removeAllChildren();
for (Object sampler : buffer) {
SampleResult res = (SampleResult) sampler;
// Add sample
DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
treeModel.insertNodeInto(currNode, root, root.getChildCount());
addSubResults(currNode, res);
// Add any assertion that failed as children of the sample node
AssertionResult[] assertionResults = res.getAssertionResults();
int assertionIndex = currNode.getChildCount();
for (AssertionResult assertionResult : assertionResults) {
if (assertionResult.isFailure() || assertionResult.isError()) {
DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel);
treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
}
}
}
treeModel.nodeStructureChanged(root);
dataChanged = false;
}
if (root.getChildCount() == 1) {
jTree.expandPath(new TreePath(root));
}
if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
jTree.scrollPathToVisible(new TreePath(new Object[] { root, treeModel.getChild(root, root.getChildCount() - 1) }));
}
}
use of javax.swing.tree.TreePath in project jmeter by apache.
the class JMeter method startGui.
/**
* Starts up JMeter in GUI mode
*/
private void startGui(String testFile) {
//NOSONAR
System.out.println("================================================================================");
//NOSONAR
System.out.println("Don't use GUI mode for load testing, only for Test creation and Test debugging !");
//NOSONAR
System.out.println("For load testing, use NON GUI Mode:");
//NOSONAR
System.out.println(" jmeter -n -t [jmx file] -l [results file] -e -o [Path to output folder]");
//NOSONAR
System.out.println("& adapt Java Heap to your test requirements:");
//NOSONAR
System.out.println(" Modify HEAP=\"-Xms512m -Xmx512m\" in the JMeter batch file");
//NOSONAR
System.out.println("================================================================================");
SplashScreen splash = new SplashScreen();
splash.showScreen();
String jMeterLaf = LookAndFeelCommand.getJMeterLaf();
try {
UIManager.setLookAndFeel(jMeterLaf);
} catch (Exception ex) {
log.warn("Could not set LAF to: {}", jMeterLaf, ex);
}
splash.setProgress(10);
JMeterUtils.applyHiDPIOnFonts();
PluginManager.install(this, true);
JMeterTreeModel treeModel = new JMeterTreeModel();
splash.setProgress(30);
JMeterTreeListener treeLis = new JMeterTreeListener(treeModel);
final ActionRouter instance = ActionRouter.getInstance();
instance.populateCommandMap();
splash.setProgress(60);
treeLis.setActionHandler(instance);
GuiPackage.initInstance(treeLis, treeModel);
splash.setProgress(80);
MainFrame main = new MainFrame(treeModel, treeLis);
splash.setProgress(100);
ComponentUtil.centerComponentInWindow(main, 80);
main.setVisible(true);
instance.actionPerformed(new ActionEvent(main, 1, ActionNames.ADD_ALL));
if (testFile != null) {
try {
File f = new File(testFile);
log.info("Loading file: {}", f);
FileServer.getFileServer().setBaseForScript(f);
HashTree tree = SaveService.loadTree(f);
GuiPackage.getInstance().setTestPlanFile(f.getAbsolutePath());
Load.insertLoadedTree(1, tree);
} catch (ConversionException e) {
log.error("Failure loading test file", e);
JMeterUtils.reportErrorToUser(SaveService.CEtoString(e));
} catch (Exception e) {
log.error("Failure loading test file", e);
JMeterUtils.reportErrorToUser(e.toString());
}
} else {
JTree jTree = GuiPackage.getInstance().getMainFrame().getTree();
TreePath path = jTree.getPathForRow(0);
jTree.setSelectionPath(path);
FocusRequester.requestFocus(jTree);
}
splash.setProgress(100);
splash.close();
}
use of javax.swing.tree.TreePath in project jmeter by apache.
the class ModuleControllerGui method expandToSelectNode.
/**
* @param selected JMeterTreeNode tree node to expand
*/
protected void expandToSelectNode(JMeterTreeNode selected) {
GuiPackage guiInstance = GuiPackage.getInstance();
JTree jTree = guiInstance.getMainFrame().getTree();
jTree.expandPath(new TreePath(selected.getPath()));
selected.setMarkedBySearch(true);
}
Aggregations