| package org.eclipse.stem.diseasemodels.vector.presentation; |
| |
| /******************************************************************************* |
| * Copyright (c) 2007, 2008 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.emf.ecore.EAttribute; |
| import org.eclipse.emf.ecore.EcorePackage; |
| import org.eclipse.stem.diseasemodels.standard.DiseaseModel; |
| import org.eclipse.stem.diseasemodels.vector.DengueModel; |
| import org.eclipse.stem.diseasemodels.vector.MacdonaldRossDiseaseModel; |
| import org.eclipse.stem.diseasemodels.vector.SimpleDengueModel; |
| import org.eclipse.stem.diseasemodels.vector.VectorDiseaseModel; |
| import org.eclipse.stem.diseasemodels.vector.VectorPackage; |
| import org.eclipse.stem.ui.wizards.StandardDiseaseModelPropertyEditor; |
| import org.eclipse.swt.events.ModifyListener; |
| import org.eclipse.swt.widgets.Composite; |
| |
| /** |
| * |
| */ |
| public class VectorDiseaseModelPropertyEditor extends |
| StandardDiseaseModelPropertyEditor { |
| |
| /** |
| * @param parent |
| * @param style |
| * @param diseaseModel |
| * @param projectValidator |
| */ |
| public VectorDiseaseModelPropertyEditor(Composite parent, int style, |
| DiseaseModel diseaseModel, ModifyListener projectValidator, |
| IProject project) { |
| super(parent, style, diseaseModel, projectValidator, project); |
| } // MultiDiseaseModelPropertyEditor |
| |
| /** |
| * @see org.eclipse.stem.ui.wizards.StandardDiseaseModelPropertyEditor#populate(org.eclipse.stem.diseasemodels.standard.DiseaseModel) |
| */ |
| @Override |
| public void populate(DiseaseModel diseaseModel) { |
| super.populate(diseaseModel); |
| |
| for (EAttribute attribute : diseaseModel.eClass().getEAllAttributes()) { |
| if (attribute.eContainer().eContainer() == VectorPackage.eINSTANCE) { |
| String value = map.get(attribute).getText(); |
| |
| if (attribute.getEType() == EcorePackage.Literals.ESTRING) { |
| diseaseModel.eSet(attribute, value); |
| } else if (attribute.getEType() == EcorePackage.Literals.EDOUBLE) { |
| diseaseModel.eSet(attribute, Double.parseDouble(value)); |
| } |
| } |
| } |
| } |
| |
| /** |
| * @see org.eclipse.stem.ui.wizards.StandardDiseaseModelPropertyEditor#validate() |
| */ |
| @Override |
| public boolean validate() { |
| boolean retValue = super.validate(); |
| // Infectious Mortality Rate |
| /* |
| * if (retValue) { // Yes final Text text = map |
| * .get(MultipopulationPackage |
| * .Literals.MULTI_POPULATION_SI_DISEASE_MODEL__RECOVERY_RATE); if (text |
| * != null) { // Yes retValue = !text.getText().equals(""); |
| * //$NON-NLS-1$ // nothing? if (!retValue) { // Yes errorMessage = |
| * DiseaseWizardMessages .getString("RECOVERY_RATE_INVALID"); |
| * //$NON-NLS-1$ } // if else { // No // Is it a valid value? retValue = |
| * isValidValue(text.getText(), 0.0); if (!retValue) { // No |
| * errorMessage = MultipopulationDiseaseWizardMessages |
| * .getString("RECOVERY_RATE_INVALID"); //$NON-NLS-1$ } // if } } // if |
| * } if (retValue) { // Yes Text text = map |
| * .get(MultipopulationPackage.Literals. |
| * MULTI_POPULATION_SI_DISEASE_MODEL__PHYSICALLY_ADJACENT_INFECTIOUS_PROPORTION |
| * ); if (text != null) { // Yes retValue = !text.getText().equals(""); |
| * //$NON-NLS-1$ // nothing? if (!retValue) { // Yes errorMessage = |
| * DiseaseWizardMessages .getString("PHYS_ADJ_INVALID"); //$NON-NLS-1$ } |
| * // if else { // No // Is it a valid value? retValue = |
| * isValidValue(text.getText(), 0.0); if (!retValue) { // No |
| * errorMessage = MultipopulationDiseaseWizardMessages |
| * .getString("PHYS_ADJ_INVALID"); //$NON-NLS-1$ } // if } } // if } if |
| * (retValue) { // Yes Text text = map |
| * .get(MultipopulationPackage.Literals |
| * .MULTI_POPULATION_SI_DISEASE_MODEL__ROAD_NETWORK_INFECTIOUS_PROPORTION |
| * ); if (text != null) { // Yes retValue = !text.getText().equals(""); |
| * //$NON-NLS-1$ // nothing? if (!retValue) { // Yes errorMessage = |
| * DiseaseWizardMessages .getString("ROAD_NET_INVALID"); //$NON-NLS-1$ } |
| * // if else { // No // Is it a valid value? retValue = |
| * isValidValue(text.getText(), 0.0); if (!retValue) { // No |
| * errorMessage = MultipopulationDiseaseWizardMessages |
| * .getString("ROAD_NET_INVALID"); //$NON-NLS-1$ } // if } } // if } |
| */ |
| return retValue; |
| } |
| |
| } // VectorDiseaseModelPropertyEditor |