-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DarkLaf equivalent of "File breadcrumbs" #237
Comments
I'm currently writing a library swingdsl containing several quality of life enhancements for developing swing applications. It also contains a BreadcrumbBar implementation. Though it currently doesn't provide the popup mechanism from WebLaf or IntelliJ, this is something I can add (including some specialized version for Files). |
I think the most convenient way to do this would be to connect the breadcrumb bar with a TreeModel, where clicking an element opens a popup with all children. Do you already have a tree model of the folder structure at hand? |
I don't. I intend to use it as a simple file browsing tool (as in intellij). |
I see. Luckily I already have a |
With the latest snapshot version of Here is a short working example of how to use it: fun main() = onSwingThread {
LafManager.install()
frame {
content {
borderPanel {
val fsv = FileSystemView.getFileSystemView()
val rootFiles = fsv.getFiles(fsv.roots[0], true)
val fileTree = FileTree(showHiddenFiles = false, *rootFiles)
fileTree.setSelectionRow(0)
north {
+createFileBreadcrumbBar(fileTree)
}
center {
scrollPane { +fileTree }
}
}
}
centerOnScreen()
visible = true
}
} Note that the |
Is this also usable using a down-to-earth java swing application? I really appreciate your work. Thank you very much. |
Yes :). Here is the equivalent Java code: SwingUtilities.invokeLater(() -> {
LafManager.install();
JFrame frame = new JFrame();
JPanel content = new JPanel(new BorderLayout());
FileSystemView fsv = FileSystemView.getFileSystemView();
File[] rootFiles = fsv.getFiles(fsv.getRoots()[0], true);
FileTree fileTree = new FileTree(false, rootFiles);
content.add(FileBreadcrumbBar.create(fileTree), BorderLayout.NORTH);
content.add(new JScrollPane(fileTree), BorderLayout.CENTER);
frame.setContentPane(content);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}); |
Do I have to add swing-dsl as a library? Is it on maven / jitpack? |
The library is available on maven: https://search.maven.org/artifact/com.github.weisj/swing-dsl |
I don't really want to add an unnecessary library to my project for a look and feel class. It would be nicer to have it as a darklaf implementation, but that's probably going to eat some time as it is written in kotlin i assume. |
I'll try to see whether it's feasible to port it to a standalone Java library. |
What I’ll do for now is to extract the components into a separate library. Of course this will still pull in the kotlin stdlib (which isn’t too big), but will allow me to rewrite the components in java once I find time for it. |
I have now done that. The coordinates are: implementation("com.github.weisj:swing-extensions-components:latest.integration") |
Wow, that's pretty amazing! Will try it out when I have time. |
Getting a java.lang.ClassNotFoundException: com.github.weisj.darklaf.icons.IconLoader when trying to use with 3.0.0. |
Please try |
Seems to work now. (I only tested the breadcrumb stuff.) |
I am still not sure how to implement a BreadcrumbBar correctly with my own tree structure. |
Here is an example DefaultMutableTreeNode root = new DefaultMutableTreeNode();
root.add(new DefaultMutableTreeNode("Child 1"));
root.add(new DefaultMutableTreeNode("Child 2"));
TreeModel treeModel = new DefaultTreeModel(root);
JTree tree = new JTree(treeModel);
TreeBreadCrumbModel<DefaultMutableTreeNode, String> breadCrumbModel = new TreeBreadCrumbModel<>(
tree, treeNode -> (String) treeNode.getUserObject());
BreadcrumbBar<DefaultMutableTreeNode, String> breadcrumbBar = new BreadcrumbBar<>(breadCrumbModel); |
General description
This component was included in WebLaF under the name "File breadcrumbs". I am looking for a darklaf implementation. Is there one?
Additional context
Intellij also has such a bar. Examples here:
The text was updated successfully, but these errors were encountered: