* 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.
*/
-
package eu.etaxonomy.taxeditor.ui.section;
import org.eclipse.jface.util.PropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
import eu.etaxonomy.taxeditor.ui.element.ISelectable;
import eu.etaxonomy.taxeditor.ui.element.LabelElement;
/**
* Visualizes an element of type ENTITY in an {@link AbstractEntityCollectionSection}
- * and links listener functionalities to it.
+ * and links listener functionalities to it.
*
- * @param ENTITY the type of the element which is visualized by this class
+ * @param ENTITY the type of the element which is visualized by this class
*
* @author n.hoffmann
* @created Nov 16, 2009
*/
-public abstract class AbstractEntityCollectionElement<ENTITY> extends
- AbstractCdmFormElement implements IEntityElement<ENTITY>,
- SelectionListener, IConversationEnabled {
+public abstract class AbstractEntityCollectionElement<ENTITY>
+ extends AbstractCdmFormElement
+ implements IEntityElement<ENTITY>, SelectionListener,
+ IConversationEnabled, IEnableableFormElement {
protected ENTITY entity;
*/
private final Composite box;
+ private boolean isEnabled;
+
private Button btnRemove;
- protected Button btnChooseEntity;
+
+ private Button btnChooseEntity;
private Color backgroundColor;
btnRemove.setToolTipText("Remove");
btnRemove.addSelectionListener(removeListener);
+ btnRemove.setEnabled(isEnabled);
}
- createControls(this, style);
+
setEntity(entity);
+ createControls(this, style);
}
/**
setBackground(selected ? SELECTED : getPersistentBackground());
}
- /** {@inheritDoc} */
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event == null) {
public abstract void handleEvent(Object eventSource);
- /** {@inheritDoc} */
@Override
public void setBackground(Color color) {
if(box.isDisposed() || container.isDisposed()){
}
- /** {@inheritDoc} */
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
- /** {@inheritDoc} */
@Override
public Composite getLayoutComposite() {
return container;
"Parent element should be IConversationEnabled");
}
- /** {@inheritDoc} */
@Override
public void update(CdmDataChangeMap changeEvents) {
}
warnForReferencedObjects.setVisible(isVisible);
}
}
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ this.isEnabled = enabled;
+ if (btnRemove != null){
+ btnRemove.setEnabled(enabled);
+ }
+ if (btnChooseEntity != null){
+ btnChooseEntity.setEnabled(enabled);
+ }
+
+ for (ICdmFormElement element:this.getElements()){
+ if (element instanceof IEnableableFormElement){
+ ((IEnableableFormElement)element).setEnabled(enabled);
+ }
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return isEnabled;
+ }
}