1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.editors.ui; 18 19 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiFlagAttributeNode; 20 21 import org.eclipse.swt.widgets.Composite; 22 import org.eclipse.swt.widgets.Control; 23 24 /** 25 * DialogCellEditor able to receive a {@link UiFlagAttributeNode} in the {@link #setValue(Object)} 26 * method. 27 * <p/>The dialog box opened is the same as the one in the ui created by 28 * {@link UiFlagAttributeNode#createUiControl(Composite, org.eclipse.ui.forms.IManagedForm)} 29 */ 30 public class FlagValueCellEditor extends EditableDialogCellEditor { 31 32 private UiFlagAttributeNode mUiFlagAttribute; 33 34 public FlagValueCellEditor(Composite parent) { 35 super(parent); 36 } 37 38 @Override 39 protected Object openDialogBox(Control cellEditorWindow) { 40 if (mUiFlagAttribute != null) { 41 String currentValue = (String)getValue(); 42 return mUiFlagAttribute.showDialog(cellEditorWindow.getShell(), currentValue); 43 } 44 45 return null; 46 } 47 48 @Override 49 protected void doSetValue(Object value) { 50 if (value instanceof UiFlagAttributeNode) { 51 mUiFlagAttribute = (UiFlagAttributeNode)value; 52 super.doSetValue(mUiFlagAttribute.getCurrentValue()); 53 return; 54 } 55 56 super.doSetValue(value); 57 } 58 } 59