Permlink Replies: 31 - Pages: 3 [ 1 2 3 | Next ] - Last Post: 06-Sep-2017 22:59 Last Post By: jGromit Threads: [ Previous | Next ]
davidekholm

Posts: 21,296
Registered: 10/18/02
Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 00:53
  Click to reply to this thread Reply
Attachment Minimal7.1.jaskin (78.0 KB)
I've finally improved our JDraggableList component so it not only allows items to be rearranged with drag and drop but it now also works in pairs so you can have one "Available" and one "Used" list to allow the end user to pick and choose what variables to display under thumbnails for instance. The user simply drags items from the "Available" to the "Used" list. The user can delete unwanted items by hitting delete or dragging them back to the "Available" list.

I've added this improved JDraggableList component to jAlbum 14.1.1. Do a core update to get it, them try this attached Minimal 7.1 skin which demonstrates the usage:



Edited by: davidekholm on 10-Aug-2017 09:43
Fix for file names showing through if title was missing

Edited by: davidekholm on 10-Aug-2017 14:50
Fix for issues reported by jGromit. Do a core update to 14.1.2!
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 01:05   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
I'll have to play with this more when I'm sober, but the implementation in Minimal isn't quite right. Choose just Title and Comment, and feed it some images that have neither. The thumbnails show the file name, even though that's not selected.

This is why we don't let David develop skins. ;)
RobM

Posts: 4,258
Registered: 08/04/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 10:20   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
I'll have to play with this more when I'm sober, but the implementation in Minimal isn't quite right. Choose just Title and Comment, and feed it some images that have neither. The thumbnails show the file name, even though that's not selected.

This is why we don't let David develop skins. ;)

It only shows the file name for folders when the folder object has none of the selected texts. See the method at line 33 of init.bsh, lines 48 to 50.
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 10:24   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
I'll have to play with this more when I'm sober, but the implementation in Minimal isn't quite right. Choose just Title and Comment, and feed it some images that have neither. The thumbnails show the file name, even though that's not selected.

This is why we don't let David develop skins. ;)


Oh, there are more reasons than that ;-). Lack of visual design taste would be my main pick.
Thanks for spotting that error. Now fixed in the attached skin above. Please also do another core update. I fixed a small layout hint so these lists automatically size properly depending on number of rows they are to hold, taking into account worst case scenario where all items are put in one of the lists. I've however set these lists to suggest scrolling if there are more than 8 items present (Swing's default is to always size lists to 8 rows)
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 10:35   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
RobM wrote:
jGromit wrote:
I'll have to play with this more when I'm sober, but the implementation in Minimal isn't quite right. Choose just Title and Comment, and feed it some images that have neither. The thumbnails show the file name, even though that's not selected.

This is why we don't let David develop skins. ;)

It only shows the file name for folders when the folder object has none of the selected texts. See the method at line 33 of init.bsh, lines 48 to 50.

It was actually a bug jGromit spotted. The "title" variable I used as one of the items has the property to let the base file name "shine through" if the title is missing. There is no point in letting such "shine through" variables take part in these flexible lists. Users who wants that behavior simply adds "title" (internally fileTitle) followed by "Base name" (internally label) to the "Used" list now. I renamed these item names once more so please grab the skin again.

With regards to folders: True, the Minimal skin is designed to never leave out any label for folders, so if folders end up missing any descriptive text, their folder name is added by the clever getLabel() method from init.bsh
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 12:49   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
The "title" variable I used as one of the items has the property to let the base file name "shine through" if the title is missing.

That's why I always make unkind remarks about "slippery" jAlbum variables like title, and why I never use them in my skins - you never know what you're going to get. ;)

Seems to be working properly now. Just one more suggestion, however. I wouldn't use a pipe separator between items, especially not for a thumbnail caption, where the space is going to be fairly narrow. I'd use a <br> separator - each item on its own line.
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 12:58   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
Attachment ss003176.png (19.5 KB)
Attachment ss003177.png (19.3 KB)
Attachment ss003178.png (19.1 KB)
I take it back. I'm seeing some flaky behavior in the lists.

I start a new project, and the lists look like ss003176. I move Title and Comment to the list, and move File name off the list, and make the album. The lists now look like ss003177. So far, so good.

But now I do a quick CTRL-S, CTRL-W, CTRL-1, and now the lists look like ss003178. File name has vanished.
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 13:02   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
Ah, simple mistake. Some careless coder failed to add File name to the list of available options in onload.bsh. Do I have to come over there and start putting some stick about?

Edit: Maybe not so simple. If I add it to the list, it now appears on both sides. Clearly, the concepts of "used" and "available" need some work. If something is taken off the "used" side, it needs to be added to the "available" side.
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 15:02   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
Ah, simple mistake. Some careless coder failed to add File name to the list of available options in onload.bsh. Do I have to come over there and start putting some stick about?

Edit: Maybe not so simple. If I add it to the list, it now appears on both sides. Clearly, the concepts of "used" and "available" need some work. If something is taken off the "used" side, it needs to be added to the "available" side.


I reworked the mechanism a bit to hopefully make this solid now. Please both do a core update to 14.1.2 and grab the updated Minimal 7.1 skin from the top of this thread.

Changes:
  • Uses <br> to separate multiple items
  • Only the primary list takes part in UI synchronization and project file disk persistence. It's the job of the primary list to also update the state of the secondary list.
  • JDraggableList has a new constructor for creating list pairs and a getSecondaryList() method to get the secondary list and add it to the UI. See updated onload.bsh of Minimal7.1 for correct usage.

Edited by: jGromit, to encode the break tag
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 15:06   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
One more thing. The JDraggableList component now also allows multiple item selection. Use SHIFT to select and drag ranges of items and CMD/CTRL to select and drag individual items
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 10-Aug-2017 15:32   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Close to solid. I can still beat it to the punch, however. If I choose, say, Title, Comment, and Base name, make the album, save the album, then do a rapid CTRL-W, CTRL-1, I'm seeing the default choices. If I pause a bit after closing the project, then open it again, the saved choices are displayed properly.

I suspect this is a manifestation of a deep project-loading bug we've seen once in a while over the past few years, when fast-fingered users claim that their project settings aren't being saved. What's in the .jap file is actually correct.

And multiple item selection is only partially working. I can select multiple items, but when I then try to drag them, I'm getting only one item. Only a right-click drag works, especially for non-contiguous items. Not terrible, but not immediately obvious, either.
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 11-Aug-2017 13:39   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
Off-topic, but I notice you're using a StringBuffer in the method for putting together the caption string. My reading on that tells me that it's more efficient, but only if you're doing thousands of "appends" to a string. For Minimal simplicity, shouldn't it be:
String getLabel(AlbumObject ao) {
	Map vars = ao.getVars();
	String buf = "";
	for (String key : thumbnailItems.split("\t")) {
		Object val = vars.get(key);
		if (val != null && val.toString().length() > 0) {
			if (buf.length() > 0) {
				buf += "<br>";
			}
			buf += val.toString();
			if (thumbnailItemsDisplay.equals("firstFound")) {
				break;
			}
		}
	}
	if (buf.length() == 0 && ao.isFolder) {
		buf += vars.get("fileName");
	}
	return buf;
}
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 11-Aug-2017 15:08   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
Off-topic, but I notice you're using a StringBuffer in the method for putting together the caption string. My reading on that tells me that it's more efficient, but only if you're doing thousands of "appends" to a string. For Minimal simplicity, shouldn't it be:
String getLabel(AlbumObject ao) {
	Map vars = ao.getVars();
	String buf = "";
	for (String key : thumbnailItems.split("\t")) {
		Object val = vars.get(key);
		if (val != null && val.toString().length() > 0) {
			if (buf.length() > 0) {
				buf += "<br>";
			}
			buf += val.toString();
			if (thumbnailItemsDisplay.equals("firstFound")) {
				break;
			}
		}
	}
	if (buf.length() == 0 && ao.isFolder) {
		buf += vars.get("fileName");
	}
	return buf;
}

You refer to StringBuilder, the faster successor to StringBuilder. Well, simplicity is always good. I just felt like using StringBuilder as it signals that we're building a string step by step. In my world, it helps the reader to understand what's going on, but from a performance stand point, it really doesn't matter.
jGromit

Posts: 32,925
Registered: 01/31/06
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 11-Aug-2017 15:15   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
I was also thinking about Nashorn. Converting to init.js is a lot easier if you're already doing things in a Javascript-y sort of way.
davidekholm

Posts: 21,296
Registered: 10/18/02
Re: Improved JDraggableList component for jAlbum 14.1.1
Posted: 11-Aug-2017 15:26   in response to: jGromit in response to: jGromit
  Click to reply to this thread Reply
jGromit wrote:
I was also thinking about Nashorn. Converting to init.js is a lot easier if you're already doing things in a Javascript-y sort of way.

True
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums