update copyright
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / checkout / CheckoutEventHandler.java
blobe7be4c54fff675b0d1b392bca91e3edcfd1e14fe
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.svn.checkout;
18 import com.intellij.openapi.progress.ProgressIndicator;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.openapi.wm.StatusBar;
21 import com.intellij.openapi.wm.WindowManager;
22 import org.jetbrains.idea.svn.SvnBundle;
23 import org.jetbrains.idea.svn.SvnUtil;
24 import org.jetbrains.idea.svn.SvnVcs;
25 import org.tmatesoft.svn.core.SVNCancelException;
26 import org.tmatesoft.svn.core.SVNErrorCode;
27 import org.tmatesoft.svn.core.SVNErrorMessage;
28 import org.tmatesoft.svn.core.wc.ISVNEventHandler;
29 import org.tmatesoft.svn.core.wc.SVNEvent;
30 import org.tmatesoft.svn.core.wc.SVNEventAction;
32 public class CheckoutEventHandler implements ISVNEventHandler {
33 private final ProgressIndicator myIndicator;
34 private int myExternalsCount;
35 private final SvnVcs myVCS;
36 private final boolean myIsExport;
38 public CheckoutEventHandler(SvnVcs vcs, boolean isExport, ProgressIndicator indicator) {
39 myIndicator = indicator;
40 myVCS = vcs;
41 myExternalsCount = 1;
42 myIsExport = isExport;
45 public void handleEvent(SVNEvent event, double progress) {
46 final String path = SvnUtil.getPathForProgress(event);
47 if (path == null) {
48 return;
50 if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) {
51 myExternalsCount++;
52 myIndicator.setText(SvnBundle.message("progress.text2.fetching.external.location", event.getFile().getAbsolutePath()));
53 myIndicator.setText2("");
55 else if (event.getAction() == SVNEventAction.UPDATE_ADD) {
56 myIndicator.setText2(SvnBundle.message(myIsExport ? "progress.text2.exported" : "progress.text2.checked.out", event.getFile().getName()));
58 else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED) {
59 myExternalsCount--;
60 myIndicator.setText2(SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "progress.text2.checked.out.revision", event.getRevision()));
61 if (myExternalsCount == 0 && event.getRevision() >= 0 && myVCS != null) {
62 myExternalsCount = 1;
63 Project project = myVCS.getProject();
64 if (project != null) {
65 StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
66 if (statusBar != null) {
67 statusBar.setInfo(SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "status.text.checked.out.revision", event.getRevision()));
71 } else if (event.getAction() == SVNEventAction.COMMIT_ADDED) {
72 myIndicator.setText2(SvnBundle.message("progress.text2.adding", path));
73 } else if (event.getAction() == SVNEventAction.COMMIT_DELTA_SENT) {
74 myIndicator.setText2(SvnBundle.message("progress.text2.transmitting.delta", path));
78 public void checkCancelled() throws SVNCancelException {
79 if (myIndicator.isCanceled()) {
80 throw new SVNCancelException(SVNErrorMessage.create(SVNErrorCode.CANCELLED, "Operation cancelled"));