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 03-14-2007, 03:04 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Java GUIs for Dummies

Anybody know a good guide/tools/tips for building a GUI app in Java? Now that Sage supports pulling in metadata on it's own, I think DVDPro2Sage needs to go down a different path.

Ideally the goal is a gui that would list off your DVDs/Movies, auto associate them as best possible with DVD Profiler entries, allow overrides to associate missed movies, or fix wrongly chosen ones, and finally to generate xxx.properties files for each DVD/Movie that Sage can then import and copy image files.

Unfortunatly I'm a bit overwhelmed by where to start on this project, any advice would be most welcome.
Reply With Quote
  #2  
Old 03-14-2007, 03:09 PM
flavius flavius is offline
Sage Icon
 
Join Date: May 2004
Location: New Hampshire
Posts: 1,257
Do you already have the SDK you want to use? Those typically ship with lots of examples. Why not use swing?
Reply With Quote
  #3  
Old 03-14-2007, 03:12 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Eclipse would be great, I've taken a bit of a look at the Java Visual Editor project for that. But like I said, kind of overwhelming.
Reply With Quote
  #4  
Old 03-14-2007, 03:17 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Here's what I used to learn Swing:

http://java.sun.com/docs/books/tutor...ing/index.html

You'll also find working examples of Swing UI code (including source) in my Studio Tools package.
__________________
-- Greg
Reply With Quote
  #5  
Old 03-14-2007, 03:21 PM
flavius flavius is offline
Sage Icon
 
Join Date: May 2004
Location: New Hampshire
Posts: 1,257
I understand you already have an application that you want to build a UI for? Why not use the same editor you used before? You are not building an enterprise class app, do you?
Reply With Quote
  #6  
Old 03-14-2007, 03:52 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Well that was the idea

But when I was looking at it last night (same tutorial linked by Greg), it appeared much more daunting than today. I sort of figured I was either missing something or that there had to be a better way.

Well, guess I was missing something because it makes more sense today.

Thanks for the suggestions
Reply With Quote
  #7  
Old 03-24-2007, 04:49 PM
MattJackson86 MattJackson86 is offline
Sage User
 
Join Date: Nov 2006
Posts: 74
Swing is great, once you know how. I would say that to get good at swing and not find it scary, it takes a good 6 months of use. The layout managers at first might not do what you are looking for. But once you get used to Swing, it can do anything you want.

Start reading, but mainly start programming and try it out.
__________________
Server: Athlon 64 X2 4200+, 2GB Memory, 2x750GB HDD (DVD Library), 1x500GB (Recordings), 1x500GB(Data), 1x80GB(OS), nVidia 7600GS, PVR-500, HDHomerun
Reply With Quote
  #8  
Old 03-24-2007, 07:47 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
When I was a co-op I did a little gui work with TK, and there's a lot of similarities (build gui object, then pack them together).

One thing I will say is that I finally broke down and downloaded Netbeans 5.5 and I must say, it's a better than the Visual Editor for Eclipse, I'm not sure how much exactly. But there's a more important difference, and that is that the tutorials for NetBeans are much better:
http://www.netbeans.org/kb/55/quickstart-gui.html

I'd previously been frustrated trying to get anywhere just laying out a GUI, but at least now I've got a reasonable start on on that so I'm a little more motivated to continue.

Thanks for the advice guys.
Reply With Quote
  #9  
Old 04-08-2007, 03:22 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
OK, I'm back, got at least the basics of the GUI layed out so I've been picking away at functionality. First thing I want to do is search a directory (entered) and find all the potential/probable mediafiles underneath that directory.

Listing the contents of a folder seems simple enough, but is there a better way to get a recursive list of all files in a path than making my own recursive list function?

Second, it seems the easiest way to separate misc files from "mediafiles" is with a regular expression, something like: ".*VIDEO_TS.*|.*\.mpg|.*\.avi". However I've run into a roadblock on how to filter a list of files (File[]) with a regex.

Only way I can come up with is to loop over the File[] and match each entry with the regex and copy the new ones over. But that just seems horribly inelegant.

Any thoughts would be appreciated.
Reply With Quote
  #10  
Old 04-08-2007, 03:42 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
java.io.File has methods for returning filtered lists, given an object to do the filtering based either on filename (java.io.FilenameFilter) or File (java.io.FileFilter). In the latest version of my Studio Tools you'll find a class called REFilenameFilter that uses regular expressions to implement a FilenameFilter.

It's hard to believe this isn't a standard feature of the Java runtime, but when I Googled it I found everybody rolling their own, so that's what I did too.

You can either use the compiled class from my JAR, or just copy and paste the code into your own class:

Code:
import java.io.*;
import java.util.regex.*;

public class REFilenameFilter
  implements FilenameFilter
	{
	private Pattern pattern;
	
	/**
	 * Creates a new instance of REFilenameFilter.
	 * @param szPattern		The pattern to be matched.
	 */
	public REFilenameFilter(String szPattern)
		{
		this.pattern = Pattern.compile(szPattern);
		}
	
	/**
	 * Creates a new instance of REFilenameFilter.
	 * @param pattern		The pattern to be matched.
	 */
	public REFilenameFilter(Pattern pattern)
		{
		this.pattern = pattern;
		}

	/**
	 * Tests if a specified file should be included in a file list.
	 * 
	 * @param dir    the directory in which the file was found.
	 * @param name   the name of the file.
	 * @return <code>true</code> if and only if the name should be
	 * included in the file list; <code>false</code> otherwise.
	 */
	public boolean accept(File dir, String name)
		{
		return pattern.matcher(name).matches();
		}
	
	}
__________________
-- Greg
Reply With Quote
  #11  
Old 04-08-2007, 04:16 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Just tried that, and it works great (thanks), except, doing that ends up filtering the list before I recurse into subdirectories, and thus filters out all the subdirectories before I enter.
Reply With Quote
  #12  
Old 04-08-2007, 04:25 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Right, I forgot about that part. See DirFileFilter in my Tools package, or just copy the code below. This makes for a two-pass filtering process on each directory, one pass using REFilenameFilter to get the directly contained files, and another pass using DirFileFilter to get the subdirs for recursion.

Code:
import java.io.*;

public class DirFileFilter
  implements FileFilter
	{
	
	/**
	 * Tests whether or not the specified abstract pathname should be
	 * included in a pathname list.
	 * 
	 * @param pathname  The abstract pathname to be tested
	 * @return <code>true</code> if and only if <code>pathname</code>
	 *          should be included
	 */
	public boolean accept(File pathname)
		{
		return pathname.isDirectory();
		}
	
	}
__________________
-- Greg
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java question matrix35 General Discussion 0 12-04-2006 04:12 PM
Testing Sagetv with Java Access bridge nallan SageTV Software 0 04-01-2006 07:31 PM
Sage UI disappears during playback Keith SageTV Software 17 03-03-2006 03:31 AM
Good/Bad Versions of Sun JAVA Related to SageTV AWS General Discussion 6 11-10-2005 02:17 PM
Java problem with AwtToolkit Ctrl-Z SageTV Beta Test Software 0 11-01-2005 09:32 AM


All times are GMT -6. The time now is 06:10 PM.


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