001package org.nasdanika.html.ecore; 002 003import org.eclipse.emf.ecore.EClass; 004import org.eclipse.emf.ecore.EPackage; 005import org.eclipse.emf.ecore.EStructuralFeature; 006import org.nasdanika.common.Context; 007import org.nasdanika.common.ProgressMonitor; 008import org.nasdanika.html.bootstrap.Table; 009import org.nasdanika.html.model.app.Action; 010 011public class EStructuralFeatureActionSupplier<T extends EStructuralFeature> extends ETypedElementActionSupplier<T> implements EcoreActionSupplier { 012 013 public EStructuralFeatureActionSupplier(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 021 EClass eContainingClass = eObject.getEContainingClass(); 022 action.setId(encodeEPackage( 023 eContainingClass.getEPackage()) 024 + "-" 025 + eContainingClass.getName() 026 + "-" 027 + eObject.eClass().getName() 028 + "-" 029 + eObject.getName()); 030 031 action.setName(eObject.eClass().getName() + "-" + eObject.getName()); 032 return action; 033 } 034 035 @Override 036 protected Table propertiesTable(EClass contextEClass, ProgressMonitor monitor) throws Exception { 037 Table table = super.propertiesTable(contextEClass, monitor); 038 addRow(table, "Changeable").add(eObject.isChangeable()); 039 addRow(table, "Derived").add(eObject.isDerived()); 040 if (contextEClass != null) { 041 addRow(table, "Declaring class").add(link(eObject.getEContainingClass(), contextEClass)); 042 } 043 044 return table; 045 } 046 047 048}