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 10-10-2006, 04:00 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
New tools for Studio users

Some months back I posted my wishlist for new Studio features in which one of the items I wished for was this:

Quote:
Some sort of plugin interface for Studio so we can extend Studio's command set with our own Java code for searching and modifying the widget tree. This would involve three components: (1) a Java interface for registering Studio commands, (2) a set of API calls for getting/setting Studio state such as selection info and clean/dirty status, and (3) a way to signal Studio that widget properties have changed and need to be refreshed in the Studio window.
About a month ago I realized that I now know enough about how Java, Swing, and Studio work to make a stab at implementing this on my own. My preliminary experiments along these lines worked out pretty well and I've now got it to the point where I think it's ready for Beta-testing by the Studio user community.

Briefly, a Studio plugin is a Java class that implements the StudioPlugin interface. My plugin manager provides a simple UI for selecting plugins to load, loads those plugins into memory, adds their commands to the Studio menus, and implements a StudioAPI through which the plugins can access Studio UI state such as selection info and display refresh. A plugin can then use normal WidgetAPI calls to traverse the widget tree and make modifications to it.

Given that Studio was not designed with this in mind, finding the necessary hook points took some fairly invasive experimentation (which probably pushes the limits of the reverse-engineering clause of the SageTV EULA). However I've discussed it with Jeff by email and he's OK with the idea of releasing this code to the community. His hope is that this can all be legitimized someday by folding the plugin manager into the SageTV core.

In addition to the plugin manager, the tools package includes a sample plugin with several useful commands, plus a complete set of wrapper classes for the SageTV API.

You can download the package here. Source code and Javadocs are included. For setup and usage instructions, see the download page.

The bad news is that this package requires SageTV V6 (the new Beta) as well as Java version 1.5 or better. (I've been using the Java 1.6 release candidates.) Sorry about that, but I got hooked on the 1.5 language features (enum types, for-each iterations, generic collection types) pretty early, before the problems with 1.5 came to light, and it's too late for me to go back to 1.4.

Again, please consider this to be Beta-quality code. Feel free to play with it, but be on the lookout for any instability or other funny business. Make frequent backups of your STV, and check the results of plugin commands to make sure they haven't done anything nasty. I haven't had any disasters so far, but do be aware that this is all fairly new code.

One final note: because I haven't (yet) found a way to hook into Studio's Undo system, any edits made by Studio plugins are not undoable. So again, save often and make frequent backups.

Download page
__________________
-- Greg

Last edited by GKusnick; 10-20-2006 at 04:12 PM.
Reply With Quote
  #2  
Old 10-11-2006, 12:39 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Greg, this looks awesome, I can imagine that it opens up countless new possibilities for Studio programming. I wont be able to use it right now since the new 6.0 beta has problems with java 1.6 on my system, and I had to revert back to 1.4. But once I have my other dev machine available again I'll have a closer look. The description of the sample plugin alone makes me drool ...



Dirk
Reply With Quote
  #3  
Old 10-12-2006, 01:45 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
This is very cool. Anyone using the Studio should really check this out.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #4  
Old 10-12-2006, 07:21 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Hi Greg,

I just installed this and ran into the following problem: As soon as I bring up Studio, the options menu is popping up in the left upper corner, and as soon as I close it it automatically pops up again, preventing me from doing anything in Studio.

I see the following error repeatedly in the log:

Code:
New Studio frame found; hooking...

{ gkusnick.sagetv.studio.Inject.HookStudioFrame
  
  { gkusnick.sagetv.studio.Hook.FindTree
    Searching for CellRendererPane...
      Component sage.StudioFrame$1
      Component javax.swing.JScrollPane
        Component javax.swing.JViewport
          Component sage.e
            Component javax.swing.CellRendererPane
    Casting sage.e to JTree...
    Success.
    
    { gkusnick.sagetv.studio.Hook.InitClassWidget([java.lang.Object@138b5c6, default:Menu:MainMenu|Menu:Main Menu])
      oSelRoot = java.lang.Object@138b5c6
      classWidget = tv.sage.b.h
    } gkusnick.sagetv.studio.Hook.InitClassWidget
  
  } gkusnick.sagetv.studio.Hook.FindTree
  
  { gkusnick.sagetv.studio.Hook.FindMenus
    Searching for PopupMenu...
      Component javax.swing.JRootPane
        Component javax.swing.JPanel
        Component javax.swing.JLayeredPane
          Component javax.swing.JPanel
            Component sage.StudioFrame$1
            Component javax.swing.JScrollPane
              Component javax.swing.JViewport
                Component sage.e
                  Component javax.swing.CellRendererPane
              Component javax.swing.JScrollPane.ScrollBar
                Component javax.swing.plaf.metal.MetalScrollButton
                Component javax.swing.plaf.metal.MetalScrollButton
              Component javax.swing.JScrollPane.ScrollBar
                Component javax.swing.plaf.metal.MetalScrollButton
                Component javax.swing.plaf.metal.MetalScrollButton
            Component sage.b7
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component sage.b7.a
              Component javax.swing.Box.Filler
              Component javax.swing.JLabel
              Component javax.swing.Box.Filler
              Component javax.swing.JLabel
          Component javax.swing.JMenuBar
            Component javax.swing.JMenu
            Component javax.swing.JMenu
            Component javax.swing.JMenu
            Component javax.swing.JMenu
    Not found.
    Searching for Refresh item...
    Found item Refresh
    Searching for Highlight item...
    Hook failed.
    Exception chain:
      java.lang.NullPointerException
    Stack trace:
      gkusnick.sagetv.studio.Hook.MenuItemFind [Hook.java line 605]
      gkusnick.sagetv.studio.Hook.FindMenus [Hook.java line 575]
      gkusnick.sagetv.studio.Hook.<init> [Hook.java line 48]
      gkusnick.sagetv.studio.Inject.HookStudioFrame [Inject.java line 111]
      gkusnick.sagetv.studio.Inject.access$200 [Inject.java line 22]

} gkusnick.sagetv.studio.Inject.HookStudioFrame
Did I miss anything in the setup ? I am using 1.6 beta-2, if this matters ...

Dirk
Reply With Quote
  #5  
Old 10-12-2006, 07:35 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Jeff noticed the same bug. I rolled back to Java 1.5.0_05 and it started happening to me too.

Here's a JAR file with a fix that worked for me, although Jeff is still having issues. Let me know if it works for you (or not).

There's also a new menu command called List References, which I'll let you figure out for yourself.

I'll be out of touch from midday Friday until late Sunday. If any more issues crop up, I'll try to deal with them on Monday.

Edit: Removed attachment; see the download page for the latest version.
__________________
-- Greg

Last edited by GKusnick; 10-20-2006 at 04:16 PM.
Reply With Quote
  #6  
Old 10-12-2006, 07:44 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by GKusnick
Jeff noticed the same bug. I rolled back to Java 1.5.0_05 and it started happening to me too.

Here's a JAR file with a fix that worked for me, although Jeff is still having issues. Let me know if it works for you (or not).

There's also a new menu command called List References, which I'll let you figure out for yourself.

I'll be out of touch from midday Friday until late Sunday. If any more issues crop up, I'll try to deal with them on Monday.
Hi Greg,

unfortunately this fix doesn't work for me, I get the same behavior and error.
But no sweat, I can wait until next week ...

Dirk
Reply With Quote
  #7  
Old 10-12-2006, 08:12 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
OK, I think I figured it out. It wasn't a Java dependency, it was an STV dependency, which affected the initial scroll position of the widget tree in the Studio window. I've now fixed the code to compensate for that, instead of just assuming it was scrolled to the top.

I've updated the attachment in my previous post, so give it another whirl and see if that does it for you.
__________________
-- Greg
Reply With Quote
  #8  
Old 10-13-2006, 06:48 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by GKusnick
OK, I think I figured it out. It wasn't a Java dependency, it was an STV dependency, which affected the initial scroll position of the widget tree in the Studio window. I've now fixed the code to compensate for that, instead of just assuming it was scrolled to the top.

I've updated the attachment in my previous post, so give it another whirl and see if that does it for you.
Greg, this finally fixed it !

I don't know what to say, my jaws are still dropped ... This is *so* awesome. I can't even imagine how much time and design work you must have put into this framework, it looks very well-founded. And the sample plugin already fullfills some of my dreams - finally being able to only search a subtree , and the reference list is just plain incredible.

This will make Studio development *so* much more efficient, thank you very much. I really expect this to become part of the Sage core, I'm sure Jeff will agree


Dirk
Reply With Quote
  #9  
Old 10-14-2006, 11:37 AM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Now that it works for me...SUPER COOL

Very useful stuff here and LOTS of options for extending it to do much more.

First feature request for your plugin. Can you select the widget types to search on? (sorry, couldn't resist )
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #10  
Old 10-14-2006, 02:56 PM
BobPhoenix BobPhoenix is offline
SageTVaholic
 
Join Date: Oct 2004
Posts: 3,152
Thank you very much for this The replace function was enough to make me want to install it. Of course with the plugin interface I have an even greater desire to learn Java now.
Reply With Quote
  #11  
Old 10-15-2006, 07:06 PM
evilpenguin's Avatar
evilpenguin evilpenguin is offline
SageTVaholic
 
Join Date: Aug 2003
Location: Seattle, WA
Posts: 3,696
Great work Having two Studio windows open is so handy. Thanks!
__________________
Clients: 1xHD200 Connected to 50" TH-50PZ750U Plasma
Server : Shuttle SFF SSH55J2 w/ Win7 Home, SageTV v7, Core i3 540, 2GB RAM, 30GB SSD for OS, 1.5TB+2x1TB WDGP for Recordings, BluRay, 2xHDHR, 1xFirewire
SageTV : PlayOn, SJQ, MediaShrink, Comskip, Jetty, Web Client, BMT


Having a problem? Don't forget to include a log! (Instructions for: PlayOn For SageTV v1.5, MediaShrink)
Reply With Quote
  #12  
Old 10-15-2006, 07:17 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by evilpenguin
Having two Studio windows open is so handy.
I agree, but I can't take any credit for that. Launch Another Frame is a core feature of V6, not of my plugin framework.

Glad you all were able to get it working and find some use for it. I was part of an IDE design team on my last job, so I've been thinking of ways to improve Studio since I first started using it. Now I can finally start implementing some of them. (And so can you!)
__________________
-- Greg
Reply With Quote
  #13  
Old 10-20-2006, 04:13 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I've uploaded version 0.2 of my Studio Tools package. This update includes the popup menu fix and List References command you've already seen in the patch, plus various other new goodies:

* Jeff's search-by-widget-type feature.
* Copy Widget Name, Copy Widget Path, and Set as Non-Primary commands.
* Drag & drop to reorder plugins in the Manage... dialog.
* A couple of new WidgetAPI extension functions.
* Various minor bug fixes.

See the version history in the included Javadocs for full details.

Click here to download (or use the link in the original post).
__________________
-- Greg
Reply With Quote
  #14  
Old 10-21-2006, 08:46 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by GKusnick
I've uploaded version 0.2 of my Studio Tools package. This update includes the popup menu fix and List References command you've already seen in the patch, plus various other new goodies:

* Jeff's search-by-widget-type feature.
* Copy Widget Name, Copy Widget Path, and Set as Non-Primary commands.
* Drag & drop to reorder plugins in the Manage... dialog.
* A couple of new WidgetAPI extension functions.
* Various minor bug fixes.

See the version history in the included Javadocs for full details.

Click here to download (or use the link in the original post).
Great new features, especially the search by widget . May I suggest something (I know this is a tool for dev's to write their own plugins, but so little time right now ... ): after cutting/copying a widget, insert before or after a certain widget. Having to hit ctrl-u 47 times sometimes gets a bit boring ...

On another note, I got the obscure 'options menu always popping up' again (last version and new version). After I deleted all Studio entries from the property file, it started up fine again. Here are the entries which were causing the issue for me, it might help you to diagnose the problem

Code:
studio/autosave_interval=180000
studio/breakpoints_file=Breakpoints.properties
studio/chain_type_highlight_size=8
studio/check=
studio/code_font=Monospaced
studio/diff_win_pos_h=181
studio/diff_win_pos_w=1086
studio/diff_win_pos_x=42
studio/diff_win_pos_y=16
studio/discard_mouse_events=false
studio/enable_tracer=true
studio/horizontal_scrolling=true
studio/plugins=gkusnick.sagetv.studio.Tools
studio/scroll_tracks_tracer=false
studio/show_expand_all_nodes=false
studio/text_font=Times New Roman
studio/trace_depth=1000
studio/tracer_col_width/0=87
studio/tracer_col_width/1=87
studio/tracer_col_width/2=87
studio/tracer_col_width/3=87
studio/tracer_col_width/4=87
studio/tracer_win_pos_h=453
studio/tracer_win_pos_w=461
studio/tracer_win_pos_x=2
studio/tracer_win_pos_y=-3
studio/uicomps_win_pos_h=517
studio/uicomps_win_pos_w=388
studio/uicomps_win_pos_x=14
studio/uicomps_win_pos_y=7
studio_undo_depth=100
studio_win_pos_h=465
studio_win_pos_w=1220
studio_win_pos_x=2
studio_win_pos_y=518
Dirk
Reply With Quote
  #15  
Old 10-22-2006, 02:08 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Thanks; those properties helped a lot in tracking it down. It turns out my fake-right-click hack for finding the popup menu doesn't work properly if the menu is taller than the Studio window. Don't ask me why.

If this happens and you find yourself stuck in persistent popup mode, I've found that you can escape it by just clicking the maximize button in the upper right corner of the Studio window. Once the popup goes away and the Plugins menu appears on the menubar, you can then restore the window back to whatever size you like and carry on normally.

I'll add some code for the next version to try to avoid the problem by forcibly enlarging the window if necessary before doing my popup initialization.

The paste before/after idea is a good one. I'll have to think about how it might be done. I'm not seeing any obvious way to get at the cut/copy selection using standard Swing APIs, but I'll do some more poking around just to be sure.
__________________
-- Greg
Reply With Quote
  #16  
Old 12-23-2006, 11:17 AM
alon24 alon24 is offline
Sage Aficionado
 
Join Date: Jun 2004
Posts: 351
I would like to say that your plugin is BRILIANT!!!

I like the idea that I can add to stuio itself, and make it more friendly.

Could you add to the search, a little JFrame which will hold the refrences to the locations of the search string.

Kinda like the find refrences, where u list all refrences in a window and can jump to them.

I just hate searching and then loosing sight of all the places , and trying to look for the correct one.

A simple addition to your search to incorparate this, should be easy to do.
Thanks,
Alon24
__________________
Server
SageTv 6.3.5, Core2Duo 6300 ,2Gigs ,Saphire x1650, PVR250, 2*320GB + 160GB, java 1.6.1
Client
SageTV Client 6.3.5 , AMD 3000, 1024Mb, Saphire x1600Pro256HDMI, java 1.6.1

Using Nielm's Web server 2.22
Reply With Quote
  #17  
Old 12-28-2006, 04:52 PM
alon24 alon24 is offline
Sage Aficionado
 
Join Date: Jun 2004
Posts: 351
ok, so i started adding to your Framework, and its going nice.

I simply copied your code for search and am showing the results in a frame (like the refview)

any ideas about creating the copy to this location that was asked before?? (copy and then paste to the same place as the current widget)???

If anybody wants my (Very Very) simple addition to the search, please say and I will add it.
__________________
Server
SageTv 6.3.5, Core2Duo 6300 ,2Gigs ,Saphire x1650, PVR250, 2*320GB + 160GB, java 1.6.1
Client
SageTV Client 6.3.5 , AMD 3000, 1024Mb, Saphire x1600Pro256HDMI, java 1.6.1

Using Nielm's Web server 2.22
Reply With Quote
  #18  
Old 12-28-2006, 05:47 PM
alon24 alon24 is offline
Sage Aficionado
 
Join Date: Jun 2004
Posts: 351
request

Could you add a way to get the JTree, and Menus, so we can use them
getStudioTree()
getStudioMenuBar()


also can expose (public) the ComponentFind and MenuItemFind functions??

I would like to use those to add stuff, (copy paste and other stuff).

Thanks,
Alon24
__________________
Server
SageTv 6.3.5, Core2Duo 6300 ,2Gigs ,Saphire x1650, PVR250, 2*320GB + 160GB, java 1.6.1
Client
SageTV Client 6.3.5 , AMD 3000, 1024Mb, Saphire x1600Pro256HDMI, java 1.6.1

Using Nielm's Web server 2.22
Reply With Quote
  #19  
Old 12-28-2006, 07:20 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
It's been in the back of my mind to add a search list analogous to the reference list, which would dynamically update itself as you edit. But I haven't got around to doing anything with that yet.

The problem with Paste Before/After is figuring out what to paste. As far as I can tell the Move/Copy marquee selection is internal to the Studio machinery and is not accessible through AWT/Swing.

Something that might be done instead is a sort of block up/down command in which you select a range of consecutive widgets and move them up or down as a unit. So instead of moving the recently pasted widget up ten times, you could select the previous ten widgets and move them all down one. But again, I haven't had time to get into that.

The question of how much to expose is a tricky one. I wanted to be fairly conservative at first, and provide just enough hooks to be useful, rather than hooking out everything under the sun. Remember that the goal is to get the hooks integrated in the core at some point with some clean API for accessing them. From that point of view, groveling around in the component and menu hierarchies is probably not something that plugins should be doing; that sort of thing is best kept quarantined on the core side of the API. We don't want plugins breaking because of some implementation change in the core. That's why I've tried to factor the code into "hook" code that does all the groveling and will eventually get absorbed into the core, and "plugin" code that does everything through the StudioAPI.

If there's something in particular you'd like to see added to the StudioAPI that doesn't require exposing specific Swing/AWT components, I'm happy to add it (subject to Jeff's approval of course). But I think it's best if plugins regard the StudioAPI as a black box and make no assumptions about the underlying component structures.
__________________
-- Greg
Reply With Quote
  #20  
Old 12-29-2006, 12:09 AM
alon24 alon24 is offline
Sage Aficionado
 
Join Date: Jun 2004
Posts: 351
if you can hook a kelistener to the JTree, you would know when a user pressed,ctrl+c or Ctrl+V... and then u can check selected, and remember it for yourself.
also since u can hook to the cut and paste menu, that could be good also and you can know when the user clicked it, and figure our what to copy, paste.

since you are taking note of the widegets, there should be no problem to figure which widget is selected and copy/copy refrence to there.

what do u think?
__________________
Server
SageTv 6.3.5, Core2Duo 6300 ,2Gigs ,Saphire x1650, PVR250, 2*320GB + 160GB, java 1.6.1
Client
SageTV Client 6.3.5 , AMD 3000, 1024Mb, Saphire x1600Pro256HDMI, java 1.6.1

Using Nielm's Web server 2.22
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 12:58 PM.


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