private JPanel footerPanel( MessageWriter writer, ChatFriend chatFriend, ScheduledExecutorService schedExecService) { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(BACKGROUND_COLOR); downloadlink = new HyperlinkButton(new DownloadFromFriendLibraryAction()); downloadlink.setFont(linkFont); downloadlink.setEnabled(chatFriend.isSignedInToLimewire()); toolbar = new JXPanel(new MigLayout("insets 0 0 0 5, gap 10, alignx right, aligny 50%")); ResizeUtils.forceHeight(toolbar, 22); toolbar.setBackgroundPainter( new GenericBarPainter<JXPanel>( new GradientPaint(0, 0, toolbarTopColor, 0, 1, toolbarBottomColor), toolbarBorderColor, PainterUtils.TRASPARENT, toolbarBorderColor, PainterUtils.TRASPARENT)); if (hasFeature(NoSaveFeature.ID)) { ensureNoSaveLinkExists(); } toolbar.add(downloadlink); inputPanel = new ResizingInputPanel(writer, schedExecService); inputPanel.setBorder(BorderFactory.createEmptyBorder()); panel.add(toolbar, BorderLayout.NORTH); panel.add(inputPanel, BorderLayout.CENTER); return panel; }
/** * Called to indicate a new chat state in this conversation. * * @param chatState being added. */ public void newChatState(ChatState chatState) { LOG.debugf("Chat state update for {0} to {1}", chatFriend.getName(), chatState); if (currentChatState != chatState) { currentChatState = chatState; displayMessages(); } }
/** * Returns the feature identified by the method parameter. The feature can be in any of the * presences of the friend. * * <p>This was done to get around implementing adding/removing features on objects (such as xmpp * connections and friends) other than FriendPresences * * @param feature desired feature's URI * @return {@link Feature} */ private Feature getFeature(URI feature) { for (FriendPresence presence : chatFriend.getFriend().getPresences().values()) { if (presence.hasFeatures(feature)) { return presence.getFeature(feature); } } return null; }
public MockMessageFileOffer( ChatFriend chatFriend, long messageTimeMillis, String senderName, Type type, FileMetaData fileOffer) { this.friendID = chatFriend.getID(); this.messageTimeMillis = messageTimeMillis; this.senderName = senderName; this.type = type; this.fileOffer = fileOffer; }
private void handleLinkClick(String linkDescription, URL url) { if (ChatDocumentBuilder.LIBRARY_LINK.equals(linkDescription)) { ChatFriend libraryChatFriend = conversation.getChatFriend(); LOG.debugf("Opening a view to {0}'s library", libraryChatFriend.getName()); // libraryNavigator.selectFriendLibrary(libraryChatFriend.getFriend()); throw new IllegalStateException("action does't exist"); } else if (ChatDocumentBuilder.MY_LIBRARY_LINK.equals(linkDescription)) { LOG.debugf("Opening a view to my library"); // libraryNavigator.selectLibrary(); throw new IllegalStateException("action does't exist"); } else { LOG.debugf("Hyperlink clicked: {0}", linkDescription); if (linkDescription.startsWith("magnet")) { // TODO: Need to do something with magnet links } else if (url != null) { NativeLaunchUtils.openURL(url.toString()); } } }
/** * Called to indicate a new feature addition/removal. * * @param feature the feature being updated * @param action whether the feature is added or removed. */ public void featureUpdate(Feature feature, FeatureEvent.Type action) { if (feature.getID().equals(LimewireFeature.ID)) { if (action == FeatureEvent.Type.ADDED) { downloadlink.setEnabled(true); } else if (action == FeatureEvent.Type.REMOVED) { downloadlink.setEnabled(chatFriend.isSignedInToLimewire()); } } else if (feature.getID().equals(NoSaveFeature.ID)) { if (action == FeatureEvent.Type.ADDED) { ensureNoSaveLinkExists(); NoSave status = ((NoSaveStatus) feature.getFeature()).getStatus(); if (status != noSaveState) { NoSaveStatusMessage msg = new NoSaveStatusMessage(friendId, Message.Type.SERVER, status); messageBroadcaster.broadcast(new ChatMessageEvent(msg)); } } } }
@Override public void displayMessages() { displayMessages(!chatFriend.isSignedIn()); }
@Inject public ConversationPane( @Assisted MessageWriter writer, final @Assisted ChatFriend chatFriend, Provider<IconManager> iconManager, ChatHyperlinkListenerFactory chatHyperlinkListenerFactory, CloseChatMessage closeChatMessage, FriendPresenceActions remoteHostActions, @Named("backgroundExecutor") ScheduledExecutorService schedExecService, EventBroadcaster<ChatMessageEvent> messageBroadcaster) { this.writer = writer; this.chatFriend = chatFriend; this.conversationName = chatFriend.getName(); this.friendId = chatFriend.getID(); this.iconManager = iconManager; this.noSaveState = null; this.remoteHostActions = remoteHostActions; this.messageBroadcaster = messageBroadcaster; GuiUtils.assignResources(this); setLayout(new BorderLayout()); editor = new JEditorPane(); editor.setEditable(false); editor.setContentType("text/html"); editor.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING)); HTMLEditorKit editorKit = (HTMLEditorKit) editor.getEditorKit(); editorKit.setAutoFormSubmission(false); conversationScroll = new JScrollPane( editor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); conversationScroll.setOpaque(false); conversationScroll.setBorder(BorderFactory.createEmptyBorder()); final JButton closeConversation = new IconButton(closeChatMessage); closeConversation.setIcon(endChat); chatWrapper = new JPanel(); chatWrapper.setLayout(new OverlayLayout(chatWrapper)); JPanel closePanel = new JPanel(); closePanel.setLayout(null); closePanel.setOpaque(false); final Rectangle closeBounds = new Rectangle(268, 5, 6, 6); final Rectangle closeBoundsSlider = new Rectangle(250, 5, 6, 6); closeConversation.setBounds(closeBounds); closePanel.add(closeConversation); JPanel conversationPanel = new JPanel(new BorderLayout()); conversationPanel.setOpaque(false); conversationPanel.add(conversationScroll, BorderLayout.CENTER); chatWrapper.add(closePanel); chatWrapper.add(conversationPanel); conversationScroll .getVerticalScrollBar() .addComponentListener( new ComponentListener() { @Override public void componentHidden(ComponentEvent e) { closeConversation.setBounds(closeBounds); } @Override public void componentMoved(ComponentEvent e) {} @Override public void componentResized(ComponentEvent e) {} @Override public void componentShown(ComponentEvent e) { closeConversation.setBounds(closeBoundsSlider); } }); AdjustmentListener adjustmentListener = new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { chatWrapper.repaint(); } }; conversationScroll.getVerticalScrollBar().addAdjustmentListener(adjustmentListener); conversationScroll.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener); add(chatWrapper, BorderLayout.CENTER); PopupUtil.addPopupMenus(editor, new CopyAction(editor), new CopyAllAction()); add(footerPanel(writer, chatFriend, schedExecService), BorderLayout.SOUTH); setBackground(DEFAULT_BACKGROUND); editor.addHyperlinkListener(chatHyperlinkListenerFactory.create(this)); }