/*******************************************************************************
* Copyright (c) 2011 Sebastian Benz.
* 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:
* Sebastian Benz - initial API and implementation
******************************************************************************/
/*
* generated by Xtext
*/
package de.sebastianbenz.xgherkin.ui.labeling;
import static com.google.common.collect.Iterables.transform;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.inject.Inject;
import de.sebastianbenz.xgherkin.gherkin.ExampleCell;
import de.sebastianbenz.xgherkin.gherkin.ExampleRow;
import de.sebastianbenz.xgherkin.gherkin.Step;
/**
* Provides labels for a EObjects.
*
* see http://www.eclipse.org/Xtext/documentation/latest/xtext.html#labelProvider
*/
public class GherkinLabelProvider extends DefaultEObjectLabelProvider {
@Inject
public GherkinLabelProvider(AdapterFactoryLabelProvider delegate) {
super(delegate);
}
String text(Step step){
if(step.getDesc().isEmpty()){
return "<empty>";
}else{
return step.getDesc().get(0);
}
}
String text(ExampleCell cell){
return cell.getValue();
}
String text(ExampleRow row){
return "| " + Joiner.on(" |�").join(transform(row.getCells(), new Function<ExampleCell, String>() {
public String apply(ExampleCell from) {
return from.getValue();
}
})) + " |";
}
/*
//Labels and icons can be computed like this:
String text(MyModel ele) {
return "my "+ele.getName();
}
String image(MyModel ele) {
return "MyModel.gif";
}
*/
}