Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
3 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |