blob: ac23d39f1b6e6c0ef05149133339b0c2a4540482 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 Fundación Tecnalia Research & Innovation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Huascar Espinoza - initial API and implementation
* Alejandra Ruíz - initial API and implementation
* Idoya Del Río - initial API and implementation
* Mari Carmen Palacios - initial API and implementation
* Angel López - initial API and implementation
*******************************************************************************/
/**
* Generated with Acceleo
*/
package org.eclipse.opencert.sam.arg.arg.parts.forms;
// Start of user code for imports
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.eef.runtime.EEFRuntimePlugin;
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.context.impl.EObjectPropertiesEditionContext;
import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent;
import org.eclipse.emf.eef.runtime.part.impl.SectionPropertiesEditingPart;
import org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy;
import org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider;
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.EMFComboViewer;
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.TabElementTreeSelectionDialog;
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.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
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;
import org.eclipse.opencert.sam.arg.arg.parts.ArgViewsRepository;
import org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart;
import org.eclipse.opencert.sam.arg.arg.providers.ArgMessages;
// End of user code
/**
*
*
*/
public class AssertedEvidencePropertiesEditionPartForm extends SectionPropertiesEditingPart implements IFormPropertiesEditionPart, AssertedEvidencePropertiesEditionPart {
protected Text id;
protected Text name;
protected Text description;
protected Text content;
protected EMFComboViewer multiextension;
protected Text cardinality;
protected ReferencesTable source;
protected List<ViewerFilter> sourceBusinessFilters = new ArrayList<ViewerFilter>();
protected List<ViewerFilter> sourceFilters = new ArrayList<ViewerFilter>();
protected ReferencesTable target;
protected List<ViewerFilter> targetBusinessFilters = new ArrayList<ViewerFilter>();
protected List<ViewerFilter> targetFilters = new ArrayList<ViewerFilter>();
/**
* For {@link ISection} use only.
*/
public AssertedEvidencePropertiesEditionPartForm() { super(); }
/**
* Default constructor
* @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
*
*/
public AssertedEvidencePropertiesEditionPartForm(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 assertedEvidenceStep = new BindingCompositionSequence(propertiesEditionComponent);
CompositionStep propertiesStep = assertedEvidenceStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.class);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.id);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.name);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.description);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.content);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.multiextension);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.cardinality);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.source);
propertiesStep.addStep(ArgViewsRepository.AssertedEvidence.Properties.target);
composer = new PartComposer(assertedEvidenceStep) {
@Override
public Composite addToPart(Composite parent, Object key) {
if (key == ArgViewsRepository.AssertedEvidence.Properties.class) {
return createPropertiesGroup(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.id) {
return createIdText(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.name) {
return createNameText(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.description) {
return createDescriptionText(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.content) {
return createContentText(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.multiextension) {
return createMultiextensionEMFComboViewer(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.cardinality) {
return createCardinalityText(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.source) {
return createSourceReferencesTable(widgetFactory, parent);
}
if (key == ArgViewsRepository.AssertedEvidence.Properties.target) {
return createTargetReferencesTable(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(ArgMessages.AssertedEvidencePropertiesEditionPart_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 createIdText(FormToolkit widgetFactory, Composite parent) {
createDescription(parent, ArgViewsRepository.AssertedEvidence.Properties.id, ArgMessages.AssertedEvidencePropertiesEditionPart_IdLabel);
id = widgetFactory.createText(parent, ""); //$NON-NLS-1$
id.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
widgetFactory.paintBordersFor(parent);
GridData idData = new GridData(GridData.FILL_HORIZONTAL);
id.setLayoutData(idData);
id.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(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.id,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, id.getText()));
propertiesEditionComponent
.firePropertiesChanged(new PropertiesEditionEvent(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.id,
PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST,
null, id.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(
AssertedEvidencePropertiesEditionPartForm.this,
null,
PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED,
null, null));
}
}
});
id.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(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.id, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, id.getText()));
}
}
});
EditingUtils.setID(id, ArgViewsRepository.AssertedEvidence.Properties.id);
EditingUtils.setEEFtype(id, "eef::Text"); //$NON-NLS-1$
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.id, ArgViewsRepository.FORM_KIND), null); //$NON-NLS-1$
// Start of user code for createIdText
// End of user code
return parent;
}
protected Composite createNameText(FormToolkit widgetFactory, Composite parent) {
createDescription(parent, ArgViewsRepository.AssertedEvidence.Properties.name, ArgMessages.AssertedEvidencePropertiesEditionPart_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(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.name,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
propertiesEditionComponent
.firePropertiesChanged(new PropertiesEditionEvent(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.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(
AssertedEvidencePropertiesEditionPartForm.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(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.name, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, name.getText()));
}
}
});
EditingUtils.setID(name, ArgViewsRepository.AssertedEvidence.Properties.name);
EditingUtils.setEEFtype(name, "eef::Text"); //$NON-NLS-1$
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.name, ArgViewsRepository.FORM_KIND), null); //$NON-NLS-1$
// Start of user code for createNameText
// End of user code
return parent;
}
protected Composite createDescriptionText(FormToolkit widgetFactory, Composite parent) {
createDescription(parent, ArgViewsRepository.AssertedEvidence.Properties.description, ArgMessages.AssertedEvidencePropertiesEditionPart_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(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.description,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText()));
propertiesEditionComponent
.firePropertiesChanged(new PropertiesEditionEvent(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.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(
AssertedEvidencePropertiesEditionPartForm.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(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.description, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, description.getText()));
}
}
});
EditingUtils.setID(description, ArgViewsRepository.AssertedEvidence.Properties.description);
EditingUtils.setEEFtype(description, "eef::Text"); //$NON-NLS-1$
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.description, ArgViewsRepository.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, ArgViewsRepository.AssertedEvidence.Properties.content, ArgMessages.AssertedEvidencePropertiesEditionPart_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(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.content,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, content.getText()));
propertiesEditionComponent
.firePropertiesChanged(new PropertiesEditionEvent(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.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(
AssertedEvidencePropertiesEditionPartForm.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(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.content, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, content.getText()));
}
}
});
EditingUtils.setID(content, ArgViewsRepository.AssertedEvidence.Properties.content);
EditingUtils.setEEFtype(content, "eef::Text"); //$NON-NLS-1$
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.content, ArgViewsRepository.FORM_KIND), null); //$NON-NLS-1$
// Start of user code for createContentText
// End of user code
return parent;
}
protected Composite createMultiextensionEMFComboViewer(FormToolkit widgetFactory, Composite parent) {
createDescription(parent, ArgViewsRepository.AssertedEvidence.Properties.multiextension, ArgMessages.AssertedEvidencePropertiesEditionPart_MultiextensionLabel);
multiextension = new EMFComboViewer(parent);
multiextension.setContentProvider(new ArrayContentProvider());
multiextension.setLabelProvider(new AdapterFactoryLabelProvider(EEFRuntimePlugin.getDefault().getAdapterFactory()));
GridData multiextensionData = new GridData(GridData.FILL_HORIZONTAL);
multiextension.getCombo().setLayoutData(multiextensionData);
multiextension.addSelectionChangedListener(new ISelectionChangedListener() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*
*/
public void selectionChanged(SelectionChangedEvent event) {
if (propertiesEditionComponent != null)
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.multiextension, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, getMultiextension()));
}
});
multiextension.setID(ArgViewsRepository.AssertedEvidence.Properties.multiextension);
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.multiextension, ArgViewsRepository.FORM_KIND), null); //$NON-NLS-1$
// Start of user code for createMultiextensionEMFComboViewer
// End of user code
return parent;
}
protected Composite createCardinalityText(FormToolkit widgetFactory, Composite parent) {
createDescription(parent, ArgViewsRepository.AssertedEvidence.Properties.cardinality, ArgMessages.AssertedEvidencePropertiesEditionPart_CardinalityLabel);
cardinality = widgetFactory.createText(parent, ""); //$NON-NLS-1$
cardinality.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
widgetFactory.paintBordersFor(parent);
GridData cardinalityData = new GridData(GridData.FILL_HORIZONTAL);
cardinality.setLayoutData(cardinalityData);
cardinality.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(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.cardinality,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, cardinality.getText()));
propertiesEditionComponent
.firePropertiesChanged(new PropertiesEditionEvent(
AssertedEvidencePropertiesEditionPartForm.this,
ArgViewsRepository.AssertedEvidence.Properties.cardinality,
PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_LOST,
null, cardinality.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(
AssertedEvidencePropertiesEditionPartForm.this,
null,
PropertiesEditionEvent.FOCUS_CHANGED, PropertiesEditionEvent.FOCUS_GAINED,
null, null));
}
}
});
cardinality.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(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.cardinality, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, cardinality.getText()));
}
}
});
EditingUtils.setID(cardinality, ArgViewsRepository.AssertedEvidence.Properties.cardinality);
EditingUtils.setEEFtype(cardinality, "eef::Text"); //$NON-NLS-1$
FormUtils.createHelpButton(widgetFactory, parent, propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.cardinality, ArgViewsRepository.FORM_KIND), null); //$NON-NLS-1$
// Start of user code for createCardinalityText
// End of user code
return parent;
}
/**
*
*/
protected Composite createSourceReferencesTable(FormToolkit widgetFactory, Composite parent) {
this.source = new ReferencesTable(getDescription(ArgViewsRepository.AssertedEvidence.Properties.source, ArgMessages.AssertedEvidencePropertiesEditionPart_SourceLabel), new ReferencesTableListener () {
public void handleAdd() { addSource(); }
public void handleEdit(EObject element) { editSource(element); }
public void handleMove(EObject element, int oldIndex, int newIndex) { moveSource(element, oldIndex, newIndex); }
public void handleRemove(EObject element) { removeFromSource(element); }
public void navigateTo(EObject element) { }
});
this.source.setHelpText(propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.source, ArgViewsRepository.FORM_KIND));
this.source.createControls(parent, widgetFactory);
this.source.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.item != null && e.item.getData() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.source, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
}
}
});
GridData sourceData = new GridData(GridData.FILL_HORIZONTAL);
sourceData.horizontalSpan = 3;
this.source.setLayoutData(sourceData);
this.source.disableMove();
source.setID(ArgViewsRepository.AssertedEvidence.Properties.source);
source.setEEFType("eef::AdvancedReferencesTable"); //$NON-NLS-1$
// Start of user code for createSourceReferencesTable
// End of user code
return parent;
}
/**
*
*/
protected void addSource() {
TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(source.getInput(), sourceFilters, sourceBusinessFilters,
"source", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
@Override
public void process(IStructuredSelection selection) {
for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.source,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
source.refresh();
}
};
dialog.open();
}
/**
*
*/
protected void moveSource(EObject element, int oldIndex, int newIndex) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.source, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
source.refresh();
}
/**
*
*/
protected void removeFromSource(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.source, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
source.refresh();
}
/**
*
*/
protected void editSource(EObject element) {
EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(propertiesEditionComponent.getEditingContext(), propertiesEditionComponent, element, adapterFactory);
PropertiesEditingProvider provider = (PropertiesEditingProvider)adapterFactory.adapt(element, PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy policy = provider.getPolicy(context);
if (policy != null) {
policy.execute();
source.refresh();
}
}
}
/**
*
*/
protected Composite createTargetReferencesTable(FormToolkit widgetFactory, Composite parent) {
this.target = new ReferencesTable(getDescription(ArgViewsRepository.AssertedEvidence.Properties.target, ArgMessages.AssertedEvidencePropertiesEditionPart_TargetLabel), new ReferencesTableListener () {
public void handleAdd() { addTarget(); }
public void handleEdit(EObject element) { editTarget(element); }
public void handleMove(EObject element, int oldIndex, int newIndex) { moveTarget(element, oldIndex, newIndex); }
public void handleRemove(EObject element) { removeFromTarget(element); }
public void navigateTo(EObject element) { }
});
this.target.setHelpText(propertiesEditionComponent.getHelpContent(ArgViewsRepository.AssertedEvidence.Properties.target, ArgViewsRepository.FORM_KIND));
this.target.createControls(parent, widgetFactory);
this.target.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.item != null && e.item.getData() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.target, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
}
}
});
GridData targetData = new GridData(GridData.FILL_HORIZONTAL);
targetData.horizontalSpan = 3;
this.target.setLayoutData(targetData);
this.target.disableMove();
target.setID(ArgViewsRepository.AssertedEvidence.Properties.target);
target.setEEFType("eef::AdvancedReferencesTable"); //$NON-NLS-1$
// Start of user code for createTargetReferencesTable
// End of user code
return parent;
}
/**
*
*/
protected void addTarget() {
TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(target.getInput(), targetFilters, targetBusinessFilters,
"target", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
@Override
public void process(IStructuredSelection selection) {
for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.target,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
target.refresh();
}
};
dialog.open();
}
/**
*
*/
protected void moveTarget(EObject element, int oldIndex, int newIndex) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.target, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
target.refresh();
}
/**
*
*/
protected void removeFromTarget(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AssertedEvidencePropertiesEditionPartForm.this, ArgViewsRepository.AssertedEvidence.Properties.target, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
target.refresh();
}
/**
*
*/
protected void editTarget(EObject element) {
EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(propertiesEditionComponent.getEditingContext(), propertiesEditionComponent, element, adapterFactory);
PropertiesEditingProvider provider = (PropertiesEditingProvider)adapterFactory.adapt(element, PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy policy = provider.getPolicy(context);
if (policy != null) {
policy.execute();
target.refresh();
}
}
}
/**
* {@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.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getId()
*
*/
public String getId() {
return id.getText();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setId(String newValue)
*
*/
public void setId(String newValue) {
if (newValue != null) {
id.setText(newValue);
} else {
id.setText(""); //$NON-NLS-1$
}
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.id);
if (eefElementEditorReadOnlyState && id.isEnabled()) {
id.setEnabled(false);
id.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !id.isEnabled()) {
id.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getName()
*
*/
public String getName() {
return name.getText();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setName(String newValue)
*
*/
public void setName(String newValue) {
if (newValue != null) {
name.setText(newValue);
} else {
name.setText(""); //$NON-NLS-1$
}
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.name);
if (eefElementEditorReadOnlyState && name.isEnabled()) {
name.setEnabled(false);
name.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !name.isEnabled()) {
name.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getDescription()
*
*/
public String getDescription() {
return description.getText();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setDescription(String newValue)
*
*/
public void setDescription(String newValue) {
if (newValue != null) {
description.setText(newValue);
} else {
description.setText(""); //$NON-NLS-1$
}
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.description);
if (eefElementEditorReadOnlyState && description.isEnabled()) {
description.setEnabled(false);
description.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !description.isEnabled()) {
description.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getContent()
*
*/
public String getContent() {
return content.getText();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setContent(String newValue)
*
*/
public void setContent(String newValue) {
if (newValue != null) {
content.setText(newValue);
} else {
content.setText(""); //$NON-NLS-1$
}
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.content);
if (eefElementEditorReadOnlyState && content.isEnabled()) {
content.setEnabled(false);
content.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !content.isEnabled()) {
content.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getMultiextension()
*
*/
public Enumerator getMultiextension() {
Enumerator selection = (Enumerator) ((StructuredSelection) multiextension.getSelection()).getFirstElement();
return selection;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#initMultiextension(Object input, Enumerator current)
*/
public void initMultiextension(Object input, Enumerator current) {
multiextension.setInput(input);
multiextension.modelUpdating(new StructuredSelection(current));
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.multiextension);
if (eefElementEditorReadOnlyState && multiextension.isEnabled()) {
multiextension.setEnabled(false);
multiextension.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !multiextension.isEnabled()) {
multiextension.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setMultiextension(Enumerator newValue)
*
*/
public void setMultiextension(Enumerator newValue) {
multiextension.modelUpdating(new StructuredSelection(newValue));
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.multiextension);
if (eefElementEditorReadOnlyState && multiextension.isEnabled()) {
multiextension.setEnabled(false);
multiextension.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !multiextension.isEnabled()) {
multiextension.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#getCardinality()
*
*/
public String getCardinality() {
return cardinality.getText();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#setCardinality(String newValue)
*
*/
public void setCardinality(String newValue) {
if (newValue != null) {
cardinality.setText(newValue);
} else {
cardinality.setText(""); //$NON-NLS-1$
}
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.cardinality);
if (eefElementEditorReadOnlyState && cardinality.isEnabled()) {
cardinality.setEnabled(false);
cardinality.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !cardinality.isEnabled()) {
cardinality.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#initSource(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)
*/
public void initSource(ReferencesTableSettings settings) {
if (current.eResource() != null && current.eResource().getResourceSet() != null)
this.resourceSet = current.eResource().getResourceSet();
ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
source.setContentProvider(contentProvider);
source.setInput(settings);
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.source);
if (eefElementEditorReadOnlyState && source.getTable().isEnabled()) {
source.setEnabled(false);
source.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !source.getTable().isEnabled()) {
source.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#updateSource()
*
*/
public void updateSource() {
source.refresh();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#addFilterSource(ViewerFilter filter)
*
*/
public void addFilterToSource(ViewerFilter filter) {
sourceFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#addBusinessFilterSource(ViewerFilter filter)
*
*/
public void addBusinessFilterToSource(ViewerFilter filter) {
sourceBusinessFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#isContainedInSourceTable(EObject element)
*
*/
public boolean isContainedInSourceTable(EObject element) {
return ((ReferencesTableSettings)source.getInput()).contains(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#initTarget(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)
*/
public void initTarget(ReferencesTableSettings settings) {
if (current.eResource() != null && current.eResource().getResourceSet() != null)
this.resourceSet = current.eResource().getResourceSet();
ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
target.setContentProvider(contentProvider);
target.setInput(settings);
boolean eefElementEditorReadOnlyState = isReadOnly(ArgViewsRepository.AssertedEvidence.Properties.target);
if (eefElementEditorReadOnlyState && target.getTable().isEnabled()) {
target.setEnabled(false);
target.setToolTipText(ArgMessages.AssertedEvidence_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !target.getTable().isEnabled()) {
target.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#updateTarget()
*
*/
public void updateTarget() {
target.refresh();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#addFilterTarget(ViewerFilter filter)
*
*/
public void addFilterToTarget(ViewerFilter filter) {
targetFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#addBusinessFilterTarget(ViewerFilter filter)
*
*/
public void addBusinessFilterToTarget(ViewerFilter filter) {
targetBusinessFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.opencert.sam.arg.arg.parts.AssertedEvidencePropertiesEditionPart#isContainedInTargetTable(EObject element)
*
*/
public boolean isContainedInTargetTable(EObject element) {
return ((ReferencesTableSettings)target.getInput()).contains(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
*
*/
public String getTitle() {
return ArgMessages.AssertedEvidence_Part_Title;
}
// Start of user code additional methods
// End of user code
}