Fixes a memory leak of 600+ KB caused by .plugin.simpleaccreg.InitialAccountRegistrationFrame being retained.

cusax-fix
Lyubomir Marinov 18 years ago
parent b2aad2c146
commit c48ee0d7c6

@ -33,71 +33,65 @@ public class InitialAccountRegistrationFrame
extends JFrame
implements ServiceListener
{
private Logger logger
private final Logger logger
= Logger.getLogger(InitialAccountRegistrationFrame.class);
private JPanel messageAreaPanel
= new JPanel(new FlowLayout(FlowLayout.CENTER));
private JTextArea messageArea =
new JTextArea(Resources.getString("initialAccountRegistration"));
private MainPanel mainPanel = new MainPanel(new BorderLayout(5, 5));
private JPanel mainAccountsPanel = new JPanel(new BorderLayout(10, 10));
private JPanel accountsPanel = new JPanel(new GridLayout(0, 2, 10, 10));
private JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
private JButton signinButton
= new JButton(Resources.getString("signin"));
private JButton signinButton = new JButton(Resources.getString("signin"));
private JButton cancelButton
= new JButton(Resources.getString("cancel"));
private Vector registrationForms = new Vector();
private Collection registrationForms = new Vector();
/**
* Creates an instance of <tt>NoAccountFoundPage</tt>.
*/
public InitialAccountRegistrationFrame()
{
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
MainPanel mainPanel = new MainPanel(new BorderLayout(5, 5));
JPanel messageAreaPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JTextArea messageArea =
new JTextArea(Resources.getString("initialAccountRegistration"));
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton cancelButton = new JButton(Resources.getString("cancel"));
this.setTitle(Resources.getString("signin"));
this.mainPanel.setBorder(
BorderFactory.createEmptyBorder(20, 20, 20, 20));
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
this.getContentPane().add(mainPanel);
this.mainPanel.add(messageAreaPanel, BorderLayout.NORTH);
this.mainPanel.add(mainAccountsPanel, BorderLayout.CENTER);
this.mainPanel.add(buttonPanel, BorderLayout.SOUTH);
mainPanel.add(messageAreaPanel, BorderLayout.NORTH);
mainPanel.add(mainAccountsPanel, BorderLayout.CENTER);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
this.messageAreaPanel.add(messageArea);
this.messageArea.setPreferredSize(new Dimension(350, 20));
this.messageArea.setFont(messageArea.getFont().deriveFont(Font.BOLD));
messageAreaPanel.add(messageArea);
messageArea.setPreferredSize(new Dimension(350, 20));
messageArea.setFont(messageArea.getFont().deriveFont(Font.BOLD));
this.mainAccountsPanel.add(accountsPanel, BorderLayout.CENTER);
mainAccountsPanel.add(accountsPanel, BorderLayout.CENTER);
this.mainAccountsPanel.setOpaque(false);
this.accountsPanel.setOpaque(false);
this.buttonPanel.setOpaque(false);
this.messageArea.setOpaque(false);
this.messageAreaPanel.setOpaque(false);
mainAccountsPanel.setOpaque(false);
accountsPanel.setOpaque(false);
buttonPanel.setOpaque(false);
messageArea.setOpaque(false);
messageAreaPanel.setOpaque(false);
SigninActionListener actionListener = new SigninActionListener();
this.signinButton.addActionListener(actionListener);
this.cancelButton.addActionListener(actionListener);
signinButton.addActionListener(actionListener);
cancelButton.addActionListener(actionListener);
this.buttonPanel.add(cancelButton);
this.buttonPanel.add(signinButton);
buttonPanel.add(cancelButton);
buttonPanel.add(signinButton);
this.messageArea.setLineWrap(true);
this.messageArea.setWrapStyleWord(true);
this.messageArea.setEditable(false);
this.messageArea.setOpaque(false);
messageArea.setLineWrap(true);
messageArea.setWrapStyleWord(true);
messageArea.setEditable(false);
messageArea.setOpaque(false);
this.getRootPane().setDefaultButton(signinButton);
@ -108,19 +102,18 @@ public InitialAccountRegistrationFrame()
if(groupName != null && groupName.length() > 0)
{
Iterator iter = SimpleAccountRegistrationActivator.getContactList().
getRoot().getSubgroups();
while (iter.hasNext())
MetaContactListService contactList =
SimpleAccountRegistrationActivator.getContactList();
Iterator iter = contactList.getRoot().getSubgroups();
while (iter.hasNext())
{
MetaContactGroup gr = (MetaContactGroup)iter.next();
if(gr.getGroupName().equals(groupName))
MetaContactGroup gr = (MetaContactGroup) iter.next();
if (groupName.equals(gr.getGroupName()))
return;
}
SimpleAccountRegistrationActivator.getContactList().
createMetaContactGroup(
SimpleAccountRegistrationActivator.getContactList().getRoot(),
groupName);
contactList
.createMetaContactGroup(contactList.getRoot(), groupName);
SimpleAccountRegistrationActivator.getConfigurationService().
setProperty(
@ -391,13 +384,6 @@ public void signin()
}
}
/**
*
*/
protected void close(boolean isEscaped)
{
}
/**
* Handles registration of a new account wizard.
*/
@ -485,11 +471,12 @@ public void actionPerformed(ActionEvent evt)
regForm.signin();
}
}
InitialAccountRegistrationFrame.this.dispose();
}
else
InitialAccountRegistrationFrame.this.dispose();
InitialAccountRegistrationFrame initialAccountRegistrationFrame =
InitialAccountRegistrationFrame.this;
initialAccountRegistrationFrame.setVisible(false);
initialAccountRegistrationFrame.dispose();
}
}

@ -19,14 +19,12 @@
public class SimpleAccountRegistrationActivator
implements BundleActivator
{
private static Logger logger
private static final Logger logger
= Logger.getLogger(SimpleAccountRegistrationActivator.class);
public static BundleContext bundleContext;
private static ConfigurationService configService;
private static MetaContactListService contactListService;
public void start(BundleContext bc) throws Exception
{
@ -39,12 +37,11 @@ public void start(BundleContext bc) throws Exception
= new InitialAccountRegistrationFrame();
accountRegFrame.pack();
accountRegFrame.setLocation(
Toolkit.getDefaultToolkit().getScreenSize().width/2
- accountRegFrame.getWidth()/2,
Toolkit.getDefaultToolkit().getScreenSize().height/2
- accountRegFrame.getHeight()/2
);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
accountRegFrame.setLocation(screenSize.width / 2
- accountRegFrame.getWidth() / 2, screenSize.height / 2
- accountRegFrame.getHeight() / 2);
accountRegFrame.setVisible(true);
}
@ -129,23 +126,27 @@ private static boolean hasRegisteredAccounts()
return hasRegisteredAccounts;
}
/**
* Returns the <tt>MetaContactListService</tt> obtained from the bundle
* context.
* <p>
* <b>Note</b>: Because this plug-in is meant to be initially displayed (if
* necessary) and not get used afterwards, the method doesn't cache the
* return value. Make sure you call it as little as possible if execution
* speed is under consideration.
* </p>
*
* @return the <tt>MetaContactListService</tt> obtained from the bundle
* context
* context
*/
public static MetaContactListService getContactList()
public static MetaContactListService getContactList()
{
if (contactListService == null) {
ServiceReference serviceReference = bundleContext
.getServiceReference(MetaContactListService.class.getName());
contactListService = (MetaContactListService) bundleContext
.getService(serviceReference);
}
ServiceReference serviceReference =
bundleContext.getServiceReference(MetaContactListService.class
.getName());
return contactListService;
return (MetaContactListService) bundleContext
.getService(serviceReference);
}
}

Loading…
Cancel
Save