mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 21:00:45 +00:00
Issue #155 Remembering window size and splitbar position between runs
This commit is contained in:
@@ -105,6 +105,10 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsConfig(String cfg) {
|
||||
return config.containsKey(cfg);
|
||||
}
|
||||
|
||||
public static Object getConfig(String cfg) {
|
||||
return getConfig(cfg, null);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.Configuration;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
@@ -30,6 +31,8 @@ import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -56,9 +59,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
public int listIndex = -1;
|
||||
public DecompiledEditorPane decompiledTextArea;
|
||||
public JScrollPane decompiledScrollPane;
|
||||
public JSplitPane splitPaneDecompiledVSDetail;
|
||||
public JSplitPane splitPaneTreeVSNavigator;
|
||||
public JSplitPane splitPaneTreeNavVSDecompiledDetail;
|
||||
public JSplitPane splitPane;
|
||||
//public JSplitPane splitPaneTreeVSNavigator;
|
||||
//public JSplitPane splitPaneTreeNavVSDecompiledDetail;
|
||||
private JTable constantTable;
|
||||
public JComboBox constantTypeList;
|
||||
public JLabel asmLabel = new JLabel("P-code source");
|
||||
@@ -224,7 +227,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
splitPaneDecompiledVSDetail.setDividerLocation(splitPaneDecompiledVSDetail.getWidth() * 1 / 2);
|
||||
|
||||
|
||||
splitPane.setDividerLocation((Integer) Configuration.getConfig("gui.avm2.splitPane.dividerLocation", splitPane.getWidth() * 1 / 2));
|
||||
|
||||
}
|
||||
|
||||
@@ -262,10 +267,17 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
panB.add(decLabel, BorderLayout.NORTH);
|
||||
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
splitPaneDecompiledVSDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
|
||||
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
|
||||
panB, detailPanel);
|
||||
splitPaneDecompiledVSDetail.setResizeWeight(0.5);
|
||||
splitPaneDecompiledVSDetail.setContinuousLayout(true);
|
||||
splitPane.setResizeWeight(0.5);
|
||||
splitPane.setContinuousLayout(true);
|
||||
|
||||
splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
Configuration.setConfig("gui.avm2.splitPane.dividerLocation", pce.getNewValue());
|
||||
}
|
||||
});
|
||||
decompiledTextArea.setContentType("text/actionscript");
|
||||
decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize()));
|
||||
|
||||
@@ -352,11 +364,11 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
filterPanel.add(picLabel, BorderLayout.EAST);
|
||||
treePanel.add(filterPanel, BorderLayout.NORTH);
|
||||
|
||||
splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
|
||||
treePanel,
|
||||
navPanel);
|
||||
splitPaneTreeVSNavigator.setResizeWeight(0.5);
|
||||
splitPaneTreeVSNavigator.setContinuousLayout(true);
|
||||
/* splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
|
||||
treePanel,
|
||||
navPanel);
|
||||
splitPaneTreeVSNavigator.setResizeWeight(0.5);
|
||||
splitPaneTreeVSNavigator.setContinuousLayout(true);*/
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabbedPane.addTab("Traits", navPanel);
|
||||
//tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
|
||||
@@ -377,7 +389,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
|
||||
add(splitPaneTreeNavVSDecompiledDetail, BorderLayout.CENTER);*/
|
||||
add(splitPaneDecompiledVSDetail, BorderLayout.CENTER);
|
||||
add(splitPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel panConstants = new JPanel();
|
||||
panConstants.setLayout(new BorderLayout());
|
||||
|
||||
@@ -44,6 +44,8 @@ import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
@@ -78,7 +80,6 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
public LineMarkedEditorPane recompiledEditor;
|
||||
public List<Tag> list;
|
||||
public JSplitPane splitPane;
|
||||
public JSplitPane splitPane2;
|
||||
public JButton saveButton = new JButton("Save", View.getIcon("save16"));
|
||||
public JButton editButton = new JButton("Edit", View.getIcon("edit16"));
|
||||
public JButton cancelButton = new JButton("Cancel", View.getIcon("cancel16"));
|
||||
@@ -455,10 +456,14 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
//add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER);
|
||||
add(splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, debugRecompile ? new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panB, panC) : panB), BorderLayout.CENTER);
|
||||
// splitPane.setResizeWeight(0.5);
|
||||
splitPane2.setResizeWeight(0.5);
|
||||
add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, debugRecompile ? new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panB, panC) : panB), BorderLayout.CENTER);
|
||||
splitPane.setResizeWeight(0.5);
|
||||
splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
Configuration.setConfig("gui.action.splitPane.dividerLocation", pce.getNewValue());
|
||||
}
|
||||
});
|
||||
editor.setContentType("text/flasm");
|
||||
editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize()));
|
||||
decompiledEditor.setContentType("text/actionscript");
|
||||
@@ -530,14 +535,12 @@ public class ActionPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
|
||||
public void initSplits() {
|
||||
//splitPane.setDividerLocation(getWidth() / 3);
|
||||
splitPane2.setDividerLocation(getWidth() / 2);
|
||||
splitPane.setDividerLocation((Integer) Configuration.getConfig("gui.action.splitPane.dividerLocation", getWidth() / 2));
|
||||
}
|
||||
|
||||
public void display() {
|
||||
setVisible(true);
|
||||
splitPane.setDividerLocation(0.5);
|
||||
splitPane2.setDividerLocation(0.5);
|
||||
}
|
||||
|
||||
public void setEditMode(boolean val) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Graph {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if(heads!=null){
|
||||
if (heads != null) {
|
||||
return;
|
||||
}
|
||||
heads = makeGraph(code, new ArrayList<GraphPart>(), alternateEntries);
|
||||
|
||||
@@ -74,8 +74,6 @@ public class GraphFrame extends JFrame {
|
||||
setPreferredSize(new Dimension(size.x, size.y));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
@@ -250,7 +248,7 @@ public class GraphFrame extends JFrame {
|
||||
gp = new GraphPanel(graph);
|
||||
setTitle("Graph " + name);
|
||||
cnt.add(new JScrollPane(gp));
|
||||
|
||||
|
||||
View.setWindowIcon(this);
|
||||
|
||||
}
|
||||
@@ -289,12 +287,12 @@ public class GraphFrame extends JFrame {
|
||||
arrowHead.addPoint(3, -8);
|
||||
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.setToIdentity();
|
||||
tx.setToIdentity();
|
||||
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
|
||||
tx.translate(line.x2, line.y2);
|
||||
tx.rotate((angle - Math.PI / 2d));
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
AffineTransform oldTransform = g2d.getTransform();
|
||||
g2d.draw(line);
|
||||
tx.preConcatenate(oldTransform);
|
||||
|
||||
@@ -113,12 +113,16 @@ import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.DropTargetDropEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -262,9 +266,25 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
}
|
||||
|
||||
public MainFrame(SWF swf) {
|
||||
setSize(1000, 700);
|
||||
int w = (Integer) Configuration.getConfig("gui.window.width", 1000);
|
||||
int h = (Integer) Configuration.getConfig("gui.window.height", 700);
|
||||
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
if (w > dim.width) {
|
||||
w = dim.width;
|
||||
}
|
||||
if (h > dim.height) {
|
||||
h = dim.height;
|
||||
}
|
||||
setSize(w, h);
|
||||
tabPane = new JTabbedPane();
|
||||
View.setWindowIcon(this);
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
Configuration.setConfig("gui.window.width", getWidth());
|
||||
Configuration.setConfig("gui.window.height", getHeight());
|
||||
}
|
||||
});
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
@@ -854,8 +874,25 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
//displayPanel.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pan1, detailPanel);
|
||||
splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane2, displayPanel);
|
||||
|
||||
|
||||
|
||||
cnt.add(splitPane1, BorderLayout.CENTER);
|
||||
splitPane1.setDividerLocation(0.5);
|
||||
|
||||
splitPane1.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
Configuration.setConfig("gui.splitPane1.dividerLocation", pce.getNewValue());
|
||||
}
|
||||
});
|
||||
|
||||
splitPane2.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
Configuration.setConfig("gui.splitPane2.dividerLocation", pce.getNewValue());
|
||||
}
|
||||
});
|
||||
View.centerScreen(this);
|
||||
tagTree.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
@@ -914,8 +951,10 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
if (actionPanel != null) {
|
||||
actionPanel.initSplits();
|
||||
}
|
||||
splitPane1.setDividerLocation(getWidth() / 3);
|
||||
splitPane2.setDividerLocation(splitPane2.getHeight() * 3 / 5);
|
||||
|
||||
splitPane1.setDividerLocation((Integer) Configuration.getConfig("gui.splitPane1.dividerLocation", getWidth() / 3));
|
||||
splitPane2.setDividerLocation((Integer) Configuration.getConfig("gui.splitPane2.dividerLocation", splitPane2.getHeight() * 3 / 5));
|
||||
|
||||
splitPos = splitPane2.getDividerLocation();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user