Lines 12-58
Link Here
|
12 |
|
12 |
|
13 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.EJB_NAME; |
13 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.EJB_NAME; |
14 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.TRANSACTION_TYPE; |
14 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewEnterpriseBeanClassDataModelProperties.TRANSACTION_TYPE; |
|
|
15 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewMessageDrivenBeanClassDataModelProperties.MESSAGE_LISTENER_INTERFACE; |
15 |
|
16 |
|
|
|
17 |
import org.eclipse.core.resources.IProject; |
18 |
import org.eclipse.jdt.core.IJavaProject; |
19 |
import org.eclipse.jdt.core.IType; |
20 |
import org.eclipse.jdt.core.search.IJavaSearchConstants; |
21 |
import org.eclipse.jdt.core.search.IJavaSearchScope; |
22 |
import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog; |
23 |
import org.eclipse.jem.workbench.utility.JemProjectUtilities; |
24 |
import org.eclipse.jface.operation.IRunnableContext; |
25 |
import org.eclipse.jface.window.Window; |
16 |
import org.eclipse.jst.ejb.ui.internal.util.EJBUIMessages; |
26 |
import org.eclipse.jst.ejb.ui.internal.util.EJBUIMessages; |
|
|
27 |
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties; |
28 |
import org.eclipse.jst.j2ee.internal.dialogs.TypeSearchEngine; |
29 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages; |
30 |
import org.eclipse.osgi.util.NLS; |
17 |
import org.eclipse.swt.SWT; |
31 |
import org.eclipse.swt.SWT; |
18 |
import org.eclipse.swt.layout.GridData; |
32 |
import org.eclipse.swt.layout.GridData; |
19 |
import org.eclipse.swt.layout.GridLayout; |
33 |
import org.eclipse.swt.layout.GridLayout; |
20 |
import org.eclipse.swt.widgets.Combo; |
34 |
import org.eclipse.swt.widgets.Combo; |
21 |
import org.eclipse.swt.widgets.Composite; |
35 |
import org.eclipse.swt.widgets.Composite; |
|
|
36 |
import org.eclipse.swt.widgets.Control; |
37 |
import org.eclipse.swt.widgets.Display; |
22 |
import org.eclipse.swt.widgets.Label; |
38 |
import org.eclipse.swt.widgets.Label; |
23 |
import org.eclipse.swt.widgets.Text; |
39 |
import org.eclipse.swt.widgets.Text; |
|
|
40 |
import org.eclipse.ui.PlatformUI; |
41 |
import org.eclipse.ui.forms.HyperlinkGroup; |
42 |
import org.eclipse.ui.forms.events.HyperlinkAdapter; |
43 |
import org.eclipse.ui.forms.events.HyperlinkEvent; |
44 |
import org.eclipse.ui.forms.widgets.Hyperlink; |
24 |
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; |
45 |
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor; |
25 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModel; |
46 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModel; |
|
|
47 |
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper; |
26 |
|
48 |
|
27 |
public class AddMessageDrivenBeanWizardPage extends |
49 |
public class AddMessageDrivenBeanWizardPage extends |
28 |
AddEnterpriseBeanWizardPage { |
50 |
AddEnterpriseBeanWizardPage { |
29 |
|
51 |
|
|
|
52 |
private class HyperlinkDataModelSynchHelper extends DataModelSynchHelper { |
53 |
|
54 |
public HyperlinkDataModelSynchHelper(IDataModel model) { |
55 |
super(model); |
56 |
} |
57 |
|
58 |
public void synchHyperlink(Hyperlink hyperlink, String propertyName, Control[] dependentControls) { |
59 |
synchComposite(hyperlink, propertyName, dependentControls); |
60 |
} |
61 |
|
62 |
@Override |
63 |
public void synchUIWithModel(final String propertyName, final int flag) { |
64 |
if (MESSAGE_LISTENER_INTERFACE.equals(propertyName)) { |
65 |
if(Thread.currentThread() == Display.getDefault().getThread()) { |
66 |
setHyperlinkText(); |
67 |
} else { |
68 |
Display.getDefault().asyncExec(new Runnable() { |
69 |
public void run() { |
70 |
setHyperlinkText(); |
71 |
} |
72 |
}); |
73 |
} |
74 |
} |
75 |
|
76 |
super.synchUIWithModel(propertyName, flag); |
77 |
} |
78 |
|
79 |
public void setHyperlinkText() { |
80 |
if (null != messageListenerInterfaceHyperlink) { |
81 |
String value = getDataModel().getStringProperty(MESSAGE_LISTENER_INTERFACE); |
82 |
if (value == null || value.trim().length() == 0) { |
83 |
value = IEjbWizardConstants.CLICK_TO_SELECT; |
84 |
} |
85 |
messageListenerInterfaceHyperlink.setText(NLS.bind( |
86 |
IEjbWizardConstants.MESSAGE_LISTENER_INTERFACE_HYPERLINK, |
87 |
value)); |
88 |
} |
89 |
} |
90 |
|
91 |
} |
92 |
|
30 |
private Text ejbNameText; |
93 |
private Text ejbNameText; |
31 |
private Combo transactionTypeCombo; |
94 |
private Combo transactionTypeCombo; |
32 |
|
95 |
|
|
|
96 |
private Hyperlink messageListenerInterfaceHyperlink; |
97 |
|
33 |
public AddMessageDrivenBeanWizardPage(IDataModel model, String pageName) { |
98 |
public AddMessageDrivenBeanWizardPage(IDataModel model, String pageName) { |
34 |
super(model, pageName, |
99 |
super(model, pageName, |
35 |
IEjbWizardConstants.ADD_MESSAGE_DRIVEN_BEAN_WIZARD_PAGE_DESC, |
100 |
IEjbWizardConstants.ADD_MESSAGE_DRIVEN_BEAN_WIZARD_PAGE_DESC, |
36 |
IEjbWizardConstants.ADD_MESSAGE_DRIVEN_BEANS_WIZARD_PAGE_TITLE); |
101 |
IEjbWizardConstants.ADD_MESSAGE_DRIVEN_BEANS_WIZARD_PAGE_TITLE); |
37 |
} |
102 |
} |
|
|
103 |
|
104 |
@Override |
105 |
public DataModelSynchHelper initializeSynchHelper(IDataModel dm) { |
106 |
return new HyperlinkDataModelSynchHelper(dm); |
107 |
} |
38 |
|
108 |
|
39 |
protected Composite createTopLevelComposite(Composite parent) { |
109 |
protected Composite createTopLevelComposite(Composite parent) { |
40 |
|
|
|
41 |
Composite composite = new Composite(parent, SWT.NULL); |
110 |
Composite composite = new Composite(parent, SWT.NULL); |
42 |
composite.setLayout(new GridLayout(3, false)); |
111 |
composite.setLayout(new GridLayout(2, false)); |
|
|
112 |
GridData data = new GridData(GridData.FILL_BOTH); |
113 |
data.widthHint = 300; |
114 |
composite.setLayoutData(data); |
115 |
|
116 |
createBeanNameTransactionType(composite); |
117 |
addSeperator(composite, 2); |
118 |
createInterfaceControls(composite); |
119 |
createMessageListenerInterfaceControl(composite); |
120 |
addSeperator(composite, 2); |
121 |
createStubsComposite(composite); |
43 |
|
122 |
|
|
|
123 |
return composite; |
124 |
} |
125 |
|
126 |
private void createBeanNameTransactionType(Composite composite) { |
127 |
// bean name |
44 |
Label ejbNameLabel = new Label(composite, SWT.LEFT); |
128 |
Label ejbNameLabel = new Label(composite, SWT.LEFT); |
45 |
ejbNameLabel.setText(IEjbWizardConstants.EJB_NAME); |
129 |
ejbNameLabel.setText(IEjbWizardConstants.EJB_NAME); |
46 |
|
130 |
|
47 |
GridData data = new GridData (); |
131 |
GridData data = new GridData(); |
48 |
data.horizontalAlignment = GridData.FILL; |
132 |
data.horizontalAlignment = GridData.FILL; |
49 |
data.horizontalSpan = 2; |
|
|
50 |
data.grabExcessHorizontalSpace = true; |
133 |
data.grabExcessHorizontalSpace = true; |
51 |
|
134 |
|
52 |
ejbNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); |
135 |
ejbNameText = new Text(composite, SWT.SINGLE | SWT.BORDER); |
53 |
ejbNameText.setLayoutData(data); |
136 |
ejbNameText.setLayoutData(data); |
54 |
synchHelper.synchText(ejbNameText, EJB_NAME, null); |
137 |
synchHelper.synchText(ejbNameText, EJB_NAME, null); |
55 |
|
138 |
|
|
|
139 |
// transaction type |
56 |
Label transactionTypeLabel = new Label(composite, SWT.LEFT); |
140 |
Label transactionTypeLabel = new Label(composite, SWT.LEFT); |
57 |
transactionTypeLabel.setText(EJBUIMessages.TRANSACTION_TYPE); |
141 |
transactionTypeLabel.setText(EJBUIMessages.TRANSACTION_TYPE); |
58 |
transactionTypeCombo = new Combo(composite, SWT.None | SWT.READ_ONLY); |
142 |
transactionTypeCombo = new Combo(composite, SWT.None | SWT.READ_ONLY); |
Lines 63-76
Link Here
|
63 |
} |
147 |
} |
64 |
transactionTypeCombo.select(0); |
148 |
transactionTypeCombo.select(0); |
65 |
synchHelper.synchCombo(transactionTypeCombo, TRANSACTION_TYPE, null); |
149 |
synchHelper.synchCombo(transactionTypeCombo, TRANSACTION_TYPE, null); |
|
|
150 |
} |
66 |
|
151 |
|
67 |
addSeperator(composite, 3); |
152 |
private void createMessageListenerInterfaceControl(Composite composite) { |
68 |
|
153 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
69 |
createInterfaceControls(composite); |
154 |
data.horizontalSpan = 2; |
|
|
155 |
messageListenerInterfaceHyperlink = new Hyperlink(composite, SWT.NULL); |
156 |
messageListenerInterfaceHyperlink.setLayoutData(data); |
157 |
String messageListenerInterface = getDataModel().getStringProperty(MESSAGE_LISTENER_INTERFACE); |
158 |
messageListenerInterfaceHyperlink.setToolTipText(IEjbWizardConstants.MESSAGE_LISTENER_INTERFACE_HYPERLINK_TOOLTIP); |
159 |
messageListenerInterfaceHyperlink.setVisible(true); |
160 |
messageListenerInterfaceHyperlink.setUnderlined(true); |
161 |
messageListenerInterfaceHyperlink.addHyperlinkListener(new HyperlinkAdapter() { |
162 |
public void linkActivated(HyperlinkEvent e){ |
163 |
IProject project = (IProject) model.getProperty(INewJavaClassDataModelProperties.PROJECT); |
164 |
IRunnableContext context = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
165 |
IJavaProject javaProject = JemProjectUtilities.getJavaProject(project); |
166 |
// this eliminates the non-exported classpath entries |
167 |
final IJavaSearchScope scope = TypeSearchEngine.createJavaSearchScopeForAProject(javaProject, true, true); |
168 |
FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(getShell(), false, context, scope, IJavaSearchConstants.INTERFACE); |
169 |
dialog.setTitle(J2EEUIMessages.INTERFACE_SELECTION_DIALOG_TITLE); |
170 |
if (dialog.open() == Window.OK) { |
171 |
IType type = (IType) dialog.getFirstResult(); |
172 |
String fullyQualifiedName = type.getFullyQualifiedName(); |
173 |
getDataModel().setProperty(MESSAGE_LISTENER_INTERFACE, fullyQualifiedName); |
174 |
} |
175 |
} |
176 |
}); |
177 |
new HyperlinkGroup(Display.getCurrent()).add(messageListenerInterfaceHyperlink); |
178 |
((HyperlinkDataModelSynchHelper) synchHelper).synchHyperlink(messageListenerInterfaceHyperlink, MESSAGE_LISTENER_INTERFACE, null); |
179 |
} |
70 |
|
180 |
|
71 |
createStubsComposite(composite); |
181 |
@Override |
|
|
182 |
protected boolean showValidationErrorsOnEnter() { |
183 |
return true; |
184 |
} |
72 |
|
185 |
|
73 |
return composite; |
186 |
@Override |
|
|
187 |
protected String[] getValidationPropertyNames() { |
188 |
return new String[] { MESSAGE_LISTENER_INTERFACE }; |
74 |
} |
189 |
} |
75 |
|
190 |
|
76 |
} |
191 |
} |