|
Lines 27-38
Link Here
|
| 27 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
27 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
| 28 |
import org.eclipse.jface.viewers.ILightweightLabelDecorator; |
28 |
import org.eclipse.jface.viewers.ILightweightLabelDecorator; |
| 29 |
|
29 |
|
|
|
30 |
import java.util.HashSet; |
| 31 |
import java.util.Set; |
| 32 |
|
| 30 |
/** |
33 |
/** |
| 31 |
* @author Eugen Neufeld |
34 |
* @author Eugen Neufeld |
| 32 |
*/ |
35 |
*/ |
| 33 |
public class EMFStoreDirtyDecorator implements ILightweightLabelDecorator, CommitObserver { |
36 |
public class EMFStoreDirtyDecorator implements ILightweightLabelDecorator, CommitObserver { |
| 34 |
|
37 |
|
| 35 |
private String dirtyPath = "icons/dirty.png"; |
38 |
private String dirtyPath = "icons/dirty.png"; |
|
|
39 |
private Set<InternalProject> observers = new HashSet<InternalProject>(); |
| 36 |
|
40 |
|
| 37 |
/** {@inheritDoc} */ |
41 |
/** {@inheritDoc} */ |
| 38 |
public void decorate(Object element, IDecoration decoration) { |
42 |
public void decorate(Object element, IDecoration decoration) { |
|
Lines 40-57
Link Here
|
| 40 |
if (element instanceof ECPProject) { |
44 |
if (element instanceof ECPProject) { |
| 41 |
InternalProject project = (InternalProject) element; |
45 |
InternalProject project = (InternalProject) element; |
| 42 |
ProjectSpace projectSpace = EMFStoreProvider.INSTANCE.getProjectSpace(project); |
46 |
ProjectSpace projectSpace = EMFStoreProvider.INSTANCE.getProjectSpace(project); |
| 43 |
projectSpace.getOperationManager().addOperationListener(new EMFStoreDirtyObserver(projectSpace, project)); |
|
|
| 44 |
|
47 |
|
|
|
48 |
if (!observers.contains(element)) { |
| 49 |
projectSpace.getOperationManager().addOperationListener( |
| 50 |
new EMFStoreDirtyObserver(projectSpace, project)); |
| 51 |
observers.add(project); |
| 52 |
} |
| 45 |
if (project.isOpen() && EMFStoreProvider.INSTANCE.getProjectSpace(project).isShared() |
53 |
if (project.isOpen() && EMFStoreProvider.INSTANCE.getProjectSpace(project).isShared() |
| 46 |
&& EMFStoreDirtyDecoratorCachedTree.getInstance(project).getRootValue() > 0) { |
54 |
&& EMFStoreDirtyDecoratorCachedTree.getInstance(project).getRootValue().shouldDisplayDirtyIndicator()) { |
| 47 |
decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); |
55 |
decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); |
| 48 |
} |
56 |
} |
| 49 |
} |
57 |
} |
| 50 |
|
58 |
|
| 51 |
if (element instanceof EObject) { |
59 |
if (element instanceof EObject) { |
| 52 |
InternalProject project = ECPUtil.getECPProject(element, InternalProject.class); |
60 |
InternalProject project = null; |
| 53 |
if (project != null && project.isOpen() && EMFStoreProvider.INSTANCE.getProjectSpace(project).isShared() |
61 |
try { |
| 54 |
&& EMFStoreDirtyDecoratorCachedTree.getInstance(project).getCachedValue(element) > 0) { |
62 |
project = ECPUtil.getECPProject(element, InternalProject.class); |
|
|
63 |
} catch (IllegalArgumentException iae) { |
| 64 |
// ignore |
| 65 |
} |
| 66 |
if (project != null |
| 67 |
&& project.isOpen() |
| 68 |
&& EMFStoreProvider.INSTANCE.getProjectSpace(project).isShared() |
| 69 |
&& EMFStoreDirtyDecoratorCachedTree.getInstance(project).getCachedValue(element) |
| 70 |
.shouldDisplayDirtyIndicator()) { |
| 55 |
decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); |
71 |
decoration.addOverlay(Activator.getImageDescriptor(dirtyPath), IDecoration.BOTTOM_LEFT); |
| 56 |
} |
72 |
} |
| 57 |
|
73 |
|