KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006 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.debug.internal.ui.model.elements.VariableEditor;
14 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
15 import org.eclipse.jdt.debug.core.IJavaVariable;
16 import org.eclipse.jface.viewers.CellEditor;
17 import org.eclipse.jface.viewers.ComboBoxCellEditor;
18 import org.eclipse.jface.viewers.ICellModifier;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.widgets.Composite;
21
22 /**
23  * Editor for Java variable columns. Restricts edits to primitives and strings.
24  *
25  * @since 3.2
26  *
27  */

28 public class JavaVariableEditor extends VariableEditor {
29     
30     /* (non-Javadoc)
31      * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellModifier(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
32      */

33     public ICellModifier getCellModifier(IPresentationContext context, Object JavaDoc element) {
34         return new JavaVariableCellModifier();
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellEditor(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, java.lang.Object, org.eclipse.swt.widgets.Composite)
39      */

40     public CellEditor getCellEditor(IPresentationContext context, String JavaDoc columnId, Object JavaDoc element, Composite parent) {
41         if (element instanceof IJavaVariable) {
42             IJavaVariable var = (IJavaVariable) element;
43             if (JavaVariableCellModifier.isBoolean(var)) {
44                 return new ComboBoxCellEditor(parent, new String JavaDoc[]{Boolean.toString(true), Boolean.toString(false)}, SWT.READ_ONLY);
45             }
46         }
47         return super.getCellEditor(context, columnId, element, parent);
48     }
49
50 }
51
Popular Tags