Package com.biglybt.ui.swt.pifimpl
Class UISWTInstanceImpl.instanceWrapper
- java.lang.Object
-
- com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.instanceWrapper
-
- All Implemented Interfaces:
UIToolBarManager
,UIInstance
,UIInstanceBase
,UISWTInstance
- Enclosing class:
- UISWTInstanceImpl
protected static class UISWTInstanceImpl.instanceWrapper extends java.lang.Object implements UISWTInstance, UIToolBarManager, UIInstanceBase
-
-
Field Summary
Fields Modifier and Type Field Description private UISWTInstanceImpl
delegate
private java.util.List<org.eclipse.swt.graphics.Resource>
listDisposeOnUnload
private java.util.List<UIToolBarItem>
listItems
private java.lang.ref.WeakReference<PluginInterface>
pi_ref
private UIToolBarManagerCore
toolBarManager
private UIFunctionsSWT
ui_functions
-
Fields inherited from interface com.biglybt.pif.ui.UIInstance
UIT_CONSOLE, UIT_SWT
-
Fields inherited from interface com.biglybt.ui.swt.pif.UISWTInstance
VIEW_MAIN, VIEW_MYTORRENTS, VIEW_SIDEBAR_AREA, VIEW_STATISTICS, VIEW_TOPBAR, VIEW_TORRENT_DETAILS, VIEW_TORRENT_PEERS
-
Fields inherited from interface com.biglybt.pif.ui.toolbar.UIToolBarManager
GROUP_BIG, GROUP_MAIN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
instanceWrapper(PluginInterface _pi, UIFunctionsSWT _ui_functions, UISWTInstanceImpl _delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addToolBarItem(UIToolBarItem item)
Adds aUIToolBarItem
to the UI.void
addView(java.lang.String sParentViewID, java.lang.String sViewID, UISWTViewEventListener l)
Deprecated.void
addView(java.lang.String sParentViewID, java.lang.String sViewID, java.lang.Class<? extends UISWTViewEventListener> cla, java.lang.Object datasource)
Add a view to an Apps parent view.UISWTGraphic
createGraphic(org.eclipse.swt.graphics.Image img)
Creates an UISWTGraphic object with the supplied SWT ImageUIMessage
createMessage()
Creates aUIMessage
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(java.lang.String id)
Create a newUIToolBarItem
.UISWTViewBuilder
createViewBuilder(java.lang.String viewID)
Creates an object representing how your view is to be created.UISWTViewBuilder
createViewBuilder(java.lang.String viewID, java.lang.Class<? extends UISWTViewEventListener> cla)
Creates an object representing how your view is to be createdvoid
detach()
UIToolBarItem[]
getAllToolBarItems()
org.eclipse.swt.widgets.Display
getDisplay()
Retrieve the SWT Display object that Azureus uses (when in SWT mode).UIInputReceiver
getInputReceiver()
Creates aUIInputReceiver
instance to allow a plugin to request text input from the user.UISWTView[]
getOpenViews(java.lang.String sParentID)
Get a list of views currently open on the specified VIEW_* viewUIToolBarItem
getToolBarItem(java.lang.String id)
UIToolBarManager
getToolBarManager()
java.lang.String
getUIType()
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(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 viewboolean
openView(java.lang.String forViewID, java.lang.String sViewID, java.lang.Object dataSource, boolean setfocus)
Open a previously added viewint
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
promptUser(java.lang.String title, java.lang.String text, java.lang.String[] options, int defaultOption, UIMessageListener listener)
Prompts the user with a title, text, and a series of options.void
registerView(java.lang.Class forDataSourceType, UISWTViewBuilder viewBuilder)
Register a view that will be created when a certain datasource type is displayedvoid
registerView(java.lang.String forViewID, UISWTViewBuilder viewBuilder)
Register a view that will be created when the specified view is displayedvoid
removeToolBarItem(java.lang.String id)
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..void
unregisterView(java.lang.Class forDataSourceType, java.lang.String viewID)
Unregister and dispose of any previously created views of this viewIDvoid
unregisterView(java.lang.String forViewID, java.lang.String viewID)
Unregister and dispose of any previously created views of this viewID
-
-
-
Field Detail
-
pi_ref
private java.lang.ref.WeakReference<PluginInterface> pi_ref
-
ui_functions
private UIFunctionsSWT ui_functions
-
delegate
private UISWTInstanceImpl delegate
-
toolBarManager
private UIToolBarManagerCore toolBarManager
-
listItems
private java.util.List<UIToolBarItem> listItems
-
listDisposeOnUnload
private java.util.List<org.eclipse.swt.graphics.Resource> listDisposeOnUnload
-
-
Constructor Detail
-
instanceWrapper
protected instanceWrapper(PluginInterface _pi, UIFunctionsSWT _ui_functions, UISWTInstanceImpl _delegate)
-
-
Method Detail
-
getToolBarItem
public UIToolBarItem getToolBarItem(java.lang.String id)
- Specified by:
getToolBarItem
in interfaceUIToolBarManager
-
getAllToolBarItems
public UIToolBarItem[] getAllToolBarItems()
- Specified by:
getAllToolBarItems
in interfaceUIToolBarManager
-
createToolBarItem
public UIToolBarItem createToolBarItem(java.lang.String id)
Description copied from interface:UIToolBarManager
Create a newUIToolBarItem
. You will still need to add it viaUIToolBarManager.addToolBarItem(UIToolBarItem)
, after setting the item's properties- Specified by:
createToolBarItem
in interfaceUIToolBarManager
- Parameters:
id
- unique id- Returns:
- newly created toolbar
-
addToolBarItem
public void addToolBarItem(UIToolBarItem item)
Description copied from interface:UIToolBarManager
Adds aUIToolBarItem
to the UI. Make sure you at least set the icon before adding- Specified by:
addToolBarItem
in interfaceUIToolBarManager
-
removeToolBarItem
public void removeToolBarItem(java.lang.String id)
- Specified by:
removeToolBarItem
in interfaceUIToolBarManager
-
detach
public void detach() throws UIException
- Throws:
UIException
-
getUIType
public java.lang.String getUIType()
- Specified by:
getUIType
in interfaceUIInstance
- 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 interfaceUISWTInstance
- Returns:
- SWT Display object that Azureus uses
-
loadImage
public org.eclipse.swt.graphics.Image loadImage(java.lang.String resource)
- Specified by:
loadImage
in interfaceUISWTInstance
-
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 interfaceUISWTInstance
- Parameters:
img
- Image to assign to the object- Returns:
- a new UISWTGraphic object
-
addView
@Deprecated public void addView(java.lang.String sParentViewID, java.lang.String sViewID, UISWTViewEventListener l)
Deprecated.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 interfaceUISWTInstance
- Parameters:
sParentViewID
- VIEW_* constantsViewID
- of your view. Used as part of the resource id.
"Views.plugins." + ID + ".title" = title of your viewl
- Listener to be triggered when parent view wants to tell you an event has happened
-
addView
public void addView(java.lang.String sParentViewID, java.lang.String sViewID, java.lang.Class<? extends UISWTViewEventListener> cla, java.lang.Object datasource)
Description copied from interface:UISWTInstance
Add a view to an Apps parent view. For views added to theUISWTInstance.VIEW_MAIN
window, this adds a menu option.In comparison to
UISWTInstance.addView(String, String, UISWTViewEventListener)
, this method saves memory by not creating theUISWTViewEventListener
until it is needed. It also ensures that only oneUISWTViewEvent.TYPE_CREATE
event is triggered per instance.- Specified by:
addView
in interfaceUISWTInstance
- Parameters:
sParentViewID
- VIEW_* constantsViewID
- of your view. Used as part of the resource id.
"Views.plugins." + ID + ".title" = title of your viewcla
- Class of the Listener to be created and triggered
-
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 fromUIManagerListener.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 interfaceUISWTInstance
- Parameters:
sViewID
- ID to give your viewl
- Listener to be triggered when View Events occurdataSource
- objects to setUISWTView.getDataSource()
with
-
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 fromUIManagerListener.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 interfaceUISWTInstance
- Parameters:
sViewID
- ID to give your viewl
- Listener to be triggered when View Events occurdataSource
- objects to setUISWTView.getDataSource()
withsetfocus
- true if you want to display the view immediately, false if you want to display it in the background.
-
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, useUIPluginView.closeView()
- Specified by:
removeViews
in interfaceUISWTInstance
- Parameters:
sParentID
- One of VIEW_* constantssViewID
- View ID to remove
-
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 interfaceUISWTInstance
- 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. This method returns blocks the UI until the user makes a choice. It's recommended to useUIInstance.promptUser(String, String, String[], int, UIMessageListener)
instead- Specified by:
promptUser
in interfaceUIInstance
- Returns:
- Index of option chosen, -1 if cancelled or error
-
promptUser
public void promptUser(java.lang.String title, java.lang.String text, java.lang.String[] options, int defaultOption, UIMessageListener listener)
Description copied from interface:UIInstance
Prompts the user with a title, text, and a series of options. The options are typically displayed as buttons. This method returns immediately.- Specified by:
promptUser
in interfaceUIInstance
options
- List of options to present to the user. Typically shown as buttonslistener
- triggered after user chooses an option
-
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 interfaceUISWTInstance
- Parameters:
sParentID
- ParentID of the view to be shownsViewID
- id of the view to be showndataSource
- any data you need to pass the view- Returns:
- success level
-
openView
public boolean openView(java.lang.String forViewID, java.lang.String sViewID, java.lang.Object dataSource, boolean setfocus)
Description copied from interface:UISWTInstance
Open a previously added view- Specified by:
openView
in interfaceUISWTInstance
- Parameters:
forViewID
- View that the opened view belongs tosViewID
- id of the view to be showndataSource
- any data you need to pass the viewsetfocus
- true if you want to display the view immediately, false if you want to display it in the background.- Returns:
- success level
-
getInputReceiver
public UIInputReceiver getInputReceiver()
Description copied from interface:UIInstance
Creates aUIInputReceiver
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 returnnull
for this method.- Specified by:
getInputReceiver
in interfaceUIInstance
-
createMessage
public UIMessage createMessage()
Description copied from interface:UIInstance
Creates aUIMessage
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 returnnull
for this method.- Specified by:
createMessage
in interfaceUIInstance
-
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 interfaceUISWTInstance
- 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 interfaceUISWTInstance
- 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 interfaceUISWTInstance
- 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 interfaceUIInstance
- Specified by:
openView
in interfaceUISWTInstance
- 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 interfaceUISWTInstance
-
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 interfaceUISWTInstance
- Returns:
-
getToolBarManager
public UIToolBarManager getToolBarManager()
- Specified by:
getToolBarManager
in interfaceUIInstance
-
unload
public void unload(PluginInterface pi)
Description copied from interface:UIInstanceBase
PluginInterface is unloading.. destroy anything related to it- Specified by:
unload
in interfaceUIInstanceBase
-
createViewBuilder
public UISWTViewBuilder createViewBuilder(java.lang.String viewID, java.lang.Class<? extends UISWTViewEventListener> cla)
Description copied from interface:UISWTInstance
Creates an object representing how your view is to be created- Specified by:
createViewBuilder
in interfaceUISWTInstance
- Parameters:
viewID
- Unique ID of your viewcla
- AUISWTViewEventListener
class that will be created when the UI shows the view.
Since this class will be instantiated with cla.newInstance(), the class must be a top-level class, and not a local or non-static nested class.- Returns:
- UISWTViewBuilder which has additional values you can set, such as initial datasource
-
createViewBuilder
public UISWTViewBuilder createViewBuilder(java.lang.String viewID)
Description copied from interface:UISWTInstance
Creates an object representing how your view is to be created. At minimum, you will need to specify a way to instanatiate your listener, with one of the following methods:UISWTViewBuilder.setListenerClass(Class)
UISWTViewBuilder.setListenerInstantiator(boolean, UISWTViewBuilder.UISWTViewEventListenerInstantiator)
- Specified by:
createViewBuilder
in interfaceUISWTInstance
- Parameters:
viewID
- Unique ID of your view- Returns:
- UISWTViewBuilder which has additional values you can set, such as initial datasource
-
registerView
public void registerView(java.lang.Class forDataSourceType, UISWTViewBuilder viewBuilder)
Description copied from interface:UISWTInstance
Register a view that will be created when a certain datasource type is displayed For example, you can register an image rendering view forDiskManagerFileInfo
When plugin is unloaded, any registrations will be automatically unregistered, and any views created from the builder will be automatically disposed- Specified by:
registerView
in interfaceUISWTInstance
- Parameters:
forDataSourceType
- Class of datasource you want to add a view to, such asDownload
,DownloadTypeComplete
,DownloadTypeIncomplete
viewBuilder
- useUISWTInstance.createViewBuilder(String, Class)
-
registerView
public void registerView(java.lang.String forViewID, UISWTViewBuilder viewBuilder)
Description copied from interface:UISWTInstance
Register a view that will be created when the specified view is displayed When plugin is unloaded, any registrations will be automatically unregistered, and any views created from the builder will be automatically disposed- Specified by:
registerView
in interfaceUISWTInstance
- Parameters:
forViewID
- VIEW_ ConstantviewBuilder
- useUISWTInstance.createViewBuilder(String, Class)
-
unregisterView
public void unregisterView(java.lang.String forViewID, java.lang.String viewID)
Description copied from interface:UISWTInstance
Unregister and dispose of any previously created views of this viewID- Specified by:
unregisterView
in interfaceUISWTInstance
-
unregisterView
public void unregisterView(java.lang.Class forDataSourceType, java.lang.String viewID)
Description copied from interface:UISWTInstance
Unregister and dispose of any previously created views of this viewID- Specified by:
unregisterView
in interfaceUISWTInstance
-
-