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 java.lang.Object
implements UISWTViewCore, UIPluginViewToolBarListener

This class creates an view that triggers UISWTViewEventListener appropriately

Author:
TuxPaper

Field Summary
static java.lang.String CFG_PREFIX
           
protected  org.eclipse.swt.widgets.Composite composite
           
protected  java.lang.Object datasource
           
protected  java.lang.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(java.lang.String id, java.lang.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()
           
 java.lang.Object getDataSource()
          Retrieve the data sources related to this view.
 UISWTViewEventListener getEventListener()
           
 java.lang.String getFullTitle()
          Called in order to set / update the title of this View.
 java.lang.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()
           
 java.lang.String getTitleID()
          Messagebundle ID for title
 UIToolBarEnablerBase[] getToolbarEnablers()
           
 UIPluginViewToolBarListener getToolBarListener()
           
 java.lang.Object getUserData(java.lang.Object key)
           
 java.lang.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(java.util.Map<java.lang.String,java.lang.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(java.lang.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(java.lang.String title)
          Override the default title with a new one.
 void setTitleID(java.lang.String titleID)
           
 void setToolBarListener(UIPluginViewToolBarListener l)
           
protected  void setToolbarVisibility(boolean visible)
           
 void setUseCoreDataSource(boolean useCoreDataSource)
           
 void setUserData(java.lang.Object key, java.lang.Object data)
           
 boolean toolBarItemActivated(ToolBarItem item, long activationType, java.lang.Object datasource)
          XXX Should have been UIToolBarItem
 void triggerEvent(int eventType, java.lang.Object data)
          Trigger an event for this view
protected  boolean triggerEventRaw(int eventType, java.lang.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 java.lang.String CFG_PREFIX
See Also:
Constant Field Values

skinObject

protected PluginUISWTSkinObject skinObject

datasource

protected java.lang.Object datasource

composite

protected org.eclipse.swt.widgets.Composite composite

id

protected final java.lang.String id
Constructor Detail

UISWTViewImpl

public UISWTViewImpl(java.lang.String id,
                     java.lang.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 java.lang.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(java.lang.Object datasource)

getDataSource

public java.lang.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 java.lang.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,
                         java.lang.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,
                                  java.lang.Object data)

setTitle

public void setTitle(java.lang.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(java.lang.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 java.lang.String getTitleID()
Description copied from interface: UISWTViewCore
Messagebundle ID for title

Specified by:
getTitleID in interface UISWTViewCore

getFullTitle

public java.lang.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,
                                    java.lang.Object datasource)
Description copied from interface: UIToolBarActivationListener
XXX Should have been UIToolBarItem

Specified by:
toolBarItemActivated in interface UIToolBarActivationListener

refreshToolBarItems

public void refreshToolBarItems(java.util.Map<java.lang.String,java.lang.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(java.lang.Object key,
                        java.lang.Object data)
Specified by:
setUserData in interface UISWTViewCore

getUserData

public java.lang.Object getUserData(java.lang.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)