blob: dc90a11298fc12c746920d6aa52afbd67931e9cf [file] [log] [blame]
/******************************************************************************
* 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
*******************************************************************************/
package org.eclipse.stem.ui.adapters.loggerpropertyeditor;
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.logger.util.LoggerAdapterFactory;
import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProvider;
import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProviderAdapter;
import org.eclipse.stem.ui.adapters.propertystrings.PropertyStringProviderAdapterFactory;
import org.eclipse.stem.ui.wizards.LoggerWizardMessages;
/**
* This class is used to NLS'd strings for {@link Logger} properties.
*/
public class SimulationLoggerPropertyStringProviderAdapterFactory extends
LoggerAdapterFactory implements PropertyStringProviderAdapterFactory {
PropertyStringProviderAdapter adapter = null;
/**
* Default Constructor
*/
public SimulationLoggerPropertyStringProviderAdapterFactory() {
super();
PropertyStringProviderAdapterFactory.INSTANCE.addAdapterFactory(this);
}
/**
* @see org.eclipse.emf.common.notify.impl.AdapterFactoryImpl#isFactoryForType(java.lang.Object)
*/
@Override
public boolean isFactoryForType(Object type) {
return super.isFactoryForType(type) || type == PropertyStringProvider.class;
}
/**
* @see org.eclipse.stem.diseasemodels.standard.util.StandardAdapterFactory#createDiseaseModelAdapter()
*/
@Override
public Adapter createLoggerAdapter() {
// Have we created one before?
if (adapter == null) {
// No
adapter = new SimulationLoggerPropertyStringProviderAdapter();
} // if we didn't create one before
return adapter;
} // createDiseaseModelAdapter
/**
* This class represents
*/
public static class SimulationLoggerPropertyStringProviderAdapter extends
PropertyStringProviderAdapter {
/**
* @param descriptor
* @return the NLS'd name of the property to display to the user
*/
public String getPropertyName(IItemPropertyDescriptor descriptor) {
return LoggerWizardMessages
.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 LoggerWizardMessages.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 LoggerWizardMessages.getString(feature.getName()
+ UNIT_SUFFIX);
} // getPropertyUnits
}
}