Merge pull request #2056 from SiboVG/issue-2046
[#2046] Add Wiki button to help menu
This commit is contained in:
commit
ab0fb6aedb
@ -1464,6 +1464,8 @@ main.menu.help = Help
|
||||
main.menu.help.desc = Information about OpenRocket
|
||||
main.menu.help.tours = Guided tours
|
||||
main.menu.help.tours.desc = Take guided tours on OpenRocket
|
||||
main.menu.help.wiki = Wiki (Online Help)
|
||||
main.menu.help.wiki.desc = Open the OpenRocket Wiki site, containing documentation, in your default webbrowser
|
||||
main.menu.help.license = License
|
||||
main.menu.help.license.desc = OpenRocket license information
|
||||
main.menu.help.bugReport = Bug report
|
||||
|
BIN
core/resources/pix/icons/wiki.png
Normal file
BIN
core/resources/pix/icons/wiki.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 622 B |
@ -1,5 +1,7 @@
|
||||
package net.sf.openrocket.gui.components;
|
||||
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
@ -143,7 +145,7 @@ public class DescriptionArea extends JScrollPane {
|
||||
}
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().browse(uri);
|
||||
URLUtil.openWebpage(uri);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
@ -12,6 +12,7 @@ import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -60,12 +61,9 @@ public class URLLabel extends SelectableLabel {
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
Desktop d = Desktop.getDesktop();
|
||||
try {
|
||||
d.browse(new URI(url));
|
||||
} catch (URISyntaxException e1) {
|
||||
throw new BugException("Illegal URL: " + url, e1);
|
||||
} catch (IOException e1) {
|
||||
URLUtil.openWebpage(url);
|
||||
} catch (Exception e1) {
|
||||
log.error("Unable to launch browser: " + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import net.sf.openrocket.gui.components.StyledLabel;
|
||||
import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.gui.util.Icons;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||
@ -94,9 +95,8 @@ public class UpdateInfoDialog extends JDialog {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(e.getURL().toURI());
|
||||
URLUtil.openWebpage(e.getURL().toURI());
|
||||
} catch (Exception ex) {
|
||||
log.warn("Exception hyperlink: " + ex.getMessage());
|
||||
}
|
||||
@ -180,9 +180,8 @@ public class UpdateInfoDialog extends JDialog {
|
||||
String url = AssetHandler.getInstallerURLForPlatform((UpdatePlatform) comboBox.getSelectedItem(),
|
||||
release.getReleaseName());
|
||||
if (url == null) return;
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(new URI(url));
|
||||
URLUtil.openWebpage(url);
|
||||
} catch (Exception ex) {
|
||||
log.warn("Exception install link: " + ex.getMessage());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.gui.components.StyledLabel;
|
||||
import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.gui.util.Icons;
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
@ -68,9 +69,8 @@ public class WelcomeDialog extends JDialog {
|
||||
@Override
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
try {
|
||||
desktop.browse(e.getURL().toURI());
|
||||
URLUtil.openWebpage(e.getURL().toURI());
|
||||
} catch (Exception ex) {
|
||||
log.warn("Exception hyperlink: " + ex.getMessage());
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkEvent.EventType;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -35,13 +36,9 @@ public class SlideShowLinkListener implements HyperlinkListener {
|
||||
|
||||
URL url = event.getURL();
|
||||
if (url != null && (url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equals("https"))) {
|
||||
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(url.toURI());
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
URLUtil.openWebpage(url.toURI());
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -84,6 +84,7 @@ import net.sf.openrocket.gui.util.Icons;
|
||||
import net.sf.openrocket.gui.util.OpenFileWorker;
|
||||
import net.sf.openrocket.gui.util.SaveFileWorker;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.gui.util.URLUtil;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.logging.Markers;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
@ -751,6 +752,15 @@ public class BasicFrame extends JFrame {
|
||||
}
|
||||
|
||||
//// Help
|
||||
generateHelpMenu(menubar, this);
|
||||
|
||||
this.setJMenuBar(menubar);
|
||||
}
|
||||
|
||||
public static void generateHelpMenu(JMenuBar menubar, JFrame parent) {
|
||||
JMenu menu;
|
||||
JMenuItem item;
|
||||
|
||||
menu = new JMenu(trans.get("main.menu.help"));
|
||||
menu.setMnemonic(KeyEvent.VK_H);
|
||||
menu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.desc"));
|
||||
@ -764,7 +774,20 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Guided tours selected");
|
||||
GuidedTourSelectionDialog.showDialog(BasicFrame.this);
|
||||
GuidedTourSelectionDialog.showDialog(parent);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
//// Wiki (Online Help)
|
||||
item = new JMenuItem(trans.get("main.menu.help.wiki"));
|
||||
item.setIcon(Icons.WIKI);
|
||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.wiki.desc"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Wiki selected");
|
||||
URLUtil.openWebpage(URLUtil.WIKI_URL);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -779,7 +802,7 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Bug report selected");
|
||||
BugReportDialog.showBugReportDialog(BasicFrame.this);
|
||||
BugReportDialog.showBugReportDialog(parent);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -793,7 +816,7 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Debug log selected");
|
||||
new DebugLogDialog(BasicFrame.this).setVisible(true);
|
||||
new DebugLogDialog(parent).setVisible(true);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -808,7 +831,7 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "License selected");
|
||||
new LicenseDialog(BasicFrame.this).setVisible(true);
|
||||
new LicenseDialog(parent).setVisible(true);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
@ -821,12 +844,10 @@ public class BasicFrame extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "About selected");
|
||||
new AboutDialog(BasicFrame.this).setVisible(true);
|
||||
new AboutDialog(parent).setVisible(true);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
this.setJMenuBar(menubar);
|
||||
}
|
||||
|
||||
public RocketActions getRocketActions() {
|
||||
|
@ -131,54 +131,8 @@ public class DummyFrameMenuOSX extends JFrame {
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
|
||||
//// Help
|
||||
menu = new JMenu(trans.get("main.menu.help"));
|
||||
menu.setMnemonic(KeyEvent.VK_H);
|
||||
menu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.desc"));
|
||||
menubar.add(menu);
|
||||
|
||||
//// Guided tours
|
||||
item = new JMenuItem(trans.get("main.menu.help.tours"), KeyEvent.VK_L);
|
||||
item.setIcon(Icons.HELP_TOURS);
|
||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.tours.desc"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "Guided tours selected");
|
||||
GuidedTourSelectionDialog.showDialog(DummyFrameMenuOSX.this);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
//// License
|
||||
item = new JMenuItem(trans.get("main.menu.help.license"), KeyEvent.VK_L);
|
||||
item.setIcon(Icons.HELP_LICENSE);
|
||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.license.desc"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "License selected");
|
||||
new LicenseDialog(DummyFrameMenuOSX.this).setVisible(true);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
//// About
|
||||
item = new JMenuItem(trans.get("main.menu.help.about"), KeyEvent.VK_A);
|
||||
item.setIcon(Icons.HELP_ABOUT);
|
||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.about.desc"));
|
||||
item.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
log.info(Markers.USER_MARKER, "About selected");
|
||||
new AboutDialog(DummyFrameMenuOSX.this).setVisible(true);
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
BasicFrame.generateHelpMenu(menubar, this);
|
||||
|
||||
this.setJMenuBar(menubar);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -54,11 +53,9 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.TableColumnModelListener;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.DefaultTableColumnModel;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@ -69,7 +66,6 @@ import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import net.sf.openrocket.gui.Resettable;
|
||||
import net.sf.openrocket.logging.Markers;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.Invalidatable;
|
||||
|
@ -78,6 +78,7 @@ public class Icons {
|
||||
public static final Icon HELP_BUG_REPORT = loadImageIcon("pix/icons/help-bug.png", "Bug report");
|
||||
public static final Icon HELP_DEBUG_LOG = loadImageIcon("pix/icons/help-log.png", "Debug log");
|
||||
public static final Icon HELP_TOURS = loadImageIcon("pix/icons/help-tours.png", "Guided tours");
|
||||
public static final Icon WIKI = loadImageIcon("pix/icons/wiki.png", "Wiki (Documentation)");
|
||||
|
||||
public static final Icon ZOOM_IN = loadImageIcon("pix/icons/zoom-in.png", "Zoom in");
|
||||
public static final Icon ZOOM_OUT = loadImageIcon("pix/icons/zoom-out.png", "Zoom out");
|
||||
|
32
swing/src/net/sf/openrocket/gui/util/URLUtil.java
Normal file
32
swing/src/net/sf/openrocket/gui/util/URLUtil.java
Normal file
@ -0,0 +1,32 @@
|
||||
package net.sf.openrocket.gui.util;
|
||||
|
||||
import net.sf.openrocket.util.BugException;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public abstract class URLUtil {
|
||||
public static final String WIKI_URL = "http://wiki.openrocket.info/";
|
||||
|
||||
public static boolean openWebpage(URI uri) {
|
||||
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
|
||||
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
|
||||
try {
|
||||
desktop.browse(uri);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean openWebpage(String url) {
|
||||
try {
|
||||
return openWebpage(new URI(url));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new BugException("Illegal URL: " + url, e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user