From 23ec0f5dd9befd5edc1d77d57252d299f5e4c283 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Sat, 13 Sep 2008 22:04:05 +0000 Subject: [PATCH] Delays the creation of AddContactWizard for the purposed of UIServiceImpl's ExportedWindows because the mentioned creation is slow. --- .../communicator/impl/gui/UIServiceImpl.java | 4 +- .../addcontact/AddContactWizard.java | 44 +------ .../AddContactWizardExportedWindow.java | 120 ++++++++++++++++++ 3 files changed, 122 insertions(+), 46 deletions(-) create mode 100644 src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index c362f6d3f..c02a945fd 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -371,10 +371,8 @@ public boolean getExitOnMainWindowClose() */ public void initExportedWindows() { - AddContactWizard addContactWizard = new AddContactWizard(mainFrame); - registerExportedWindow(configurationFrame); - registerExportedWindow(addContactWizard); + registerExportedWindow(new AddContactWizardExportedWindow(mainFrame)); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java index 2e748c164..0c2ae853c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java @@ -14,7 +14,6 @@ import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; -import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -26,8 +25,7 @@ */ public class AddContactWizard extends Wizard - implements WizardListener, - ExportedWindow + implements WizardListener { private Logger logger = Logger.getLogger(AddContactWizard.class.getName()); @@ -210,37 +208,6 @@ public void setVisible(boolean isVisible) super.setVisible(false); } - /** - * Implements the ExportedWindow.getIdentifier() method. - */ - public WindowID getIdentifier() - { - return ExportedWindow.ADD_CONTACT_WINDOW; - } - - /** - * This dialog could not be minimized. - */ - public void minimize() - { - } - - /** - * This dialog could not be maximized. - */ - public void maximize() - { - } - - /** - * Implements the ExportedWindow.bringToFront() method. Brings this - * window to front. - */ - public void bringToFront() - { - this.toFront(); - } - /** * Returns the main application window. * @@ -250,13 +217,4 @@ public MainFrame getMainFrame() { return mainFrame; } - - /** - * The source of the window - * @return the source of the window - */ - public Object getSource() - { - return this; - } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java new file mode 100644 index 000000000..47f654464 --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizardExportedWindow.java @@ -0,0 +1,120 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.gui.main.contactlist.addcontact; + +import java.awt.Window; + +import net.java.sip.communicator.impl.gui.main.*; +import net.java.sip.communicator.service.gui.*; + +/** + * Implements ExportedWindow for the purposes of delaying the + * initialization of an associated AddContactWizard instance + * because it is slow. + * + * @author Lubomir Marinov + */ +public class AddContactWizardExportedWindow + implements ExportedWindow +{ + + /** + * The argument required by the AddContactWizard constructor. + */ + private final MainFrame mainFrame; + + /** + * The AddContactWizard adapted by this instance. + */ + private Window wizard; + + /** + * Initializes a new AddContactWizardExportedWindow which is to + * delay the initialization of a AddContactWizard with a + * specific MainFrame. + * + * @param mainFrame the argument required by the + * AddContactWizard constructor + */ + public AddContactWizardExportedWindow(MainFrame mainFrame) + { + this.mainFrame = mainFrame; + } + + public void bringToFront() + { + getWizard().toFront(); + } + + public WindowID getIdentifier() + { + return ExportedWindow.ADD_CONTACT_WINDOW; + } + + public Object getSource() + { + return getWizard(); + } + + /** + * Gets the AddContactWizard being adapted by this instance and + * creates it if it hasn't already been created. + * + * @return the AddContactWizard adapted by this instance + */ + private Window getWizard() + { + if (wizard == null) + { + wizard = new AddContactWizard(mainFrame); + } + return wizard; + } + + public boolean isFocused() + { + return getWizard().isFocused(); + } + + public boolean isVisible() + { + return getWizard().isVisible(); + } + + /** + * Does nothing because the dialog associated with this instance doesn't + * support maximizing. + */ + public void maximize() + { + // The dialog cannot be maximized. + } + + /** + * Does nothing because the dialog associated with this instance doesn't + * support minimizing. + */ + public void minimize() + { + // The dialog cannot be minimized. + } + + public void setLocation(int x, int y) + { + getWizard().setLocation(x, y); + } + + public void setSize(int width, int height) + { + getWizard().setSize(width, height); + } + + public void setVisible(boolean isVisible) + { + getWizard().setVisible(isVisible); + } +}