1 11 12 package org.eclipse.debug.internal.ui.viewers.update; 13 14 import org.eclipse.debug.core.DebugPlugin; 15 import org.eclipse.debug.core.IExpressionManager; 16 import org.eclipse.debug.core.IExpressionsListener; 17 import org.eclipse.debug.core.model.IExpression; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; 19 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 20 import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; 21 import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy; 22 import org.eclipse.jface.viewers.Viewer; 23 24 25 public class ExpressionManagerModelProxy extends AbstractModelProxy implements IExpressionsListener { 26 27 30 public void init(IPresentationContext context) { 31 super.init(context); 32 getExpressionManager().addExpressionListener(this); 33 } 34 35 38 public void installed(Viewer viewer) { 39 updateExpressions(getExpressionManager().getExpressions(), IModelDelta.INSTALL); 40 } 41 42 45 protected IExpressionManager getExpressionManager() { 46 return DebugPlugin.getDefault().getExpressionManager(); 47 } 48 49 52 public synchronized void dispose() { 53 super.dispose(); 54 getExpressionManager().removeExpressionListener(this); 55 } 56 57 60 public void expressionsAdded(IExpression[] expressions) { 61 updateExpressions(expressions, IModelDelta.ADDED | IModelDelta.INSTALL); 62 } 63 64 67 public void expressionsRemoved(IExpression[] expressions) { 68 updateExpressions(expressions, IModelDelta.REMOVED | IModelDelta.UNINSTALL); 69 } 70 71 74 public void expressionsChanged(IExpression[] expressions) { 75 updateExpressions(expressions, IModelDelta.CONTENT | IModelDelta.STATE); 76 } 77 78 private void updateExpressions(IExpression[] expressions, int flags) { 79 ModelDelta delta = new ModelDelta(getExpressionManager(), IModelDelta.NO_CHANGE); 80 for (int i = 0; i < expressions.length; i++) { 81 IExpression expression = expressions[i]; 82 delta.addNode(expression, flags); 83 } 84 fireModelChanged(delta); 85 } 86 87 } 88 | Popular Tags |