SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-12-2006, 08:17 AM
nathanm nathanm is offline
Sage User
 
Join Date: Aug 2004
Posts: 39
Send a message via AIM to nathanm
Sorting

I've noticed that there is a Sort function that is used. I could not locate information about it in the API docs. So if anybody knows where it is at, please post the link.

Now.. If I have one of my own plugin functions returning a ArrayList, is it possible for SageTV to sort that list using the Sort function or another function?

What would be ideal is if there is some way to have an ArrayList or other type of object that is sortable by another property that is specified.

For example, I would have
Name / Priority
"Name 1", 10
"Name 3", 30
"Name 2", 20

Is there a function and object that I can pass that function that will sort all the items in the list by the priority?
Reply With Quote
  #2  
Old 11-12-2006, 10:05 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
Sort and SortLexical are part of the Database API in the API docs linked in the sticky at the top of this forum

http://download.sage.tv/api/sage/api...va.lang.Object, boolean, java.lang.Object)
but these only tend to work with Sage objects (Airings/MediaFiles etc).

What is actually in your ArrayList?
If they are Sage objects, you can use the Sage Sort method with the approriate getter to sort by (GetShowTitle or whatever -- see inside the STV for examples)

If it is a java class that implements the Comparable interface, or you can have a Comparator helper class available to compare the objects, you can convert the ArrayList to an Array (toArray() ) and then use the java array sorting methods (java.lang.Arrays.Sort()).

Or you can choose a different Collection for your data that is already automatically sorted, eg a java.util.TreeSet
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #3  
Old 11-12-2006, 10:35 AM
nathanm nathanm is offline
Sage User
 
Join Date: Aug 2004
Posts: 39
Send a message via AIM to nathanm
If I create my own class that implements the Comparable interface that includes the ID of the item and the string of the item and compares them. Is it still possible to have it work with SageTV Table elements, or do SageTV Table elements only work with functions that return ArrayLists?
Reply With Quote
  #4  
Old 11-12-2006, 11:15 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
Tables work with either java arrays of Objects (ie Object[])
or with any collection: lists/maps/sets etc

You would have to return either an array of objects of your class, or a list of objects of your class.

Your class would have to implement Comparable (for sorting), and would have to have getter/setter methods so that you can access the member data from with Studio.

You would pass an Array or Collection of such class objects to the Table widget, and each table row would be an object from that array.
Several of my plugins use Collections of objects of custom classes if you want pointers (eg rss news, autoaspect)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.