/** * Generated with Acceleo */ package org.eclipse.emf.ecoretools.design.properties.parts.impl; // Start of user code for imports import org.eclipse.emf.ecoretools.design.properties.ecore.providers.EcoreMessages; import org.eclipse.emf.ecoretools.design.properties.parts.EEnumLiteralPropertiesEditionPart; import org.eclipse.emf.ecoretools.design.properties.parts.EcoreViewsRepository; 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.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; 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.Text; // End of user code /** * * */ public class EEnumLiteralPropertiesEditionPartImpl extends CompositePropertiesEditionPart implements ISWTPropertiesEditionPart, EEnumLiteralPropertiesEditionPart { protected Text name; protected Text value; protected Text literal; /** * Default constructor * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part * */ public EEnumLiteralPropertiesEditionPartImpl(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 eEnumLiteralStep = new BindingCompositionSequence(propertiesEditionComponent); CompositionStep propertiesStep = eEnumLiteralStep.addStep(EcoreViewsRepository.EEnumLiteral.Properties.class); propertiesStep.addStep(EcoreViewsRepository.EEnumLiteral.Properties.name); propertiesStep.addStep(EcoreViewsRepository.EEnumLiteral.Properties.value); propertiesStep.addStep(EcoreViewsRepository.EEnumLiteral.Properties.literal); composer = new PartComposer(eEnumLiteralStep) { @Override public Composite addToPart(Composite parent, Object key) { if (key == EcoreViewsRepository.EEnumLiteral.Properties.class) { return createPropertiesGroup(parent); } if (key == EcoreViewsRepository.EEnumLiteral.Properties.name) { return createNameText(parent); } if (key == EcoreViewsRepository.EEnumLiteral.Properties.value) { return createValueText(parent); } if (key == EcoreViewsRepository.EEnumLiteral.Properties.literal) { return createLiteralText(parent); } return parent; } }; composer.compose(view); } /** * */ protected Composite createPropertiesGroup(Composite parent) { Group propertiesGroup = new Group(parent, SWT.NONE); propertiesGroup.setText(EcoreMessages.EEnumLiteralPropertiesEditionPart_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 createNameText(Composite parent) { createDescription(parent, EcoreViewsRepository.EEnumLiteral.Properties.name, EcoreMessages.EEnumLiteralPropertiesEditionPart_NameLabel); name = SWTUtils.createScrollableText(parent, SWT.BORDER); GridData nameData = new GridData(GridData.FILL_HORIZONTAL); name.setLayoutData(nameData); name.addFocusListener(new FocusAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) * */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText())); } }); name.addKeyListener(new KeyAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) * */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText())); } } }); EditingUtils.setID(name, EcoreViewsRepository.EEnumLiteral.Properties.name); EditingUtils.setEEFtype(name, "eef::Text"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EEnumLiteral.Properties.name, EcoreViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createNameText // End of user code return parent; } protected Composite createValueText(Composite parent) { createDescription(parent, EcoreViewsRepository.EEnumLiteral.Properties.value, EcoreMessages.EEnumLiteralPropertiesEditionPart_ValueLabel); value = SWTUtils.createScrollableText(parent, SWT.BORDER); GridData valueData = new GridData(GridData.FILL_HORIZONTAL); value.setLayoutData(valueData); value.addFocusListener(new FocusAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) * */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.value, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, value.getText())); } }); value.addKeyListener(new KeyAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) * */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.value, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, value.getText())); } } }); EditingUtils.setID(value, EcoreViewsRepository.EEnumLiteral.Properties.value); EditingUtils.setEEFtype(value, "eef::Text"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EEnumLiteral.Properties.value, EcoreViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createValueText // End of user code return parent; } protected Composite createLiteralText(Composite parent) { createDescription(parent, EcoreViewsRepository.EEnumLiteral.Properties.literal, EcoreMessages.EEnumLiteralPropertiesEditionPart_LiteralLabel); literal = SWTUtils.createScrollableText(parent, SWT.BORDER); GridData literalData = new GridData(GridData.FILL_HORIZONTAL); literal.setLayoutData(literalData); literal.addFocusListener(new FocusAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) * */ @Override @SuppressWarnings("synthetic-access") public void focusLost(FocusEvent e) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.literal, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, literal.getText())); } }); literal.addKeyListener(new KeyAdapter() { /** * {@inheritDoc} * * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent) * */ @Override @SuppressWarnings("synthetic-access") public void keyPressed(KeyEvent e) { if (e.character == SWT.CR) { if (propertiesEditionComponent != null) propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(EEnumLiteralPropertiesEditionPartImpl.this, EcoreViewsRepository.EEnumLiteral.Properties.literal, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, literal.getText())); } } }); EditingUtils.setID(literal, EcoreViewsRepository.EEnumLiteral.Properties.literal); EditingUtils.setEEFtype(literal, "eef::Text"); //$NON-NLS-1$ SWTUtils.createHelpButton(parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EEnumLiteral.Properties.literal, EcoreViewsRepository.SWT_KIND), null); //$NON-NLS-1$ // Start of user code for createLiteralText // 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.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#getName() * */ public String getName() { return name.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#setName(String newValue) * */ public void setName(String newValue) { if (newValue != null) { name.setText(newValue); } else { name.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EEnumLiteral.Properties.name); if (eefElementEditorReadOnlyState && name.isEnabled()) { name.setEnabled(false); name.setToolTipText(EcoreMessages.EEnumLiteral_ReadOnly); } else if (!eefElementEditorReadOnlyState && !name.isEnabled()) { name.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#getValue() * */ public String getValue() { return value.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#setValue(String newValue) * */ public void setValue(String newValue) { if (newValue != null) { value.setText(newValue); } else { value.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EEnumLiteral.Properties.value); if (eefElementEditorReadOnlyState && value.isEnabled()) { value.setEnabled(false); value.setToolTipText(EcoreMessages.EEnumLiteral_ReadOnly); } else if (!eefElementEditorReadOnlyState && !value.isEnabled()) { value.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#getLiteral() * */ public String getLiteral() { return literal.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EEnumLiteralPropertiesEditionPart#setLiteral(String newValue) * */ public void setLiteral(String newValue) { if (newValue != null) { literal.setText(newValue); } else { literal.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EEnumLiteral.Properties.literal); if (eefElementEditorReadOnlyState && literal.isEnabled()) { literal.setEnabled(false); literal.setToolTipText(EcoreMessages.EEnumLiteral_ReadOnly); } else if (!eefElementEditorReadOnlyState && !literal.isEnabled()) { literal.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle() * */ public String getTitle() { return EcoreMessages.EEnumLiteral_Part_Title; } // Start of user code additional methods // End of user code }