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)
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);
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.
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.
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 hereI 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.
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();
}
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://www.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;
}
}
Users browsing this forum: No registered users and 1 guest