com.alee.utils.WebUtils Java Examples

The following examples show how to use com.alee.utils.WebUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinkUtils.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    WebTextPane textPane = (WebTextPane) e.getComponent();
    StyledDocument doc = textPane.getStyledDocument();
    Element elem = doc.getCharacterElement(textPane.viewToModel(e.getPoint()));
    if (!elem.getAttributes().isDefined(URL_ATT_NAME))
        // not a link
        return;

    int len = elem.getEndOffset() - elem.getStartOffset();
    final String url;
    try {
        url = doc.getText(elem.getStartOffset(), len);
    } catch (BadLocationException ex) {
        LOGGER.log(Level.WARNING, "can't get URL", ex);
        return;
    }

    Runnable run = new Runnable() {
        @Override
        public void run() {
            WebUtils.browseSiteSafely(fixProto(url));
        }
    };
    new Thread(run, "Link Browser").start();
}
 
Example #2
Source File: UrlLinkAction.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void asyncLinkExecuted ( @NotNull final ActionEvent event )
{
    final String url = getText ();
    if ( url == null )
    {
        throw new RuntimeException ( "URL cannot be null" );
    }
    WebUtils.browseSiteSafely ( url );
}
 
Example #3
Source File: EmailLinkAction.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void asyncLinkExecuted ( @NotNull final ActionEvent event )
{
    final String email = getText ();
    if ( email == null )
    {
        throw new RuntimeException ( "E-mail cannot be null" );
    }
    WebUtils.writeEmailSafely ( email );
}
 
Example #4
Source File: FileLinkAction.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void asyncLinkExecuted ( @NotNull final ActionEvent event )
{
    WebUtils.openFileSafely ( file );
}