| package org.eclipse.apogy.addons.mqtt.ros.ui.composites; |
| |
| import org.eclipse.apogy.addons.mqtt.ApogyAddonsMQTTPackage; |
| import org.eclipse.apogy.addons.mqtt.MQTTClient; |
| import org.eclipse.apogy.addons.mqtt.MQTTClientConnectionOptions; |
| import org.eclipse.apogy.addons.mqtt.ros.ApogyAddonsMQTTROSPackage; |
| import org.eclipse.apogy.addons.mqtt.ros.MQTTROSArbitratorServer; |
| import org.eclipse.apogy.common.emf.ApogyCommonTransactionFacade; |
| import org.eclipse.apogy.common.emf.ui.ApogyCommonEMFUIFactory; |
| import org.eclipse.apogy.common.emf.ui.EObjectCompositeSettings; |
| import org.eclipse.apogy.common.emf.ui.MapBasedEClassSettings; |
| import org.eclipse.apogy.common.emf.ui.composites.AbstractEObjectComposite; |
| import org.eclipse.apogy.common.emf.ui.emfforms.ApogyCommonEMFUiEMFFormsFacade; |
| import org.eclipse.apogy.common.emf.ui.emfforms.wizards.EObjectWizard; |
| import org.eclipse.emf.databinding.FeaturePath; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.jface.wizard.WizardDialog; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.custom.ScrolledComposite; |
| import org.eclipse.swt.events.SelectionEvent; |
| import org.eclipse.swt.events.SelectionListener; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Button; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Group; |
| import org.eclipse.swt.widgets.Label; |
| |
| public class MQTTROSArbitratorServerClientComposite extends AbstractEObjectComposite<MQTTROSArbitratorServer, MQTTClient, MQTTClient> |
| { |
| protected Button newClientConnectionsOptionButton; |
| protected Button clearClientConnectionsOptionButton; |
| protected Composite clientConnectionsOptionDetailsComposite; |
| protected Composite clientSettingsComposite; |
| |
| protected String labelName = ""; |
| |
| public MQTTROSArbitratorServerClientComposite(Composite parent, int style, FeaturePath featurePath, |
| EStructuralFeature eStructuralFeature, EObjectCompositeSettings settings) |
| { |
| super(parent, style, featurePath, eStructuralFeature, settings); |
| } |
| |
| @Override |
| protected Composite createContentComposite(Composite parent, int style) |
| { |
| Composite top = new Composite(parent, SWT.BORDER); |
| top.setLayout(new GridLayout(2, true)); |
| |
| // Left Side |
| Group clientGroup = new Group(top, SWT.BORDER); |
| clientGroup.setText("Client Setting"); |
| clientGroup.setLayout(new GridLayout(1, false)); |
| clientGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
| |
| ScrolledComposite clientScrolledComposite = new ScrolledComposite(clientGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); |
| clientScrolledComposite.setLayout(new GridLayout(1, false)); |
| clientScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); |
| clientScrolledComposite.setExpandHorizontal(true); |
| clientScrolledComposite.setExpandVertical(true); |
| |
| clientSettingsComposite = new Composite(clientScrolledComposite, SWT.NONE); |
| GridData gd_cclientSettingsComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); |
| gd_cclientSettingsComposite.widthHint = 400; |
| gd_cclientSettingsComposite.minimumWidth = 400; |
| gd_cclientSettingsComposite.minimumHeight = 800; |
| gd_cclientSettingsComposite.heightHint = 800; |
| clientSettingsComposite.setLayoutData(gd_cclientSettingsComposite); |
| clientSettingsComposite.setLayout(new GridLayout(1, false)); |
| clientScrolledComposite.setContent(clientSettingsComposite); |
| |
| // Right Side |
| Group clientConnectionsOptionGroup = new Group(top, SWT.BORDER); |
| clientConnectionsOptionGroup.setText("Connection Options"); |
| clientConnectionsOptionGroup.setLayout(new GridLayout(4, false)); |
| clientConnectionsOptionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
| |
| // First Line |
| Label label = new Label(clientConnectionsOptionGroup, SWT.NONE); |
| if(getEStructuralFeature() == ApogyAddonsMQTTROSPackage.Literals.MQTTROS_ARBITRATOR_SERVER__CLIENT_SIDE) |
| { |
| label.setText("Client Side Connection Options"); |
| } |
| else |
| { |
| label.setText("ROS Side Connection Options"); |
| } |
| |
| newClientConnectionsOptionButton = new Button(clientConnectionsOptionGroup, SWT.PUSH); |
| newClientConnectionsOptionButton.setText("New"); |
| newClientConnectionsOptionButton.addSelectionListener(new SelectionListener() { |
| |
| @Override |
| public void widgetSelected(SelectionEvent arg0) |
| { |
| doNewClientConnectionsOptions(); |
| } |
| |
| @Override |
| public void widgetDefaultSelected(SelectionEvent arg0) |
| { |
| } |
| }); |
| |
| clearClientConnectionsOptionButton = new Button(clientConnectionsOptionGroup, SWT.PUSH); |
| clearClientConnectionsOptionButton.setText("Clear"); |
| clearClientConnectionsOptionButton.addSelectionListener(new SelectionListener() { |
| |
| @Override |
| public void widgetSelected(SelectionEvent arg0) |
| { |
| doClearClientConnectionsOptions(); |
| } |
| |
| @Override |
| public void widgetDefaultSelected(SelectionEvent arg0) |
| { |
| } |
| }); |
| |
| // Second line |
| Label detailsLabel = new Label(clientConnectionsOptionGroup, SWT.NONE); |
| detailsLabel.setText("Details:"); |
| detailsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 4, 1)); |
| |
| |
| // Bottom |
| ScrolledComposite scrolledComposite = new ScrolledComposite(clientConnectionsOptionGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); |
| scrolledComposite.setLayout(new GridLayout(1, false)); |
| scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); |
| scrolledComposite.setExpandHorizontal(true); |
| scrolledComposite.setExpandVertical(true); |
| |
| clientConnectionsOptionDetailsComposite = new Composite(scrolledComposite, SWT.NONE); |
| GridData gd_compositeDetails = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); |
| gd_compositeDetails.widthHint = 400; |
| gd_compositeDetails.minimumWidth = 400; |
| gd_compositeDetails.minimumHeight = 800; |
| gd_compositeDetails.heightHint = 800; |
| clientConnectionsOptionDetailsComposite.setLayoutData(gd_compositeDetails); |
| clientConnectionsOptionDetailsComposite.setLayout(new GridLayout(1, false)); |
| |
| scrolledComposite.setContent(clientConnectionsOptionDetailsComposite); |
| |
| return top; |
| } |
| |
| @Override |
| protected void rootEObjectChanged(MQTTROSArbitratorServer rootEObject) |
| { |
| if(rootEObject != null) |
| { |
| MQTTClient client = (MQTTClient) rootEObject.eGet(getEStructuralFeature()); |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(clientSettingsComposite, client); |
| } |
| else |
| { |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(clientSettingsComposite, null); |
| } |
| } |
| |
| @SuppressWarnings({ "unchecked", "rawtypes" }) |
| protected void doNewClientConnectionsOptions() |
| { |
| // Open EObject Wizard |
| MapBasedEClassSettings settings = ApogyCommonEMFUIFactory.eINSTANCE.createMapBasedEClassSettings(); |
| EObjectWizard wizard = new EObjectWizard(getRootEObject(), |
| FeaturePath.fromList(getEStructuralFeature()), |
| ApogyAddonsMQTTPackage.Literals.MQTT_CLIENT__CONNECTION_OPTIONS, |
| ApogyAddonsMQTTPackage.Literals.MQTT_CLIENT_CONNECTION_OPTIONS, |
| settings); |
| WizardDialog dialog = new WizardDialog(getShell(), wizard); |
| dialog.open(); |
| |
| if(wizard.getCreatedEObject() instanceof MQTTClientConnectionOptions) |
| { |
| MQTTClient client = (MQTTClient) getRootEObject().eGet(getEStructuralFeature()); |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(client, ApogyAddonsMQTTPackage.Literals.MQTT_CLIENT__CONNECTION_OPTIONS, wizard.getCreatedEObject(), true); |
| |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(clientConnectionsOptionDetailsComposite, wizard.getCreatedEObject()); |
| |
| clientConnectionsOptionsSelected((MQTTClientConnectionOptions) wizard.getCreatedEObject()); |
| } |
| else |
| { |
| clientConnectionsOptionsSelected(null); |
| } |
| } |
| |
| protected void doClearClientConnectionsOptions() |
| { |
| MQTTClient client = (MQTTClient) getRootEObject().eGet(getEStructuralFeature()); |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(client, ApogyAddonsMQTTPackage.Literals.MQTT_CLIENT__CONNECTION_OPTIONS, null, true); |
| |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(clientConnectionsOptionDetailsComposite, null); |
| |
| clientConnectionsOptionsSelected(null); |
| } |
| |
| protected void clientConnectionsOptionsSelected(MQTTClientConnectionOptions mqttClientConnectionOptions) |
| { |
| } |
| } |