1 /******************************************************************************* 2 * Copyright (c) 2000, 2007 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.team.internal.ccvs.ui.subscriber; 15 16 import org.eclipse.team.internal.ccvs.ui.Policy; 17 import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; 18 import org.eclipse.team.internal.ui.Utils; 19 import org.eclipse.team.internal.ui.synchronize.ActionDelegateWrapper; 20 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 21 22 /** 23 * Superclass of CVS participant action delegates that uses the classname as the key 24 * to access the text from the resource bundle 25 */ 26 public class CVSActionDelegateWrapper extends ActionDelegateWrapper { 27 CVSActionDelegateWrapper(CVSAction delegate, ISynchronizePageConfiguration configuration, String id)28 public CVSActionDelegateWrapper(CVSAction delegate, ISynchronizePageConfiguration configuration, String id) { 29 super(delegate, configuration, id); 30 Utils.initAction(this, getBundleKeyPrefix(), Policy.getActionBundle()); 31 } 32 CVSActionDelegateWrapper(CVSAction delegate, ISynchronizePageConfiguration configuration)33 public CVSActionDelegateWrapper(CVSAction delegate, ISynchronizePageConfiguration configuration) { 34 this(delegate, configuration, delegate.getId()); 35 } 36 37 /** 38 * Return the key to the action text in the resource bundle. 39 * The default is the class name followed by a dot (.). 40 * @return the bundle key prefix 41 */ getBundleKeyPrefix()42 protected String getBundleKeyPrefix() { 43 String name = getDelegate().getClass().getName(); 44 int lastDot = name.lastIndexOf("."); //$NON-NLS-1$ 45 if (lastDot == -1) { 46 return name; 47 } 48 return name.substring(lastDot + 1) + "."; //$NON-NLS-1$ 49 } 50 } 51