use of the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem in project bytecode-viewer by Konloch.
the class IconDemo method main.
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
switchToLaf(LAFTheme.SYSTEM);
JFrame frame = new JFrame("Icon Demo");
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu menu = menuBar.add(new JMenu("Theme"));
ButtonGroup lafGroup = new ButtonGroup();
for (LAFTheme theme : LAFTheme.values()) {
JRadioButtonMenuItem item = new TranslatedJRadioButtonMenuItem(theme.getReadableName(), theme.getTranslation());
if (LAFTheme.SYSTEM.equals(theme))
item.setSelected(true);
lafGroup.add(item);
item.addActionListener(e -> switchToLaf(theme));
menu.add(item);
}
IconEntry[] iconEntries = new IconEntry[] { new IconEntry("Next", IconResources.nextIcon), new IconEntry("Previous", IconResources.prevIcon), new IconEntry("Busy", IconResources.busyIcon), new IconEntry(".bat", IconResources.batIcon), new IconEntry(".sh", IconResources.shIcon), new IconEntry(".cs", IconResources.csharpIcon), new IconEntry(".cpp", IconResources.cplusplusIcon), new IconEntry(".Config", IconResources.configIcon), new IconEntry(".jar", IconResources.jarIcon), new IconEntry(".zip", IconResources.zipIcon), new IconEntry("Package", IconResources.packagesIcon), new IconEntry("Folder", IconResources.folderIcon), new IconEntry("Android", IconResources.androidIcon), new IconEntry("Unknown File", IconResources.unknownFileIcon), new IconEntry("Text", IconResources.textIcon), new IconEntry(".class", IconResources.classIcon), new IconEntry("Image", IconResources.imageIcon), new IconEntry("Decoded", IconResources.decodedIcon), new IconEntry(".java", IconResources.javaIcon) };
JList<IconEntry> iconList = new JList<>(iconEntries);
iconList.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, ((IconEntry) value).name, index, isSelected, cellHasFocus);
setIcon(((IconEntry) value).icon);
return this;
}
});
JComponent content = new JScrollPane(iconList);
content.setPreferredSize(new Dimension(200, 400));
frame.setContentPane(content);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
}
use of the.bytecode.club.bytecodeviewer.translation.components.TranslatedJRadioButtonMenuItem in project bytecode-viewer by Konloch.
the class MainViewerGUI method buildSettingsMenu.
public void buildSettingsMenu() {
rootMenu.add(settingsMainMenu);
// settingsMainMenu.add(visualSettings);
// settingsMainMenu.add(new JSeparator());
settingsMainMenu.add(compileOnSave);
settingsMainMenu.add(autoCompileOnRefresh);
settingsMainMenu.add(refreshOnChange);
settingsMainMenu.add(new JSeparator());
settingsMainMenu.add(updateCheck);
settingsMainMenu.add(forcePureAsciiAsText);
settingsMainMenu.add(new JSeparator());
settingsMainMenu.add(setPython2);
settingsMainMenu.add(setPython3);
settingsMainMenu.add(setJRERT);
settingsMainMenu.add(setOptionalLibrary);
settingsMainMenu.add(setJavac);
settingsMainMenu.add(new JSeparator());
// TODO the dialog below works but for 3 options,
// it might be better to leave it as a secondary menu
settingsMainMenu.add(apkConversionSecondaryMenu);
// settingsMainMenu.add(useNewSettingsDialog ? apkConversionSettings : apkConversionMenu);
// Smali minSdkVersion
minSdkVersionSpinner.setPreferredSize(new Dimension(60, 24));
minSdkVersionSpinner.setMinimumSize(new Dimension(60, 24));
minSdkVersionSpinner.setModel(new SpinnerNumberModel(26, 1, null, 1));
minSdkVersionMenu.add(minSdkVersionSpinner);
settingsMainMenu.add(minSdkVersionMenu);
settingsMainMenu.add(new JSeparator());
fontSpinner.setPreferredSize(new Dimension(60, 24));
fontSpinner.setMinimumSize(new Dimension(60, 24));
fontSpinner.setModel(new SpinnerNumberModel(12, 1, null, 1));
fontSize.add(fontSpinner);
apkConversionSecondaryMenu.add(decodeAPKResources);
apkConversionSecondaryMenu.add(apkConversionDex);
apkConversionSecondaryMenu.add(apkConversionEnjarify);
apkConversionGroup.add(apkConversionDex);
apkConversionGroup.add(apkConversionEnjarify);
apkConversionGroup.setSelected(apkConversionDex.getModel(), true);
// apkConversionSettingsDialog = new SettingsDialogue(apkConversionSecondaryMenu, new JPanel());
apkConversionSettings.addActionListener((e) -> apkConversionSettingsDialog.showDialog());
ButtonGroup rstaGroup = new ButtonGroup();
for (RSTATheme t : RSTATheme.values()) {
JRadioButtonMenuItem item = new TranslatedJRadioButtonMenuItem(t.getReadableName(), t.getTranslation());
if (Configuration.rstaTheme.equals(t))
item.setSelected(true);
rstaGroup.add(item);
item.addActionListener(e -> {
Configuration.rstaTheme = t;
item.setSelected(true);
SettingsSerializer.saveSettingsAsync();
updateTabTheme();
});
rstaThemes.put(t, item);
rstaTheme.add(item);
}
rstaThemeSettingsDialog = new SettingsDialog(rstaTheme, new JPanel());
rstaThemeSettings.addActionListener((e) -> rstaThemeSettingsDialog.showDialog());
ButtonGroup lafGroup = new ButtonGroup();
for (LAFTheme theme : LAFTheme.values()) {
JRadioButtonMenuItem item = new TranslatedJRadioButtonMenuItem(theme.getReadableName(), theme.getTranslation());
if (Configuration.lafTheme.equals(theme))
item.setSelected(true);
lafGroup.add(item);
item.addActionListener(e -> {
Configuration.lafTheme = theme;
Configuration.rstaTheme = theme.getRSTATheme();
rstaThemes.get(Configuration.rstaTheme).setSelected(true);
item.setSelected(true);
SettingsSerializer.saveSettingsAsync();
try {
theme.setLAF();
updateTabTheme();
} catch (Exception ex) {
ex.printStackTrace();
}
});
lafThemes.put(theme, item);
lafTheme.add(item);
}
lafThemeSettingsDialog = new SettingsDialog(lafTheme, new JPanel());
lafThemeSettings.addActionListener((e) -> lafThemeSettingsDialog.showDialog());
ButtonGroup languageGroup = new ButtonGroup();
for (Language l : Language.values()) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(l.getReadableName());
if (Configuration.language.equals(l))
item.setSelected(true);
languageGroup.add(item);
item.addActionListener(e -> {
SettingsSerializer.saveSettingsAsync();
MiscUtils.setLanguage(l);
});
languages.put(l, item);
language.add(item);
}
languageSettingsDialog = new SettingsDialog(language, new JPanel());
languageSettings.addActionListener((e) -> languageSettingsDialog.showDialog());
visualSettings.add(useNewSettingsDialog ? lafThemeSettings : lafTheme);
visualSettings.add(useNewSettingsDialog ? rstaThemeSettings : rstaTheme);
visualSettings.add(useNewSettingsDialog ? languageSettings : language);
visualSettings.add(fontSize);
visualSettings.add(showFileInTabTitle);
visualSettings.add(simplifyNameInTabTitle);
visualSettings.add(synchronizedViewing);
visualSettings.add(showClassMethods);
// PROCYON SETTINGS
settingsMainMenu.add(useNewSettingsDialog ? procyonSettings : procyonSettingsSecondaryMenu);
procyonSettingsSecondaryMenu.add(alwaysGenerateExceptionVars);
procyonSettingsSecondaryMenu.add(excludeNestedTypes);
procyonSettingsSecondaryMenu.add(showDebugLineNumbers);
procyonSettingsSecondaryMenu.add(includeLineNumbersInBytecode);
procyonSettingsSecondaryMenu.add(includeErrorDiagnostics);
procyonSettingsSecondaryMenu.add(showSyntheticMembers);
procyonSettingsSecondaryMenu.add(simplifyMemberReferences);
procyonSettingsSecondaryMenu.add(mergeVariables);
procyonSettingsSecondaryMenu.add(forceExplicitTypeArguments);
procyonSettingsSecondaryMenu.add(forceExplicitImports);
procyonSettingsSecondaryMenu.add(flattenSwitchBlocks);
procyonSettingsSecondaryMenu.add(retainPointlessSwitches);
procyonSettingsSecondaryMenu.add(retainRedunantCasts);
procyonSettingsSecondaryMenu.add(unicodeOutputEnabled);
procyonSettingsDialog = new SettingsDialog(procyonSettingsSecondaryMenu, new JPanel());
procyonSettings.addActionListener((e) -> procyonSettingsDialog.showDialog());
// CFR SETTINGS
settingsMainMenu.add(useNewSettingsDialog ? cfrSettings : cfrSettingsSecondaryMenu);
cfrSettingsSecondaryMenu.add(decodeEnumSwitch);
cfrSettingsSecondaryMenu.add(sugarEnums);
cfrSettingsSecondaryMenu.add(decodeStringSwitch);
cfrSettingsSecondaryMenu.add(arrayiter);
cfrSettingsSecondaryMenu.add(collectioniter);
cfrSettingsSecondaryMenu.add(innerClasses);
cfrSettingsSecondaryMenu.add(removeBoilerPlate);
cfrSettingsSecondaryMenu.add(removeInnerClassSynthetics);
cfrSettingsSecondaryMenu.add(decodeLambdas);
cfrSettingsSecondaryMenu.add(hideBridgeMethods);
cfrSettingsSecondaryMenu.add(liftConstructorInit);
cfrSettingsSecondaryMenu.add(removeDeadMethods);
cfrSettingsSecondaryMenu.add(removeBadGenerics);
cfrSettingsSecondaryMenu.add(sugarAsserts);
cfrSettingsSecondaryMenu.add(sugarBoxing);
cfrSettingsSecondaryMenu.add(showVersion);
cfrSettingsSecondaryMenu.add(decodeFinally);
cfrSettingsSecondaryMenu.add(tidyMonitors);
cfrSettingsSecondaryMenu.add(lenient);
cfrSettingsSecondaryMenu.add(dumpClassPath);
cfrSettingsSecondaryMenu.add(comments);
cfrSettingsSecondaryMenu.add(forceTopSort);
cfrSettingsSecondaryMenu.add(forceTopSortAggress);
cfrSettingsSecondaryMenu.add(forceExceptionPrune);
cfrSettingsSecondaryMenu.add(stringBuffer);
cfrSettingsSecondaryMenu.add(stringBuilder);
cfrSettingsSecondaryMenu.add(silent);
cfrSettingsSecondaryMenu.add(recover);
cfrSettingsSecondaryMenu.add(eclipse);
cfrSettingsSecondaryMenu.add(override);
cfrSettingsSecondaryMenu.add(showInferrable);
cfrSettingsSecondaryMenu.add(aexagg);
cfrSettingsSecondaryMenu.add(forceCondPropagate);
cfrSettingsSecondaryMenu.add(hideUTF);
cfrSettingsSecondaryMenu.add(hideLongStrings);
cfrSettingsSecondaryMenu.add(commentMonitor);
cfrSettingsSecondaryMenu.add(allowCorrecting);
cfrSettingsSecondaryMenu.add(labelledBlocks);
cfrSettingsSecondaryMenu.add(j14ClassOBJ);
cfrSettingsSecondaryMenu.add(hideLangImports);
cfrSettingsSecondaryMenu.add(recoveryTypeClash);
cfrSettingsSecondaryMenu.add(recoveryTypehInts);
cfrSettingsSecondaryMenu.add(forceTurningIFs);
cfrSettingsSecondaryMenu.add(forLoopAGGCapture);
cfrSettingsDialog = new SettingsDialog(cfrSettingsSecondaryMenu, new JPanel());
cfrSettings.addActionListener((e) -> cfrSettingsDialog.showDialog());
// FERNFLOWER SETTINGS
settingsMainMenu.add(useNewSettingsDialog ? fernFlowerSettings : fernFlowerSettingsSecondaryMenu);
fernFlowerSettingsSecondaryMenu.add(ren);
fernFlowerSettingsSecondaryMenu.add(dc4);
fernFlowerSettingsSecondaryMenu.add(nns);
fernFlowerSettingsSecondaryMenu.add(ner);
fernFlowerSettingsSecondaryMenu.add(bto);
fernFlowerSettingsSecondaryMenu.add(rgn);
fernFlowerSettingsSecondaryMenu.add(rer);
fernFlowerSettingsSecondaryMenu.add(rbr);
fernFlowerSettingsSecondaryMenu.add(rsy);
fernFlowerSettingsSecondaryMenu.add(hes);
fernFlowerSettingsSecondaryMenu.add(hdc);
fernFlowerSettingsSecondaryMenu.add(din);
fernFlowerSettingsSecondaryMenu.add(das);
fernFlowerSettingsSecondaryMenu.add(dgs);
fernFlowerSettingsSecondaryMenu.add(den);
fernFlowerSettingsSecondaryMenu.add(uto);
fernFlowerSettingsSecondaryMenu.add(udv);
fernFlowerSettingsSecondaryMenu.add(fdi);
fernFlowerSettingsSecondaryMenu.add(asc);
fernFlowerSettingsDialog = new SettingsDialog(fernFlowerSettingsSecondaryMenu, new JPanel());
fernFlowerSettings.addActionListener((e) -> fernFlowerSettingsDialog.showDialog());
// CFIDE SETTINGS
settingsMainMenu.add(useNewSettingsDialog ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu);
bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers);
bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels);
bytecodeDecompilerSettingsSecondaryMenu.add(printLineNumbers);
bytecodeDecompilerSettingsDialog = new SettingsDialog(bytecodeDecompilerSettingsSecondaryMenu, new JPanel());
bytecodeDecompilerSettings.addActionListener((e) -> bytecodeDecompilerSettingsDialog.showDialog());
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
forcePureAsciiAsText.addActionListener(arg0 -> SettingsSerializer.saveSettingsAsync());
setPython2.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython2());
setJRERT.addActionListener(arg0 -> ExternalResources.getSingleton().selectJRERTLibrary());
setPython3.addActionListener(arg0 -> ExternalResources.getSingleton().selectPython3());
setOptionalLibrary.addActionListener(arg0 -> ExternalResources.getSingleton().selectOptionalLibraryFolder());
setJavac.addActionListener(arg0 -> ExternalResources.getSingleton().selectJavac());
showFileInTabTitle.addActionListener(arg0 -> {
Configuration.displayParentInTab = BytecodeViewer.viewer.showFileInTabTitle.isSelected();
SettingsSerializer.saveSettingsAsync();
BytecodeViewer.refreshAllTabTitles();
});
simplifyNameInTabTitle.addActionListener(arg0 -> {
Configuration.simplifiedTabNames = BytecodeViewer.viewer.simplifyNameInTabTitle.isSelected();
SettingsSerializer.saveSettingsAsync();
BytecodeViewer.refreshAllTabTitles();
});
}
Aggregations