From 73bde0edaf282804356153c654c3654489d06896 Mon Sep 17 00:00:00 2001 From: Serge Huber Date: Mon, 25 May 2020 21:01:23 +0200 Subject: [PATCH] Add support for CND (Apache Jackrabbit), Drools and Groovy files --- .../GroovyTreeNodeFactoryProvider.java | 46 ++++++++++++++++++ ...PropertiesFileTreeNodeFactoryProvider.java | 2 +- .../TextFileTreeNodeFactoryProvider.java | 2 +- .../services/org.jd.gui.spi.TreeNodeFactory | 1 + .../org/jd/gui/images/groovy_obj.png | Bin 0 -> 367 bytes 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java create mode 100644 services/src/main/resources/org/jd/gui/images/groovy_obj.png 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..a5ecf79c --- /dev/null +++ b/services/src/main/java/org/jd/gui/service/treenode/GroovyTreeNodeFactoryProvider.java @@ -0,0 +1,46 @@ +/* + * 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.view.data.TreeNodeBean; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import java.io.File; + +public class GroovyTreeNodeFactoryProvider extends TextFileTreeNodeFactoryProvider { + protected static final ImageIcon ICON = new ImageIcon(GroovyTreeNodeFactoryProvider.class.getClassLoader().getResource("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 GroovyTreeNodeFactoryProvider.TreeNode(entry, new TreeNodeBean(label, "Location: " + location, ICON)); + } + + protected static class TreeNode extends TextFileTreeNodeFactoryProvider.TreeNode { + 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) { + @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 68c2fa7b..092b306a 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 @@ -21,7 +21,7 @@ public class PropertiesFileTreeNodeFactoryProvider extends TextFileTreeNodeFactoryProvider { protected static final ImageIcon ICON = new ImageIcon(PropertiesFileTreeNodeFactoryProvider.class.getClassLoader().getResource("org/jd/gui/images/ascii_obj.png")); - @Override public String[] getSelectors() { return appendSelectors("*:file:*.properties"); } + @Override public String[] getSelectors() { return appendSelectors("*:file:*.properties", "*:file:*.cfg"); } @Override @SuppressWarnings("unchecked") 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 6665c83c..06b9689d 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 @@ -40,7 +40,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 701e2e25..ad7365b9 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 @@ -32,3 +32,4 @@ org.jd.gui.service.treenode.XmlBasedFileTreeNodeFactoryProvider org.jd.gui.service.treenode.XmlFileTreeNodeFactoryProvider org.jd.gui.service.treenode.ZipFileTreeNodeFactoryProvider org.jd.gui.service.treenode.ImageFileTreeNodeFactoryProvider +org.jd.gui.service.treenode.GroovyTreeNodeFactoryProvider 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 0000000000000000000000000000000000000000..6ce053f7f58ae13644a701a10ed1e5f7ef0c7225 GIT binary patch literal 367 zcmV-#0g(QQP)LmO;X0cp zi%~GBh|H_uyjPBgyK~W}{NevT&+~qgk0QDnaB?w^@2?dXafcgJFj|k)oMSMB6C7g; zrI#3Vgy0x`@ps?IpnzdaV;8^i6;)hg1T(=Y)I?2^A$>+$%5V;Ev5zk}#CwcIyoy__ zG-DDQDe(mkaD_eW1i6x_d=uYlA8)XX2mD1Z{^1g5SU`WoAFvvlXK2AI7b<+5&t8(kN;vI4A#({$@C%G8cGYYcknUZQdDs-S=lU(!muYT z$PS_wd?&fWYy7~tWUc8Wb@4MqWwfVSC`46P_?2hSFLh;gP>{^&36Jn`K?rr&ulN7} N002ovPDHLkV1iJqp4I>W literal 0 HcmV?d00001