KickJava   Java API By Example, From Geeks To Geeks.

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


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  * A specialized update that will ignore unmanaged local content.
20  * It is the same os CheckoutWithOverwrite.
21  */

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

28     public class CreatedResponseHandler extends UpdatedHandler {
29         public CreatedResponseHandler() {
30             super(UpdatedHandler.HANDLE_UPDATED);
31         }
32         public String JavaDoc getResponseID() {
33             return "Created"; //$NON-NLS-1$
34
}
35     }
36
37     /* (non-Javadoc)
38      * @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)
39      */

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