001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Thomas Roger <troger@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.activity; 019 020import java.util.HashMap; 021import java.util.Map; 022 023import org.nuxeo.runtime.model.ContributionFragmentRegistry; 024 025/** 026 * Registry for activity verbs, handling merge of registered {@link org.nuxeo.ecm.activity.ActivityVerb} elements. 027 * 028 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 029 * @since 5.6 030 */ 031public class ActivityVerbRegistry extends ContributionFragmentRegistry<ActivityVerb> { 032 033 protected Map<String, ActivityVerb> activityVerbs = new HashMap<String, ActivityVerb>(); 034 035 public ActivityVerb get(String name) { 036 return activityVerbs.get(name); 037 } 038 039 @Override 040 public String getContributionId(ActivityVerb contrib) { 041 return contrib.getVerb(); 042 } 043 044 @Override 045 public void contributionUpdated(String id, ActivityVerb contrib, ActivityVerb newOrigContrib) { 046 activityVerbs.put(id, contrib); 047 } 048 049 @Override 050 public void contributionRemoved(String id, ActivityVerb origContrib) { 051 activityVerbs.remove(id); 052 } 053 054 @Override 055 public ActivityVerb clone(ActivityVerb orig) { 056 return orig.clone(); 057 } 058 059 @Override 060 public void merge(ActivityVerb src, ActivityVerb dst) { 061 String labelKey = src.getLabelKey(); 062 if (labelKey != null) { 063 dst.setLabelKey(labelKey); 064 } 065 String icon = src.getIcon(); 066 if (icon != null) { 067 dst.setIcon(icon); 068 } 069 } 070}