From: Pierre-Luc P. <pa...@us...> - 2004-02-25 23:29:16
|
Update of /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32636/com/gallery/GalleryRemote Modified Files: GRAppletMini.java GRAppletSlideshow.java GalleryComm1.java GalleryComm2.java MainFrame.java MoveAlbumDialog.java NewAlbumDialog.java Log Message: 2004-02-25 Pierre-Luc Paour <ga...@pa...> (1.3.2-b6) * Solved a very long-standing problem where I didn't know how to get the albums tree to draw correctly when adding images (the album name would be truncated). * When adding an album, no longer refreshing the list of albums (this makes it faster and doesn't lose the album tree's disclosure status) * When downloading pictures from the server, flush any previously downloaded pictures first. * Made fetching list of albums from the server slightly faster by disabling events during the download, so the window is only refreshed when the download completes. * Fixed a bug in GRI18n where quote characters in strings that are subjected to pattern-matching to replace some of the text at runtime would cause the pattern-matching algorithm to barf. Also created a cache for patterns. Index: GRAppletMini.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/GRAppletMini.java,v retrieving revision 1.11 retrieving revision 1.12 diff -w -u -r1.11 -r1.12 --- GRAppletMini.java 11 Feb 2004 01:45:00 -0000 1.11 +++ GRAppletMini.java 25 Feb 2004 23:21:45 -0000 1.12 @@ -79,6 +79,7 @@ ImageUtils.deferredTasks(); album = new Album(gallery); + album.setSuppressEvents(true); album.setName(info.albumName); gallery.addAlbum(album); Index: GRAppletSlideshow.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/GRAppletSlideshow.java,v retrieving revision 1.9 retrieving revision 1.10 diff -w -u -r1.9 -r1.10 --- GRAppletSlideshow.java 12 Feb 2004 23:33:16 -0000 1.9 +++ GRAppletSlideshow.java 25 Feb 2004 23:21:45 -0000 1.10 @@ -54,6 +54,7 @@ ImageUtils.deferredTasks(); album = new Album(gallery); + album.setSuppressEvents(true); album.setName(info.albumName); album.addListDataListener(this); Index: GalleryComm1.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/GalleryComm1.java,v retrieving revision 1.17 retrieving revision 1.18 diff -w -u -r1.17 -r1.18 --- GalleryComm1.java 26 Jan 2004 06:27:45 -0000 1.17 +++ GalleryComm1.java 25 Feb 2004 23:21:45 -0000 1.18 @@ -325,6 +325,7 @@ if (colT.countTokens() == 2) { Album a = new Album(g); + a.setSuppressEvents(true); a.setName(colT.nextToken()); a.setTitle(HTMLEscaper.unescape(colT.nextToken())); @@ -332,6 +333,7 @@ mAlbumList.add(a); a.setParentAlbum(null); + a.setSuppressEvents(false); } } Index: GalleryComm2.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/GalleryComm2.java,v retrieving revision 1.44 retrieving revision 1.45 diff -w -u -r1.44 -r1.45 --- GalleryComm2.java 19 Feb 2004 05:45:55 -0000 1.44 +++ GalleryComm2.java 25 Feb 2004 23:21:45 -0000 1.45 @@ -695,8 +695,7 @@ } void runTask() { - Object[] params = {g.toString()}; - su.startProgress(StatusUpdate.LEVEL_BACKGROUND, 0, 10, GRI18n.getString(MODULE, "albmFtchng", params), true); + su.startProgress(StatusUpdate.LEVEL_BACKGROUND, 0, 10, GRI18n.getString(MODULE, "albmFtchng", new Object[] {g.toString()}), true); try { long startTime = System.currentTimeMillis(); @@ -745,6 +744,7 @@ HashMap ref2album = new HashMap(); for (int i = 1; i < albumCount + 1; i++) { Album a = new Album(g); + a.setSuppressEvents(true); String nameKey = "album.name." + i; String titleKey = "album.title." + i; @@ -766,6 +766,7 @@ a.setName(p.getProperty(nameKey)); a.setTitle(HTMLEscaper.unescape(p.getProperty(titleKey))); + a.setSuppressEvents(false); mAlbumList.add(a); // map album ref nums to albums @@ -822,6 +823,7 @@ HashMap name2album = new HashMap(); for (int i = 1; i < albumCount + 1; i++) { Album a = new Album(g); + a.setSuppressEvents(true); String nameKey = "album.name." + i; String titleKey = "album.title." + i; @@ -844,6 +846,8 @@ a.setTitle(HTMLEscaper.unescape(p.getProperty(titleKey))); a.setExtraFieldsString(HTMLEscaper.unescape(p.getProperty(infoExtraFieldKey))); + a.setSuppressEvents(false); + albums.add(a); // map album names to parent albums @@ -1019,8 +1023,7 @@ } void runTask() { - Object[] params = {g.toString()}; - status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "getAlbmInfo", params)); + status(su, StatusUpdate.LEVEL_GENERIC, GRI18n.getString(MODULE, "newAlbm", new Object[] { albumName, g.toString() })); // if the parent is null (top-level album), set the album name to an illegal name so it's set to null // by Gallery. Using an empty string doesn't work, because then the HTTP parameter is not Index: MainFrame.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/MainFrame.java,v retrieving revision 1.113 retrieving revision 1.114 diff -w -u -r1.113 -r1.114 --- MainFrame.java 25 Feb 2004 17:55:52 -0000 1.113 +++ MainFrame.java 25 Feb 2004 23:21:45 -0000 1.114 @@ -34,6 +34,7 @@ import com.gallery.GalleryRemote.util.OsShutdown; import javax.swing.*; +import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.border.TitledBorder; import javax.swing.event.*; import javax.swing.filechooser.FileFilter; @@ -108,7 +109,7 @@ GridBagLayout gridBagLayout3 = new GridBagLayout(); JPanel jAlbumPanel = new JPanel(); JScrollPane jAlbumScroll = new JScrollPane(); - DroppableTree jAlbumTree = new DroppableTree(); + public DroppableTree jAlbumTree = new DroppableTree(); JComboBox jGalleryCombo = new JComboBox(); JButton jNewGalleryButton = new JButton(); @@ -749,29 +750,30 @@ Log.log(Log.LEVEL_TRACE, MODULE, "Album '" + newAlbumName + "' created."); // there is probably a better way... this is needed to give the UI time to catch up // and load the combo up with the reloaded album list - new Thread() { - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Log.logException(Log.LEVEL_ERROR, MODULE, e); - } + //new Thread() { + // public void run() { + // try { + // Thread.sleep(1000); + // } catch (InterruptedException e) { + // Log.logException(Log.LEVEL_ERROR, MODULE, e); + // } //SwingUtilities.invokeLater(new Runnable() { // public void run() { - // todo: none of the calls below seem to have any effect Log.log(Log.LEVEL_TRACE, MODULE, "Selecting " + newAlbumName); TreePath path = getCurrentGallery().getPathForAlbum(getCurrentGallery().getAlbumByName(newAlbumName)); - //jAlbumTree.expandPath(path); - //jAlbumTree.makeVisible(path); + //jAlbumTree.expandPath(path.getParentPath()); + // todo: this call doesn't seem to have any effect + jAlbumTree.makeVisible(path); + jAlbumTree.setSelectionPath(path); //jAlbumTree.repaint(); // } //}); - } - }.start(); + // } + //}.start(); // We've been modified, we are now dirty. setDirtyFlag(true); @@ -1671,6 +1673,7 @@ * @param e the event that characterizes the change. */ public void valueChanged(TreeSelectionEvent e) { + //jAlbumTree.treeDidChange(); updateAlbumCombo(); jAlbumInspector.setAlbum(getCurrentAlbum()); @@ -1866,7 +1869,10 @@ /*** TreeModelListener implementation ***/ public void treeNodesChanged(TreeModelEvent e) { - albumChanged((Album) e.getTreePath().getLastPathComponent()); + TreePath treePath = e.getTreePath(); + if (treePath != null && getCurrentGallery().getRoot() != treePath.getLastPathComponent()) { + albumChanged((Album) treePath.getLastPathComponent()); + } } public void treeNodesInserted(TreeModelEvent e) { @@ -1882,6 +1888,8 @@ } class AlbumTreeRenderer extends DefaultTreeCellRenderer { + Album album = null; + public Component getTreeCellRendererComponent( JTree tree, Object value, @@ -1891,14 +1899,21 @@ int row, boolean hasFocus) { + // Swing incorrectly passes selection state in some cases + TreePath selectionPath = tree.getSelectionPath(); + if (selectionPath != null && selectionPath.getLastPathComponent() == value) { + sel = true; + } + super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); - Album album = null; if (value instanceof Album) { album = (Album) value; + } else { + album = null; } Font font = getFont(); @@ -1923,6 +1938,15 @@ return this; } + + public Dimension getPreferredSize() { + Dimension retDimension = super.getPreferredSize(); + + if(retDimension != null) + retDimension = new Dimension((int) (retDimension.width * 1.5 + 15), + retDimension.height); + return retDimension; + } } class GalleryListRenderer extends DefaultListCellRenderer { Index: MoveAlbumDialog.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/MoveAlbumDialog.java,v retrieving revision 1.4 retrieving revision 1.5 diff -w -u -r1.4 -r1.5 --- MoveAlbumDialog.java 12 Feb 2004 14:47:27 -0000 1.4 +++ MoveAlbumDialog.java 25 Feb 2004 23:21:46 -0000 1.5 @@ -87,6 +87,7 @@ Vector albums = new Vector(gallery.getAlbumList()); rootAlbum = new Album(gallery); + rootAlbum.setSuppressEvents(true); rootAlbum.setTitle(GRI18n.getString(MODULE, "rootAlbmTitle")); rootAlbum.setName("root.root"); albums.add(0, rootAlbum); Index: NewAlbumDialog.java =================================================================== RCS file: /cvsroot/gallery/gallery_remote/com/gallery/GalleryRemote/NewAlbumDialog.java,v retrieving revision 1.20 retrieving revision 1.21 diff -w -u -r1.20 -r1.21 --- NewAlbumDialog.java 16 Jan 2004 21:23:44 -0000 1.20 +++ NewAlbumDialog.java 25 Feb 2004 23:21:46 -0000 1.21 @@ -93,6 +93,7 @@ Vector albums = new Vector(gallery.getAlbumList()); rootAlbum = new Album(gallery); + rootAlbum.setSuppressEvents(true); rootAlbum.setTitle(GRI18n.getString(MODULE, "rootAlbmTitle")); rootAlbum.setName("root.root"); albums.add(0, rootAlbum); @@ -170,10 +171,13 @@ setVisible(false); } else if (command.equals("OK")) { Album a = new Album(gallery); + a.setSuppressEvents(true); a.setName(jName.getText()); a.setTitle(jTitle.getText()); a.setCaption(jDescription.getText()); + a.setSuppressEvents(false); + Album selectedAlbum = (Album) jAlbum.getSelectedItem(); if (selectedAlbum == rootAlbum) { Log.log(Log.LEVEL_TRACE, MODULE, "Selected root album"); |