/** * @param mapping * @param forceDeleteOrgColor */ public DeleteMappingCommand(Mapping mapping, boolean forceDeleteOrgColor) { this.mapping = mapping; NodeLayout originLayout = HenshinLayoutUtil.INSTANCE.getLayout(mapping.getOrigin()); NodeLayout imageLayout = HenshinLayoutUtil.INSTANCE.getLayout(mapping.getImage()); List<Mapping> originMappings = ModelUtil.getReferences( mapping.getOrigin(), Mapping.class, HenshinUtil.INSTANCE.getTransformationSystem(mapping), HenshinPackage.Literals.MAPPING__ORIGIN); originMappings.remove(mapping); if (originMappings.isEmpty() || forceDeleteOrgColor) { add( new SimpleSetEFeatureCommand<NodeLayout, Integer>( originLayout, 0, HenshinLayoutPackage.Literals.NODE_LAYOUT__COLOR)); } add( new SimpleSetEFeatureCommand<NodeLayout, Integer>( imageLayout, 0, HenshinLayoutPackage.Literals.NODE_LAYOUT__COLOR)); add(new SimpleDeleteEObjectCommand(mapping)); }
@Override public boolean canExecute() { if (!HenshinLayoutUtil.INSTANCE.hasOriginInKernelRule(mapping.getOrigin()) && HenshinLayoutUtil.INSTANCE.hasOriginInKernelRule(mapping.getImage())) return false; return super.canExecute(); }