blob: 068b816d54b4763db609da4bd16ed11a0f83ee54 [file] [log] [blame]
/***********************************************************************************************************************
* Copyright (c) 2010 Attensity Europe GmbH.
* 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
**********************************************************************************************************************/
package org.eclipse.smila.processing.designer.ui.properties;
import org.eclipse.bpel.common.ui.details.*;
import org.eclipse.bpel.common.ui.details.widgets.DecoratedLabel;
import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
import org.eclipse.bpel.common.ui.flatui.FlatFormData;
import org.eclipse.bpel.ui.properties.BPELPropertySection;
import org.eclipse.bpel.ui.properties.EditController;
import org.eclipse.bpel.ui.util.BPELUtil;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.commands.Command;
import org.eclipse.smila.processing.designer.model.processor.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
/**
* The type section for the InvokeServlet activity.
*
* Copyright (c) 2010 Attensity Europe GmbH
*
* @author Tobias Liefke
*/
public class ServiceTypeSection extends BPELPropertySection
{
private Text typeTextField;
private EditController typeEditController;
/**
* Changes the content of the text field.
*
* @see BPELPropertySection#basicSetInput(EObject)
*/
@Override
protected void basicSetInput(EObject input)
{
super.basicSetInput(input);
typeEditController.setInput(input);
}
/**
* Create the components and event handlers.
*
* @see BPELPropertySection#createClient(Composite)
*/
@Override
protected void createClient(Composite parent)
{
createComponents(parent);
createChangeTrackers();
}
/**
* Create the components.
*
* @param composite the parent
*/
private void createComponents(Composite parent)
{
Composite composite = createFlatFormComposite(parent);
DecoratedLabel typeLabel = new DecoratedLabel(composite, SWT.LEFT);
fWidgetFactory.adapt(typeLabel);
typeLabel.setText("Servicename:");
typeTextField = fWidgetFactory.createText(composite, EMPTY_STRING);
FlatFormData data = new FlatFormData();
data.left = new FlatFormAttachment(0, BPELUtil.calculateLabelWidth(typeLabel, STANDARD_LABEL_WIDTH_AVG));
data.right = new FlatFormAttachment(100, (-2) * IDetailsAreaConstants.HSPACE);
data.top = new FlatFormAttachment(0, IDetailsAreaConstants.VSPACE);
typeTextField.setLayoutData(data);
data = new FlatFormData();
data.left = new FlatFormAttachment(0, 0);
data.right = new FlatFormAttachment(typeTextField, -IDetailsAreaConstants.HSPACE);
data.top = new FlatFormAttachment(typeTextField, 0, SWT.CENTER);
typeLabel.setLayoutData(data);
// TODO Add help reference
// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PROPERTY_PAGE_NAME);
}
/**
* Create the event listeners.
*/
private void createChangeTrackers()
{
typeEditController = new EditController(getCommandFramework())
{
@Override
public boolean checkNotification(Notification notification)
{
return notification.getFeatureID(Service.class) == ProcessorPackage.SERVICE__NAME;
}
@Override
public Command createApplyCommand()
{
return wrapInShowContextCommand(super.createApplyCommand());
}
};
typeEditController.setLabel(ProcessorPackage.eINSTANCE.getPipelet_Class().getName());
typeEditController.setViewIValue(new TextIValue(typeTextField));
typeEditController.setModeIValue(new IValue()
{
@Override
public Object get()
{
InvokeService invokeService = (InvokeService) typeEditController.getInput();
return invokeService == null || invokeService.getService() == null ? "" : invokeService.getService().getName();
}
@Override
public void set(Object object)
{
InvokeService invokeService = (InvokeService) typeEditController.getInput();
if (invokeService != null)
{
invokeService.getService().setName(object.toString());
}
}
});
typeEditController.startListeningTo(typeTextField);
}
/**
* @see org.eclipse.bpel.ui.properties.BPELPropertySection#getUserContext()
*/
@Override
public Object getUserContext()
{
return null;
}
/**
* @see BPELPropertySection#restoreUserContext(Object)
*/
@Override
public void restoreUserContext(Object userContext)
{
typeTextField.setFocus();
}
}