From 02749d6913c26fd6446b33d3584c112382ccca98 Mon Sep 17 00:00:00 2001 From: Konloch Date: Wed, 25 Sep 2024 19:58:24 -0600 Subject: [PATCH] Removed Unused Tab Code --- .../club/bytecodeviewer/BytecodeViewer.java | 6 +- .../gui/components/ButtonHoverAnimation.java | 53 -------- .../gui/resourceviewer/TabExitButton.java | 119 ------------------ .../gui/resourceviewer/TabRemovalEvent.java | 50 -------- .../gui/resourceviewer/TabbedPane.java | 73 ----------- .../gui/resourceviewer/Workspace.java | 1 - .../resourceviewer/viewer/ResourceViewer.java | 7 +- .../gui/util/BytecodeViewPanelUpdater.java | 3 +- 8 files changed, 7 insertions(+), 305 deletions(-) delete mode 100644 src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ButtonHoverAnimation.java delete mode 100644 src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java delete mode 100644 src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabRemovalEvent.java delete mode 100644 src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index df6d5039..b6648c04 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -43,7 +43,6 @@ import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; import the.bytecode.club.bytecodeviewer.gui.components.SearchableJTextArea; import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea; import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListIconRenderer; -import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer; @@ -668,8 +667,9 @@ public class BytecodeViewer { for(int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++) { - ResourceViewer viewer = ((TabbedPane) BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i)).resource; - viewer.refreshTitle(); + //ResourceViewer viewer = ((TabbedPane) BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i)).resource; + //viewer.refreshTitle(); + //TODO } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ButtonHoverAnimation.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ButtonHoverAnimation.java deleted file mode 100644 index 88365db3..00000000 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/ButtonHoverAnimation.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * - * Copyright (C) 2014 Konloch - Konloch.com / BytecodeViewer.com * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - ***************************************************************************/ - -package the.bytecode.club.bytecodeviewer.gui.components; - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import javax.swing.AbstractButton; - -/** - * @author Konloch - * @since 6/25/2021 - */ -public class ButtonHoverAnimation extends MouseAdapter -{ - @Override - public void mouseEntered(MouseEvent e) - { - final Component component = e.getComponent(); - if (component instanceof AbstractButton) - { - final AbstractButton button = (AbstractButton) component; - button.setBorderPainted(true); - } - } - - @Override - public void mouseExited(MouseEvent e) - { - final Component component = e.getComponent(); - if (component instanceof AbstractButton) - { - final AbstractButton button = (AbstractButton) component; - button.setBorderPainted(false); - } - } -} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java deleted file mode 100644 index a17a03ed..00000000 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabExitButton.java +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * - * Copyright (C) 2014 Konloch - Konloch.com / BytecodeViewer.com * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - ***************************************************************************/ - -package the.bytecode.club.bytecodeviewer.gui.resourceviewer; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.plaf.basic.BasicButtonUI; - -/** - * @author Konloch - * @since 6/25/2021 - * Using CloseButton of darklaf instead. 4/17/2022 - */ -@Deprecated -public class TabExitButton extends JButton implements ActionListener { - - private final TabbedPane tabbedPane; - private final int tabIndex; - private final String tabWorkingName; - - public TabExitButton(TabbedPane tabbedPane, int tabIndex, String tabWorkingName) { - this.tabbedPane = tabbedPane; - this.tabIndex = tabIndex; - this.tabWorkingName = tabWorkingName; - final int size = 17; - setPreferredSize(new Dimension(size, size)); - setToolTipText("Close this tab"); - // Make the button looks the same for all Laf's - setUI(new BasicButtonUI()); - // Make it transparent - setContentAreaFilled(false); - // No need to be focusable - setFocusable(false); - setBorder(BorderFactory.createEtchedBorder()); - setBorderPainted(false); - // Making nice rollover effect - // we use the same listener for all buttons - addMouseListener(TabbedPane.buttonHoverAnimation); - setRolloverEnabled(true); - // Close the proper tab by clicking the button - addActionListener(this); - } - - public int getTabIndex() { - return tabIndex; - } - - @Override - public void actionPerformed(ActionEvent e) { - final int i = tabbedPane.tabs.indexOfTabComponent(tabbedPane); - if (i != -1) { - tabbedPane.tabs.remove(i); - } - } - - // we don't want to update UI for this button - @Override - public void updateUI() { - } - - // paint the cross - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - final Graphics2D g2 = (Graphics2D) g.create(); - // shift the image for pressed buttons - if (getModel().isPressed()) - g2.translate(1, 1); - - g2.setStroke(new BasicStroke(2)); - g2.setColor(Color.BLACK); - - if (getModel().isRollover()) { - g2.setColor(Color.MAGENTA); - } - - final int delta = 6; - g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1); - g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1); - g2.dispose(); - } - - public TabbedPane getTabbedPane() { - return tabbedPane; - } - - public String getTabWorkingName() { - return tabWorkingName; - } - - public static long getSerialVersionUID() { - return serialVersionUID; - } - - private static final long serialVersionUID = -4492967978286454159L; -} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabRemovalEvent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabRemovalEvent.java deleted file mode 100644 index 5aa3c7d7..00000000 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabRemovalEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * - * Copyright (C) 2014 Konloch - Konloch.com / BytecodeViewer.com * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - ***************************************************************************/ - -package the.bytecode.club.bytecodeviewer.gui.resourceviewer; - -import java.awt.Component; -import java.awt.event.ContainerEvent; -import java.awt.event.ContainerListener; -import the.bytecode.club.bytecodeviewer.BytecodeViewer; -import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; - -/** - * @author Konloch - * @since 6/24/2021 - * @deprecated Removal pending.
- * Disabled due to a bug when dragging a component, it got "removed" resulting in another - * tab being opened when clicking the same class in the file resource rather than opening the already opened file. - */ -public class TabRemovalEvent implements ContainerListener -{ - @Override - public void componentAdded(ContainerEvent e) { } - - @Override - public void componentRemoved(ContainerEvent e) - { - final Component c = e.getChild(); - - if(!(c instanceof ResourceViewer)) - return; - - String workingName = ((ResourceViewer) c).resource.workingName; - BytecodeViewer.viewer.workPane.openedTabs.remove(workingName); - } -} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java deleted file mode 100644 index 31f5cb2f..00000000 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/TabbedPane.java +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * - * Copyright (C) 2014 Konloch - Konloch.com / BytecodeViewer.com * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - ***************************************************************************/ - -package the.bytecode.club.bytecodeviewer.gui.resourceviewer; - -import the.bytecode.club.bytecodeviewer.gui.components.ButtonHoverAnimation; -import the.bytecode.club.bytecodeviewer.gui.components.MaxWidthJLabel; -import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseListener; - -/** - * Component to be used as tabComponent; Contains a JLabel to show the text and a JButton to close the tab it belongs to - * - * @author Konloch - * @author WaterWolf - * @since 09/26/2011 - */ -public class TabbedPane extends JPanel { - - public final JTabbedPane tabs; - public final JLabel label; - private long startedDragging = 0; - public final String tabName; - public final String fileContainerName; - public final ResourceViewer resource; - private static long lastMouseClick = System.currentTimeMillis(); - public final static MouseListener buttonHoverAnimation = new ButtonHoverAnimation(); - public static final Color BLANK_COLOR = new Color(0, 0, 0, 0); - - public TabbedPane(int tabIndex, String tabWorkingName, String fileContainerName, String name, JTabbedPane existingTabs, ResourceViewer resource) { - // unset default FlowLayout' gaps - super(new FlowLayout(FlowLayout.LEFT, 0, 0)); - - this.tabName = name; - this.fileContainerName = fileContainerName; - this.resource = resource; - - if (existingTabs == null) - throw new NullPointerException("TabbedPane is null"); - - this.tabs = existingTabs; - setOpaque(false); - - // make JLabel read titles from JTabbedPane - label = new MaxWidthJLabel(tabName, 400, 20); - - this.add(label); - // add more space between the label and the button - label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); - // add more space to the top of the component - setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); - } - - private static final long serialVersionUID = -4774885688297538774L; -} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java index 48fdb51b..2f2938c2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/Workspace.java @@ -142,7 +142,6 @@ public class Workspace extends TranslatedVisibleComponent { final int tabIndex = tabs.indexOfComponent(resourceView); //create a new tabbed pane - resourceView.tabbedPane = new TabbedPane(tabIndex, workingName, containerName, name, tabs, resourceView); resourceView.resource.workingName = workingName; //set the tabs index diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java index dcb620a4..48058b03 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java @@ -21,7 +21,6 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer; import javax.swing.JButton; import javax.swing.JPanel; import the.bytecode.club.bytecodeviewer.Configuration; -import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane; import the.bytecode.club.bytecodeviewer.resources.Resource; import the.bytecode.club.bytecodeviewer.util.MiscUtils; @@ -34,7 +33,6 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils; public abstract class ResourceViewer extends JPanel { public final Resource resource; - public TabbedPane tabbedPane; protected ResourceViewer(Resource resource) {this.resource = resource;} @@ -69,8 +67,9 @@ public abstract class ResourceViewer extends JPanel */ public void refreshTitle() { - if(tabbedPane != null) - tabbedPane.label.setText(getTabName()); + //TODO + //if(tabbedPane != null) + // tabbedPane.label.setText(getTabName()); } private static final long serialVersionUID = -2965538493489119191L; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java index 33e79048..9a3876a7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/util/BytecodeViewPanelUpdater.java @@ -50,7 +50,6 @@ import java.awt.event.*; import java.util.Objects; import java.util.regex.Matcher; -import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLANK_COLOR; import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.EDITABLE; /** @@ -376,7 +375,7 @@ public class BytecodeViewPanelUpdater implements Runnable JPanel panel = new JPanel(new BorderLayout()); panel.add(updateUpdaterTextArea.getScrollPane().getColumnHeader().getComponent(0), BorderLayout.NORTH); panel.add(methodsList, BorderLayout.SOUTH); - methodsList.setBackground(BLANK_COLOR); + methodsList.setBackground(new Color(0, 0, 0, 0)); SwingUtilities.invokeLater(() -> {