1 11 package org.eclipse.debug.internal.ui; 12 13 import org.eclipse.core.expressions.PropertyTester; 14 import org.eclipse.debug.core.model.IDebugElement; 15 import org.eclipse.debug.core.model.IDebugTarget; 16 import org.eclipse.debug.core.model.IDisconnect; 17 import org.eclipse.debug.core.model.IProcess; 18 import org.eclipse.debug.core.model.ITerminate; 19 20 28 public class DebugModelPropertyTester extends PropertyTester { 29 30 public static final String MODEL_TYPE_PROPERTY = "getModelIdentifier"; public static final String IS_TERMINATED_OR_DISCONNECTED_PROPERTY = "isTerminatedOrDisconnected"; 33 36 public boolean test(Object receiver, String property, Object [] args, Object expectedValue) { 37 if (MODEL_TYPE_PROPERTY.equals(property)){ 38 IDebugTarget target = null; 39 if(receiver instanceof IProcess) { 40 target = (IDebugTarget) ((IProcess)receiver).getAdapter(IDebugTarget.class); 41 } 42 else if(receiver instanceof IDebugElement) { 43 target = (IDebugTarget) ((IDebugElement)receiver).getAdapter(IDebugTarget.class); 44 } 45 if(target != null) { 46 if (expectedValue == null || expectedValue.equals("")){ return false; 49 } 50 if(expectedValue.equals(target.getModelIdentifier())) { 52 return true; 53 } 54 } 55 return false; 56 } else if (IS_TERMINATED_OR_DISCONNECTED_PROPERTY.equals(property)){ 57 if (receiver instanceof ITerminate && ((ITerminate)receiver).isTerminated()){ 58 return true; 59 } if (receiver instanceof IDisconnect && ((IDisconnect)receiver).isDisconnected()){ 60 return true; 61 } else { 62 return false; 63 } 64 } else { 65 return false; 66 } 67 } 68 } 69 | Popular Tags |