001package org.nasdanika.html.ecore; 002 003import org.eclipse.emf.ecore.EClass; 004import org.eclipse.emf.ecore.ENamedElement; 005import org.eclipse.emf.ecore.EPackage; 006import org.nasdanika.common.Context; 007import org.nasdanika.common.ProgressMonitor; 008import org.nasdanika.emf.EObjectAdaptable; 009import org.nasdanika.html.model.app.Action; 010 011public class ENamedElementActionSupplier<T extends ENamedElement> extends EModelElementActionSupplier<T> { 012 013 public ENamedElementActionSupplier(T value, Context context, java.util.function.Function<EPackage,String> ePackagePathComputer) { 014 super(value, context, ePackagePathComputer); 015 } 016 017 @Override 018 public Action execute(EClass contextEClass, ProgressMonitor progressMonitor) throws Exception { 019 Action action = super.execute(contextEClass, progressMonitor); 020 Context resourceContext = EObjectAdaptable.getResourceContext(eObject); 021 String text = resourceContext.getString("label"); 022 action.setText(text == null ? org.nasdanika.common.Util.nameToLabel(eObject.getName()) : text); 023 return action; 024 } 025 026 @Override 027 public String name() { 028 return super.name() + " " + eObject.getName(); 029 } 030 031 032}