-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nbauma109
committed
May 12, 2024
1 parent
03f9640
commit f2ab087
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2008-2019 Emmanuel Dupuy. | ||
* This project is distributed under the GPLv3 license. | ||
* This is a Copyleft license that gives the user the right to use, | ||
* copy and modify the code freely for non-commercial purposes. | ||
*/ | ||
package org.jd.gui.service.treenode; | ||
|
||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | ||
import org.jd.gui.api.API; | ||
import org.jd.gui.api.feature.ContainerEntryGettable; | ||
import org.jd.gui.api.feature.UriGettable; | ||
import org.jd.gui.api.model.Container; | ||
import org.jd.gui.util.ImageUtil; | ||
import org.jd.gui.view.data.TreeNodeBean; | ||
|
||
import java.io.File; | ||
|
||
import javax.swing.ImageIcon; | ||
import javax.swing.JComponent; | ||
import javax.swing.tree.DefaultMutableTreeNode; | ||
|
||
public class GroovyTreeNodeFactoryProvider extends TextFileTreeNodeFactoryProvider { | ||
|
||
protected static final ImageIcon ICON = new ImageIcon(ImageUtil.getImage("/org/jd/gui/images/groovy_obj.png")); | ||
|
||
@Override | ||
public String[] getSelectors() { | ||
return appendSelectors("*:file:*.groovy"); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T extends DefaultMutableTreeNode & ContainerEntryGettable & UriGettable> T make(API api, Container.Entry entry) { | ||
int lastSlashIndex = entry.getPath().lastIndexOf("/"); | ||
String label = entry.getPath().substring(lastSlashIndex + 1); | ||
String location = new File(entry.getUri()).getPath(); | ||
return (T) new TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON)); | ||
} | ||
|
||
protected static class TreeNode extends TextFileTreeNodeFactoryProvider.TreeNode { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public TreeNode(Container.Entry entry, Object userObject) { | ||
super(entry, userObject); | ||
} | ||
|
||
// --- PageCreator --- // | ||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T extends JComponent & UriGettable> T createPage(API api) { | ||
return (T) new TextFileTreeNodeFactoryProvider.Page(entry) { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public String getSyntaxStyle() { | ||
return SyntaxConstants.SYNTAX_STYLE_GROOVY; | ||
} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.