Removes some UI repetition from the chat history window, uses one and the same spacing between the components for consistency and so that they become properly aligned.

cusax-fix
Lyubomir Marinov 17 years ago
parent 29c6aa082b
commit 3c53069887

@ -49,9 +49,7 @@ public DatesPanel(HistoryWindow historyWindow)
this.historyWindow = historyWindow;
this.setPreferredSize(new Dimension(100, 100));
this.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3, 3, 3, 0),
SIPCommBorders.getBoldRoundBorder()));
this.setBorder(SIPCommBorders.getBoldRoundBorder());
this.setOpaque(false);
this.datesList.setModel(listModel);
@ -65,7 +63,6 @@ public DatesPanel(HistoryWindow historyWindow)
this.setViewportView(listPanel);
this.getVerticalScrollBar().setUnitIncrement(30);
}
/**

@ -48,20 +48,30 @@ public class HistoryWindow
{
private static final Logger logger = Logger.getLogger(HistoryWindow.class);
private static final String[] HISTORY_FILTER
= new String[]
{
MessageHistoryService.class.getName(),
FileHistoryService.class.getName()
};
/**
* The horizontal and vertical spacing between the UI components of this
* instance defined in one place for the purposes of consistency. Hopefully,
* one day it should be defined at a global application level to achieve
* consistency with the UI elsewhere.
*/
private static final int SPACING = 5;
private ChatConversationPanel chatConvPanel;
private TransparentPanel mainPanel
= new TransparentPanel(new BorderLayout(10, 10));
private final JPanel mainPanel
= new TransparentPanel(new BorderLayout(SPACING, SPACING));
private JProgressBar progressBar;
private SearchPanel searchPanel;
private HistoryMenu historyMenu;
private TransparentPanel northPanel
= new TransparentPanel(new BorderLayout());
private DatesPanel datesPanel;
private Object historyContact;
@ -71,17 +81,14 @@ public class HistoryWindow
private Hashtable<Date, HTMLDocument> dateHistoryTable
= new Hashtable<Date, HTMLDocument>();
private JLabel readyLabel = new JLabel(
GuiActivator.getResources().getI18NString("service.gui.READY"));
private final JLabel readyLabel
= new JLabel(
GuiActivator.getResources().getI18NString("service.gui.READY"));
private String searchKeyword;
private Vector<Date> datesVector = new Vector<Date>();
private static final String[] historyFilter
= new String[]{ MessageHistoryService.class.getName(),
FileHistoryService.class.getName()};
private Date ignoreProgressDate;
private int lastProgress = 0;
@ -124,7 +131,6 @@ public HistoryWindow(Object historyContact)
this.datesPanel = new DatesPanel(this);
this.historyMenu = new HistoryMenu(this);
this.searchPanel = new SearchPanel(this);
this.initPanels();
@ -173,24 +179,22 @@ else if (historyContact instanceof ChatRoomWrapper)
*/
private void initPanels()
{
this.northPanel.add(searchPanel, BorderLayout.CENTER);
this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.mainPanel.add(northPanel, BorderLayout.NORTH);
this.mainPanel
.setBorder(
BorderFactory
.createEmptyBorder(SPACING, SPACING, SPACING, SPACING));
this.mainPanel.setPreferredSize(new Dimension(500, 400));
this.mainPanel.add(new SearchPanel(this), BorderLayout.NORTH);
this.mainPanel.add(chatConvPanel, BorderLayout.CENTER);
this.mainPanel.add(datesPanel, BorderLayout.WEST);
this.mainPanel.setPreferredSize(new Dimension(500, 400));
this.getContentPane().add(mainPanel);
}
/**
* Initializes the history with a list of all dates, for which a history
* with the given contact is availabled.
* with the given contact is available.
*/
private void initDates()
{
@ -433,7 +437,7 @@ public void run()
if (historyContact instanceof MetaContact)
{
msgList = history.findByEndDate(
historyFilter,
HISTORY_FILTER,
(MetaContact) historyContact,
new Date(System.currentTimeMillis()));
}
@ -446,7 +450,7 @@ else if(historyContact instanceof ChatRoomWrapper)
return;
msgList = history.findByEndDate(
historyFilter,
HISTORY_FILTER,
chatRoomWrapper.getChatRoom(),
new Date(System.currentTimeMillis()));
}
@ -551,7 +555,7 @@ public void run()
if(historyContact instanceof MetaContact)
{
msgList = history.findByPeriod(
historyFilter,
HISTORY_FILTER,
(MetaContact) historyContact,
startDate, endDate);
}
@ -564,7 +568,7 @@ else if (historyContact instanceof ChatRoomWrapper)
return;
msgList = history.findByPeriod(
historyFilter,
HISTORY_FILTER,
chatRoomWrapper.getChatRoom(),
startDate, endDate);
}
@ -613,7 +617,7 @@ public void run()
if (historyContact instanceof MetaContact)
{
msgList = history.findByKeyword(
historyFilter,
HISTORY_FILTER,
(MetaContact) historyContact, keyword);
}
else if (historyContact instanceof ChatRoomWrapper)
@ -625,7 +629,7 @@ else if (historyContact instanceof ChatRoomWrapper)
return;
msgList = history.findByKeyword(
historyFilter,
HISTORY_FILTER,
chatRoomWrapper.getChatRoom(), keyword);
}
@ -752,11 +756,14 @@ private void initProgressBar(Date date)
public void messageReceived(MessageReceivedEvent evt)
{
Contact sourceContact = evt.getSourceContact();
this.processMessage(sourceContact, evt.getTimestamp(),
Chat.INCOMING_MESSAGE,
evt.getSourceMessage().getContent(),
evt.getSourceMessage().getContentType());
Message sourceMessage = evt.getSourceMessage();
this.processMessage(
sourceContact,
evt.getTimestamp(),
Chat.INCOMING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType());
}
/**
@ -766,11 +773,14 @@ public void messageReceived(MessageReceivedEvent evt)
public void messageDelivered(MessageDeliveredEvent evt)
{
Contact destContact = evt.getDestinationContact();
Message sourceMessage = evt.getSourceMessage();
this.processMessage(destContact, evt.getTimestamp(),
Chat.OUTGOING_MESSAGE,
evt.getSourceMessage().getContent(),
evt.getSourceMessage().getContentType());
this.processMessage(
destContact,
evt.getTimestamp(),
Chat.OUTGOING_MESSAGE,
sourceMessage.getContent(),
sourceMessage.getContentType());
}
public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)

@ -15,7 +15,8 @@
*/
public class HistoryWindowManager
{
private Hashtable<Object, HistoryWindow> contactHistory = new Hashtable<Object, HistoryWindow>();
private final Map<Object, HistoryWindow> contactHistory
= new Hashtable<Object, HistoryWindow>();
/**
* Checks if there's an open history window for the given history contact.

@ -22,25 +22,14 @@
* or an hour, or searching by a keyword.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class SearchPanel
extends TransparentPanel
implements ActionListener,
DocumentListener
{
private static final String searchString
= GuiActivator.getResources().getI18NString("service.gui.SEARCH");
private JButton searchButton = new JButton(
searchString,
new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));
private JLabel searchLabel = new JLabel(searchString + ": ");
private JTextField searchTextField = new JTextField();
private TransparentPanel textFieldPanel
= new TransparentPanel(new BorderLayout());
/*
private JRadioButton todayMessagesRadio = new JRadioButton(Messages
@ -91,38 +80,40 @@ public class SearchPanel
private JPanel checksPanel = new JPanel(new GridLayout(0, 1));
*/
private HistoryWindow historyWindow;
private final HistoryWindow historyWindow;
// private JPanel extendedSearchPanel = new JPanel(new BorderLayout());
/**
* Creates an instance of the <tt>SearchPanel</tt>.
*/
public SearchPanel(HistoryWindow historyWindow) {
super(new BorderLayout());
public SearchPanel(HistoryWindow historyWindow)
{
super(new BorderLayout(5, 5));
this.historyWindow = historyWindow;
this.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(searchString),
BorderFactory.createEmptyBorder(5, 5, 5, 5)));
this.textFieldPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
this.init();
}
/**
* Constructs the <tt>SearchPanel</tt>.
*/
public void init() {
this.textFieldPanel.add(searchTextField);
private void init()
{
String searchString
= GuiActivator.getResources().getI18NString("service.gui.SEARCH");
JLabel searchLabel = new JLabel(searchString + ": ");
JButton searchButton
= new JButton(
searchString,
new ImageIcon(
ImageLoader.getImage(ImageLoader.SEARCH_ICON)));
this.searchTextField.getDocument().addDocumentListener(this);
this.add(searchLabel, BorderLayout.WEST);
this.add(textFieldPanel, BorderLayout.CENTER);
this.add(searchTextField, BorderLayout.CENTER);
/*
this.detailsLabelsPanel.add(dateLabel);
@ -150,14 +141,14 @@ public void init() {
this.dateCenteredPanel.add(datePanel);
*/
this.searchButton.setName("search");
this.searchButton.setMnemonic(
searchButton.setName("search");
searchButton.setMnemonic(
GuiActivator.getResources().getI18nMnemonic("service.gui.SEARCH"));
// this.extendedSearchButton.setName("extendedSearch");
// this.extendedSearchOpenedButton.setName("extendedSearchOpened");
this.searchButton.addActionListener(this);
searchButton.addActionListener(this);
this.historyWindow.getRootPane().setDefaultButton(searchButton);
// this.extendedSearchPanel.add(extendedSearchButton,

Loading…
Cancel
Save