blob: 28111a30020df227b88e9b3e9dbbe482682aa04a [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2011 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.wizards;
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.Logger;
import org.eclipse.stem.loggers.csv.util.CSVAdapterFactory;
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 Logger} properties.
*/
public class CSVLoggerPropertyStringProviderAdapterFactory extends
CSVAdapterFactory implements PropertyStringProviderAdapterFactory {
PropertyStringProviderAdapter adapter = null;
/**
* Default Constructor
*/
public CSVLoggerPropertyStringProviderAdapterFactory() {
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 CSVLoggerPropertyStringProviderAdapter();
} // if we didn't create one before
return adapter;
} // createDiseaseModelAdapter
/**
* This class represents
*/
public static class CSVLoggerPropertyStringProviderAdapter extends
PropertyStringProviderAdapter {
/**
* @param descriptor
* @return the NLS'd name of the property to display to the user
*/
public String getPropertyName(IItemPropertyDescriptor descriptor) {
return CSVLoggerWizardMessages
.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 CSVLoggerWizardMessages.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 CSVLoggerWizardMessages.getString(feature.getName()
+ UNIT_SUFFIX);
} // getPropertyUnits
}
}