Merge pull request #474 from ThexXTURBOXx/master

Update dependencies (again)
This commit is contained in:
Konloch 2023-07-20 17:37:50 -07:00 committed by GitHub
commit eda6416609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 238 additions and 331 deletions

45
pom.xml
View file

@ -13,42 +13,42 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Dependency versions --> <!-- Dependency versions -->
<annotations.version>24.0.0</annotations.version> <annotations.version>24.0.1</annotations.version>
<antlr4.version>4.9.3</antlr4.version> <antlr4.version>4.9.3</antlr4.version>
<apktool.version>2.7.0</apktool.version> <apktool.version>2.8.0</apktool.version>
<asm.version>9.4</asm.version> <asm.version>9.5</asm.version>
<bined.version>0.2.0</bined.version> <bined.version>0.2.0</bined.version>
<byteanalysis.version>1.0bcv</byteanalysis.version> <byteanalysis.version>1.0bcv</byteanalysis.version>
<cfr.version>0.152</cfr.version> <cfr.version>0.152</cfr.version>
<cloning.version>1.9.12</cloning.version> <cloning.version>1.9.12</cloning.version>
<commons-cli.version>1.5.0</commons-cli.version> <commons-cli.version>1.5.0</commons-cli.version>
<commons-codec.version>1.15</commons-codec.version> <commons-codec.version>1.16.0</commons-codec.version>
<commons-compiler.version>3.1.9</commons-compiler.version> <commons-compiler.version>3.1.10</commons-compiler.version>
<commons-compress.version>1.22</commons-compress.version> <commons-compress.version>1.23.0</commons-compress.version>
<commons-io.version>2.11.0</commons-io.version> <commons-io.version>2.13.0</commons-io.version>
<commons-lang3.version>3.12.0</commons-lang3.version> <commons-lang3.version>3.12.0</commons-lang3.version>
<commons-text.version>1.10.0</commons-text.version> <commons-text.version>1.10.0</commons-text.version>
<darklaf.version>3.0.2</darklaf.version> <darklaf.version>3.0.2</darklaf.version>
<darklaf-extensions-rsta.version>0.4.1</darklaf-extensions-rsta.version> <darklaf-extensions-rsta.version>0.4.1</darklaf-extensions-rsta.version>
<decompiler-fernflower.version>6.1.2.Final</decompiler-fernflower.version> <decompiler-fernflower.version>6.2.5.Final</decompiler-fernflower.version>
<dex2jar.version>v59</dex2jar.version> <dex2jar.version>v64</dex2jar.version>
<fernflower.version>e0d44f4</fernflower.version> <fernflower.version>e0d44f4</fernflower.version>
<gson.version>2.10.1</gson.version> <gson.version>2.10.1</gson.version>
<guava.version>31.1-jre</guava.version> <guava.version>32.1.1-jre</guava.version>
<httprequest.version>2.1.0</httprequest.version> <httprequest.version>2.2.0</httprequest.version>
<imgscalr-lib.version>4.2</imgscalr-lib.version> <imgscalr-lib.version>4.2</imgscalr-lib.version>
<jadx.version>1.4.5</jadx.version> <jadx.version>1.4.7</jadx.version>
<jd-gui.version>1.6.6bcv</jd-gui.version> <jd-gui.version>1.6.6bcv</jd-gui.version>
<jgraphx.version>3.4.1.3</jgraphx.version> <jgraphx.version>3.4.1.3</jgraphx.version>
<js.version>21.2.0</js.version> <js.version>21.2.0</js.version>
<objenesis.version>3.3</objenesis.version> <objenesis.version>3.3</objenesis.version>
<paged-data.version>0.2.0</paged-data.version> <paged-data.version>0.2.0</paged-data.version>
<procyon.version>0.6.0</procyon.version> <procyon.version>0.6.0</procyon.version>
<rsyntaxtextarea.version>3.3.2</rsyntaxtextarea.version> <rsyntaxtextarea.version>3.3.3</rsyntaxtextarea.version>
<semantic-version.version>2.1.1</semantic-version.version> <semantic-version.version>2.1.1</semantic-version.version>
<slf4j.version>2.0.6</slf4j.version> <slf4j.version>2.0.7</slf4j.version>
<smali.version>403e90375e</smali.version> <smali.version>3.0.3</smali.version>
<safeyaml.version>1.33.0</safeyaml.version> <safeyaml.version>1.34.1</safeyaml.version>
<treelayout.version>1.0.3</treelayout.version> <treelayout.version>1.0.3</treelayout.version>
<webp-imageio.version>0.2.2</webp-imageio.version> <webp-imageio.version>0.2.2</webp-imageio.version>
<xpp3.version>1.1.4c</xpp3.version> <xpp3.version>1.1.4c</xpp3.version>
@ -277,13 +277,13 @@
<version>${slf4j.version}</version> <version>${slf4j.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.iBotPeaches.smali</groupId> <groupId>com.android.tools.smali</groupId>
<artifactId>smali</artifactId> <artifactId>smali</artifactId>
<version>${smali.version}</version> <version>${smali.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.iBotPeaches.smali</groupId> <groupId>com.android.tools.smali</groupId>
<artifactId>baksmali</artifactId> <artifactId>smali-baksmali</artifactId>
<version>${smali.version}</version> <version>${smali.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@ -398,7 +398,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version> <version>3.11.0</version>
<configuration> <configuration>
<source>${maven.compiler.source}</source> <source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target> <target>${maven.compiler.target}</target>
@ -408,7 +408,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.0</version> <version>3.5.0</version>
<configuration> <configuration>
<source>${maven.compiler.source}</source> <source>${maven.compiler.source}</source>
</configuration> </configuration>
@ -416,7 +416,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version> <version>3.4.1</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@ -437,6 +437,7 @@
<exclude>META-INF/*LICENSE*</exclude> <exclude>META-INF/*LICENSE*</exclude>
<exclude>META-INF/*NOTICE*</exclude> <exclude>META-INF/*NOTICE*</exclude>
<exclude>META-INF/MANIFEST.MF</exclude> <exclude>META-INF/MANIFEST.MF</exclude>
<exclude>LICENSE</exclude>
</excludes> </excludes>
</filter> </filter>
<!-- Ignore all ASM-related files from d2j-external but MCTLE fix --> <!-- Ignore all ASM-related files from d2j-external but MCTLE fix -->

View file

@ -116,7 +116,7 @@ public class MainViewerGUI extends JFrame
public final SearchBoxPane searchBoxPane = new SearchBoxPane(); public final SearchBoxPane searchBoxPane = new SearchBoxPane();
public JSplitPane splitPane1; public JSplitPane splitPane1;
public JSplitPane splitPane2; public JSplitPane splitPane2;
//the root menu bar //the root menu bar
public final JMenuBar rootMenu = new JMenuBar(); public final JMenuBar rootMenu = new JMenuBar();
@ -351,9 +351,12 @@ public class MainViewerGUI extends JFrame
searchBoxPane.setPreferredSize(new Dimension(200, 50)); searchBoxPane.setPreferredSize(new Dimension(200, 50));
searchBoxPane.setMinimumSize(new Dimension(200, 50)); searchBoxPane.setMinimumSize(new Dimension(200, 50));
searchBoxPane.setMaximumSize(new Dimension(200, 2147483647)); searchBoxPane.setMaximumSize(new Dimension(200, 2147483647));
workPane.setPreferredSize(new Dimension(1500, 1000));
splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane); splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane);
splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane); splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane);
getContentPane().add(splitPane2); getContentPane().add(splitPane2);
splitPane2.setResizeWeight(0.05); splitPane2.setResizeWeight(0.05);
splitPane1.setResizeWeight(0.5); splitPane1.setResizeWeight(0.5);
@ -361,6 +364,7 @@ public class MainViewerGUI extends JFrame
uiComponents.add(resourcePane); uiComponents.add(resourcePane);
uiComponents.add(searchBoxPane); uiComponents.add(searchBoxPane);
uiComponents.add(workPane); uiComponents.add(workPane);
// uiComponents.add(hierarchy);
viewPane1.setDefault(); viewPane1.setDefault();
viewPane2.setDefault(); viewPane2.setDefault();

View file

@ -5,6 +5,7 @@ import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelListener;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
@ -13,6 +14,7 @@ import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.RTextScrollPane;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -50,9 +52,9 @@ import the.bytecode.club.bytecodeviewer.util.JTextAreaUtils;
* @author Konloch * @author Konloch
* @since 6/25/2021 * @since 6/25/2021
*/ */
public class SearchableRSyntaxTextArea extends RSyntaxTextArea public class SearchableRSyntaxTextArea extends RSyntaxTextArea {
{
private final RTextScrollPane scrollPane = new RTextScrollPane(this); private RTextScrollPane scrollPane = new RTextScrollPane(this);
private final JPanel searchPanel = new JPanel(new BorderLayout()); private final JPanel searchPanel = new JPanel(new BorderLayout());
private final JTextField searchInput = new JTextField(); private final JTextField searchInput = new JTextField();
private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE); private final JCheckBox caseSensitiveSearch = new TranslatedJCheckBox("Match case", TranslatedComponents.MATCH_CASE);
@ -62,30 +64,26 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
private final Color blackScrollBackground = new Color(0x232323); private final Color blackScrollBackground = new Color(0x232323);
private final Color blackScrollForeground = new Color(0x575859); private final Color blackScrollForeground = new Color(0x575859);
private Runnable onCtrlS; private Runnable onCtrlS;
public SearchableRSyntaxTextArea() public SearchableRSyntaxTextArea() {
{ if (Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK) {
if(Configuration.lafTheme == LAFTheme.HIGH_CONTRAST_DARK)
{
//this fixes the white border on the jScrollBar panes //this fixes the white border on the jScrollBar panes
scrollPane.getHorizontalScrollBar().setBackground(blackScrollBackground); scrollPane.getHorizontalScrollBar().setBackground(blackScrollBackground);
scrollPane.getHorizontalScrollBar().setForeground(blackScrollForeground); scrollPane.getHorizontalScrollBar().setForeground(blackScrollForeground);
scrollPane.getVerticalScrollBar().setBackground(blackScrollBackground); scrollPane.getVerticalScrollBar().setBackground(blackScrollBackground);
scrollPane.getVerticalScrollBar().setForeground(blackScrollForeground); scrollPane.getVerticalScrollBar().setForeground(blackScrollForeground);
} } else if (Configuration.lafTheme.isDark()) {
else if(Configuration.lafTheme.isDark())
{
//this fixes the white border on the jScrollBar panes //this fixes the white border on the jScrollBar panes
scrollPane.getHorizontalScrollBar().setBackground(darkScrollBackground); scrollPane.getHorizontalScrollBar().setBackground(darkScrollBackground);
scrollPane.getHorizontalScrollBar().setForeground(darkScrollForeground); scrollPane.getHorizontalScrollBar().setForeground(darkScrollForeground);
scrollPane.getVerticalScrollBar().setBackground(darkScrollBackground); scrollPane.getVerticalScrollBar().setBackground(darkScrollBackground);
scrollPane.getVerticalScrollBar().setForeground(darkScrollForeground); scrollPane.getVerticalScrollBar().setForeground(darkScrollForeground);
} }
setAntiAliasingEnabled(true); setAntiAliasingEnabled(true);
scrollPane.setColumnHeaderView(searchPanel); scrollPane.setColumnHeaderView(searchPanel);
JButton searchNext = new JButton(); JButton searchNext = new JButton();
JButton searchPrev = new JButton(); JButton searchPrev = new JButton();
JPanel buttonPane = new JPanel(new BorderLayout()); JPanel buttonPane = new JPanel(new BorderLayout());
@ -96,90 +94,84 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
searchPanel.add(buttonPane, BorderLayout.WEST); searchPanel.add(buttonPane, BorderLayout.WEST);
searchPanel.add(searchInput, BorderLayout.CENTER); searchPanel.add(searchInput, BorderLayout.CENTER);
searchPanel.add(caseSensitiveSearch, BorderLayout.EAST); searchPanel.add(caseSensitiveSearch, BorderLayout.EAST);
searchNext.addActionListener(arg0 -> search(searchInput.getText(), true, caseSensitiveSearch.isSelected())); searchNext.addActionListener(arg0 -> search(searchInput.getText(), true, caseSensitiveSearch.isSelected()));
searchPrev.addActionListener(arg0 -> search(searchInput.getText(), false, caseSensitiveSearch.isSelected())); searchPrev.addActionListener(arg0 -> search(searchInput.getText(), false, caseSensitiveSearch.isSelected()));
searchInput.addKeyListener(new ReleaseKeyListener(keyEvent -> searchInput.addKeyListener(new ReleaseKeyListener(keyEvent ->
{ {
if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
search(searchInput.getText(), true, caseSensitiveSearch.isSelected()); search(searchInput.getText(), true, caseSensitiveSearch.isSelected());
})); }));
addKeyListener(new PressKeyListener(keyEvent -> addKeyListener(new PressKeyListener(keyEvent ->
{ {
if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) if ((keyEvent.getKeyCode() == KeyEvent.VK_F) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0))
searchInput.requestFocus(); searchInput.requestFocus();
if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) if (onCtrlS != null && (keyEvent.getKeyCode() == KeyEvent.VK_S) && ((keyEvent.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0)) {
{
onCtrlS.run(); onCtrlS.run();
return; return;
} }
GlobalHotKeys.keyPressed(keyEvent); GlobalHotKeys.keyPressed(keyEvent);
})); }));
final Font newFont = getFont().deriveFont((float) BytecodeViewer.viewer.getFontSize()); final Font newFont = getFont().deriveFont((float) BytecodeViewer.viewer.getFontSize());
//set number-bar font //set number-bar font
setFont(newFont); setFont(newFont);
SwingUtilities.invokeLater(()-> { SwingUtilities.invokeLater(() -> {
//attach CTRL + Mouse Wheel Zoom //attach CTRL + Mouse Wheel Zoom
attachCtrlMouseWheelZoom(); attachCtrlMouseWheelZoom();
//set text font //set text font
setFont(newFont); setFont(newFont);
}); });
} }
public void search(String search, boolean forwardSearchDirection, boolean caseSensitiveSearch) public void search(String search, boolean forwardSearchDirection, boolean caseSensitiveSearch) {
{
JTextAreaUtils.search(this, search, forwardSearchDirection, caseSensitiveSearch); JTextAreaUtils.search(this, search, forwardSearchDirection, caseSensitiveSearch);
} }
public void highlight(String pattern, boolean caseSensitiveSearch) public void highlight(String pattern, boolean caseSensitiveSearch) {
{
JTextAreaUtils.highlight(this, pattern, caseSensitiveSearch); JTextAreaUtils.highlight(this, pattern, caseSensitiveSearch);
} }
public void attachCtrlMouseWheelZoom() public void attachCtrlMouseWheelZoom() {
{ scrollPane.addMouseWheelListener(e -> {
//get the existing scroll event if (getText().isEmpty()) return;
MouseWheelListener ogListener = scrollPane.getMouseWheelListeners().length > 0 ? if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
scrollPane.getMouseWheelListeners()[0] : null;
//remove the existing event
if(ogListener != null)
scrollPane.removeMouseWheelListener(ogListener);
//add a new event
scrollPane.addMouseWheelListener(e ->
{
if (getText().isEmpty())
return;
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)
{
Font font = getFont(); Font font = getFont();
int size = font.getSize(); int size = font.getSize();
if (e.getWheelRotation() > 0)
if (e.getWheelRotation() > 0) //Up
setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2)); setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2));
else //Down else
setFont(new Font(font.getName(), font.getStyle(), ++size)); setFont(new Font(font.getName(), font.getStyle(), ++size));
e.consume(); e.consume();
} }
else if(ogListener != null)
{
ogListener.mouseWheelMoved(e);
}
}); });
scrollPane = new RTextScrollPane() {
@Override
protected void processMouseWheelEvent(MouseWheelEvent event) {
if (!isWheelScrollingEnabled()) {
if (getParent() != null) {
getParent().dispatchEvent(SwingUtilities.convertMouseEvent(this, event, getParent()));
return;
}
}
super.processMouseWheelEvent(event);
}
};
scrollPane.setWheelScrollingEnabled(false);
} }
public String getLineText(int line) { public String getLineText(int line) {
try { try {
if (line < getLineCount()) { if (line < getLineCount()) {
@ -187,42 +179,36 @@ public class SearchableRSyntaxTextArea extends RSyntaxTextArea
int end = getLineEndOffset(line); int end = getLineEndOffset(line);
return getText(start, end - start).trim(); return getText(start, end - start).trim();
} }
} catch (BadLocationException ignored) { } } catch (BadLocationException ignored) {
}
return ""; return "";
} }
public void setOnCtrlS(Runnable onCtrlS) public void setOnCtrlS(Runnable onCtrlS) {
{
this.onCtrlS = onCtrlS; this.onCtrlS = onCtrlS;
} }
public RTextScrollPane getScrollPane() public RTextScrollPane getScrollPane() {
{
return scrollPane; return scrollPane;
} }
public JPanel getSearchPanel() public JPanel getSearchPanel() {
{
return searchPanel; return searchPanel;
} }
public JTextField getSearchInput() public JTextField getSearchInput() {
{
return searchInput; return searchInput;
} }
public JCheckBox getCaseSensitiveSearch() public JCheckBox getCaseSensitiveSearch() {
{
return caseSensitiveSearch; return caseSensitiveSearch;
} }
public JLabel getTitleHeader() public JLabel getTitleHeader() {
{
return titleHeader; return titleHeader;
} }
public Runnable getOnCtrlS() public Runnable getOnCtrlS() {
{
return onCtrlS; return onCtrlS;
} }
} }

View file

@ -1,24 +1,16 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer; package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import com.android.tools.r8.internal.Cl;
import com.github.weisj.darklaf.components.CloseButton; import com.github.weisj.darklaf.components.CloseButton;
import com.github.weisj.darklaf.listener.MouseClickListener;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.MouseClickedListener; import the.bytecode.club.bytecodeviewer.gui.components.listeners.MouseClickedListener;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class CloseButtonComponent extends JPanel { public class CloseButtonComponent extends JPanel {
private final JTabbedPane pane; private final JTabbedPane pane;
String title = "";
public CloseButtonComponent(final JTabbedPane pane) { public CloseButtonComponent(final JTabbedPane pane) {
super(new FlowLayout(FlowLayout.LEFT, 0, 0)); super(new FlowLayout(FlowLayout.LEFT, 0, 0));
if (pane == null) { if (pane == null) {

View file

@ -1,5 +1,6 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer; package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import javax.swing.*; import javax.swing.*;
@ -16,106 +17,75 @@ public class DraggableTabbedPane extends JTabbedPane {
private static final int LINEWIDTH = 3; private static final int LINEWIDTH = 3;
private static final String NAME = "TabTransferData"; private static final String NAME = "TabTransferData";
private final DataFlavor FLAVOR = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, NAME); private final DataFlavor FLAVOR = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType, NAME);
private static GhostGlassPane s_glassPane = new GhostGlassPane(); private static final GhostGlassPane s_glassPane = new GhostGlassPane();
private boolean m_isDrawRect = false; private boolean m_isDrawRect = false;
private final Rectangle2D m_lineRect = new Rectangle2D.Double(); private final Rectangle2D m_lineRect = new Rectangle2D.Double();
private final Color m_lineColor = new Color(0, 100, 255); private final Color m_lineColor = new Color(0, 100, 255);
private TabAcceptor m_acceptor = null; private TabAcceptor m_acceptor;
public DraggableTabbedPane() { public DraggableTabbedPane() {
super(SwingConstants.TOP, SCROLL_TAB_LAYOUT); super(SwingConstants.TOP, SCROLL_TAB_LAYOUT);
this.putClientProperty(DarkTabbedPaneUI.KEY_DND, true);
final DragSourceListener dsl = new DragSourceListener() { /*if (!Configuration.showDarkLAFComponentIcons) {
public void dragEnter(DragSourceDragEvent e) { final DragSourceListener dsl = new DragSourceListener() {
e.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop); public void dragEnter(DragSourceDragEvent e) {
} e.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
public void dragExit(DragSourceEvent e) {
e.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false;
s_glassPane.setPoint(new Point(-1000, -1000));
s_glassPane.repaint();
}
public void dragOver(DragSourceDragEvent e) {
//e.getLocation()
//This method returns a Point indicating the cursor location in screen coordinates at the moment
TabTransferData data = getTabTransferData(e);
if (data == null) {
e.getDragSourceContext().setCursor(
DragSource.DefaultMoveNoDrop);
return;
} // if
/*
Point tabPt = e.getLocation();
SwingUtilities.convertPointFromScreen(tabPt, DnDTabbedPane.this);
if (DnDTabbedPane.this.contains(tabPt)) {
int targetIdx = getTargetTabIndex(tabPt);
int sourceIndex = data.getTabIndex();
if (getTabAreaBound().contains(tabPt)
&& (targetIdx >= 0)
&& (targetIdx != sourceIndex)
&& (targetIdx != sourceIndex + 1)) {
e.getDragSourceContext().setCursor(
DragSource.DefaultMoveDrop);
return;
} // if
e.getDragSourceContext().setCursor(
DragSource.DefaultMoveNoDrop);
return;
} // if
*/
e.getDragSourceContext().setCursor(
DragSource.DefaultMoveDrop);
}
public void dragDropEnd(DragSourceDropEvent e) {
m_isDrawRect = false;
m_lineRect.setRect(0, 0, 0, 0);
// m_dragTabIndex = -1;
if (hasGhost()) {
s_glassPane.setVisible(false);
s_glassPane.setImage(null);
} }
}
public void dropActionChanged(DragSourceDragEvent e) { public void dragExit(DragSourceEvent e) {
} e.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
}; m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false;
s_glassPane.setPoint(new Point(-1000, -1000));
s_glassPane.repaint();
}
final DragGestureListener dgl = e -> { public void dragOver(DragSourceDragEvent e) {
// System.out.println("dragGestureRecognized"); TabTransferData data = getTabTransferData(e);
if (data == null) {
e.getDragSourceContext().setCursor(
DragSource.DefaultMoveNoDrop);
return;
}
Point tabPt = e.getDragOrigin(); e.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
int dragTabIndex = indexAtLocation(tabPt.x, tabPt.y); }
if (dragTabIndex < 0) {
return;
} // if
initGlassPane(e.getComponent(), e.getDragOrigin(), dragTabIndex); public void dragDropEnd(DragSourceDropEvent e) {
try { m_isDrawRect = false;
e.startDrag(DragSource.DefaultMoveDrop, m_lineRect.setRect(0, 0, 0, 0);
new TabTransferable(DraggableTabbedPane.this, dragTabIndex), dsl); if (hasGhost()) {
} catch (InvalidDnDOperationException idoe) { s_glassPane.setVisible(false);
idoe.printStackTrace(); s_glassPane.setImage(null);
} }
}; }
//dropTarget = public void dropActionChanged(DragSourceDragEvent e) {
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, }
new CDropTargetListener(), true); };
new DragSource().createDefaultDragGestureRecognizer(this,
DnDConstants.ACTION_COPY_OR_MOVE, dgl); final DragGestureListener dgl = e -> {
m_acceptor = (a_component, a_index) -> true; Point tabPt = e.getDragOrigin();
int dragTabIndex = indexAtLocation(tabPt.x, tabPt.y);
if (dragTabIndex < 0) {
return;
}
initGlassPane(e.getComponent(), e.getDragOrigin(), dragTabIndex);
try {
e.startDrag(DragSource.DefaultMoveDrop, new TabTransferable(DraggableTabbedPane.this, dragTabIndex), dsl);
} catch (InvalidDnDOperationException idoe) {
idoe.printStackTrace();
}
};
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new CDropTargetListener(), true);
new DragSource().createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dgl);
m_acceptor = (a_component, a_index) -> true;
}*/
} }
public TabAcceptor getAcceptor() { public TabAcceptor getAcceptor() {
@ -131,7 +101,7 @@ public class DraggableTabbedPane extends JTabbedPane {
if (!t.isDataFlavorSupported(FLAVOR)) return null; if (!t.isDataFlavorSupported(FLAVOR)) return null;
try { try {
return (TabTransferData) t.getTransferData(FLAVOR); return (TabTransferData) a_event.getTransferable().getTransferData(FLAVOR);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -144,7 +114,7 @@ public class DraggableTabbedPane extends JTabbedPane {
if (!t.isDataFlavorSupported(FLAVOR)) return null; if (!t.isDataFlavorSupported(FLAVOR)) return null;
try { try {
return (TabTransferData) t.getTransferData(FLAVOR); return (TabTransferData) a_event.getTransferable().getTransferData(FLAVOR);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -157,7 +127,7 @@ public class DraggableTabbedPane extends JTabbedPane {
if (!t.isDataFlavorSupported(FLAVOR)) return null; if (!t.isDataFlavorSupported(FLAVOR)) return null;
try { try {
return (TabTransferData) t.getTransferData(FLAVOR); return (TabTransferData) a_event.getDragSourceContext().getTransferable().getTransferData(FLAVOR);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -175,7 +145,6 @@ public class DraggableTabbedPane extends JTabbedPane {
public Object getTransferData(DataFlavor flavor) { public Object getTransferData(DataFlavor flavor) {
return m_data; return m_data;
// return DnDTabbedPane.this;
} }
public DataFlavor[] getTransferDataFlavors() { public DataFlavor[] getTransferDataFlavors() {
@ -246,27 +215,23 @@ public class DraggableTabbedPane extends JTabbedPane {
retval.y -= s_glassPane.getGhostHeight() / 2; retval.y -= s_glassPane.getGhostHeight() / 2;
} }
break; break;
} // switch }
retval = SwingUtilities.convertPoint(DraggableTabbedPane.this, retval = SwingUtilities.convertPoint(DraggableTabbedPane.this, retval, s_glassPane);
retval, s_glassPane);
return retval; return retval;
} }
class CDropTargetListener implements DropTargetListener { class CDropTargetListener implements DropTargetListener {
public void dragEnter(DropTargetDragEvent e) { public void dragEnter(DropTargetDragEvent e) {
// System.out.println("DropTarget.dragEnter: " + DnDTabbedPane.this);
if (isDragAcceptable(e)) { if (isDragAcceptable(e)) {
e.acceptDrag(e.getDropAction()); e.acceptDrag(e.getDropAction());
} else { } else {
e.rejectDrag(); e.rejectDrag();
} // if }
} }
public void dragExit(DropTargetEvent e) { public void dragExit(DropTargetEvent e) {
// System.out.println("DropTarget.dragExit: " + DnDTabbedPane.this);
m_isDrawRect = false; m_isDrawRect = false;
} }
@ -282,7 +247,7 @@ public class DraggableTabbedPane extends JTabbedPane {
initTargetLeftRightLine(getTargetTabIndex(e.getLocation()), data); initTargetLeftRightLine(getTargetTabIndex(e.getLocation()), data);
} else { } else {
initTargetTopBottomLine(getTargetTabIndex(e.getLocation()), data); initTargetTopBottomLine(getTargetTabIndex(e.getLocation()), data);
} // if-else }
repaint(); repaint();
if (hasGhost()) { if (hasGhost()) {
@ -292,14 +257,12 @@ public class DraggableTabbedPane extends JTabbedPane {
} }
public void drop(DropTargetDropEvent a_event) { public void drop(DropTargetDropEvent a_event) {
// System.out.println("DropTarget.drop: " + DnDTabbedPane.this);
if (isDropAcceptable(a_event)) { if (isDropAcceptable(a_event)) {
convertTab(getTabTransferData(a_event), getTargetTabIndex(a_event.getLocation())); convertTab(getTabTransferData(a_event), getTargetTabIndex(a_event.getLocation()));
a_event.dropComplete(true); a_event.dropComplete(true);
} else { } else {
a_event.dropComplete(false); a_event.dropComplete(false);
} // if-else }
m_isDrawRect = false; m_isDrawRect = false;
repaint(); repaint();
@ -311,12 +274,12 @@ public class DraggableTabbedPane extends JTabbedPane {
Transferable t = e.getTransferable(); Transferable t = e.getTransferable();
if (t == null) { if (t == null) {
return false; return false;
} // if }
DataFlavor[] flavor = e.getCurrentDataFlavors(); DataFlavor[] flavor = e.getCurrentDataFlavors();
if (!t.isDataFlavorSupported(flavor[0])) { if (!t.isDataFlavorSupported(flavor[0])) {
return false; return false;
} // if }
TabTransferData data = getTabTransferData(e); TabTransferData data = getTabTransferData(e);
if (data == null) return false; if (data == null) return false;
@ -324,13 +287,13 @@ public class DraggableTabbedPane extends JTabbedPane {
if (DraggableTabbedPane.this == data.getTabbedPane() if (DraggableTabbedPane.this == data.getTabbedPane()
&& data.getTabIndex() >= 0) { && data.getTabIndex() >= 0) {
return true; return true;
} // if }
if (DraggableTabbedPane.this != data.getTabbedPane()) { if (DraggableTabbedPane.this != data.getTabbedPane()) {
if (m_acceptor != null) { if (m_acceptor != null) {
return m_acceptor.isDropAcceptable(data.getTabbedPane(), data.getTabIndex()); return m_acceptor.isDropAcceptable(data.getTabbedPane(), data.getTabIndex());
} // if }
} // if }
return false; return false;
} }
@ -339,12 +302,12 @@ public class DraggableTabbedPane extends JTabbedPane {
Transferable t = e.getTransferable(); Transferable t = e.getTransferable();
if (t == null) { if (t == null) {
return false; return false;
} // if }
DataFlavor[] flavor = e.getCurrentDataFlavors(); DataFlavor[] flavor = e.getCurrentDataFlavors();
if (!t.isDataFlavorSupported(flavor[0])) { if (!t.isDataFlavorSupported(flavor[0])) {
return false; return false;
} // if }
TabTransferData data = getTabTransferData(e); TabTransferData data = getTabTransferData(e);
if (data == null) return false; if (data == null) return false;
@ -352,13 +315,13 @@ public class DraggableTabbedPane extends JTabbedPane {
if (DraggableTabbedPane.this == data.getTabbedPane() if (DraggableTabbedPane.this == data.getTabbedPane()
&& data.getTabIndex() >= 0) { && data.getTabIndex() >= 0) {
return true; return true;
} // if }
if (DraggableTabbedPane.this != data.getTabbedPane()) { if (DraggableTabbedPane.this != data.getTabbedPane()) {
if (m_acceptor != null) { if (m_acceptor != null) {
return m_acceptor.isDropAcceptable(data.getTabbedPane(), data.getTabIndex()); return m_acceptor.isDropAcceptable(data.getTabbedPane(), data.getTabIndex());
} // if }
} // if }
return false; return false;
} }
@ -387,20 +350,20 @@ public class DraggableTabbedPane extends JTabbedPane {
// if the pane is empty, the target index is always zero. // if the pane is empty, the target index is always zero.
if (getTabCount() == 0) { if (getTabCount() == 0) {
return 0; return 0;
} // if }
for (int i = 0; i < getTabCount(); i++) { for (int i = 0; i < getTabCount(); i++) {
Rectangle r = getBoundsAt(i); Rectangle r = getBoundsAt(i);
if (isTopOrBottom) { if (isTopOrBottom) {
r.setRect(r.x - r.width / 2, r.y, r.width, r.height); r.setRect(r.x - r.width / 2D, r.y, r.width, r.height);
} else { } else {
r.setRect(r.x, r.y - r.height / 2, r.width, r.height); r.setRect(r.x, r.y - r.height / 2D, r.width, r.height);
} // if-else }
if (r.contains(a_point)) { if (r.contains(a_point)) {
return i; return i;
} // if }
} // for }
Rectangle r = getBoundsAt(getTabCount() - 1); Rectangle r = getBoundsAt(getTabCount() - 1);
if (isTopOrBottom) { if (isTopOrBottom) {
@ -409,18 +372,19 @@ public class DraggableTabbedPane extends JTabbedPane {
} else { } else {
int y = r.y + r.height / 2; int y = r.y + r.height / 2;
r.setRect(r.x, y, r.width, getHeight() - y); r.setRect(r.x, y, r.width, getHeight() - y);
} // if-else }
return r.contains(a_point) ? getTabCount() : -1; return r.contains(a_point) ? getTabCount() : -1;
} }
private void convertTab(TabTransferData a_data, int a_targetIndex) { private void convertTab(TabTransferData a_data, int a_targetIndex) {
if (a_data == null) return; if (a_data == null) return;
DraggableTabbedPane source = a_data.getTabbedPane(); DraggableTabbedPane source = a_data.getTabbedPane();
int sourceIndex = a_data.getTabIndex(); int sourceIndex = a_data.getTabIndex();
if (sourceIndex < 0) { if (sourceIndex < 0) {
return; return;
} // if }
Component cmp = source.getComponentAt(sourceIndex); Component cmp = source.getComponentAt(sourceIndex);
String str = source.getTitleAt(sourceIndex); String str = source.getTitleAt(sourceIndex);
@ -432,34 +396,28 @@ public class DraggableTabbedPane extends JTabbedPane {
} else { } else {
if (a_targetIndex < 0) { if (a_targetIndex < 0) {
a_targetIndex = 0; a_targetIndex = 0;
} // if }
insertTab(str, null, cmp, null, a_targetIndex); insertTab(str, null, cmp, null, a_targetIndex);
}
} // if
setSelectedComponent(cmp); setSelectedComponent(cmp);
// System.out.println("press="+sourceIndex+" next="+a_targetIndex);
return; return;
} // if }
if (a_targetIndex < 0 || sourceIndex == a_targetIndex) { if (a_targetIndex < 0 || sourceIndex == a_targetIndex) {
//System.out.println("press="+prev+" next="+next);
return; return;
} // if }
if (a_targetIndex == getTabCount()) { if (a_targetIndex == getTabCount()) {
//System.out.println("last: press="+prev+" next="+next);
source.remove(sourceIndex); source.remove(sourceIndex);
addTab(str, cmp); addTab(str, cmp);
setSelectedIndex(getTabCount() - 1); setSelectedIndex(getTabCount() - 1);
} else if (sourceIndex > a_targetIndex) { } else if (sourceIndex > a_targetIndex) {
//System.out.println(" >: press="+prev+" next="+next);
source.remove(sourceIndex); source.remove(sourceIndex);
insertTab(str, null, cmp, null, a_targetIndex); insertTab(str, null, cmp, null, a_targetIndex);
setSelectedIndex(a_targetIndex); setSelectedIndex(a_targetIndex);
} else { } else {
//System.out.println(" <: press="+prev+" next="+next);
source.remove(sourceIndex); source.remove(sourceIndex);
insertTab(str, null, cmp, null, a_targetIndex - 1); insertTab(str, null, cmp, null, a_targetIndex - 1);
setSelectedIndex(a_targetIndex - 1); setSelectedIndex(a_targetIndex - 1);
@ -471,31 +429,27 @@ public class DraggableTabbedPane extends JTabbedPane {
m_lineRect.setRect(0, 0, 0, 0); m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false; m_isDrawRect = false;
return; return;
} // if }
if (a_data == null) return;
if ((a_data.getTabbedPane() == this) if (a_data == null) return;
&& (a_data.getTabIndex() == next
|| next - a_data.getTabIndex() == 1)) { if ((a_data.getTabbedPane() == this) && (a_data.getTabIndex() == next || next - a_data.getTabIndex() == 1)) {
m_lineRect.setRect(0, 0, 0, 0); m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false; m_isDrawRect = false;
} else if (getTabCount() == 0) { } else if (getTabCount() == 0) {
m_lineRect.setRect(0, 0, 0, 0); m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false; m_isDrawRect = false;
return;
} else if (next == 0) { } else if (next == 0) {
Rectangle rect = getBoundsAt(0); Rectangle rect = getBoundsAt(0);
m_lineRect.setRect(-LINEWIDTH / 2, rect.y, LINEWIDTH, rect.height); m_lineRect.setRect(-LINEWIDTH / 2D, rect.y, LINEWIDTH, rect.height);
m_isDrawRect = true; m_isDrawRect = true;
} else if (next == getTabCount()) { } else if (next == getTabCount()) {
Rectangle rect = getBoundsAt(getTabCount() - 1); Rectangle rect = getBoundsAt(getTabCount() - 1);
m_lineRect.setRect(rect.x + rect.width - LINEWIDTH / 2, rect.y, m_lineRect.setRect(rect.x + rect.width - LINEWIDTH / 2D, rect.y, LINEWIDTH, rect.height);
LINEWIDTH, rect.height);
m_isDrawRect = true; m_isDrawRect = true;
} else { } else {
Rectangle rect = getBoundsAt(next - 1); Rectangle rect = getBoundsAt(next - 1);
m_lineRect.setRect(rect.x + rect.width - LINEWIDTH / 2, rect.y, m_lineRect.setRect(rect.x + rect.width - LINEWIDTH / 2D, rect.y, LINEWIDTH, rect.height);
LINEWIDTH, rect.height);
m_isDrawRect = true; m_isDrawRect = true;
} }
} }
@ -505,12 +459,11 @@ public class DraggableTabbedPane extends JTabbedPane {
m_lineRect.setRect(0, 0, 0, 0); m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false; m_isDrawRect = false;
return; return;
} // if }
if (a_data == null) return; if (a_data == null) return;
if ((a_data.getTabbedPane() == this) if ((a_data.getTabbedPane() == this) && (a_data.getTabIndex() == next || next - a_data.getTabIndex() == 1)) {
&& (a_data.getTabIndex() == next
|| next - a_data.getTabIndex() == 1)) {
m_lineRect.setRect(0, 0, 0, 0); m_lineRect.setRect(0, 0, 0, 0);
m_isDrawRect = false; m_isDrawRect = false;
} else if (getTabCount() == 0) { } else if (getTabCount() == 0) {
@ -519,33 +472,29 @@ public class DraggableTabbedPane extends JTabbedPane {
return; return;
} else if (next == getTabCount()) { } else if (next == getTabCount()) {
Rectangle rect = getBoundsAt(getTabCount() - 1); Rectangle rect = getBoundsAt(getTabCount() - 1);
m_lineRect.setRect(rect.x, rect.y + rect.height - LINEWIDTH / 2, m_lineRect.setRect(rect.x, rect.y + rect.height - LINEWIDTH / 2D, rect.width, LINEWIDTH);
rect.width, LINEWIDTH);
m_isDrawRect = true; m_isDrawRect = true;
} else if (next == 0) { } else if (next == 0) {
Rectangle rect = getBoundsAt(0); Rectangle rect = getBoundsAt(0);
m_lineRect.setRect(rect.x, -LINEWIDTH / 2, rect.width, LINEWIDTH); m_lineRect.setRect(rect.x, -LINEWIDTH / 2D, rect.width, LINEWIDTH);
m_isDrawRect = true; m_isDrawRect = true;
} else { } else {
Rectangle rect = getBoundsAt(next - 1); Rectangle rect = getBoundsAt(next - 1);
m_lineRect.setRect(rect.x, rect.y + rect.height - LINEWIDTH / 2, m_lineRect.setRect(rect.x, rect.y + rect.height - LINEWIDTH / 2D, rect.width, LINEWIDTH);
rect.width, LINEWIDTH);
m_isDrawRect = true; m_isDrawRect = true;
} }
} }
private void initGlassPane(Component c, Point tabPt, int a_tabIndex) { private void initGlassPane(Component c, Point tabPt, int a_tabIndex) {
//Point p = (Point) pt.clone();
getRootPane().setGlassPane(s_glassPane); getRootPane().setGlassPane(s_glassPane);
if (hasGhost()) { if (hasGhost()) {
Rectangle rect = getBoundsAt(a_tabIndex); Rectangle rect = getBoundsAt(a_tabIndex);
BufferedImage image = new BufferedImage(c.getWidth(), BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
c.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics(); Graphics g = image.getGraphics();
c.paint(g); c.paint(g);
image = image.getSubimage(rect.x, rect.y, rect.width, rect.height); image = image.getSubimage(rect.x, rect.y, rect.width, rect.height);
s_glassPane.setImage(image); s_glassPane.setImage(image);
} // if }
s_glassPane.setPoint(buildGhostLocation(tabPt)); s_glassPane.setPoint(buildGhostLocation(tabPt));
s_glassPane.setVisible(true); s_glassPane.setVisible(true);
@ -563,7 +512,7 @@ public class DraggableTabbedPane extends JTabbedPane {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.setPaint(m_lineColor); g2.setPaint(m_lineColor);
g2.fill(m_lineRect); g2.fill(m_lineRect);
} // if }
} }
public interface TabAcceptor { public interface TabAcceptor {
@ -577,7 +526,7 @@ class GhostGlassPane extends JPanel {
public static final long serialVersionUID = 1L; public static final long serialVersionUID = 1L;
private final AlphaComposite m_composite; private final AlphaComposite m_composite;
private Point m_location = new Point(0, 0); private final Point m_location = new Point(0, 0);
private BufferedImage m_draggingGhost = null; private BufferedImage m_draggingGhost = null;
@ -598,7 +547,7 @@ class GhostGlassPane extends JPanel {
public int getGhostWidth() { public int getGhostWidth() {
if (m_draggingGhost == null) { if (m_draggingGhost == null) {
return 0; return 0;
} // if }
return m_draggingGhost.getWidth(this); return m_draggingGhost.getWidth(this);
} }
@ -606,7 +555,7 @@ class GhostGlassPane extends JPanel {
public int getGhostHeight() { public int getGhostHeight() {
if (m_draggingGhost == null) { if (m_draggingGhost == null) {
return 0; return 0;
} // if }
return m_draggingGhost.getHeight(this); return m_draggingGhost.getHeight(this);
} }
@ -614,7 +563,7 @@ class GhostGlassPane extends JPanel {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
if (m_draggingGhost == null) { if (m_draggingGhost == null) {
return; return;
} // if }
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.setComposite(m_composite); g2.setComposite(m_composite);

View file

@ -1,22 +1,13 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer; package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import com.github.weisj.darklaf.components.CloseButton;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation; import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation;
import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel; import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel;
import the.bytecode.club.bytecodeviewer.gui.components.listeners.MouseClickedListener;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
import the.bytecode.club.bytecodeviewer.gui.util.DelayTabbedPaneThread; import the.bytecode.club.bytecodeviewer.gui.util.DelayTabbedPaneThread;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -56,7 +47,7 @@ public class TabbedPane extends JPanel {
public final static MouseListener buttonHoverAnimation = new ButtonHoverAnimation(); public final static MouseListener buttonHoverAnimation = new ButtonHoverAnimation();
public static final Color BLANK_COLOR = new Color(0, 0, 0, 0); public static final Color BLANK_COLOR = new Color(0, 0, 0, 0);
public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName, String name, final DraggableTabbedPane existingTabs, ResourceViewer resource) { public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName, String name, final JTabbedPane existingTabs, ResourceViewer resource) {
// unset default FlowLayout' gaps // unset default FlowLayout' gaps
super(new FlowLayout(FlowLayout.LEFT, 0, 0)); super(new FlowLayout(FlowLayout.LEFT, 0, 0));
@ -80,33 +71,5 @@ public class TabbedPane extends JPanel {
setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
} }
public void onMousePressed(MouseEvent e)
{
BytecodeViewer.viewer.workPane.tabs.dispatchEvent(e);
if(e.getButton() == 1)
{
startedDragging = System.currentTimeMillis();
//dragging = true;
if (probablyABadIdea != null)
probablyABadIdea.stopped = true;
probablyABadIdea = new DelayTabbedPaneThread(TabbedPane.this);
probablyABadIdea.start();
repaint();
Rectangle bounds = new Rectangle(e.getX(), e.getY(), e.getX() + this.getX(), e.getY());
for(int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
{
Component c = BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i);
if(c != null && bounds.intersects(c.getBounds()))
BytecodeViewer.viewer.workPane.tabs.setSelectedIndex(i);
}
}
}
private static final long serialVersionUID = -4774885688297538774L; private static final long serialVersionUID = -4774885688297538774L;
/*public int getTabIndex() {
return tabs.indexOfTabComponent(this);
}*/
} }

View file

@ -1,16 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui.resourceviewer; package the.bytecode.club.bytecodeviewer.gui.resourceviewer;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import com.github.weisj.darklaf.components.CloseButton;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
@ -22,6 +11,13 @@ import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton;
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.HashSet;
import java.util.Set;
import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
/*************************************************************************** /***************************************************************************
@ -52,7 +48,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
public class Workspace extends TranslatedVisibleComponent { public class Workspace extends TranslatedVisibleComponent {
public final DraggableTabbedPane tabs; public JTabbedPane tabs;
public final JPanel buttonPanel; public final JPanel buttonPanel;
public final JButton refreshClass; public final JButton refreshClass;
public final Set<String> openedTabs = new HashSet<>(); public final Set<String> openedTabs = new HashSet<>();
@ -193,7 +189,7 @@ public class Workspace extends TranslatedVisibleComponent {
//search through each tab //search through each tab
for (int i = 0; i < tabs.getTabCount(); i++) { for (int i = 0; i < tabs.getTabCount(); i++) {
//find the matching resource and open it //find the matching resource and open it
ResourceViewer tab = (ResourceViewer) tabs.getComponentAt(i); ResourceViewer tab = (ResourceViewer) tabs.getComponentAt(i);
if (tab.resource.workingName.equals(workingName)) { if (tab.resource.workingName.equals(workingName)) {
tabs.setSelectedIndex(i); tabs.setSelectedIndex(i);
break; break;

View file

@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJLabel;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.Arrays;
import java.util.List; import java.util.List;
/*************************************************************************** /***************************************************************************
@ -67,11 +68,13 @@ public class MemberWithAnnotationSearch implements SearchPanel {
if (srchText.isEmpty()) return; if (srchText.isEmpty()) return;
node.fields.stream().filter(fn -> hasAnnotation(srchText, fn.invisibleAnnotations, fn.visibleAnnotations)).forEach(fn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, null, fn, fn.name + " " + fn.desc, ""))); node.fields.stream().filter(fn -> hasAnnotation(srchText, Arrays.asList(fn.invisibleAnnotations, fn.visibleAnnotations)))
node.methods.stream().filter(mn -> hasAnnotation(srchText, mn.invisibleAnnotations, mn.visibleAnnotations)).forEach(mn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, mn, null, mn.name + mn.desc, ""))); .forEach(fn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, null, fn, fn.name + " " + fn.desc, "")));
node.methods.stream().filter(mn -> hasAnnotation(srchText, Arrays.asList(mn.invisibleAnnotations, mn.visibleAnnotations)))
.forEach(mn -> BytecodeViewer.viewer.searchBoxPane.treeRoot.add(new LDCSearchTreeNodeResult(container, resourceWorkingName, node, mn, null, mn.name + mn.desc, "")));
} }
public static boolean hasAnnotation(String annotation, List<AnnotationNode>... annoLists) { public static boolean hasAnnotation(String annotation, List<List<AnnotationNode>> annoLists) {
if (annoLists == null) return false; if (annoLists == null) return false;
for (List<AnnotationNode> annos : annoLists) { for (List<AnnotationNode> annos : annoLists) {
if (annos == null) continue; if (annos == null) continue;

View file

@ -1,6 +1,10 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
import com.googlecode.d2j.dex.Dex2jar; import com.googlecode.d2j.dex.Dex2jar;
import com.googlecode.d2j.dex.DexExceptionHandler;
import com.googlecode.d2j.Method;
import com.googlecode.d2j.node.DexMethodNode;
import org.objectweb.asm.MethodVisitor;
import java.io.File; import java.io.File;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -38,7 +42,16 @@ public class Dex2Jar {
*/ */
public static synchronized void dex2Jar(File input, File output) { public static synchronized void dex2Jar(File input, File output) {
try { try {
Dex2jar d2Jar = Dex2jar.from(input); Dex2jar d2Jar = Dex2jar.from(input)
.withExceptionHandler(new DexExceptionHandler() {
public void handleFileException(Exception e) {
e.printStackTrace();
}
public void handleMethodTranslateException(Method method, DexMethodNode methodNode, MethodVisitor mv, Exception e) {
e.printStackTrace();
}
});
d2Jar.to(output.toPath()); d2Jar.to(output.toPath());
} catch (com.googlecode.d2j.DexException e) { } catch (com.googlecode.d2j.DexException e) {
e.printStackTrace(); e.printStackTrace();