1 11 package org.eclipse.team.internal.ui.actions; 12 13 14 import java.lang.reflect.InvocationTargetException ; 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 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 , 44 InterruptedException { 45 run(new IRunnableWithProgress() { 46 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 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.open(); 54 } catch (Exception e) { 55 throw new InvocationTargetException (e); 56 } 57 } 58 }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR); 59 } 60 61 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 75 public void init(IWorkbenchWindow window) { 76 } 77 } 78 | Popular Tags |