KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > actions > ImportProjectSetAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ui.actions;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.core.resources.IFile;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.Status;
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.dialogs.ErrorDialog;
22 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
23 import org.eclipse.jface.operation.IRunnableWithProgress;
24 import org.eclipse.jface.viewers.ISelection;
25 import org.eclipse.jface.viewers.IStructuredSelection;
26 import org.eclipse.swt.widgets.Display;
27 import org.eclipse.swt.widgets.Shell;
28 import org.eclipse.team.internal.ui.*;
29 import org.eclipse.ui.IObjectActionDelegate;
30 import org.eclipse.ui.IWorkbenchPart;
31 import org.eclipse.ui.actions.ActionDelegate;
32
33 public class ImportProjectSetAction extends ActionDelegate implements IObjectActionDelegate {
34     
35     private IStructuredSelection fSelection;
36     
37     public void run(IAction action) {
38         final Shell shell= Display.getDefault().getActiveShell();
39         try {
40             new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
41                 public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
42                     Iterator JavaDoc iterator= fSelection.iterator();
43                     while (iterator.hasNext()) {
44                         IFile file= (IFile) iterator.next();
45                         ProjectSetImporter.importProjectSet(file.getLocation().toString(), shell, monitor);
46                     }
47                 }
48             });
49         } catch (InvocationTargetException JavaDoc exception) {
50             ErrorDialog.openError(shell, null, null, new Status(IStatus.ERROR, TeamUIPlugin.PLUGIN_ID, IStatus.ERROR, TeamUIMessages.ImportProjectSetAction_0, exception.getTargetException()));
51         } catch (InterruptedException JavaDoc exception) {
52         }
53     }
54     
55     public void selectionChanged(IAction action, ISelection sel) {
56         if (sel instanceof IStructuredSelection) {
57             fSelection= (IStructuredSelection) sel;
58         }
59     }
60
61     public void setActivePart(IAction action, IWorkbenchPart targetPart) {
62     }
63
64 }
65
Popular Tags