Skip to content

Commit

Permalink
New Release
Browse files Browse the repository at this point in the history
Resizing the editor works correctly
  • Loading branch information
Christian-2003 committed May 30, 2023
1 parent 45c018f commit 47761aa
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>de.vate</groupId>
<artifactId>VATE</artifactId>
<version>0.2</version>
<version>0.3</version>

<build>
<plugins>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/backend/config/Settings.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package backend.config;

import java.awt.*;
import java.util.ArrayList;

/**
Expand All @@ -22,4 +23,19 @@ public class Settings {
*/
public static ArrayList<String> PREVIOUSLY_OPENED_FILES = new ArrayList<>();

/**
* Stores whether VATE shall be instantiated with the last dimensions.
*/
public static boolean usePreviousDimensionWhenCreated = true;

/**
* Stores the last width of the main frame.
*/
public static int previousWidth = -1;

/**
* Stores the last height of the main frame.
*/
public static int previousHeight = -1;

}
1 change: 1 addition & 0 deletions src/main/java/frontend/dialogs/SearchDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private void create() {
add(buttonContainer, BorderLayout.SOUTH);
add(mainContainer, BorderLayout.NORTH);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setTitle(Config.strings.SEARCH_DIALOG_TITLE);
setSize(512, 256);
setVisible(true);
}
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/frontend/frames/main/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import frontend.menus.FileMenu;

import javax.swing.*;
import javax.tools.Tool;
import java.awt.*;
import java.io.IOException;

Expand Down Expand Up @@ -109,7 +110,17 @@ else if (Config.settings.LOAD_PREVIOUS_FILES_WHEN_OPENED) {
}
}

setSize(1024, 512);
//Set size:
if (Config.settings.usePreviousDimensionWhenCreated && Config.settings.previousHeight != -1 && Config.settings.previousWidth != -1) {
//Use previous dimensions:
setSize(Config.settings.previousWidth, Config.settings.previousHeight);
}
else {
//Use standard size:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setSize((int)(screenSize.getWidth() * 0.6), (int)(screenSize.getHeight() * 0.6));
}

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setVisible(true);
}
Expand Down Expand Up @@ -216,6 +227,13 @@ else if (option == JOptionPane.CANCEL_OPTION) {
Config.settings.PREVIOUSLY_OPENED_FILES.add(((Tab)tabs.getComponentAt(i)).getFile().getPath());
}

//Save the current dimension:
if (getExtendedState() != JFrame.MAXIMIZED_BOTH) {
//MainFrame is not in fullscreen, save current dimensions:
Config.settings.previousWidth = getWidth();
Config.settings.previousHeight = getHeight();
}

//Save the config:
try {
Config.saveConfig();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frontend/frames/main/components/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ public TextArea(Tab context) {

setViewportView(textPane);
setRowHeaderView(lineNumbers);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
}


Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: VATE

2 changes: 1 addition & 1 deletion vate.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"LINE_SEPARATOR":"\n"}
{"PROGRAM_FONT_SIZE":12,"TEXT_EDITOR_FONT_SIZE":16,"TEXT_EDITOR_FONT":"Consolas"}
{"USE_SYSTEM_LOOK_AND_FEEL":true,"LOAD_PREVIOUS_FILES_WHEN_OPENED":true,"PREVIOUSLY_OPENED_FILES":["test.txt","source.txt"]}
{"USE_SYSTEM_LOOK_AND_FEEL":true,"LOAD_PREVIOUS_FILES_WHEN_OPENED":true,"PREVIOUSLY_OPENED_FILES":["source.txt"],"usePreviousDimensionWhenCreated":true,"previousWidth":822,"previousHeight":458}

0 comments on commit 47761aa

Please sign in to comment.