Git Repositories View: Allow to "remove" multiple Repositories
[egit.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / actions / AddToIndexAction.java
blob880d9e303699dc225b5dca53a91b5515add2e566
1 /*******************************************************************************
2 * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.ui.internal.actions;
11 import java.util.Collection;
12 import java.util.List;
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.egit.core.op.AddToIndexOperation;
16 import org.eclipse.egit.core.op.IEGitOperation;
17 import org.eclipse.egit.ui.UIText;
18 import org.eclipse.jface.dialogs.MessageDialog;
20 /**
21 * An action to add files to a Git index.
23 * @see AddToIndexOperation
25 public class AddToIndexAction extends AbstractOperationAction {
26 private AddToIndexOperation operation = null;
28 protected IEGitOperation createOperation(final List sel) {
29 if (sel.isEmpty()) {
30 return null;
31 } else {
32 operation = new AddToIndexOperation(sel);
33 return operation;
37 @Override
38 protected void postOperation() {
39 Collection<IFile> notAddedFiles = operation.getNotAddedFiles();
40 if (notAddedFiles.size()==0)
41 return;
42 String title = UIText.AddToIndexAction_addingFilesFailed;
43 String message = UIText.AddToIndexAction_indexesWithUnmergedEntries;
44 message += "\n\n"; //$NON-NLS-1$
45 message += getFileList(notAddedFiles);
46 MessageDialog.openWarning(wp.getSite().getShell(), title, message);
49 private static String getFileList(Collection<IFile> notAddedFiles) {
50 String result = ""; //$NON-NLS-1$
51 for (IFile file : notAddedFiles) {
52 result += file.getName();
53 result += "\n"; //$NON-NLS-1$
55 return result;