diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index ff2f0719..54eeac14 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -759,6 +759,10 @@ public class MainViewerGUI extends JFrame JMenuItem waitIcon = waitIcons.get(0); waitIcons.remove(0); rootMenu.remove(waitIcon); + + //re-enable the Refresh Button incase it gets stuck + if(waitIcons.isEmpty() && !workPane.refreshClass.isEnabled()) + workPane.refreshClass.setEnabled(true); } rootMenu.updateUI(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/VisibleComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/VisibleComponent.java index 4a440200..cc1729b1 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/VisibleComponent.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/VisibleComponent.java @@ -30,11 +30,11 @@ import javax.swing.JInternalFrame; public abstract class VisibleComponent extends JInternalFrame { - private static final long serialVersionUID = -6453413772343643526L; - public VisibleComponent(final String title) { super(title, false, false, false, false); this.setFrameIcon(null); } + + private static final long serialVersionUID = -6453413772343643526L; } \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java index 27da1793..13d6e1a9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java @@ -32,6 +32,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; import the.bytecode.club.bytecodeviewer.translation.Translation; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBox; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent; import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.FileDrop; import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; @@ -63,7 +64,7 @@ import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; * @since 09/26/2011 */ -public class ResourceListPane extends VisibleComponent implements FileDrop.Listener +public class ResourceListPane extends TranslatedVisibleComponent implements FileDrop.Listener { public final JPopupMenu rightClickMenu = new JPopupMenu(); public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT); @@ -116,11 +117,10 @@ public class ResourceListPane extends VisibleComponent implements FileDrop.Liste public ResourceListPane() { - super("ClassNavigation"); + super("Files", Translation.FILES); tree.setRootVisible(false); tree.setShowsRootHandles(true); quickSearch.setForeground(Color.gray); - setTitle("Files"); attachTreeListeners(); attachQuickSearchListeners(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceTree.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceTree.java index e9390f41..2c453251 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceTree.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceTree.java @@ -1,6 +1,7 @@ package the.bytecode.club.bytecodeviewer.gui.resourcelist; import the.bytecode.club.bytecodeviewer.gui.util.StringMetricsUtil; +import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -38,7 +39,7 @@ public class ResourceTree extends JTree g.setColor(new Color(0, 0, 0, 100)); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.white); - String s = "Drag class/jar/zip/APK/DEX here"; + String s = TranslatedStrings.DRAG_CLASS_JAR.toString(); g.drawString(s, ((int) ((getWidth() / 2) - (m.getWidth(s) / 2))), getHeight() / 2); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java index 9d642ec3..f7ca0c0e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcesearch/SearchBoxPane.java @@ -21,7 +21,9 @@ import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer import the.bytecode.club.bytecodeviewer.searching.BackgroundSearchThread; import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; import the.bytecode.club.bytecodeviewer.translation.Translation; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBox; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent; import the.bytecode.club.bytecodeviewer.util.FileContainer; /*************************************************************************** @@ -51,7 +53,7 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer; */ @SuppressWarnings("rawtypes") -public class SearchBoxPane extends VisibleComponent +public class SearchBoxPane extends TranslatedVisibleComponent { public static final SearchRadius[] SEARCH_RADII = SearchRadius.values(); public static final SearchType[] SEARCH_TYPES = SearchType.values(); @@ -64,13 +66,13 @@ public class SearchBoxPane extends VisibleComponent public SearchType searchType = null; public final JComboBox searchRadiusBox; - public JButton search = new JButton("Search"); + public JButton search = new TranslatedJButton("Search", Translation.SEARCH); public BackgroundSearchThread performSearchThread; @SuppressWarnings("unchecked") public SearchBoxPane() { - super("Search"); + super("Search", Translation.SEARCH); final JPanel optionPanel = new JPanel(new BorderLayout()); final JPanel searchRadiusOpt = new JPanel(new BorderLayout()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java index 71fd49bb..9d1384c2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/WorkPaneMainComponent.java @@ -18,6 +18,9 @@ import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer; import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer; +import the.bytecode.club.bytecodeviewer.translation.Translation; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJButton; +import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent; import the.bytecode.club.bytecodeviewer.util.FileContainer; import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; @@ -47,7 +50,7 @@ import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; * @author WaterWolf * @since 09/26/2011 */ -public class WorkPaneMainComponent extends VisibleComponent +public class WorkPaneMainComponent extends TranslatedVisibleComponent { public final JTabbedPane tabs; public final JPanel buttonPanel; @@ -56,8 +59,7 @@ public class WorkPaneMainComponent extends VisibleComponent public WorkPaneMainComponent() { - super("WorkPanel"); - setTitle("Work Space"); + super("Workspace", Translation.WORK_SPACE); this.tabs = new JTabbedPane(); @@ -88,6 +90,7 @@ public class WorkPaneMainComponent extends VisibleComponent tabs.remove(1); } }); + tabs.addMouseListener(new MouseListener() { @Override @@ -139,16 +142,17 @@ public class WorkPaneMainComponent extends VisibleComponent buttonPanel = new JPanel(new FlowLayout()); - refreshClass = new JButton("Refresh"); - refreshClass.addActionListener((event)->{ + refreshClass = new TranslatedJButton("Refresh", Translation.REFRESH); + refreshClass.addActionListener((event)-> + { refreshClass.setEnabled(false); Thread t = new Thread(() -> new WorkPaneRefresh(event).run(), "Refresh"); t.start(); }); buttonPanel.add(refreshClass); - buttonPanel.setVisible(false); + getContentPane().add(buttonPanel, BorderLayout.SOUTH); tabs.addContainerListener(new TabRemovalEvent()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java index 4715787a..f5e6561f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Language.java @@ -102,8 +102,8 @@ public enum Language //check if translation key has been assigned to a component, //on fail print an error alerting the devs - if(translation.getTranslatedComponent().runOnUpdate.isEmpty() - && TranslatedStrings.nameSet.contains(translation.name())) + if(translation.getTranslatedComponent().runOnUpdate.isEmpty()) + //&& TranslatedStrings.nameSet.contains(translation.name())) { System.err.println("Translation Reference " + translation.name() + " is missing component attachment, skipping..."); continue; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java index a8eb9c5e..825b52bb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java @@ -29,6 +29,7 @@ public enum TranslatedStrings DISASSEMBLER("Disassembler"), SUGGESTED_FIX_DECOMPILER_ERROR("Suggested Fix: Click refresh class, if it fails again try another decompiler."), SUGGESTED_FIX_COMPILER_ERROR("Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable."), + DRAG_CLASS_JAR("Drag class/jar/zip/APK/DEX here"), ; public static final HashSet nameSet = new HashSet<>(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJButton.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJButton.java new file mode 100644 index 00000000..27cf803f --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedJButton.java @@ -0,0 +1,36 @@ +package the.bytecode.club.bytecodeviewer.translation.components; + +import the.bytecode.club.bytecodeviewer.translation.TranslatedComponent; +import the.bytecode.club.bytecodeviewer.translation.Translation; + +import javax.swing.*; + +/** + * @author Konloch + * @since 7/7/2021 + */ +public class TranslatedJButton extends JButton +{ + private final TranslatedComponent component; + + public TranslatedJButton(String text, Translation translation) + { + super(text); + + if(translation != null) + { + this.component = translation.getTranslatedComponent(); + this.component.runOnUpdate.add(this::updateText); + } + else + { + this.component = null; + } + } + + public void updateText() + { + if(component != null) + setText(component.value); + } +} diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedVisibleComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedVisibleComponent.java new file mode 100644 index 00000000..7f057f3b --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/components/TranslatedVisibleComponent.java @@ -0,0 +1,35 @@ +package the.bytecode.club.bytecodeviewer.translation.components; + +import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; +import the.bytecode.club.bytecodeviewer.translation.TranslatedComponent; +import the.bytecode.club.bytecodeviewer.translation.Translation; + +/** + * @author Konloch + * @since 7/7/2021 + */ +public class TranslatedVisibleComponent extends VisibleComponent +{ + private final TranslatedComponent component; + + public TranslatedVisibleComponent(String title, Translation translation) + { + super(title); + + if(translation != null) + { + this.component = translation.getTranslatedComponent(); + this.component.runOnUpdate.add(this::updateText); + } + else + { + this.component = null; + } + } + + public void updateText() + { + if(component != null) + setTitle(component.value); + } +} diff --git a/src/main/resources/translations/english.json b/src/main/resources/translations/english.json index 94f27f7c..cc9680e7 100644 --- a/src/main/resources/translations/english.json +++ b/src/main/resources/translations/english.json @@ -107,6 +107,7 @@ "ERROR": "Error", "SUGGESTED_FIX_DECOMPILER_ERROR": "Suggested Fix: Click refresh class, if it fails again try another decompiler.", "SUGGESTED_FIX_COMPILER_ERROR": "Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable.", + "DRAG_CLASS_JAR": "Drag class/jar/zip/APK/DEX here", "FILES": "Files", "QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",