/******************************************************************************* * Copyright (c) 2008, 2012 Obeo. * 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 * * Contributors: * Obeo - initial API and implementation *******************************************************************************/ package org.eclipse.emf.eef.mapping.filters.parts.impl; // Start of user code for imports import org.eclipse.emf.eef.mapping.filters.parts.FiltersViewsRepository; import org.eclipse.emf.eef.mapping.filters.parts.JavaBodyStepFilterPropertiesEditionPart; import org.eclipse.emf.eef.mapping.filters.providers.FiltersMessages; import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent; import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent; import org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart; import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent; import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart; import org.eclipse.emf.eef.runtime.ui.parts.PartComposer; import org.eclipse.emf.eef.runtime.ui.parts.sequence.BindingCompositionSequence; import org.eclipse.emf.eef.runtime.ui.parts.sequence.CompositionSequence; import org.eclipse.emf.eef.runtime.ui.utils.EditingUtils; import org.eclipse.emf.eef.runtime.ui.widgets.SWTUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; // End of user code /** * @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a> * */ public class JavaBodyStepFilterPropertiesEditionPartImpl extends CompositePropertiesEditionPart implements ISWTPropertiesEditionPart, JavaBodyStepFilterPropertiesEditionPart { protected Text body; /** * Default constructor * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part * */ public JavaBodyStepFilterPropertiesEditionPartImpl(IPropertiesEditionComponent editionComponent) { super(editionComponent); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart# * createFigure(org.eclipse.swt.widgets.Composite) * */ public Composite createFigure(final Composite parent) { view = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; view.setLayout(layout); createControls(view); return view; } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.ISWTPropertiesEditionPart# * createControls(org.eclipse.swt.widgets.Composite) * */ public void createControls(Composite view) { CompositionSequence javaBodyStepFilterStep = new BindingCompositionSequence(propertiesEditionComponent); javaBodyStepFilterStep .addStep(FiltersViewsRepository.JavaBodyStepFilter.Properties.class) .addStep(FiltersViewsRepository.JavaBodyStepFilter.Properties.body); composer = new PartComposer(javaBodyStepFilterStep) { @Override public Composite addToPart(Composite parent, Object key) { if (key == FiltersViewsRepository.JavaBodyStepFilter.Properties.class) { return createPropertiesGroup(parent); } if (key == FiltersViewsRepository.JavaBodyStepFilter.Properties.body) { return createBodyTextarea(parent); } return parent; } }; composer.compose(view); } /** * */ protected Composite createPropertiesGroup(Composite parent) { Group propertiesGroup = new Group(parent, SWT.NONE); propertiesGroup.setText(FiltersMessages.JavaBodyStepFilterPropertiesEditionPart_PropertiesGroupLabel); GridData propertiesGroupData = new GridData(GridData.FILL_HORIZONTAL); propertiesGroupData.horizontalSpan = 3; propertiesGroup.setLayoutData(propertiesGroupData); GridLayout propertiesGroupLayout = new GridLayout(); propertiesGroupLayout.numColumns = 3; propertiesGroup.setLayout(propertiesGroupLayout); return propertiesGroup; } protected Composite createBodyTextarea(Composite parent) { Label bodyLabel = createDescription(parent, FiltersViewsRepository.JavaBodyStepFilter.Properties.body, FiltersMessages.JavaBodyStepFilterPropertiesEditionPart_BodyLabel); GridData bodyLabelData = new GridData(GridData.FILL_HORIZONTAL); bodyLabelData.horizontalSpan = 3; bodyLabel.setLayoutData(bodyLabelData); body = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); GridData bodyData = new GridData(GridData.FILL_HORIZONTAL); bodyData.horizontalSpan = 2; bodyData.heightHint = 80; bodyData.widthHint = 200; body.setLayoutData(bodyData); body.addFocusListener(new FocusAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) * */ public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JavaBodyStepFilterPropertiesEditionPartImpl.this, FiltersViewsRepository.JavaBodyStepFilter.Properties.body, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, body.getText())); } }); EditingUtils.setID(body, FiltersViewsRepository.JavaBodyStepFilter.Properties.body); EditingUtils.setEEFtype(body, "eef::Textarea"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(FiltersViewsRepository.JavaBodyStepFilter.Properties.body, FiltersViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createBodyTextArea // End of user code return parent; } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionListener#firePropertiesChanged(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * */ public void firePropertiesChanged(IPropertiesEditionEvent event) { // Start of user code for tab synchronization // End of user code } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.filters.parts.JavaBodyStepFilterPropertiesEditionPart#getBody() * */ public String getBody() { return body.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.filters.parts.JavaBodyStepFilterPropertiesEditionPart#setBody(String newValue) * */ public void setBody(String newValue) { if (newValue != null) { body.setText(newValue); } else { body.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(FiltersViewsRepository.JavaBodyStepFilter.Properties.body); if (eefElementEditorReadOnlyState && body.isEnabled()) { body.setEnabled(false); body.setBackground(body.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); body.setToolTipText(FiltersMessages.JavaBodyStepFilter_ReadOnly); } else if (!eefElementEditorReadOnlyState && !body.isEnabled()) { body.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle() * */ public String getTitle() { return FiltersMessages.JavaBodyStepFilter_Part_Title; } // Start of user code additional methods // End of user code }