KickJava   Java API By Example, From Geeks To Geeks.

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


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.elements.adapters.VariableColumnEditor;
14 import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
15 import org.eclipse.jdt.debug.core.IJavaVariable;
16 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
17 import org.eclipse.jface.viewers.CellEditor;
18 import org.eclipse.jface.viewers.ComboBoxCellEditor;
19 import org.eclipse.jface.viewers.ICellModifier;
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 JavaVariableColumnEditor extends VariableColumnEditor {
29
30     public static final String JavaDoc JAVA_VARIABLE_COLUMN_EDITOR = JDIDebugUIPlugin.getUniqueIdentifier() + ".JAVA_VARIABLE_COLUMN_EDITOR"; //$NON-NLS-1$
31

32     private ICellModifier fModifier;
33     
34     /* (non-Javadoc)
35      * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditor#getCellModifier()
36      */

37     public ICellModifier getCellModifier() {
38         if (fModifier == null) {
39             fModifier = new JavaVariableCellModifier(getPresentationContext());
40         }
41         return fModifier;
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditor#getId()
46      */

47     public String JavaDoc getId() {
48         return JAVA_VARIABLE_COLUMN_EDITOR;
49     }
50
51     /* (non-Javadoc)
52      * @see org.eclipse.debug.internal.ui.elements.adapters.VariableColumnEditor#getCellEditor(java.lang.String, java.lang.Object, org.eclipse.swt.widgets.Composite)
53      */

54     public CellEditor getCellEditor(String JavaDoc id, Object JavaDoc element, Composite parent) {
55         if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(id)) {
56             if (element instanceof IJavaVariable) {
57                 IJavaVariable var = (IJavaVariable) element;
58                 if (JavaVariableCellModifier.isBoolean(var)) {
59                     return new ComboBoxCellEditor(parent, new String JavaDoc[]{Boolean.toString(true), Boolean.toString(false)});
60                 }
61             }
62         }
63         return super.getCellEditor(id, element, parent);
64     }
65     
66     
67
68 }
69
Popular Tags