1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 13 import org.eclipse.jface.viewers.*; 14 import org.eclipse.pde.internal.core.*; 15 import org.eclipse.pde.internal.ui.*; 16 import org.eclipse.swt.*; 17 import org.eclipse.swt.widgets.*; 18 19 public class PortabilityChoiceCellEditor extends DialogCellEditor { 20 private static final String KEY_TITLE = 21 "FeatureEditor.PortabilityChoicesDialog.title"; private Label label; 23 private Choice[] choices; 24 25 public PortabilityChoiceCellEditor( 26 Composite parent, 27 Choice[] choices) { 28 super(parent); 29 this.choices = choices; 30 } 31 protected Control createContents(Composite cell) { 32 label = new Label(cell, SWT.LEFT); 33 label.setFont(cell.getFont()); 34 label.setBackground(cell.getBackground()); 35 return label; 36 } 37 protected Object openDialogBox(Control cellEditorWindow) { 38 String value = (String ) getValue(); 39 40 PortabilityChoicesDialog dialog = 41 new PortabilityChoicesDialog( 42 PDEPlugin.getActiveWorkbenchShell(), 43 choices, 44 value); 45 dialog.create(); 46 dialog.getShell().setText(PDEPlugin.getResourceString(KEY_TITLE)); 47 int result = dialog.open(); 49 if (result == PortabilityChoicesDialog.OK) { 50 return dialog.getValue(); 51 } 52 return value; 53 } 54 protected void updateContents(Object value) { 55 if (value != null) 56 label.setText(value.toString()); 57 else 58 label.setText(""); } 60 } 61 | Popular Tags |