|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.refractions.udig.style.IStyleConfigurator
public abstract class IStyleConfigurator
Configures a style object.
Responsibilities:
Style objects are stored a StyleBlackboard. Configurators use the blackboard
to collaborate. Objects are stored on the blackboard by id. When a configurator
queries the blackboard for an object and it does not exist, a default object
should be created and placed on the blackboard. The following is an example:
...
StyleBlackboard styleBlackboard = getStyleBlackboard();
Point style = styleBlackboard.lookup("point.style");
if (style == null) {
style = new Point();
style.setX(0);
style.setY(0);
styleBlackboard.put("point.style", style);
}
...
Each Layer has a StyleBlackboard. Configurators should not write to this blackboard directly. Each configurator is supplied with a copy of the actual layer blackboard.
Note:Each time a style object is changed, it must be replaced onto
the blackboard for persistance reasons.
StyleBlackboard styleBlackboard = getStyleBlackboard();
Point style = styleBlackboard.lookup("point.style");
...
style.setX(10);
style.setY(10);
styleBlackboard.put("point.style", style);
The StyleConfigurator should store no state. All state should be stored in the style objects on the style blackboard. When a ui widget changes state, the style object should be written to immediately to reflect the change. When the configurator becomes active, the ui widgets should be initialized from the values of style objects on the blackboard. This should be performed every time refresh() is called.
Whenever style objects are read from the blackboard,
void apply() {
StyleBlackboard styleBlackboard = getStyleBlackboard();
Point style = styleBlackboard.lookup("point.style");
if (style == null) {
style = new Point();
styleBlackboard.put("point.style", style);
}
style.setX(...) //set to some value from ui
style.setY(...) //set to some value from ui
}
void init() {
StyleBlackboard styleBlackboard = getStyleBlackboard();
Point style = styleBlackboard.lookup("point.style");
if (style != null) {
//set some ui widget to value of style.getX();
//set some ui widget to value of style.getY();
}
}
A StyleConfigurator is not considered active until its ui has been created.
Field Summary | |
---|---|
static java.lang.String |
XPID
extension point id |
Constructor Summary | |
---|---|
IStyleConfigurator()
|
Method Summary | |
---|---|
abstract boolean |
canStyle(Layer aLayer)
Determines if the configurator can be used to configure the style for a specified layer. |
abstract void |
createControl(Composite parent)
Creates the control that is to be used to configure the style. |
void |
dispose()
Cleans up any resources (like icons) held by this StyleConfigurator. |
void |
focus(Layer layer1)
Sets the layer and style blackboard that the configurator can populate with style. |
protected IAction |
getApplyAction()
|
java.lang.String |
getLabel()
Returns the label describing the configurator. |
Layer |
getLayer()
Gets the current layer to which the current style being configured is to be applied to. |
IBlackboard |
getStyleBlackboard()
Returns the style blackboard that the configurator is populating with style information. |
java.lang.String |
getStyleId()
Returns the declared style id of the style the configurator depends on. |
IViewSite |
getViewSite()
Returns the site for this view. |
protected void |
init()
Initialize this style configurator. |
void |
init(IViewSite viewSite)
Initializes this view with the given view site. |
protected void |
makeActionDoStuff()
Runs the apply action. |
void |
preApply()
Called after apply action has been triggeredbefore apply is executed. |
protected abstract void |
refresh()
Called when new layer and blackbard values are available. |
void |
setAction(IAction applyAction1)
Sets the apply action. |
void |
setLabel(java.lang.String label)
Sets the label describing the configurator. |
void |
setStyleId(java.lang.String id)
Sets the declared style id of the style the configurator depends on. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String XPID
Constructor Detail |
---|
public IStyleConfigurator()
Method Detail |
---|
public final void setAction(IAction applyAction1)
applyAction1
- protected void makeActionDoStuff()
protected IAction getApplyAction()
public void preApply()
public final java.lang.String getStyleId()
This is provided by SetStyleId by the extention point.
When keeping information associated with a IStyleConfigurator (in a Map, or Memento) use this as a KEY. Don't use label, two IStyleConfigurator may have the same label.
public final void setStyleId(java.lang.String id)
Called by the extention point processor.
id
- The style id.public final java.lang.String getLabel()
public void setLabel(java.lang.String label)
label
- A short description of the configurator.public IViewSite getViewSite()
(IViewSite) getSite()
.
The site can be null
while the view is being initialized.
After the initialization is complete, this value must be non-null
for the remainder of the view's life cycle.
null
if the view
has not yet been initializedpublic void init(IViewSite viewSite) throws PartInitException
This method is automatically shortly after the part is instantiated. It marks the start of the views's lifecycle. Clients must not call this method.
viewSite
- the view site
PartInitException
protected void init() throws PartInitException
You must call super.init();
PartInitException
public abstract boolean canStyle(Layer aLayer)
aLayer
- The layer to be styled.
public final Layer getLayer()
The layer can be null
while the view is being initialized or created.
This value must be non-null
when the IStyleConfigurator.getControl()
is visiable.
public final IBlackboard getStyleBlackboard()
The blackboard can be null
while the view is being initialized or created.
This value must be non-null
when the IStyleConfigurator.getControl()
is visiable.
public void focus(Layer layer1)
When changing layers:
layer1
- The layer being styled.protected abstract void refresh()
This provides update information as a callback (rather than an event listener).
This should only be called after create part control has had a chance to be called.
public abstract void createControl(Composite parent)
This method uses a template pattern to get the subclass to create the control. This method will not be called until after init and setViewPart. The parent container (composite) passed in is for the explicit use of the configurator, this method must set a layout for the container.
You can set the layout to the parent to be whatever you want.
parent
- public void dispose()
You should not assume that create, or even init has been called. You must call super.dispose();
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |