Permalink
Browse files

Changed contents of the Help tab to be context sensitive.

  • Loading branch information...
1 parent 01bfd98 commit 4f14dc732f95922ebf6d4b37a2a9ff6430c2ea56 @Raptor399 Raptor399 committed Mar 31, 2013
View
@@ -40,6 +40,7 @@ Changelog:
- Trapped exception when handling unsupported formats
- Fixed response to M-SEARCH "ssdp:all" message (thanks, ler0y!)
- Moved several transcoding settings from MEncoder to Common transcoding settings
+ - Help is now context sensitive
1.72.0 - 2012-11-18
@@ -93,6 +93,12 @@
*/
private String uuid;
+ /**
+ * Relative location of a context sensitive help page in the documentation
+ * directory.
+ */
+ private static String helpPage = "index.html";
+
/**Returns a pointer to the main PMS GUI.
* @return {@link net.pms.gui.IFrame} Main PMS window.
*/
@@ -983,4 +989,24 @@ private void logSystemInfo() {
}
}
}
+
+ /**
+ * Sets the relative URL of a context sensitive help page located in the
+ * documentation directory.
+ *
+ * @param page The help page.
+ */
+ public static void setHelpPage(String page) {
+ helpPage = page;
+ }
+
+ /**
+ * Returns the relative URL of a context sensitive help page in the
+ * documentation directory.
+ *
+ * @return The help page.
+ */
+ public static String getHelpPage() {
+ return helpPage;
+ }
}
@@ -21,6 +21,8 @@
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
+
+import net.pms.PMS;
import net.pms.util.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,18 +68,7 @@ public JComponent build() {
editorPane.setContentType("text/html");
editorPane.setBackground(Color.WHITE);
- try {
- // Read the HTML help file
- String documentationDir = PropertiesUtil.getProjectProperties().get("project.documentation.dir");
- File file = new File(documentationDir + "/index.html");
-
- // Display the HTML help file in the editor
- editorPane.setPage(file.toURI().toURL());
- } catch (MalformedURLException e) {
- LOGGER.debug("Caught exception", e);
- } catch (IOException e) {
- LOGGER.debug("Caught exception", e);
- }
+ updateContents();
// Enable internal anchor links
editorPane.addHyperlinkListener(new HyperlinkListener() {
@@ -112,4 +103,25 @@ public void hyperlinkUpdate(HyperlinkEvent event) {
return builder.getPanel();
}
+
+ /**
+ * Load the current help page in the editor pane.
+ */
+ public void updateContents() {
+ if (editorPane != null) {
+ try {
+ // Read the HTML help file
+ String documentationDir = PropertiesUtil.getProjectProperties().get("project.documentation.dir");
+ String helpPage = PMS.getHelpPage();
+ File file = new File(documentationDir + "/" + helpPage);
+
+ // Display the HTML help file in the editor
+ editorPane.setPage(file.toURI().toURL());
+ } catch (MalformedURLException e) {
+ LOGGER.debug("Caught exception", e);
+ } catch (IOException e) {
+ LOGGER.debug("Caught exception", e);
+ }
+ }
+ }
}
@@ -37,6 +37,8 @@
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.*;
@@ -54,16 +56,28 @@
private final PmsConfiguration configuration;
public static final String START_SERVICE = "start.service";
private static final long serialVersionUID = 8723727186288427690L;
+ protected static final Dimension PREFERRED_SIZE = new Dimension(1000, 750);
+ // https://code.google.com/p/ps3mediaserver/issues/detail?id=949
+ protected static final Dimension MINIMUM_SIZE = new Dimension(800, 480);
+
+ /**
+ * List of context sensitive help pages URLs. These URLs should be relative
+ * to the documentation directory and in the same order as the tabs. The
+ * value <code>null</code> means "don't care", activating the tab will not
+ * change the help page.
+ */
+ protected static final String[] HELP_PAGES = { "index.html", null,
+ "general_configuration.html", "navigation_share.html",
+ "transcoding.html", null, null };
+
private NavigationShareTab ft;
private StatusTab st;
private TracesTab tt;
private TranscodingTab tr;
private GeneralTab nt;
+ private HelpTab ht;
private AbstractButton reload;
private JLabel status;
- protected static final Dimension PREFERRED_SIZE = new Dimension(1000, 750);
- // https://code.google.com/p/ps3mediaserver/issues/detail?id=949
- protected static final Dimension MINIMUM_SIZE = new Dimension(800, 480);
private static boolean lookAndFeelInitialized = false;
public TracesTab getTt() {
@@ -345,21 +359,36 @@ public void actionPerformed(ActionEvent e) {
}
public JComponent buildMain() {
- JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP);
+ final JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP);
st = new StatusTab(configuration);
tt = new TracesTab(configuration);
tr = new TranscodingTab(configuration);
nt = new GeneralTab(configuration);
ft = new NavigationShareTab(configuration);
-
- tabbedPane.addTab(Messages.getString("LooksFrame.18"),/* readImageIcon("server-16.png"),*/ st.build());
- tabbedPane.addTab(Messages.getString("LooksFrame.19"),/* readImageIcon("mail_new-16.png"),*/ tt.build());
- tabbedPane.addTab(Messages.getString("LooksFrame.20"),/* readImageIcon("advanced-16.png"),*/ nt.build());
- tabbedPane.addTab(Messages.getString("LooksFrame.22"), /*readImageIcon("bookmark-16.png"),*/ ft.build());
- tabbedPane.addTab(Messages.getString("LooksFrame.21"),/* readImageIcon("player_play-16.png"),*/ tr.build());
- tabbedPane.addTab(Messages.getString("LooksFrame.24"), /* readImageIcon("mail_new-16.png"), */ new HelpTab().build());
- tabbedPane.addTab(Messages.getString("LooksFrame.25"), /*readImageIcon("documentinfo-16.png"),*/ new AboutTab().build());
+ ht = new HelpTab();
+
+ tabbedPane.addTab(Messages.getString("LooksFrame.18"), st.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.19"), tt.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.20"), nt.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.22"), ft.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.21"), tr.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.24"), ht.build());
+ tabbedPane.addTab(Messages.getString("LooksFrame.25"), new AboutTab().build());
+
+ tabbedPane.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ int selectedIndex = tabbedPane.getSelectedIndex();
+
+ if (HELP_PAGES[selectedIndex] != null) {
+ PMS.setHelpPage(HELP_PAGES[selectedIndex]);
+
+ // Update the contents of the help tab itself
+ ht.updateContents();
+ }
+ }
+ });
tabbedPane.setBorder(new EmptyBorder(5, 5, 5, 5));

0 comments on commit 4f14dc7

Please sign in to comment.