KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.jface.action.IAction;
19 import org.eclipse.jface.operation.IRunnableWithProgress;
20 import org.eclipse.jface.wizard.IWizard;
21 import org.eclipse.jface.wizard.WizardDialog;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.team.core.RepositoryProvider;
25 import org.eclipse.team.internal.ui.TeamUIMessages;
26 import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
27 import org.eclipse.ui.IWorkbenchWindow;
28 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
29
30 /**
31  * Action for configuring a project. Configuring involves associating
32  * the project with a Team provider and performing any provider-specific
33  * configuration that is necessary.
34  */

35 public class ConfigureProjectAction extends TeamAction implements IWorkbenchWindowActionDelegate {
36     private static class ResizeWizardDialog extends WizardDialog {
37         public ResizeWizardDialog(Shell parentShell, IWizard newWizard) {
38             super(parentShell, newWizard);
39             setShellStyle(getShellStyle() | SWT.RESIZE);
40         }
41     }
42     
43     protected void execute(IAction action) throws InvocationTargetException JavaDoc,
44             InterruptedException JavaDoc {
45         run(new IRunnableWithProgress() {
46             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
47                 try {
48                     IProject project = getSelectedProjects()[0];
49                     ConfigureProjectWizard wizard = new ConfigureProjectWizard();
50                     wizard.init(null, project);
51                     WizardDialog dialog = new ResizeWizardDialog(getShell(), wizard);
52                     //dialog.
53
dialog.open();
54                 } catch (Exception JavaDoc e) {
55                     throw new InvocationTargetException JavaDoc(e);
56                 }
57             }
58         }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
59     }
60     
61     /**
62      * @see TeamAction#isEnabled()
63      */

64     public boolean isEnabled() {
65         IProject[] selectedProjects = getSelectedProjects();
66         if (selectedProjects.length != 1) return false;
67         if (!selectedProjects[0].isAccessible()) return false;
68         if (!RepositoryProvider.isShared(selectedProjects[0])) return true;
69         return false;
70     }
71     
72     /* (non-Javadoc)
73      * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
74      */

75     public void init(IWorkbenchWindow window) {
76     }
77 }
78
Popular Tags