KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > variables > JavaVariableColumnPresentationFactory


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.variables;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
15 import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
16 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
17 import org.eclipse.debug.ui.IDebugUIConstants;
18 import org.eclipse.jdt.debug.core.IJavaStackFrame;
19
20 /**
21  * @since 3.2
22  *
23  */

24 public class JavaVariableColumnPresentationFactory implements IColumnPresentationFactory {
25
26     /* (non-Javadoc)
27      * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnPresentationFactoryAdapter#createColumnPresentation(org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.Object)
28      */

29     public IColumnPresentation createColumnPresentation(IPresentationContext context, Object JavaDoc element) {
30         if (isApplicable(context, element)) {
31             return new JavaVariableColumnPresentation();
32         }
33         return null;
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnPresentationFactoryAdapter#getColumnPresentationId(org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext, java.lang.Object)
38      */

39     public String JavaDoc getColumnPresentationId(IPresentationContext context, Object JavaDoc element) {
40         if (isApplicable(context, element)) {
41             return JavaVariableColumnPresentation.JAVA_VARIABLE_COLUMN_PRESENTATION;
42         }
43         return null;
44     }
45     
46     private boolean isApplicable(IPresentationContext context, Object JavaDoc element) {
47         IJavaStackFrame frame = null;
48         if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
49             if (element instanceof IAdaptable) {
50                 IAdaptable adaptable = (IAdaptable)element;
51                 frame = (IJavaStackFrame) adaptable.getAdapter(IJavaStackFrame.class);
52             }
53         }
54         return frame != null;
55     }
56
57 }
58
Popular Tags