Package com.biglybt.ui.swt.pifimpl
Class UISWTViewImpl
- java.lang.Object
-
- com.biglybt.ui.swt.pifimpl.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 triggersUISWTViewEventListener
appropriately
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CFG_PREFIX
protected org.eclipse.swt.widgets.Composite
composite
private boolean
created
protected java.lang.Object
datasource
private static boolean
DEBUG_TRIGGERS
private boolean
delayInitializeToFirstActivate
private boolean
destroyOnDeactivate
Whether to destroy view on deactivation (view becomes hidden).private UISWTViewEventListener
eventListener
private UISWTViewBuilderCore
eventListenerBuilder
private boolean
haveSentInitialize
private int
iControlType
protected java.lang.String
id
private java.lang.Object
initialDatasource
private java.lang.Boolean
isShown
private org.eclipse.swt.widgets.Composite
masterComposite
private UISWTView
parentView
private java.util.Set<UIPluginViewToolBarListener>
setToolBarEnablers
protected SWTSkin
skin
protected PluginUISWTSkinObject
skinObject
protected static java.lang.String
SO_ID_ENTRY_WRAPPER
private java.lang.String
titleID
protected static long
uniqueNumber
private boolean
useCoreDataSource
private java.util.Map<java.lang.Object,java.lang.Object>
user_data
-
Fields inherited from interface com.biglybt.ui.swt.pif.UISWTView
CONTROLTYPE_AWT, CONTROLTYPE_SWT
-
Fields inherited from interface com.biglybt.ui.swt.pifimpl.UISWTViewCore
CONTROLTYPE_SKINOBJECT
-
Fields inherited from interface com.biglybt.pif.ui.toolbar.UIToolBarActivationListener
ACTIVATIONTYPE_HELD, ACTIVATIONTYPE_NORMAL, ACTIVATIONTYPE_RIGHTCLICK
-
-
Constructor Summary
Constructors Constructor Description UISWTViewImpl(UISWTViewBuilderCore builder, boolean doCreate)
UISWTViewImpl(java.lang.String id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToolbarEnabler(UIToolBarEnablerBase enabler)
SWTSkinObjectContainer
buildStandAlone(SWTSkinObjectContainer soParent)
static SWTSkinObjectContainer
buildStandAlone(SWTSkinObjectContainer soParent, SWTSkin skin, java.lang.String id, java.lang.Object datasource, int controlType, UISWTViewBuilderCore original_builder)
boolean
canBuildStandAlone()
void
closeView()
Closes the viewvoid
create()
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()
UISWTViewBuilderCore
getEventListenerBuilder()
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 viewUISWTView
getParentView()
Get parent view, if one existsPluginInterface
getPluginInterface()
Gets the plugin interface associated with this view, null if none definedPluginUISWTSkinObject
getPluginSkinObject()
java.lang.String
getTitleID()
Messagebundle ID for titleUIToolBarEnablerBase[]
getToolbarEnablers()
UIPluginViewToolBarListener
getToolBarListener()
java.lang.Object
getUserData(java.lang.Object key)
java.lang.String
getViewID()
ID of the viewboolean
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
isContentDisposed()
boolean
isDelayInitializeToFirstActivate()
boolean
isDestroyOnDeactivate()
Retrieve whether this view can be destroyed onUISWTViewEvent.TYPE_FOCUSLOST
private static java.lang.String
padRight(java.lang.String s, int n)
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 setvoid
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 onUISWTViewEvent.TYPE_FOCUSLOST
void
setEventListener(UISWTViewEventListener _eventListener, UISWTViewBuilderCore builder, boolean doCreate)
protected void
setMasterComposite(org.eclipse.swt.widgets.Composite masterComposite)
void
setParentView(UISWTView parentView)
void
setPluginSkinObject(PluginUISWTSkinObject so)
void
setTitle(java.lang.String title)
Override the default title with a new one.protected void
setTitleID(java.lang.String titleID)
protected boolean
setTitleIDSupport(java.lang.String titleID)
protected boolean
setTitleSupport(java.lang.String title)
void
setToolBarListener(UIPluginViewToolBarListener l)
protected void
setToolbarVisibility(boolean visible)
void
setUseCoreDataSource(boolean useCoreDataSource)
void
setUserData(java.lang.Object key, java.lang.Object data)
private void
swt_triggerInitialize()
boolean
toolBarItemActivated(ToolBarItem item, long activationType, java.lang.Object datasource)
XXX Should have been UIToolBarItemprivate boolean
triggerBooleanEvent(int eventType, java.lang.Object data)
void
triggerEvent(int eventType, java.lang.Object data)
Trigger an event for this viewprotected 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
-
Methods inherited from interface com.biglybt.pif.ui.UIPluginViewToolBarListener
isActive
-
-
-
-
Field Detail
-
CFG_PREFIX
public static final java.lang.String CFG_PREFIX
- See Also:
- Constant Field Values
-
SO_ID_ENTRY_WRAPPER
protected static final java.lang.String SO_ID_ENTRY_WRAPPER
- See Also:
- Constant Field Values
-
uniqueNumber
protected static long uniqueNumber
-
delayInitializeToFirstActivate
private boolean delayInitializeToFirstActivate
-
DEBUG_TRIGGERS
private static final boolean DEBUG_TRIGGERS
- See Also:
- Constant Field Values
-
skinObject
protected PluginUISWTSkinObject skinObject
-
initialDatasource
private java.lang.Object initialDatasource
-
parentView
private UISWTView parentView
-
skin
protected SWTSkin skin
-
datasource
protected java.lang.Object datasource
-
useCoreDataSource
private boolean useCoreDataSource
-
eventListener
private UISWTViewEventListener eventListener
-
composite
protected org.eclipse.swt.widgets.Composite composite
-
id
protected final java.lang.String id
-
titleID
private java.lang.String titleID
-
iControlType
private int iControlType
-
isShown
private java.lang.Boolean isShown
-
user_data
private java.util.Map<java.lang.Object,java.lang.Object> user_data
-
haveSentInitialize
private boolean haveSentInitialize
-
created
private boolean created
-
destroyOnDeactivate
private boolean destroyOnDeactivate
Whether to destroy view on deactivation (view becomes hidden). Note that views can be rebuilt after being destroyed (ie. when shown again)
-
masterComposite
private org.eclipse.swt.widgets.Composite masterComposite
-
setToolBarEnablers
private final java.util.Set<UIPluginViewToolBarListener> setToolBarEnablers
-
eventListenerBuilder
private UISWTViewBuilderCore eventListenerBuilder
-
-
Constructor Detail
-
UISWTViewImpl
public UISWTViewImpl(java.lang.String id)
-
UISWTViewImpl
public UISWTViewImpl(UISWTViewBuilderCore builder, boolean doCreate) throws UISWTViewEventCancelledException
- Throws:
UISWTViewEventCancelledException
-
-
Method Detail
-
setEventListener
public void setEventListener(UISWTViewEventListener _eventListener, UISWTViewBuilderCore builder, boolean doCreate) throws UISWTViewEventCancelledException
- Throws:
UISWTViewEventCancelledException
-
create
public void create() throws UISWTViewEventCancelledException
- Throws:
UISWTViewEventCancelledException
-
getEventListener
public UISWTViewEventListener getEventListener()
- Specified by:
getEventListener
in interfaceUISWTViewCore
-
getEventListenerBuilder
public UISWTViewBuilderCore getEventListenerBuilder()
- Specified by:
getEventListenerBuilder
in interfaceUISWTViewCore
-
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 interfaceUISWTView
-
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 interfaceUIPluginView
- Specified by:
getDataSource
in interfaceUISWTView
- Specified by:
getDataSource
in interfaceUISWTViewCore
- Returns:
- Returns data source, based on
UISWTViewCore.useCoreDataSource()
-
setParentView
public void setParentView(UISWTView parentView)
- Specified by:
setParentView
in interfaceUISWTViewCore
-
getParentView
public UISWTView getParentView()
Description copied from interface:UISWTView
Get parent view, if one exists- Specified by:
getParentView
in interfaceUISWTView
-
getViewID
public java.lang.String getViewID()
Description copied from interface:UIPluginView
ID of the view- Specified by:
getViewID
in interfaceUIPluginView
- Returns:
- ID of the view
-
closeView
public void closeView()
Description copied from interface:UIPluginView
Closes the view- Specified by:
closeView
in interfaceUIPluginView
-
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 interfaceUISWTView
-
getControlType
public int getControlType()
- Specified by:
getControlType
in interfaceUISWTView
- 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 interfaceUISWTView
- Parameters:
eventType
- Event to triggerUISWTViewEvent
}data
- data to send with trigger
-
isContentDisposed
public boolean isContentDisposed()
- Specified by:
isContentDisposed
in interfaceUISWTView
-
padRight
private static java.lang.String padRight(java.lang.String s, int n)
-
triggerBooleanEvent
private boolean triggerBooleanEvent(int eventType, java.lang.Object data)
-
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 theUISWTViewEvent.TYPE_LANGUAGEUPDATE
to update your title to the new language.
-
setTitleSupport
protected boolean setTitleSupport(java.lang.String title)
-
setTitleID
protected void setTitleID(java.lang.String titleID)
-
setTitleIDSupport
protected boolean setTitleIDSupport(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 Important Note
BiglyBT 2.0.0.0 and below will only return aPluginInterface
during theUISWTViewEvent.TYPE_CREATE
event. After this event is processed, the return value will be null. 2.0.0.1 and later will always return aPluginInterface
- Specified by:
getPluginInterface
in interfaceUIPluginView
- Specified by:
getPluginInterface
in interfaceUISWTView
-
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 interfaceUISWTViewCore
- 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 interfaceUISWTViewCore
-
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 interfaceUISWTViewCore
- 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 interfaceUISWTViewCore
- Parameters:
parent
- the parent composite. Each view should create a child composite, and then use this child composite to add all elements to.
-
swt_triggerInitialize
private void swt_triggerInitialize()
-
useCoreDataSource
public boolean useCoreDataSource()
- Specified by:
useCoreDataSource
in interfaceUISWTViewCore
-
setUseCoreDataSource
public void setUseCoreDataSource(boolean useCoreDataSource)
- Specified by:
setUseCoreDataSource
in interfaceUISWTViewCore
-
getPluginSkinObject
public PluginUISWTSkinObject getPluginSkinObject()
- Specified by:
getPluginSkinObject
in interfaceUISWTViewCore
-
setPluginSkinObject
public void setPluginSkinObject(PluginUISWTSkinObject so)
- Specified by:
setPluginSkinObject
in interfaceUISWTViewCore
-
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 interfaceUIToolBarActivationListener
-
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 interfaceUIPluginViewToolBarListener
-
setToolBarListener
public void setToolBarListener(UIPluginViewToolBarListener l)
- Specified by:
setToolBarListener
in interfaceUIPluginView
-
getToolBarListener
public UIPluginViewToolBarListener getToolBarListener()
- Specified by:
getToolBarListener
in interfaceUIPluginView
-
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 interfaceUISWTViewCore
-
getUserData
public java.lang.Object getUserData(java.lang.Object key)
- Specified by:
getUserData
in interfaceUISWTViewCore
-
setDestroyOnDeactivate
public void setDestroyOnDeactivate(boolean b)
Description copied from interface:UISWTView
To save memory/CPU, views are sometimes destroyed onUISWTViewEvent.TYPE_FOCUSLOST
This allows overriding of the default behaviour
- Specified by:
setDestroyOnDeactivate
in interfaceUISWTView
-
isDestroyOnDeactivate
public boolean isDestroyOnDeactivate()
Description copied from interface:UISWTView
Retrieve whether this view can be destroyed onUISWTViewEvent.TYPE_FOCUSLOST
- Specified by:
isDestroyOnDeactivate
in interfaceUISWTView
-
isDelayInitializeToFirstActivate
public boolean isDelayInitializeToFirstActivate()
-
setDelayInitializeToFirstActivate
public void setDelayInitializeToFirstActivate(boolean delayInitializeToFirstActivate)
-
setMasterComposite
protected void setMasterComposite(org.eclipse.swt.widgets.Composite masterComposite)
-
buildStandAlone
public SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent)
- Specified by:
buildStandAlone
in interfaceUISWTViewCore
-
buildStandAlone
public static SWTSkinObjectContainer buildStandAlone(SWTSkinObjectContainer soParent, SWTSkin skin, java.lang.String id, java.lang.Object datasource, int controlType, UISWTViewBuilderCore original_builder)
-
canBuildStandAlone
public boolean canBuildStandAlone()
- Specified by:
canBuildStandAlone
in interfaceUISWTViewCore
-
-