org.gudy.azureus2.ui.swt.pluginsimpl
Class UISWTInstanceImpl.instanceWrapper

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.pluginsimpl.UISWTInstanceImpl.instanceWrapper
All Implemented Interfaces:
UIToolBarManager, UIInstance, UIInstanceBase, UISWTInstance
Enclosing class:
UISWTInstanceImpl

protected static class UISWTInstanceImpl.instanceWrapper
extends Object
implements UISWTInstance, UIToolBarManager


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gudy.azureus2.ui.swt.plugins.UISWTInstance
UISWTInstance.UISWTViewEventListenerWrapper
 
Field Summary
 
Fields inherited from interface org.gudy.azureus2.ui.swt.plugins.UISWTInstance
VIEW_CONFIG, VIEW_MAIN, VIEW_MYTORRENTS, VIEW_SIDEBAR_AREA, VIEW_STATISTICS, VIEW_TOPBAR, VIEW_TORRENT_DETAILS, VIEW_TORRENT_FILES, VIEW_TORRENT_PEERS, VIEW_TORRENT_PIECES
 
Fields inherited from interface org.gudy.azureus2.plugins.ui.UIInstance
UIT_CONSOLE, UIT_SWT
 
Fields inherited from interface org.gudy.azureus2.plugins.ui.toolbar.UIToolBarManager
GROUP_BIG, GROUP_MAIN
 
Constructor Summary
protected UISWTInstanceImpl.instanceWrapper(PluginInterface _pi, UIFunctionsSWT _ui_functions, UISWTInstanceImpl _delegate)
           
 
Method Summary
 void addToolBarItem(UIToolBarItem item)
          Adds a UIToolBarItem to the UI.
 void addView(String sParentID, String sViewID, Class<? extends UISWTViewEventListener> cla, Object datasource)
          Add a view to an Azureus parent view.
 void addView(String sParentID, String sViewID, UISWTViewEventListener l)
          Add a detail view to an Azureus parent view.
 UISWTGraphic createGraphic(org.eclipse.swt.graphics.Image img)
          Creates an UISWTGraphic object with the supplied SWT Image
 UIMessage createMessage()
          Creates a UIMessage instance to allow a plugin to inform or ask the user something.
 org.eclipse.swt.widgets.Shell createShell(int style)
          Creates a SWT Shell, ensuring Vuze knows about it (ie.
 UISWTStatusEntry createStatusEntry()
          Creates an entry in the status bar to display custom status information.
 UIToolBarItem createToolBarItem(String id)
          Create a new UIToolBarItem.
 void detach()
           
 UIToolBarItem[] getAllToolBarItems()
           
 org.eclipse.swt.widgets.Display getDisplay()
          Retrieve the SWT Display object that Azureus uses (when in SWT mode).
 UIInputReceiver getInputReceiver()
          Creates a UIInputReceiver instance to allow a plugin to request text input from the user.
 UISWTView[] getOpenViews(String sParentID)
          Get a list of views currently open on the specified VIEW_* view
 UIToolBarItem getToolBarItem(String id)
           
 UIToolBarManager getToolBarManager()
           
 int getUIType()
           
 UISWTInstance.UISWTViewEventListenerWrapper[] getViewListeners(String sParentId)
           
 org.eclipse.swt.graphics.Image loadImage(String resource)
           
 void openConfig(BasicPluginConfigModel model)
          Opens the window linked to a given BasicPluginViewModel object.
 void openMainView(String sViewID, UISWTViewEventListener l, Object dataSource)
          Create and open a view in the main window immediately.
 void openMainView(String sViewID, UISWTViewEventListener l, Object dataSource, boolean setfocus)
          Create and open a view in the main window immediately.
 boolean openView(BasicPluginViewModel model)
          Opens the window linked to a given BasicPluginViewModel object.
 boolean openView(String sParentID, String sViewID, Object dataSource)
          Open a previously added view
 boolean openView(String sParentID, String sViewID, Object dataSource, boolean setfocus)
          Open a previously added view
 int promptUser(String title, String text, String[] options, int defaultOption)
          Prompts the user with a title, text, and a series of options.
 void removeToolBarItem(String id)
           
 void removeViews(String sParentID, String sViewID)
          Remove all views that belong to a specific parent and of a specific View ID.
 void showDownloadBar(Download download, boolean display)
          Shows or hides a download bar for a given download.
 void showTransfersBar(boolean display)
          Shows or hides the transfers bar.
 void unload(PluginInterface pi)
          PluginInterface is unloading..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UISWTInstanceImpl.instanceWrapper

protected UISWTInstanceImpl.instanceWrapper(PluginInterface _pi,
                                            UIFunctionsSWT _ui_functions,
                                            UISWTInstanceImpl _delegate)
Method Detail

getToolBarItem

public UIToolBarItem getToolBarItem(String id)
Specified by:
getToolBarItem in interface UIToolBarManager

getAllToolBarItems

public UIToolBarItem[] getAllToolBarItems()
Specified by:
getAllToolBarItems in interface UIToolBarManager

createToolBarItem

public UIToolBarItem createToolBarItem(String id)
Description copied from interface: UIToolBarManager
Create a new UIToolBarItem. You will still need to add it via UIToolBarManager.addToolBarItem(UIToolBarItem), after setting the item's properties

Specified by:
createToolBarItem in interface UIToolBarManager
Parameters:
id - unique id
Returns:
newly created toolbar

addToolBarItem

public void addToolBarItem(UIToolBarItem item)
Description copied from interface: UIToolBarManager
Adds a UIToolBarItem to the UI. Make sure you at least set the icon before adding

Specified by:
addToolBarItem in interface UIToolBarManager

removeToolBarItem

public void removeToolBarItem(String id)
Specified by:
removeToolBarItem in interface UIToolBarManager

detach

public void detach()
            throws UIException
Throws:
UIException

getUIType

public int getUIType()
Specified by:
getUIType in interface UIInstance
Returns:

getDisplay

public org.eclipse.swt.widgets.Display getDisplay()
Description copied from interface: UISWTInstance
Retrieve the SWT Display object that Azureus uses (when in SWT mode). If you have a thread that does some periodic/asynchronous stuff, Azureus will crashes with and 'InvalidThreadAccess' exception unless you embed your calls in a Runnable, and use getDisplay().aSyncExec(Runnable r);

Specified by:
getDisplay in interface UISWTInstance
Returns:
SWT Display object that Azureus uses

loadImage

public org.eclipse.swt.graphics.Image loadImage(String resource)
Specified by:
loadImage in interface UISWTInstance

createGraphic

public UISWTGraphic createGraphic(org.eclipse.swt.graphics.Image img)
Description copied from interface: UISWTInstance
Creates an UISWTGraphic object with the supplied SWT Image

Specified by:
createGraphic in interface UISWTInstance
Parameters:
img - Image to assign to the object
Returns:
a new UISWTGraphic object

addView

public void addView(String sParentID,
                    String sViewID,
                    UISWTViewEventListener l)
Description copied from interface: UISWTInstance
Add a detail view to an Azureus parent view. For views added to the Main window, this adds a menu option. For the other parent views, this adds a new tab within Azureus' own detail view.

Specified by:
addView in interface UISWTInstance
Parameters:
sParentID - VIEW_* constant
sViewID - of your view. Used as part of the resource id.
"Views.plugins." + ID + ".title" = title of your view
l - Listener to be triggered when parent view wants to tell you an event has happened

addView

public void addView(String sParentID,
                    String sViewID,
                    Class<? extends UISWTViewEventListener> cla,
                    Object datasource)
Description copied from interface: UISWTInstance
Add a view to an Azureus parent view. For views added to the UISWTInstance.VIEW_MAIN window, this adds a menu option.

In comparison to UISWTInstance.addView(String, String, UISWTViewEventListener), this method saves memory by not creating the UISWTViewEventListener until it is needed. It also ensures that only one UISWTViewEvent.TYPE_CREATE event is triggered per instance.

Specified by:
addView in interface UISWTInstance
Parameters:
sParentID - VIEW_* constant
sViewID - of your view. Used as part of the resource id.
"Views.plugins." + ID + ".title" = title of your view
cla - Class of the Listener to be created and triggered

openMainView

public void openMainView(String sViewID,
                         UISWTViewEventListener l,
                         Object dataSource)
Description copied from interface: UISWTInstance
Create and open a view in the main window immediately. If you are calling this from UIManagerListener.UIAttached(UIInstance), the view will not gain focus.

Tip: You can add a menu item to a table view, and when triggered, have it open a new window, passing the datasources that were selected

Specified by:
openMainView in interface UISWTInstance
Parameters:
sViewID - ID to give your view
l - Listener to be triggered when View Events occur
dataSource - objects to set UISWTView.getDataSource() with

openMainView

public void openMainView(String sViewID,
                         UISWTViewEventListener l,
                         Object dataSource,
                         boolean setfocus)
Description copied from interface: UISWTInstance
Create and open a view in the main window immediately. If you are calling this from UIManagerListener.UIAttached(UIInstance), the view will not gain focus.

Tip: You can add a menu item to a table view, and when triggered, have it open a new window, passing the datasources that were selected

Specified by:
openMainView in interface UISWTInstance
Parameters:
sViewID - ID to give your view
l - Listener to be triggered when View Events occur
dataSource - objects to set UISWTView.getDataSource() with
setfocus - true if you want to display the view immediately, false if you want to display it in the background.

removeViews

public void removeViews(String sParentID,
                        String sViewID)
Description copied from interface: UISWTInstance
Remove all views that belong to a specific parent and of a specific View ID. If the parent is the main window, the menu item will be removed.
If you wish to remove (close) just one view, use UIPluginView.closeView()

Specified by:
removeViews in interface UISWTInstance
Parameters:
sParentID - One of VIEW_* constants
sViewID - View ID to remove

getOpenViews

public UISWTView[] getOpenViews(String sParentID)
Description copied from interface: UISWTInstance
Get a list of views currently open on the specified VIEW_* view

Specified by:
getOpenViews in interface UISWTInstance
Parameters:
sParentID - VIEW_* constant
Returns:
list of views currently open

promptUser

public int promptUser(String title,
                      String text,
                      String[] options,
                      int defaultOption)
Description copied from interface: UIInstance
Prompts the user with a title, text, and a series of options. The options are typically displayed as buttons.

Specified by:
promptUser in interface UIInstance
Returns:
Index of option chosen, -1 if cancelled or error

openView

public boolean openView(String sParentID,
                        String sViewID,
                        Object dataSource)
Description copied from interface: UISWTInstance
Open a previously added view

Specified by:
openView in interface UISWTInstance
Parameters:
sParentID - ParentID of the view to be shown
sViewID - id of the view to be shown
dataSource - any data you need to pass the view
Returns:
success level

openView

public boolean openView(String sParentID,
                        String sViewID,
                        Object dataSource,
                        boolean setfocus)
Description copied from interface: UISWTInstance
Open a previously added view

Specified by:
openView in interface UISWTInstance
Parameters:
sParentID - ParentID of the view to be shown
sViewID - id of the view to be shown
dataSource - any data you need to pass the view
setfocus - true if you want to display the view immediately, false if you want to display it in the background.
Returns:
success level

getViewListeners

public UISWTInstance.UISWTViewEventListenerWrapper[] getViewListeners(String sParentId)
Specified by:
getViewListeners in interface UISWTInstance

getInputReceiver

public UIInputReceiver getInputReceiver()
Description copied from interface: UIInstance
Creates a UIInputReceiver instance to allow a plugin to request text input from the user. Some interfaces may not allow or support the ability for a plugin to request text input from a user, in which case they will return null for this method.

Specified by:
getInputReceiver in interface UIInstance

createMessage

public UIMessage createMessage()
Description copied from interface: UIInstance
Creates a UIMessage instance to allow a plugin to inform or ask the user something. Some interfaces may not allow or support the ability for a plugin to ask a user in this manner, in which case they will return null for this method.

Specified by:
createMessage in interface UIInstance

showDownloadBar

public void showDownloadBar(Download download,
                            boolean display)
Description copied from interface: UISWTInstance
Shows or hides a download bar for a given download.

Specified by:
showDownloadBar in interface UISWTInstance
Parameters:
download - Download to use.
display - true to show a download bar, false to hide it.

showTransfersBar

public void showTransfersBar(boolean display)
Description copied from interface: UISWTInstance
Shows or hides the transfers bar.

Specified by:
showTransfersBar in interface UISWTInstance
Parameters:
display - true to show the bar, false to hide it.

createStatusEntry

public UISWTStatusEntry createStatusEntry()
Description copied from interface: UISWTInstance
Creates an entry in the status bar to display custom status information.

Specified by:
createStatusEntry in interface UISWTInstance
See Also:
UISWTStatusEntry

openView

public boolean openView(BasicPluginViewModel model)
Description copied from interface: UISWTInstance
Opens the window linked to a given BasicPluginViewModel object.

Specified by:
openView in interface UIInstance
Specified by:
openView in interface UISWTInstance
Returns:
true if the view was opened successfully.

openConfig

public void openConfig(BasicPluginConfigModel model)
Description copied from interface: UISWTInstance
Opens the window linked to a given BasicPluginViewModel object.

Specified by:
openConfig in interface UISWTInstance

createShell

public org.eclipse.swt.widgets.Shell createShell(int style)
Description copied from interface: UISWTInstance
Creates a SWT Shell, ensuring Vuze knows about it (ie. Icon, "Window" menu)

Specified by:
createShell in interface UISWTInstance
Returns:

getToolBarManager

public UIToolBarManager getToolBarManager()
Specified by:
getToolBarManager in interface UIInstance

unload

public void unload(PluginInterface pi)
Description copied from interface: UIInstanceBase
PluginInterface is unloading.. destroy anything related to it

Specified by:
unload in interface UIInstanceBase