/** * Generated with Acceleo */ package org.eclipse.emf.ecoretools.design.properties.parts.forms; // Start of user code for imports import org.eclipse.emf.ecoretools.design.properties.EcoreToolsPropertiesEditingPart; import org.eclipse.emf.ecoretools.design.properties.ecore.providers.EcoreMessages; import org.eclipse.emf.ecoretools.design.properties.parts.EPackagePropertiesEditionPart; 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.IFormPropertiesEditionPart; import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent; 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.FormUtils; 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.Text; import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.views.properties.tabbed.ISection; // End of user code /** * * */ public class EPackagePropertiesEditionPartForm extends EcoreToolsPropertiesEditingPart implements IFormPropertiesEditionPart, EPackagePropertiesEditionPart { protected Text name; protected Text nsURI; protected Text nsPrefix; /** * For {@link ISection} use only. */ public EPackagePropertiesEditionPartForm() { super(); } /** * Default constructor * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part * */ public EPackagePropertiesEditionPartForm(IPropertiesEditionComponent editionComponent) { super(editionComponent); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart# * createFigure(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit) * */ public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) { ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent); Form form = scrolledForm.getForm(); view = form.getBody(); GridLayout layout = new GridLayout(); layout.numColumns = 3; view.setLayout(layout); createControls(widgetFactory, view); return scrolledForm; } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart# * createControls(org.eclipse.ui.forms.widgets.FormToolkit, org.eclipse.swt.widgets.Composite) * */ public void createControls(final FormToolkit widgetFactory, Composite view) { CompositionSequence ePackageStep = new BindingCompositionSequence(propertiesEditionComponent); CompositionStep propertiesStep = ePackageStep.addStep(EcoreViewsRepository.EPackage.Properties.class); propertiesStep.addStep(EcoreViewsRepository.EPackage.Properties.name); propertiesStep.addStep(EcoreViewsRepository.EPackage.Properties.nsURI); propertiesStep.addStep(EcoreViewsRepository.EPackage.Properties.nsPrefix); composer = new PartComposer(ePackageStep) { @Override public Composite addToPart(Composite parent, Object key) { if (key == EcoreViewsRepository.EPackage.Properties.class) { return createPropertiesGroup(widgetFactory, parent); } if (key == EcoreViewsRepository.EPackage.Properties.name) { return createNameText(widgetFactory, parent); } if (key == EcoreViewsRepository.EPackage.Properties.nsURI) { return createNsURIText(widgetFactory, parent); } if (key == EcoreViewsRepository.EPackage.Properties.nsPrefix) { return createNsPrefixText(widgetFactory, parent); } return parent; } }; composer.compose(view); } /** * */ protected Composite createPropertiesGroup(FormToolkit widgetFactory, final Composite parent) { Section propertiesSection = widgetFactory.createSection(parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED); propertiesSection.setText(EcoreMessages.EPackagePropertiesEditionPart_PropertiesGroupLabel); GridData propertiesSectionData = new GridData(GridData.FILL_HORIZONTAL); propertiesSectionData.horizontalSpan = 3; propertiesSection.setLayoutData(propertiesSectionData); Composite propertiesGroup = widgetFactory.createComposite(propertiesSection); GridLayout propertiesGroupLayout = new GridLayout(); propertiesGroupLayout.numColumns = 3; propertiesGroup.setLayout(propertiesGroupLayout); propertiesSection.setClient(propertiesGroup); return propertiesGroup; } protected Composite createNameText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, EcoreViewsRepository.EPackage.Properties.name, EcoreMessages.EPackagePropertiesEditionPart_NameLabel); name = widgetFactory.createText(parent, ""); //$NON-NLS-1$ name.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData nameData = new GridData(GridData.FILL_HORIZONTAL); name.setLayoutData(nameData); name.addFocusListener(new FocusAdapter() { /** * @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( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.name, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, name.getText())); } } /** * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ @Override public void focusGained(FocusEvent e) { if (propertiesEditionComponent != null) { propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); name.addKeyListener(new KeyAdapter() { /** * @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(EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText())); } } }); EditingUtils.setID(name, EcoreViewsRepository.EPackage.Properties.name); EditingUtils.setEEFtype(name, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EPackage.Properties.name, EcoreViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createNameText // End of user code return parent; } protected Composite createNsURIText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, EcoreViewsRepository.EPackage.Properties.nsURI, EcoreMessages.EPackagePropertiesEditionPart_NsURILabel); nsURI = widgetFactory.createText(parent, ""); //$NON-NLS-1$ nsURI.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData nsURIData = new GridData(GridData.FILL_HORIZONTAL); nsURI.setLayoutData(nsURIData); nsURI.addFocusListener(new FocusAdapter() { /** * @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( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsURI, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, nsURI.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsURI, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, nsURI.getText())); } } /** * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ @Override public void focusGained(FocusEvent e) { if (propertiesEditionComponent != null) { propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); nsURI.addKeyListener(new KeyAdapter() { /** * @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(EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsURI, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, nsURI.getText())); } } }); EditingUtils.setID(nsURI, EcoreViewsRepository.EPackage.Properties.nsURI); EditingUtils.setEEFtype(nsURI, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EPackage.Properties.nsURI, EcoreViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createNsURIText // End of user code return parent; } protected Composite createNsPrefixText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, EcoreViewsRepository.EPackage.Properties.nsPrefix, EcoreMessages.EPackagePropertiesEditionPart_NsPrefixLabel); nsPrefix = widgetFactory.createText(parent, ""); //$NON-NLS-1$ nsPrefix.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData nsPrefixData = new GridData(GridData.FILL_HORIZONTAL); nsPrefix.setLayoutData(nsPrefixData); nsPrefix.addFocusListener(new FocusAdapter() { /** * @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( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsPrefix, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, nsPrefix.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsPrefix, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, nsPrefix.getText())); } } /** * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent) */ @Override public void focusGained(FocusEvent e) { if (propertiesEditionComponent != null) { propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( EPackagePropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); nsPrefix.addKeyListener(new KeyAdapter() { /** * @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(EPackagePropertiesEditionPartForm.this, EcoreViewsRepository.EPackage.Properties.nsPrefix, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, nsPrefix.getText())); } } }); EditingUtils.setID(nsPrefix, EcoreViewsRepository.EPackage.Properties.nsPrefix); EditingUtils.setEEFtype(nsPrefix, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(EcoreViewsRepository.EPackage.Properties.nsPrefix, EcoreViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createNsPrefixText // 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.EPackagePropertiesEditionPart#getName() * */ public String getName() { return name.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EPackagePropertiesEditionPart#setName(String newValue) * */ public void setName(String newValue) { if (newValue != null) { name.setText(newValue); } else { name.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EPackage.Properties.name); if (eefElementEditorReadOnlyState && name.isEnabled()) { name.setEnabled(false); name.setToolTipText(EcoreMessages.EPackage_ReadOnly); } else if (!eefElementEditorReadOnlyState && !name.isEnabled()) { name.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EPackagePropertiesEditionPart#getNsURI() * */ public String getNsURI() { return nsURI.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EPackagePropertiesEditionPart#setNsURI(String newValue) * */ public void setNsURI(String newValue) { if (newValue != null) { nsURI.setText(newValue); } else { nsURI.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EPackage.Properties.nsURI); if (eefElementEditorReadOnlyState && nsURI.isEnabled()) { nsURI.setEnabled(false); nsURI.setToolTipText(EcoreMessages.EPackage_ReadOnly); } else if (!eefElementEditorReadOnlyState && !nsURI.isEnabled()) { nsURI.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EPackagePropertiesEditionPart#getNsPrefix() * */ public String getNsPrefix() { return nsPrefix.getText(); } /** * {@inheritDoc} * * @see org.eclipse.emf.ecoretools.design.properties.ecore.parts.EPackagePropertiesEditionPart#setNsPrefix(String newValue) * */ public void setNsPrefix(String newValue) { if (newValue != null) { nsPrefix.setText(newValue); } else { nsPrefix.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(EcoreViewsRepository.EPackage.Properties.nsPrefix); if (eefElementEditorReadOnlyState && nsPrefix.isEnabled()) { nsPrefix.setEnabled(false); nsPrefix.setToolTipText(EcoreMessages.EPackage_ReadOnly); } else if (!eefElementEditorReadOnlyState && !nsPrefix.isEnabled()) { nsPrefix.setEnabled(true); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle() * */ public String getTitle() { return EcoreMessages.EPackage_Part_Title; } // Start of user code additional methods // End of user code }