1 11 12 package org.eclipse.ui.internal.contexts; 13 14 import java.util.Iterator ; 15 16 import org.eclipse.core.expressions.Expression; 17 import org.eclipse.ui.contexts.IContextActivation; 18 import org.eclipse.ui.contexts.IContextService; 19 import org.eclipse.ui.internal.services.INestable; 20 21 34 public class NestableContextService extends SlaveContextService implements 35 INestable { 36 39 private boolean fActive; 40 41 51 public NestableContextService(IContextService parentService, 52 Expression defaultExpression) { 53 super(parentService, defaultExpression); 54 fActive = false; 55 } 56 57 62 protected IContextActivation doActivateContext(IContextActivation activation) { 63 if (fActive) { 64 return super.doActivateContext(activation); 65 } 66 fLocalActivations.put(activation, null); 67 return activation; 68 } 69 70 75 public void activate() { 76 if (fActive) { 77 return; 78 } 79 80 Iterator c = fLocalActivations.keySet().iterator(); 81 while (c.hasNext()) { 82 IContextActivation activation = (IContextActivation) c.next(); 83 super.doActivateContext(activation); 84 } 85 fActive = true; 86 } 87 88 93 public void deactivate() { 94 if (!fActive) { 95 return; 96 } 97 deactivateContexts(fParentActivations); 98 fParentActivations.clear(); 99 100 Iterator c = fLocalActivations.keySet().iterator(); 101 while (c.hasNext()) { 102 fLocalActivations.put(c.next(), null); 103 } 104 fActive = false; 105 } 106 } 107 | Popular Tags |