diff --git a/jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java b/jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java index fd9923ec04a..8577e3a049d 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java @@ -1,9 +1,11 @@ package jadx.gui.ui; -import javax.swing.*; -import javax.swing.plaf.basic.BasicButtonUI; -import javax.swing.text.BadLocationException; -import java.awt.*; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.Component; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -15,13 +17,22 @@ import java.util.List; import java.util.Map; -import jadx.gui.treemodel.JCertificate; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.swing.plaf.basic.BasicButtonUI; +import javax.swing.text.BadLocationException; import jadx.api.ResourceFile; import jadx.api.ResourceType; +import jadx.gui.treemodel.JCertificate; +import jadx.gui.treemodel.JClass; import jadx.gui.treemodel.JNode; import jadx.gui.treemodel.JResource; import jadx.gui.utils.JumpManager; @@ -252,6 +263,15 @@ public void mouseClicked(MouseEvent e) { private JPopupMenu createTabPopupMenu(final ContentPanel contentPanel) { JPopupMenu menu = new JPopupMenu(); + JMenuItem copyRootClassName = new JMenuItem(NLS.str("tabs.copy_class_name")); + copyRootClassName.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + copyRootClassName(); + } + }); + menu.add(copyRootClassName); + JMenuItem closeTab = new JMenuItem(NLS.str("tabs.close")); closeTab.addActionListener(new ActionListener() { @Override @@ -315,6 +335,16 @@ public void closeAllTabs() { } } + public void copyRootClassName(){ + ContentPanel selectedPanel = getSelectedCodePanel(); + JNode node = selectedPanel.getNode(); + JClass jClass = node.getRootClass(); + if (jClass != null){ + String name = jClass.getFullName(); + Utils.setClipboardString(name); + } + } + public void loadSettings() { for (ContentPanel panel : openTabs.values()) { panel.loadSettings(); diff --git a/jadx-gui/src/main/java/jadx/gui/utils/Utils.java b/jadx-gui/src/main/java/jadx/gui/utils/Utils.java index af12f8c5438..18cd858fb24 100644 --- a/jadx-gui/src/main/java/jadx/gui/utils/Utils.java +++ b/jadx-gui/src/main/java/jadx/gui/utils/Utils.java @@ -1,16 +1,26 @@ package jadx.gui.utils; -import java.awt.*; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; import java.io.InputStream; import java.net.URL; -import javax.swing.*; + +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.KeyStroke; import jadx.core.dex.info.AccessInfo; import jadx.core.dex.instructions.args.ArgType; import jadx.core.utils.exceptions.JadxRuntimeException; -import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class Utils { private static final Logger LOG = LoggerFactory.getLogger(Utils.class); @@ -136,4 +146,10 @@ private static String format(long mem) { public static char caseChar(char ch, boolean toLower) { return toLower ? Character.toLowerCase(ch) : ch; } + + public static void setClipboardString(String text){ + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable transferable = new StringSelection(text); + clipboard.setContents(transferable, null); + } } diff --git a/jadx-gui/src/main/resources/i18n/Messages_en_US.properties b/jadx-gui/src/main/resources/i18n/Messages_en_US.properties index 5fc77acffab..3ab52ca1202 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_en_US.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_en_US.properties @@ -38,6 +38,7 @@ search.match_case=Match Case search.whole_word=Whole word search.find=Find +tabs.copy_class_name=Copy Name tabs.close=Close tabs.closeOthers=Close Others tabs.closeAll=Close All diff --git a/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties b/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties index 9d7f053a6fc..6f675b95ec1 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_es_ES.properties @@ -38,6 +38,7 @@ search.match_case=Sensible a minúsculas/mayúsculas search.whole_word=Palabra entera search.find=Buscar +tabs.copy_class_name=Copy Name tabs.close=Cerrar tabs.closeOthers=Cerrar otros tabs.closeAll=Cerrar todo diff --git a/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties b/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties index 9056c494675..8b1e5df8f33 100644 --- a/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties +++ b/jadx-gui/src/main/resources/i18n/Messages_zh_CN.properties @@ -38,6 +38,7 @@ search.match_case=区分大小写 search.whole_word=整个词语 search.find=查询 +tabs.copy_class_name=复制类名 tabs.close=关闭 tabs.closeOthers=关闭其他文件 tabs.closeAll=全部关闭