blob: f5eb61c8d1519c45e0f68553349477b29c8c2a3d [file] [log] [blame]
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.stem.diseasemodels.standard.DiseaseModel;
import org.eclipse.stem.diseasemodels.vector.DengueModel;
import org.eclipse.stem.diseasemodels.vector.MacdonaldRossDiseaseModel;
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);
if (diseaseModel instanceof VectorDiseaseModel) {
VectorDiseaseModel model = (VectorDiseaseModel) diseaseModel;
model.setVectorPopulationIdentifier(map
.get(VectorPackage.Literals.VECTOR_DISEASE_MODEL__VECTOR_POPULATION_IDENTIFIER)
.getText());
}
if (diseaseModel instanceof MacdonaldRossDiseaseModel) {
MacdonaldRossDiseaseModel model = (MacdonaldRossDiseaseModel) diseaseModel;
model.setBitingRate(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__BITING_RATE)
.getText()));
model.setInfectiousBitingProportionHuman(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__INFECTIOUS_BITING_PROPORTION_HUMAN)
.getText()));
model.setInfectiousBitingProportionVector(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__INFECTIOUS_BITING_PROPORTION_VECTOR)
.getText()));
model.setRecoveryRate(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__RECOVERY_RATE)
.getText()));
model.setIncubationRate(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__INCUBATION_RATE)
.getText()));
model.setVectorIncubationRate(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__VECTOR_INCUBATION_RATE)
.getText()));
model.setImmunityLossRate(Double
.parseDouble(map
.get(VectorPackage.Literals.MACDONALD_ROSS_DISEASE_MODEL__IMMUNITY_LOSS_RATE)
.getText()));
}
if (diseaseModel instanceof DengueModel) {
// TODO
}
}
/**
* @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