upload.setEnabled( mAlbum != null && mAlbum.sizePictures() > 0 && !mInProgress && album.getSelectedIndex() >= 0 );   fetch.setEnabled( !mInProgress ); gallery.setEnabled( !mInProgress ); newGallery.setEnabled( !mInProgress ); username.setEnabled( !mInProgress ); password.setEnabled( !mInProgress );   boolean enabled = ! mInProgress && mAlbum != null && album.getModel().getSize() >= 1; browse.setEnabled( enabled ); pictureInspector.setEnabled( enabled ); picturesList.setEnabled( enabled ); album.setEnabled( enabled );   int sel = picturesList.getSelectedIndex();   if ( GalleryRemote.getInstance().properties.getShowPreview() ) { if ( sel != -1 ) { String filename = ( mAlbum.getPicture( sel ).getSource() ).getPath(); previewFrame.displayFile( filename ); } else { previewFrame.displayFile( null ); }  if ( !previewFrame.isVisible() ) { previewFrame.setVisible( true ); } }   if ( mAlbum == null) { pictureInspector.setPictures( (Object[]) null );  setStatus( "Select a Gallery URL and click Fetch Albums..." ); } else if ( mAlbum.sizePictures() > 0 ) { pictureInspector.setPictures( picturesList.getSelectedValues() );  int selN = picturesList.getSelectedIndices().length;  if ( sel == -1 ) { setStatus( mAlbum.sizePictures() + " pictures / " + NumberFormat.getInstance().format( ( (int) mAlbum.getPictureFileSize() / 1024 ) ) + " K" ); } else { setStatus( "Selected " + selN + ((selN == 1)?" picture / ":" pictures / ") + NumberFormat.getInstance().format( ( (int) mAlbum.getObjectFileSize( picturesList.getSelectedValues() ) / 1024 ) ) + " K" ); } } else { pictureInspector.setPictures( (Object[]) null );  setStatus( "No selection" ); }
upload.setEnabled( mAlbum != null && mAlbum.sizePictures() > 0 && !mInProgress && album.getSelectedIndex() >= 0 );   fetch.setEnabled( !mInProgress ); gallery.setEnabled( !mInProgress ); newGallery.setEnabled( !mInProgress ); username.setEnabled( !mInProgress ); password.setEnabled( !mInProgress );   boolean enabled = ! mInProgress && mAlbum != null && album.getModel().getSize() >= 1; browse.setEnabled( enabled ); pictureInspector.setEnabled( enabled ); picturesList.setEnabled( enabled ); album.setEnabled( enabled );   int sel = picturesList.getSelectedIndex();   if ( GalleryRemote.getInstance().properties.getShowPreview() ) { if ( sel != -1 ) { String filename = ( mAlbum.getPicture( sel ).getSource() ).getPath(); previewFrame.displayFile( filename ); } else { previewFrame.displayFile( null ); }  if ( !previewFrame.isVisible() ) { previewFrame.setVisible( true ); } }   if ( mAlbum == null) { pictureInspector.setPictures( (Object[]) null );  setStatus( "Select a Gallery URL and click Fetch Albums..." ); } else if ( mAlbum.sizePictures() > 0 ) { int selN = picturesList.getSelectedIndices().length;  pictureInspector.setPictures( picturesList.getSelectedValues() );  if ( sel == -1 ) { setStatus( mAlbum.sizePictures() + " pictures / " + NumberFormat.getInstance().format( ( (int) mAlbum.getPictureFileSize() / 1024 ) ) + " K" ); } else { setStatus( "Selected " + selN + ((selN == 1)?" picture / ":" pictures / ") + NumberFormat.getInstance().format( ( (int) mAlbum.getObjectFileSize( picturesList.getSelectedValues() ) / 1024 ) ) + " K" ); } } else { pictureInspector.setPictures( (Object[]) null );  setStatus( "No selection" ); }
	void resetUIState() {		SwingUtilities.invokeLater(new Runnable() {			public void run() {		// if the list is empty or comm, disable upload		upload.setEnabled( mAlbum != null			&& mAlbum.sizePictures() > 0 			&& !mInProgress			&& album.getSelectedIndex() >= 0 );				// during comm, don't change Gallery or do any other comm		fetch.setEnabled( !mInProgress );		gallery.setEnabled( !mInProgress );		newGallery.setEnabled( !mInProgress );		username.setEnabled( !mInProgress );		password.setEnabled( !mInProgress );				// if the selected album is uploading, disable everything		boolean enabled = ! mInProgress && mAlbum != null && album.getModel().getSize() >= 1;		browse.setEnabled( enabled );		pictureInspector.setEnabled( enabled );		picturesList.setEnabled( enabled );		album.setEnabled( enabled );				// change image displayed		int sel = picturesList.getSelectedIndex();		/*if (mAlbum != null && mAlbum.getSize() < 1) {			// if album was just emptied, it takes a while for the pictureList			// to notice...			sel = -1;		}*/				if ( GalleryRemote.getInstance().properties.getShowPreview() ) {			if ( sel != -1 ) {				String filename = ( mAlbum.getPicture( sel ).getSource() ).getPath();				previewFrame.displayFile( filename );			} else {				previewFrame.displayFile( null );			}			if ( !previewFrame.isVisible() ) {				previewFrame.setVisible( true );			}		}				// status		if ( mAlbum == null) {			pictureInspector.setPictures( (Object[]) null );			setStatus( "Select a Gallery URL and click Fetch Albums..." );		} else if ( mAlbum.sizePictures() > 0 ) {			pictureInspector.setPictures( picturesList.getSelectedValues() );			int selN = picturesList.getSelectedIndices().length;			if ( sel == -1 ) {				setStatus( mAlbum.sizePictures() + " pictures / "				+ NumberFormat.getInstance().format(					( (int) mAlbum.getPictureFileSize() / 1024 ) )				+ " K" );			} else {				setStatus( "Selected " + selN + ((selN == 1)?" picture / ":" pictures / ")				+ NumberFormat.getInstance().format(					( (int) mAlbum.getObjectFileSize( picturesList.getSelectedValues() ) / 1024 ) )				+ " K" );			}		} else {			pictureInspector.setPictures( (Object[]) null );			setStatus( "No selection" );		}		}});	}