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;
}
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
}
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()]);
}
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;
}
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);
}
}
}
}
Aggregations