blob: c3a503c50acfe9a2808423e4bce85f6bec94cd7a (
plain) (
blame)
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.papyrus.emf.facet.query.java.sdk.ui.internal.widget;
import org.eclipse.papyrus.emf.facet.efacet.sdk.ui.internal.exported.IQueryContext;
import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.JavaQueryUIRuntimeException;
import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.Messages;
import org.eclipse.papyrus.emf.facet.query.java.sdk.ui.internal.wizard.SelectOrCreateJavaClassWizard;
import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.util.widget.component.getorcreate.AbstractGetOrCreateElementWithWizardButtonWidget;
import org.eclipse.papyrus.emf.facet.util.ui.utils.PropertyElement2;
import org.eclipse.swt.widgets.Composite;
/**
* Widget for the recovery or creation of a java query class.
*/
public class GetOrCreateJavaImplementationWidgetComposite extends
AbstractGetOrCreateElementWithWizardButtonWidget<String, SelectOrCreateJavaClassWizard> {
private final IQueryContext queryContext;
/**
* Constructor.
*
* @param parent
* the parent of this widget.
* @param properties
* the properties.
* @param queryContext
* the main queryContext of the model.
* @param facet
* the current facet of the model.
*/
public GetOrCreateJavaImplementationWidgetComposite(final Composite parent,
final PropertyElement2<String> implClassNameProp,
final IQueryContext queryContext) {
super(parent, implClassNameProp);
this.queryContext = queryContext;
}
@Override
protected String getLabel() {
return Messages.JavaQueryWizardPage_Java_Class_Name;
}
@Override
protected String getErrorMessage() {
return Messages.JavaQueryWizardPage_Please_select_create_IJavaQuery_Class;
}
@Override
protected String getTextFieldInitialText() {
return null;
}
@Override
public void notifyChanged() {
// Nothing to do.
}
@Override
protected SelectOrCreateJavaClassWizard createIWizard() {
SelectOrCreateJavaClassWizard classCreation = null;
final IDialogCallback<String> callBack = new IDialogCallback<String>() {
@Override
public void committed(final String result) {
GetOrCreateJavaImplementationWidgetComposite.this
.onWizardCommited(result);
}
};
try {
classCreation = new SelectOrCreateJavaClassWizard(this.queryContext,
callBack);
} catch (Exception e) {
throw new JavaQueryUIRuntimeException(e);
}
return classCreation;
}
protected final void onWizardCommited(final String classQAName) {
this.getPropertyElement().setValue(classQAName);
this.getTextField().setText(classQAName);
}
@Override
protected void onWizardCanceled() {
// Not used because SelectOrCreateJavaClassWizard manage event using
// the call back pattern.
}
@Override
protected void onWizardCommited(final SelectOrCreateJavaClassWizard wizard) {
// Not used because SelectOrCreateJavaClassWizard manage event using
// the call back pattern.
}
@Override
protected SelectOrCreateJavaClassWizard createSynchronizedWizard(
final SelectOrCreateJavaClassWizard wizard) {
return null;
}
}
|