/** * Generated with Acceleo */ package net.certware.argument.gsn.parts.forms; // Start of user code for imports import java.util.ArrayList; import java.util.List; import net.certware.argument.gsn.parts.GsnViewsRepository; import net.certware.argument.gsn.parts.JustificationPropertiesEditionPart; import net.certware.argument.gsn.providers.GsnMessages; import org.eclipse.emf.ecore.EObject; 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.part.impl.SectionPropertiesEditingPart; 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.emf.eef.runtime.ui.widgets.ReferencesTable; import org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener; import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableContentProvider; import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings; import org.eclipse.jface.viewers.ViewerFilter; 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.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; 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; // End of user code /** * * */ public class JustificationPropertiesEditionPartForm extends SectionPropertiesEditingPart implements IFormPropertiesEditionPart, JustificationPropertiesEditionPart { protected Text identifier; protected Text description; protected Text content; protected ReferencesTable isTagged; protected List<ViewerFilter> isTaggedBusinessFilters = new ArrayList<ViewerFilter>(); protected List<ViewerFilter> isTaggedFilters = new ArrayList<ViewerFilter>(); /** * For {@link ISection} use only. */ public JustificationPropertiesEditionPartForm() { super(); } /** * Default constructor * @param editionComponent the {@link IPropertiesEditionComponent} that manage this part * */ public JustificationPropertiesEditionPartForm(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 justificationStep = new BindingCompositionSequence(propertiesEditionComponent); CompositionStep propertiesStep = justificationStep.addStep(GsnViewsRepository.Justification.Properties.class); propertiesStep.addStep(GsnViewsRepository.Justification.Properties.identifier); propertiesStep.addStep(GsnViewsRepository.Justification.Properties.description); propertiesStep.addStep(GsnViewsRepository.Justification.Properties.content); propertiesStep.addStep(GsnViewsRepository.Justification.Properties.isTagged); composer = new PartComposer(justificationStep) { @Override public Composite addToPart(Composite parent, Object key) { if (key == GsnViewsRepository.Justification.Properties.class) { return createPropertiesGroup(widgetFactory, parent); } if (key == GsnViewsRepository.Justification.Properties.identifier) { return createIdentifierText(widgetFactory, parent); } if (key == GsnViewsRepository.Justification.Properties.description) { return createDescriptionText(widgetFactory, parent); } if (key == GsnViewsRepository.Justification.Properties.content) { return createContentText(widgetFactory, parent); } if (key == GsnViewsRepository.Justification.Properties.isTagged) { return createIsTaggedTableComposition(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(GsnMessages.JustificationPropertiesEditionPart_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 createIdentifierText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, GsnViewsRepository.Justification.Properties.identifier, GsnMessages.JustificationPropertiesEditionPart_IdentifierLabel); identifier = widgetFactory.createText(parent, ""); //$NON-NLS-1$ identifier.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData identifierData = new GridData(GridData.FILL_HORIZONTAL); identifier.setLayoutData(identifierData); identifier.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( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.identifier, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, identifier.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.identifier, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, identifier.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( JustificationPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); identifier.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(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.identifier, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, identifier.getText())); } } }); EditingUtils.setID(identifier, GsnViewsRepository.Justification.Properties.identifier); EditingUtils.setEEFtype(identifier, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(GsnViewsRepository.Justification.Properties.identifier, GsnViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createIdentifierText // End of user code return parent; } protected Composite createDescriptionText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, GsnViewsRepository.Justification.Properties.description, GsnMessages.JustificationPropertiesEditionPart_DescriptionLabel); description = widgetFactory.createText(parent, ""); //$NON-NLS-1$ description.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData descriptionData = new GridData(GridData.FILL_HORIZONTAL); description.setLayoutData(descriptionData); description.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( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.description, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.description, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, description.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( JustificationPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); description.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(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.description, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText())); } } }); EditingUtils.setID(description, GsnViewsRepository.Justification.Properties.description); EditingUtils.setEEFtype(description, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(GsnViewsRepository.Justification.Properties.description, GsnViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createDescriptionText // End of user code return parent; } protected Composite createContentText(FormToolkit widgetFactory, Composite parent) { createDescription(parent, GsnViewsRepository.Justification.Properties.content, GsnMessages.JustificationPropertiesEditionPart_ContentLabel); content = widgetFactory.createText(parent, ""); //$NON-NLS-1$ content.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); widgetFactory.paintBordersFor(parent); GridData contentData = new GridData(GridData.FILL_HORIZONTAL); content.setLayoutData(contentData); content.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( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.content, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, content.getText())); propertiesEditionComponent .firePropertiesChanged(new PropertiesEditionEvent( JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.content, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST, null, content.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( JustificationPropertiesEditionPartForm.this, null, PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED, null, null)); } } }); content.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(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.content, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, content.getText())); } } }); EditingUtils.setID(content, GsnViewsRepository.Justification.Properties.content); EditingUtils.setEEFtype(content, "eef::Text"); //$NON-NLS-1$ FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(GsnViewsRepository.Justification.Properties.content, GsnViewsRepository.FORM_KIND), null); //$NON-NLS-1$ // Start of user code for createContentText // End of user code return parent; } /** * @param container * */ protected Composite createIsTaggedTableComposition(FormToolkit widgetFactory, Composite parent) { this.isTagged = new ReferencesTable(getDescription(GsnViewsRepository.Justification.Properties.isTagged, GsnMessages.JustificationPropertiesEditionPart_IsTaggedLabel), new ReferencesTableListener() { public void handleAdd() { propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.isTagged, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null)); isTagged.refresh(); } public void handleEdit(EObject element) { propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.isTagged, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element)); isTagged.refresh(); } public void handleMove(EObject element, int oldIndex, int newIndex) { propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.isTagged, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex)); isTagged.refresh(); } public void handleRemove(EObject element) { propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.isTagged, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element)); isTagged.refresh(); } public void navigateTo(EObject element) { } }); for (ViewerFilter filter : this.isTaggedFilters) { this.isTagged.addFilter(filter); } this.isTagged.setHelpText(propertiesEditionComponent.getHelpContent(GsnViewsRepository.Justification.Properties.isTagged, GsnViewsRepository.FORM_KIND)); this.isTagged.createControls(parent, widgetFactory); this.isTagged.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (e.item != null && e.item.getData() instanceof EObject) { propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(JustificationPropertiesEditionPartForm.this, GsnViewsRepository.Justification.Properties.isTagged, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData())); } } }); GridData isTaggedData = new GridData(GridData.FILL_HORIZONTAL); isTaggedData.horizontalSpan = 3; this.isTagged.setLayoutData(isTaggedData); this.isTagged.setLowerBound(0); this.isTagged.setUpperBound(-1); isTagged.setID(GsnViewsRepository.Justification.Properties.isTagged); isTagged.setEEFType("eef::AdvancedTableComposition"); //$NON-NLS-1$ // Start of user code for createIsTaggedTableComposition // 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 net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#getIdentifier() * */ public String getIdentifier() { return identifier.getText(); } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#setIdentifier(String newValue) * */ public void setIdentifier(String newValue) { if (newValue != null) { identifier.setText(newValue); } else { identifier.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(GsnViewsRepository.Justification.Properties.identifier); if (eefElementEditorReadOnlyState && identifier.isEnabled()) { identifier.setEnabled(false); identifier.setToolTipText(GsnMessages.Justification_ReadOnly); } else if (!eefElementEditorReadOnlyState && !identifier.isEnabled()) { identifier.setEnabled(true); } } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#getDescription() * */ public String getDescription() { return description.getText(); } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#setDescription(String newValue) * */ public void setDescription(String newValue) { if (newValue != null) { description.setText(newValue); } else { description.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(GsnViewsRepository.Justification.Properties.description); if (eefElementEditorReadOnlyState && description.isEnabled()) { description.setEnabled(false); description.setToolTipText(GsnMessages.Justification_ReadOnly); } else if (!eefElementEditorReadOnlyState && !description.isEnabled()) { description.setEnabled(true); } } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#getContent() * */ public String getContent() { return content.getText(); } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#setContent(String newValue) * */ public void setContent(String newValue) { if (newValue != null) { content.setText(newValue); } else { content.setText(""); //$NON-NLS-1$ } boolean eefElementEditorReadOnlyState = isReadOnly(GsnViewsRepository.Justification.Properties.content); if (eefElementEditorReadOnlyState && content.isEnabled()) { content.setEnabled(false); content.setToolTipText(GsnMessages.Justification_ReadOnly); } else if (!eefElementEditorReadOnlyState && !content.isEnabled()) { content.setEnabled(true); } } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#initIsTagged(EObject current, EReference containingFeature, EReference feature) */ public void initIsTagged(ReferencesTableSettings settings) { if (current.eResource() != null && current.eResource().getResourceSet() != null) this.resourceSet = current.eResource().getResourceSet(); ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider(); isTagged.setContentProvider(contentProvider); isTagged.setInput(settings); boolean eefElementEditorReadOnlyState = isReadOnly(GsnViewsRepository.Justification.Properties.isTagged); if (eefElementEditorReadOnlyState && isTagged.isEnabled()) { isTagged.setEnabled(false); isTagged.setToolTipText(GsnMessages.Justification_ReadOnly); } else if (!eefElementEditorReadOnlyState && !isTagged.isEnabled()) { isTagged.setEnabled(true); } } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#updateIsTagged() * */ public void updateIsTagged() { isTagged.refresh(); } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#addFilterIsTagged(ViewerFilter filter) * */ public void addFilterToIsTagged(ViewerFilter filter) { isTaggedFilters.add(filter); if (this.isTagged != null) { this.isTagged.addFilter(filter); } } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#addBusinessFilterIsTagged(ViewerFilter filter) * */ public void addBusinessFilterToIsTagged(ViewerFilter filter) { isTaggedBusinessFilters.add(filter); } /** * {@inheritDoc} * * @see net.certware.argument.gsn.parts.JustificationPropertiesEditionPart#isContainedInIsTaggedTable(EObject element) * */ public boolean isContainedInIsTaggedTable(EObject element) { return ((ReferencesTableSettings)isTagged.getInput()).contains(element); } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle() * */ public String getTitle() { return GsnMessages.Justification_Part_Title; } // Start of user code additional methods // End of user code }