This package provides support for building up chat applications.
Each chat application haspublic class SimpleChatPanel extends JPanel { /** creates a new simple chat panel for the given chatModel */ public SimpleChatPanel(IChatModel chatModel) // the chat model { super(new BorderLayout()); MessageList messageList = new MessageList(false); // the message view messageList.setModel(chatModel.getChatListModel()); MessageModel messageModel = new MessageModel(chatModel);// the local message model DefaultMessageEditor editor = // the message editor new DefaultMessageEditor(messageModel); this.add(new JScrollPane(messageList), BorderLayout.CENTER); this.add(editor, BorderLayout.SOUTH); messageModel.startEditing(); } }
The references are rendered by a ReferencePanel. The reference panel must be the root component of all IReferencingDocViewers (eg. the message editor and the chat views) and all IReferencedDocViewers (eg. the chat views and the material components). The reference panel delegates the actual computations of the reference shapes to registered reference renderers. There exists some base implementations for showing references between messages in the list view, the tree view and between the message editor and a chat view.
The ChatPanel is a base container for multiple chat views as well as multiple editors (if you need different message editors in your application). The chat panel can show the references either on the left or the right side.
The base implementation of the local message model with outgoing references is the ReferencingMessageModel. A "reference property" editor is the reference creator, which allows the creation of references by pressing the right mouse button.
public class ReferencingChatPanel extends ReferencePanel // we extend the reference panel to have it as root { public ReferencingChatPanel(IChatModel chatModel) // the chat model { super(new BorderLayout()); // create the chat panel containing one Filler chatPanel = new ChatPanel(true, referenceDirection); chatPanel.setChatModel(messageFilter); // create and register the reference renderer using the chat panels filler referencePanel.registerRenderer(new DefaultVerticalReferenceRenderer(chatPanel.getFillPanel())); // create and add the chat views if (listView) { MessageList messageList = new MessageList(); chatPanel.addChatView(messageList); } if (treeView) { MessageTree messageTree = new MessageTree(); chatPanel.addChatView(messageTree); } chatPanel.getMultipleChatView().getToolbar().setVisible(treeView && listView); // create the message model containing the local message properties // final MessageModel messageModel = new MessageModel(chatModel, true); messageModel = new MessageModel(null, true); if (messageFactory != null) { messageModel.setMessageFactory(messageFactory); } // create the message editor and add it to the chat panel DefaultMessageEditor editor = new DefaultMessageEditor(messageModel); chatPanel.addMessageEditor(editor); materialListModel = new MaterialListModel(); targetSelectionListModel = new TargetSelectionListModel(); targetSelectionListModel.addReverseListModel(chatPanel.getMultipleChatView().getMessageListModel()); targetSelectionListModel.addListModel(materialListModel); PopupReferenceEditor.bindPopupTo(editor.getMessageArea(),targetSelectionListModel,messageModel); // add a listener to the message model updating the shown references for the message editor messageModel.addMessageChangeListener( new MessageReferenceChangeListener( referencePanel.getMultiSelectionModel(), referencePanel.getReferenceModel())); // create a reference editor using the mouse and the currently selected things and // add it to all chat views mouseReferenceEditor = new MouseReferenceEditor(messageModel, referencePanel.getReferenceModel()); chatPanel.getMultipleChatView().addMouseListenerToChatViews(mouseReferenceEditor); // create a type model and mouse editor using the mouse and a popup and // add it to all chat views typeModel = new TypeModel(); mouseTypeEditor = new MouseTypeEditor(messageModel, typeModel); PopupTypeEditor.bindPopupTo(editor.getMessageArea(), typeModel, messageModel); chatPanel.getMultipleChatView().addMouseListenerToChatViews(mouseTypeEditor); // add the chat panel to the reference panel this.add(chatPanel, BorderLayout.CENTER); // let the message model start the message creation process messageModel.startEditing(); } }