/** * Creates and returns a HyperlinkAction with the given target and action type. * @param uri the target uri, maybe null. * @param desktopAction the type of desktop action this class should perform, must be * BROWSE or MAIL * @return a HyperlinkAction * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop * @throws IllegalArgumentException if unsupported action type */ public static HyperlinkAction createHyperlinkAction(URI uri, Action type) { return new HyperlinkAction(uri, type); }
/** * Factory method to create and return a HyperlinkAction for the given uri. Tries * to guess the appropriate type from the uri. If uri is not null and has a * scheme of mailto, create one of type Mail. In all other cases, creates one * for BROWSE. * * @param uri to uri to create a HyperlinkAction for, maybe null. * @return a HyperlinkAction for the given URI. * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop */ public static HyperlinkAction createHyperlinkAction(URI uri) { Action type = isMailURI(uri) ? Action.MAIL : Action.BROWSE; return createHyperlinkAction(uri, type); }
/** * @return */ private URIVisitor getURIVisitor() { if (visitor == null) { visitor = createURIVisitor(); } return visitor; }
/** * */ private void updateEnabled() { setEnabled(getURIVisitor().isEnabled(getTarget())); }
/** * {@inheritDoc} <p> * * Implemented to perform the appropriate Desktop action if supported on the current * target. Sets the visited property to true if the desktop action doesn't throw * an exception or to false if it did. * * Does nothing if the action isn't supported. */ @Override public void actionPerformed(ActionEvent e) { if (!getURIVisitor().isEnabled(getTarget())) return; try { getURIVisitor().visit(getTarget()); setVisited(true); } catch (IOException e1) { setVisited(false); LOG.fine("cant visit Desktop " + e); } }
/** * * @param uri the target uri, maybe null. * @param desktopAction the type of desktop action this class should perform, must be * BROWSE or MAIL * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop * @throws IllegalArgumentException if unsupported action type */ public HyperlinkAction(URI uri, Action desktopAction) { super(); if (!Desktop.isDesktopSupported()) { throw new UnsupportedOperationException("Desktop API is not " + "supported on the current platform"); } if (desktopAction != Desktop.Action.BROWSE && desktopAction != Desktop.Action.MAIL) { throw new IllegalArgumentException("Illegal action type: " + desktopAction + ". Must be BROWSE or MAIL"); } this.desktopAction = desktopAction; getURIVisitor(); setTarget(uri); }
/** * @return */ private URIVisitor createURIVisitor() { return getDesktopAction() == Action.BROWSE ? new BrowseVisitor() : new MailVisitor(); }
/** * Convenience method to create and install a HyperlinkAction for the given URI. * * @param uri * to uri to create a HyperlinkAction for, maybe null. * @throws HeadlessException * if {@link GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException * if the current platform doesn't support Desktop * * @see HyperlinkAction#createHyperlinkAction(URI) */ public void setURI(URI uri) { setAction(HyperlinkAction.createHyperlinkAction(uri)); }
/** * */ private void updateEnabled() { setEnabled(getURIVisitor().isEnabled(getTarget())); }
/** * {@inheritDoc} <p> * * Implemented to perform the appropriate Desktop action if supported on the current * target. Sets the visited property to true if the desktop action doesn't throw * an exception or to false if it did. * * Does nothing if the action isn't supported. */ @Override public void actionPerformed(ActionEvent e) { if (!getURIVisitor().isEnabled(getTarget())) return; try { getURIVisitor().visit(getTarget()); setVisited(true); } catch (IOException e1) { setVisited(false); LOG.fine("cant visit Desktop " + e); } }
/** * * @param uri the target uri, maybe null. * @param desktopAction the type of desktop action this class should perform, must be * BROWSE or MAIL * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop * @throws IllegalArgumentException if unsupported action type */ public HyperlinkAction(URI uri, Action desktopAction) { super(); if (!Desktop.isDesktopSupported()) { throw new UnsupportedOperationException("Desktop API is not " + "supported on the current platform"); } if (desktopAction != Desktop.Action.BROWSE && desktopAction != Desktop.Action.MAIL) { throw new IllegalArgumentException("Illegal action type: " + desktopAction + ". Must be BROWSE or MAIL"); } this.desktopAction = desktopAction; getURIVisitor(); setTarget(uri); }
/** * @return */ private URIVisitor createURIVisitor() { return getDesktopAction() == Action.BROWSE ? new BrowseVisitor() : new MailVisitor(); }
/** * Convenience method to create and install a HyperlinkAction for the given URI. * * @param uri * to uri to create a HyperlinkAction for, maybe null. * @throws HeadlessException * if {@link GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException * if the current platform doesn't support Desktop * * @see HyperlinkAction#createHyperlinkAction(URI) */ public void setURI(URI uri) { setAction(HyperlinkAction.createHyperlinkAction(uri)); }
/** * */ private void updateEnabled() { setEnabled(getURIVisitor().isEnabled(getTarget())); }
/** * {@inheritDoc} <p> * * Implemented to perform the appropriate Desktop action if supported on the current * target. Sets the visited property to true if the desktop action doesn't throw * an exception or to false if it did. * * Does nothing if the action isn't supported. */ @Override public void actionPerformed(ActionEvent e) { if (!getURIVisitor().isEnabled(getTarget())) return; try { getURIVisitor().visit(getTarget()); setVisited(true); } catch (IOException e1) { setVisited(false); LOG.fine("cant visit Desktop " + e); } }
/** * Factory method to create and return a HyperlinkAction for the given uri. Tries * to guess the appropriate type from the uri. If uri is not null and has a * scheme of mailto, create one of type Mail. In all other cases, creates one * for BROWSE. * * @param uri to uri to create a HyperlinkAction for, maybe null. * @return a HyperlinkAction for the given URI. * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop */ public static HyperlinkAction createHyperlinkAction(URI uri) { Action type = isMailURI(uri) ? Action.MAIL : Action.BROWSE; return createHyperlinkAction(uri, type); }
/** * * @param uri the target uri, maybe null. * @param desktopAction the type of desktop action this class should perform, must be * BROWSE or MAIL * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop * @throws IllegalArgumentException if unsupported action type */ public HyperlinkAction(URI uri, Action desktopAction) { super(); if (!Desktop.isDesktopSupported()) { throw new UnsupportedOperationException("Desktop API is not " + "supported on the current platform"); } if (desktopAction != Desktop.Action.BROWSE && desktopAction != Desktop.Action.MAIL) { throw new IllegalArgumentException("Illegal action type: " + desktopAction + ". Must be BROWSE or MAIL"); } this.desktopAction = desktopAction; getURIVisitor(); setTarget(uri); }
/** * Creates and returns a HyperlinkAction with the given target and action type. * @param uri the target uri, maybe null. * @param desktopAction the type of desktop action this class should perform, must be * BROWSE or MAIL * @return a HyperlinkAction * @throws HeadlessException if {@link * GraphicsEnvironment#isHeadless()} returns {@code true} * @throws UnsupportedOperationException if the current platform doesn't support * Desktop * @throws IllegalArgumentException if unsupported action type */ public static HyperlinkAction createHyperlinkAction(URI uri, Action type) { return new HyperlinkAction(uri, type); }
/** * @return */ private URIVisitor createURIVisitor() { return getDesktopAction() == Action.BROWSE ? new BrowseVisitor() : new MailVisitor(); }
/** * @return */ private URIVisitor getURIVisitor() { if (visitor == null) { visitor = createURIVisitor(); } return visitor; }