fixes #1041
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / forms / EditorFormToolkit.java
index 1ef3c41c6a141e2941bedf04e2d70275bef08c96..a8c8dad3619978ae29d49b6b51bbf9671bc58fbf 100644 (file)
@@ -5,6 +5,9 @@ package eu.etaxonomy.taxeditor.forms;
 
 import java.net.URI;
 
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
@@ -16,16 +19,45 @@ import org.eclipse.ui.internal.forms.widgets.FormFonts;
 
 import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
 import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.Credit;
 import eu.etaxonomy.cdm.model.common.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.common.Extension;
+import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.common.IdentifiableSource;
 import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.Marker;
+import eu.etaxonomy.cdm.model.common.VersionableEntity;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
+import eu.etaxonomy.cdm.model.media.Rights;
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
+import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.taxeditor.forms.entitysections.AnnotationComposite;
 import eu.etaxonomy.taxeditor.forms.entitysections.AnnotationSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.CreditComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.CreditSection;
 import eu.etaxonomy.taxeditor.forms.entitysections.DescriptionElementSourceComposite;
-import eu.etaxonomy.taxeditor.forms.entitysections.OriginalSourceSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.DescriptionElementSourceSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.ExtensionComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.ExtensionSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.MarkerComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.MarkerSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.NomenclaturalStatusComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.NomenclaturalStatusSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.IdentifiableSourceComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.ProtologComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.ProtologSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.RightsComposite;
+import eu.etaxonomy.taxeditor.forms.entitysections.RightsSection;
+import eu.etaxonomy.taxeditor.forms.entitysections.SourceSection;
 import eu.etaxonomy.taxeditor.forms.selectioncomposites.TaxonSelectionComposite;
 import eu.etaxonomy.taxeditor.forms.termcombos.LanguageComboComposite;
+import eu.etaxonomy.taxeditor.forms.termcombos.NomenclaturalStatusTypeComboComposite;
+import eu.etaxonomy.taxeditor.forms.termcombos.RankComboComposite;
 
 /**
  * @author nho
@@ -77,19 +109,21 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public MultilineTextWithLabel createMultilineTextWithLabel(Composite parent, String labelString, int textHeight, int style){
-               return new MultilineTextWithLabel(parent, labelString, "", textHeight, style);
+       public MultilineTextWithLabel createMultilineTextWithLabel(Composite parent, String labelString, IPropertyChangeListener listener, int textHeight, int style){
+               return new MultilineTextWithLabel(parent, labelString, "", listener, textHeight, style);
        }
+
        
        /**
         * 
         * @param parent
-        * @param source
+        * @param labelString
+        * @param initialText
         * @param style
         * @return
         */
-       public DescriptionElementSourceComposite createDescriptionElementSourceComposite(Composite parent, DescriptionElementSource source, int style){
-               return new DescriptionElementSourceComposite(parent, source, style);
+       public TextWithLabelComposite createTextWithLabelComposite(Composite parent, String labelString, String initialText, IPropertyChangeListener listener, int style){
+               return new TextWithLabelComposite(parent, labelString, initialText, listener, style);
        }
        
        /**
@@ -100,8 +134,20 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public TextWithLabelComposite createTextWithLabelComposite(Composite parent, String labelString, String initialText, int style){
-               return new TextWithLabelComposite(parent, labelString, initialText, style);
+       public TextWithLabelComposite createTextComposite(Composite parent, String initialText, IPropertyChangeListener listener, int style){
+               return new TextWithLabelComposite(parent, null, initialText, listener, style);
+       }
+       
+       /**
+        * 
+        * @param parent
+        * @param labelString
+        * @param selection
+        * @param style
+        * @return
+        */
+       public LanguageComboComposite createLanguageComboComposite(Composite parent, String labelString, Language selection, IPropertyChangeListener listener, int style){
+               return new LanguageComboComposite(parent, labelString, selection, listener, style);
        }
        
        /**
@@ -109,11 +155,26 @@ public class EditorFormToolkit extends FormToolkit{
         * @param parent
         * @param labelString
         * @param selection
+        * @param listener
         * @param style
         * @return
         */
-       public LanguageComboComposite createLanguageComboComposite(Composite parent, String labelString, Language selection, int style){
-               return new LanguageComboComposite(parent, labelString, selection, style);
+       public RankComboComposite createRankComboComposite(Composite parent, String labelString, Rank selection, IPropertyChangeListener listener, int style){
+               return new RankComboComposite(parent, labelString, selection, listener, style);
+       }
+       
+       /**
+        * @param parent
+        * @param string
+        * @param object
+        * @param namePropertySection
+        * @param null1
+        * @return
+        */
+       public NomenclaturalStatusTypeComboComposite createNomenclaturalStatusCombo(Composite parent,
+                       String labelString, NomenclaturalStatusType selection,
+                       IPropertyChangeListener listener, int style) {
+               return new NomenclaturalStatusTypeComboComposite(parent, labelString, selection, listener, style, style);
        }
        
        /**
@@ -146,8 +207,8 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public AnnotationComposite createAnnotationComposite(Composite parent, Annotation annotation, int style) {
-               return new AnnotationComposite(parent, annotation, style);
+       public AnnotationComposite createAnnotationComposite(Composite parent, Annotation annotation, SelectionListener removeListener, IPropertyChangeListener listener, int style) {
+               return new AnnotationComposite(parent, annotation, removeListener, listener, style);
        }
        
        /**
@@ -157,8 +218,20 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public TaxonSelectionComposite createTaxonSelectionComposite(Composite parent, TaxonBase selection, int style) {
-               return new TaxonSelectionComposite(parent, "Taxon", selection, style);
+       public TaxonSelectionComposite createTaxonSelectionComposite(Composite parent, TaxonBase selection, IPropertyChangeListener listener, int style) {
+               return new TaxonSelectionComposite(parent, "Taxon", selection, listener, style);
+       }
+       
+       /**
+        * 
+        * @param parent
+        * @param annotatableEntity
+        * @param style
+        * @return
+        */
+       public AnnotationSection createAnnotationSection(Composite parent, AnnotatableEntity annotatableEntity,
+                       IPropertyChangeListener listener, int style){
+               return new AnnotationSection(parent, annotatableEntity, listener, style);
        }
        
        /**
@@ -168,8 +241,20 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public AnnotationSection createAnnotationSection(Composite parent, AnnotatableEntity annotatableEntity,  int style){
-               return new AnnotationSection(parent, annotatableEntity, style);
+       public NomenclaturalStatusSection createNomenclaturalStatusSection(Composite parent, TaxonNameBase taxonNameBase,
+                       IPropertyChangeListener listener, int style){
+               return new NomenclaturalStatusSection(parent, taxonNameBase, listener, style);
+       }
+       
+       /**
+        * @param parent
+        * @param annotatableEntity
+        * @param style
+        * @return
+        */
+       public MarkerSection createMarkerSection(Composite parent, AnnotatableEntity annotatableEntity,
+                       IPropertyChangeListener listener, int style) {
+               return new MarkerSection(parent, annotatableEntity, listener, style);
        }
        
        /**
@@ -179,10 +264,83 @@ public class EditorFormToolkit extends FormToolkit{
         * @param style
         * @return
         */
-       public OriginalSourceSection createOriginalSourceSection(Composite parent, DescriptionElementBase entity, int style){
-               return new OriginalSourceSection(parent, entity, style);
+       public DescriptionElementSourceSection createOriginalSourceSection(Composite parent, DescriptionElementBase entity,
+                       IPropertyChangeListener listener, int style){
+               return new DescriptionElementSourceSection(parent, entity, listener, style);
        }
        
+       /**
+        * @param parent
+        * @param identifiableEntity
+        * @param style
+        * @return
+        */
+       public CreditSection createCreditSection(Composite parent, IdentifiableEntity identifiableEntity,
+                       IPropertyChangeListener listener, int style) {
+               return new CreditSection(parent, identifiableEntity, listener, style);
+       }
+       
+       /**
+        * 
+        * @param parent
+        * @param identifiableEntity
+        * @param style
+        * @return
+        */
+       public ExtensionSection createExtensionSection(Composite parent, IdentifiableEntity identifiableEntity,
+                       IPropertyChangeListener listener, int style) {
+               return new ExtensionSection(parent, identifiableEntity, listener, style);
+       }
+
+       /**
+        * 
+        * @param parent
+        * @param object
+        * @param null1
+        * @return
+        */
+       public RightsSection createRightsSection(Composite parent, IdentifiableEntity identifiableEntity,
+                       IPropertyChangeListener listener, int style) {
+               return new RightsSection(parent, identifiableEntity, listener, style);
+       }
+
+       /**
+        * 
+        * @param parent
+        * @param object
+        * @param null1
+        * @return
+        */
+       public SourceSection createSourcesSection(Composite parent, IdentifiableEntity identifiableEntity,
+                       IPropertyChangeListener listener, int style) {
+               return new SourceSection(parent, identifiableEntity, listener, style);
+       }
+       
+       /**
+        * 
+        * @param parent
+        * @param listener
+        * @param nonViralName
+        * @param style
+        * @return
+        */
+       public NonViralNameDetailsComposite createNonViralNameDetailsComposite(Composite parent,
+                       IPropertyChangeListener listener, int style) {
+               return new NonViralNameDetailsComposite(parent, listener, style);
+       }
+       
+       /**
+        * @param parent
+        * @param string
+        * @param b
+        * @param taxonBasePropertySection
+        * @return
+        */
+       public CheckboxComposite createCheckbox(Composite parent, String label, boolean initialState,
+                       IPropertyChangeListener listener) {
+               return new CheckboxComposite(parent, label, initialState, listener, SWT.NULL);
+       }
+
        
        /**
         * Creates a section as a part of the form.
@@ -205,13 +363,13 @@ public class EditorFormToolkit extends FormToolkit{
                
                section.setFont(boldFontHolder2.getBoldFont(section.getParent().getFont()));
 
-//             if ((section.getStyle() & Section.TITLE_BAR) != 0
-//                             || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
+               if ((section.getStyle() & Section.TITLE_BAR) != 0
+                               || (section.getStyle() & Section.SHORT_TITLE_BAR) != 0) {
                        getColors().initializeSectionToolBarColors();
                        section.setTitleBarBackground(getColors().getColor(IFormColors.TB_BG));
                        section.setTitleBarBorderColor(getColors()
                                        .getColor(IFormColors.TB_BORDER));
-//             }
+               }
                // call setTitleBarForeground regardless as it also sets the label color
                section.setTitleBarForeground(getColors()
                                .getColor(IFormColors.TB_TOGGLE));
@@ -250,5 +408,20 @@ public class EditorFormToolkit extends FormToolkit{
                }
        }
 
+       /**
+        * @param parent
+        * @param object
+        * @param listener
+        * @param i
+        * @return
+        */
+       public ProtologSection createProtologSection(Composite parent,
+                       TaxonNameDescription nameDescription, IPropertyChangeListener listener, int style) {
+               return new ProtologSection(parent, nameDescription, listener, style);
+       }
+       
+       public CdmComposite createCdmComposite(Composite parent, VersionableEntity entity, int style){
+               return new CdmComposite(parent, entity, null, style); 
+       }
 
 }