/** * Checks to see if the mouse is located over a browseable * link. * * @param e - the current MouseEvent. */ public void mouseMoved(MouseEvent e) { checkForLink(e); }
public void actionPerformed(ActionEvent e) { if (e.getSource() == cutMenu) { cutAction(); } else if (e.getSource() == copyMenu) { SparkManager.setClipboard(getSelectedText()); } else if (e.getSource() == pasteMenu) { pasteAction(); } else if (e.getSource() == selectAll) { requestFocus(); selectAll(); } }
@Override protected void addTo( ChatArea chatArea ) throws BadLocationException { final Document doc = chatArea.getDocument(); chatArea.insertComponent( new JSeparator() ); doc.insertString(doc.getLength(), "\n", null ); chatArea.setCaretPosition(doc.getLength()); } }
private void cutAction() { String selectedText = getSelectedText(); replaceSelection(""); SparkManager.setClipboard(selectedText); }
/** * Inserts an emotion icon into the current document. * * @param imageKey - the smiley representation of the image.( ex. :) ) * @return true if the image was found, otherwise false. */ public boolean insertImage( ChatArea chatArea, String imageKey ) { if ( !chatArea.getForceEmoticons() && !SettingsManager.getLocalPreferences().areEmoticonsEnabled() || !chatArea.emoticonsAvailable ) { return false; } final Icon emotion = EmoticonManager.getInstance().getEmoticonImage( imageKey ); if ( emotion == null ) { return false; } final Document doc = chatArea.getDocument(); chatArea.select( doc.getLength(), doc.getLength() ); chatArea.insertIcon( emotion ); return true; } }
setFont(new Font("Dialog", Font.PLAIN, 12)); getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl x"), "cut"); getActionMap().put("cut", new AbstractAction("cut") { private static final long serialVersionUID = 9117190151545566922L; getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl c"), "copy"); getActionMap().put("copy", new AbstractAction("copy") { private static final long serialVersionUID = 4949716854440264528L; getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("Ctrl v"), "paste"); getActionMap().put("paste", new AbstractAction("paste") { private static final long serialVersionUID = -8767763580660683678L; setEditorKit( new WrapEditorKit() ); // SPARK-1613 Ensure that long text wraps.
private void handlePopup(MouseEvent e) { popup = new JPopupMenu(); popup.add(cutMenu); popup.add(copyMenu); popup.add(pasteMenu); fireContextMenuListeners(); popup.addSeparator(); popup.add(selectAll); // Handle enable boolean textSelected = ModelUtil.hasLength(getSelectedText()); String clipboard = SparkManager.getClipboard(); cutMenu.setEnabled(textSelected && isEditable()); copyMenu.setEnabled(textSelected); pasteMenu.setEnabled(ModelUtil.hasLength(clipboard) && isEditable()); popup.show(this, e.getX(), e.getY()); }
/** * Checks to see if the mouse is located over a browseable * link. * * @param e - the current MouseEvent. */ private void checkForLink(MouseEvent e) { try { final int pos = viewToModel(e.getPoint()); final Element element = getStyledDocument().getCharacterElement(pos); if (element != null) { final AttributeSet as = element.getAttributes(); final Object o = as.getAttribute("link"); if (o != null) { setCursor(HAND_CURSOR); } else { setCursor(DEFAULT_CURSOR); } } } catch (Exception ex) { Log.error("Error in CheckLink:", ex); } }
@Override protected void addTo( ChatArea chatArea ) throws BadLocationException { final Document doc = chatArea.getDocument(); doc.insertString( doc.getLength(), getFormattedTimestamp() + message + "\n", getStyle() ); chatArea.setCaretPosition( doc.getLength() ); } }
public void mouseClicked(MouseEvent e) { try { final int pos = viewToModel(e.getPoint()); final Element element = getStyledDocument().getCharacterElement(pos); try { final String url = (String)o; boolean handled = fireLinkInterceptors(e, url); if (!handled) { if(e.getButton() == MouseEvent.BUTTON1)
protected void releaseResources() { getActionMap().remove("copy"); getActionMap().remove("cut"); getActionMap().remove("paste"); }
public void actionPerformed(ActionEvent evt) { SparkManager.setClipboard(getSelectedText()); } });
@Override protected void addTo( ChatArea chatArea ) throws BadLocationException { // Get the instant that represents the start of the day in the local time-zone. final LocalDateTime startOfDay = getTimestamp().withZoneSameInstant( ZoneId.systemDefault() ).toLocalDate().atStartOfDay(); final String startOfDayMessage = FORMAT.format( startOfDay ); final Document doc = chatArea.getDocument(); doc.insertString(doc.getLength(), startOfDayMessage + '\n', STYLE ); chatArea.setCaretPosition(doc.getLength()); } }
final Document doc = chatArea.getDocument(); doc.insertString( doc.getLength(), getFormattedTimestamp() + prefix + ": ", prefixStyle ); chatArea.setCaretPosition( doc.getLength() );