1 12 package org.eclipse.team.internal.ccvs.ui.actions; 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 import org.eclipse.core.runtime.IStatus; 19 import org.eclipse.jface.operation.IRunnableWithProgress; 20 import org.eclipse.jface.window.Window; 21 import org.eclipse.osgi.util.NLS; 22 import org.eclipse.swt.widgets.Shell; 23 import org.eclipse.team.core.Team; 24 import org.eclipse.team.internal.ccvs.core.*; 25 import org.eclipse.team.internal.ccvs.ui.*; 26 import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceAction.IProviderAction; 27 28 37 public class EditorsAction implements IProviderAction, IRunnableWithProgress { 38 EditorsInfo[] f_editorsInfo = new EditorsInfo[0]; 39 CVSTeamProvider f_provider; 40 IResource[] f_resources; 41 42 public EditorsAction() { 43 } 44 45 public EditorsAction(CVSTeamProvider provider, IResource[] resources) { 46 f_provider = provider; 47 f_resources = resources; 48 } 49 52 public IStatus execute(CVSTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws CVSException { 53 f_editorsInfo = provider.editors(resources, monitor); 54 return Team.OK_STATUS; 55 } 56 57 public boolean promptToEdit(Shell shell) { 58 if (!isEmpty()) { 59 final EditorsDialog view = new EditorsDialog(shell, f_editorsInfo); 60 CVSUIPlugin.openDialog(shell, new CVSUIPlugin.IOpenableInShell() { 63 public void open(Shell shell) { 64 view.open(); 65 } 66 }, CVSUIPlugin.PERFORM_SYNC_EXEC); 67 return (view.getReturnCode() == Window.OK); 68 } 69 return true; 70 } 71 72 77 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 78 if (f_provider == null || f_resources == null) { 79 throw new InvocationTargetException (new RuntimeException (NLS.bind(CVSUIMessages.EditorsAction_classNotInitialized, new String [] { this.getClass().getName() }))); 80 } 81 try { 82 execute(f_provider,f_resources,monitor); 83 } catch (CVSException e) { 84 throw new InvocationTargetException (e); 85 } 86 } 87 88 92 public EditorsInfo[] getEditorsInfo() { 93 return f_editorsInfo; 94 } 95 96 102 public boolean isEmpty() { 103 return f_editorsInfo.length == 0; 104 } 105 106 } 107 | Popular Tags |