KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > CheckoutWithOverwrite


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.core.client;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.team.internal.ccvs.core.CVSException;
16 import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
17
18 /**
19  * This checkout will overwrite any resources even for created responses
20  */

21 public class CheckoutWithOverwrite extends Checkout {
22
23     /**
24      * This class overrides the "Created" handler but uses the "Updated"
25      * behavior which will overwrite existing files.
26      */

27     public class CreatedResponseHandler extends UpdatedHandler {
28         public CreatedResponseHandler() {
29             super(UpdatedHandler.HANDLE_UPDATED);
30         }
31         public String JavaDoc getResponseID() {
32             return "Created"; //$NON-NLS-1$
33
}
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.team.internal.ccvs.core.client.Command#doExecute(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], java.lang.String[], org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener, org.eclipse.core.runtime.IProgressMonitor)
38      */

39     protected IStatus doExecute(
40         Session session,
41         GlobalOption[] globalOptions,
42         LocalOption[] localOptions,
43         String JavaDoc[] arguments,
44         ICommandOutputListener listener,
45         IProgressMonitor monitor)
46         throws CVSException {
47         
48         ResponseHandler newCreated = new CreatedResponseHandler();
49         ResponseHandler oldCreated = session.getResponseHandler(newCreated.getResponseID());
50         session.registerResponseHandler(newCreated);
51         try {
52             return super.doExecute(
53                 session,
54                 globalOptions,
55                 localOptions,
56                 arguments,
57                 listener,
58                 monitor);
59         } finally {
60             session.registerResponseHandler(oldCreated);
61         }
62     }
63
64 }
65
Popular Tags