summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2014-06-12 16:06:47 +0000
committerMarko Živković <[email protected]>2014-06-12 16:06:47 +0000
commit643db0facc64bc51b5940a3f009ecae1ecd2a5e6 (patch)
tree7392c7f19b94bf39a1777b77a19d538b9543ff17
parent1107aa0763e3d7554408c401d2a1dbed11a94c51 (diff)
Settings Window is now created only once, thus does not consume more memory when opened several times.
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@2 3b0d7934-f7ef-4143-9606-b51f2e2281fd
-rw-r--r--logo/src/xlogo/gui/welcome/WelcomeScreen.java47
-rw-r--r--logo/src/xlogo/gui/welcome/WorkspaceSettings.java6
2 files changed, 31 insertions, 22 deletions
diff --git a/logo/src/xlogo/gui/welcome/WelcomeScreen.java b/logo/src/xlogo/gui/welcome/WelcomeScreen.java
index f6e068c..011081e 100644
--- a/logo/src/xlogo/gui/welcome/WelcomeScreen.java
+++ b/logo/src/xlogo/gui/welcome/WelcomeScreen.java
@@ -77,14 +77,16 @@ public class WelcomeScreen extends JFrame {
private JPanel panel = new JPanel();
private GroupLayout groupLayout;
- private ActionListener listener;
+ private ActionListener onApplicationEnterListener;
+
+ private WorkspaceSettings workspaceSettings;
/**
*
* @param listener to be informed when the user is ready to enter the application
*/
- public WelcomeScreen(ActionListener listener){
- this.listener = listener;
+ public WelcomeScreen(ActionListener onApplicationEnterListener){
+ this.onApplicationEnterListener = onApplicationEnterListener;
// Window
super.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setIconImage(Toolkit.getDefaultToolkit().createImage(Utils.class.getResource("Icon_x4s.png")));
@@ -160,8 +162,22 @@ public class WelcomeScreen extends JFrame {
setText();
pack();
setVisible(true);
- //MessageManager.getInstance().setParent(this);
+
+ /*
+ * Make this component the parent for popups and dialogs.
+ */
setMessageManagerParent();
+
+ workspaceSettings = new WorkspaceSettings(new ActionListener() {
+ public void actionPerformed(ActionEvent arg0) {
+ // When the window is closed, repopulate workspace and user lists, update language, enable this window again.
+ setMessageManagerParent();
+ setText();
+ populateWorkspaceList();
+ populateUserList();
+ setEnabled(true);
+ }
+ });
}
private void initWorkspaceListModel()
@@ -281,13 +297,12 @@ public class WelcomeScreen extends JFrame {
)
);
}
-
+
/**
* Display {@link xlogo.gui.welcome.WelcomeScreen} when starting the application.
*/
- private void showWorkspaceSettings()
- {
-
+ private synchronized void showWorkspaceSettings()
+ {
Runnable runnable = new Runnable() {
public void run() {
String authentification = null;
@@ -308,18 +323,8 @@ public class WelcomeScreen extends JFrame {
}
}
- ActionListener listener = new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- setMessageManagerParent();
- setText();
- populateWorkspaceList();
- populateUserList();
- setEnabled(true);
- }
- };
-
setEnabled(false);
- new WorkspaceSettings(listener, authentification);
+ workspaceSettings.showFrame(authentification);
}
};
@@ -371,7 +376,6 @@ public class WelcomeScreen extends JFrame {
public void enterApplication()
{
- System.gc();
String username = (String) userSelection.getSelectedItem();
if ((username == null) || (username.length() == 0))
@@ -398,8 +402,9 @@ public class WelcomeScreen extends JFrame {
Logo.messages.getString("welcome.could.not.enter.user") + e.toString());
return;
}
+ workspaceSettings.stopEventListeners();
+ onApplicationEnterListener.actionPerformed(new ActionEvent(this, 0, null));
System.gc();
- listener.actionPerformed(new ActionEvent(this, 0, null));
}
@Override
diff --git a/logo/src/xlogo/gui/welcome/WorkspaceSettings.java b/logo/src/xlogo/gui/welcome/WorkspaceSettings.java
index 9634325..e82acef 100644
--- a/logo/src/xlogo/gui/welcome/WorkspaceSettings.java
+++ b/logo/src/xlogo/gui/welcome/WorkspaceSettings.java
@@ -64,10 +64,14 @@ public class WorkspaceSettings extends X4SFrame {
*/
private ActionListener listener;
- public WorkspaceSettings(ActionListener listener, String authentification)
+ public WorkspaceSettings(ActionListener listener)
{
super();
this.listener = listener;
+ }
+
+ public void showFrame(String authentification)
+ {
globalTab.authenticate(authentification);
frame.setVisible(true);
}