2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
26 * The Original Software is NetBeans. The Initial Developer of the Original
27 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28 * Microsystems, Inc. All Rights Reserved.
29 * Portions Copyright 2008 Alexander Coles (Ikonoklastik Productions).
31 * If you wish your version of this file to be governed by only the CDDL
32 * or only the GPL Version 2, indicate your decision by adding
33 * "[Contributor] elects to include this software in this distribution
34 * under the [CDDL or GPL Version 2] license." If you do not indicate a
35 * single choice of license, a recipient has the option to distribute
36 * your version of this file under either the CDDL, the GPL Version 2 or
37 * to extend the choice of license to its licensees as provided above.
38 * However, if you add GPL Version 2 code and therefore, elected the GPL
39 * Version 2 license, then the option applies only if the new code is
40 * made subject to such option by the copyright holder.
42 package org
.nbgit
.ui
.update
;
44 import java
.awt
.event
.ActionEvent
;
46 import java
.util
.List
;
48 import org
.nbgit
.GitProgressSupport
;
49 import org
.nbgit
.OutputLogger
;
50 import org
.nbgit
.util
.GitUtils
;
51 import org
.nbgit
.ui
.ContextAction
;
52 import org
.netbeans
.modules
.versioning
.spi
.VCSContext
;
53 import org
.openide
.filesystems
.FileObject
;
54 import org
.openide
.filesystems
.FileUtil
;
55 import org
.openide
.util
.NbBundle
;
56 import org
.openide
.util
.RequestProcessor
;
59 * Update action for Git:
60 * git update - update or merge working directory
64 public class UpdateAction
extends ContextAction
{
66 public UpdateAction(String name
, VCSContext context
) {
70 public void performAction(ActionEvent e
) {
74 public static void update(final VCSContext ctx
) {
75 final File root
= GitUtils
.getRootFile(ctx
);
79 String repository
= root
.getAbsolutePath();
82 final Update update
= new Update(root
);
83 if (!update
.showDialog()) {
86 rev
= update
.getSelectionRevision();
87 final boolean doForcedUpdate
= update
.isForcedUpdateRequested();
88 final String revStr
= rev
;
90 RequestProcessor rp
= Git
.getInstance().getRequestProcessor(repository
);
91 GitProgressSupport support
= new GitProgressSupport() {
93 public void perform() {
94 boolean bNoUpdates
= true;
95 OutputLogger logger
= getLogger();
98 NbBundle
.getMessage(UpdateAction
.class,
99 "MSG_UPDATE_TITLE")); // NOI18N
101 NbBundle
.getMessage(UpdateAction
.class,
102 "MSG_UPDATE_TITLE_SEP")); // NOI18N
104 NbBundle
.getMessage(UpdateAction
.class,
105 "MSG_UPDATE_INFO_SEP", revStr
, root
.getAbsolutePath())); // NOI18N
106 List
<String
> list
= updateAll(root
, doForcedUpdate
, revStr
);
108 if (list
!= null && !list
.isEmpty()) {
109 bNoUpdates
= isNoUpdates(list
.get(0));
110 //logger.clearOutput();
112 logger
.output(""); // NOI18N
114 // refresh filesystem to take account of changes
115 FileObject rootObj
= FileUtil
.toFileObject(root
);
117 rootObj
.getFileSystem().refresh(true);
118 } catch (Exception ex
) {
121 // Force Status Refresh from this dir and below
123 GitUtils
.forceStatusRefreshProject(ctx
);
126 NbBundle
.getMessage(UpdateAction
.class,
127 "MSG_UPDATE_DONE")); // NOI18N
128 logger
.output(""); // NOI18N
131 support
.start(rp
, repository
, org
.openide
.util
.NbBundle
.getMessage(UpdateAction
.class, "MSG_Update_Progress")); // NOI18N
134 public static List
<String
> updateAll(File root
, boolean doForcedUpdate
, String revStr
) {
135 throw new UnsupportedOperationException("Not yet implemented");
138 public static boolean isNoUpdates(String get
) {
139 throw new UnsupportedOperationException("Not yet implemented");