Fixes warnings, removes unnecessary fields.

cusax-fix
Lyubomir Marinov 17 years ago
parent f77489e9c3
commit 70ade3308f

@ -30,12 +30,13 @@ public class IrcStack
/**
* Timeout for server response.
*/
private int timeout = 10000;
private static final int TIMEOUT = 10000;
/**
* A list of timers indicating when a chat room join fails.
*/
private Hashtable joinTimeoutTimers = new Hashtable();
private final Map<ChatRoom, Timer> joinTimeoutTimers
= new Hashtable<ChatRoom, Timer>();
/**
* A list of the channels on this server
@ -46,20 +47,21 @@ public class IrcStack
* A list of users that we have info about, it is used to stock "whois"
* responses
*/
private Hashtable userInfoTable = new Hashtable();
private final Map<String, UserInfo> userInfoTable
= new Hashtable<String, UserInfo>();
/**
* The IRC multi-user chat operation set.
*/
private OperationSetMultiUserChatIrcImpl ircMUCOpSet;
private final OperationSetMultiUserChatIrcImpl ircMUCOpSet;
/**
* The IRC protocol provider service.
*/
private ProtocolProviderServiceIrcImpl parentProvider;
private final ProtocolProviderServiceIrcImpl parentProvider;
private Object operationLock = new Object();
private final Object operationLock = new Object();
/**
* The operation response code indicates
@ -74,7 +76,7 @@ public class IrcStack
/**
* Keeps all join requests received before the server is initialized.
*/
private ArrayList joinCache = new ArrayList();
private final List<ChatRoom> joinCache = new ArrayList<ChatRoom>();
/**
* The indicator which determines whether #onConnect() has been invoked and
@ -469,7 +471,7 @@ protected void onJoin( String channel,
if(joinTimeoutTimers.containsKey(chatRoom))
{
Timer timer = (Timer) joinTimeoutTimers.get(chatRoom);
Timer timer = joinTimeoutTimers.get(chatRoom);
timer.cancel();
joinTimeoutTimers.remove(chatRoom);
@ -1144,8 +1146,7 @@ else if (code == RPL_WHOISSERVER)
if (userInfoTable.containsKey(userNickName))
{
((UserInfo) userInfoTable.get(userNickName))
.setServerInfo(serverInfo);
userInfoTable.get(userNickName).setServerInfo(serverInfo);
}
}
else if (code == RPL_WHOISOPERATOR)
@ -1156,7 +1157,7 @@ else if (code == RPL_WHOISOPERATOR)
if (userInfoTable.containsKey(userNickName))
{
((UserInfo) userInfoTable.get(userNickName)).setIrcOp(true);
userInfoTable.get(userNickName).setIrcOp(true);
}
}
else if (code == RPL_WHOISIDLE)
@ -1168,7 +1169,7 @@ else if (code == RPL_WHOISIDLE)
if (userInfoTable.containsKey(userNickName))
{
((UserInfo) userInfoTable.get(userNickName)).setIdle(idle);
userInfoTable.get(userNickName).setIdle(idle);
}
}
else if (code == RPL_WHOISCHANNELS)
@ -1179,8 +1180,7 @@ else if (code == RPL_WHOISCHANNELS)
if (userInfoTable.containsKey(userNickName))
{
((UserInfo) userInfoTable.get(userNickName))
.clearJoinedChatRoom();
userInfoTable.get(userNickName).clearJoinedChatRoom();
while(tokenizer.hasMoreTokens())
{
@ -1189,8 +1189,7 @@ else if (code == RPL_WHOISCHANNELS)
if(channel.startsWith(":"))
channel = channel.substring(1);
((UserInfo) userInfoTable.get(userNickName))
.addJoinedChatRoom(channel);
userInfoTable.get(userNickName).addJoinedChatRoom(channel);
}
}
}
@ -1202,8 +1201,7 @@ else if (code == RPL_ENDOFWHOIS)
if (userInfoTable.containsKey(userNickName))
{
UserInfo userInfo
= (UserInfo) userInfoTable.get(userNickName);
UserInfo userInfo = userInfoTable.get(userNickName);
this.onWhoIs(userInfo);
}
@ -1212,13 +1210,14 @@ else if (code == RPL_ENDOFMOTD)
{
this.isInitialized = true;
ArrayList joinCacheCopy = new ArrayList(joinCache);
ChatRoom[] joinCacheCopy
= joinCache.toArray(new ChatRoom[joinCache.size()]);
joinCache.clear();
for (int i = 0; i < joinCacheCopy.size(); i ++)
for (ChatRoom joinCacheElement : joinCacheCopy)
{
this.join((ChatRoom) joinCacheCopy.get(i));
this.join(joinCacheElement);
}
}
else if (code != RPL_LISTSTART
@ -1666,7 +1665,7 @@ public void join(ChatRoom chatRoom)
joinTimeoutTimers.put(chatRoom, joinTimeoutTimer);
joinTimeoutTimer.schedule(new JoinTimeoutTask(chatRoom), timeout);
joinTimeoutTimer.schedule(new JoinTimeoutTask(chatRoom), TIMEOUT);
}
/**
@ -1683,7 +1682,7 @@ public void join(ChatRoom chatRoom, byte[] password)
joinTimeoutTimers.put(chatRoom, joinTimeoutTimer);
joinTimeoutTimer.schedule(new JoinTimeoutTask(chatRoom), timeout);
joinTimeoutTimer.schedule(new JoinTimeoutTask(chatRoom), TIMEOUT);
}
/**
@ -2094,4 +2093,4 @@ protected void createPrivateChatRoom(String target)
System.currentTimeMillis(),
ChatRoomMessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
}
}
}

@ -26,10 +26,10 @@
*/
public class FirstWizardPage
extends TransparentPanel
implements WizardPage
implements WizardPage
{
private static final Logger logger = Logger
.getLogger(FirstWizardPage.class);
private static final Logger logger
= Logger.getLogger(FirstWizardPage.class);
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
@ -38,18 +38,12 @@ public class FirstWizardPage
private JPanel userIDPassPanel
= new TransparentPanel(new BorderLayout(10, 10));
private JPanel labelsPanel = new TransparentPanel();
private JPanel valuesPanel = new TransparentPanel();
private JLabel userIDLabel = new JLabel(
Resources.getString("plugin.googletalkaccregwizz.USERNAME"));
private JLabel passLabel
= new JLabel(Resources.getString("service.gui.PASSWORD"));
private JPanel emptyPanel = new TransparentPanel();
private JLabel userIDExampleLabel = new JLabel(USER_NAME_EXAMPLE);
private JTextField userIDField = new JTextField();
@ -108,9 +102,7 @@ public class FirstWizardPage
private JPanel mainPanel = new TransparentPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private GoogleTalkAccountRegistrationWizard wizard;
private final GoogleTalkAccountRegistrationWizard wizard;
private boolean isCommitted = false;
@ -123,34 +115,14 @@ public class FirstWizardPage
*/
public FirstWizardPage(GoogleTalkAccountRegistrationWizard wizard)
{
super(new BorderLayout());
this.wizard = wizard;
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
this.init();
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.labelsPanel
.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
this.valuesPanel
.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
}
/**
* Initializes all panels, buttons, etc.
*/
private void init()
{
this.mainPanel.setOpaque(false);
this.labelsPanel.setOpaque(false);
this.valuesPanel.setOpaque(false);
this.userIDPassPanel.setOpaque(false);
this.emptyPanel.setOpaque(false);
this.userIDField.getDocument().addDocumentListener(new DocumentListener()
{
@ -176,14 +148,20 @@ public void changedUpdate(DocumentEvent evt) {}
this.userIDExampleLabel.setForeground(Color.GRAY);
this.userIDExampleLabel.setFont(userIDExampleLabel.getFont()
.deriveFont(8));
this.emptyPanel.setMaximumSize(new Dimension(40, 35));
this.userIDExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0,
8, 0));
JPanel emptyPanel = new TransparentPanel();
emptyPanel.setMaximumSize(new Dimension(40, 35));
JPanel labelsPanel = new TransparentPanel();
labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
labelsPanel.add(userIDLabel);
labelsPanel.add(emptyPanel);
labelsPanel.add(passLabel);
JPanel valuesPanel = new TransparentPanel();
valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
valuesPanel.add(userIDField);
valuesPanel.add(userIDExampleLabel);
valuesPanel.add(passField);
@ -264,7 +242,7 @@ public void actionPerformed(ActionEvent evt)
* We don't have our own implementation of registering/signing
* up with Google Talk so we'll just use webSignup.
*/
wizard.webSignup();
FirstWizardPage.this.wizard.webSignup();
logger.debug("Reg End");
}
@ -286,6 +264,8 @@ public void actionPerformed(ActionEvent evt)
mainPanel.add(registerPanel);
this.add(mainPanel, BorderLayout.NORTH);
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
/**
@ -307,7 +287,7 @@ public Object getIdentifier()
*/
public Object getNextPageIdentifier()
{
return nextPageIdentifier;
return SUMMARY_PAGE_IDENTIFIER;
}
/**
@ -369,8 +349,6 @@ public void commitPage()
registration.setPriority(
Integer.parseInt(priorityField.getText()));
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
isCommitted = true;
}
@ -380,17 +358,18 @@ public void commitPage()
*/
private void setNextButtonAccordingToUserIDAndResource()
{
if (userIDField.getText() == null
|| userIDField.getText().equals("")
|| resourceField.getText() == null
|| resourceField.getText().equals(""))
{
wizard.getWizardContainer().setNextFinishButtonEnabled(false);
}
String userID = userIDField.getText();
boolean enabled;
if ((userID == null) || userID.equals(""))
enabled = false;
else
{
wizard.getWizardContainer().setNextFinishButtonEnabled(true);
String resource = resourceField.getText();
enabled = ((resource != null) && !resource.equals(""));
}
wizard.getWizardContainer().setNextFinishButtonEnabled(enabled);
}
public void pageHiding()
@ -440,8 +419,9 @@ public void loadAccount(ProtocolProviderService protocolProvider)
portField.setText(serverPort);
boolean keepAlive = new Boolean((String)accountProperties
.get("SEND_KEEP_ALIVE")).booleanValue();
boolean keepAlive
= Boolean.parseBoolean(
(String) accountProperties.get("SEND_KEEP_ALIVE"));
sendKeepAliveBox.setSelected(keepAlive);
@ -457,12 +437,11 @@ public void loadAccount(ProtocolProviderService protocolProvider)
this.isServerOverridden = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.IS_SERVER_OVERRIDDEN, false);
}
/**
* Parse the server part from the Google Talk id and set it to server as
* default value. If Advanced option is enabled Do nothing.
* default value. If Advanced option is enabled, do nothing.
*/
private void setServerFieldAccordingToUserID()
{
@ -479,16 +458,19 @@ private void setServerFieldAccordingToUserID()
*/
private void setNextButtonAccordingToPortAndPriority()
{
boolean enabled;
try
{
new Integer(portField.getText());
new Integer(priorityField.getText());
wizard.getWizardContainer().setNextFinishButtonEnabled(true);
Integer.parseInt(portField.getText());
Integer.parseInt(priorityField.getText());
enabled = true;
}
catch (NumberFormatException ex)
{
wizard.getWizardContainer().setNextFinishButtonEnabled(false);
enabled = false;
}
wizard.getWizardContainer().setNextFinishButtonEnabled(enabled);
}
public Object getSimpleForm()

Loading…
Cancel
Save