/******************************************************************************* * 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.eefnr.parts.impl; // Start of user code for imports import org.eclipse.emf.eef.eefnr.parts.EefnrViewsRepository; import org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart; import org.eclipse.emf.eef.eefnr.providers.EefnrMessages; 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.parts.sequence.CompositionStep; 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 TextareaSamplePropertiesEditionPartImpl extends CompositePropertiesEditionPart implements ISWTPropertiesEditionPart, TextareaSamplePropertiesEditionPart { protected Text textareaRequiredProperty; protected Text textareaOptionalProperty; protected Text textareaROProperty; /** * Default constructor * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part * */ public TextareaSamplePropertiesEditionPartImpl(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 textareaSampleStep = new BindingCompositionSequence(propertiesEditionComponent); CompositionStep propertiesStep = textareaSampleStep.addStep(EefnrViewsRepository.TextareaSample.Properties.class); propertiesStep.addStep(EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty); propertiesStep.addStep(EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty); propertiesStep.addStep(EefnrViewsRepository.TextareaSample.Properties.textareaROProperty); composer = new PartComposer(textareaSampleStep) { @Override public Composite addToPart(Composite parent, Object key) { if (key == EefnrViewsRepository.TextareaSample.Properties.class) { return createPropertiesGroup(parent); } if (key == EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty) { return createTextareaRequiredPropertyTextarea(parent); } if (key == EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty) { return createTextareaOptionalPropertyTextarea(parent); } if (key == EefnrViewsRepository.TextareaSample.Properties.textareaROProperty) { return createTextareaROPropertyTextarea(parent); } return parent; } }; composer.compose(view); } /** * */ protected Composite createPropertiesGroup(Composite parent) { Group propertiesGroup = new Group(parent, SWT.NONE); propertiesGroup.setText(EefnrMessages.TextareaSamplePropertiesEditionPart_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 createTextareaRequiredPropertyTextarea(Composite parent) { Label textareaRequiredPropertyLabel = createDescription(parent, EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty, EefnrMessages.TextareaSamplePropertiesEditionPart_TextareaRequiredPropertyLabel); GridData textareaRequiredPropertyLabelData = new GridData(GridData.FILL_HORIZONTAL); textareaRequiredPropertyLabelData.horizontalSpan = 3; textareaRequiredPropertyLabel.setLayoutData(textareaRequiredPropertyLabelData); textareaRequiredProperty = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); GridData textareaRequiredPropertyData = new GridData(GridData.FILL_HORIZONTAL); textareaRequiredPropertyData.horizontalSpan = 2; textareaRequiredPropertyData.heightHint = 80; textareaRequiredPropertyData.widthHint = 200; textareaRequiredProperty.setLayoutData(textareaRequiredPropertyData); textareaRequiredProperty.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(TextareaSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, textareaRequiredProperty.getText())); } }); EditingUtils.setID(textareaRequiredProperty, EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty); EditingUtils.setEEFtype(textareaRequiredProperty, "eef::Textarea"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty, EefnrViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createTextareaRequiredPropertyTextArea // End of user code return parent; } protected Composite createTextareaOptionalPropertyTextarea(Composite parent) { Label textareaOptionalPropertyLabel = createDescription(parent, EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty, EefnrMessages.TextareaSamplePropertiesEditionPart_TextareaOptionalPropertyLabel); GridData textareaOptionalPropertyLabelData = new GridData(GridData.FILL_HORIZONTAL); textareaOptionalPropertyLabelData.horizontalSpan = 3; textareaOptionalPropertyLabel.setLayoutData(textareaOptionalPropertyLabelData); textareaOptionalProperty = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); GridData textareaOptionalPropertyData = new GridData(GridData.FILL_HORIZONTAL); textareaOptionalPropertyData.horizontalSpan = 2; textareaOptionalPropertyData.heightHint = 80; textareaOptionalPropertyData.widthHint = 200; textareaOptionalProperty.setLayoutData(textareaOptionalPropertyData); textareaOptionalProperty.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(TextareaSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, textareaOptionalProperty.getText())); } }); EditingUtils.setID(textareaOptionalProperty, EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty); EditingUtils.setEEFtype(textareaOptionalProperty, "eef::Textarea"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty, EefnrViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createTextareaOptionalPropertyTextArea // End of user code return parent; } protected Composite createTextareaROPropertyTextarea(Composite parent) { Label textareaROPropertyLabel = createDescription(parent, EefnrViewsRepository.TextareaSample.Properties.textareaROProperty, EefnrMessages.TextareaSamplePropertiesEditionPart_TextareaROPropertyLabel); GridData textareaROPropertyLabelData = new GridData(GridData.FILL_HORIZONTAL); textareaROPropertyLabelData.horizontalSpan = 3; textareaROPropertyLabel.setLayoutData(textareaROPropertyLabelData); textareaROProperty = SWTUtils.createScrollableText(parent, SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL); GridData textareaROPropertyData = new GridData(GridData.FILL_HORIZONTAL); textareaROPropertyData.horizontalSpan = 2; textareaROPropertyData.heightHint = 80; textareaROPropertyData.widthHint = 200; textareaROProperty.setLayoutData(textareaROPropertyData); textareaROProperty.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(TextareaSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.TextareaSample.Properties.textareaROProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, textareaROProperty.getText())); } }); EditingUtils.setID(textareaROProperty, EefnrViewsRepository.TextareaSample.Properties.textareaROProperty); EditingUtils.setEEFtype(textareaROProperty, "eef::Textarea"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EefnrViewsRepository.TextareaSample.Properties.textareaROProperty, EefnrViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createTextareaROPropertyTextArea // 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.eefnr.parts.TextareaSamplePropertiesEditionPart#getTextareaRequiredProperty() * */ public String getTextareaRequiredProperty() { return textareaRequiredProperty.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart#setTextareaRequiredProperty(String newValue) * */ public void setTextareaRequiredProperty(String newValue) { if (newValue != null) { textareaRequiredProperty.setText(newValue); } else { textareaRequiredProperty.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EefnrViewsRepository.TextareaSample.Properties.textareaRequiredProperty); if (eefElementEditorReadOnlyState && textareaRequiredProperty.isEnabled()) { textareaRequiredProperty.setEnabled(false); textareaRequiredProperty.setBackground(textareaRequiredProperty.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); textareaRequiredProperty.setToolTipText(EefnrMessages.TextareaSample_ReadOnly); } else if (!eefElementEditorReadOnlyState && !textareaRequiredProperty.isEnabled()) { textareaRequiredProperty.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart#getTextareaOptionalProperty() * */ public String getTextareaOptionalProperty() { return textareaOptionalProperty.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart#setTextareaOptionalProperty(String newValue) * */ public void setTextareaOptionalProperty(String newValue) { if (newValue != null) { textareaOptionalProperty.setText(newValue); } else { textareaOptionalProperty.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EefnrViewsRepository.TextareaSample.Properties.textareaOptionalProperty); if (eefElementEditorReadOnlyState && textareaOptionalProperty.isEnabled()) { textareaOptionalProperty.setEnabled(false); textareaOptionalProperty.setBackground(textareaOptionalProperty.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); textareaOptionalProperty.setToolTipText(EefnrMessages.TextareaSample_ReadOnly); } else if (!eefElementEditorReadOnlyState && !textareaOptionalProperty.isEnabled()) { textareaOptionalProperty.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart#getTextareaROProperty() * */ public String getTextareaROProperty() { return textareaROProperty.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.eefnr.parts.TextareaSamplePropertiesEditionPart#setTextareaROProperty(String newValue) * */ public void setTextareaROProperty(String newValue) { if (newValue != null) { textareaROProperty.setText(newValue); } else { textareaROProperty.setText(""); //$NON-NLS-1$ } textareaROProperty.setEnabled(false); textareaROProperty.setBackground(textareaROProperty.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); textareaROProperty.setToolTipText(EefnrMessages.TextareaSample_ReadOnly); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle() * */ public String getTitle() { return EefnrMessages.TextareaSample_Part_Title; } // Start of user code additional methods // End of user code }