in uimaj-ep-deployeditor/src/main/java/org/apache/uima/dde/internal/page/OverviewPage.java [620:834]
private Section createServiceSection(Composite parent, final FormToolkit toolkit) {
Section section = FormSection.createTableWrapDataSection(toolkit, parent, Section.TREE_NODE
| Section.DESCRIPTION, Messages.DDE_OverviewPage_Service_Section_Title,
Messages.DDE_OverviewPage_Service_Section_Description, 10, 3, TableWrapData.FILL_GRAB,
TableWrapData.FILL_GRAB, 1, 1);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
Composite sectionClient = toolkit.createComposite(section);
serviceSectionClient = sectionClient;
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
sectionClient.setLayout(gl);
section.setClient(sectionClient);
// Top part
Composite topComposite = toolkit.createComposite(sectionClient);
TableWrapLayout tl = new TableWrapLayout();
tl.numColumns = 2;
tl.bottomMargin = 10;
topComposite.setLayout(tl);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
topComposite.setLayoutData(gd);
// <deployment protocol="jms" provider="activemq">
// Note: Need to add SWT.BORDER style to make the border VISIBLE in Linux
brokerUrlDecoField = FormSection2.createLabelAndDecoratedText(toolkit, topComposite,
"Broker URL for input queue:",
aeService.getBrokerURL(), SWT.WRAP | SWT.BORDER, 200, 0, true, 0);
// Create an error decoration
decorationBrokerUrl = FormSection2.registerFieldDecoration("brokerUrl",
"The broker URL cannot be empty");
brokerUrlDecoField.addFieldDecoration(decorationBrokerUrl, SWT.LEFT | SWT.TOP, false);
brokerUrl = (Text) brokerUrlDecoField.getControl();
brokerUrl.setToolTipText("Enter the URL for the input queue");
brokerUrl.addModifyListener(fModifyListener);
// Note: Need to add SWT.BORDER style to make the border VISIBLE in Linux
endPointDecoField = FormSection2.createLabelAndDecoratedText(toolkit, topComposite,
"Name for input queue:", aeService.getEndPoint(), SWT.WRAP | SWT.BORDER, 200, 0, true, 0);
endPoint = (Text) endPointDecoField.getControl();
// ((FormData) endPoint.getLayoutData()).width = 200;
endPoint.setToolTipText("Enter the name for the input queue");
endPoint.addModifyListener(fModifyListener);
decorationEndPoint =
FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
decorationEndPoint.setDescription("The name for the queue cannot be empty");
endPointDecoField.addFieldDecoration(decorationEndPoint, SWT.LEFT | SWT.TOP, false);
// <.. prefetch=="0" /> <!-- optional -->
prefetch = FormSection2.createLabelAndSpinner(toolkit, topComposite,
"Number of requests that might be prefetched:", SWT.BORDER, 0,
Integer.MAX_VALUE, false, FormSection2.MAX_DECORATION_WIDTH);
prefetch.setSelection(aeService.getPrefetch());
prefetch.addSelectionListener(selectionListener);
// <casPool numberOfCASes="3"/> <!-- optional -->
casPoolSize = FormSection2.createLabelAndSpinner(toolkit, topComposite,
"Number of CASes in CAS pool:", SWT.BORDER, 1,
Integer.MAX_VALUE, false, FormSection2.MAX_DECORATION_WIDTH);
casPoolSize.setSelection(aeDeploymentDescription.getCasPoolSize());
casPoolSize.addSelectionListener(selectionListener);
try {
if (!aeDeploymentDescription.getAeService().getAnalysisEngineDeploymentMetaData().isAsync()) {
// Top AE is not Async (it is a UIMA-AS Primitive)
casPoolSize.setEnabled(false);
// Display warning if CAS pool size is not equal to the number of instances
int instances = aeDeploymentDescription.getAeService().getAnalysisEngineDeploymentMetaData().getNumberOfInstances();
if (casPoolSize.getSelection() != instances) {
if (Window.OK == Utility.popOkCancel("Warning - CAS Pool Size", MessageFormat.format(
"The CAS pool size (={0}) is not equal to the number of instances (={1}).\n\n"
+ "Set the CAS pool size to " + instances + "?",
new Object[] { casPoolSize.getSelection(), instances }),
MessageDialog.WARNING)) {
setCasPoolSize(instances);
multiPageEditor.setFileDirty();
}
}
}
} catch (InvalidXMLException e) {
e.printStackTrace();
}
// initialFsHeapSize (default size is 2M)
initialFsHeapSize = FormSection2.createLabelAndSpinner(toolkit, topComposite,
"Initial size of CAS heap (in bytes):", SWT.BORDER, 1,
Integer.MAX_VALUE, false, FormSection2.MAX_DECORATION_WIDTH);
initialFsHeapSize.setSelection(aeDeploymentDescription.getInitialFsHeapSize());
initialFsHeapSize.addSelectionListener(selectionListener);
// ////////////////////////////////////////
// Top descriptor
topDescriptorDecoField = FormSection2.createLabelAndGridLayoutDecoratedContainer(toolkit,
topComposite, "Top analysis engine descriptor", 2, 0, 0);
Composite browsingGroup = (Composite) topDescriptorDecoField.getControl();
decorationTopDescriptor = FormSection2.registerFieldDecoration("topDescriptorField",
"Top descriptor cannot be empty");
topDescriptorDecoField.addFieldDecoration(decorationTopDescriptor, SWT.LEFT | SWT.TOP, false);
toolkit.paintBordersFor(browsingGroup);
topDescriptorField = toolkit.createText(browsingGroup, "", SWT.READ_ONLY);
topDescriptorField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
| GridData.GRAB_HORIZONTAL));
String topDescriptor = null;
Import imp = aeService.getImportDescriptor();
if (imp != null) {
String descr = imp.getLocation();
if (descr == null) {
isImportByLocation = false;
descr = imp.getName();
} else {
isImportByLocation = true;
}
topDescriptor = descr;
}
topDescriptorField.setText(topDescriptor != null ? topDescriptor : "");
topDescriptorField.addModifyListener(fModifyListener);
// Button for browsing AE Xml descriptor
Button browseDirectoriesButton = toolkit.createButton(browsingGroup, "B&rowse...", SWT.PUSH);
browseDirectoriesButton.setLayoutData(new GridData());
browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
MultiResourceSelectionDialog dialog = new MultiResourceSelectionDialog(
form.getShell(), multiPageEditor.getFile().getProject().getParent(),
"Component Engine Selection", multiPageEditor.getFile().getLocation(), multiPageEditor.cde);
dialog.setTitle("Component Engine Selection");
dialog.setMessage("Select one component engine from the workspace:");
dialog.open();
Object[] files = dialog.getResult();
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
FileAndShortName fsn = new FileAndShortName(files[i]);
updateTopDescriptor(fsn.fileName, !dialog.isImportByName);
}
}
}
});
topDescriptorField.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
// updateFileList(inputDocPathField.getText().trim());
}
}
});
topDescriptorField.addFocusListener(new FocusAdapter() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
// updateFileList(inputDocPathField.getText().trim());
}
});
createContextMenu();
// Import by Name or by Location
toolkit.createLabel(topComposite, "", SWT.NONE);
Composite nameOrLocation = toolkit.createComposite(topComposite, SWT.NONE);
nameOrLocation.setLayout(new GridLayout(2, false));
TableWrapData td = new TableWrapData();
td.colspan = 1;
td.grabHorizontal = true;
td.indent = 0;
nameOrLocation.setLayoutData(td);
toolkit.paintBordersFor(nameOrLocation);
importByNameOrLocation = FormSection.createLabelAndLabel(toolkit, nameOrLocation, "Import by:",
"(Name or Location)", 200, 20);
if (imp != null) {
if (isImportByLocation) {
importByNameOrLocation.setText("Location");
} else {
importByNameOrLocation.setText("Name");
}
}
// Run C++ component in a separate process
customButton = toolkit.createButton(sectionClient, "Run top level C++ component in a separate process", SWT.CHECK);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = SERVICE_PANE_INDENT;
gd.grabExcessHorizontalSpace = true;
customButton.setLayoutData(gd);
customButton.addSelectionListener(selectionListener);
if (imp != null) {
// Check if C++ AE
customButton.setEnabled(aeService.isCPlusPlusTopAE());
if (aeService.getCustomValue() != null) {
customButton.setSelection(true);
if (aeService.getEnvironmentVariables() != null) {
for (NameValue nv: aeService.getEnvironmentVariables()) {
envName2NameValueMap.put(nv.getName(), nv);
}
customComposite = createCustomizationSection(serviceSectionClient);
}
}
} else {
customButton.setEnabled(false);
}
toolkit.paintBordersFor(topComposite);
return section;
} // createServiceSection