blob: 4f34e32ec68055b3329f8cae1b84d4ccfb189dad [file] [log] [blame]
// StandardPropertyStringProviderAdapterFactory.java
package org.eclipse.stem.ui.graphgenerators.wizards;
/******************************************************************************
* 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.graphgenerators.util.GraphgeneratorsAdapterFactory;
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 Graph Generator properties.
*/
public class GraphGeneratorPropertyStringProviderAdapterFactory extends
GraphgeneratorsAdapterFactory implements PropertyStringProviderAdapterFactory {
PropertyStringProviderAdapter adapter = null;
/**
* Default Constructor
*/
public GraphGeneratorPropertyStringProviderAdapterFactory() {
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 createGraphGeneratorAdapter() {
// Have we created one before?
if (adapter == null) {
// No
adapter = new GraphGeneratorPropertyStringProviderAdapter();
} // if we didn't create one before
return adapter;
} // createDiseaseModelAdapter
public static class GraphGeneratorPropertyStringProviderAdapter extends
PropertyStringProviderAdapter {
/**
* @param descriptor
* @return the NLS'd name of the property to display to the user
*/
public String getPropertyName(IItemPropertyDescriptor descriptor) {
return Messages
.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 Messages.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 Messages.getString(feature.getName()
+ UNIT_SUFFIX);
} // getPropertyUnits
}
}