Open GoogleCodeExporter opened 9 years ago
What is it you want to do in the ActionListener?
Maybe it would make more sense to introduce a SourceListViewController if your
trying to toggle views based on
what item is selected.
This would keep the SourceList class free of particular usage patterns.
Original comment by kenneth....@gmail.com
on 31 Oct 2008 at 2:52
Original comment by kenneth....@gmail.com
on 17 Jan 2009 at 1:18
Enabling SourceItems (potentially SourceListCategories too) to be configured
via an
Action will increase code reuse. A SourceListClickListener may delegate to an
item's
action to handle the click event for instance.
Original comment by aalmi...@gmail.com
on 9 Jun 2009 at 5:31
Thanks for the feedback Andres. Can you show me what you want your Groovy
syntax to look like? That'll give
me a better idea of your use case.
Original comment by kenneth....@gmail.com
on 9 Jun 2009 at 10:24
Sure, this is what I have in mind
class DefaultSourceListClickListener implements SourceListClickListener {
void sourceListItemClicked(SourceListItem item, Button button, int clickCount) {
Action action = item.getAction()
if( action && item.enabled ) {
ActionEvent evt = ...
action.actionPerformed(evt)
}
}
void sourceListCategoryClicked(SourceListCategory category, Button button, int
clickCount) {
... // similar impl as above
}
}
actions {
action(id: "checkEmailAction",
smallIcon: imageIcon("/icons/email.png"),
closure: controller.checkEmail)
}
sourceList(id: "sl") {
sourceListCategory("Mail") {
sourceListItem(checkEmailAction, text: "John Doe")
sourceListItem(checkEmailAction, text: "Jane Doe")
}
}
sl.addSourceListClickListener(new DefaultSourceClicklistener())
Both items will inherit the same icon and actionListener,
DefaultSourceClicklistener
makes sure to delegate to the appropriate action if it exists and if it is
enabled. I
believe items/categories are always enabled, does it make sense to disable them?
(don't know if Apple HIGs define this behavior).
Original comment by aalmi...@gmail.com
on 9 Jun 2009 at 5:41
Thanks Andres. Would it be better if I just called the action for you when an
item was selected?
Original comment by kenneth....@gmail.com
on 10 Jun 2009 at 12:29
That would take care of the click event if a DefaultSourceClickListener is
registered
upon SourceList creation. My concern is also about the looks of an
Item/Category, as
if you update an action's properties so must the configured Item/Category.
I'm not sure if Item/Category support updating their text/icon after they are
created. In any case we can prototype this on MacwidgetsBuilder without
affecting
Macwidgets directly, thanks to Groovy's metaprogramming facilities :-)
Original comment by aalmi...@gmail.com
on 10 Jun 2009 at 6:43
Issue 5 has been merged into this issue.
Original comment by kenneth....@gmail.com
on 3 Dec 2009 at 9:00
Is this issue ever going to be resolved? What is the use of the sourcelist if
you cant apply actionevents to it?
Original comment by JakeTyo
on 5 Jun 2010 at 10:17
You can react to selection events using a SourceListSelectionListener:
http://exploding-
pixels.com/google_code/javadoc_0.9.5/com/explodingpixels/macwidgets/SourceListSe
lectionListener.html
Original comment by kenneth....@gmail.com
on 5 Jun 2010 at 10:55
Thanks for the quick response! I tried adding it with minimal success. Can you
look at this snippet and tell me what Im doing wrong?
// Source List
SourceListModel model = new SourceListModel();
// Source List Category
SourceListCategory category = new SourceListCategory("Views");
model.addCategory(category);
// Create Source List Items
SourceListItem codeViewItem = new SourceListItem("Code View", new ImageIcon(FrameController.class.getResource("assets/TreeIcons/codeView.png")));
SourceListItem debuggerItem = new SourceListItem("Debugger", new ImageIcon(FrameController.class.getResource("assets/TreeIcons/debuggerView.png")));
SourceListItem profilerItem = new SourceListItem("Profiler", new ImageIcon(FrameController.class.getResource("assets/TreeIcons/profilerView.png")));
// Add Source List Items
model.addItemToCategory(codeViewItem, category);
model.addItemToCategory(debuggerItem, category);
model.addItemToCategory(profilerItem, category);
// Add Source List Categorys
SourceList sourceList = new SourceList(model);
// Set Selected Source List Item
sourceList.setSelectedItem(codeViewItem);
// Create Source List Listener
new SourceListSelectionListener() {
public void sourceListItemSelected(SourceListItem sli) {
System.err.println(sli);
}
};
Original comment by JakeTyo
on 6 Jun 2010 at 5:03
You need to install the SourceListSelectionListener you created on your
SourceList:
http://exploding-
pixels.com/google_code/javadoc_0.9.5/com/explodingpixels/macwidgets/SourceList.h
tml#addSourceListSelecti
onListener(com.explodingpixels.macwidgets.SourceListSelectionListener)
Original comment by kenneth....@gmail.com
on 6 Jun 2010 at 3:06
It works! Thanks a bunch!
Original comment by JakeTyo
on 6 Jun 2010 at 7:04
Original issue reported on code.google.com by
steve.mc...@gmail.com
on 30 Oct 2008 at 7:57