From f255319f910eeb130ccb40f00f06eef53b670824 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 22 Jun 2015 13:11:34 +0200 Subject: [PATCH] Maximized state of IDE gets properly stored and restored. Fixes #2909 --- app/src/processing/app/Base.java | 8 ++++---- app/src/processing/app/Editor.java | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 15acb588a..3d7e969ba 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -558,7 +558,7 @@ public class Base { location = nextEditorLocation(); } // If file did not exist, null will be returned for the Editor - if (handleOpen(new File(path), location, true, false, false) != null) { + if (handleOpen(new File(path), location, nextEditorLocation(), true, false, false) != null) { opened++; } } @@ -890,10 +890,10 @@ public class Base { } protected Editor handleOpen(File file, int[] location, boolean showEditor, boolean untitled) throws Exception { - return handleOpen(file, location, showEditor, true, untitled); + return handleOpen(file, location, location, showEditor, true, untitled); } - protected Editor handleOpen(File file, int[] location, boolean showEditor, boolean storeOpenedSketches, boolean untitled) throws Exception { + protected Editor handleOpen(File file, int[] storedLocation, int[] defaultLocation, boolean showEditor, boolean storeOpenedSketches, boolean untitled) throws Exception { if (!file.exists()) return null; // Cycle through open windows to make sure that it's not already open. @@ -905,7 +905,7 @@ public class Base { } } - final Editor editor = new Editor(this, file, location, BaseNoGui.getPlatform()); + Editor editor = new Editor(this, file, storedLocation, defaultLocation, BaseNoGui.getPlatform()); // Make sure that the sketch actually loaded if (editor.getSketch() == null) { diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index e9e987c2f..ead54b09b 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -179,7 +179,7 @@ public class Editor extends JFrame implements RunnerListener { private Runnable exportAppHandler; - public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception { + public Editor(Base ibase, File file, int[] storedLocation, int[] defaultLocation, Platform platform) throws Exception { super("Arduino"); this.base = ibase; this.platform = platform; @@ -326,7 +326,7 @@ public class Editor extends JFrame implements RunnerListener { // System.out.println("t2"); // Set the window bounds and the divider location before setting it visible - setPlacement(location); + setPlacement(storedLocation, defaultLocation); // Set the minimum size for the editor window @@ -414,6 +414,14 @@ public class Editor extends JFrame implements RunnerListener { } } + private void setPlacement(int[] storedLocation, int[] defaultLocation) { + if (storedLocation.length > 5 && storedLocation[5] != 0) { + setExtendedState(storedLocation[5]); + setPlacement(defaultLocation); + } else { + setPlacement(storedLocation); + } + } private void setPlacement(int[] location) { setBounds(location[0], location[1], location[2], location[3]); @@ -422,9 +430,8 @@ public class Editor extends JFrame implements RunnerListener { } } - protected int[] getPlacement() { - int[] location = new int[5]; + int[] location = new int[6]; // Get the dimensions of the Frame Rectangle bounds = getBounds(); @@ -435,6 +442,7 @@ public class Editor extends JFrame implements RunnerListener { // Get the current placement of the divider location[4] = splitPane.getDividerLocation(); + location[5] = getExtendedState() & MAXIMIZED_BOTH; return location; }