From: n.hoffmann Date: Mon, 7 Mar 2011 12:17:24 +0000 (+0000) Subject: fixes issues with named area selection dialog and custom areas; fixes #2265 X-Git-Tag: rcp.ss-first-working-version~185 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/e53963de6b81e3f0be33a8c075d1c489015d279d fixes issues with named area selection dialog and custom areas; fixes #2265 --- diff --git a/.gitattributes b/.gitattributes index ec4379e25..ea2450b6e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 index db659db68..000000000 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizardPage.java +++ /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; - -/** - *

NewTaxonNodeWizardPage class.

- * - * @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; - - /** - *

Constructor for NewTaxonNodeWizardPage.

- * - * @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; - - } - - /** - *

openInEditor

- * - * @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; - } - - /** - *

Getter for the field parentTreeNode.

- * - * @return a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object. - */ - public ITreeNode getParentTreeNode() { - return parentTreeNode; - } - - /** - *

Getter for the field taxon.

- * - * @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(); - } -} diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java index ce5da8793..abbb76463 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java @@ -104,13 +104,8 @@ public class NamedAreaSelectionDialog extends protected void fillViewMenu(IMenuManager menuManager) { super.fillViewMenu(menuManager); - - List> 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 vocabulary : vocabularies){ + + for(TermVocabulary 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> getVocabularies(){ + List> 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} */ diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java index 21a205cd1..78b3f9009 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/AbstractCdmEntityWizardPage.java @@ -11,8 +11,12 @@ 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 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 extends WizardPage implemen rootElement.setBackground(bgColor); control.setBackground(bgColor); + scrolledForm.setBackground(bgColor); - setControl(control); + setControl(scrolledForm); } /** @@ -97,7 +107,7 @@ public abstract class AbstractCdmEntityWizardPage 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 createElement(ICdmFormElement rootElement); private class WizardPageRootElement extends RootElement implements IConversationEnabled{ diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewPart.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewPart.java index 2ebb261e0..5beaa06e9 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewPart.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/CdmDataSourceViewPart.java @@ -112,13 +112,20 @@ public class CdmDataSourceViewPart extends ViewPart{ List dataSources = CdmDataSourceRepository.getAll(); - final List containers = new ArrayList(); + List containers = new ArrayList(); - 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{