fixes issues with named area selection dialog and custom areas; fixes #2265
authorn.hoffmann <n.hoffmann@localhost>
Mon, 7 Mar 2011 12:17:24 +0000 (12:17 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 7 Mar 2011 12:17:24 +0000 (12:17 +0000)
.gitattributes
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizardPage.java [deleted file]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewPart.java

index ec4379e2552c274238515337588dffffebd80fe7..ea2450b6e7ac27ae811976d2f5d7fb65d241b461 100644 (file)
@@ -822,7 +822,6 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewPersonWizard.j
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewPolytomousKeyWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewReferenceWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java -text
-taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTeamWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewUserWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/PolytomousKeyWizardPage.java -text
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizardPage.java
deleted file mode 100644 (file)
index db659db..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-// $Id$
-/**
-* Copyright (C) 2007 EDIT
-* 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.
-*/
-
-package eu.etaxonomy.taxeditor.newWizard;
-
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.ITreeNode;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.parser.ParseHandler;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
-import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
-import eu.etaxonomy.taxeditor.ui.forms.RootElement;
-import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
-import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
-import eu.etaxonomy.taxeditor.ui.selection.ClassificationSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.TaxonSelectionElement;
-
-/**
- * <p>NewTaxonNodeWizardPage class.</p>
- *
- * @author n.hoffmann
- * @created Sep 29, 2010
- * @version 1.0
- */
-@Deprecated //delete this file when refactoring is complete 
-public class NewTaxonNodeWizardPage extends WizardPage implements IPropertyChangeListener, IConversationEnabled{       
-       private ClassificationSelectionElement selection_classification;
-       private TaxonNodeSelectionElement selection_parentTaxonNode;
-       private TaxonSelectionElement selection_reuseExistingTaxon;
-       private TextWithLabelElement text_newTaxonName;
-       private CheckboxElement checkbox_openInEditor;
-       private CdmFormFactory formFactory;
-       private NameSelectionElement selection_reuseExistingName;
-       private ITreeNode parentTreeNode;
-       private Classification classification;
-       private Taxon taxon;
-       private boolean openInEditor = true;
-       private ConversationHolder conversation;
-       private ITreeNode initiallySelectedNode;
-
-       /**
-        * <p>Constructor for NewTaxonNodeWizardPage.</p>
-        *
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param selectedNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
-        */
-       protected NewTaxonNodeWizardPage(ConversationHolder conversation, ITreeNode selectedNode) {
-               super("Taxon");
-               
-               setTitle("Taxon");
-               
-               this.conversation = conversation;
-               this.formFactory = new CdmFormFactory(Display.getCurrent());
-               
-               formFactory.addPropertyChangeListener(this);
-               
-               initiallySelectedNode = selectedNode;
-               
-       }
-       
-       /**
-        * <p>openInEditor</p>
-        *
-        * @return a boolean.
-        */
-       public boolean openInEditor(){
-               return openInEditor;
-       }       
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void propertyChange(PropertyChangeEvent event) {
-               
-               Object eventSource = event.getSource();
-               if(eventSource == selection_classification){
-                       setClassification(selection_classification.getEntity());
-               }
-               else if(eventSource == selection_parentTaxonNode){
-                       setParentTreeNode(selection_parentTaxonNode.getEntity());
-               }
-               else if(eventSource == selection_reuseExistingTaxon){
-                       boolean enabled = selection_reuseExistingTaxon.getEntity() == null;
-                       selection_reuseExistingName.setEnabled(enabled);
-                       text_newTaxonName.setEnabled(enabled);
-                       
-                       setTaxon(selection_reuseExistingTaxon.getEntity());
-               }
-               else if(eventSource == selection_reuseExistingName){
-                       boolean enabled = selection_reuseExistingName.getEntity() == null;
-                       selection_reuseExistingTaxon.setEnabled(enabled);
-                       text_newTaxonName.setEnabled(enabled);
-                       
-                       setTaxon(selection_reuseExistingName.getEntity());
-               }
-               else if(eventSource == text_newTaxonName){
-                       boolean enabled = CdmUtils.isEmpty(text_newTaxonName.getText());
-                       selection_reuseExistingTaxon.setEnabled(enabled);
-                       selection_reuseExistingName.setEnabled(enabled);
-                       
-                       setTaxon(text_newTaxonName.getText());
-               }
-               else if(eventSource == checkbox_openInEditor){
-                       setOpenInEditor(checkbox_openInEditor.getSelection());
-               }
-               
-               checkComplete();
-       }
-
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void createControl(Composite parent) {
-               Composite control = formFactory.createComposite(parent);
-               
-               control.setLayout(CdmFormFactory.LAYOUT(2, false));
-               RootElement rootElement = new RootElement(formFactory, control);
-               
-               selection_classification = (ClassificationSelectionElement) formFactory.createSelectionElement(SelectionType.CLASSIFICATION, getConversationHolder(), rootElement, "Classification", null, SWT.NULL);
-               selection_parentTaxonNode = (TaxonNodeSelectionElement) formFactory.createSelectionElement(SelectionType.TAXON_NODE, getConversationHolder(), rootElement, "Parent", null, SWT.NULL);
-               selection_reuseExistingTaxon = (TaxonSelectionElement) formFactory.createSelectionElement(SelectionType.TAXON, getConversationHolder(), rootElement, "Reuse existing Taxon", null, SWT.NULL);
-               
-               selection_reuseExistingName = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, getConversationHolder(), rootElement, "Reuse existing name", null, SWT.NULL);
-               
-               text_newTaxonName = formFactory.createTextWithLabelElement(rootElement, "New Taxon", "", SWT.NULL);
-               text_newTaxonName.setFocus();
-               
-               checkbox_openInEditor = formFactory.createCheckbox(rootElement, "Open in Editor", openInEditor, SWT.NULL);
-               
-               setParentTreeNode(initiallySelectedNode);
-               
-               Color bgColor = getShell().getBackground();
-               
-               rootElement.setBackground(bgColor);
-               control.setBackground(bgColor);
-               
-               setControl(control);
-               
-       }
-       
-       /**
-        * @param classification the classification to set
-        */
-       private void setClassification(Classification classification) {
-               this.classification = classification;
-               setParentTreeNode(classification);
-       }
-
-       /**
-        * @param parentTreeNode the parentTreeNode to set
-        */
-       private void setParentTreeNode(ITreeNode parentTreeNode) {
-               if(parentTreeNode == null){
-                       setPageComplete(false);
-                       return;
-               }
-               
-               this.parentTreeNode = parentTreeNode;
-
-               if(parentTreeNode instanceof Classification){
-                       classification = (Classification) parentTreeNode;
-                       selection_classification.setEntity(classification);
-                       selection_parentTaxonNode.setEntity(null);
-               }
-               else if(parentTreeNode instanceof TaxonNode){
-                       classification = ((TaxonNode) parentTreeNode).getClassification();
-                       selection_classification.setEntity(classification);
-                       selection_parentTaxonNode.setEntity((TaxonNode) parentTreeNode);
-               }               
-       }
-
-       /**
-        * 
-        * @param taxon
-        */
-       private void setTaxon(Taxon taxon) {
-               this.taxon = taxon;
-       }
-       
-       private void setTaxon(String taxonNameString){
-               TaxonNameBase taxonName = ParseHandler.parseReferencedName(taxonNameString, null);
-               setTaxon(taxonName);
-       }               
-               
-       private void setTaxon(TaxonNameBase taxonName){
-               Reference secundum = null;
-               if(getParentTreeNode() != null){
-                       if(getParentTreeNode() instanceof Classification){
-                               secundum = ((Classification) getParentTreeNode()).getReference();
-                       }
-                       else if(getParentTreeNode() instanceof TaxonNode){
-                               secundum = ((TaxonNode) getParentTreeNode()).getTaxon().getSec();
-                       }
-               }
-               taxon = Taxon.NewInstance(taxonName, secundum);
-       }
-
-       /**
-        * @param openInEditor the openInEditor to set
-        */
-       private void setOpenInEditor(boolean openInEditor) {
-               this.openInEditor = openInEditor;
-       }
-       
-       /**
-        * <p>Getter for the field <code>parentTreeNode</code>.</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
-        */
-       public ITreeNode getParentTreeNode() {
-               return parentTreeNode;
-       }
-
-       /**
-        * <p>Getter for the field <code>taxon</code>.</p>
-        *
-        * @return the taxon
-        */
-       public Taxon getTaxon() {
-               return taxon;
-       }
-       
-       /**
-        * 
-        */
-       private void checkComplete() {
-               if(classification == null){
-                       setMessage("No classification", WARNING);
-                       setPageComplete(false);
-               }else{
-                       setMessage(null);
-                       setPageComplete(true);
-               }
-               
-               
-       }
-       
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void update(CdmDataChangeMap changeEvents) {
-               
-       }
-
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-        */
-       /** {@inheritDoc} */
-       @Override
-       public ConversationHolder getConversationHolder() {
-               return conversation;
-       }       
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void dispose() {
-               formFactory.removePropertyChangeListener(this);
-               super.dispose();
-       }
-}
index ce5da8793a29c2de4684bb2b5ed63d5cabcb0810..abbb76463385ecfdd0af81c7cf19f8338d2685fe 100644 (file)
@@ -104,13 +104,8 @@ public class NamedAreaSelectionDialog extends
        protected void fillViewMenu(IMenuManager menuManager) {
                                
                super.fillViewMenu(menuManager);
-               
-               List<TermVocabulary<NamedArea>> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
-               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
-               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
-               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
-               
-               for(TermVocabulary<NamedArea> vocabulary : vocabularies){
+                               
+               for(TermVocabulary<NamedArea> vocabulary : getVocabularies()){
                        IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
                        menuManager.add(action);
                        action.setChecked(true);
@@ -134,10 +129,15 @@ public class NamedAreaSelectionDialog extends
        /** {@inheritDoc} */
        @Override
        protected void init() {
-               selectedVocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
-               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
-               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
-               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
+               selectedVocabularies = getVocabularies();
+       }
+       
+       private List<TermVocabulary<NamedArea>> getVocabularies(){
+               List<TermVocabulary<NamedArea>> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
+               return vocabularies;
        }
 
        /** {@inheritDoc} */
index 21a205cd1631e1450960cb7ba3041b675de67fa4..78b3f900945174426ef7a78fb08d149d48a2561d 100644 (file)
 package eu.etaxonomy.taxeditor.ui.forms;
 
 import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
@@ -67,7 +71,12 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage implemen
         */
        /** {@inheritDoc} */
        public void createControl(Composite parent) {
-               Composite control = formFactory.createComposite(parent);
+               ScrolledForm scrolledForm = formFactory.createScrolledForm(parent);
+               GridLayout layout = new GridLayout();           
+               scrolledForm.getBody().setLayout(layout);
+               
+               Composite control = formFactory.createComposite(scrolledForm.getBody());
+               control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                
                control.setLayout(CdmFormFactory.LAYOUT(2, false));
                WizardPageRootElement rootElement = new WizardPageRootElement(formFactory, control, getConversationHolder());
@@ -78,8 +87,9 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage implemen
                
                rootElement.setBackground(bgColor);
                control.setBackground(bgColor);
+               scrolledForm.setBackground(bgColor);
                
-               setControl(control);
+               setControl(scrolledForm);
        }
        
        /**
@@ -97,7 +107,7 @@ public abstract class AbstractCdmEntityWizardPage<T> extends WizardPage implemen
         * @param rootElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
         * @return a {@link eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement} object.
         */
-       public abstract AbstractCdmDetailElement createElement(ICdmFormElement rootElement);
+       public abstract AbstractCdmDetailElement<T> createElement(ICdmFormElement rootElement);
        
        private class WizardPageRootElement extends RootElement implements IConversationEnabled{
 
index 2ebb261e0e7e6d697ffd4eb2e25775b291409de7..5beaa06e985bd410e7461eb993ac04f27fa27e59 100644 (file)
@@ -112,13 +112,20 @@ public class CdmDataSourceViewPart extends ViewPart{
                        
                                List<ICdmDataSource> dataSources = CdmDataSourceRepository.getAll();
                                
-                               final List<CdmMetaDataAwareDataSourceContainer> containers = new ArrayList<CdmMetaDataAwareDataSourceContainer>();
+                               List<CdmMetaDataAwareDataSourceContainer> containers = new ArrayList<CdmMetaDataAwareDataSourceContainer>();
                                
-                               for(final ICdmDataSource dataSource : dataSources){
+                               for(ICdmDataSource dataSource : dataSources){
                                        containers.add(new CdmMetaDataAwareDataSourceContainer(dataSource, CdmDataSourceViewPart.this));
                                        monitor.worked(1);
                                }
                                
+//                             Display.getDefault().asyncExec(new Runnable() {
+//                                     
+//                                     @Override
+//                                     public void run() {
+//                                             viewer.setInput(containers);
+//                                     }
+//                             });                             
                                viewer.setInput(containers);
                                
                        }finally{