| 1 | package de.uka.ipd.sdq.pcm.dialogs.parameters; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | |
| 5 | import org.eclipse.emf.ecore.EReference; |
| 6 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
| 7 | import org.eclipse.jface.viewers.DialogCellEditor; |
| 8 | import org.eclipse.swt.widgets.Composite; |
| 9 | import org.eclipse.swt.widgets.Control; |
| 10 | |
| 11 | import de.uka.ipd.sdq.pcm.dialogs.datatype.CallDataTypeDialog; |
| 12 | import de.uka.ipd.sdq.pcm.repository.DataType; |
| 13 | import de.uka.ipd.sdq.pcm.repository.Repository; |
| 14 | |
| 15 | /** |
| 16 | * The class defines a CellEditor, for which the call of DataTypeDialog makes |
| 17 | * possible. |
| 18 | * |
| 19 | * @author Roman Andrej |
| 20 | */ |
| 21 | public class TypeDialogCellEditor extends DialogCellEditor { |
| 22 | |
| 23 | /** |
| 24 | * The transactional editing domain which is used to get the commands and |
| 25 | * alter the model |
| 26 | */ |
| 27 | |
| 28 | private TransactionalEditingDomain editingDomain = null; |
| 29 | |
| 30 | /* |
| 31 | * @See org.eclipse.jface.viewers.DialogCellEditor#DialogCellEditor(org.eclipse.swt.widgets.Control |
| 32 | * parent) |
| 33 | */ |
| 34 | public TypeDialogCellEditor(Composite parent, TransactionalEditingDomain editingDomain) { |
| 35 | super(parent); |
| 36 | this.editingDomain = editingDomain; |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * (non-Javadoc) |
| 41 | * |
| 42 | * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) |
| 43 | */ |
| 44 | @Override |
| 45 | protected Object openDialogBox(Control cellEditorWindow) { |
| 46 | |
| 47 | ArrayList<Object> filterList = new ArrayList<Object>(); |
| 48 | filterList.add(Repository.class); |
| 49 | filterList.add(DataType.class); |
| 50 | ArrayList<EReference> additionalReferences = new ArrayList<EReference>(); |
| 51 | |
| 52 | CallDataTypeDialog dialog = new CallDataTypeDialog(cellEditorWindow |
| 53 | .getShell(), filterList, additionalReferences, editingDomain |
| 54 | .getResourceSet()); |
| 55 | dialog.setProvidedService(DataType.class); |
| 56 | dialog.open(); |
| 57 | |
| 58 | if (!(dialog.getResult() instanceof DataType)) |
| 59 | return null; |
| 60 | |
| 61 | return dialog.getResult(); |
| 62 | } |
| 63 | } |