public abstract class AbstractEntityCollectionSection<ENTITY, ELEMENT> extends AbstractFormSection<ENTITY> implements IExpansionListener, Observer {
- /**
- *
- */
private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
protected Composite container;
private String title;
- /**
- * <p>Constructor for AbstractEntityCollectionSection.</p>
- *
- * @param conversation
- * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
- * @param style a int.
- * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
- * @param title a {@link java.lang.String} object.
- * @param <ENTITY> a ENTITY object.
- * @param <ELEMENT> a ELEMENT object.
- */
+ private AbstractEntityCollectionElement entityCollectionElement;
+
public AbstractEntityCollectionSection(CdmFormFactory formFactory, ConversationHolder conversation, ICdmFormElement parentElement, String title, int style) {
super(formFactory, parentElement, ExpandableComposite.CLIENT_INDENT | style);
this.title = title;
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
Action addAction = new Action("add", IAction.AS_PUSH_BUTTON){
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
@Override
public void run() {
ELEMENT element = createNewElement();
setTextClient(null);
}
- /**
- * <p>setEntity</p>
- *
- * @param entity a ENTITY object.
- */
@Override
public void setEntity(ENTITY entity) {
if(entity != null){
reflow();
}
- /**
- * <p>createEmptyContent</p>
- */
protected void createEmptyContent(){
label_empty = formFactory.createLabel(getLayoutComposite(), getEmptyString());
}
* @param backgroundColor a {@link org.eclipse.swt.graphics.Color} object.
*/
protected void createElementComposite(ELEMENT element, SelectionListener removeListener, Color backgroundColor){
- formFactory.createEntityCollectionElement(this, element, removeListener, backgroundColor, SWT.NULL);
+ entityCollectionElement = formFactory.createEntityCollectionElement(this, element, removeListener, backgroundColor, SWT.NULL);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.forms.section.AbstractEditorFormSection#setBackground(org.eclipse.swt.graphics.Color)
- */
/** {@inheritDoc} */
@Override
public void setBackground(Color color) {
internalUpdateSection(true);
}
- /* (non-Javadoc)
- * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
- */
@Override
public void update(Observable o, Object arg){
if(o instanceof LoginManager){
}
}
+ public AbstractEntityCollectionElement getEntityCollectionElement() {
+ return entityCollectionElement;
+ }
+
/**
* Get the specific collection of this entity
*
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* 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.
*/
import java.util.Collection;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
+import eu.etaxonomy.taxeditor.ui.section.media.ITogglableMediaElement;
/**
* <p>DescriptionElementMediaSection class.</p>
*/
public class DescriptionElementMediaSection extends
AbstractEntityCollectionSection<DescriptionElementBase, Media> {
-
- /**
- * <p>Constructor for DescriptionElementMediaSection.</p>
- *
- * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
- * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
- * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
- * @param style a int.
- */
+
public DescriptionElementMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
ICdmFormElement parentElement, int style) {
super(cdmFormFactory, conversation, parentElement, "Media", style);
}
-
+
/** {@inheritDoc} */
@Override
public void setEntity(DescriptionElementBase entity) {
public void removeElement(Media element) {
getEntity().removeMedia(element);
}
-
+
+ @Override
+ protected Control createToolbar() {
+ ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+
+ final String label = "Change View Type";
+
+ Action addAction = new Action(label, IAction.AS_PUSH_BUTTON) {
+ @Override
+ public void run() {
+ if(isExpanded()){
+ if(getEntityCollectionElement() instanceof ITogglableMediaElement){
+ ((ITogglableMediaElement) getEntityCollectionElement()).toggleAdvancedMediaView();
+ }
+ }
+ }
+ };
+ addAction.setToolTipText(label);
+
+ toolBarManager.add(addAction);
+
+ return toolBarManager.createControl(this);
+ }
+
}