* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
*/
public class ToggleableTextElement extends AbstractCdmFormElement implements SelectionListener, ModifyListener, IEnableableFormElement, ISelectable {
*/
public class ToggleableTextElement extends AbstractCdmFormElement implements SelectionListener, ModifyListener, IEnableableFormElement, ISelectable {
- private Set<SelectionListener> selectionListener = new HashSet<SelectionListener>();
- private Label label;
- private Composite container;
-
+ private final Set<SelectionListener> selectionListener = new HashSet<SelectionListener>();
+ private final Label label;
+ private final Composite container;
+
protected ToggleableTextElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
String labelString, String initialText, boolean initialState, int style) {
super(formFactory, parentElement);
protected ToggleableTextElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
String labelString, String initialText, boolean initialState, int style) {
super(formFactory, parentElement);
container.setLayout(LayoutConstants.LAYOUT(2, false));
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
addControl(container);
container.setLayout(LayoutConstants.LAYOUT(2, false));
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
addControl(container);
text_cache = formFactory.createText(container, initialText, SWT.WRAP | SWT.MULTI);
addControl(text_cache);
text_cache.addModifyListener(this);
text_cache = formFactory.createText(container, initialText, SWT.WRAP | SWT.MULTI);
addControl(text_cache);
text_cache.addModifyListener(this);
text_cache.removeModifyListener(this);
text_cache.setText(text);
text_cache.addModifyListener(this);
text_cache.removeModifyListener(this);
text_cache.setText(text);
text_cache.addModifyListener(this);
/**
* <p>Setter for the field <code>state</code>.</p>
*
* @param state a boolean.
*/
public void setState(boolean state) {
/**
* <p>Setter for the field <code>state</code>.</p>
*
* @param state a boolean.
*/
public void setState(boolean state) {
text_cache.setEnabled(enabled);
String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED;
text_cache.setForeground(StoreUtil.getColor(symbolicName));
text_cache.setEnabled(enabled);
String symbolicName = enabled ? Resources.COLOR_FONT_DEFAULT : Resources.COLOR_TEXT_DISABLED;
text_cache.setForeground(StoreUtil.getColor(symbolicName));
setState(button_toggle.getSelection());
for(SelectionListener listener : selectionListener){
listener.widgetSelected(e);
}
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
}
setState(button_toggle.getSelection());
for(SelectionListener listener : selectionListener){
listener.widgetSelected(e);
}
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
}
/** {@inheritDoc} */
@Override
public void setBackground(Color color) {
label.setBackground(color);
container.setBackground(color);
}
/** {@inheritDoc} */
@Override
public void setBackground(Color color) {
label.setBackground(color);
container.setBackground(color);
}
@Override
public void setSelected(boolean selected) {
setBackground(selected ? SELECTED : getPersistentBackground());
@Override
public void setSelected(boolean selected) {
setBackground(selected ? SELECTED : getPersistentBackground());