| // StandardPropertyStringProviderAdapterFactory.java |
| package org.eclipse.stem.solvers.stochastic.presentation; |
| |
| /****************************************************************************** |
| * Copyright (c) 2007 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.emf.common.notify.Adapter; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| import org.eclipse.stem.core.solver.util.SolverAdapterFactory; |
| import org.eclipse.stem.solvers.stochastic.StochasticPackage; |
| import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProvider; |
| import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProviderAdapter; |
| import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProviderAdapterFactory; |
| |
| /** |
| * This class is used to NLS'd strings for {@link DiseaseModel} properties. |
| */ |
| public class StochasticSolverPropertyStringProviderAdapterFactory extends |
| SolverAdapterFactory implements PropertyStringProviderAdapterFactory { |
| |
| |
| PropertyStringProviderAdapter adapter = null; |
| |
| /** |
| * Default Constructor |
| */ |
| public StochasticSolverPropertyStringProviderAdapterFactory() { |
| super(); |
| PropertyStringProviderAdapterFactory.INSTANCE.addAdapterFactory(this); |
| } |
| |
| /** |
| * @see org.eclipse.emf.common.notify.impl.AdapterFactoryImpl#isFactoryForType(java.lang.Object) |
| */ |
| @Override |
| public boolean isFactoryForType(Object type) { |
| if(type == StochasticPackage.eINSTANCE) return true; |
| return super.isFactoryForType(type) || type == PropertyStringProvider.class; |
| } |
| |
| /** |
| * @see org.eclipse.stem.diseasemodels.standard.util.StandardAdapterFactory#createDiseaseModelAdapter() |
| */ |
| @Override |
| public Adapter createSolverAdapter() { |
| // Have we created one before? |
| if (adapter == null) { |
| // No |
| adapter = new SolverPropertyStringProviderAdapter(); |
| } // if we didn't create one before |
| return adapter; |
| } // createDiseaseModelAdapter |
| |
| /** |
| * This class represents |
| */ |
| public static class SolverPropertyStringProviderAdapter extends |
| PropertyStringProviderAdapter { |
| |
| /** |
| * @param descriptor |
| * @return the NLS'd name of the property to display to the user |
| */ |
| public String getPropertyName(IItemPropertyDescriptor descriptor) { |
| return SolverMessages |
| .getString(((EStructuralFeature) descriptor |
| .getFeature(null)).getName()); |
| } // getPropertyName |
| |
| /** |
| * @param descriptor |
| * @return the NLS'd tool tip text that describes the property |
| */ |
| public String getPropertyToolTip( |
| IItemPropertyDescriptor descriptor) { |
| final EStructuralFeature feature = (EStructuralFeature) descriptor |
| .getFeature(null); |
| return SolverMessages.getString(feature.getName() |
| + TT_SUFFIX); |
| } // getPropertyToolTip |
| |
| /** |
| * @param descriptor |
| * @return the NLS'd text that represents the units of the |
| * property |
| */ |
| public String getPropertyUnits( |
| IItemPropertyDescriptor descriptor) { |
| final EStructuralFeature feature = (EStructuralFeature) descriptor |
| .getFeature(null); |
| return SolverMessages.getString(feature.getName() |
| + UNIT_SUFFIX); |
| } // getPropertyUnits |
| |
| } // StandardPropertyStringProviderAdapter |
| } // StandardPropertyStringProviderAdapterFactory |