Removes unnecessary repetitions of method calls in ConfigurationForm-related code.

cusax-fix
Lyubomir Marinov 17 years ago
parent 6a10002015
commit aee0c5142b

@ -24,9 +24,9 @@
*/
public class ConfigFormDescriptor
{
private Logger logger = Logger.getLogger(ConfigFormDescriptor.class);
private final Logger logger = Logger.getLogger(ConfigFormDescriptor.class);
private ConfigurationForm configForm;
private final ConfigurationForm configForm;
private ImageIcon configFormIcon;

@ -4,7 +4,6 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.configforms;
import java.awt.*;
@ -12,7 +11,6 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.*;
/**
* The <tt>ContactListCellRenderer</tt> is the custom cell renderer used in the
@ -26,7 +24,6 @@ public class ConfigFormListCellRenderer
extends JPanel
implements ListCellRenderer
{
private Logger logger = Logger.getLogger(ConfigFormListCellRenderer.class);
/**
* The size of the gradient used for painting the selected background of
@ -88,13 +85,15 @@ public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
ConfigFormDescriptor cfDescriptor = (ConfigFormDescriptor) value;
if(cfDescriptor.getConfigFormIcon() != null)
iconLabel.setIcon(cfDescriptor.getConfigFormIcon());
if(cfDescriptor.getConfigFormTitle() != null)
textLabel.setText(cfDescriptor.getConfigFormTitle());
ImageIcon icon = cfDescriptor.getConfigFormIcon();
if(icon != null)
iconLabel.setIcon(icon);
String title = cfDescriptor.getConfigFormTitle();
if (title != null)
textLabel.setText(title);
this.isSelected = isSelected;
return this;
@ -115,45 +114,37 @@ public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
int width = getWidth();
int height = getHeight();
if (isSelected)
{
GradientPaint p = new GradientPaint(this.getWidth() / 2, 0,
SELECTED_START_COLOR, this
.getWidth() / 2,
SELECTED_GRADIENT_SIZE,
SELECTED_END_COLOR);
GradientPaint p1 = new GradientPaint(this.getWidth() / 2, this
.getHeight()
- SELECTED_GRADIENT_SIZE,
SELECTED_END_COLOR,
this.getWidth() / 2, this.getHeight() - 1,
GradientPaint p =
new GradientPaint(width / 2, 0, SELECTED_START_COLOR,
width / 2, SELECTED_GRADIENT_SIZE, SELECTED_END_COLOR);
GradientPaint p1 =
new GradientPaint(width / 2, height - SELECTED_GRADIENT_SIZE,
SELECTED_END_COLOR, width / 2, height - 1,
SELECTED_START_COLOR);
g2.setPaint(p);
g2.fillRect(0, 0, this.getWidth(),
SELECTED_GRADIENT_SIZE);
g2.fillRect(0, 0, width, SELECTED_GRADIENT_SIZE);
g2.setColor(SELECTED_END_COLOR);
g2.fillRect(0, SELECTED_GRADIENT_SIZE, this
.getWidth(), this.getHeight()
- SELECTED_GRADIENT_SIZE);
g2.fillRect(0, SELECTED_GRADIENT_SIZE, width, height
- SELECTED_GRADIENT_SIZE);
g2.setPaint(p1);
g2.fillRect(0, this.getHeight()
- SELECTED_GRADIENT_SIZE, this
.getWidth(), this.getHeight() - 1);
g2.fillRect(0, height - SELECTED_GRADIENT_SIZE, width, height - 1);
g2.setColor(Constants.LIST_SELECTION_BORDER_COLOR);
g2.drawRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1,
5, 5);
g2.drawRoundRect(0, 0, width - 1, height - 1, 5, 5);
}
else
{
g2.setColor(SELECTED_START_COLOR);
g2.drawLine(0, this.getHeight() - 1,
this.getWidth(), this.getHeight() - 1);
g2.drawLine(0, height - 1, width, height - 1);
}
}
}

@ -3,7 +3,6 @@
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.configforms;
import java.awt.*;
@ -47,8 +46,6 @@ public class ConfigurationFrame
private TransparentPanel buttonsPanel
= new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
private MainFrame mainFrame;
/**
* Creates an instance of <tt>ConfigurationManagerImpl</tt>.
*
@ -58,8 +55,6 @@ public ConfigurationFrame(MainFrame mainFrame)
{
super(mainFrame);
this.mainFrame = mainFrame;
this.configList = new ConfigFormList(this);
this.configScrollList = new SCScrollPane();
@ -161,11 +156,8 @@ public void setVisible(boolean isVisible)
if (isVisible)
{
this.configList.setSelectedIndex(0);
super.setVisible(true);
}
else
super.setVisible(false);
super.setVisible(isVisible);
}
/**
@ -245,15 +237,17 @@ public void serviceChanged(ServiceEvent event)
ConfigurationForm configForm = (ConfigurationForm) sService;
if (event.getType() == ServiceEvent.REGISTERED)
switch (event.getType())
{
case ServiceEvent.REGISTERED:
logger.info("Handling registration of a new Configuration Form.");
this.addConfigurationForm(configForm);
}
else if (event.getType() == ServiceEvent.UNREGISTERING)
{
break;
case ServiceEvent.UNREGISTERING:
this.removeConfigurationForm(configForm);
break;
}
}
@ -273,8 +267,10 @@ private void addConfigurationForm(ConfigurationForm configForm)
if (descriptor != null)
{
if (configForm.getIndex() > -1)
configList.addConfigForm(descriptor, configForm.getIndex());
int index = configForm.getIndex();
if (index > -1)
configList.addConfigForm(descriptor, index);
else
configList.addConfigForm(descriptor);
}

Loading…
Cancel
Save