Search in sources :

Example 91 with TreePath

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;
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath)

Example 92 with TreePath

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;
}
Also used : MTreeNode(org.compiere.model.MTreeNode) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) Transferable(java.awt.datatransfer.Transferable)

Example 93 with TreePath

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) }));
    }
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 94 with TreePath

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();
}
Also used : ConversionException(com.thoughtworks.xstream.converters.ConversionException) HashTree(org.apache.jorphan.collections.HashTree) ActionEvent(java.awt.event.ActionEvent) ActionRouter(org.apache.jmeter.gui.action.ActionRouter) ConfigurationException(org.apache.jmeter.report.config.ConfigurationException) JMeterException(org.apache.jorphan.util.JMeterException) FileNotFoundException(java.io.FileNotFoundException) ConversionException(com.thoughtworks.xstream.converters.ConversionException) SocketException(java.net.SocketException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) GenerationException(org.apache.jmeter.report.dashboard.GenerationException) MainFrame(org.apache.jmeter.gui.MainFrame) JMeterTreeModel(org.apache.jmeter.gui.tree.JMeterTreeModel) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) JMeterTreeListener(org.apache.jmeter.gui.tree.JMeterTreeListener) File(java.io.File)

Example 95 with TreePath

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);
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) GuiPackage(org.apache.jmeter.gui.GuiPackage)

Aggregations

TreePath (javax.swing.tree.TreePath)539 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)177 ArrayList (java.util.ArrayList)58 TreeNode (javax.swing.tree.TreeNode)56 Nullable (org.jetbrains.annotations.Nullable)49 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)46 JTree (javax.swing.JTree)34 NotNull (org.jetbrains.annotations.NotNull)32 Test (org.junit.Test)22 Tree (com.intellij.ui.treeStructure.Tree)21 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)21 TreeSelectionListener (javax.swing.event.TreeSelectionListener)21 MouseEvent (java.awt.event.MouseEvent)18 Point (java.awt.Point)17 ActionEvent (java.awt.event.ActionEvent)15 KeyEvent (java.awt.event.KeyEvent)12 EVTask (net.sourceforge.processdash.ev.EVTask)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 KeyAdapter (java.awt.event.KeyAdapter)11 List (java.util.List)11