T
- Type of metadata returned by addon.public abstract class AddonUIAdapter<T extends AddonMetadata> extends java.lang.Object implements AddonUI<T>
Constructor and Description |
---|
AddonUIAdapter(T metadata,
YouScopeClient client,
YouScopeServer server)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addFrameListener(YouScopeFrameListener listener)
Adds a listener to the frame in which the UI element is initialized (or, to which the panel belongs) which is informed e.g.
|
protected void |
closeAddon()
Call this function to signal that the addon user interface has finished doing what it is supposed to do, and might be closed now.
|
protected abstract java.awt.Component |
createUI()
Return a Component (typically a JPanel) containing the UI elements of the addon.
|
T |
getAddonMetadata()
Returns the metadata (like human readable name) for the addon.
|
protected YouScopeClient |
getClient()
Returns the YouScope client.
|
protected java.lang.String |
getCloseButtonLabel()
Returns the label of the commit button which is displayed at the bottom of a frame, when initialized as a frame.
|
protected YouScopeFrame |
getContainingFrame()
Returns the frame containing this addon.
|
protected Microscope |
getMicroscope()
Returns the microscope.
|
protected java.awt.Dimension |
getPreferredSize()
Returns the preferred size of this UI element, or null if size should be calculated automatically.
|
protected YouScopeServer |
getServer()
Returns the YouScope server.
|
protected java.lang.String |
getTitle()
Returns the title of this UI element.
|
protected boolean |
isInitialized()
Returns true if the functions toXXXFrame() or toPanel() was called, that is, if
createUI() was called or not.
|
protected boolean |
isMaximizable()
Returns if this UI element will be maximizable if initialized as a frame.
|
protected boolean |
isMaximize()
Indicates if this UI element should be maximized if it is a frame.
|
protected boolean |
isResizable()
Returns if this element should be resizable.
|
protected boolean |
isSeparateFrame() |
protected boolean |
isShowCloseButton()
Returns true if a commit button is automatically added when addon is initialized as a frame.
|
protected void |
notifyLayoutChanged()
Call this function if the layout of the addon changed in a way such that the components need resizing.
|
protected void |
removeFrameListener(YouScopeFrameListener listener)
Removes a previously added listener.
|
protected void |
sendErrorMessage(java.lang.String message,
java.lang.Throwable error)
Call this function to notify that an error occurred.
|
protected void |
sendMessage(java.lang.String message)
Send a general message meant for information.
|
protected void |
setCloseButtonLabel(java.lang.String commitButtonLabel)
Sets the label of the commit button which is displayed at the bottom of a frame, when initialized as a frame.
|
protected void |
setDescription(java.lang.String description)
Sets a description for this addon.
|
protected void |
setMaximizable(boolean maximizable)
Sets if this UI element will be maximizable if initialized as a frame.
|
protected void |
setMaximize(boolean maximize)
Sets if this UI element should be maximized if it is a frame.
|
protected void |
setPreferredSize(java.awt.Dimension preferredSize)
Set the preferred size of this UI element.
|
protected void |
setResizable(boolean resizable)
Sets if this element should be resizable.
|
protected void |
setShowCloseButton(boolean commitButton)
Set to true if a commit button should be automatically added when addon is initialized as a frame.
|
protected void |
setTitle(java.lang.String title)
Sets the title of this UI element.
|
YouScopeFrame |
toFrame()
Creates a frame containing the UI elements of this addon.
|
java.awt.Component |
toPanel(YouScopeFrame containingFrame)
Creates a UI component (usually a panel) containing the UI elements of this addon.
|
public AddonUIAdapter(T metadata, YouScopeClient client, YouScopeServer server) throws AddonException
metadata
- The metadata of the addon.client
- The YouScope client.server
- The YouScope server.AddonException
protected void setDescription(java.lang.String description)
toFrame()
or toPanel(YouScopeFrame)
.description
- Description of the addon.protected void notifyLayoutChanged()
public YouScopeFrame toFrame() throws AddonException
AddonUI
YouScopeFrame.setVisible(true)
should be
called by the invoker of this function). A new frame can be created by calling YouScopeClient.createFrame()
. The caller can decide to add this frame
as a child or modal child frame to the frame the caller elements are displayed in by calling on its frame addChildFrame()
or addModalChildFrame()
.
Only one of the functions toFrame()
or toPanel()
must be called for a given addon. Furthermore, this function must not be called more than once.
To create more than one UI representation of a given addon, create a second addon UI using the corresponding factory.toFrame
in interface AddonUI<T extends AddonMetadata>
AddonException
- thrown if an error occurs during construction of the UI.public java.awt.Component toPanel(YouScopeFrame containingFrame) throws AddonException
AddonUI
toFrame()
or toPanel()
must be called for a given tool. Furthermore, this function must not be called more than once.
To create more than one UI representation of a given addon, create a second addon UI using the corresponding factory.toPanel
in interface AddonUI<T extends AddonMetadata>
containingFrame
- The frame containing the UI elements. Note that this frame is not necessarily visible when this function is invoked. The reference to the containing frame can e.g.
be used to register frame listeners to get notified when the containing frame opens or closes.AddonException
- thrown if an error occurs during creation of the addon UI.protected abstract java.awt.Component createUI() throws AddonException
setShowCloseButton(boolean)
and setCloseButtonLabel(String)
).AddonException
protected boolean isMaximize()
protected void setMaximize(boolean maximize)
maximize
- true if should be maximized when frame.protected java.awt.Dimension getPreferredSize()
protected void setPreferredSize(java.awt.Dimension preferredSize)
preferredSize
- preferred size, or null.protected boolean isResizable()
protected void setResizable(boolean resizable)
resizable
- true if resizable.protected boolean isMaximizable()
protected void setMaximizable(boolean maximizable)
maximizable
- true if maximizable.protected java.lang.String getTitle()
protected void setTitle(java.lang.String title)
protected void addFrameListener(YouScopeFrameListener listener)
listener
- The listener to add.protected void removeFrameListener(YouScopeFrameListener listener)
listener
- The listener to remove.protected java.lang.String getCloseButtonLabel()
protected void setCloseButtonLabel(java.lang.String commitButtonLabel)
commitButtonLabel
- Label of the commit button, or null.protected void closeAddon()
protected void sendErrorMessage(java.lang.String message, java.lang.Throwable error)
message
- A description in which step the error happened.error
- The error which happened.protected void sendMessage(java.lang.String message)
message
- The message to sendprotected boolean isInitialized()
protected boolean isSeparateFrame()
protected YouScopeFrame getContainingFrame()
protected boolean isShowCloseButton()
protected void setShowCloseButton(boolean commitButton)
commitButton
- True if commit button should be created.protected YouScopeClient getClient()
protected YouScopeServer getServer()
protected Microscope getMicroscope() throws java.rmi.RemoteException
java.rmi.RemoteException
public T getAddonMetadata()
AddonUI
getAddonMetadata
in interface AddonUI<T extends AddonMetadata>