1 11 package org.eclipse.team.internal.ccvs.ui.model; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.jface.operation.IRunnableContext; 16 import org.eclipse.team.core.TeamException; 17 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; 18 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 19 import org.eclipse.ui.IWorkingSet; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.model.IWorkbenchAdapter; 22 import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; 23 import org.eclipse.ui.progress.IElementCollector; 24 25 public abstract class CVSModelElement implements IWorkbenchAdapter, IAdaptable { 26 27 private IRunnableContext runnableContext; 28 private IWorkingSet workingSet; 29 30 public IWorkingSet getWorkingSet() { 31 return workingSet; 32 } 33 34 public void setWorkingSet(IWorkingSet workingSet) { 35 this.workingSet = workingSet; 36 } 37 38 public Object getAdapter(Class adapter) { 39 if (adapter == IWorkbenchAdapter.class) 40 return this; 41 if ((adapter == IDeferredWorkbenchAdapter.class) && this instanceof IDeferredWorkbenchAdapter) 42 return this; 43 return null; 44 } 45 46 50 public IRunnableContext getRunnableContext() { 51 if (runnableContext == null) { 52 return PlatformUI.getWorkbench().getProgressService(); 53 } 54 return runnableContext; 55 } 56 57 61 public void setRunnableContext(IRunnableContext runnableContext) { 62 this.runnableContext = runnableContext; 63 } 64 65 public Object [] getChildren(Object o) { 66 try { 67 return fetchChildren(o, null); 68 } catch (TeamException e) { 69 handle(e); 70 } 71 72 return new Object [0]; 73 } 74 75 abstract protected Object [] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException; 76 77 83 protected void handle(final String title, final String description, final Throwable e) { 84 CVSUIPlugin.openError(null, title, description, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS | CVSUIPlugin.PERFORM_SYNC_EXEC); 85 } 86 87 91 protected void handle(Throwable t) { 92 handle(CVSUIMessages.CVSModelElement_0, CVSUIMessages.CVSModelElement_1, t); } 94 95 100 protected void handle(IElementCollector collector, Throwable t) { 101 handle(t); 103 } 104 105 } 106 | Popular Tags |