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

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.pluginsimpl.UISWTViewImpl
All Implemented Interfaces:
UIToolBarActivationListener, UIToolBarEnablerBase, UIPluginView, UIPluginViewToolBarListener, UISWTView, UISWTViewCore
Direct Known Subclasses:
BaseMdiEntry

public class UISWTViewImpl
extends Object
implements UISWTViewCore, UIPluginViewToolBarListener

This class creates an view that triggers UISWTViewEventListener appropriately

Author:
TuxPaper

Field Summary
static String CFG_PREFIX
           
protected  org.eclipse.swt.widgets.Composite composite
           
protected  Object datasource
           
protected  String id
           
protected  PluginUISWTSkinObject skinObject
           
 
Fields inherited from interface org.gudy.azureus2.ui.swt.pluginsimpl.UISWTViewCore
CONTROLTYPE_SKINOBJECT
 
Fields inherited from interface org.gudy.azureus2.ui.swt.plugins.UISWTView
CONTROLTYPE_AWT, CONTROLTYPE_SWT
 
Fields inherited from interface org.gudy.azureus2.plugins.ui.toolbar.UIToolBarActivationListener
ACTIVATIONTYPE_HELD, ACTIVATIONTYPE_NORMAL, ACTIVATIONTYPE_RIGHTCLICK
 
Constructor Summary
UISWTViewImpl(String id, String parentViewID, boolean destroyOnDeactivate)
           
 
Method Summary
 void addToolbarEnabler(UIToolBarEnablerBase enabler)
           
 void closeView()
          Closes the view
 org.eclipse.swt.widgets.Composite getComposite()
          This method is called after initialize so that the Tab is set its control Caller is the GUI Thread.
 int getControlType()
           
 Object getDataSource()
          Retrieve the data sources related to this view.
 UISWTViewEventListener getEventListener()
           
 String getFullTitle()
          Called in order to set / update the title of this View.
 Object getInitialDataSource()
          Get the original datasource that was set to the view
 UISWTView getParentView()
          Get parent view, if one exists
 PluginInterface getPluginInterface()
          Gets the plugin interface associated with this view, null if none defined
 PluginUISWTSkinObject getPluginSkinObject()
           
 String getTitleID()
          Messagebundle ID for title
 UIToolBarEnablerBase[] getToolbarEnablers()
           
 UIPluginViewToolBarListener getToolBarListener()
           
 Object getUserData(Object key)
           
 String getViewID()
          ID of the view
 boolean hasToolbarEnableers()
           
 void initialize(org.eclipse.swt.widgets.Composite parent)
          This method is called when the view is instanciated, it should initialize all GUI components.
 boolean isDelayInitializeToFirstActivate()
           
 boolean isDestroyOnDeactivate()
          Retrieve whether this view can be destroyed on UISWTViewEvent.TYPE_FOCUSLOST
protected  void refreshTitle()
           
 void refreshToolBarItems(Map<String,Long> list)
          Fill in list with the toolbar ids and states you wish to set
 void removeToolbarEnabler(UIToolBarEnablerBase enabler)
           
 void setControlType(int iControlType)
          Sets the type of control this view uses.
 void setDatasource(Object datasource)
           
 void setDelayInitializeToFirstActivate(boolean delayInitializeToFirstActivate)
           
 void setDestroyOnDeactivate(boolean b)
          To save memory/CPU, views are sometimes destroyed on UISWTViewEvent.TYPE_FOCUSLOST
 void setEventListener(UISWTViewEventListener _eventListener, boolean doCreate)
           
 void setParentView(UISWTView parentView)
           
 void setPluginSkinObject(PluginUISWTSkinObject so)
           
 void setTitle(String title)
          Override the default title with a new one.
 void setTitleID(String titleID)
           
 void setToolBarListener(UIPluginViewToolBarListener l)
           
protected  void setToolbarVisibility(boolean visible)
           
 void setUseCoreDataSource(boolean useCoreDataSource)
           
 void setUserData(Object key, Object data)
           
 boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource)
          XXX Should have been UIToolBarItem
 void triggerEvent(int eventType, Object data)
          Trigger an event for this view
protected  boolean triggerEventRaw(int eventType, Object data)
           
 boolean useCoreDataSource()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CFG_PREFIX

public static final String CFG_PREFIX
See Also:
Constant Field Values

skinObject

protected PluginUISWTSkinObject skinObject

datasource

protected Object datasource

composite

protected org.eclipse.swt.widgets.Composite composite

id

protected final String id
Constructor Detail

UISWTViewImpl

public UISWTViewImpl(String id,
                     String parentViewID,
                     boolean destroyOnDeactivate)
Method Detail

setEventListener

public void setEventListener(UISWTViewEventListener _eventListener,
                             boolean doCreate)
                      throws UISWTViewEventCancelledException
Throws:
UISWTViewEventCancelledException

getEventListener

public UISWTViewEventListener getEventListener()
Specified by:
getEventListener in interface UISWTViewCore

getInitialDataSource

public Object getInitialDataSource()
Description copied from interface: UISWTView
Get the original datasource that was set to the view

Specified by:
getInitialDataSource in interface UISWTView

setDatasource

public void setDatasource(Object datasource)

getDataSource

public Object getDataSource()
Description copied from interface: UISWTView
Retrieve the data sources related to this view.

Specified by:
getDataSource in interface UIPluginView
Specified by:
getDataSource in interface UISWTView
Returns:
Depending on the parent view you added your view to, the Object will be:
UISWTInstance.VIEW_MAIN- null
UISWTInstance.VIEW_MYTORRENTS- Download
UISWTInstance.VIEW_TORRENT_PEERS- Peer
If created by UISWTInstance.openMainView(String, UISWTViewEventListener, Object), value will be the value set.

May return null if no data source is selected, or while processing the UISWTViewEvent.TYPE_CREATE event.


setParentView

public void setParentView(UISWTView parentView)
Specified by:
setParentView in interface UISWTViewCore

getParentView

public UISWTView getParentView()
Description copied from interface: UISWTView
Get parent view, if one exists

Specified by:
getParentView in interface UISWTView

getViewID

public String getViewID()
Description copied from interface: UIPluginView
ID of the view

Specified by:
getViewID in interface UIPluginView
Returns:
ID of the view

closeView

public void closeView()
Description copied from interface: UIPluginView
Closes the view

Specified by:
closeView in interface UIPluginView

setControlType

public void setControlType(int iControlType)
Description copied from interface: UISWTView
Sets the type of control this view uses. Set before view initialization.

The default value is UISWTView.CONTROLTYPE_SWT

Specified by:
setControlType in interface UISWTView

getControlType

public int getControlType()
Specified by:
getControlType in interface UISWTView
Returns:
CONTROLTYPE_*

triggerEvent

public void triggerEvent(int eventType,
                         Object data)
Description copied from interface: UISWTView
Trigger an event for this view

Specified by:
triggerEvent in interface UISWTView
Parameters:
eventType - Event to trigger UISWTViewEvent}
data - data to send with trigger

triggerEventRaw

protected boolean triggerEventRaw(int eventType,
                                  Object data)

setTitle

public void setTitle(String title)
Description copied from interface: UISWTView
Override the default title with a new one. After setting this, you should use the UISWTViewEvent.TYPE_LANGUAGEUPDATE to update your title to the new language.

Specified by:
setTitle in interface UISWTView
Parameters:
title - new Title

setTitleID

public void setTitleID(String titleID)

refreshTitle

protected void refreshTitle()

getPluginInterface

public PluginInterface getPluginInterface()
Description copied from interface: UISWTView
Gets the plugin interface associated with this view, null if none defined

Specified by:
getPluginInterface in interface UIPluginView
Specified by:
getPluginInterface in interface UISWTView

getComposite

public org.eclipse.swt.widgets.Composite getComposite()
Description copied from interface: UISWTViewCore
This method is called after initialize so that the Tab is set its control Caller is the GUI Thread.

Specified by:
getComposite in interface UISWTViewCore
Returns:
the Composite that should be set as the control for the Tab item

getTitleID

public String getTitleID()
Description copied from interface: UISWTViewCore
Messagebundle ID for title

Specified by:
getTitleID in interface UISWTViewCore

getFullTitle

public String getFullTitle()
Description copied from interface: UISWTViewCore
Called in order to set / update the title of this View. When the view is being displayed in a tab, the full title is used for the tooltip.

Specified by:
getFullTitle in interface UISWTViewCore
Returns:
the full title for the view

initialize

public void initialize(org.eclipse.swt.widgets.Composite parent)
Description copied from interface: UISWTViewCore
This method is called when the view is instanciated, it should initialize all GUI components. Must NOT be blocking, or it'll freeze the whole GUI. Caller is the GUI Thread.

Specified by:
initialize in interface UISWTViewCore
Parameters:
parent - the parent composite. Each view should create a child composite, and then use this child composite to add all elements to.

useCoreDataSource

public boolean useCoreDataSource()
Specified by:
useCoreDataSource in interface UISWTViewCore

setUseCoreDataSource

public void setUseCoreDataSource(boolean useCoreDataSource)
Specified by:
setUseCoreDataSource in interface UISWTViewCore

getPluginSkinObject

public PluginUISWTSkinObject getPluginSkinObject()
Specified by:
getPluginSkinObject in interface UISWTViewCore

setPluginSkinObject

public void setPluginSkinObject(PluginUISWTSkinObject so)
Specified by:
setPluginSkinObject in interface UISWTViewCore

toolBarItemActivated

public boolean toolBarItemActivated(ToolBarItem item,
                                    long activationType,
                                    Object datasource)
Description copied from interface: UIToolBarActivationListener
XXX Should have been UIToolBarItem

Specified by:
toolBarItemActivated in interface UIToolBarActivationListener

refreshToolBarItems

public void refreshToolBarItems(Map<String,Long> list)
Description copied from interface: UIPluginViewToolBarListener
Fill in list with the toolbar ids and states you wish to set

Specified by:
refreshToolBarItems in interface UIPluginViewToolBarListener

setToolBarListener

public void setToolBarListener(UIPluginViewToolBarListener l)
Specified by:
setToolBarListener in interface UIPluginView

getToolBarListener

public UIPluginViewToolBarListener getToolBarListener()
Specified by:
getToolBarListener in interface UIPluginView

getToolbarEnablers

public UIToolBarEnablerBase[] getToolbarEnablers()

hasToolbarEnableers

public boolean hasToolbarEnableers()

addToolbarEnabler

public void addToolbarEnabler(UIToolBarEnablerBase enabler)

removeToolbarEnabler

public void removeToolbarEnabler(UIToolBarEnablerBase enabler)

setToolbarVisibility

protected void setToolbarVisibility(boolean visible)

setUserData

public void setUserData(Object key,
                        Object data)
Specified by:
setUserData in interface UISWTViewCore

getUserData

public Object getUserData(Object key)
Specified by:
getUserData in interface UISWTViewCore

setDestroyOnDeactivate

public void setDestroyOnDeactivate(boolean b)
Description copied from interface: UISWTView
To save memory/CPU, views are sometimes destroyed on UISWTViewEvent.TYPE_FOCUSLOST

This allows overriding of the default behaviour

Specified by:
setDestroyOnDeactivate in interface UISWTView

isDestroyOnDeactivate

public boolean isDestroyOnDeactivate()
Description copied from interface: UISWTView
Retrieve whether this view can be destroyed on UISWTViewEvent.TYPE_FOCUSLOST

Specified by:
isDestroyOnDeactivate in interface UISWTView

isDelayInitializeToFirstActivate

public boolean isDelayInitializeToFirstActivate()

setDelayInitializeToFirstActivate

public void setDelayInitializeToFirstActivate(boolean delayInitializeToFirstActivate)