Skip to content

Commit

Permalink
Added middle mouse toggle
Browse files Browse the repository at this point in the history
I was working on getting single left mouse click state toggle but I was hitting some issues with multiple bounds so I've put this to the side for now and just added a little work around so I can release the plugin

Found why I needed the repaint, which I removed from EditableCheckboxTreeCellRenderer
 when pressing space it wouldn't update the toggle state
  • Loading branch information
BeardyKing committed Dec 4, 2023
1 parent 9e843e3 commit 16a559d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Plugin description -->

### Info:
Better command line arguments is a small plugin that manages CLion "program arguments" as a tree structures, This plugin is highly inspired by the Visual Studio plugin [SmartCommandlineArgs](https://github.com/MBulli/SmartCommandlineArgs)
Better command line arguments is a CLion 2022.3.3+ plugin that manages your "program arguments" as a tree structures, this plugin is highly inspired by the Visual Studio plugin [SmartCommandlineArgs](https://github.com/MBulli/SmartCommandlineArgs)

### Warning:
This plugin will write raw command line text to `workspace.xml` which is used by CLion to manage Configurations, be sure to validate that your `.idea` folder is ignored from public repositories.
Expand All @@ -30,16 +30,18 @@ If there are any features you would like feel free to open a pull request.

#### Shortcuts:

| keybind | use |
| ------------ | --------------------------------------------------------- |
| "Insert" | Add CLArg to current selected folder |
| "Delete" | Remove all currently selected CLArgs |
| "Home" | Add all currently selected CLArgs to new Folder |
| "Space" | Toggle all currently selected CLArgs on/off |
| "Alt + Up" | Move all currently selected CLArgs up in current folder |
| "Alt + Down" | Move all currently selected CLArgs down in current folder |
| "Ctrl + R" | Manually parse CLArgs and save to workspace.xml |
| "Ctrl + V" | Add CLArg with text from the clipboard in current folder |
| keybind | use |
| -------------- | --------------------------------------------------------- |
| "Insert" | Add CLArg to current selected folder |
| "Delete" | Remove all currently selected CLArgs |
| "Home" | Add all currently selected CLArgs to new Folder |
| "Space" | Toggle all currently selected CLArgs on/off |
| "Alt + Up" | Move all currently selected CLArgs up in current folder |
| "Alt + Down" | Move all currently selected CLArgs down in current folder |
| "Ctrl + R" | Manually parse CLArgs and save to workspace.xml |
| "Ctrl + V" | Add CLArg with text from the clipboard in current folder |
| "Middle Mouse" | Toggle currently mouse hovered CLArg on/off |


<!-- Plugin description end -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
Expand Down Expand Up @@ -106,6 +108,8 @@ public CLArgumentTree() {
tabbedPane.addTab("CL Args", createTreeTab());
tabbedPane.addTab("CL Vars", createTableTab());

toggleTreeOnMiddleMouseClick(tree);

frame.add(tabbedPane, BorderLayout.CENTER);
frame.setVisible(true);
}
Expand All @@ -131,6 +135,24 @@ private static String updateNodeTexts(DefaultMutableTreeNode node) {
static JEditorPane nodeTextLabel = new JEditorPane();
static Tree tree;

private void toggleTreeOnMiddleMouseClick(JTree tree) {
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {
TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY());

if (clickedPath != null) {
Rectangle checkBoxBounds = tree.getPathBounds(clickedPath);
if (checkBoxBounds != null && checkBoxBounds.contains(e.getPoint())) {
toggleSelectedNodes(tree);
tree.repaint();
}
}
}
}
});
}

private JPanel createTreeTab() {
JPanel frame = new JBPanel<>(new BorderLayout());
Expand Down Expand Up @@ -270,6 +292,7 @@ public void keyPressed(KeyEvent e) {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
toggleSelectedNodes(tree);
tree.repaint();
}
}
});
Expand Down

0 comments on commit 16a559d

Please sign in to comment.