Update of /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote In directory sc8-pr-cvs1:/tmp/cvs-serv4501/com/gallery/GalleryRemote Modified Files: AboutBox.java AddFileDialog.java AlbumInspector.java AuthorizePopup.java Base64.java DroppableList.java DroppableTree.java GR2Exception.java GalleryAbstractListModel.java GalleryComm.java GalleryComm1.java GalleryComm2.java GalleryComm2Consts.java GalleryCommCapabilities.java GalleryFileFilter.java GalleryRemote.java Log.java MainFrame.java NewAlbumDialog.java PictureInspector.java PictureSelection.java PreviewFrame.java SlideshowFrame.java StatusBar.java StatusUpdate.java StatusUpdateAdapter.java ThumbnailCache.java Update.java UploadProgress.java Log Message: 2003-12-27 Pierre-Luc Paour <ga...@pa...> (1.3-b11) * Merged changes from 1.2.1, mostly MacOS changes. Index: AboutBox.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/AboutBox.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- AboutBox.java 19 Nov 2003 05:54:57 -0000 1.14 +++ AboutBox.java 27 Dec 2003 07:52:26 -0000 1.15 @@ -23,251 +23,231 @@ import com.gallery.GalleryRemote.util.DialogUtil; import com.gallery.GalleryRemote.util.GRI18n; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Frame; -import java.awt.Graphics; +import javax.swing.*; +import javax.swing.border.MatteBorder; +import java.awt.*; import java.awt.event.MouseEvent; import java.net.URL; -import java.util.StringTokenizer; import java.util.ArrayList; - -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.UIManager; -import javax.swing.border.MatteBorder; +import java.util.StringTokenizer; /** - * Gallery Remote About Box - * - *@author paour - *@created August 18, 2002 + * Gallery Remote About Box + * + * @author paour + * @created August 18, 2002 */ public class AboutBox extends JDialog { public static final String MODULE = "About"; - public static int TOP = 5; - public static int BOTTOM = 105; + public static int TOP = 5; + public static int BOTTOM = 105; + + + /** + * Constructor for the AboutBox object + */ + public AboutBox() { + super(); + init(); + } + + + /** + * Constructor for the AboutBox object + * + * @param owner Description of Parameter + */ + public AboutBox(Frame owner) { + super(owner); + init(); + } + + + private void init() { + setModal(true); + getContentPane().add(new AboutPanel(), BorderLayout.CENTER); + setTitle(GRI18n.getString(MODULE, "title")); + pack(); + DialogUtil.center(this); - /** - * Constructor for the AboutBox object - */ - public AboutBox() { - super(); - init(); - } - - - /** - * Constructor for the AboutBox object - * - *@param owner Description of Parameter - */ - public AboutBox( Frame owner ) { - super( owner ); - init(); - } - - - private void init() { - setModal( true ); - getContentPane().add( new AboutPanel(), BorderLayout.CENTER ); - setTitle( GRI18n.getString(MODULE, "title") ); - - pack(); - - DialogUtil.center(this); - - addMouseListener( - new java.awt.event.MouseAdapter() { - public void mouseClicked( MouseEvent e ) { - thisWindowClosing(); - } - } ); - addWindowListener( - new java.awt.event.WindowAdapter() { - public void windowClosing( MouseEvent e ) { - thisWindowClosing(); - } - } ); - } - - // Close the window when the box is clicked - void thisWindowClosing() { - setVisible( false ); - dispose(); - } - - - /** - * AboutPanel: scrolling panel of credits for About boxes - * - *@author paour - *@created August 16, 2002 - */ - public class AboutPanel extends JComponent { - ImageIcon image; - ArrayList text; - int scrollPosition; - AnimationThread thread; - int maxWidth; - FontMetrics fm; - int initialPosition; - - /** - * Constructor for the AboutPanel object - */ - public AboutPanel() { - setFont( UIManager.getFont( "Label.font" ) ); - fm = getFontMetrics( getFont() ); - - URL imu = getClass().getResource( "/rar_about_gr1.png" ); + addMouseListener( + new java.awt.event.MouseAdapter() { + public void mouseClicked(MouseEvent e) { + thisWindowClosing(); + } + }); + addWindowListener( + new java.awt.event.WindowAdapter() { + public void windowClosing(MouseEvent e) { + thisWindowClosing(); + } + }); + } + + // Close the window when the box is clicked + void thisWindowClosing() { + setVisible(false); + dispose(); + } + + + /** + * AboutPanel: scrolling panel of credits for About boxes + * + * @author paour + * @created August 16, 2002 + */ + public class AboutPanel extends JComponent { + ImageIcon image; + ArrayList text; + int scrollPosition; + AnimationThread thread; + int maxWidth; + FontMetrics fm; + int initialPosition; + + /** + * Constructor for the AboutPanel object + */ + public AboutPanel() { + setFont(UIManager.getFont("Label.font")); + fm = getFontMetrics(getFont()); + + URL imu = getClass().getResource("/rar_about_gr1.png"); Log.log(Log.LEVEL_TRACE, MODULE, "Looking for splash screen in " + imu.toString()); - image = new ImageIcon( imu ); - - setBorder( new MatteBorder( 1, 1, 1, 1, Color.gray ) ); - - text = new ArrayList( ); - StringTokenizer st = new StringTokenizer( - GalleryRemote.getInstance().properties.getProperty( "aboutText" ), "\n" ); - while ( st.hasMoreTokens() ) { - String line = st.nextToken(); - text.add( line ); - maxWidth = Math.max( maxWidth, - fm.stringWidth( line ) + 10 ); - } - initialPosition = getHeight() - BOTTOM /*- BOTTOM*/ - TOP - TOP; - scrollPosition = initialPosition; - - thread = new AnimationThread(); - } - - /** - * Gets the preferredSize attribute of the AboutPanel object - * - *@return The preferredSize value - *@since - */ - public Dimension getPreferredSize() { - return new Dimension( 1 + image.getIconWidth(), - 1 + image.getIconHeight() ); - } - - /** - * Description of the Method - * - *@param g Description of Parameter - *@since - */ - public void paintComponent( Graphics g ) { - //g.setColor(new Color(96, 96, 96)); - image.paintIcon( this, g, 1, 1 ); - - FontMetrics fm = g.getFontMetrics(); - - String version = GalleryRemote.getInstance().properties.getProperty( "version" ); - g.drawString( version, ( getWidth() - fm.stringWidth( version ) ) / 2, - getHeight() - 5 ); - - g = g.create( ( getWidth() - maxWidth ) / 2, TOP, maxWidth, - getHeight() - TOP - BOTTOM ); - - int height = fm.getHeight(); - int firstLine = scrollPosition / height; - - int firstLineOffset = height - scrollPosition % height; - int lines = ( getHeight() - TOP - BOTTOM ) / height; - - int y = firstLineOffset; - g.setColor(new Color(255, 255, 255)); - for ( int i = 0; i <= lines; i++ ) { - if ( i + firstLine >= 0 && i + firstLine < text.size() ) { - String line = (String) text.get( i + firstLine ); - g.drawString( line, ( maxWidth - fm.stringWidth( line ) ) / 2, y ); - } - y += fm.getHeight(); - } - } - - /** - * Adds a feature to the Notify attribute of the AboutPanel object - * - *@since - */ - public void addNotify() { - super.addNotify(); - thread.start(); - } - - /** - * Description of the Method - * - *@since - */ - public void removeNotify() { - super.removeNotify(); - thread.kill(); - } - - /** - * Animation thread - * - *@author paour - *@created August 16, 2002 - */ - class AnimationThread extends Thread { - private boolean running = true; - - - AnimationThread() { - super( GRI18n.getString(MODULE, "aboutAnim") ); - setPriority( Thread.MIN_PRIORITY ); - } - - - /** - * Description of the Method - * - *@since - */ - public void kill() { - running = false; - } - - - /** - * Main processing method for the AnimationThread object - * - *@since - */ - public void run() { - FontMetrics fm = getFontMetrics( getFont() ); - int max = ( text.size() * fm.getHeight() ); - - while ( running ) { - long start = System.currentTimeMillis(); - - scrollPosition += 2; - - if ( scrollPosition > max ) { - scrollPosition = initialPosition; - } - - try { - Thread.sleep( 100 ); - } catch ( Exception e ) { - } - - repaint( getWidth() / 2 - maxWidth, - TOP, maxWidth * 2, - getHeight() - TOP - BOTTOM ); - } - } - } - } + image = new ImageIcon(imu); + + setBorder(new MatteBorder(1, 1, 1, 1, Color.gray)); + + text = new ArrayList(); + StringTokenizer st = new StringTokenizer( + GalleryRemote.getInstance().properties.getProperty("aboutText"), "\n"); + while (st.hasMoreTokens()) { + String line = st.nextToken(); + text.add(line); + maxWidth = Math.max(maxWidth, + fm.stringWidth(line) + 10); + } + initialPosition = getHeight() - BOTTOM /*- BOTTOM*/ - TOP - TOP; + scrollPosition = initialPosition; + + thread = new AnimationThread(); + } + + /** + * Gets the preferredSize attribute of the AboutPanel object + * + * @return The preferredSize value + */ + public Dimension getPreferredSize() { + return new Dimension(1 + image.getIconWidth(), + 1 + image.getIconHeight()); + } + + /** + * Description of the Method + * + * @param g Description of Parameter + */ + public void paintComponent(Graphics g) { + //g.setColor(new Color(96, 96, 96)); + image.paintIcon(this, g, 1, 1); + + FontMetrics fm = g.getFontMetrics(); + + String version = GalleryRemote.getInstance().properties.getProperty("version"); + g.drawString(version, (getWidth() - fm.stringWidth(version)) / 2, + getHeight() - 5); + + g = g.create((getWidth() - maxWidth) / 2, TOP, maxWidth, + getHeight() - TOP - BOTTOM); + + int height = fm.getHeight(); + int firstLine = scrollPosition / height; + + int firstLineOffset = height - scrollPosition % height; + int lines = (getHeight() - TOP - BOTTOM) / height; + + int y = firstLineOffset; + g.setColor(new Color(255, 255, 255)); + for (int i = 0; i <= lines; i++) { + if (i + firstLine >= 0 && i + firstLine < text.size()) { + String line = (String) text.get(i + firstLine); + g.drawString(line, (maxWidth - fm.stringWidth(line)) / 2, y); + } + y += fm.getHeight(); + } + } + + /** + * Adds a feature to the Notify attribute of the AboutPanel object + */ + public void addNotify() { + super.addNotify(); + thread.start(); + } + + /** + * Description of the Method + */ + public void removeNotify() { + super.removeNotify(); + thread.kill(); + } + + /** + * Animation thread + * + * @author paour + * @created August 16, 2002 + */ + class AnimationThread extends Thread { + private boolean running = true; + + + AnimationThread() { + super(GRI18n.getString(MODULE, "aboutAnim")); + setPriority(Thread.MIN_PRIORITY); + } + + + /** + * Description of the Method + */ + public void kill() { + running = false; + } + + + /** + * Main processing method for the AnimationThread object + */ + public void run() { + FontMetrics fm = getFontMetrics(getFont()); + int max = (text.size() * fm.getHeight()); + + while (running) { + long start = System.currentTimeMillis(); + + scrollPosition += 2; + + if (scrollPosition > max) { + scrollPosition = initialPosition; + } + + try { + Thread.sleep(100); + } catch (Exception e) { + } + + repaint(getWidth() / 2 - maxWidth, + TOP, maxWidth * 2, + getHeight() - TOP - BOTTOM); + } + } + } + } } Index: AddFileDialog.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/AddFileDialog.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AddFileDialog.java 19 Nov 2003 05:54:57 -0000 1.6 +++ AddFileDialog.java 27 Dec 2003 07:52:26 -0000 1.7 @@ -23,38 +23,33 @@ import com.gallery.GalleryRemote.util.GRI18n; -import java.awt.Component; +import javax.swing.*; +import java.awt.*; import java.io.File; -import javax.swing.JFileChooser; +public class AddFileDialog { -public class AddFileDialog -{ - - static File[] addFiles(Component parent) - { + static File[] addFiles(Component parent) { JFileChooser fc = new JFileChooser(); - + fc.addChoosableFileFilter(new GalleryFileFilter()); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(true); - + File currentDirectory = GalleryRemote.getInstance().properties.getCurrentDirectory(); - if (currentDirectory != null) - { + if (currentDirectory != null) { fc.setCurrentDirectory(currentDirectory); } int retval = fc.showDialog(parent, GRI18n.getString("AddFileDialog", "Add")); - if (retval != JFileChooser.CANCEL_OPTION) - { + if (retval != JFileChooser.CANCEL_OPTION) { GalleryRemote.getInstance().properties.setCurrentDirectory(fc.getCurrentDirectory()); - + File[] files = fc.getSelectedFiles(); - + return files; } - + return null; } } Index: AlbumInspector.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/AlbumInspector.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AlbumInspector.java 10 Dec 2003 17:34:35 -0000 1.5 +++ AlbumInspector.java 27 Dec 2003 07:52:26 -0000 1.6 @@ -20,31 +20,22 @@ */ package com.gallery.GalleryRemote; -import java.awt.event.*; -import java.text.NumberFormat; - -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - import com.gallery.GalleryRemote.model.Album; -import com.gallery.GalleryRemote.model.Picture; -import com.gallery.GalleryRemote.util.ImageUtils; import com.gallery.GalleryRemote.util.GRI18n; -import java.awt.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.ArrayList; import javax.swing.*; -import javax.swing.text.Document; -import javax.swing.border.Border; import javax.swing.border.TitledBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.Document; +import java.awt.*; +import java.awt.event.*; /** - * Bean inspector for Pictures - * - *@author paour - *@created August 16, 2002 + * Bean inspector for Pictures + * + * @author paour + * @created August 16, 2002 */ public class AlbumInspector extends JPanel implements ActionListener, ItemListener, DocumentListener { @@ -63,7 +54,7 @@ JTextArea jTitle = new JTextArea(); JTextArea jPictures = new JTextArea(); - JTextArea jName = new JTextArea(); + JTextArea jName = new JTextArea(); JTextArea jSummary = new JTextArea(); GridBagLayout gridBagLayout1 = new GridBagLayout(); JButton jFetch = new JButton(); @@ -83,7 +74,7 @@ boolean ignoreItemChanges = false; /** - * Constructor for the PictureInspector object + * Constructor for the PictureInspector object */ public AlbumInspector() { jbInit(); @@ -92,11 +83,11 @@ private void jbInit() { - setLayout( new GridBagLayout() ); - jLabelName.setText(GRI18n.getString(MODULE, "Name") ); - jLabelTitle.setText(GRI18n.getString(MODULE, "Title") ); - jLabelPictures.setText(GRI18n.getString(MODULE, "Pictures") ); - jLabelSummary.setText(GRI18n.getString(MODULE, "Summary") ); + setLayout(new GridBagLayout()); + jLabelName.setText(GRI18n.getString(MODULE, "Name")); + jLabelTitle.setText(GRI18n.getString(MODULE, "Title")); + jLabelPictures.setText(GRI18n.getString(MODULE, "Pictures")); + jLabelSummary.setText(GRI18n.getString(MODULE, "Summary")); jName.setFont(new Font("SansSerif", 0, 11)); jName.setLineWrap(true); @@ -134,62 +125,62 @@ jResizeToForce.setText(GRI18n.getString(MODULE, "res2Frc")); jBeginning.setText(GRI18n.getString(MODULE, "Beginning")); - jPanel1.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),GRI18n.getString(MODULE, "Override"))); - jPanelProps.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140)),GRI18n.getString(MODULE, "Props"))); + jPanel1.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), GRI18n.getString(MODULE, "Override"))); + jPanelProps.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)), GRI18n.getString(MODULE, "Props"))); - jPanelProps.add( jLabelName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 2, 0) ); - jPanelProps.add(new JScrollPane(jName), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 3, 0), 0, 0)); - jPanelProps.add( jLabelTitle, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 2, 0) ); - jPanelProps.add(new JScrollPane(jTitle), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 3, 0), 0, 0)); - jPanelProps.add(jLabelSummary, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 0, 0)); - jPanelProps.add(new JScrollPane(jSummary), new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); - jPanelProps.add( jLabelPictures, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 2, 5), 2, 0) ); - jPanelProps.add(jPictures, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 3, 0), 0, 0)); - jPanelProps.add(jApply, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); - - jPanel1.add(jResizeToWidth, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - jPanel1.add(jLabel7, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); - jPanel1.add(jResizeToHeight, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - jPanel1.add(jPanel6, new GridBagConstraints(4, 1, 1, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - jPanel1.add(jResizeBeforeUpload, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); - jPanel1.add(jResizeToDefault, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 20, 0, 0), 0, 0)); - jPanel1.add(jResizeToForce, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 20, 0, 0), 0, 0)); - jPanel1.add(jBeginning, new GridBagConstraints(0, 3, 4, 1, 0.0, 0.0 - ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); - - this.add(jPanelProps, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); - this.add(jPanel1, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); - this.add(jFetch, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); - this.add(jSlideshow, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 - ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); + jPanelProps.add(jLabelName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 + , GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 2, 0)); + jPanelProps.add(new JScrollPane(jName), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 3, 0), 0, 0)); + jPanelProps.add(jLabelTitle, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 + , GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 2, 0)); + jPanelProps.add(new JScrollPane(jTitle), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 3, 0), 0, 0)); + jPanelProps.add(jLabelSummary, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 0, 0, 5), 0, 0)); + jPanelProps.add(new JScrollPane(jSummary), new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + jPanelProps.add(jLabelPictures, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 + , GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 2, 5), 2, 0)); + jPanelProps.add(jPictures, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 3, 0), 0, 0)); + jPanelProps.add(jApply, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); + + jPanel1.add(jResizeToWidth, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + jPanel1.add(jLabel7, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); + jPanel1.add(jResizeToHeight, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + jPanel1.add(jPanel6, new GridBagConstraints(4, 1, 1, 1, 1.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + jPanel1.add(jResizeBeforeUpload, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + jPanel1.add(jResizeToDefault, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 20, 0, 0), 0, 0)); + jPanel1.add(jResizeToForce, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 20, 0, 0), 0, 0)); + jPanel1.add(jBeginning, new GridBagConstraints(0, 3, 4, 1, 0.0, 0.0 + , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); + + this.add(jPanelProps, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + this.add(jPanel1, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + this.add(jFetch, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); + this.add(jSlideshow, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0 + , GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); //this.add(jNew, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0 // ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0)); - add( jSpacer, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.1 - ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0) ); + add(jSpacer, new GridBagConstraints(0, 5, 1, 1, 1.0, 0.1 + , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); buttonGroup1.add(jResizeToDefault); buttonGroup1.add(jResizeToForce); - this.setMinimumSize( new Dimension( 150, 0 ) ); + this.setMinimumSize(new Dimension(150, 0)); setupKeyboardHandling(jName); setupKeyboardHandling(jTitle); @@ -226,14 +217,14 @@ // Event handling /** - * Menu and button handling - * - *@param e Action event + * Menu and button handling + * + * @param e Action event */ - public void actionPerformed( ActionEvent e ) { + public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); JComponent source = (JComponent) e.getSource(); - Log.log(Log.LEVEL_TRACE, MODULE, "Action selected " + command ); + Log.log(Log.LEVEL_TRACE, MODULE, "Action selected " + command); if (source == jFetch) { mf.fetchAlbumImages(); @@ -259,7 +250,7 @@ } JComponent source = (JComponent) e.getSource(); - Log.log(Log.LEVEL_TRACE, MODULE, "Item state changed " + source ); + Log.log(Log.LEVEL_TRACE, MODULE, "Item state changed " + source); if (source == jBeginning) { album.setOverrideAddToBeginning(new Boolean(jBeginning.isSelected())); @@ -280,7 +271,7 @@ boolean oldIgnoreItemChanges = ignoreItemChanges; ignoreItemChanges = true; - if (album!= null && jResizeBeforeUpload.isSelected()) { + if (album != null && jResizeBeforeUpload.isSelected()) { jResizeToDefault.setEnabled(true); jResizeToForce.setEnabled(true); @@ -308,11 +299,11 @@ } /** - * Sets the mainFrame attribute of the PictureInspector object - * - *@param mf The new mainFrame value + * Sets the mainFrame attribute of the PictureInspector object + * + * @param mf The new mainFrame value */ - public void setMainFrame( MainFrame mf ) { + public void setMainFrame(MainFrame mf) { this.mf = mf; } @@ -322,7 +313,7 @@ this.album = album; - if ( album == null ) { + if (album == null) { /*setActive(jName, false); setActive(jTitle, false); setActive(jSummary, false);*/ @@ -349,7 +340,7 @@ jResizeBeforeUpload.setSelected(album.getResize()); jResizeToDefault.setSelected(album.getResizeDefault()); - jResizeToForce.setSelected(! album.getResizeDefault()); + jResizeToForce.setSelected(!album.getResizeDefault()); jResizeToWidth.setText("" + album.getResizeDimension().width); jResizeToHeight.setText("" + album.getResizeDimension().height); jBeginning.setSelected(album.getAddToBeginning()); @@ -410,14 +401,14 @@ // Focus traversal actions public Action nextFocusAction = new AbstractAction("Move Focus Forwards") { public void actionPerformed(ActionEvent evt) { - ((Component)evt.getSource()).transferFocus(); + ((Component) evt.getSource()).transferFocus(); } }; public Action prevFocusAction = new AbstractAction("Move Focus Backwards") { public void actionPerformed(ActionEvent evt) { try { - ((Component)evt.getSource()).transferFocusBackward(); + ((Component) evt.getSource()).transferFocusBackward(); } catch (NoSuchMethodError e) { Log.log(Log.LEVEL_ERROR, MODULE, "Can't transfer focus backwards on 1.3"); } @@ -437,7 +428,7 @@ }; /** - * Caption JTextArea events. + * Caption JTextArea events. */ public void insertUpdate(DocumentEvent e) { textUpdate(e); Index: AuthorizePopup.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/AuthorizePopup.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AuthorizePopup.java 19 Nov 2003 05:54:57 -0000 1.5 +++ AuthorizePopup.java 27 Dec 2003 07:52:26 -0000 1.6 @@ -4,64 +4,52 @@ */ package com.gallery.GalleryRemote; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; +import HTTPClient.NVPair; +import com.gallery.GalleryRemote.util.GRI18n; + +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JTextField; - -import HTTPClient.NVPair; -import com.gallery.GalleryRemote.util.GRI18n; - /** - * Do the authorization popup in a swing-compatible way. Built from the code in - * HTTPClient.DefaultAuthHandler - * - *@author Stanley Knutson - *@created Januray 3, 2003 + * Do the authorization popup in a swing-compatible way. Built from the code in + * HTTPClient.DefaultAuthHandler + * + * @author Stanley Knutson + * @created Januray 3, 2003 */ -public class AuthorizePopup implements HTTPClient.AuthorizationPrompter -{ +public class AuthorizePopup implements HTTPClient.AuthorizationPrompter { private static BasicAuthBox inp = null; - public static final String MODULE = "AuthorizePopup"; - - + public static final String MODULE = "AuthorizePopup"; /** - * Engage this class to be the authorization popup + * Engage this class to be the authorization popup */ public static void enable() { HTTPClient.DefaultAuthHandler.setAuthorizationPrompter - ( new AuthorizePopup() ); + (new AuthorizePopup()); } /** - * the method called by DefaultAuthHandler. - * - *@param challenge Description of Parameter - *@param forProxy Description of Parameter - *@return the username/password pair + * the method called by DefaultAuthHandler. + * + * @param challenge Description of Parameter + * @param forProxy Description of Parameter + * @return the username/password pair */ - public NVPair getUsernamePassword( HTTPClient.AuthorizationInfo challenge, - boolean forProxy ) { + public NVPair getUsernamePassword(HTTPClient.AuthorizationInfo challenge, + boolean forProxy) { String line1; String line2; String line3; - if ( challenge.getScheme().equalsIgnoreCase( "SOCKS5" ) ) { + if (challenge.getScheme().equalsIgnoreCase("SOCKS5")) { line1 = GRI18n.getString(MODULE, "enterUsrPwd"); line2 = challenge.getHost(); line3 = GRI18n.getString(MODULE, "authMthd"); @@ -73,28 +61,27 @@ line3 = GRI18n.getString(MODULE, "authScheme") + challenge.getScheme(); } - synchronized ( getClass() ) { - if ( inp == null ) { + synchronized (getClass()) { + if (inp == null) { MainFrame fr = GalleryRemote.getInstance().mainFrame; - inp = new BasicAuthBox( fr ); + inp = new BasicAuthBox(fr); } } - return inp.getInput( line1, line2, line3, challenge.getScheme() ); + return inp.getInput(line1, line2, line3, challenge.getScheme()); } /** - * This class implements a simple popup that request username and password - * used for the "basic" and "digest" authentication schemes. - * - *@author Ronald Tschalar - *@created February 2, 2003 - *@version 0.3-3 06/05/2001 + * This class implements a simple popup that request username and password + * used for the "basic" and "digest" authentication schemes. + * + * @author Ronald Tschalar + * @version 0.3-3 06/05/2001 + * @created February 2, 2003 */ - private static class BasicAuthBox extends javax.swing.JDialog - { + private static class BasicAuthBox extends javax.swing.JDialog { private final static String title = GRI18n.getString(MODULE, "authReq"); private Dimension screen; private JLabel line1, line2, line3; @@ -105,121 +92,121 @@ /** - * Constructs the popup with two lines of text above the input fields - * - *@param container Description of Parameter + * Constructs the popup with two lines of text above the input fields + * + * @param container Description of Parameter */ - BasicAuthBox( MainFrame container ) { + BasicAuthBox(MainFrame container) { - super( container, title, true ); + super(container, title, true); theFrame = container; screen = getToolkit().getScreenSize(); addNotify(); - addWindowListener( new Close() ); - getContentPane().setLayout( new BorderLayout() ); + addWindowListener(new Close()); + getContentPane().setLayout(new BorderLayout()); - JPanel p = new JPanel( new GridLayout( 3, 1 ) ); - p.add( line1 = new JLabel() ); - p.add( line2 = new JLabel() ); - p.add( line3 = new JLabel() ); - getContentPane().add( "North", p ); - - p = new JPanel( new GridLayout( 2, 1 ) ); - p.add( new JLabel( GRI18n.getString(MODULE, "username") ) ); - p.add( new JLabel( GRI18n.getString(MODULE, "passwd") ) ); - getContentPane().add( "West", p ); - p = new JPanel( new GridLayout( 2, 1 ) ); - p.add( user = new JTextField( 30 ) ); - p.add( pass = new JPasswordField( 30 ) ); - pass.addActionListener( new Ok() ); - getContentPane().add( "East", p ); + JPanel p = new JPanel(new GridLayout(3, 1)); + p.add(line1 = new JLabel()); + p.add(line2 = new JLabel()); + p.add(line3 = new JLabel()); + getContentPane().add("North", p); + + p = new JPanel(new GridLayout(2, 1)); + p.add(new JLabel(GRI18n.getString(MODULE, "username"))); + p.add(new JLabel(GRI18n.getString(MODULE, "passwd"))); + getContentPane().add("West", p); + p = new JPanel(new GridLayout(2, 1)); + p.add(user = new JTextField(30)); + p.add(pass = new JPasswordField(30)); + pass.addActionListener(new Ok()); + getContentPane().add("East", p); GridBagLayout gb = new GridBagLayout(); - p = new JPanel( gb ); + p = new JPanel(gb); GridBagConstraints constr = new GridBagConstraints(); JPanel pp = new JPanel(); - p.add( pp ); + p.add(pp); constr.gridwidth = GridBagConstraints.REMAINDER; - gb.setConstraints( pp, constr ); + gb.setConstraints(pp, constr); constr.gridwidth = 1; constr.weightx = 1.0; JButton b; - p.add( b = new JButton( GRI18n.getString(MODULE, "ok") ) ); - b.addActionListener( new Ok() ); + p.add(b = new JButton(GRI18n.getString(MODULE, "ok"))); + b.addActionListener(new Ok()); constr.weightx = 1.0; - gb.setConstraints( b, constr ); - p.add( b = new JButton( GRI18n.getString(MODULE, "clear") ) ); - b.addActionListener( new Clear() ); + gb.setConstraints(b, constr); + p.add(b = new JButton(GRI18n.getString(MODULE, "clear"))); + b.addActionListener(new Clear()); constr.weightx = 2.0; - gb.setConstraints( b, constr ); - p.add( b = new JButton( GRI18n.getString(MODULE, "cancel") ) ); - b.addActionListener( new Cancel() ); + gb.setConstraints(b, constr); + p.add(b = new JButton(GRI18n.getString(MODULE, "cancel"))); + b.addActionListener(new Cancel()); constr.weightx = 1.0; - gb.setConstraints( b, constr ); - getContentPane().add( "South", p ); + gb.setConstraints(b, constr); + getContentPane().add("South", p); pack(); } /** - * the method called by SimpleAuthPopup. - * - *@param l1 Description of Parameter - *@param l2 Description of Parameter - *@param l3 Description of Parameter - *@param scheme Description of Parameter - *@return the username/password pair + * the method called by SimpleAuthPopup. + * + * @param l1 Description of Parameter + * @param l2 Description of Parameter + * @param l3 Description of Parameter + * @param scheme Description of Parameter + * @return the username/password pair */ - NVPair getInput( String l1, String l2, String l3, - String scheme ) { - line1.setText( l1 ); - line2.setText( l2 ); - line3.setText( l3 ); + NVPair getInput(String l1, String l2, String l3, + String scheme) { + line1.setText(l1); + line2.setText(l2); + line3.setText(l3); line1.invalidate(); line2.invalidate(); line3.invalidate(); - setResizable( true ); + setResizable(true); pack(); - setResizable( false ); + setResizable(false); // put popup at upper right of the parent frame (assuming we have one) - if ( theFrame != null ) { + if (theFrame != null) { int popX = theFrame.getX() + 20; Dimension sz = getPreferredSize(); - if ( popX + sz.width > screen.width ) { + if (popX + sz.width > screen.width) { popX = screen.width - sz.width; } - if ( popX < 0 ) { + if (popX < 0) { popX = 0; } int popY = theFrame.getY() + 65; - if ( popY + sz.height + 30 > screen.height ) { + if (popY + sz.height + 30 > screen.height) { popY = screen.height - sz.height - 30; } - if ( popY < 0 ) { + if (popY < 0) { popY = 0; } - setLocation( popX, popY ); + setLocation(popX, popY); } else { - setLocation( ( screen.width - getPreferredSize().width ) / 2, - (int) ( ( screen.height - getPreferredSize().height ) / 2 * .7 ) ); + setLocation((screen.width - getPreferredSize().width) / 2, + (int) ((screen.height - getPreferredSize().height) / 2 * .7)); } boolean user_focus = true; - if ( scheme.equalsIgnoreCase( "NTLM" ) ) { + if (scheme.equalsIgnoreCase("NTLM")) { // prefill the user field with the username try { - user.setText( System.getProperty( "user.name", "" ) ); + user.setText(System.getProperty("user.name", "")); user_focus = false; - } catch ( SecurityException se ) { + } catch (SecurityException se) { } } // This call to request focus probably does not do anything, but leave it in. - if ( user_focus ) { + if (user_focus) { user.requestFocus(); } else { pass.requestFocus(); @@ -229,11 +216,11 @@ // until "hide" is called by close, cancel or ok action show(); - NVPair result = new NVPair( user.getText(), pass.getText() ); - user.setText( "" ); - pass.setText( "" ); + NVPair result = new NVPair(user.getText(), pass.getText()); + user.setText(""); + pass.setText(""); - if ( done == CANCEL ) { + if (done == CANCEL) { return null; } else { return result; @@ -242,19 +229,18 @@ /** - * our event handlers - * - *@author paour - *@created February 2, 2003 + * our event handlers + * + * @author paour + * @created February 2, 2003 */ - private class Ok implements ActionListener - { + private class Ok implements ActionListener { /** - * Description of the Method - * - *@param ae Description of Parameter + * Description of the Method + * + * @param ae Description of Parameter */ - public void actionPerformed( ActionEvent ae ) { + public void actionPerformed(ActionEvent ae) { done = OK; hide(); // synchronized (BasicAuthBox.this) @@ -264,40 +250,38 @@ /** - * Description of the Class - * - *@author paour - *@created February 2, 2003 + * Description of the Class + * + * @author paour + * @created February 2, 2003 */ - private class Clear implements ActionListener - { + private class Clear implements ActionListener { /** - * Description of the Method - * - *@param ae Description of Parameter + * Description of the Method + * + * @param ae Description of Parameter */ - public void actionPerformed( ActionEvent ae ) { - user.setText( "" ); - pass.setText( "" ); + public void actionPerformed(ActionEvent ae) { + user.setText(""); + pass.setText(""); user.requestFocus(); } } /** - * Description of the Class - * - *@author paour - *@created February 2, 2003 + * Description of the Class + * + * @author paour + * @created February 2, 2003 */ - private class Cancel implements ActionListener - { + private class Cancel implements ActionListener { /** - * Description of the Method - * - *@param ae Description of Parameter + * Description of the Method + * + * @param ae Description of Parameter */ - public void actionPerformed( ActionEvent ae ) { + public void actionPerformed(ActionEvent ae) { done = CANCEL; hide(); //synchronized (BasicAuthBox.this) @@ -307,20 +291,19 @@ /** - * Description of the Class - * - *@author paour - *@created February 2, 2003 + * Description of the Class + * + * @author paour + * @created February 2, 2003 */ - private class Close extends WindowAdapter - { + private class Close extends WindowAdapter { /** - * Description of the Method - * - *@param we Description of Parameter + * Description of the Method + * + * @param we Description of Parameter */ - public void windowClosing( WindowEvent we ) { - new Cancel().actionPerformed( null ); + public void windowClosing(WindowEvent we) { + new Cancel().actionPerformed(null); } } } Index: Base64.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/Base64.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Base64.java 17 Aug 2002 00:30:37 -0000 1.1 +++ Base64.java 27 Dec 2003 07:52:27 -0000 1.2 @@ -1,123 +1,120 @@ /** -* Provides encoding of raw bytes to base64-encoded characters, and -* decoding of base64 characters to raw bytes. -* -* @author Kevin Kelley (ke...@ig...) -* @version 1.0 -* @date 06 August 1998 -*/ + * Provides encoding of raw bytes to base64-encoded characters, and + * decoding of base64 characters to raw bytes. + * + * @author Kevin Kelley (ke...@ig...) + * @version 1.0 + * @date 06 August 1998 + */ package com.gallery.GalleryRemote; -public class Base64 -{ - public static String encode(String data) - { +public class Base64 { + public static String encode(String data) { return new String(encode(data.getBytes())); } - public static String decode(String data) - { + public static String decode(String data) { char[] dataArr = new char[data.length()]; data.getChars(0, data.length(), dataArr, 0); return new String(decode(dataArr)); } /** - * returns an array of base64-encoded characters to represent the - * passed data array. - * - * @param data the array of bytes to encode - * @return base64-coded character array. - */ - - static public char[] encode(byte[] data) - { - char[] out = new char[((data.length + 2) / 3) * 4]; - - // - // 3 bytes encode to 4 chars. Output is always an even - // multiple of 4 characters. - // - for (int i=0, index=0; i<data.length; i+=3, index+=4) { - boolean quad = false; - boolean trip = false; - - int val = (0xFF & (int) data[i]); - val <<= 8; - if ((i+1) < data.length) { - val |= (0xFF & (int) data[i+1]); - trip = true; - } - val <<= 8; - if ((i+2) < data.length) { - val |= (0xFF & (int) data[i+2]); - quad = true; - } - out[index+3] = alphabet[(quad? (val & 0x3F): 64)]; - val >>= 6; - out[index+2] = alphabet[(trip? (val & 0x3F): 64)]; - val >>= 6; - out[index+1] = alphabet[val & 0x3F]; - val >>= 6; - out[index+0] = alphabet[val & 0x3F]; - } - return out; + * returns an array of base64-encoded characters to represent the + * passed data array. + * + * @param data the array of bytes to encode + * @return base64-coded character array. + */ + + static public char[] encode(byte[] data) { + char[] out = new char[((data.length + 2) / 3) * 4]; + + // + // 3 bytes encode to 4 chars. Output is always an even + // multiple of 4 characters. + // + for (int i = 0, index = 0; i < data.length; i += 3, index += 4) { + boolean quad = false; + boolean trip = false; + + int val = (0xFF & (int) data[i]); + val <<= 8; + if ((i + 1) < data.length) { + val |= (0xFF & (int) data[i + 1]); + trip = true; + } + val <<= 8; + if ((i + 2) < data.length) { + val |= (0xFF & (int) data[i + 2]); + quad = true; + } + out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)]; + val >>= 6; + out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)]; + val >>= 6; + out[index + 1] = alphabet[val & 0x3F]; + val >>= 6; + out[index + 0] = alphabet[val & 0x3F]; + } + return out; } /** - * Returns an array of bytes which were encoded in the passed - * character array. - * - * @param data the array of base64-encoded characters - * @return decoded data array - */ - static public byte[] decode(char[] data) - { - int len = ((data.length + 3) / 4) * 3; - if (data.length>0 && data[data.length-1] == '=') --len; - if (data.length>1 && data[data.length-2] == '=') --len; - byte[] out = new byte[len]; - - int shift = 0; // # of excess bits stored in accum - int accum = 0; // excess bits - int index = 0; - - for (int ix=0; ix<data.length; ix++) - { - int value = codes[ data[ix] & 0xFF ]; // ignore high byte of char - if ( value >= 0 ) { // skip over non-code - accum <<= 6; // bits shift up by 6 each time thru - shift += 6; // loop, with new bits being put in - accum |= value; // at the bottom. - if ( shift >= 8 ) { // whenever there are 8 or more shifted in, - shift -= 8; // write them out (from the top, leaving any - out[index++] = // excess at the bottom for next iteration. - (byte) ((accum >> shift) & 0xff); - } } } - if (index != out.length) - throw new Error("miscalculated data length!"); + * Returns an array of bytes which were encoded in the passed + * character array. + * + * @param data the array of base64-encoded characters + * @return decoded data array + */ + static public byte[] decode(char[] data) { + int len = ((data.length + 3) / 4) * 3; + if (data.length > 0 && data[data.length - 1] == '=') --len; + if (data.length > 1 && data[data.length - 2] == '=') --len; + byte[] out = new byte[len]; + + int shift = 0; // # of excess bits stored in accum + int accum = 0; // excess bits + int index = 0; + + for (int ix = 0; ix < data.length; ix++) { + int value = codes[data[ix] & 0xFF]; // ignore high byte of char + if (value >= 0) { // skip over non-code + accum <<= 6; // bits shift up by 6 each time thru + shift += 6; // loop, with new bits being put in + accum |= value; // at the bottom. + if (shift >= 8) { // whenever there are 8 or more shifted in, + shift -= 8; // write them out (from the top, leaving any + out[index++] = // excess at the bottom for next iteration. + (byte) ((accum >> shift) & 0xff); + } + } + } + if (index != out.length) + throw new Error("miscalculated data length!"); - return out; + return out; } // // code characters for values 0..63 // static private char[] alphabet = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" - .toCharArray(); + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + .toCharArray(); // // lookup table for converting base64 characters to value in range 0..63 // static private byte[] codes = new byte[256]; + static { - for (int i=0; i<256; i++) codes[i] = -1; - for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)( i - 'A'); - for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a'); - for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0'); - codes['+'] = 62; - codes['/'] = 63; + for (int i = 0; i < 256; i++) codes[i] = -1; + for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte) (i - 'A'); + for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte) (26 + i - 'a'); + for (int i = '0'; i <= '9'; i++) codes[i] = (byte) (52 + i - '0'); + codes['+'] = 62; + codes['/'] = 63; } } Index: DroppableList.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/DroppableList.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- DroppableList.java 19 Nov 2003 05:54:57 -0000 1.21 +++ DroppableList.java 27 Dec 2003 07:52:27 -0000 1.22 @@ -20,42 +20,26 @@ */ package com.gallery.GalleryRemote; +import com.gallery.GalleryRemote.model.Picture; +import com.gallery.GalleryRemote.util.GRI18n; +import com.gallery.GalleryRemote.util.ImageUtils; + +import javax.swing.*; import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceDragEvent; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceEvent; -import java.awt.dnd.DragSourceListener; -import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; +import java.awt.dnd.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; -import javax.swing.JList; -import javax.swing.JOptionPane; - -import com.gallery.GalleryRemote.model.Picture; -import com.gallery.GalleryRemote.util.GRI18n; -import com.gallery.GalleryRemote.util.ImageUtils; - /** - * Drag and drop handler - * - *@author paour - *@created August 16, 2002 + * Drag and drop handler + * + * @author paour + * @created August 16, 2002 */ public class DroppableList extends JList implements DropTargetListener, DragSourceListener, DragGestureListener { @@ -70,13 +54,13 @@ public DroppableList() { dragSource = new DragSource(); - dragSource.createDefaultDragGestureRecognizer( this, DnDConstants.ACTION_MOVE, this ); - dropTarget = new DropTarget( this, this ); + dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); + dropTarget = new DropTarget(this, this); } - public void paint( Graphics g ) { + public void paint(Graphics g) { lastY = -1; - super.paint( g ); + super.paint(g); } public boolean isDragOK(DropTargetEvent dropTargetEvent) { @@ -94,34 +78,44 @@ } /* ********* TargetListener ********** */ - public void dragEnter( DropTargetDragEvent dropTargetDragEvent ) { - Log.log( Log.LEVEL_TRACE, MODULE, "dragEnter - dtde" ); - if (! isDragOK(dropTargetDragEvent)) { - dropTargetDragEvent.rejectDrag( ); + public void dragEnter(DropTargetDragEvent dropTargetDragEvent) { + Log.log(Log.LEVEL_TRACE, MODULE, "dragEnter - dtde"); + for (Iterator it = dropTargetDragEvent.getCurrentDataFlavorsAsList().iterator(); it.hasNext();) { + DataFlavor flavor = (DataFlavor) it.next(); + Log.log(Log.LEVEL_TRACE, MODULE, "Flavor: " + flavor.getHumanPresentableName() + " -- " + + flavor.getMimeType()); + } + Log.log(Log.LEVEL_TRACE, MODULE, "Action: " + dropTargetDragEvent.getSourceActions() + " -- " + + dropTargetDragEvent.getDropAction()); + + if (!isDragOK(dropTargetDragEvent)) { + Log.log(Log.LEVEL_TRACE, MODULE, "Refusing drag"); + dropTargetDragEvent.rejectDrag(); return; } - dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE ); + Log.log(Log.LEVEL_TRACE, MODULE, "Accepting drag"); + //dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE ); } - public void dragExit( DropTargetEvent dropTargetEvent ) { - Log.log( Log.LEVEL_TRACE, MODULE, "dragExit - dtde" ); + public void dragExit(DropTargetEvent dropTargetEvent) { + Log.log(Log.LEVEL_TRACE, MODULE, "dragExit - dtde"); repaint(); } - public void dragOver( DropTargetDragEvent dropTargetDragEvent ) { + public void dragOver(DropTargetDragEvent dropTargetDragEvent) { //Log.log(Log.TRACE, MODULE,"dragOver - dtde"); - if ( ! isDragOK(dropTargetDragEvent) ) { - dropTargetDragEvent.rejectDrag( ); + if (!isDragOK(dropTargetDragEvent)) { + dropTargetDragEvent.rejectDrag(); return; } - dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE ); - dragOver( (int) dropTargetDragEvent.getLocation().getY() ); + //dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE ); + dragOver((int) dropTargetDragEvent.getLocation().getY()); } - public void dragOver( int y ) { + public void dragOver(int y) { int i = locationToIndex(new Point(1, y)); Rectangle r = getVisibleRect(); boolean scrolled = false; @@ -140,103 +134,107 @@ } Graphics g = getGraphics(); - g.setXORMode( Color.cyan ); + g.setXORMode(Color.cyan); int xStart = 10; - int xStop = ( (int) this.getVisibleRect().getWidth() ) - xStart; - if ( lastY != -1 ) { - int ySnap = snap( lastY ); - g.drawLine( xStart, ySnap, xStop, ySnap ); - g.drawLine( xStart, ySnap + 1, xStop, ySnap + 1 ); + int xStop = ((int) this.getVisibleRect().getWidth()) - xStart; + if (lastY != -1) { + int ySnap = snap(lastY); + g.drawLine(xStart, ySnap, xStop, ySnap); + g.drawLine(xStart, ySnap + 1, xStop, ySnap + 1); } lastY = y; - int ySnap = snap( lastY ); - g.drawLine( xStart, ySnap, xStop, ySnap ); - g.drawLine( xStart, ySnap + 1, xStop, ySnap + 1 ); + int ySnap = snap(lastY); + g.drawLine(xStart, ySnap, xStop, ySnap); + g.drawLine(xStart, ySnap + 1, xStop, ySnap + 1); if (scrolled) { scrollPace++; try { Thread.sleep(scrollPace > 5 ? 10 : 200); - } catch (InterruptedException e) { } + } catch (InterruptedException e) { + } } else { scrollPace = 0; } } - public synchronized void drop( DropTargetDropEvent dropTargetDropEvent ) { - Log.log( Log.LEVEL_TRACE, MODULE, "drop - dtde" ); - - if ( ! isDragOK(dropTargetDropEvent) ) { + public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) { + Log.log(Log.LEVEL_TRACE, MODULE, "drop - dtde"); + + if (!isDragOK(dropTargetDropEvent)) { + Log.log(Log.LEVEL_TRACE, MODULE, "Refusing drop"); dropTargetDropEvent.rejectDrop(); return; } + Log.log(Log.LEVEL_TRACE, MODULE, "Accepting drop"); + try { Transferable tr = dropTargetDropEvent.getTransferable(); dropTargetDropEvent.acceptDrop( - DnDConstants.ACTION_COPY_OR_MOVE ); + DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE); //thanks John Zukowski Point dropLocation = dropTargetDropEvent.getLocation(); - int listIndex = snapIndex( (int) dropLocation.getY() ); + int listIndex = snapIndex((int) dropLocation.getY()); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { List fileList = (List) - tr.getTransferData( DataFlavor.javaFileListFlavor ); + tr.getTransferData(DataFlavor.javaFileListFlavor); /* recursively add contents of directories */ try { - fileList = ImageUtils.expandDirectories( fileList ); - } catch ( IOException ioe ) { - Log.log( Log.LEVEL_ERROR, MODULE, "i/o exception listing dirs in a drop" ); - Log.logStack( Log.LEVEL_ERROR, MODULE ); + fileList = ImageUtils.expandDirectories(fileList); + } catch (IOException ioe) { + Log.log(Log.LEVEL_ERROR, MODULE, "i/o exception listing dirs in a drop"); + Log.logStack(Log.LEVEL_ERROR, MODULE); JOptionPane.showMessageDialog( null, GRI18n.getString(MODULE, "imgError"), GRI18n.getString(MODULE, "dragError"), - JOptionPane.ERROR_MESSAGE ); + JOptionPane.ERROR_MESSAGE); } - Log.log( Log.LEVEL_TRACE, MODULE, "Adding " + fileList.size() + " new files(s) to list at index " + listIndex ); + Log.log(Log.LEVEL_TRACE, MODULE, "Adding " + fileList.size() + " new files(s) to list at index " + listIndex); - mf.addPictures( (File[]) fileList.toArray( new File[0] ), listIndex, false); + mf.addPictures((File[]) fileList.toArray(new File[0]), listIndex, false); } else { List pictureList = (List) - tr.getTransferData( PictureSelection.flavors[0] ); + tr.getTransferData(PictureSelection.flavors[0]); - Log.log( Log.LEVEL_TRACE, MODULE, "Adding " + pictureList.size() + " new pictures(s) to list at index " + listIndex ); + Log.log(Log.LEVEL_TRACE, MODULE, "Adding " + pictureList.size() + " new pictures(s) to list at index " + listIndex); - mf.addPictures( (Picture[]) pictureList.toArray( new Picture[0] ), listIndex, true); + mf.addPictures((Picture[]) pictureList.toArray(new Picture[0]), listIndex, true); } - dropTargetDropEvent.getDropTargetContext().dropComplete( true ); - } catch ( IOException io ) { + dropTargetDropEvent.getDropTargetContext().dropComplete(true); + } catch (IOException io) { Log.logException(Log.LEVEL_ERROR, MODULE, io); - dropTargetDropEvent.getDropTargetContext().dropComplete( false ); - } catch ( UnsupportedFlavorException ufe ) { + dropTargetDropEvent.getDropTargetContext().dropComplete(false); + } catch (UnsupportedFlavorException ufe) { Log.logException(Log.LEVEL_ERROR, MODULE, ufe); - dropTargetDropEvent.getDropTargetContext().dropComplete( false ); + dropTargetDropEvent.getDropTargetContext().dropComplete(false); } } - public void dropActionChanged( DropTargetDragEvent dropTargetDragEvent ) { - Log.log( Log.LEVEL_TRACE, MODULE, "dropActionChanged - dtde" ); - if ( ! isDragOK(dropTargetDragEvent) ) { + public void dropActionChanged(DropTargetDragEvent dropTargetDragEvent) { + Log.log(Log.LEVEL_TRACE, MODULE, "dropActionChanged - dtde"); + if (!isDragOK(dropTargetDragEvent)) { dropTargetDragEvent.rejectDrag(); return; } - dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE ); + //dropTargetDragEvent.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE ); } - + /* ********* DragSourceListener ********** */ - public void dragDropEnd( DragSourceDropEvent dragSourceDropEvent ) { - Log.log( Log.LEVEL_TRACE, MODULE, "dragDropEnd - dsde" ); + public void dragDropEnd(DragSourceDropEvent dragSourceDropEvent) { + Log.log(Log.LEVEL_TRACE, MODULE, "dragDropEnd - dsde"); if (dragSourceDropEvent.getDropSuccess() && dragSourceDropEvent.getDropAction() == DnD... [truncated message content] |