Skip to content

Commit

Permalink
Fixed bug 521237: non-unique album titles would confuse the Albums co…
Browse files Browse the repository at this point in the history
…mbo-box.

The changes implemented for this fix open the way for multiple album uploads. Yay!
I'll add this shortly.

I'll need to disable everything while the upload runs (would be nice to put up a
copy dialog) and be careful with threading...
  • Loading branch information
Pierre-Luc Paour committed Sep 20, 2002
1 parent 74e9ce4 commit b0332d1
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 14 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -5,6 +5,9 @@
but it means users will have to either copy the preferences file over themselves
or recreate their preferences.
* Fixed bug 612281: redirects needed two clicks.
* Fixed bug 521237: non-unique album titles would confuse the Albums combo-box.
The changes implemented for this fix open the way for multiple album uploads. Yay!
I'll add this shortly.

2002-09-17 Pierre-Luc Paour <gallery@paour.com> (1.0-b5)

Expand Down
17 changes: 10 additions & 7 deletions com/gallery/GalleryRemote/MainFrame.java
Expand Up @@ -55,6 +55,7 @@ public class MainFrame extends javax.swing.JFrame

private GalleryComm mGalleryComm;
private DefaultComboBoxModel galleries = null;
//private DefaultComboBoxModel albums = null;
private Gallery currentGallery = null;
private Album mAlbum;
private boolean mInProgress = false;
Expand Down Expand Up @@ -119,6 +120,7 @@ public MainFrame() {
ImageUtils.THUMB );

galleries = new DefaultComboBoxModel();
//albums = new DefaultComboBoxModel();
int i = -1;
String url;
while ( ( url = p.getProperty( "url." + (++i) ) ) != null ) {
Expand Down Expand Up @@ -283,15 +285,15 @@ private void updateGalleryParams() {


private void updateAlbumCombo() {
album.removeAllItems();
album.setModel(currentGallery);

if (currentGallery.getAlbumList() != null) {
/*if (currentGallery.getAlbumList() != null) {
Iterator iter = currentGallery.getAlbumList().iterator();
while ( iter.hasNext() ) {
Hashtable h = (Hashtable) iter.next();
album.addItem( (String) h.get( "title" ) );
}
}
}*/
}


Expand Down Expand Up @@ -443,8 +445,8 @@ public void uploadPictures() {
mGalleryComm.setPassword( currentGallery.getPassword() );

int index = album.getSelectedIndex();
Hashtable h = (Hashtable) currentGallery.getAlbumList().get( index );
mGalleryComm.setAlbum( (String) h.get( "name" ) );
//Hashtable h = (Hashtable) currentGallery.getAlbumList().get( index );
mGalleryComm.setAlbum( currentGallery.getSelectedAlbum().getName() );
picturesList.disable();
mGalleryComm.uploadFiles( mAlbum.getFileList() );

Expand Down Expand Up @@ -512,7 +514,7 @@ public void actionPerformed( ActionEvent evt ) {
currentGallery.setAlbumList(mGalleryComm.getAlbumList());
mInProgress = false;

if (currentGallery.getAlbumList() != null) {
if (mGalleryComm.getAlbumList() != null) {
updateAlbumCombo();
resetUIState();
} else {
Expand Down Expand Up @@ -863,7 +865,8 @@ public void itemStateChanged( ItemEvent e ) {
GalleryRemote.getInstance().properties.setShowPath( ( e.getStateChange() == ItemEvent.SELECTED ) ? true : false );
picturesList.repaint();
} else if ( item == album ) {
mAlbum.setName( (String) ( (JComboBox) item ).getSelectedItem() );
mAlbum = (Album) ( (JComboBox) item ).getSelectedItem();
picturesList.setModel( mAlbum );
} else {
Log.log(Log.ERROR, MODULE, "Unhandled item state change " + item );
}
Expand Down
4 changes: 2 additions & 2 deletions com/gallery/GalleryRemote/PictureInspector.java
Expand Up @@ -241,7 +241,7 @@ public void setPictures( Object[] pictures ) {
icon.setText( p.getSource().getName() );
icon.setIcon( mf.getThumbnail( p ) );
path.setText( p.getSource().getParent() );
album.setText( p.getAlbum().getName() );
album.setText( p.getAlbum().getTitle() );
caption.setText( p.getCaption() );
size.setText( NumberFormat.getInstance().format(
(int) p.getFileSize() ) + " bytes" );
Expand All @@ -255,7 +255,7 @@ public void setPictures( Object[] pictures ) {
icon.setText( pictures.length + " elements selected" );
icon.setIcon( mf.defaultThumbnail );
path.setText( "" );
album.setText( p.getAlbum().getName() );
album.setText( p.getAlbum().getTitle() );
caption.setText( "" );
size.setText( NumberFormat.getInstance().format(
Album.getObjectFileSize(pictures) ) + " bytes" );
Expand Down
27 changes: 26 additions & 1 deletion com/gallery/GalleryRemote/model/Album.java
Expand Up @@ -39,7 +39,8 @@ public class Album extends Picture implements ListModel
public static final String MODULE="Album";

Vector pictures = new Vector();
String name = "Not yet connected to Gallery";
String title = "Not yet connected to Gallery";
String name;
String url;
String username;
String password;
Expand Down Expand Up @@ -247,6 +248,26 @@ public String getName() {
}


/**
* Sets the title attribute of the Album object
*
*@param title The new title
*/
public void setTitle( String title ) {
this.title = title;
}


/**
* Gets the title attribute of the Album object
*
*@return The title
*/
public String getTitle() {
return title;
}


/**
* Gets the aggregated file size of all the pictures in the album
*
Expand Down Expand Up @@ -288,6 +309,10 @@ public static long getObjectFileSize( Object[] pictures ) {

return total;
}

public String toString() {
return title;
}


/*
Expand Down
83 changes: 80 additions & 3 deletions com/gallery/GalleryRemote/model/Gallery.java
Expand Up @@ -25,20 +25,27 @@
import javax.swing.*;
import javax.swing.event.*;

import com.gallery.GalleryRemote.*;

/**
* Album model
* Gallery model
*
*@author paour
*@created 17 août 2002
*/

public class Gallery
public class Gallery implements ComboBoxModel
{
public static final String MODULE="Gallery";

String url = "http://";
String username;
String password;
ArrayList albumList = null;
Album selectedAlbum = null;

// ListModel
Vector listeners = new Vector( 1 );

/**
* Constructor for the Gallery object
Expand Down Expand Up @@ -96,7 +103,23 @@ public void setPassword( String password ) {
*@param albumList The new albumList value
*/
public void setAlbumList( ArrayList albumList ) {
this.albumList = albumList;
//this.albumList = albumList;
ArrayList buf = new ArrayList(albumList.size());

Iterator iter = albumList.iterator();
while (iter.hasNext()) {
Hashtable h = (Hashtable) iter.next();
Album a = new Album();
a.setName((String) h.get( "name" ));
a.setTitle((String) h.get( "title" ));
a.setGallery(this);

buf.add(a);
}

this.albumList = buf;

notifyListeners();
}


Expand Down Expand Up @@ -148,5 +171,59 @@ public ArrayList getAlbumList() {
public String toString() {
return url;
}

public Album getSelectedAlbum() {
return selectedAlbum;
}


/*
* ListModel Implementation
*/
public int getSize() {
if (albumList != null) {
return albumList.size();
} else {
return 0;
}
}


public Object getElementAt( int index ) {
return albumList.get( index );
}

public void setSelectedItem(Object anItem) {
selectedAlbum = (Album) anItem;
}

public Object getSelectedItem() {
return selectedAlbum;
}

public void addListDataListener( ListDataListener ldl ) {
listeners.addElement( ldl );
}


public void removeListDataListener( ListDataListener ldl ) {
listeners.removeElement( ldl );
}


void notifyListeners() {
ListDataEvent lde = new ListDataEvent( com.gallery.GalleryRemote.GalleryRemote.getInstance().mainFrame, ListDataEvent.CONTENTS_CHANGED, 0, albumList.size() );

notifyListeners(lde);
}

void notifyListeners(ListDataEvent lde) {
Log.log(Log.TRACE, MODULE, "Firing ListDataEvent=" + lde.toString());
Enumeration e = listeners.elements();
while ( e.hasMoreElements() ) {
ListDataListener ldl = (ListDataListener) e.nextElement();
ldl.contentsChanged( lde );
}
}
}

1 change: 0 additions & 1 deletion com/gallery/GalleryRemote/model/Picture.java
Expand Up @@ -145,6 +145,5 @@ public int getListIndex() {
*/
public void setListIndex(int listIndex) {
}

}

0 comments on commit b0332d1

Please sign in to comment.