Fixes issue #461 : No call history in dial box

cusax-fix
Emil Ivov 18 years ago
parent c2e5c3b8a7
commit 1c09347eb8

@ -173,8 +173,8 @@ public boolean accept(Object o)
}
public class CallComboEditor
implements ComboBoxEditor,
DocumentListener
implements ComboBoxEditor,
DocumentListener
{
private JTextField text;
private volatile boolean filtering = false;

@ -1,25 +1,28 @@
/*
* 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.call;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
import net.java.sip.communicator.service.callhistory.*;
import net.java.sip.communicator.service.contactlist.*;
/**
* The <tt>CallComboBox</tt> is a history editable combo box that is
* positioned above call and hangup buttons and is used when writing a number or
* a contact name in order to be called.
*
*
* @author Yana Stamcheva
*/
public class CallComboBox
@ -28,14 +31,16 @@ public class CallComboBox
DocumentListener,
FocusListener
{
public final static int MAX_COMBO_SIZE = 10;
public final static int MAX_HISTORY_SIZE = 30;
private final MainCallPanel parentCallPanel;
private LoadLastCallsFromHistory callHistoryLoadThread = null;
/**
* Creates a <tt>CallComboBox</tt> by specifying the parent panel, where
* this combo box will be placed.
*
*
* @param parentCallPanel The parent panel.
*/
public CallComboBox(MainCallPanel parentCallPanel)
@ -55,13 +60,16 @@ public CallComboBox(MainCallPanel parentCallPanel)
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "createCall");
textField.addFocusListener(this);
callHistoryLoadThread = new LoadLastCallsFromHistory();
SwingUtilities.invokeLater(callHistoryLoadThread);
}
/**
* Checks if this combobox editor field is empty. This will be the case if
* the user hasn't selected an item from the combobox and hasn't written
* anything the field.
*
*
* @return TRUE if the combobox editor field is empty, otherwise FALSE
*/
public boolean isComboFieldEmpty()
@ -96,7 +104,7 @@ public void changedUpdate(DocumentEvent e)
}
/**
* Enables or disabled the call button according to the content in the combo
* Enables or disables the call button according to the content in the combo
* box editor field.
*/
protected void handleChange()
@ -132,6 +140,7 @@ protected void handleChange()
public void focusGained(FocusEvent e)
{
SwingUtilities.invokeLater(callHistoryLoadThread);
this.handleChange();
}
@ -159,4 +168,51 @@ public void actionPerformed(ActionEvent e)
}
}
}
/**
* We use this thread to load the last MAX_HISTORY_SIZE calls from the
* call history and insert all unique entries in our data model. The point
* is to propose auto completion when users start dialing numbers.
*/
private class LoadLastCallsFromHistory extends Thread
{
/**
* Executes a query for the last MAX_HISTORY_SIZE calls against the
* call history service and then adds all unique entries to our data
* model.
*/
public void run()
{
CallHistoryService callHistory
= GuiActivator.getCallHistoryService();
if (callHistory == null)
return;
Collection<CallRecord> historyCalls
= callHistory.findLast(MAX_HISTORY_SIZE);
FilterableComboBoxModel callComboModel
= (FilterableComboBoxModel)getModel();
for (CallRecord call : historyCalls)
{
List<CallParticipantRecord> callParticipantRecords
= call.getParticipantRecords();
//extract all call participants for that call.
for (CallParticipantRecord cpRecord
: callParticipantRecords)
{
String participant = cpRecord.getParticipantAddress();
if(!callComboModel.contains(participant))
{
callComboModel
.addElement(participant);
}
}
}
}
}
}

@ -30,7 +30,7 @@
/**
* The panel containing the call field and button, serving to make calls.
*
*
* @author Yana Stamcheva
*/
public class MainCallPanel
@ -188,8 +188,7 @@ public void actionPerformed(ActionEvent evt)
else if (!phoneNumberCombo.isComboFieldEmpty())
{
// if no contact is selected checks if the user has chosen
// or has
// writen something in the phone combo box
// or has writen something in the phone combo box
String stringContact = phoneNumberCombo.getEditor()
.getItem().toString();
@ -221,7 +220,7 @@ else if (buttonName.equals(DIAL_BUTTON))
/**
* Returns the main application window, which is the parent of this panel.
*
*
* @return the main application window, which is the parent of this panel.
*/
public MainFrame getMainFrame()
@ -231,7 +230,7 @@ public MainFrame getMainFrame()
/**
* Sets the protocol provider to be used for making calls.
*
*
* @param protocolProvider the protocol provider to be used for making calls.
*/
public ProtocolProviderService getCallProvider()
@ -241,7 +240,7 @@ public ProtocolProviderService getCallProvider()
/**
* Sets the protocol provider to be used for making calls.
*
*
* @param protocolProvider the protocol provider to be used for making calls.
*/
public void setCallProvider(ProtocolProviderService protocolProvider)
@ -253,7 +252,7 @@ public void setCallProvider(ProtocolProviderService protocolProvider)
* Sets the isCallMetaContact variable to TRUE or FALSE. This defines if
* this call is a call to a given meta contact selected from the contact
* list or a call to an external contact or phone number.
*
*
* @param isCallMetaContact TRUE to define this call as a call to an
* internal meta contact and FALSE to define it as a call to an
* external contact or phone number.
@ -265,7 +264,7 @@ public void setCallMetaContact(boolean isCallMetaContact)
/**
* Enables or disabled the call button.
*
*
* @param isEnabled <code>true</code> to enable the call button and
* <tt>false</tt> otherwise.
*/
@ -276,7 +275,7 @@ public void setCallButtonEnabled(boolean isEnabled)
/**
* Sets the given <tt>phoneNumber</tt> to the phone number combo box.
*
*
* @param phoneNumber the phone number to set.
*/
public void setPhoneNumberComboText(String phoneNumber)
@ -286,14 +285,14 @@ public void setPhoneNumberComboText(String phoneNumber)
/**
* Returns the content of the phone number combo box.
*
*
* @return the content of the phone number combo box.
*/
public String getPhoneNumberComboText()
{
return (String) this.phoneNumberCombo.getEditor().getItem();
}
/**
* Requests the focus in the phone number combo box.
*/
@ -304,7 +303,7 @@ public void requestFocusInPhoneCombo()
/**
* Adds the given call account to the list of call via accounts.
*
*
* @param pps the protocol provider service corresponding to the account
*/
public void addCallAccount(ProtocolProviderService pps)
@ -322,7 +321,7 @@ public void addCallAccount(ProtocolProviderService pps)
/**
* Removes the account corresponding to the given protocol provider from the
* call via selector box.
*
*
* @param pps the protocol provider service to remove
*/
public void removeCallAccount(ProtocolProviderService pps)
@ -341,7 +340,7 @@ public void removeCallAccount(ProtocolProviderService pps)
* Returns TRUE if the account corresponding to the given protocol provider
* is already contained in the call via selector box, otherwise returns
* FALSE.
*
*
* @param pps the protocol provider service for the account
* @return TRUE if the account corresponding to the given protocol provider
* is already contained in the call via selector box, otherwise
@ -354,7 +353,7 @@ public boolean containsCallAccount(ProtocolProviderService pps)
/**
* Updates the call via account status.
*
*
* @param pps the protocol provider service for the account
*/
public void updateCallAccountStatus(ProtocolProviderService pps)
@ -364,7 +363,7 @@ public void updateCallAccountStatus(ProtocolProviderService pps)
/**
* Returns the account selector box.
*
*
* @return the account selector box.
*/
public AccountSelectorBox getAccountSelectorBox()

Loading…
Cancel
Save