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

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.pluginsimpl.UISWTInstanceImpl
All Implemented Interfaces:
UIInstance, UIInstanceFactory, UIManagerEventListener, UIInstanceBase, UISWTInstance

public class UISWTInstanceImpl
extends java.lang.Object
implements UIInstanceFactory, UISWTInstance, UIManagerEventListener


Nested Class Summary
protected static class UISWTInstanceImpl.instanceWrapper
           
static interface UISWTInstanceImpl.SWTViewListener
           
 
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
 
Constructor Summary
UISWTInstanceImpl()
           
 
Method Summary
 void addSWTViewListener(UISWTInstanceImpl.SWTViewListener l)
           
 void addView(PluginInterface pi, java.lang.String sParentID, java.lang.String sViewID, java.lang.Class<? extends UISWTViewEventListener> cla, java.lang.Object datasource)
           
 void addView(java.lang.String sParentID, java.lang.String sViewID, java.lang.Class<? extends UISWTViewEventListener> cla, java.lang.Object datasource)
          Add a view to an Azureus parent view.
 void addView(java.lang.String sParentID, java.lang.String sViewID, UISWTViewEventListener l)
          Add a detail view to an Azureus parent view.
 void addView(java.lang.String sParentID, java.lang.String sViewID, UISWTViewEventListenerHolder holder)
           
 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.
 void detach()
          This method will be called by the UI manager when detaching the UI to permit the action to be vetoed/any detach logic to occur.
 boolean eventOccurred(UIManagerEvent event)
          Return true if the event has been handled
 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.
 UIInstance getInstance(PluginInterface plugin_interface)
          Some UI instances need to understand which plugin they are associated with.
 UISWTView[] getOpenViews(java.lang.String sParentID)
          Get a list of views currently open on the specified VIEW_* view
 UIToolBarManager getToolBarManager()
           
 int getUIType()
           
 UISWTViewEventListenerHolder[] getViewListeners(java.lang.String sParentID)
           
 void init(IUIIntializer init)
           
 org.eclipse.swt.graphics.Image loadImage(java.lang.String resource)
           
 void openConfig(BasicPluginConfigModel model)
          Opens the window linked to a given BasicPluginViewModel object.
 void openMainView(PluginInterface pi, java.lang.String sViewID, UISWTViewEventListener l, java.lang.Object dataSource)
           
 void openMainView(PluginInterface pi, java.lang.String sViewID, UISWTViewEventListener _l, java.lang.Object dataSource, boolean setfocus)
           
 void openMainView(java.lang.String sViewID, UISWTViewEventListener l, java.lang.Object dataSource)
          Create and open a view in the main window immediately.
 void openMainView(java.lang.String sViewID, UISWTViewEventListener l, java.lang.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(java.lang.String sParentID, java.lang.String sViewID, java.lang.Object dataSource)
          Open a previously added view
 boolean openView(java.lang.String sParentID, java.lang.String sViewID, java.lang.Object dataSource, boolean setfocus)
          Open a previously added view
 int promptUser(java.lang.String title, java.lang.String text, java.lang.String[] options, int defaultOption)
          Prompts the user with a title, text, and a series of options.
 void removeSWTViewListener(UISWTInstanceImpl.SWTViewListener l)
           
 void removeViews(java.lang.String sParentID, java.lang.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

public UISWTInstanceImpl()
Method Detail

getUIType

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

init

public void init(IUIIntializer init)

getInstance

public UIInstance getInstance(PluginInterface plugin_interface)
Description copied from interface: UIInstanceFactory
Some UI instances need to understand which plugin they are associated with. This method gives the opportunity to customise the UIInstance returned to a plugin so that operations on it can take the appropriate actions

Specified by:
getInstance in interface UIInstanceFactory

eventOccurred

public boolean eventOccurred(UIManagerEvent event)
Description copied from interface: UIManagerEventListener
Return true if the event has been handled

Specified by:
eventOccurred in interface UIManagerEventListener
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(java.lang.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

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:

detach

public void detach()
            throws UIException
Description copied from interface: UIInstanceFactory
This method will be called by the UI manager when detaching the UI to permit the action to be vetoed/any detach logic to occur. It should not be directly called by the plugin code

Specified by:
detach in interface UIInstanceFactory
Throws:
UIException

addView

public void addView(java.lang.String sParentID,
                    java.lang.String sViewID,
                    java.lang.Class<? extends UISWTViewEventListener> cla,
                    java.lang.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

addView

public void addView(PluginInterface pi,
                    java.lang.String sParentID,
                    java.lang.String sViewID,
                    java.lang.Class<? extends UISWTViewEventListener> cla,
                    java.lang.Object datasource)

addView

public void addView(java.lang.String sParentID,
                    java.lang.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(java.lang.String sParentID,
                    java.lang.String sViewID,
                    UISWTViewEventListenerHolder holder)

addSWTViewListener

public void addSWTViewListener(UISWTInstanceImpl.SWTViewListener l)

removeSWTViewListener

public void removeSWTViewListener(UISWTInstanceImpl.SWTViewListener l)

removeViews

public void removeViews(java.lang.String sParentID,
                        java.lang.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

openView

public boolean openView(java.lang.String sParentID,
                        java.lang.String sViewID,
                        java.lang.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(java.lang.String sParentID,
                        java.lang.String sViewID,
                        java.lang.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

openMainView

public void openMainView(java.lang.String sViewID,
                         UISWTViewEventListener l,
                         java.lang.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(PluginInterface pi,
                         java.lang.String sViewID,
                         UISWTViewEventListener l,
                         java.lang.Object dataSource)

openMainView

public void openMainView(java.lang.String sViewID,
                         UISWTViewEventListener l,
                         java.lang.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.

openMainView

public void openMainView(PluginInterface pi,
                         java.lang.String sViewID,
                         UISWTViewEventListener _l,
                         java.lang.Object dataSource,
                         boolean setfocus)

getOpenViews

public UISWTView[] getOpenViews(java.lang.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(java.lang.String title,
                      java.lang.String text,
                      java.lang.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

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.

getViewListeners

public UISWTViewEventListenerHolder[] getViewListeners(java.lang.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

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

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