Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New prefs panel: Quick Config, to help newbies set their configuratio…
…n to match the prefs of your gallery. This is me pursuing my own agenda :-)
  • Loading branch information
Pierre-Luc Paour committed Jun 26, 2003
1 parent 7146508 commit 065ef0f
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,6 +1,9 @@
2003-06-26 Pierre-Luc Paour <gallery@paour.com> (1.1-b9)

* Implemented extra fields in UI and protocol.
* New prefs panel: Quick Config, to help newbies set their
configuration to match the prefs of your gallery. This is me
pursuing my own agenda :-)

2003-06-25 Pierre-Luc Paour <gallery@paour.com> (1.1-b8)

Expand Down
117 changes: 117 additions & 0 deletions com/gallery/GalleryRemote/prefs/QuickConfigPanel.java
@@ -0,0 +1,117 @@
package com.gallery.GalleryRemote.prefs;

import com.gallery.GalleryRemote.Log;
import com.gallery.GalleryRemote.GalleryRemote;
import com.gallery.GalleryRemote.model.Gallery;

import javax.swing.*;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.util.Properties;
import java.util.Enumeration;
import java.util.Iterator;
import java.io.InputStream;
import java.net.URL;

/**
* Created by IntelliJ IDEA.
* User: paour
* Date: May 8, 2003
*/
public class QuickConfigPanel extends PreferencePanel implements ActionListener {
public static final String MODULE = "QuickCPa";

GalleryProperties newProps = null;

JLabel icon = new JLabel("Quick Config");
GridBagLayout gridBagLayout1 = new GridBagLayout();
JLabel jLabel1 = new JLabel();
JTextField jURL = new JTextField();
JButton jSetup = new JButton();
JLabel jLabel2 = new JLabel();

public JLabel getIcon() {
return icon;
}

public boolean isReversible() {
return false;
}

public void readProperties(GalleryProperties props) {
}

public void writeProperties(GalleryProperties props) {
}

public void buildUI() {
jbInit();
}

private void jbInit() {
jLabel1.setText("URL");
this.setLayout(gridBagLayout1);

jSetup.setText("Setup");
jLabel2.setText("<html>" +
"This panel allows you to connect to a web server and fetch configuration options from it, for easy setup." +
"Enter the URL of the setup file (your administrator needs to give it to you) and click <i>Setup</i>.<br>" +
"<b>Caution</b>: this operation is not cancellable.<br>" +
"<br>" +
"Gallery administrators: to enable your users to use this functionality you merely need to put somewhere " +
"on your web site a properties file that contains the settings you want to override and distribute that " +
"URL to your users." +
"</html>");
jLabel2.setVerticalAlignment(SwingConstants.TOP);
jLabel2.setPreferredSize(new Dimension(200, 100));
this.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 2, 0, 2), 0, 0));
this.add(jURL, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(jSetup, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
this.add(jLabel2, new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0));

jSetup.addActionListener(this);
}

public void actionPerformed(ActionEvent e) {
try {
InputStream content = (InputStream) new URL(jURL.getText()).getContent();
GalleryProperties newProps = new GalleryProperties();
newProps.load(content);

StringBuffer overridden = new StringBuffer("<ul>");
if (newProps != null) {
GalleryProperties props = GalleryRemote.getInstance().properties;

Iterator it = newProps.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
String value = newProps.getProperty(key);

props.setProperty(key, value);

overridden.append("<li>").append(key).append("</li>");
}

overridden.append("</ul>");

JOptionPane.showMessageDialog(this, "<html>Loaded configuration file.<br>Overridden properties:" + overridden.toString() + "</html>", "Done", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(this, "Empty configuration file.", "Error", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "Could not find configuration file.", "Error", JOptionPane.ERROR_MESSAGE);
Log.log(Log.CRITICAL, MODULE, "Fetching configuration failed");
Log.logException( Log.ERROR, MODULE, ex );
}
}

public void resetUIState() {
}
}
3 changes: 2 additions & 1 deletion com/gallery/GalleryRemote/prefs/panes.properties
@@ -1,4 +1,5 @@
pane.1=com.gallery.GalleryRemote.prefs.GeneralPanel
pane.2=com.gallery.GalleryRemote.prefs.UploadPanel
pane.3=com.gallery.GalleryRemote.prefs.URLPanel
pane.4=com.gallery.GalleryRemote.prefs.ProxyPanel
pane.4=com.gallery.GalleryRemote.prefs.ProxyPanel
pane.5=com.gallery.GalleryRemote.prefs.QuickConfigPanel

0 comments on commit 065ef0f

Please sign in to comment.