Search in sources :

Example 76 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class DebuggerTreeBase method getTipText.

@Nullable
private String getTipText(DebuggerTreeNodeImpl node) {
    NodeDescriptorImpl descriptor = node.getDescriptor();
    if (descriptor instanceof ValueDescriptorImpl) {
        String text = ((ValueDescriptorImpl) descriptor).getValueText();
        final String tipText = DebuggerUtilsEx.prepareValueText(text, myProject);
        if (!tipText.isEmpty() && (tipText.indexOf('\n') >= 0 || !getVisibleRect().contains(getRowBounds(getRowForPath(new TreePath(node.getPath())))))) {
            return tipText;
        }
    }
    return node.getMarkupTooltipText() != null ? "" : null;
}
Also used : ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) TreePath(javax.swing.tree.TreePath) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 77 with TreePath

use of javax.swing.tree.TreePath in project Botnak by Gocnak.

the class GUIViewerList method initComponents.

private void initComponents(String channel) {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Nick K
    searchBar = new JTextField();
    scrollPane = new JScrollPane();
    viewerTree = new JTree();
    //======== this ========
    setTitle("Viewers");
    setIconImage(new ImageIcon(getClass().getResource("/image/icon.png")).getImage());
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setResizable(true);
    Container contentPane = getContentPane();
    //---- searchBar ----
    searchBar.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            String text = searchBar.getText();
            if (text != null) {
                text = text.trim();
                if (text.length() > 0) {
                    if (!isFiltering) {
                        isFiltering = true;
                    }
                    buildFilteredModel(text);
                } else {
                    isFiltering = false;
                    setViewerTreeModel(defaultModel);
                }
            } else {
                isFiltering = false;
                setViewerTreeModel(defaultModel);
            }
        }
    });
    //======== scrollPane2 ========
    {
        //---- viewerTree ---
        default_root = new DefaultMutableTreeNode(channel);
        defaultModel = new DefaultTreeModel(default_root);
        filtered_root = new DefaultMutableTreeNode(channel);
        viewerTree.setShowsRootHandles(true);
        staff = new DefaultMutableTreeNode("Staff");
        admins = new DefaultMutableTreeNode("Admins");
        global_mods = new DefaultMutableTreeNode("Global Moderators");
        mods = new DefaultMutableTreeNode("Moderators");
        viewers = new DefaultMutableTreeNode("Viewers");
        setViewerTreeModel(defaultModel);
        viewerTree.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseReleased(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    TreePath selPath = viewerTree.getPathForLocation(e.getX(), e.getY());
                    if (selPath != null && selPath.getPathCount() == 3) {
                        //should be a name
                        DefaultMutableTreeNode nameNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();
                        ListenerName.createUserPopup(channel, nameNode.getUserObject().toString(), viewerTree, e.getX(), e.getY());
                    }
                }
            }
        });
        scrollPane.setViewportView(viewerTree);
    }
    setMinimumSize(new Dimension(250, 490));
    GroupLayout contentPaneLayout = new GroupLayout(contentPane);
    contentPane.setLayout(contentPaneLayout);
    contentPaneLayout.setHorizontalGroup(contentPaneLayout.createParallelGroup().addComponent(searchBar, GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE).addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE));
    contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup().addComponent(searchBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE)));
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            GUIMain.viewerLists.remove(channel);
        }
    });
    pack();
    setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreePath(javax.swing.tree.TreePath)

Example 78 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class DebuggerAction method getSelectedNodes.

@Nullable
public static DebuggerTreeNodeImpl[] getSelectedNodes(DataContext dataContext) {
    DebuggerTree tree = getTree(dataContext);
    if (tree == null)
        return null;
    TreePath[] paths = tree.getSelectionPaths();
    if (paths == null || paths.length == 0) {
        return EMPTY_TREE_NODE_ARRAY;
    }
    List<DebuggerTreeNodeImpl> nodes = new ArrayList<>(paths.length);
    for (TreePath path : paths) {
        Object component = path.getLastPathComponent();
        if (component instanceof DebuggerTreeNodeImpl) {
            nodes.add((DebuggerTreeNodeImpl) component);
        }
    }
    return nodes.toArray(new DebuggerTreeNodeImpl[nodes.size()]);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TreePath(javax.swing.tree.TreePath) ArrayList(java.util.ArrayList) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) DebuggerTree(com.intellij.debugger.ui.impl.watch.DebuggerTree) Nullable(org.jetbrains.annotations.Nullable)

Example 79 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class DebuggerAction method getSelectedNode.

@Nullable
public static DebuggerTreeNodeImpl getSelectedNode(DataContext dataContext) {
    DebuggerTree tree = getTree(dataContext);
    if (tree == null)
        return null;
    if (tree.getSelectionCount() != 1) {
        return null;
    }
    TreePath path = tree.getSelectionPath();
    if (path == null) {
        return null;
    }
    Object component = path.getLastPathComponent();
    if (!(component instanceof DebuggerTreeNodeImpl)) {
        return null;
    }
    return (DebuggerTreeNodeImpl) component;
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TreePath(javax.swing.tree.TreePath) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) DebuggerTree(com.intellij.debugger.ui.impl.watch.DebuggerTree) Nullable(org.jetbrains.annotations.Nullable)

Example 80 with TreePath

use of javax.swing.tree.TreePath in project Botnak by Gocnak.

the class UserManager method beat.

@Override
public void beat() {
    beating = true;
    String[] channels = Settings.channelManager.getChannelNames();
    URL url;
    for (String chan : channels) {
        String chanOut = chan.substring(1);
        GUIViewerList list = GUIMain.viewerLists.get(chanOut);
        if (list != null) {
            try {
                url = new URL("http://tmi.twitch.tv/group/user/" + chan.substring(1) + "/chatters");
                String line = Utils.createAndParseBufferedReader(url.openStream());
                if (!line.isEmpty()) {
                    final Enumeration<TreePath> beforePaths = list.beforePaths();
                    final int beforeScroll = list.beforeScroll();
                    JSONObject site = new JSONObject(line);
                    JSONObject chatters = site.getJSONObject("chatters");
                    JSONArray mods = chatters.getJSONArray("moderators");
                    readAndUpdate(mods, list, GUIViewerList.ViewerType.MOD);
                    JSONArray staff = chatters.getJSONArray("staff");
                    readAndUpdate(staff, list, GUIViewerList.ViewerType.STAFF);
                    JSONArray admins = chatters.getJSONArray("admins");
                    readAndUpdate(admins, list, GUIViewerList.ViewerType.ADMIN);
                    JSONArray global_mods = chatters.getJSONArray("global_mods");
                    readAndUpdate(global_mods, list, GUIViewerList.ViewerType.GLOBAL_MOD);
                    JSONArray viewers = chatters.getJSONArray("viewers");
                    readAndUpdate(viewers, list, GUIViewerList.ViewerType.VIEWER);
                    EventQueue.invokeLater(() -> list.updateRoot(beforePaths, beforeScroll));
                    Thread.sleep(2000);
                }
            } catch (Exception e) {
                GUIMain.log(e);
            }
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) JSONObject(lib.JSON.JSONObject) JSONArray(lib.JSON.JSONArray) GUIViewerList(gui.forms.GUIViewerList) URL(java.net.URL)

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