KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > feature > PortabilityChoiceCellEditor


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

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 JavaDoc KEY_TITLE =
21         "FeatureEditor.PortabilityChoicesDialog.title"; //$NON-NLS-1$
22
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 JavaDoc openDialogBox(Control cellEditorWindow) {
38         String JavaDoc value = (String JavaDoc) 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         //dialog.getShell().setSize(300, 400);
48
int result = dialog.open();
49         if (result == PortabilityChoicesDialog.OK) {
50             return dialog.getValue();
51         }
52         return value;
53     }
54     protected void updateContents(Object JavaDoc value) {
55         if (value != null)
56             label.setText(value.toString());
57         else
58             label.setText(""); //$NON-NLS-1$
59
}
60 }
61
Popular Tags