diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c11197e..3fe0fb5a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +- ![UI] Add link to online help documentation [#891](https://github.com/jdemetra/jdemetra-app/issues/891) - ![OTHER] Add Windows binaries to release [#885](https://github.com/jdemetra/jdemetra-app/issues/885) ### Fixed diff --git a/nbdemetra-ui/src/main/java/internal/BrowseOnlineDocAction.java b/nbdemetra-ui/src/main/java/internal/BrowseOnlineDocAction.java new file mode 100644 index 000000000..0dfb97012 --- /dev/null +++ b/nbdemetra-ui/src/main/java/internal/BrowseOnlineDocAction.java @@ -0,0 +1,48 @@ +package internal; + +import ec.nbdemetra.ui.notification.NotifyUtil; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; +import org.openide.nodes.Node; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; +import org.openide.util.actions.NodeAction; + +import java.awt.*; +import java.io.IOException; +import java.net.URI; + +@ActionID(category = "Help", id = BrowseOnlineDocAction.ID) +@ActionRegistration(displayName = "#BrowseOnlineDocAction", lazy = false) +@ActionReference(path = "Menu/Help", position = 200) +@NbBundle.Messages("BrowseOnlineDocAction=Online Docs") +public final class BrowseOnlineDocAction extends NodeAction { + +// @ClassNameConstant + public static final String ID = "internal.BrowseOnlineDocAction"; + + @Override + public String getName() { + return Bundle.BrowseOnlineDocAction(); + } + + @Override + public HelpCtx getHelpCtx() { + return null; + } + + @Override + protected void performAction(Node[] nodes) { + try { + Desktop.getDesktop().browse(URI.create("https://jdemetra-new-documentation.netlify.app/")); + } catch (IOException ex) { + NotifyUtil.error("Desktop", "Cannot browse uri", ex); + } + } + + @Override + protected boolean enable(Node[] nodes) { + return Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE); + } +}