More Translation Support
This commit is contained in:
parent
29c816c13e
commit
820a086a93
11 changed files with 101 additions and 17 deletions
|
@ -759,6 +759,10 @@ public class MainViewerGUI extends JFrame
|
||||||
JMenuItem waitIcon = waitIcons.get(0);
|
JMenuItem waitIcon = waitIcons.get(0);
|
||||||
waitIcons.remove(0);
|
waitIcons.remove(0);
|
||||||
rootMenu.remove(waitIcon);
|
rootMenu.remove(waitIcon);
|
||||||
|
|
||||||
|
//re-enable the Refresh Button incase it gets stuck
|
||||||
|
if(waitIcons.isEmpty() && !workPane.refreshClass.isEnabled())
|
||||||
|
workPane.refreshClass.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
rootMenu.updateUI();
|
rootMenu.updateUI();
|
||||||
|
|
|
@ -30,11 +30,11 @@ import javax.swing.JInternalFrame;
|
||||||
|
|
||||||
public abstract class VisibleComponent extends JInternalFrame
|
public abstract class VisibleComponent extends JInternalFrame
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -6453413772343643526L;
|
|
||||||
|
|
||||||
public VisibleComponent(final String title)
|
public VisibleComponent(final String title)
|
||||||
{
|
{
|
||||||
super(title, false, false, false, false);
|
super(title, false, false, false, false);
|
||||||
this.setFrameIcon(null);
|
this.setFrameIcon(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -6453413772343643526L;
|
||||||
}
|
}
|
|
@ -32,6 +32,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
|
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.Translation;
|
import the.bytecode.club.bytecodeviewer.translation.Translation;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJCheckBox;
|
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.FileContainer;
|
||||||
import the.bytecode.club.bytecodeviewer.util.FileDrop;
|
import the.bytecode.club.bytecodeviewer.util.FileDrop;
|
||||||
import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
|
import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
|
||||||
|
@ -63,7 +64,7 @@ import the.bytecode.club.bytecodeviewer.util.LazyNameUtil;
|
||||||
* @since 09/26/2011
|
* @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 JPopupMenu rightClickMenu = new JPopupMenu();
|
||||||
public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT);
|
public final JCheckBox exact = new TranslatedJCheckBox("Exact", Translation.EXACT);
|
||||||
|
@ -116,11 +117,10 @@ public class ResourceListPane extends VisibleComponent implements FileDrop.Liste
|
||||||
|
|
||||||
public ResourceListPane()
|
public ResourceListPane()
|
||||||
{
|
{
|
||||||
super("ClassNavigation");
|
super("Files", Translation.FILES);
|
||||||
tree.setRootVisible(false);
|
tree.setRootVisible(false);
|
||||||
tree.setShowsRootHandles(true);
|
tree.setShowsRootHandles(true);
|
||||||
quickSearch.setForeground(Color.gray);
|
quickSearch.setForeground(Color.gray);
|
||||||
setTitle("Files");
|
|
||||||
|
|
||||||
attachTreeListeners();
|
attachTreeListeners();
|
||||||
attachQuickSearchListeners();
|
attachQuickSearchListeners();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
package the.bytecode.club.bytecodeviewer.gui.resourcelist;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.gui.util.StringMetricsUtil;
|
import the.bytecode.club.bytecodeviewer.gui.util.StringMetricsUtil;
|
||||||
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
@ -38,7 +39,7 @@ public class ResourceTree extends JTree
|
||||||
g.setColor(new Color(0, 0, 0, 100));
|
g.setColor(new Color(0, 0, 0, 100));
|
||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
String s = "Drag class/jar/zip/APK/DEX here";
|
String s = TranslatedStrings.DRAG_CLASS_JAR.toString();
|
||||||
g.drawString(s,
|
g.drawString(s,
|
||||||
((int) ((getWidth() / 2) - (m.getWidth(s) / 2))),
|
((int) ((getWidth() / 2) - (m.getWidth(s) / 2))),
|
||||||
getHeight() / 2);
|
getHeight() / 2);
|
||||||
|
|
|
@ -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.BackgroundSearchThread;
|
||||||
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.Translation;
|
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.TranslatedJCheckBox;
|
||||||
|
import the.bytecode.club.bytecodeviewer.translation.components.TranslatedVisibleComponent;
|
||||||
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -51,7 +53,7 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class SearchBoxPane extends VisibleComponent
|
public class SearchBoxPane extends TranslatedVisibleComponent
|
||||||
{
|
{
|
||||||
public static final SearchRadius[] SEARCH_RADII = SearchRadius.values();
|
public static final SearchRadius[] SEARCH_RADII = SearchRadius.values();
|
||||||
public static final SearchType[] SEARCH_TYPES = SearchType.values();
|
public static final SearchType[] SEARCH_TYPES = SearchType.values();
|
||||||
|
@ -64,13 +66,13 @@ public class SearchBoxPane extends VisibleComponent
|
||||||
public SearchType searchType = null;
|
public SearchType searchType = null;
|
||||||
public final JComboBox searchRadiusBox;
|
public final JComboBox searchRadiusBox;
|
||||||
|
|
||||||
public JButton search = new JButton("Search");
|
public JButton search = new TranslatedJButton("Search", Translation.SEARCH);
|
||||||
public BackgroundSearchThread performSearchThread;
|
public BackgroundSearchThread performSearchThread;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public SearchBoxPane()
|
public SearchBoxPane()
|
||||||
{
|
{
|
||||||
super("Search");
|
super("Search", Translation.SEARCH);
|
||||||
|
|
||||||
final JPanel optionPanel = new JPanel(new BorderLayout());
|
final JPanel optionPanel = new JPanel(new BorderLayout());
|
||||||
final JPanel searchRadiusOpt = new JPanel(new BorderLayout());
|
final JPanel searchRadiusOpt = new JPanel(new BorderLayout());
|
||||||
|
|
|
@ -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.ClassViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer;
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.FileViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
|
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 the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU;
|
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
|
* @author WaterWolf
|
||||||
* @since 09/26/2011
|
* @since 09/26/2011
|
||||||
*/
|
*/
|
||||||
public class WorkPaneMainComponent extends VisibleComponent
|
public class WorkPaneMainComponent extends TranslatedVisibleComponent
|
||||||
{
|
{
|
||||||
public final JTabbedPane tabs;
|
public final JTabbedPane tabs;
|
||||||
public final JPanel buttonPanel;
|
public final JPanel buttonPanel;
|
||||||
|
@ -56,8 +59,7 @@ public class WorkPaneMainComponent extends VisibleComponent
|
||||||
|
|
||||||
public WorkPaneMainComponent()
|
public WorkPaneMainComponent()
|
||||||
{
|
{
|
||||||
super("WorkPanel");
|
super("Workspace", Translation.WORK_SPACE);
|
||||||
setTitle("Work Space");
|
|
||||||
|
|
||||||
this.tabs = new JTabbedPane();
|
this.tabs = new JTabbedPane();
|
||||||
|
|
||||||
|
@ -88,6 +90,7 @@ public class WorkPaneMainComponent extends VisibleComponent
|
||||||
tabs.remove(1);
|
tabs.remove(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tabs.addMouseListener(new MouseListener()
|
tabs.addMouseListener(new MouseListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,16 +142,17 @@ public class WorkPaneMainComponent extends VisibleComponent
|
||||||
|
|
||||||
buttonPanel = new JPanel(new FlowLayout());
|
buttonPanel = new JPanel(new FlowLayout());
|
||||||
|
|
||||||
refreshClass = new JButton("Refresh");
|
refreshClass = new TranslatedJButton("Refresh", Translation.REFRESH);
|
||||||
refreshClass.addActionListener((event)->{
|
refreshClass.addActionListener((event)->
|
||||||
|
{
|
||||||
refreshClass.setEnabled(false);
|
refreshClass.setEnabled(false);
|
||||||
Thread t = new Thread(() -> new WorkPaneRefresh(event).run(), "Refresh");
|
Thread t = new Thread(() -> new WorkPaneRefresh(event).run(), "Refresh");
|
||||||
t.start();
|
t.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonPanel.add(refreshClass);
|
buttonPanel.add(refreshClass);
|
||||||
|
|
||||||
buttonPanel.setVisible(false);
|
buttonPanel.setVisible(false);
|
||||||
|
|
||||||
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
tabs.addContainerListener(new TabRemovalEvent());
|
tabs.addContainerListener(new TabRemovalEvent());
|
||||||
|
|
|
@ -102,8 +102,8 @@ public enum Language
|
||||||
|
|
||||||
//check if translation key has been assigned to a component,
|
//check if translation key has been assigned to a component,
|
||||||
//on fail print an error alerting the devs
|
//on fail print an error alerting the devs
|
||||||
if(translation.getTranslatedComponent().runOnUpdate.isEmpty()
|
if(translation.getTranslatedComponent().runOnUpdate.isEmpty())
|
||||||
&& TranslatedStrings.nameSet.contains(translation.name()))
|
//&& TranslatedStrings.nameSet.contains(translation.name()))
|
||||||
{
|
{
|
||||||
System.err.println("Translation Reference " + translation.name() + " is missing component attachment, skipping...");
|
System.err.println("Translation Reference " + translation.name() + " is missing component attachment, skipping...");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public enum TranslatedStrings
|
||||||
DISASSEMBLER("Disassembler"),
|
DISASSEMBLER("Disassembler"),
|
||||||
SUGGESTED_FIX_DECOMPILER_ERROR("Suggested Fix: Click refresh class, if it fails again try another decompiler."),
|
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."),
|
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<String> nameSet = new HashSet<>();
|
public static final HashSet<String> nameSet = new HashSet<>();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,6 +107,7 @@
|
||||||
"ERROR": "Error",
|
"ERROR": "Error",
|
||||||
"SUGGESTED_FIX_DECOMPILER_ERROR": "Suggested Fix: Click refresh class, if it fails again try another decompiler.",
|
"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.",
|
"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",
|
"FILES": "Files",
|
||||||
"QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",
|
"QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue