diff --git a/services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java b/services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java new file mode 100644 index 00000000..c9be6b46 --- /dev/null +++ b/services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java @@ -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 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 createPage(API api) { + return (T) new TextFileTreeNodeFactoryProvider.Page(entry) { + + private static final long serialVersionUID = 1L; + + @Override + public String getSyntaxStyle() { + return SyntaxConstants.SYNTAX_STYLE_GROOVY; + } + }; + } + } +} \ No newline at end of file diff --git a/services/src/main/java/org/jd/gui/service/treenode/PropertiesFileTreeNodeFactoryProvider.java b/services/src/main/java/org/jd/gui/service/treenode/PropertiesFileTreeNodeFactoryProvider.java index 28584d58..cee50cd8 100644 --- a/services/src/main/java/org/jd/gui/service/treenode/PropertiesFileTreeNodeFactoryProvider.java +++ b/services/src/main/java/org/jd/gui/service/treenode/PropertiesFileTreeNodeFactoryProvider.java @@ -27,7 +27,7 @@ public class PropertiesFileTreeNodeFactoryProvider extends TextFileTreeNodeFacto @Override public String[] getSelectors() { - return appendSelectors("*:file:*.properties"); + return appendSelectors("*:file:*.properties", "*:file:*.cfg"); } @Override diff --git a/services/src/main/java/org/jd/gui/service/treenode/TextFileTreeNodeFactoryProvider.java b/services/src/main/java/org/jd/gui/service/treenode/TextFileTreeNodeFactoryProvider.java index 2cdfdd1f..c631c00e 100644 --- a/services/src/main/java/org/jd/gui/service/treenode/TextFileTreeNodeFactoryProvider.java +++ b/services/src/main/java/org/jd/gui/service/treenode/TextFileTreeNodeFactoryProvider.java @@ -42,7 +42,7 @@ public class TextFileTreeNodeFactoryProvider extends FileTreeNodeFactoryProvider @Override public String[] getSelectors() { - return appendSelectors("*:file:*.txt", "*:file:*.md", "*:file:*.SF", "*:file:*.policy", "*:file:*.yaml", "*:file:*.yml", "*:file:*/COPYRIGHT", "*:file:*/LICENSE"); + return appendSelectors("*:file:*.txt", "*:file:*.md", "*:file:*.SF", "*:file:*.policy", "*:file:*.yaml", "*:file:*.yml", "*:file:*/COPYRIGHT", "*:file:*/LICENSE", "*:file:*.cnd", "*:file:*.drl", "*:file:*.dsl"); } @Override diff --git a/services/src/main/resources/META-INF/services/org.jd.gui.spi.TreeNodeFactory b/services/src/main/resources/META-INF/services/org.jd.gui.spi.TreeNodeFactory index 959e5d0d..bcce1a47 100644 --- a/services/src/main/resources/META-INF/services/org.jd.gui.spi.TreeNodeFactory +++ b/services/src/main/resources/META-INF/services/org.jd.gui.spi.TreeNodeFactory @@ -34,3 +34,4 @@ org.jd.gui.service.treenode.ZipFileTreeNodeFactoryProvider org.jd.gui.service.treenode.ImageFileTreeNodeFactoryProvider org.jd.gui.service.treenode.GradleFileTreeNodeFactoryProvider org.jd.gui.service.treenode.BatFileTreeNodeFactoryProvider +org.jd.gui.service.treenode.GroovyTreeNodeFactoryProvider \ No newline at end of file diff --git a/services/src/main/resources/org/jd/gui/images/groovy_obj.png b/services/src/main/resources/org/jd/gui/images/groovy_obj.png new file mode 100644 index 00000000..6ce053f7 Binary files /dev/null and b/services/src/main/resources/org/jd/gui/images/groovy_obj.png differ