1 /*******************************************************************************2 * Copyright (c) 2005, 2007 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 *8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11 package org.eclipse.debug.internal.ui.viewers.update;12 13 import org.eclipse.debug.core.IExpressionManager;14 import org.eclipse.debug.core.ILaunch;15 import org.eclipse.debug.core.ILaunchManager;16 import org.eclipse.debug.core.model.IDebugTarget;17 import org.eclipse.debug.core.model.IExpression;18 import org.eclipse.debug.core.model.IMemoryBlock;19 import org.eclipse.debug.core.model.IMemoryBlockRetrieval;20 import org.eclipse.debug.core.model.IProcess;21 import org.eclipse.debug.core.model.IStackFrame;22 import org.eclipse.debug.core.model.IWatchExpression;23 import org.eclipse.debug.internal.ui.memory.provisional.AbstractAsyncTableRendering;24 import org.eclipse.debug.internal.ui.memory.provisional.MemoryViewPresentationContext;25 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;26 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;27 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;28 import org.eclipse.debug.ui.IDebugUIConstants;29 30 public class DefaultModelProxyFactory implements IModelProxyFactory {31 32 public IModelProxy createModelProxy(Object element, IPresentationContext context) {33 String id = context.getId();34 if (IDebugUIConstants.ID_DEBUG_VIEW.equals(id)) {35 if (element instanceof IDebugTarget) {36 return new DebugTargetProxy((IDebugTarget)element);37 }38 if (element instanceof ILaunchManager) {39 return new LaunchManagerProxy();40 }41 if (element instanceof ILaunch) {42 return new LaunchProxy((ILaunch) element);43 }44 if (element instanceof IProcess) {45 return new ProcessProxy((IProcess)element);46 }47 }48 if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(id)) {49 if (element instanceof IStackFrame) {50 return new DefaultVariableViewModelProxy((IStackFrame)element);51 }52 }53 if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(id)) {54 if (element instanceof IExpressionManager) {55 return new ExpressionManagerModelProxy();56 } 57 if (element instanceof IWatchExpression) {58 return new DefaultWatchExpressionModelProxy((IWatchExpression)element);59 }60 if (element instanceof IExpression) {61 return new DefaultExpressionModelProxy((IExpression)element);62 }63 }64 if (IDebugUIConstants.ID_REGISTER_VIEW.equals(id)) {65 if (element instanceof IStackFrame) {66 return new DefaultVariableViewModelProxy((IStackFrame)element);67 }68 }69 if (IDebugUIConstants.ID_MEMORY_VIEW.equals(id)) {70 if (element instanceof IMemoryBlockRetrieval)71 return new MemoryRetrievalProxy((IMemoryBlockRetrieval)element);72 }73 74 if (context instanceof MemoryViewPresentationContext)75 {76 if (((MemoryViewPresentationContext)context).getRendering() instanceof AbstractAsyncTableRendering)77 {78 if (element instanceof IMemoryBlock)79 return new MemoryBlockProxy((IMemoryBlock)element);80 }81 }82 83 return null;84 }85 86 }87