1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/**
* Copyright (c) 2012 Mia-Software.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
* Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
*/
package org.eclipse.emf.facet.efacet.sdk.ui.internal.dialog.composite;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
import org.eclipse.emf.facet.efacet.sdk.ui.internal.Messages;
import org.eclipse.emf.facet.efacet.sdk.ui.internal.exported.widget.IDerivedTypedElementWidget;
import org.eclipse.emf.facet.efacet.sdk.ui.internal.sync.generated.SynchronizedGetOrCreateFilteredElementCommmandWidget;
import org.eclipse.emf.facet.efacet.sdk.ui.internal.widget.creation.GetOrCreateFiltredOperationWidget;
import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IDialog;
import org.eclipse.emf.facet.util.ui.internal.exported.dialog.IWithResultDialogCallback;
import org.eclipse.emf.facet.util.ui.internal.exported.util.dialog.SynchronizedAbstractDialog;
import org.eclipse.emf.facet.util.ui.internal.exported.util.widget.command.IGetOrCreateFilteredElementCommmandWidget;
import org.eclipse.swt.widgets.Display;
/**
* Provide a dialog where the user can select an Operation in the existing
* facets list or create a new one. This class use the specific widget
* {@link GetOrCreateFiltredOperationWidget} and return the selected element
* with the method {@link #getFacetOperationSelected()}.</p>
*
* When the "ok" button is pressed, the parent property is set with the selected
* element.
*
* @see GetOrCreateFiltredOperationWidget
*/
public class GetOrCreateOperationDialog extends
AbstractComandExecDialog<FacetOperation, IGetOrCreateFilteredElementCommmandWidget<FacetOperation, IDerivedTypedElementWidget>> {
private GetOrCreateFiltredOperationWidget gOCOperation; // gOC=getOrCreate
private final EditingDomain editingDomain;
private final Facet context;
/**
* The constructor.
*
* @param callback
* the callback.
* @param context
* @param specificProperties
* properties that parent widget had.
*/
public GetOrCreateOperationDialog(
final IWithResultDialogCallback<FacetOperation> callback,
final EditingDomain editingDomain, final Facet context) {
super(callback, editingDomain);
this.editingDomain = editingDomain;
this.context = context;
}
/**
* Return the operation selected by the user.
*
* @return the operation selected.
*/
public FacetOperation getFacetOperation() {
return this.gOCOperation.getFacetOperationSelected();
}
@Override
protected IGetOrCreateFilteredElementCommmandWidget<FacetOperation, IDerivedTypedElementWidget> createWidget() {
this.gOCOperation = new GetOrCreateFiltredOperationWidget(
this.getDialogComposite(), this.editingDomain, this.context);
return new SynchronizedGetOrCreateFilteredElementCommmandWidget<FacetOperation, IDerivedTypedElementWidget>(
this.gOCOperation, this.gOCOperation.getDisplay());
}
@Override
protected String getDialogMessage() {
return Messages.GetOrCreate_Operation_message;
}
@Override
protected String getDialogTitle() {
return Messages.Select_Operation;
}
@Override
protected void okPressed() {
// TODO Use of an instance of PropetyElement2
this.getCallback().canceled(
this.gOCOperation.getFacetOperationSelected());
super.okPressed();
}
public void selectElement(final FacetOperation element) {
this.gOCOperation.selectElement(element);
}
public IDialog<IDerivedTypedElementWidget> createElement() {
final IDialog<IDerivedTypedElementWidget> pressNewButton = this.gOCOperation
.pressNewButton();
return new SynchronizedAbstractDialog<IDerivedTypedElementWidget>(
pressNewButton, Display.getDefault());
}
@Override
protected FacetOperation getResult() {
return this.gOCOperation.getFacetOperationSelected();
}
}
|