@Override
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
super.createControls(parent, tabbedPropertySheetPage);
TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
Composite composite = factory.createFlatFormComposite(parent);
FormData data;
Composite radioTypeComposite = new Composite(composite, SWT.NULL);
radioTypeComposite.setBackground(composite.getBackground());
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(100, 0);
radioTypeComposite.setLayoutData(data);
radioTypeComposite.setLayout(new RowLayout());
classTypeButton = new Button(radioTypeComposite, SWT.RADIO);
classTypeButton.setText("Java class");
classTypeButton.setSelection(true);
classTypeButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
setVisibleClassType(true);
setVisibleExpressionType(false);
setVisibleDelegateExpressionType(false);
saveImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
//
}
});
expressionTypeButton = new Button(radioTypeComposite, SWT.RADIO);
expressionTypeButton.setText("Expression");
expressionTypeButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
setVisibleClassType(false);
setVisibleExpressionType(true);
setVisibleDelegateExpressionType(false);
saveImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
//
}
});
delegateExpressionTypeButton = new Button(radioTypeComposite, SWT.RADIO);
delegateExpressionTypeButton.setText("Delegate expression");
delegateExpressionTypeButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
setVisibleClassType(false);
setVisibleExpressionType(false);
setVisibleDelegateExpressionType(true);
saveImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
//
}
});
CLabel typeLabel = factory.createCLabel(composite, "Type:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(radioTypeComposite, -HSPACE);
data.top = new FormAttachment(radioTypeComposite, 0, SWT.TOP);
typeLabel.setLayoutData(data);
classNameText = factory.createText(composite, ""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(70, 0);
data.top = new FormAttachment(radioTypeComposite, VSPACE);
classNameText.setEnabled(true);
classNameText.setLayoutData(data);
classSelectButton = factory.createButton(composite, "Select class", SWT.PUSH);
data = new FormData();
data.left = new FormAttachment(classNameText, 0);
data.right = new FormAttachment(78, 0);
data.top = new FormAttachment(classNameText, -2, SWT.TOP);
classSelectButton.setLayoutData(data);
classSelectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
Shell shell = classNameText.getShell();
try {
SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_CLASSES, false);
if (dialog.open() == SelectionDialog.OK) {
Object[] result = dialog.getResult();
String className = ((IType) result[0]).getFullyQualifiedName();
IJavaProject containerProject = ((IType) result[0]).getJavaProject();
if (className != null) {
classNameText.setText(className);
}
DiagramEditor diagramEditor = (DiagramEditor) getDiagramEditor();
TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
ActivitiUiUtil.runModelChange(new Runnable() {
@Override
public void run() {
Object bo = getBusinessObject(getSelectedPictogramElement());
if (bo == null) {
return;
}
String implementationName = classNameText.getText();
if (implementationName != null) {
if (bo instanceof ServiceTask) {
ServiceTask serviceTask = (ServiceTask) bo;
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
serviceTask.setImplementation(implementationName);
}
}
}
}, editingDomain, "Model Update");
IProject currentProject = ActivitiUiUtil.getProjectFromDiagram(getDiagram());
ActivitiUiUtil.doProjectReferenceChange(currentProject, containerProject, className);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
classSelectLabel = factory.createCLabel(composite, "Service class:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(classNameText, -HSPACE);
data.top = new FormAttachment(classNameText, 0, SWT.TOP);
classSelectLabel.setLayoutData(data);
expressionText = factory.createText(composite, ""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(radioTypeComposite, VSPACE);
expressionText.setVisible(false);
expressionText.setLayoutData(data);
expressionText.addFocusListener(listener);
expressionLabel = factory.createCLabel(composite, "Expression:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(expressionText, -HSPACE);
data.top = new FormAttachment(expressionText, 0, SWT.TOP);
expressionLabel.setVisible(false);
expressionLabel.setLayoutData(data);
delegateExpressionText = factory.createText(composite, ""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(radioTypeComposite, VSPACE);
delegateExpressionText.setVisible(false);
delegateExpressionText.setLayoutData(data);
delegateExpressionText.addFocusListener(listener);
delegateExpressionLabel = factory.createCLabel(composite, "Delegate expression:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(delegateExpressionText, -HSPACE);
data.top = new FormAttachment(delegateExpressionText, 0, SWT.TOP);
delegateExpressionLabel.setVisible(false);
delegateExpressionLabel.setLayoutData(data);
resultVariableText = factory.createText(composite, ""); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(expressionText, VSPACE);
resultVariableText.setLayoutData(data);
resultVariableText.addFocusListener(listener);
CLabel resultVariableLabel = factory.createCLabel(composite, "Result variable:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(resultVariableText, -HSPACE);
data.top = new FormAttachment(resultVariableText, 0, SWT.TOP);
resultVariableLabel.setLayoutData(data);
Composite extensionsComposite = factory.createComposite(composite, SWT.WRAP);
data = new FormData();
data.left = new FormAttachment(0, 160);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(resultVariableText, VSPACE);
extensionsComposite.setLayoutData(data);
GridLayout layout = new GridLayout();
layout.marginTop = 0;
layout.numColumns = 1;
extensionsComposite.setLayout(layout);
fieldEditor = new FieldExtensionEditor("fieldEditor", extensionsComposite);
fieldEditor.getLabelControl(extensionsComposite).setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
CLabel extensionLabel = factory.createCLabel(composite, "Fields:"); //$NON-NLS-1$
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(extensionsComposite, -HSPACE);
data.top = new FormAttachment(extensionsComposite, 0, SWT.TOP);
extensionLabel.setLayoutData(data);