KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > repo > NewDateTagAction


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.repo;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14 import java.util.Date JavaDoc;
15
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.jface.window.Window;
18 import org.eclipse.swt.widgets.Shell;
19 import org.eclipse.team.internal.ccvs.core.CVSTag;
20 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
21 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
22 import org.eclipse.team.internal.ccvs.ui.DateTagDialog;
23
24 /**
25  * Action for creating a CVS Date tag.
26  */

27 public class NewDateTagAction extends CVSRepoViewAction {
28
29     /* (non-Javadoc)
30      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
31      */

32     protected void execute(IAction action) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
33         ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations();
34         if (locations.length != 1) return;
35         CVSTag tag = getDateTag(getShell(), locations[0]);
36         CVSUIPlugin.getPlugin().getRepositoryManager().addDateTag(locations[0], tag);
37     }
38
39     public static CVSTag getDateTag(Shell shell, ICVSRepositoryLocation location) {
40         DateTagDialog dialog = new DateTagDialog(shell);
41         if (dialog.open() == Window.OK) {
42             Date JavaDoc date = dialog.getDate();
43             CVSTag tag = new CVSTag(date);
44             return tag;
45         }
46         return null;
47     }
48
49     /* (non-Javadoc)
50      * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
51      */

52     public boolean isEnabled() {
53         ICVSRepositoryLocation[] locations = getSelectedRepositoryLocations();
54         if (locations.length != 1) return false;
55         return true;
56     }
57 }
58
Popular Tags