KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > subscriber > CVSParticipantAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.subscriber;
12
13 import org.eclipse.jface.viewers.ISelectionProvider;
14 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
15 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
16 import org.eclipse.team.internal.ccvs.ui.Policy;
17 import org.eclipse.team.internal.ui.Utils;
18 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
19 import org.eclipse.team.ui.synchronize.SynchronizeModelAction;
20
21 /**
22  * Superclass of CVS participant actions that uses the classname as the key
23  * to access the text from the resource bundle
24  */

25 public abstract class CVSParticipantAction extends SynchronizeModelAction {
26
27     protected CVSParticipantAction(ISynchronizePageConfiguration configuration) {
28         super(null, configuration);
29         Utils.initAction(this, getBundleKeyPrefix(), Policy.getActionBundle());
30     }
31     
32     protected CVSParticipantAction(ISynchronizePageConfiguration configuration, ISelectionProvider provider, String JavaDoc bundleKey) {
33         super(null, configuration, provider);
34         Utils.initAction(this, bundleKey, Policy.getActionBundle());
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      */

42     protected String JavaDoc getBundleKeyPrefix() {
43         String JavaDoc name = 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     protected boolean needsToSaveDirtyEditors() {
52         int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS);
53         return option != ICVSUIConstants.OPTION_NEVER;
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.team.ui.synchronize.SynchronizeModelAction#confirmSaveOfDirtyEditor()
58      */

59     protected boolean confirmSaveOfDirtyEditor() {
60         int option = CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS);
61         return option == ICVSUIConstants.OPTION_PROMPT;
62     }
63 }
64
Popular Tags