- Delays the creation of the Options dialog and the loading of the ConfigurationForm implementations (which get listed in the Options dialog).

- Spares a couple of ImageIcon allocations.
- Removes unused fields and fixes raw-type warnings in the files touched by the other changes.
cusax-fix
Lyubomir Marinov 17 years ago
parent 3c911f558f
commit 2e83c45aa2

@ -206,8 +206,8 @@
<!-- Import installation build xml --> <!-- Import installation build xml -->
<import file="${inst.resrc}/build.xml"/> <import file="${inst.resrc}/build.xml"/>
<!-- default Ant target does nothing except print helpful options --> <!-- default Ant target does nothing except print helpful options -->
<!-- Ant-external target will appear in -projecthelp output --> <!-- Ant-external target will appear in -projecthelp output -->
<target name="ant-usage" <target name="ant-usage"
description="simply execute 'ant' to discover the most useful targets."> description="simply execute 'ant' to discover the most useful targets.">
<echo message="Useful ant commands for the SIP Communicator Project..." /> <echo message="Useful ant commands for the SIP Communicator Project..." />

@ -130,8 +130,6 @@ public void loadApplicationGui()
this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame); this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);
this.configurationFrame = new ConfigurationFrame(mainFrame);
if (ConfigurationManager.isTransparentWindowEnabled()) if (ConfigurationManager.isTransparentWindowEnabled())
{ {
try try
@ -385,7 +383,6 @@ public boolean getExitOnMainWindowClose()
*/ */
public void initExportedWindows() public void initExportedWindows()
{ {
registerExportedWindow(configurationFrame);
registerExportedWindow(new AddContactWizardExportedWindow(mainFrame)); registerExportedWindow(new AddContactWizardExportedWindow(mainFrame));
} }
@ -984,4 +981,11 @@ public void beginShutdown()
} }
} }
} }
public void setConfigurationWindowVisible(boolean visible)
{
if (configurationFrame == null)
configurationFrame = new ConfigurationFrame(mainFrame);
configurationFrame.setVisible(visible);
}
} }

@ -22,15 +22,15 @@
public class FramedImage public class FramedImage
extends JComponent extends JComponent
{ {
private ImageIcon shadowIcon; private final Image shadowImage;
private ImageIcon frameIcon; private final Image frameImage;
private ImageIcon imageIcon; private Image image;
private int width; private final int width;
private int height; private final int height;
/** /**
* Creates a ContactPhotoLabel by specifying the width and the height of the * Creates a ContactPhotoLabel by specifying the width and the height of the
@ -42,27 +42,17 @@ public class FramedImage
*/ */
public FramedImage(ImageIcon imageIcon, int width, int height) public FramedImage(ImageIcon imageIcon, int width, int height)
{ {
super();
this.width = width; this.width = width;
this.height = height; this.height = height;
this.setPreferredSize(new Dimension(width, height)); this.setPreferredSize(new Dimension(width, height));
Image photoFrameImage this.frameImage =
= ImageLoader.getImage(ImageLoader.USER_PHOTO_FRAME); ImageUtils.scaleImageWithinBounds(ImageLoader
.getImage(ImageLoader.USER_PHOTO_FRAME), width, height);
this.frameIcon this.shadowImage =
= ImageUtils.scaleIconWithinBounds( photoFrameImage, ImageUtils.scaleImageWithinBounds(ImageLoader
width, .getImage(ImageLoader.USER_PHOTO_SHADOW), width, height);
height);
this.shadowIcon
= ImageUtils.scaleIconWithinBounds(
ImageLoader.getImage(ImageLoader.USER_PHOTO_SHADOW),
width,
height);
if (imageIcon != null) if (imageIcon != null)
{ {
@ -75,34 +65,25 @@ public FramedImage(int width, int height)
this(null, width, height); this(null, width, height);
} }
public ImageIcon getImageIcon()
{
return imageIcon;
}
public void setImageIcon(ImageIcon imageIcon) public void setImageIcon(ImageIcon imageIcon)
{ {
this.imageIcon this.image =
= ImageUtils.getScaledRoundedImage( imageIcon.getImage(), ImageUtils.getScaledRoundedImage(imageIcon.getImage(), width - 2,
width - 2, height - 2);
height - 2);
} }
/** /*
* Overrides {@link JComponent#paintComponent(Graphics)}. * Overrides {@link JComponent#paintComponent(Graphics)}.
*/ */
public void paintComponent(Graphics g) public void paintComponent(Graphics g)
{ {
g.drawImage(imageIcon.getImage(), g.drawImage(image, width / 2 - image.getWidth(null) / 2, height / 2
width/2 - imageIcon.getIconWidth()/2, - image.getHeight(null) / 2, null);
height/2 - imageIcon.getIconHeight()/2, null);
g.drawImage(frameIcon.getImage(), g.drawImage(frameImage, width / 2 - frameImage.getWidth(null) / 2,
width/2 - frameIcon.getIconWidth()/2, height / 2 - frameImage.getHeight(null) / 2, null);
height/2 - frameIcon.getIconHeight()/2, null);
g.drawImage(shadowIcon.getImage(), g.drawImage(shadowImage, width / 2 - shadowImage.getWidth(null) / 2, 1,
width/2 - shadowIcon.getIconWidth()/2, null);
1, null);
} }
} }

@ -1,65 +0,0 @@
/*
* 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.account;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
/**
* The <tt>AccountsConfigurationForm</tt> is the form where the user could
* create, modify or delete an account.
*
* @author Yana Stamcheva
*/
public class AccountsConfigurationForm
extends AbstractConfigurationForm
{
private Object form;
/**
* Returns the form of this configuration form.
*
* @return the form of this configuration form.
*/
public Object getForm()
{
if (form == null)
form = super.getForm();
return form;
}
protected String getFormClassName()
{
return "net.java.sip.communicator.impl.gui.main.account.AccountsConfigurationPanel";
}
/**
* Returns the icon of this configuration form.
*
* @return the icon of this configuration form.
*/
public byte[] getIcon()
{
return ImageLoader.getImageInBytes(ImageLoader.ACCOUNT_ICON);
}
public int getIndex()
{
return 1;
}
/**
* Returns the title of this configuration form.
*
* @return the title of this configuration form.
*/
public String getTitle()
{
return GuiActivator.getResources()
.getI18NString("service.gui.ACCOUNTS");
}
}

@ -129,9 +129,9 @@ private void initCallLabel(JLabel callLabel)
boolean hasMoreParticipants = false; boolean hasMoreParticipants = false;
String text = ""; String text = "";
ImageIcon imageIcon = ImageUtils.getScaledRoundedImage( ImageIcon imageIcon =
ImageLoader.getImage(ImageLoader.DEFAULT_USER_PHOTO), ImageUtils.getScaledRoundedIcon(ImageLoader
40, 45); .getImage(ImageLoader.DEFAULT_USER_PHOTO), 40, 45);
while (participantsIter.hasNext()) while (participantsIter.hasNext())
{ {

@ -492,10 +492,7 @@ else if (buttonText.equals("addContact"))
} }
else if (buttonText.equalsIgnoreCase("settings")) else if (buttonText.equalsIgnoreCase("settings"))
{ {
ExportedWindow configDialog = GuiActivator.getUIService() GuiActivator.getUIService().setConfigurationWindowVisible(true);
.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
configDialog.setVisible(true);
} }
} }

@ -20,7 +20,6 @@
import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.Container;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
@ -58,8 +57,6 @@ public class MainToolBar
private ChatWindow messageWindow; private ChatWindow messageWindow;
private Contact currentChatContact = null;
/** /**
* Empty constructor to be used from inheritors. * Empty constructor to be used from inheritors.
*/ */
@ -192,10 +189,7 @@ else if (buttonText.equals("invite"))
} }
else if (buttonText.equals("options")) else if (buttonText.equals("options"))
{ {
ExportedWindow optionsDialog = GuiActivator.getUIService() GuiActivator.getUIService().setConfigurationWindowVisible(true);
.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
optionsDialog.setVisible(true);
} }
} }

@ -29,7 +29,9 @@ public class ConfigFormDescriptor
private final ConfigurationForm configForm; private final ConfigurationForm configForm;
private ImageIcon configFormIcon; private ImageIcon configFormIcon;
private Component configFormPanel;
private String configFormTitle; private String configFormTitle;
/** /**
@ -76,14 +78,18 @@ public ImageIcon getConfigFormIcon()
*/ */
public Component getConfigFormPanel() public Component getConfigFormPanel()
{ {
Object form = configForm.getForm(); if (configFormPanel == null)
if ((form instanceof Component) == false)
{ {
throw new ClassCastException("ConfigurationFrame :" Object form = configForm.getForm();
+ form.getClass() if ((form instanceof Component) == false)
+ " is not a class supported by this ui implementation"); {
throw new ClassCastException("ConfigurationFrame :"
+ form.getClass()
+ " is not a class supported by this ui implementation");
}
configFormPanel = (Component) form;
} }
return (Component) form; return configFormPanel;
} }
/** /**

@ -4,7 +4,6 @@
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.impl.gui.main.configforms; package net.java.sip.communicator.impl.gui.main.configforms;
import javax.swing.*; import javax.swing.*;
@ -22,9 +21,9 @@ public class ConfigFormList
extends JList extends JList
implements ListSelectionListener implements ListSelectionListener
{ {
private DefaultListModel listModel = new DefaultListModel(); private final DefaultListModel listModel = new DefaultListModel();
private ConfigurationFrame configFrame; private final ConfigurationFrame configFrame;
/** /**
* Creates an instance of <tt>ConfigFormList</tt> * Creates an instance of <tt>ConfigFormList</tt>

@ -12,7 +12,6 @@
import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.account.*;
import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
@ -27,24 +26,16 @@
*/ */
public class ConfigurationFrame public class ConfigurationFrame
extends SIPCommDialog extends SIPCommDialog
implements ExportedWindow, ServiceListener implements ServiceListener
{ {
private Logger logger = Logger.getLogger(ConfigurationFrame.class); private final Logger logger = Logger.getLogger(ConfigurationFrame.class);
private ConfigFormList configList; private final ConfigFormList configList;
private SCScrollPane configScrollList; private final TitlePanel titlePanel = new TitlePanel();
private TitlePanel titlePanel = new TitlePanel(); private final JPanel centerPanel =
new TransparentPanel(new BorderLayout(5, 5));
private TransparentPanel mainPanel
= new TransparentPanel(new BorderLayout(5, 5));
private TransparentPanel centerPanel
= new TransparentPanel(new BorderLayout(5, 5));
private TransparentPanel buttonsPanel
= new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
/** /**
* Creates an instance of <tt>ConfigurationManagerImpl</tt>. * Creates an instance of <tt>ConfigurationManagerImpl</tt>.
@ -55,14 +46,18 @@ public ConfigurationFrame(MainFrame mainFrame)
{ {
super(mainFrame); super(mainFrame);
JPanel mainPanel = new TransparentPanel(new BorderLayout(5, 5));
JPanel buttonsPanel =
new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
this.configList = new ConfigFormList(this); this.configList = new ConfigFormList(this);
this.configScrollList = new SCScrollPane(); SCScrollPane configScrollList = new SCScrollPane();
this.configScrollList.setHorizontalScrollBarPolicy( configScrollList.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.configScrollList.setViewportView(configList); configScrollList.setViewportView(configList);
this.setTitle(GuiActivator.getResources() this.setTitle(GuiActivator.getResources()
.getI18NString("service.gui.SETTINGS")); .getI18NString("service.gui.SETTINGS"));
@ -71,16 +66,16 @@ public ConfigurationFrame(MainFrame mainFrame)
this.addDefaultForms(); this.addDefaultForms();
this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(centerPanel, BorderLayout.CENTER);
this.mainPanel.add(configScrollList, BorderLayout.WEST); mainPanel.add(configScrollList, BorderLayout.WEST);
buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, buttonsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0,
Constants.BORDER_COLOR)); Constants.BORDER_COLOR));
this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
this.getContentPane().add(mainPanel); this.getContentPane().add(mainPanel);
@ -116,7 +111,11 @@ public ConfigurationFrame(MainFrame mainFrame)
*/ */
public void addDefaultForms() public void addDefaultForms()
{ {
this.addConfigurationForm(new AccountsConfigurationForm()); this
.addConfigurationForm(new LazyConfigurationForm(
"net.java.sip.communicator.impl.gui.main.account.AccountsConfigurationPanel",
getClass().getClassLoader(), "service.gui.icons.ACCOUNT_ICON",
"service.gui.ACCOUNTS", 1));
} }
/** /**
@ -161,24 +160,6 @@ public void setVisible(boolean isVisible)
super.setVisible(isVisible); super.setVisible(isVisible);
} }
/**
* Implements <code>ApplicationWindow.minimizeWindow</code> method.
*
* @see net.java.sip.communicator.service.gui.ExportedWindow#minimize()
*/
public void minimize()
{
}
/**
* Implements <code>ApplicationWindow.maximizeWindow</code> method.
*
* @see net.java.sip.communicator.service.gui.ExportedWindow#maximize()
*/
public void maximize()
{
}
/** /**
* Implements <tt>SIPCommFrame.close()</tt> method. Performs a click on * Implements <tt>SIPCommFrame.close()</tt> method. Performs a click on
* the close button. * the close button.
@ -190,36 +171,6 @@ protected void close(boolean isEscaped)
{ {
} }
/**
* Returns the identifier of this <tt>ExportedWindow</tt>.
*
* @return a reference to the <tt>WindowID</tt> instance representing this
* frame.
*/
public WindowID getIdentifier()
{
return ExportedWindow.CONFIGURATION_WINDOW;
}
/**
* Implements the <tt>ExportedWindow.bringToFront</tt> method. Brings this
* window to front.
*/
public void bringToFront()
{
this.toFront();
}
/**
* The source of the window
*
* @return the source of the window
*/
public Object getSource()
{
return this;
}
/** /**
* Handles registration of a new configuration form. * Handles registration of a new configuration form.
*/ */
@ -289,9 +240,4 @@ private void removeConfigurationForm(ConfigurationForm configForm)
{ {
this.configList.removeConfigForm(configForm); this.configList.removeConfigForm(configForm);
} }
/**
* Implementation of {@link ExportedWindow#setParams(Object[])}.
*/
public void setParams(Object[] windowParams) {}
} }

@ -202,10 +202,7 @@ public void actionPerformed(ActionEvent e)
} }
else if (buttonName.equals("options")) else if (buttonName.equals("options"))
{ {
ExportedWindow optionsDialog = GuiActivator.getUIService() GuiActivator.getUIService().setConfigurationWindowVisible(true);
.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
optionsDialog.setVisible(true);
} }
else if (buttonName.equals("showOffline")) else if (buttonName.equals("showOffline"))
{ {

@ -92,15 +92,13 @@ public class ExtendedQuickMenu
private MoreButton moreButton = new MoreButton(); private MoreButton moreButton = new MoreButton();
private ExportedWindow configDialog;
private MainFrame mainFrame; private MainFrame mainFrame;
private int movedDownButtons = 0; private final Map<PluginComponent, Component> pluginsTable =
new Hashtable<PluginComponent, Component>();
private Hashtable pluginsTable = new Hashtable();
private LinkedList components = new LinkedList(); private final java.util.List<Component> components =
new LinkedList<Component>();
/** /**
* Create an instance of the <tt>QuickMenu</tt>. * Create an instance of the <tt>QuickMenu</tt>.
@ -273,17 +271,7 @@ public void actionPerformed(ActionEvent arg0)
wizard.setVisible(true); wizard.setVisible(true);
} }
} }
private class ConfigAction extends AbstractAction
{
public void actionPerformed(ActionEvent arg0)
{
configDialog = GuiActivator.getUIService()
.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
configDialog.setVisible(true);
}
}
/** /**
* Handles the <tt>ActionEvent</tt> triggered when user clicks on one of * Handles the <tt>ActionEvent</tt> triggered when user clicks on one of
* the buttons in this toolbar. * the buttons in this toolbar.
@ -379,14 +367,14 @@ public void componentHidden(ComponentEvent e)
*/ */
public void componentMoved(ComponentEvent e) public void componentMoved(ComponentEvent e)
{ {
int compCount = this.components.size();
int maxWidth = this.toolBar.getWidth(); int maxWidth = this.toolBar.getWidth();
int width = 0; int width = 0;
for (int i = 0; i < compCount; i ++) for (Component component : components)
{ {
JComponent c = (JComponent) this.components.get(i); if (!(component instanceof JComponent))
continue;
JComponent c = (JComponent) component;
width += c.getWidth() + 10; width += c.getWidth() + 10;
@ -420,12 +408,8 @@ public void valueChanged(ListSelectionEvent e)
{ {
if((e.getFirstIndex() != -1 || e.getLastIndex() != -1)) if((e.getFirstIndex() != -1 || e.getLastIndex() != -1))
{ {
Enumeration plugins = pluginsTable.keys(); for (PluginComponent plugin : pluginsTable.keySet())
while (plugins.hasMoreElements())
{ {
PluginComponent plugin = (PluginComponent) plugins.nextElement();
Object selectedValue = mainFrame.getContactListPanel() Object selectedValue = mainFrame.getContactListPanel()
.getContactList().getSelectedValue(); .getContactList().getSelectedValue();
@ -457,8 +441,6 @@ public void updateMuteButton(boolean isMute)
private class ToolBarButton private class ToolBarButton
extends JLabel extends JLabel
{ {
private Image iconImage;
private boolean isMouseOver = false; private boolean isMouseOver = false;
private boolean isMousePressed = false; private boolean isMousePressed = false;
@ -554,10 +536,7 @@ public void mouseClicked(MouseEvent e)
} }
else if (buttonName.equals("config")) else if (buttonName.equals("config"))
{ {
configDialog = GuiActivator.getUIService() GuiActivator.getUIService().setConfigurationWindowVisible(true);
.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
configDialog.setVisible(true);
} }
else if (buttonName.equals("search")) else if (buttonName.equals("search"))
{ {
@ -635,12 +614,12 @@ else if (buttonName.equals("info"))
(MetaContact) selectedValue; (MetaContact) selectedValue;
OperationSetWebContactInfo wContactInfo = null; OperationSetWebContactInfo wContactInfo = null;
Iterator protocolContacts = selectedMetaContact.getContacts(); Iterator<Contact> protocolContacts = selectedMetaContact.getContacts();
while(protocolContacts.hasNext()) while (protocolContacts.hasNext())
{ {
Contact protoContact = (Contact) protocolContacts.next(); Contact protoContact = protocolContacts.next();
wContactInfo = mainFrame.getWebContactInfoOpSet( wContactInfo = mainFrame.getWebContactInfoOpSet(
protoContact.getProtocolProvider()); protoContact.getProtocolProvider());

@ -35,10 +35,6 @@ public class ToolsMenu
{ {
private final Logger logger = Logger.getLogger(ToolsMenu.class); private final Logger logger = Logger.getLogger(ToolsMenu.class);
private MainFrame parentWindow;
private ExportedWindow configDialog;
/** /**
* Creates an instance of <tt>FileMenu</tt>. * Creates an instance of <tt>FileMenu</tt>.
* @param parentWindow The parent <tt>ChatWindow</tt>. * @param parentWindow The parent <tt>ChatWindow</tt>.
@ -114,11 +110,7 @@ public void actionPerformed(ActionEvent e)
void configActionPerformed() void configActionPerformed()
{ {
ExportedWindow configDialog = GuiActivator.getUIService().setConfigurationWindowVisible(true);
GuiActivator.getUIService().getExportedWindow(
ExportedWindow.CONFIGURATION_WINDOW);
configDialog.setVisible(true);
} }
public void pluginComponentAdded(PluginComponentEvent event) public void pluginComponentAdded(PluginComponentEvent event)

@ -28,12 +28,13 @@
*/ */
public class ImageLoader { public class ImageLoader {
private static Logger log = Logger.getLogger(ImageLoader.class); private static final Logger log = Logger.getLogger(ImageLoader.class);
/** /**
* Stores all already loaded images. * Stores all already loaded images.
*/ */
private static Hashtable loadedImages = new Hashtable(); private static final Map<ImageID, BufferedImage> loadedImages =
new Hashtable<ImageID, BufferedImage>();
/** /**
* The SIP Communicator logo 16x16 icon. * The SIP Communicator logo 16x16 icon.
@ -191,12 +192,6 @@ public class ImageLoader {
public static final ImageID DOWN_ARROW_ICON public static final ImageID DOWN_ARROW_ICON
= new ImageID("service.gui.icons.DOWN_ARROW_ICON"); = new ImageID("service.gui.icons.DOWN_ARROW_ICON");
/**
* The icon on the "Add contact" button in the <tt>QuickMenu</tt>.
*/
public static final ImageID ACCOUNT_ICON
= new ImageID("service.gui.icons.ACCOUNT_ICON");
/** /**
* The icon on the "Add contact" button in the <tt>QuickMenu</tt>. * The icon on the "Add contact" button in the <tt>QuickMenu</tt>.
*/ */
@ -1088,7 +1083,7 @@ public static BufferedImage getImage(ImageID imageID)
if (loadedImages.containsKey(imageID)) if (loadedImages.containsKey(imageID))
{ {
image = (BufferedImage) loadedImages.get(imageID); image = loadedImages.get(imageID);
} }
else else
{ {
@ -1192,9 +1187,7 @@ public static Image getBytesInImage(byte[] imageBytes)
*/ */
public static BufferedImage[] getAnimatedImage(byte[] animatedImage) public static BufferedImage[] getAnimatedImage(byte[] animatedImage)
{ {
Iterator readers = ImageIO.getImageReadersBySuffix("gif"); ImageReader reader = ImageIO.getImageReadersBySuffix("gif").next();
ImageReader reader = (ImageReader) readers.next();
ImageInputStream iis; ImageInputStream iis;
@ -1234,14 +1227,10 @@ public static BufferedImage[] getAnimatedImage(byte[] animatedImage)
*/ */
public static String getImagePath(Image image) public static String getImagePath(Image image)
{ {
Iterator i = ImageLoader.loadedImages.entrySet().iterator(); for (Map.Entry<ImageID, BufferedImage> entry : loadedImages.entrySet()) {
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
if (entry.getValue().equals(image)) if (entry.getValue().equals(image))
{ {
String imageID = ((ImageID) entry.getKey()).getId(); String imageID = entry.getKey().getId();
try try
{ {

@ -8,7 +8,7 @@
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.fileaccess.*; import net.java.sip.communicator.service.fileaccess.*;
import net.java.sip.communicator.service.gui.ConfigurationForm; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.media.*; import net.java.sip.communicator.service.media.*;
import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.netaddr.*;
import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.service.resources.*;
@ -67,7 +67,10 @@ public void start(BundleContext context)
// MediaConfigurationForm // MediaConfigurationForm
context.registerService(ConfigurationForm.class.getName(), context.registerService(ConfigurationForm.class.getName(),
new MediaConfigurationForm(), null); new LazyConfigurationForm(
"net.java.sip.communicator.impl.media.MediaConfigurationPanel",
getClass().getClassLoader(), "plugin.mediaconfig.PLUGIN_ICON",
"impl.media.configform.TITLE"), null);
} }
/** /**

@ -1,33 +0,0 @@
/*
* 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.media;
import net.java.sip.communicator.service.gui.*;
/**
* @author Lubomir Marinov
*/
public class MediaConfigurationForm
extends AbstractConfigurationForm
{
protected String getFormClassName()
{
return "net.java.sip.communicator.impl.media.MediaConfigurationPanel";
}
public byte[] getIcon()
{
return MediaActivator.getResources().getImageInBytes(
"plugin.mediaconfig.PLUGIN_ICON");
}
public String getTitle()
{
return MediaActivator.getResources().getI18NString(
"impl.media.configform.TITLE");
}
}

@ -300,7 +300,7 @@ public void registerCustomCodecs()
.getSupportedOutputFormats(null), .getSupportedOutputFormats(null),
PlugInManager.CODEC); PlugInManager.CODEC);
logger.debug("Codec : " + className logger.debug("Codec : " + className
+ " is succsefully registered : " + result); + " is successfully registered : " + result);
} }
catch (Throwable ex) catch (Throwable ex)
{ {

@ -23,13 +23,11 @@
public class NotificationActivator public class NotificationActivator
implements BundleActivator implements BundleActivator
{ {
private Logger logger = Logger.getLogger(NotificationActivator.class); private final Logger logger = Logger.getLogger(NotificationActivator.class);
private static BundleContext bundleContext; private static BundleContext bundleContext;
private static ConfigurationService configService; private static ConfigurationService configService;
private NotificationServiceImpl notificationService;
private static AudioNotifierService audioNotifierService; private static AudioNotifierService audioNotifierService;
@ -41,15 +39,14 @@ public void start(BundleContext bc) throws Exception
try { try {
// Create the notification service implementation // Create the notification service implementation
this.notificationService = new NotificationServiceImpl(); NotificationService notificationService =
new NotificationServiceImpl();
logger.info("Notification Service...[ STARTED ]"); logger.info("Notification Service...[ STARTED ]");
bundleContext.registerService( bundleContext.registerService(NotificationService.class.getName(),
NotificationService.class.getName(), notificationService, null);
this.notificationService,
null);
logger.info("Notification Service ...[REGISTERED]"); logger.info("Notification Service ...[REGISTERED]");
logger.logEntry(); logger.logEntry();

@ -25,7 +25,7 @@ public class NotificationServiceImpl
private final Logger logger = private final Logger logger =
Logger.getLogger(NotificationServiceImpl.class); Logger.getLogger(NotificationServiceImpl.class);
private static String NOTIFICATIONS_PREFIX = private static final String NOTIFICATIONS_PREFIX =
"net.java.sip.communicator.impl.notifications"; "net.java.sip.communicator.impl.notifications";
/** /**
@ -37,23 +37,24 @@ public class NotificationServiceImpl
/** /**
* A set of all registered event notifications. * A set of all registered event notifications.
*/ */
private Hashtable defaultNotificationsTable = new Hashtable(); private final Map<String, EventNotification> defaultNotificationsTable =
new Hashtable<String, EventNotification>();
/** /**
* A list of all registered <tt>NotificationChangeListener</tt>s. * A list of all registered <tt>NotificationChangeListener</tt>s.
*/ */
private Vector changeListeners = new Vector(); private final List<NotificationChangeListener> changeListeners =
new Vector<NotificationChangeListener>();
private ConfigurationService configService = null;
private final ConfigurationService configService =
NotificationActivator.getConfigurationService();
/** /**
* Creates an instance of <tt>NotificationServiceImpl</tt> by loading all * Creates an instance of <tt>NotificationServiceImpl</tt> by loading all
* previously saved notifications. * previously saved notifications.
*/ */
public NotificationServiceImpl() public NotificationServiceImpl()
{ {
configService = NotificationActivator.getConfigurationService();
// Load all previously saved notifications. // Load all previously saved notifications.
this.loadNotifications(); this.loadNotifications();
} }
@ -753,13 +754,9 @@ private void fireNotificationEventTypeEvent(String eventType,
NotificationEventTypeEvent event NotificationEventTypeEvent event
= new NotificationEventTypeEvent(this, eventType, sourceEventType); = new NotificationEventTypeEvent(this, eventType, sourceEventType);
NotificationChangeListener listener; for (NotificationChangeListener listener : changeListeners)
for (int i = 0 ; i < changeListeners.size(); i ++)
{ {
listener = (NotificationChangeListener) changeListeners.get(i);
if (eventType.equals(NotificationEventTypeEvent.EVENT_TYPE_ADDED)) if (eventType.equals(NotificationEventTypeEvent.EVENT_TYPE_ADDED))
{ {
listener.eventTypeAdded(event); listener.eventTypeAdded(event);
@ -911,29 +908,17 @@ public void registerDefaultNotificationForEvent(
// We fire the appropriate event depending on whether this is an // We fire the appropriate event depending on whether this is an
// already existing actionType or a new one. // already existing actionType or a new one.
if (!isNew) fireNotificationActionTypeEvent(
{ isNew ? NotificationActionTypeEvent.ACTION_ADDED
fireNotificationActionTypeEvent( : NotificationActionTypeEvent.ACTION_CHANGED, eventType,
NotificationActionTypeEvent.ACTION_CHANGED, actionType, handler);
eventType,
actionType,
handler);
}
else
{
fireNotificationActionTypeEvent(
NotificationActionTypeEvent.ACTION_ADDED,
eventType,
actionType,
handler);
}
} }
// now store this default events if we want to retore them // now store this default events if we want to retore them
EventNotification notification = null; EventNotification notification = null;
if(defaultNotificationsTable.containsKey(eventType)) if(defaultNotificationsTable.containsKey(eventType))
notification = (EventNotification) defaultNotificationsTable.get(eventType); notification = defaultNotificationsTable.get(eventType);
else else
{ {
notification = new EventNotification(eventType); notification = new EventNotification(eventType);
@ -1016,29 +1001,17 @@ else if (actionType.equals(NotificationService.ACTION_COMMAND))
// We fire the appropriate event depending on whether this is an // We fire the appropriate event depending on whether this is an
// already existing actionType or a new one. // already existing actionType or a new one.
if (!isNew) fireNotificationActionTypeEvent(
{ isNew ? NotificationActionTypeEvent.ACTION_ADDED
fireNotificationActionTypeEvent( : NotificationActionTypeEvent.ACTION_CHANGED, eventType,
NotificationActionTypeEvent.ACTION_CHANGED, actionType, handler);
eventType,
actionType,
handler);
}
else
{
fireNotificationActionTypeEvent(
NotificationActionTypeEvent.ACTION_ADDED,
eventType,
actionType,
handler);
}
} }
// now store this default events if we want to retore them // now store this default events if we want to restore them
EventNotification notification = null; EventNotification notification = null;
if(defaultNotificationsTable.containsKey(eventType)) if(defaultNotificationsTable.containsKey(eventType))
notification = (EventNotification) defaultNotificationsTable.get(eventType); notification = defaultNotificationsTable.get(eventType);
else else
{ {
notification = new EventNotification(eventType); notification = new EventNotification(eventType);
@ -1075,16 +1048,14 @@ else if (actionType.equals(NotificationService.ACTION_COMMAND))
*/ */
public void restoreDefaults() public void restoreDefaults()
{ {
Iterator iter = Set<String> eventTypes =
((Hashtable)notificationsTable.clone()).keySet().iterator(); ((Hashtable<String, EventNotification>) notificationsTable.clone())
.keySet();
while (iter.hasNext())
for (String eventType : eventTypes)
{ {
String eventType = (String)iter.next(); EventNotification notification = notificationsTable.get(eventType);
EventNotification notification
= (EventNotification) notificationsTable.get(eventType);
Vector actionsToRemove = new Vector(notification.getActions().keySet()); Vector actionsToRemove = new Vector(notification.getActions().keySet());
Iterator actionIter = actionsToRemove.iterator(); Iterator actionIter = actionsToRemove.iterator();
while (actionIter.hasNext()) while (actionIter.hasNext())
@ -1096,16 +1067,12 @@ public void restoreDefaults()
removeEventNotification(eventType); removeEventNotification(eventType);
} }
iter = defaultNotificationsTable.keySet().iterator(); for (Map.Entry<String, EventNotification> entry : defaultNotificationsTable.entrySet())
while (iter.hasNext())
{ {
String eventType = (String)iter.next(); String eventType = entry.getKey();
EventNotification notification = entry.getValue();
EventNotification notification
= (EventNotification) defaultNotificationsTable.get(eventType);
Iterator actionIter = notification.getActions().keySet().iterator(); Iterator actionIter = notification.getActions().keySet().iterator();
while (actionIter.hasNext()) while (actionIter.hasNext())
{ {

@ -18,15 +18,12 @@
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
/** /**
*
* @author Shobhit Jindal * @author Shobhit Jindal
*/ */
class SSHContactInfo extends SIPCommDialog class SSHContactInfo extends SIPCommDialog {
implements ConfigurationForm {
private ContactSSH sshContact; private ContactSSH sshContact;
private JPanel mainPanel = new TransparentPanel(); private JPanel mainPanel = new TransparentPanel();
@ -210,15 +207,7 @@ public void actionPerformed(ActionEvent event) {
public byte[] getIcon() { public byte[] getIcon() {
return Resources.getImage(Resources.SSH_LOGO); return Resources.getImage(Resources.SSH_LOGO);
} }
/**
* Return the main panel
*
* @return the main panel
*/
public Object getForm() {
return mainPanel;
}
// //
// public void setContactGroup(ContactGroup contactGroup) // public void setContactGroup(ContactGroup contactGroup)
// { // {
@ -338,11 +327,6 @@ public void setPort(String port) {
this.portField.setText(port); this.portField.setText(port);
} }
public int getIndex()
{
return -1;
}
protected void close(boolean isEscaped) protected void close(boolean isEscaped)
{ {
} }

@ -47,11 +47,7 @@ private static void actionPerformed(ActionEvent evt)
if (itemName.equals("settings")) if (itemName.equals("settings"))
{ {
ExportedWindow configWindow = SystrayActivator.getUIService().setConfigurationWindowVisible(true);
SystrayActivator.getUIService().getExportedWindow(
ExportedWindow.CONFIGURATION_WINDOW);
configWindow.setVisible(true);
} }
else if (itemName.equals("service.gui.CLOSE")) else if (itemName.equals("service.gui.CLOSE"))
{ {

@ -4,16 +4,13 @@
* Distributable under LGPL license. * Distributable under LGPL license.
* See terms of license at gnu.org. * See terms of license at gnu.org.
*/ */
package net.java.sip.communicator.plugin.accountinfo; package net.java.sip.communicator.plugin.accountinfo;
import java.util.Hashtable; import java.util.*;
import java.util.Map;
import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.util.*;
import org.osgi.framework.*; import org.osgi.framework.*;
@ -25,27 +22,21 @@
public class AccountInfoActivator public class AccountInfoActivator
implements BundleActivator implements BundleActivator
{ {
private static Logger logger = private static final Logger logger =
Logger.getLogger(AccountInfoActivator.class.getName()); Logger.getLogger(AccountInfoActivator.class);
public static BundleContext bundleContext; public static BundleContext bundleContext;
private static Map providerFactoriesMap = new Hashtable();
private static BrowserLauncherService browserLauncherService; private static BrowserLauncherService browserLauncherService;
public void start(BundleContext bc) throws Exception public void start(BundleContext bc) throws Exception
{ {
AccountInfoActivator.bundleContext = bc; AccountInfoActivator.bundleContext = bc;
ServiceReference uiServiceRef = // new LazyConfigurationForm(
bc.getServiceReference(UIService.class.getName()); // "net.java.sip.communicator.plugin.accountinfo.AccountInfoPanel",
// getClass().getClassLoader(), "plugin.accountinfo.PLUGIN_ICON",
UIService uiService = (UIService) bc.getService(uiServiceRef); // "plugin.accountinfo.TITLE");
ExportedWindow configWindow
= uiService.getExportedWindow(ExportedWindow.CONFIGURATION_WINDOW);
// configWindow.addConfigurationForm(new AccountInfoForm());
} }
public void stop(BundleContext bc) throws Exception public void stop(BundleContext bc) throws Exception
@ -59,8 +50,10 @@ public void stop(BundleContext bc) throws Exception
* @return all <tt>ProtocolProviderFactory</tt>s obtained from the bundle * @return all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
* context * context
*/ */
public static Map getProtocolProviderFactories() public static Map<Object, ProtocolProviderFactory> getProtocolProviderFactories()
{ {
Map<Object, ProtocolProviderFactory> providerFactoriesMap =
new Hashtable<Object, ProtocolProviderFactory>();
ServiceReference[] serRefs = null; ServiceReference[] serRefs = null;
try try
@ -105,4 +98,4 @@ public static BrowserLauncherService getBrowserLauncher()
return browserLauncherService; return browserLauncherService;
} }
} }

@ -10,7 +10,6 @@
import javax.swing.*; import javax.swing.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
@ -23,9 +22,8 @@
* *
* @author Adam Goldstein * @author Adam Goldstein
*/ */
public class AccountInfoForm public class AccountInfoPanel
extends TransparentPanel extends TransparentPanel
implements ConfigurationForm
{ {
/** /**
* The right side of the AccountInfo frame that contains protocol specific * The right side of the AccountInfo frame that contains protocol specific
@ -33,10 +31,8 @@ public class AccountInfoForm
*/ */
private AccountDetailsPanel detailsPanel; private AccountDetailsPanel detailsPanel;
private JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false); private final Map<ProtocolProviderService, AccountDetailsPanel> accountsTable =
new Hashtable<ProtocolProviderService, AccountDetailsPanel>();
private Hashtable<ProtocolProviderService, AccountDetailsPanel>
accountsTable = new Hashtable();
/** /**
* Constructs a frame with an AccuontInfoAccountPanel to display all * Constructs a frame with an AccuontInfoAccountPanel to display all
@ -45,39 +41,23 @@ public class AccountInfoForm
* *
* @param metaContact * @param metaContact
*/ */
public AccountInfoForm() public AccountInfoPanel()
{ {
super(new BorderLayout()); super(new BorderLayout());
Set set = AccountInfoActivator.getProtocolProviderFactories().entrySet(); JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false);
Iterator iter = set.iterator();
boolean hasRegisteredAccounts = false;
while (iter.hasNext()) for (ProtocolProviderFactory providerFactory : AccountInfoActivator
.getProtocolProviderFactories().values())
{ {
Map.Entry entry = (Map.Entry) iter.next(); ArrayList<AccountID> accountsList =
providerFactory.getRegisteredAccounts();
ProtocolProviderFactory providerFactory
= (ProtocolProviderFactory) entry.getValue();
ArrayList accountsList = providerFactory.getRegisteredAccounts();
AccountID accountID;
ServiceReference serRef; ServiceReference serRef;
ProtocolProviderService protocolProvider; ProtocolProviderService protocolProvider;
for (int i = 0; i < accountsList.size(); i++) for (AccountID accountID : accountsList)
{ {
accountID = (AccountID) accountsList.get(i);
boolean isHidden =
accountID
.getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null;
if(!isHidden)
hasRegisteredAccounts = true;
serRef = providerFactory.getProviderForAccount(accountID); serRef = providerFactory.getProviderForAccount(accountID);
protocolProvider = (ProtocolProviderService) AccountInfoActivator protocolProvider = (ProtocolProviderService) AccountInfoActivator
@ -90,7 +70,7 @@ public AccountInfoForm()
protocolProvider.addRegistrationStateChangeListener( protocolProvider.addRegistrationStateChangeListener(
new RegistrationStateChangeListenerImpl()); new RegistrationStateChangeListenerImpl());
this.accountsTabbedPane.addTab( accountsTabbedPane.addTab(
accountID.getUserID(), detailsPanel); accountID.getUserID(), detailsPanel);
} }
} }
@ -98,36 +78,6 @@ public AccountInfoForm()
this.add(accountsTabbedPane, BorderLayout.CENTER); this.add(accountsTabbedPane, BorderLayout.CENTER);
} }
/**
* Returns the title of this configuration form.
*
* @return the icon of this configuration form.
*/
public String getTitle()
{
return Resources.getString("plugin.accountinfo.TITLE");
}
/**
* Returns the icon of this configuration form.
*
* @return the icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getImageInBytes("plugin.accountinfo.PLUGIN_ICON");
}
/**
* Returns the form of this configuration form.
*
* @return the form of this configuration form.
*/
public Object getForm()
{
return this;
}
private class RegistrationStateChangeListenerImpl private class RegistrationStateChangeListenerImpl
implements RegistrationStateChangeListener implements RegistrationStateChangeListener
{ {
@ -150,9 +100,4 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
} }
} }
} }
}
public int getIndex()
{
return -1;
}
}

@ -44,15 +44,16 @@ public class AutoAwayActivator implements BundleActivator
public void start(BundleContext bc) throws Exception public void start(BundleContext bc) throws Exception
{ {
bundleContext = bc; bundleContext = bc;
// Set config form // Set config form
AutoAwayConfigForm statusCF = new AutoAwayConfigForm(); bundleContext
bundleContext.registerService(ConfigurationForm.class.getName(), .registerService(
statusCF, ConfigurationForm.class.getName(),
null); new LazyConfigurationForm(
"net.java.sip.communicator.plugin.autoaway.AutoAwayConfigurationPanel",
getClass().getClassLoader(), "plugin.autoaway.PLUGIN_ICON",
"plugin.autoaway.AUTO_STATUS"), null);
new Thread(new Runnable() new Thread(new Runnable()
{ {

@ -14,7 +14,6 @@
import javax.swing.event.*; import javax.swing.event.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
/** /**
@ -23,9 +22,8 @@
* *
* @author Damien Roth * @author Damien Roth
*/ */
public class AutoAwayConfigForm public class AutoAwayConfigurationPanel
extends TransparentPanel extends TransparentPanel
implements ConfigurationForm
{ {
private JCheckBox enable; private JCheckBox enable;
private JSpinner timer; private JSpinner timer;
@ -33,7 +31,7 @@ public class AutoAwayConfigForm
/** /**
* Create an instance of <tt>StatusConfigForm</tt> * Create an instance of <tt>StatusConfigForm</tt>
*/ */
public AutoAwayConfigForm() public AutoAwayConfigurationPanel()
{ {
super(new BorderLayout(10, 10)); super(new BorderLayout(10, 10));
@ -155,42 +153,4 @@ private void saveData()
Integer interval = (Integer) timer.getValue(); Integer interval = (Integer) timer.getValue();
configService.setProperty(Preferences.TIMER, interval); configService.setProperty(Preferences.TIMER, interval);
} }
/**
* Implements the <tt>ConfigurationForm.getForm()</tt> method. Returns the
* component corresponding to this configuration form.
*/
public Object getForm()
{
return this;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return AutoAwayActivator.getResources()
.getImageInBytes("plugin.autoaway.PLUGIN_ICON");
}
/**
* Implements the <tt>ConfigurationForm.getIndex()</tt> method.
*/
public int getIndex()
{
return -1;
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public String getTitle()
{
return AutoAwayActivator.getResources()
.getI18NString("plugin.autoaway.AUTO_STATUS");
}
} }

@ -191,11 +191,10 @@ private JPanel createSummaryInfoPanel()
); );
} }
else else
scaledImage = ImageUtils.getScaledRoundedImage( scaledImage =
Resources.getImage("service.gui.DEFAULT_USER_PHOTO"), ImageUtils.getScaledRoundedIcon(Resources
AVATAR_AREA_WIDTH, .getImage("service.gui.DEFAULT_USER_PHOTO"),
AVATAR_AREA_HEIGHT AVATAR_AREA_WIDTH, AVATAR_AREA_HEIGHT);
);
JLabel label = new JLabel(scaledImage); JLabel label = new JLabel(scaledImage);
label.setVerticalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER);

@ -33,12 +33,14 @@ public void start(BundleContext bc) throws Exception
ConfigurationManager.loadGuiConfigurations(); ConfigurationManager.loadGuiConfigurations();
GeneralConfigurationForm preferencesForm bundleContext
= new GeneralConfigurationForm(); .registerService(
ConfigurationForm.class.getName(),
bundleContext.registerService( ConfigurationForm.class.getName(), new LazyConfigurationForm(
preferencesForm, "net.java.sip.communicator.plugin.generalconfig.GeneralConfigurationPanel",
null); getClass().getClassLoader(),
"plugin.generalconfig.PLUGIN_ICON", "service.gui.GENERAL",
0), null);
logger.info("PREFERENCES PLUGIN... [REGISTERED]"); logger.info("PREFERENCES PLUGIN... [REGISTERED]");
} }

@ -22,12 +22,11 @@
/** /**
* @author Yana Stamcheva * @author Yana Stamcheva
*/ */
public class GeneralConfigurationForm public class GeneralConfigurationPanel
extends javax.swing.JPanel extends JPanel
implements ConfigurationForm, implements ActionListener
ActionListener
{ {
private Logger logger = Logger.getLogger(GeneralConfigurationForm.class); private final Logger logger = Logger.getLogger(GeneralConfigurationPanel.class);
private JPanel mainPanel; private JPanel mainPanel;
private JCheckBox bringToFrontCheckBox; private JCheckBox bringToFrontCheckBox;
@ -43,9 +42,8 @@ public class GeneralConfigurationForm
private JCheckBox showHistoryCheckBox; private JCheckBox showHistoryCheckBox;
private JPanel logHistoryPanel; private JPanel logHistoryPanel;
public GeneralConfigurationForm() public GeneralConfigurationPanel()
{ {
super();
initGUI(); initGUI();
initDefaults(); initDefaults();
} }
@ -317,26 +315,6 @@ private String getApplicationName()
return Resources.getSettingsString("service.gui.APPLICATION_NAME"); return Resources.getSettingsString("service.gui.APPLICATION_NAME");
} }
public Object getForm()
{
return this;
}
public byte[] getIcon()
{
return Resources.getImage("plugin.generalconfig.PLUGIN_ICON");
}
public String getTitle()
{
return Resources.getString("service.gui.GENERAL");
}
public int getIndex()
{
return 0;
}
public void actionPerformed(ActionEvent event) public void actionPerformed(ActionEvent event)
{ {
Object sourceObject = event.getSource(); Object sourceObject = event.getSource();

@ -38,8 +38,14 @@ public void start(BundleContext context)
logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]"); logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]");
context.registerService(ConfigurationForm.class.getName(), context
new KeybindingsConfigForm(), null); .registerService(
ConfigurationForm.class.getName(),
new LazyConfigurationForm(
"net.java.sip.communicator.plugin.keybindingchooser.KeybindingsConfigPanel",
getClass().getClassLoader(),
"plugin.keybinding.PLUGIN_ICON",
"plugin.keybindings.PLUGIN_NAME"), null);
} }
/** /**

@ -1,45 +0,0 @@
/*
* 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.plugin.keybindingchooser;
import net.java.sip.communicator.service.gui.*;
/**
* The <tt>ConfigurationForm</tt> that would be added to the settings
* configuration to configure the application keybindings.
*
* @author Damian Johnson
* @author Lubomir Marinov
*/
public class KeybindingsConfigForm
extends AbstractConfigurationForm
{
/**
* Implements the <tt>ConfigurationForm.getTitle()</tt> method. Returns the
* title of this configuration form.
*/
public String getTitle()
{
return KeybindingChooserActivator.getResources().getI18NString(
"plugin.keybindings.PLUGIN_NAME");
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return KeybindingChooserActivator.getResources().getImageInBytes(
"plugin.keybinding.PLUGIN_ICON");
}
protected String getFormClassName()
{
return "net.java.sip.communicator.plugin.keybindingchooser.KeybindingsConfigPanel";
}
}

@ -23,7 +23,7 @@
public class MailboxActivator public class MailboxActivator
implements BundleActivator implements BundleActivator
{ {
private static Logger logger = private static final Logger logger =
Logger.getLogger(BundleActivator.class); Logger.getLogger(BundleActivator.class);
/** /**
@ -74,12 +74,13 @@ public void start(BundleContext bundleContext) throws Exception
mailbox = new Mailbox(); mailbox = new Mailbox();
mailbox.start(bundleContext); mailbox.start(bundleContext);
MailboxConfigurationForm mailboxForm bundleContext
= new MailboxConfigurationForm(); .registerService(
ConfigurationForm.class.getName(),
bundleContext.registerService( ConfigurationForm.class.getName(), new LazyConfigurationForm(
mailboxForm, "net.java.sip.communicator.plugin.mailbox.MailboxConfigurationPanel",
null); getClass().getClassLoader(), "plugin.mailbox.PLUGIN_ICON",
"plugin.mailbox.MAILBOX"), null);
logger.info("Mailbox plug-in...[STARTED]"); logger.info("Mailbox plug-in...[STARTED]");
} }

@ -13,19 +13,18 @@
import javax.swing.*; import javax.swing.*;
import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.swing.*; import net.java.sip.communicator.util.swing.*;
/** /**
* The <tt>ConfigurationForm</tt> that would be added in the user interface * The <tt>ConfigurationForm</tt> that would be added in the user interface
* configuration window. It allows the user to change parameters in the * configuration window. It allows the user to change parameters in the mailbox
* mailbox configuration * configuration
*
* @author Ryan Ricard * @author Ryan Ricard
*/ */
public class MailboxConfigurationForm public class MailboxConfigurationPanel
extends TransparentPanel extends TransparentPanel
implements ConfigurationForm, ActionListener implements ActionListener
{ {
private JLabel jlblOutgoingMessage private JLabel jlblOutgoingMessage
= new JLabel(Resources.getString("plugin.mailbox.OUTGOING")); = new JLabel(Resources.getString("plugin.mailbox.OUTGOING"));
@ -85,10 +84,10 @@ public class MailboxConfigurationForm
private JPanel jpConfirmDefault = new TransparentPanel(); private JPanel jpConfirmDefault = new TransparentPanel();
ConfigurationService config; ConfigurationService config;
public MailboxConfigurationForm() public MailboxConfigurationPanel()
{ {
super(new GridLayout(5,1)); super(new GridLayout(5,1));
config = MailboxActivator.getConfigurationService(); config = MailboxActivator.getConfigurationService();
//get our outgoing file panel set up //get our outgoing file panel set up
jtfOutgoingMessage.setText(Mailbox.getOutgoingMessageFileLocation() jtfOutgoingMessage.setText(Mailbox.getOutgoingMessageFileLocation()
@ -220,36 +219,4 @@ else if (e.getSource() == jbtnDefault)
} }
} }
}
/**
* Implements the <tt>ConfigurationForm.getTitle()</tt> method. Returns the
* title of this configuration form.
*/
public String getTitle()
{
return Resources.getString("plugin.mailbox.MAILBOX");
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getImageInBytes("plugin.mailbox.PLUGIN_ICON");
}
/**
* Implements the <tt>ConfigurationForm.getForm()</tt> method. Returns the
* component corresponding to this configuration form.
*/
public Object getForm()
{
return this;
}
public int getIndex()
{
return -1;
}
}

@ -7,8 +7,8 @@
package net.java.sip.communicator.plugin.notificationconfiguration; package net.java.sip.communicator.plugin.notificationconfiguration;
import net.java.sip.communicator.service.audionotifier.*; import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.*;
import org.osgi.framework.*; import org.osgi.framework.*;
@ -35,9 +35,14 @@ public void start(BundleContext bc) throws Exception
{ {
bundleContext = bc; bundleContext = bc;
bundleContext.registerService( ConfigurationForm.class.getName(), bundleContext
new NotificationConfigurationForm(), .registerService(
null); ConfigurationForm.class.getName(),
new LazyConfigurationForm(
"net.java.sip.communicator.plugin.notificationconfiguration.NotificationConfigurationPanel",
getClass().getClassLoader(),
"plugin.notificationconfig.PLUGIN_ICON",
"service.gui.NOTIFICATIONS"), null);
logger.trace("Notification Configuration: [ STARTED ]"); logger.trace("Notification Configuration: [ STARTED ]");
} }

@ -1,57 +0,0 @@
/*
* 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.plugin.notificationconfiguration;
import net.java.sip.communicator.service.gui.*;
/**
* Implements the <code>ConfigurationForm</code> interface in order to allow
* integrating the UI of this plug-in into the configuration UI.
* <p>
* The interface implementation in question is separated from the very UI
* implementation in order to allow the <code>ConfigurationForm</code> to be
* loaded at startup without creating and loading the very UI implementation.
* </p>
*
* @author Lubomir Marinov
*/
public class NotificationConfigurationForm
implements ConfigurationForm
{
/**
* Implements the <tt>ConfigurationForm.getForm()</tt> method. Returns the
* component corresponding to this configuration form.
*/
public Object getForm()
{
return new NotificationConfigurationPanel();
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getImageInBytes("plugin.notificationconfig.PLUGIN_ICON");
}
public int getIndex()
{
return -1;
}
/**
* Implements the <tt>ConfigurationForm.getTitle()</tt> method. Returns the
* title of this configuration form.
*/
public String getTitle()
{
return Resources.getString("service.gui.NOTIFICATIONS");
}
}

@ -82,8 +82,6 @@ public class NotificationConfigurationPanel
public NotificationConfigurationPanel() public NotificationConfigurationPanel()
{ {
super();
JPanel actions = new TransparentPanel(); JPanel actions = new TransparentPanel();
GridBagLayout actionsLayout = new GridBagLayout(); GridBagLayout actionsLayout = new GridBagLayout();
JPanel applyPanel = new TransparentPanel(); JPanel applyPanel = new TransparentPanel();

@ -33,10 +33,14 @@ public void start(BundleContext bc) throws Exception
{ {
bundleContext = bc; bundleContext = bc;
PluginManagerConfigForm pluginManager = new PluginManagerConfigForm(); bundleContext
.registerService(
bundleContext.registerService(ConfigurationForm.class.getName(), ConfigurationForm.class.getName(),
pluginManager, null); new LazyConfigurationForm(
"net.java.sip.communicator.plugin.pluginmanager.PluginManagerPanel",
getClass().getClassLoader(),
"plugin.pluginmanager.PLUGIN_ICON",
"plugin.pluginmanager.PLUGINS"), null);
} }
/** /**

@ -1,46 +0,0 @@
/*
* 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.plugin.pluginmanager;
import net.java.sip.communicator.service.gui.*;
/**
* The <tt>ConfigurationForm</tt> that would be added in the user interface
* configuration window. It contains a list of all installed plug-ins. Allows
* installing new plugins and managing the existing ones.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class PluginManagerConfigForm
extends AbstractConfigurationForm
{
/**
* Implements the <tt>ConfigurationForm.getTitle()</tt> method. Returns the
* title of this configuration form.
*/
public String getTitle()
{
return Resources.getString("plugin.pluginmanager.PLUGINS");
}
/**
* Implements the <tt>ConfigurationForm.getIcon()</tt> method. Returns the
* icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getResources().getImageInBytes(
"plugin.pluginmanager.PLUGIN_ICON");
}
protected String getFormClassName()
{
return "net.java.sip.communicator.plugin.pluginmanager.PluginManagerPanel";
}
}

@ -29,6 +29,7 @@
* accounts are found. * accounts are found.
* *
* @author Yana Stamcheva * @author Yana Stamcheva
* @author Lubomir Marinov
*/ */
public class InitialAccountRegistrationFrame public class InitialAccountRegistrationFrame
extends JFrame extends JFrame
@ -179,10 +180,9 @@ private void initAccountWizards()
} }
} }
private class AccountRegistrationPanel extends JPanel private class AccountRegistrationPanel
extends JPanel
{ {
private JLabel protocolLabel = new JLabel();
private JLabel usernameLabel private JLabel usernameLabel
= new JLabel(Resources.getString("service.gui.LOGIN")); = new JLabel(Resources.getString("service.gui.LOGIN"));
@ -204,20 +204,8 @@ private class AccountRegistrationPanel extends JPanel
private JPanel iconDescriptionPanel = new JPanel(new BorderLayout()); private JPanel iconDescriptionPanel = new JPanel(new BorderLayout());
private JPanel inputRegisterPanel = new JPanel(new BorderLayout());
private JTextArea descriptionArea = new JTextArea(); private JTextArea descriptionArea = new JTextArea();
private JLabel signupLabel
= new JLabel("<html><a href=''>"
+ Resources.getString("plugin.simpleaccregwizz.SIGNUP")
+ "</a></html>", JLabel.RIGHT);
private JLabel specialSignupLabel
= new JLabel("<html><a href=''>"
+ Resources.getString("plugin.simpleaccregwizz.SPECIAL_SIGNUP")
+ "</a></html>", JLabel.RIGHT);
private final AccountRegistrationWizard wizard; private final AccountRegistrationWizard wizard;
public AccountRegistrationPanel( public AccountRegistrationPanel(
@ -228,6 +216,9 @@ public AccountRegistrationPanel(
this.wizard = accountWizard; this.wizard = accountWizard;
JLabel protocolLabel = new JLabel();
JPanel inputRegisterPanel = new JPanel(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.setPreferredSize(new Dimension(230, 150)); this.setPreferredSize(new Dimension(230, 150));
@ -238,71 +229,54 @@ public AccountRegistrationPanel(
this.labelsPanel.setOpaque(false); this.labelsPanel.setOpaque(false);
this.fieldsPanel.setOpaque(false); this.fieldsPanel.setOpaque(false);
this.emptyPanel.setOpaque(false); this.emptyPanel.setOpaque(false);
this.inputRegisterPanel.setOpaque(false); inputRegisterPanel.setOpaque(false);
this.iconDescriptionPanel.setOpaque(false); this.iconDescriptionPanel.setOpaque(false);
this.add(inputRegisterPanel, BorderLayout.CENTER); this.add(inputRegisterPanel, BorderLayout.CENTER);
this.inputRegisterPanel.add(inputPanel, BorderLayout.NORTH); inputRegisterPanel.add(inputPanel, BorderLayout.NORTH);
if (wizard.isWebSignupSupported()) if (wizard.isWebSignupSupported())
{ {
if (isPreferredWizard) String textKey =
isPreferredWizard ? "plugin.simpleaccregwizz.SPECIAL_SIGNUP"
: "plugin.simpleaccregwizz.SIGNUP";
JLabel signupLabel =
new JLabel("<html><a href=''>"
+ Resources.getString(textKey) + "</a></html>",
JLabel.RIGHT);
signupLabel.setFont(signupLabel.getFont().deriveFont(10f));
signupLabel.addMouseListener(new MouseAdapter()
{ {
this.inputRegisterPanel.add( public void mousePressed(MouseEvent e)
specialSignupLabel, BorderLayout.SOUTH);
}
else
{
this.inputRegisterPanel.add(
signupLabel, BorderLayout.SOUTH);
}
}
this.inputPanel.add(labelsPanel, BorderLayout.WEST);
this.inputPanel.add(fieldsPanel, BorderLayout.CENTER);
this.iconDescriptionPanel.add(
protocolLabel, BorderLayout.NORTH);
this.signupLabel.setFont(signupLabel.getFont().deriveFont(10f));
this.signupLabel.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent arg0)
{ {
try try
{ {
wizard.webSignup(); wizard.webSignup();
} }
catch (UnsupportedOperationException e) catch (UnsupportedOperationException ex)
{ {
// This should not happen, because we check if the // This should not happen, because we check if the
// operation is supported, before adding the sign up. // operation is supported, before adding the sign
logger.error("The web sign up is not supported.", e); // up.
logger.error("The web sign up is not supported.",
ex);
} }
} }
}); });
this.specialSignupLabel.setFont(signupLabel.getFont().deriveFont(10f)); inputRegisterPanel.add(signupLabel, BorderLayout.SOUTH);
this.specialSignupLabel.addMouseListener(new MouseAdapter() }
{
public void mousePressed(MouseEvent arg0) this.inputPanel.add(labelsPanel, BorderLayout.WEST);
{
try this.inputPanel.add(fieldsPanel, BorderLayout.CENTER);
{
wizard.webSignup(); this.iconDescriptionPanel.add(
} protocolLabel, BorderLayout.NORTH);
catch (UnsupportedOperationException e)
{
// This should not happen, because we check if the
// operation is supported, before adding the sign up.
logger.error("The web sign up is not supported.", e);
}
}
});
this.protocolLabel.setFont( protocolLabel.setFont(
protocolLabel.getFont().deriveFont(Font.BOLD, 14f)); protocolLabel.getFont().deriveFont(Font.BOLD, 14f));
this.usernameExampleLabel.setForeground(Color.DARK_GRAY); this.usernameExampleLabel.setForeground(Color.DARK_GRAY);
this.usernameExampleLabel.setFont( this.usernameExampleLabel.setFont(
@ -319,7 +293,7 @@ public void mousePressed(MouseEvent arg0)
this.usernameExampleLabel.setText(wizard.getUserNameExample()); this.usernameExampleLabel.setText(wizard.getUserNameExample());
this.protocolLabel.setText(wizard.getProtocolName()); protocolLabel.setText(wizard.getProtocolName());
Image image = null; Image image = null;
try try
@ -418,7 +392,7 @@ public void serviceChanged(ServiceEvent event)
if (event.getType() == ServiceEvent.REGISTERED) if (event.getType() == ServiceEvent.REGISTERED)
{ {
this.addAccountRegistrationForm(wizard); this.addAccountRegistrationForm(wizard);
} }
} }

@ -1,45 +0,0 @@
/*
* 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.service.gui;
import java.lang.reflect.*;
/**
* @author Lubomir Marinov
*/
public abstract class AbstractConfigurationForm
implements ConfigurationForm
{
public Object getForm()
{
Exception exception;
try
{
return Class.forName(getFormClassName(), true,
getClass().getClassLoader()).newInstance();
}
catch (ClassNotFoundException ex)
{
exception = ex;
}
catch (IllegalAccessException ex)
{
exception = ex;
}
catch (InstantiationException ex)
{
exception = ex;
}
throw new UndeclaredThrowableException(exception);
}
protected abstract String getFormClassName();
public int getIndex()
{
return -1;
}
}

@ -27,9 +27,6 @@ public interface ExportedWindow
public static final WindowID CHAT_WINDOW public static final WindowID CHAT_WINDOW
= new WindowID("ChatWindow"); = new WindowID("ChatWindow");
public static final WindowID CONFIGURATION_WINDOW
= new WindowID("ConfigurationWindow");
public static final WindowID AUTHENTICATION_WINDOW public static final WindowID AUTHENTICATION_WINDOW
= new WindowID("AuthenticationWindow"); = new WindowID("AuthenticationWindow");

@ -0,0 +1,114 @@
/*
* 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.service.gui;
import java.lang.reflect.*;
import net.java.sip.communicator.service.gui.internal.*;
import net.java.sip.communicator.service.resources.*;
/**
* @author Lubomir Marinov
*/
public class LazyConfigurationForm
implements ConfigurationForm
{
private static ResourceManagementService resources;
private static ResourceManagementService getResources()
{
if (resources == null)
resources =
ResourceManagementServiceUtils.getService(GuiServiceActivator
.getBundleContext());
return resources;
}
private final ClassLoader formClassLoader;
private final String formClassName;
private final String iconID;
private final int index;
private final String titleID;
public LazyConfigurationForm(String formClassName,
ClassLoader formClassLoader, String iconID, String titleID)
{
this(formClassName, formClassLoader, iconID, titleID, -1);
}
public LazyConfigurationForm(String formClassName,
ClassLoader formClassLoader, String iconID, String titleID, int index)
{
this.formClassName = formClassName;
this.formClassLoader = formClassLoader;
this.iconID = iconID;
this.titleID = titleID;
this.index = index;
}
public Object getForm()
{
Exception exception;
try
{
return Class
.forName(getFormClassName(), true, getFormClassLoader())
.newInstance();
}
catch (ClassNotFoundException ex)
{
exception = ex;
}
catch (IllegalAccessException ex)
{
exception = ex;
}
catch (InstantiationException ex)
{
exception = ex;
}
throw new UndeclaredThrowableException(exception);
}
protected ClassLoader getFormClassLoader()
{
return formClassLoader;
}
protected String getFormClassName()
{
return formClassName;
}
public byte[] getIcon()
{
return getResources().getImageInBytes(getIconID());
}
protected String getIconID()
{
return iconID;
}
public int getIndex()
{
return index;
}
public String getTitle()
{
return getResources().getI18NString(getTitleID());
}
protected String getTitleID()
{
return titleID;
}
}

@ -333,4 +333,6 @@ public SecurityAuthority getDefaultSecurityAuthority(
public boolean useMacOSXScreenMenuBar(); public boolean useMacOSXScreenMenuBar();
public void beginShutdown(); public void beginShutdown();
public void setConfigurationWindowVisible(boolean visible);
} }

@ -1,7 +1,10 @@
Bundle-Activator: net.java.sip.communicator.service.gui.internal.GuiServiceActivator
Bundle-Name: UI Service Bundle-Name: UI Service
Bundle-Description: The User Interface Service. Bundle-Description: The User Interface Service.
Bundle-Vendor: sip-communicator.org Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1 Bundle-Version: 0.0.1
System-Bundle: yes System-Bundle: yes
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.resources
Export-Package: net.java.sip.communicator.service.gui, Export-Package: net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.event net.java.sip.communicator.service.gui.event

@ -0,0 +1,33 @@
/*
* 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.service.gui.internal;
import org.osgi.framework.*;
/**
* @author Lubomir Marinov
*/
public class GuiServiceActivator
implements BundleActivator
{
private static BundleContext bundleContext;
public static BundleContext getBundleContext()
{
return bundleContext;
}
public void start(BundleContext bundleContext)
{
GuiServiceActivator.bundleContext = bundleContext;
}
public void stop(BundleContext bundleContext)
{
if (GuiServiceActivator.bundleContext == bundleContext)
GuiServiceActivator.bundleContext = null;
}
}

@ -20,22 +20,23 @@
* *
* @author Sebastien Mazy * @author Sebastien Mazy
* @author Yana Stamcheva * @author Yana Stamcheva
* @author Lubomir Marinov
*/ */
public class ImageUtils public class ImageUtils
{ {
private static final Logger logger = Logger.getLogger(ImageUtils.class); private static final Logger logger = Logger.getLogger(ImageUtils.class);
/** /**
* Returns a scaled image fitting within the given bounds * Returns a scaled image fitting within the given bounds while keeping the
* while keeping the aspect ratio. * aspect ratio.
* *
* @param image the image to scale * @param image the image to scale
* @param width maximum width of the scaled image * @param width maximum width of the scaled image
* @param height maximum height of the scaled image * @param height maximum height of the scaled image
* @return the scaled image * @return the scaled image
*/ */
public static ImageIcon public static Image scaleImageWithinBounds(Image image, int width,
scaleIconWithinBounds(Image image, int width, int height) int height)
{ {
Image scaledImage; Image scaledImage;
int scaleHint = Image.SCALE_SMOOTH; int scaleHint = Image.SCALE_SMOOTH;
@ -51,8 +52,13 @@ public class ImageUtils
{ {
scaledImage = image.getScaledInstance(-1, height, scaleHint); scaledImage = image.getScaledInstance(-1, height, scaleHint);
} }
return scaledImage;
}
return new ImageIcon(scaledImage); public static ImageIcon scaleIconWithinBounds(Image image, int width,
int height)
{
return new ImageIcon(scaleImageWithinBounds(image, width, height));
} }
/** /**
@ -62,20 +68,16 @@ public class ImageUtils
* *
* @return The rounded corner image. * @return The rounded corner image.
*/ */
public static ImageIcon getScaledRoundedImage( Image image, public static Image getScaledRoundedImage(Image image, int width, int height)
int width,
int height)
{ {
BufferedImage destImage = null; ImageIcon scaledImage =
ImageUtils.scaleIconWithinBounds(image, width, height);
ImageIcon scaledImage = ImageUtils.scaleIconWithinBounds( image, int scaledImageWidth = scaledImage.getIconWidth();
width, int scaledImageHeight = scaledImage.getIconHeight();
height);
destImage BufferedImage destImage =
= new BufferedImage(scaledImage.getImage().getWidth(null), new BufferedImage(scaledImageWidth, scaledImageHeight,
scaledImage.getImage().getHeight(null), BufferedImage.TYPE_INT_ARGB);
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = destImage.createGraphics(); Graphics2D g = destImage.createGraphics();
@ -84,8 +86,7 @@ public static ImageIcon getScaledRoundedImage( Image image,
AntialiasingManager.activateAntialiasing(g); AntialiasingManager.activateAntialiasing(g);
g.setColor(Color.WHITE); g.setColor(Color.WHITE);
g.fillRoundRect(0, 0, scaledImage.getIconWidth(), scaledImage g.fillRoundRect(0, 0, scaledImageWidth, scaledImageHeight, 10, 10);
.getIconHeight(), 10, 10);
g.setComposite(AlphaComposite.SrcIn); g.setComposite(AlphaComposite.SrcIn);
g.drawImage(scaledImage.getImage(), 0, 0, null); g.drawImage(scaledImage.getImage(), 0, 0, null);
@ -94,8 +95,13 @@ public static ImageIcon getScaledRoundedImage( Image image,
{ {
g.dispose(); g.dispose();
} }
return destImage;
}
return new ImageIcon(destImage); public static ImageIcon getScaledRoundedIcon(Image image, int width,
int height)
{
return new ImageIcon(getScaledRoundedImage(image, width, height));
} }
/** /**
@ -121,7 +127,7 @@ public static ImageIcon getScaledRoundedImage( byte[] imageBytes,
InputStream in = new ByteArrayInputStream(imageBytes); InputStream in = new ByteArrayInputStream(imageBytes);
BufferedImage image = ImageIO.read(in); BufferedImage image = ImageIO.read(in);
imageIcon = getScaledRoundedImage(image, width, height); imageIcon = getScaledRoundedIcon(image, width, height);
} }
catch (Exception e) catch (Exception e)
{ {

Loading…
Cancel
Save