diff --git a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java index ffb0ee651..969f74cdf 100644 --- a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java @@ -40,6 +40,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Icon; @@ -54,6 +55,7 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.SpringLayout; +import javax.swing.WindowConstants; import javax.swing.table.DefaultTableModel; import org.pushingpixels.substance.api.ColorSchemeAssociationKind; import org.pushingpixels.substance.api.ComponentState; @@ -90,7 +92,7 @@ public class AdvancedSettingsDialog extends AppDialog { } private DefaultTableModel getModel() { - return new javax.swing.table.DefaultTableModel( + return new DefaultTableModel( new Object[][]{}, new String[]{ translate("advancedSettings.columns.name"), @@ -144,10 +146,10 @@ public class AdvancedSettingsDialog extends AppDialog { cancelButton = new JButton(); resetButton = new JButton(); - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(translate("advancedSettings.dialog.title")); setModal(true); - setPreferredSize(new java.awt.Dimension(800, 500)); + setPreferredSize(new Dimension(800, 500)); okButton.setText(AppStrings.translate("button.ok")); okButton.addActionListener(this::okButtonActionPerformed); @@ -176,25 +178,7 @@ public class AdvancedSettingsDialog extends AppDialog { cnt.add(buttonsPanel, BorderLayout.SOUTH); - Map fields = Configuration.getConfigurationFields(); - String[] keys = new String[fields.size()]; - keys = fields.keySet().toArray(keys); - Arrays.sort(keys); - - Map> categorized = new HashMap<>(); - - for (String name : keys) { - Field field = fields.get(name); - ConfigurationCategory cat = field.getAnnotation(ConfigurationCategory.class); - String scat = cat == null ? "other" : cat.value(); - if (!categorized.containsKey(scat)) { - categorized.put(scat, new HashMap<>()); - } - categorized.get(scat).put(name, field); - } - JTabbedPane tabPane = new JTabbedPane(); - Map tabs = new HashMap<>(); JComboBox skinComboBox = new JComboBox<>(); skinComboBox.setRenderer(new SubstanceDefaultListCellRenderer() { @@ -254,21 +238,57 @@ public class AdvancedSettingsDialog extends AppDialog { } } + Map tabs = new HashMap<>(); + getCategories(componentsMap, tabs, skinComboBox, getResourceBundle()); + + String catOrder[] = new String[]{"ui", "display", "decompilation", "script", "format", "export", "import", "limit", "update", "debug", "other"}; + + for (String cat : catOrder) { + if (!tabs.containsKey(cat)) { + continue; + } + + tabPane.add(translate("config.group.name." + cat), tabs.get(cat)); + tabPane.setToolTipTextAt(tabPane.getTabCount() - 1, translate("config.group.description." + cat)); + } + + cnt.add(tabPane, BorderLayout.CENTER); + pack(); + } + + public static void getCategories(Map componentsMap, Map tabs, JComboBox skinComboBox, ResourceBundle resourceBundle) { + Map> categorized = new HashMap<>(); + + Map fields = Configuration.getConfigurationFields(); + String[] keys = new String[fields.size()]; + keys = fields.keySet().toArray(keys); + Arrays.sort(keys); + + for (String name : keys) { + Field field = fields.get(name); + ConfigurationCategory cat = field.getAnnotation(ConfigurationCategory.class); + String scat = cat == null ? "other" : cat.value(); + if (!categorized.containsKey(scat)) { + categorized.put(scat, new HashMap<>()); + } + + categorized.get(scat).put(name, field); + } + for (String cat : categorized.keySet()) { JPanel configPanel = new JPanel(new SpringLayout()); for (String name : categorized.get(cat).keySet()) { Field field = categorized.get(cat).get(name); - String locName = translate("config.name." + name); + String locName = resourceBundle.getString("config.name." + name); try { - ConfigurationItem item = (ConfigurationItem) field.get(null); ParameterizedType listType = (ParameterizedType) field.getGenericType(); Class itemType = (Class) listType.getActualTypeArguments()[0]; - String description = translate("config.description." + name); + String description = resourceBundle.getString("config.description." + name); Object defaultValue = Configuration.getDefaultValue(field); if (name.equals("gui.skin")) { @@ -279,10 +299,10 @@ public class AdvancedSettingsDialog extends AppDialog { } catch (ClassNotFoundException | NoSuchFieldException | SecurityException ex) { Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex); } - } + if (defaultValue != null) { - description += " (" + translate("default") + ": " + defaultValue + ")"; + description += " (" + resourceBundle.getString("default") + ": " + defaultValue + ")"; } JLabel l = new JLabel(locName, JLabel.TRAILING); @@ -334,34 +354,22 @@ public class AdvancedSettingsDialog extends AppDialog { } else { throw new UnsupportedOperationException("Configuration ttem type '" + itemType.getName() + "' is not supported"); } + componentsMap.put(name, c); l.setLabelFor(c); configPanel.add(c); - } catch (IllegalArgumentException | IllegalAccessException ex) { // Reflection exceptions. This should never happen throw new Error(ex.getMessage()); } } + SpringUtilities.makeCompactGrid(configPanel, categorized.get(cat).size(), 2, //rows, cols 6, 6, //initX, initY 6, 6); //xPad, yPad tabs.put(cat, new JScrollPane(configPanel)); } - - String catOrder[] = new String[]{"ui", "display", "decompilation", "script", "format", "export", "import", "limit", "update", "debug", "other"}; - - for (String cat : catOrder) { - if (!tabs.containsKey(cat)) { - continue; - } - tabPane.add(translate("config.group.name." + cat), tabs.get(cat)); - tabPane.setToolTipTextAt(tabPane.getTabCount() - 1, translate("config.group.description." + cat)); - } - - cnt.add(tabPane, BorderLayout.CENTER); - pack(); } private void showRestartConfirmDialod() { diff --git a/src/com/jpexs/decompiler/flash/gui/AppDialog.java b/src/com/jpexs/decompiler/flash/gui/AppDialog.java index 19b979e13..deb282b66 100644 --- a/src/com/jpexs/decompiler/flash/gui/AppDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AppDialog.java @@ -51,6 +51,10 @@ public abstract class AppDialog extends JDialog { } } + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + public String translate(String key) { return resourceBundle.getString(key); } diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 1be536f68..97eec12b1 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -156,18 +156,21 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { snapshotButton = new JButton(View.getIcon("snapshot16")); snapshotButton.addActionListener(this::snapShotButtonActionPerformed); snapshotButton.setToolTipText(AppStrings.translate("button.snapshot.hint")); + snapshotButton.setVisible(false); zoomPanel = new JPanel(new FlowLayout()); - //updateZoom(); zoomPanel.add(percentLabel); zoomPanel.add(zoomInButton); zoomPanel.add(zoomOutButton); zoomPanel.add(zoomNoneButton); zoomPanel.add(zoomFitButton); zoomPanel.add(selectColorButton); + zoomPanel.setVisible(false); + graphicButtonsPanel.add(zoomPanel); graphicButtonsPanel.add(snapshotButton); graphicControls.add(graphicButtonsPanel, BorderLayout.EAST); + graphicControls.setVisible(false); add(graphicControls); graphicControls.setVisible(display.screenAvailable()); @@ -186,7 +189,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { }); - frameLabel.setVisible(display.screenAvailable()); + frameLabel.setVisible(false); Dimension min = new Dimension(frameLabel.getFontMetrics(notUnderlinedFont).stringWidth("000"), frameLabel.getPreferredSize().height); frameLabel.setMinimumSize(min); @@ -216,8 +219,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { timeLabel = new JLabel("(00:00.00)"); totalTimeLabel = new JLabel("(00:00.00)"); totalFrameLabel = new JLabel("0"); - - totalFrameLabel.setVisible(display.screenAvailable()); + totalFrameLabel.setVisible(false); frameControls = new JPanel(new FlowLayout()); @@ -241,6 +243,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { gotoFrameButton.setMargin(new Insets(4, 2, 2, 2)); gotoFrameButton.addActionListener(this::gotoFrameButtonActionPerformed); frameControls.add(gotoFrameButton); + frameControls.setVisible(false); JPanel currentPanel = new JPanel(new FlowLayout()); currentPanel.add(frameControls); diff --git a/test/AdvancedSettingsTest.java b/test/AdvancedSettingsTest.java index 5994a5815..9ddf0a4af 100644 --- a/test/AdvancedSettingsTest.java +++ b/test/AdvancedSettingsTest.java @@ -1,6 +1,9 @@ +import com.jpexs.decompiler.flash.gui.AdvancedSettingsDialog; import com.jpexs.decompiler.flash.gui.AppStrings; -import com.jpexs.decompiler.flash.gui.MainFrame; +import java.util.HashMap; +import java.util.ResourceBundle; +import javax.swing.JComboBox; import org.testng.annotations.Test; /* @@ -27,7 +30,7 @@ public class AdvancedSettingsTest { @Test public void testAdvancedSettginsDialog() { - AppStrings.setResourceClass(MainFrame.class); - //new AdvancedSettingsDialog(); + ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(AdvancedSettingsDialog.class)); + AdvancedSettingsDialog.getCategories(new HashMap<>(), new HashMap<>(), new JComboBox<>(), resourceBundle); } }