revision 444 GUI issue

Download and discuss official beta builds here

Re: revision 444 GUI issue

Postby dummy_user » Tue Jan 25, 2011 8:32 am

Yep, nice work!
I'll post another patch with some additional layout changes when I'm happy about the resizing behaviour (if you don't beat me to it :p)
is taconaut again
dummy_user
 
Posts: 33
Joined: Mon Nov 29, 2010 9:03 am

Re: revision 444 GUI issue

Postby dummy_user » Tue Jan 25, 2011 7:44 pm

Here's a patch which
- improves the layout of the transcoding settings tab
- makes the about scrollable
- stretches the layout of the status tab. This way, the separators don't resize according to the shown message
- Sets the preferred size of the LooksFrame to the minimum size for the scroll bars not to show after start up on mac
Take the ones you like :)

Code: Select all
Index: net/pms/newgui/LinksTab.java
===================================================================
--- net/pms/newgui/LinksTab.java   (revision 453)
+++ net/pms/newgui/LinksTab.java   (working copy)
@@ -28,6 +28,7 @@
 import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
 
 import net.pms.Messages;
 import net.pms.PMS;
@@ -96,7 +97,10 @@
            builder.addLabel(mplayerSherpiaBuildsLink.getLabel(),
                  cc.xy(2, 13, "center, fill")).addMouseListener(mplayerSherpiaBuildsLink);
           
-           return builder.getPanel();
+           JScrollPane sp = new JScrollPane(builder.getPanel());
+           sp.setBorder(null);
+          
+           return sp;
    }
 
    private static class LinkMouseListener implements MouseListener
Index: net/pms/newgui/LooksFrame.java
===================================================================
--- net/pms/newgui/LooksFrame.java   (revision 453)
+++ net/pms/newgui/LooksFrame.java   (working copy)
@@ -101,7 +101,7 @@
    
     private JLabel status;
 
-   protected static final Dimension PREFERRED_SIZE = new Dimension(1000, 750);
+   protected static final Dimension PREFERRED_SIZE = new Dimension(1000, 775);
    // https://code.google.com/p/ps3mediaserver/issues/detail?id=949
    protected static final Dimension MINIMUM_SIZE = new Dimension(800, 480);
 
Index: net/pms/newgui/StatusTab.java
===================================================================
--- net/pms/newgui/StatusTab.java   (revision 453)
+++ net/pms/newgui/StatusTab.java   (working copy)
@@ -64,7 +64,7 @@
 
    public JComponent build() {
        FormLayout layout = new FormLayout(
-                   "0:grow, pref, 0:grow", //$NON-NLS-1$
+                   "3px, fill:10:grow, 3px", //$NON-NLS-1$
                    "pref, 9dlu, pref, 3dlu, pref, 15dlu, pref, 3dlu, p, 3dlu, p, 3dlu, p, 9dlu, p, 5dlu, p"); //$NON-NLS-1$
 
            PanelBuilder builder = new PanelBuilder(layout);
@@ -80,7 +80,7 @@
              
            builder.add(jl, cc.xy(2, 3));
             imagePanel = buildImagePanel("/resources/images/connect_no-256.png");
-           builder.add(imagePanel, cc.xy(2, 5, "center, fill")); //$NON-NLS-1$
+           builder.add(imagePanel, cc.xy(2, 5, CellConstraints.CENTER, CellConstraints.CENTER)); //$NON-NLS-1$
           
            jpb = new JProgressBar(0, 100);
            jpb.setStringPainted(true);
@@ -139,6 +139,7 @@
       } catch (IOException e) {
       }
       }
+      
       return new ImagePanel(bi);
    }
    
Index: net/pms/newgui/TrTab2.java
===================================================================
--- net/pms/newgui/TrTab2.java   (revision 453)
+++ net/pms/newgui/TrTab2.java   (working copy)
@@ -21,9 +21,12 @@
 import java.awt.CardLayout;
 import java.awt.Color;
 import java.awt.Component;
+import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyEvent;
@@ -96,6 +99,7 @@
    private JCheckBox  mpeg2remux ;
    private JCheckBox  chapter_support ;
    private JTextField chapter_interval;
+   private JScrollPane spTree;
 
    private static final int MAX_CORES = 32;
    
@@ -122,8 +126,8 @@
    
    public JComponent build() {
       FormLayout mainlayout = new FormLayout(
-         "left:pref, pref, 7dlu, pref, pref, 10:grow", //$NON-NLS-1$
-         "top:10:grow" //$NON-NLS-1$
+         "left:pref, pref, 7dlu, pref, pref, fill:10:grow", //$NON-NLS-1$
+         "fill:10:grow" //$NON-NLS-1$
       );
       PanelBuilder builder = new PanelBuilder(mainlayout);
         builder.setBorder(Borders.DLU4_BORDER);
@@ -149,7 +153,7 @@
    public JComponent buildLeft() {
       FormLayout layout = new FormLayout(
          "left:pref, pref, pref, pref, 0:grow", //$NON-NLS-1$
-         "p, 3dlu, p, 3dlu, p, 3dlu, p, 30dlu, 0:grow"
+         "fill:10:grow, 3dlu, p, 3dlu, p, 3dlu, p"
       ); //$NON-NLS-1$
 
       PanelBuilder builder = new PanelBuilder(layout);
@@ -226,6 +230,12 @@
 
       DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages.getString("TrTab2.11")); //$NON-NLS-1$
       TreeNodeSettings commonEnc = new TreeNodeSettings(Messages.getString("TrTab2.5"), null, buildCommon()); //$NON-NLS-1$
+      commonEnc.getConfigPanel().addComponentListener(new ComponentAdapter() {
+         @Override
+         public void componentShown(ComponentEvent e) {
+             handleCardComponentChange(e.getComponent());
+         }
+      });
       tabbedPane.add(commonEnc.id(), commonEnc.getConfigPanel());
       root.add(commonEnc);
 
@@ -257,9 +267,10 @@
       });
 
       tree.setCellRenderer(new TreeRenderer());
-      JScrollPane pane = new JScrollPane(tree);
+      spTree = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+      spTree.setPreferredSize(new Dimension(tree.getPreferredSize().width + 20, tree.getPreferredSize().height));
 
-      builder.add(pane,          cc.xyw(2,  1, 4));
+      builder.add(spTree,          cc.xyw(2,  1, 4));
 
       builder.addLabel(Messages.getString("TrTab2.19"), cc.xyw(2, 5, 4)); //$NON-NLS-1$
       builder.addLabel(Messages.getString("TrTab2.20"), cc.xyw(2, 7, 4)); //$NON-NLS-1$
@@ -267,6 +278,11 @@
       return builder.getPanel();
    }
 
+   private void handleCardComponentChange(Component component) {
+        tabbedPane.setPreferredSize(component.getPreferredSize());
+        SwingUtilities.updateComponentTreeUI(tabbedPane);
+    }
+
    public void addEngines() {
       ArrayList<Player> disPlayers = new ArrayList<Player>();
       ArrayList<Player> ordPlayers = new ArrayList<Player>();
@@ -295,6 +311,12 @@
          JComponent jc = en.getConfigPanel();
          if (jc == null)
             jc = buildEmpty();
+         jc.addComponentListener(new ComponentAdapter() {
+            @Override
+            public void componentShown(ComponentEvent e) {
+                handleCardComponentChange(e.getComponent());
+            }
+         });
          tabbedPane.add(en.id(), jc);
          parent[p.purpose()].add(en);
          

Looking at the code, swing can be a pain.. Haven't found a better way of getting the preferred size of the shown component in the transcoding settings tab, than adding a ComponentListener, which will be called every time it gets visible. Why can't it be retrieved from the CardLayout that manages them after being set by key?
is taconaut again
dummy_user
 
Posts: 33
Joined: Mon Nov 29, 2010 9:03 am

Re: revision 444 GUI issue

Postby WorldOfHurt » Tue Jan 25, 2011 9:37 pm

Have you considered using SWT instead?

From what I remember (and we are going back years, here ;) ) it's got good cross-platform support, is much easier to code, was more flexible with way more widgets, and produced more polished-looking GUIs - all at the (minor) expense of requiring a platform-specific binary.

Or - the best solution of all - a HTTP GUI :)
User avatar
WorldOfHurt
 
Posts: 252
Joined: Thu Mar 19, 2009 10:49 pm
Location: Winchester, UK

Re: revision 444 GUI issue

Postby dummy_user » Wed Jan 26, 2011 8:18 am

Redoing the interface using another java ui using another library would represent quite a lot of work. I think that it would be overkill to redo everything. In the longer term it would be cool to have a web gui and web services which could be accessed by everything, e.g. android and iphone apps.
is taconaut again
dummy_user
 
Posts: 33
Joined: Mon Nov 29, 2010 9:03 am

Re: revision 444 GUI issue

Postby SubJunk » Wed Jan 26, 2011 8:26 am

I think the interface is good now. It can be made better with tweaks like we are doing, but I don't think we need to make fundamental changes.
It's not a program that requires a lot of ongoing configuration; most users will configure it once and rarely touch it again, if ever.
So I agree with dummy_user that it would be overkill, especially when there are other, more important changes to be worked on :)
SubJunk
 
Posts: 1210
Joined: Fri Mar 27, 2009 5:25 am

Re: revision 444 GUI issue

Postby mazey » Wed Jan 26, 2011 8:27 am

dummy_user wrote:Redoing the interface using another java ui using another library would represent quite a lot of work. I think that it would be overkill to redo everything. In the longer term it would be cool to have a web gui and web services which could be accessed by everything, e.g. android and iphone apps.


the ui is fine with the addition of scrollbars ppl can access all the features now so it wont be a problem as for a web gui dont think its really needed though we have a html console (web ui?) which couldnt hurt to add a few more options to that (so its actually useful)

[main] TRACE 17:30:42.714 A tiny media library admin interface is available at: http://192.168.0.100:5001/console/home

just add more features to that and im sure alot of ppl dont even know it exists so maybe put a few options to maybe enable/disable it aswell as the conect url and port from the normal ui so ppl might notice it exists.. but yeah without extra features it aint really worth it, what would be a good option to add is shutdown computer via it, etc.
mazey
 
Posts: 772
Joined: Sat Oct 24, 2009 9:07 am

Re: revision 444 GUI issue

Postby dummy_user » Wed Jan 26, 2011 12:06 pm

I meant the html console by web gui.
Currently I don't see a big need for it either, but I keep the media library I'm working on in mind, where it could be nice to browse your entire collection in a web browser. Btw, this is also why I'm against changing to something else than swing; I'd rather like the interface I've create not becoming obsolete before the first release ;)

In a perfect world, I'd see pms as a service, demon or whatever it is called for a specific platform, which wouldn't have a gui, but offer all the current functionalities through services. Then clients (java, web services, http server, whatever) could be created by developers and the end user could choose what he likes.
is taconaut again
dummy_user
 
Posts: 33
Joined: Mon Nov 29, 2010 9:03 am

Re: revision 444 GUI issue

Postby WorldOfHurt » Wed Jan 26, 2011 2:38 pm

dummy_user wrote:In a perfect world, I'd see pms as a service, demon or whatever it is called for a specific platform, which wouldn't have a gui, but offer all the current functionalities through services. Then clients (java, web services, http server, whatever) could be created by developers and the end user could choose what he likes.


We're talking the same language here ;) I originally suggested as much about 2 years ago but, just like today, more pressing playback issues have to come first.

I would happily donate some effort to a servlet HTTP front end if there was a common administration service, so it would not have to rely on an interface that is, by necessity, quite fragile and always changing.
User avatar
WorldOfHurt
 
Posts: 252
Joined: Thu Mar 19, 2009 10:49 pm
Location: Winchester, UK

Re: revision 444 GUI issue

Postby taconaut » Mon Feb 07, 2011 2:02 pm

WorldOfHurt wrote:
dummy_user wrote:In a perfect world, I'd see pms as a service, demon or whatever it is called for a specific platform, which wouldn't have a gui, but offer all the current functionalities through services. Then clients (java, web services, http server, whatever) could be created by developers and the end user could choose what he likes.


We're talking the same language here ;) I originally suggested as much about 2 years ago but, just like today, more pressing playback issues have to come first.

I would happily donate some effort to a servlet HTTP front end if there was a common administration service, so it would not have to rely on an interface that is, by necessity, quite fragile and always changing.

Out of curiosity and to see how much work would be needed to expose the pms configuration through a web service, I've created a proof of concept plugin, which exposes a few methods to get/set and save the configuration. The result is, that it is really simple and only requires a few lines of code to do this.

The exposed interface looks as follows:
Code: Select all
package net.pms.plugin.webservice;

import java.util.List;

public interface Configuration {

   /**
    * Get a configuration value by specifying the key
    *
    * @param key
    *            a valid parameter key
    * @throws InvalidParameterException
    *             if the specified key can't be found in the list of parameters
    * @return the value corresponding to the key
    */
   public String getValue(String key) throws InvalidParameterException;

   /**
    * Sets a value for a key
    *
    * @param key
    *            a valid parameter key
    * @param value
    *            the value to set
    * @throws InvalidParameterException
    *             if either the key or the associated value isn't valid
    */
   public void setValue(String key, String value)
         throws InvalidParameterException;

   /**
    * Save the current configuration to file
    *
    * @throws SaveException
    *             thrown if an error occurs while trying to save the
    *             configuration
    */
   public void saveConfiguration() throws SaveException;

   /**
    * Get the list of all available parameters to be used as keys in
    * get/setValue
    *
    * @return list of parameters
    */
   public List<String> getParameters();
}


Implementation:
Code: Select all
package net.pms.plugin.webservice;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

import net.pms.PMS;
import net.pms.configuration.PmsConfiguration;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;

@WebService(serviceName = "Configure", targetNamespace = "http://ps3mediaserver.org/configure")
public class ConfigurationWebService implements Configuration {
   private static final Logger log = Logger
         .getLogger(ConfigurationWebService.class);

   /**
    * the published endpoint
    */
   private Endpoint endpoint = null;

   /**
    *
    * Start to listen for remote requests
    *
    * @param host
    *            ip or host name
    * @param port
    *            port to use
    * @param path
    *            name of the web service
    */
   void bind(String host, int port, String path) {
      String endpointURL = "http://" + host + ":" + port + "/" + path;
      try {
         endpoint = Endpoint.publish(endpointURL, this);
         log.info("Sucessfully bound enpoint: " + endpointURL);
      } catch (Exception e) {
         log.error("Failed to bind enpoint: " + endpointURL, e);
      }
   }

   /**
    * Stop the webservice
    */
   void shutdown() {
      log.info("Shut down ConfigurationWebService");
      if (endpoint != null)
         endpoint.stop();
      endpoint = null;
   }

   @Override
   @WebMethod(operationName = "getValue")
   public String getValue(@WebParam(name = "key") String key)
         throws InvalidParameterException {
      ConfigurationValue enumKey = getConfigurationValue(key);
      PmsConfiguration conf = PMS.getConfiguration();

      // TODO: add all the possible configuration values
      String res = "";
      switch (enumKey) {
      case Language:
         res = conf.getLanguage();
         break;
      default:
         throw new InvalidParameterException(String.format(
               "Retrieval of key %s hasn't been implemented yet", key));
      }
      return res;
   }

   @Override
   @WebMethod(operationName = "saveConfiguration")
   public void saveConfiguration() throws SaveException {
      try {
         PMS.getConfiguration().save();
      } catch (ConfigurationException e) {
         String msg = "Failed to save pms configuration";
         log.error(msg, e);
         throw new SaveException(msg, e);
      }
   }

   @Override
   @WebMethod(operationName = "setValue")
   public void setValue(@WebParam(name = "key") String key,
         @WebParam(name = "value") String value)
         throws InvalidParameterException {
      ConfigurationValue enumKey = getConfigurationValue(key);
      PmsConfiguration conf = PMS.getConfiguration();

      // TODO: add all the possible configuration values
      switch (enumKey) {
      case Language:
         conf.setLanguage(value);
         break;
      default:
         throw new InvalidParameterException(String.format(
               "Setting of key %s hasn't been implemented yet", key));
      }
   }

   @Override
   @WebMethod(operationName = "getParameters")
   public List<String> getParameters() {
      ArrayList<String> params = new ArrayList<String>();
      for (ConfigurationValue val : ConfigurationValue.values()) {
         params.add(val.name());
      }
      return params;
   }

   private ConfigurationValue getConfigurationValue(String key)
         throws InvalidParameterException {

      try {
         // try to convert string to ConfigurationValue
         return Enum.valueOf(ConfigurationValue.class, key);
      } catch (IllegalArgumentException ex) {
         // give a clear error message if conversion fails
         throw new InvalidParameterException(
               String
                     .format(
                           "Key %s doesn't exist in the list of parameters. Valid parameters are: %s",
                           key, getParametersString()));
      }
   }

   private String getParametersString() {
      String validParams = "";
      for (String param : getParameters()) {
         validParams += param + ", ";
      }
      validParams = validParams.substring(0, validParams.length() - 2);
      return validParams;
   }
}


The implementation is 100% functional, but only works to set/get Language, save configuration ang get parameters. The longer and more boring part is to expose all getters and setters for the parameters, as each one has got its own method.

You can check out the full code under http://pms-mlx.svn.sourceforge.net/svnr ... vicePlugin
Build it with the build.xml, drop it into the plugins folder of you pms, check that the plugin shows up where it should. Et voila, the service is available on port 5443.
There is also a SOAPUI test project included, in order to test the service.

I've done this as a poc and do not intend to code the entire thing, except someone really wants to use it :)
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: revision 444 GUI issue

Postby taconaut » Fri Feb 18, 2011 1:11 pm

As I wont maintain original pms code in pms-mlx, here the print screens to illustrate what the above patch changes in the network tab, before the code gets merged again.
The tree view on the left gets resized (and allows the buttons to be used with any size) and the scroll bars for the right side are only shown when needed (this is purly for cosmetics).
If you want to see it in action, you can download the latest pms-mlx version.
Attachments
nettab2.png
nettab2.png (137.58 KiB) Viewed 3492 times
nettab1.png
nettab1.png (108.24 KiB) Viewed 3492 times
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Previous

Return to Beta Builds

Who is online

Users browsing this forum: No registered users and 9 guests