blob: 214be93cc50b40bedfe7306c67985d4903bc6fa3 [file] [log] [blame]
/*******************************************************************************
* 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 java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.emf.eef.eefnr.parts.EefnrViewsRepository;
import org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart;
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.EMFModelViewerDialog;
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.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TableColumn;
// End of user code
/**
* @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
*
*/
public class ReferencesTableSamplePropertiesEditionPartImpl extends CompositePropertiesEditionPart implements ISWTPropertiesEditionPart, ReferencesTableSamplePropertiesEditionPart {
protected TableViewer referencestableRequiredProperty;
protected Button addReferencestableRequiredProperty;
protected Button removeReferencestableRequiredProperty;
protected List<ViewerFilter> referencestableRequiredPropertyBusinessFilters = new ArrayList<ViewerFilter>();
protected List<ViewerFilter> referencestableRequiredPropertyFilters = new ArrayList<ViewerFilter>();
protected TableViewer referencestableOptionalProperty;
protected Button addReferencestableOptionalProperty;
protected Button removeReferencestableOptionalProperty;
protected List<ViewerFilter> referencestableOptionalPropertyBusinessFilters = new ArrayList<ViewerFilter>();
protected List<ViewerFilter> referencestableOptionalPropertyFilters = new ArrayList<ViewerFilter>();
protected TableViewer referencestableROProperty;
protected Button addReferencestableROProperty;
protected Button removeReferencestableROProperty;
protected List<ViewerFilter> referencestableROPropertyBusinessFilters = new ArrayList<ViewerFilter>();
protected List<ViewerFilter> referencestableROPropertyFilters = new ArrayList<ViewerFilter>();
/**
* Default constructor
* @param editionComponent the {@link IPropertiesEditionComponent} that manage this part
*
*/
public ReferencesTableSamplePropertiesEditionPartImpl(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 referencesTableSampleStep = new BindingCompositionSequence(propertiesEditionComponent);
CompositionStep propertiesStep = referencesTableSampleStep.addStep(EefnrViewsRepository.ReferencesTableSample.Properties.class);
propertiesStep.addStep(EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty);
propertiesStep.addStep(EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty);
propertiesStep.addStep(EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty);
composer = new PartComposer(referencesTableSampleStep) {
@Override
public Composite addToPart(Composite parent, Object key) {
if (key == EefnrViewsRepository.ReferencesTableSample.Properties.class) {
return createPropertiesGroup(parent);
}
if (key == EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty) {
return createReferencestableRequiredPropertyReferencesTable(parent);
}
if (key == EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty) {
return createReferencestableOptionalPropertyReferencesTable(parent);
}
if (key == EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty) {
return createReferencestableROPropertyReferencesTable(parent);
}
return parent;
}
};
composer.compose(view);
}
/**
*
*/
protected Composite createPropertiesGroup(Composite parent) {
Group propertiesGroup = new Group(parent, SWT.NONE);
propertiesGroup.setText(EefnrMessages.ReferencesTableSamplePropertiesEditionPart_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;
}
/**
* @param parent
*
*/
protected Composite createReferencestableRequiredPropertyReferencesTable(Composite parent) {
Label referencestableRequiredPropertyLabel = createDescription(parent, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty, EefnrMessages.ReferencesTableSamplePropertiesEditionPart_ReferencestableRequiredPropertyLabel);
GridData referencestableRequiredPropertyLabelData = new GridData();
referencestableRequiredPropertyLabelData.horizontalSpan = 3;
referencestableRequiredPropertyLabel.setLayoutData(referencestableRequiredPropertyLabelData);
referencestableRequiredProperty = createReferencestableRequiredPropertyViewer(parent, adapterFactory);
GridData referencestableRequiredPropertyData = new GridData(GridData.FILL_HORIZONTAL);
referencestableRequiredPropertyData.horizontalSpan = 2;
referencestableRequiredPropertyData.minimumHeight = 120;
referencestableRequiredPropertyData.heightHint = 120;
referencestableRequiredProperty.getTable().setLayoutData(referencestableRequiredPropertyData);
EditingUtils.setID(referencestableRequiredProperty.getTable(), EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty);
EditingUtils.setEEFtype(referencestableRequiredProperty.getTable(), "eef::ReferencesTable::field"); //$NON-NLS-1$
createReferencestableRequiredPropertyControlPanel(parent);
return parent;
}
/**
*
*/
protected TableViewer createReferencestableRequiredPropertyViewer(Composite container, AdapterFactory adapter) {
org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(container, SWT.FULL_SELECTION);
table.setHeaderVisible(true);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = GridData.FILL;
table.setLayoutData(gd);
table.setLinesVisible(true);
// Start of user code for table referencestableRequiredProperty s columns definition
TableColumn name = new TableColumn(table, SWT.NONE);
name.setWidth(80);
name.setText("Label"); //$NON-NLS-1$
// End of user code
TableViewer result = new TableViewer(table);
result.setLabelProvider(new ITableLabelProvider() {
// Start of user code for table referencestableRequiredProperty label provider
public String getColumnText(Object object, int columnIndex) {
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
if (object instanceof EObject) {
switch (columnIndex) {
case 0:
return labelProvider.getText(object);
}
}
return ""; //$NON-NLS-1$
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
// End of user code
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
return result;
}
/**
*
*/
protected void createReferencestableRequiredPropertyControlPanel(Composite container) {
Composite result = new Composite(container, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
result.setLayout(layout);
addReferencestableRequiredProperty = new Button(result, SWT.NONE);
addReferencestableRequiredProperty.setText(EefnrMessages.PropertiesEditionPart_AddListViewerLabel);
GridData addData = new GridData(GridData.FILL_HORIZONTAL);
addReferencestableRequiredProperty.setLayoutData(addData);
addReferencestableRequiredProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
addReferencestableRequiredProperty();
}
});
EditingUtils.setID(addReferencestableRequiredProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty);
EditingUtils.setEEFtype(addReferencestableRequiredProperty, "eef::ReferencesTable::addbutton"); //$NON-NLS-1$
removeReferencestableRequiredProperty = new Button(result, SWT.NONE);
removeReferencestableRequiredProperty.setText(EefnrMessages.PropertiesEditionPart_RemoveListViewerLabel);
GridData removeData = new GridData(GridData.FILL_HORIZONTAL);
removeReferencestableRequiredProperty.setLayoutData(removeData);
removeReferencestableRequiredProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
if (referencestableRequiredProperty.getSelection() instanceof IStructuredSelection) {
removeReferencestableRequiredProperty((IStructuredSelection) referencestableRequiredProperty.getSelection());
}
}
});
EditingUtils.setID(removeReferencestableRequiredProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty);
EditingUtils.setEEFtype(removeReferencestableRequiredProperty, "eef::ReferencesTable::removebutton"); //$NON-NLS-1$
}
/**
*
*/
protected void addReferencestableRequiredProperty() {
EMFModelViewerDialog dialog = new EMFModelViewerDialog(new AdapterFactoryLabelProvider(adapterFactory), referencestableRequiredProperty.getInput(), referencestableRequiredPropertyFilters, referencestableRequiredPropertyBusinessFilters, false, true) {
public void process(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
}
};
dialog.open();
// Start of user code for addReferencestableRequiredProperty
// End of user code
referencestableRequiredProperty.refresh();
}
/**
* @param selection the referencestableRequiredProperty to remove
*
*/
protected void removeReferencestableRequiredProperty(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, elem));
}
referencestableRequiredProperty.refresh();
}
/**
* @param parent
*
*/
protected Composite createReferencestableOptionalPropertyReferencesTable(Composite parent) {
Label referencestableOptionalPropertyLabel = createDescription(parent, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty, EefnrMessages.ReferencesTableSamplePropertiesEditionPart_ReferencestableOptionalPropertyLabel);
GridData referencestableOptionalPropertyLabelData = new GridData();
referencestableOptionalPropertyLabelData.horizontalSpan = 3;
referencestableOptionalPropertyLabel.setLayoutData(referencestableOptionalPropertyLabelData);
referencestableOptionalProperty = createReferencestableOptionalPropertyViewer(parent, adapterFactory);
GridData referencestableOptionalPropertyData = new GridData(GridData.FILL_HORIZONTAL);
referencestableOptionalPropertyData.horizontalSpan = 2;
referencestableOptionalPropertyData.minimumHeight = 120;
referencestableOptionalPropertyData.heightHint = 120;
referencestableOptionalProperty.getTable().setLayoutData(referencestableOptionalPropertyData);
EditingUtils.setID(referencestableOptionalProperty.getTable(), EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty);
EditingUtils.setEEFtype(referencestableOptionalProperty.getTable(), "eef::ReferencesTable::field"); //$NON-NLS-1$
createReferencestableOptionalPropertyControlPanel(parent);
return parent;
}
/**
*
*/
protected TableViewer createReferencestableOptionalPropertyViewer(Composite container, AdapterFactory adapter) {
org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(container, SWT.FULL_SELECTION);
table.setHeaderVisible(true);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = GridData.FILL;
table.setLayoutData(gd);
table.setLinesVisible(true);
// Start of user code for table referencestableOptionalProperty s columns definition
TableColumn name = new TableColumn(table, SWT.NONE);
name.setWidth(80);
name.setText("Label"); //$NON-NLS-1$
// End of user code
TableViewer result = new TableViewer(table);
result.setLabelProvider(new ITableLabelProvider() {
// Start of user code for table referencestableOptionalProperty label provider
public String getColumnText(Object object, int columnIndex) {
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
if (object instanceof EObject) {
switch (columnIndex) {
case 0:
return labelProvider.getText(object);
}
}
return ""; //$NON-NLS-1$
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
// End of user code
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
return result;
}
/**
*
*/
protected void createReferencestableOptionalPropertyControlPanel(Composite container) {
Composite result = new Composite(container, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
result.setLayout(layout);
addReferencestableOptionalProperty = new Button(result, SWT.NONE);
addReferencestableOptionalProperty.setText(EefnrMessages.PropertiesEditionPart_AddListViewerLabel);
GridData addData = new GridData(GridData.FILL_HORIZONTAL);
addReferencestableOptionalProperty.setLayoutData(addData);
addReferencestableOptionalProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
addReferencestableOptionalProperty();
}
});
EditingUtils.setID(addReferencestableOptionalProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty);
EditingUtils.setEEFtype(addReferencestableOptionalProperty, "eef::ReferencesTable::addbutton"); //$NON-NLS-1$
removeReferencestableOptionalProperty = new Button(result, SWT.NONE);
removeReferencestableOptionalProperty.setText(EefnrMessages.PropertiesEditionPart_RemoveListViewerLabel);
GridData removeData = new GridData(GridData.FILL_HORIZONTAL);
removeReferencestableOptionalProperty.setLayoutData(removeData);
removeReferencestableOptionalProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
if (referencestableOptionalProperty.getSelection() instanceof IStructuredSelection) {
removeReferencestableOptionalProperty((IStructuredSelection) referencestableOptionalProperty.getSelection());
}
}
});
EditingUtils.setID(removeReferencestableOptionalProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty);
EditingUtils.setEEFtype(removeReferencestableOptionalProperty, "eef::ReferencesTable::removebutton"); //$NON-NLS-1$
}
/**
*
*/
protected void addReferencestableOptionalProperty() {
EMFModelViewerDialog dialog = new EMFModelViewerDialog(new AdapterFactoryLabelProvider(adapterFactory), referencestableOptionalProperty.getInput(), referencestableOptionalPropertyFilters, referencestableOptionalPropertyBusinessFilters, false, true) {
public void process(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
}
};
dialog.open();
// Start of user code for addReferencestableOptionalProperty
// End of user code
referencestableOptionalProperty.refresh();
}
/**
* @param selection the referencestableOptionalProperty to remove
*
*/
protected void removeReferencestableOptionalProperty(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, elem));
}
referencestableOptionalProperty.refresh();
}
/**
* @param parent
*
*/
protected Composite createReferencestableROPropertyReferencesTable(Composite parent) {
Label referencestableROPropertyLabel = createDescription(parent, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty, EefnrMessages.ReferencesTableSamplePropertiesEditionPart_ReferencestableROPropertyLabel);
GridData referencestableROPropertyLabelData = new GridData();
referencestableROPropertyLabelData.horizontalSpan = 3;
referencestableROPropertyLabel.setLayoutData(referencestableROPropertyLabelData);
referencestableROProperty = createReferencestableROPropertyViewer(parent, adapterFactory);
GridData referencestableROPropertyData = new GridData(GridData.FILL_HORIZONTAL);
referencestableROPropertyData.horizontalSpan = 2;
referencestableROPropertyData.minimumHeight = 120;
referencestableROPropertyData.heightHint = 120;
referencestableROProperty.getTable().setLayoutData(referencestableROPropertyData);
EditingUtils.setID(referencestableROProperty.getTable(), EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty);
EditingUtils.setEEFtype(referencestableROProperty.getTable(), "eef::ReferencesTable::field"); //$NON-NLS-1$
createReferencestableROPropertyControlPanel(parent);
return parent;
}
/**
*
*/
protected TableViewer createReferencestableROPropertyViewer(Composite container, AdapterFactory adapter) {
org.eclipse.swt.widgets.Table table = new org.eclipse.swt.widgets.Table(container, SWT.FULL_SELECTION);
table.setHeaderVisible(true);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = GridData.FILL;
table.setLayoutData(gd);
table.setLinesVisible(true);
// Start of user code for table referencestableROProperty s columns definition
TableColumn name = new TableColumn(table, SWT.NONE);
name.setWidth(80);
name.setText("Label"); //$NON-NLS-1$
// End of user code
TableViewer result = new TableViewer(table);
result.setLabelProvider(new ITableLabelProvider() {
// Start of user code for table referencestableROProperty label provider
public String getColumnText(Object object, int columnIndex) {
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
if (object instanceof EObject) {
switch (columnIndex) {
case 0:
return labelProvider.getText(object);
}
}
return ""; //$NON-NLS-1$
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
// End of user code
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
return result;
}
/**
*
*/
protected void createReferencestableROPropertyControlPanel(Composite container) {
Composite result = new Composite(container, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
result.setLayout(layout);
addReferencestableROProperty = new Button(result, SWT.NONE);
addReferencestableROProperty.setText(EefnrMessages.PropertiesEditionPart_AddListViewerLabel);
GridData addData = new GridData(GridData.FILL_HORIZONTAL);
addReferencestableROProperty.setLayoutData(addData);
addReferencestableROProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
addReferencestableROProperty();
}
});
EditingUtils.setID(addReferencestableROProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty);
EditingUtils.setEEFtype(addReferencestableROProperty, "eef::ReferencesTable::addbutton"); //$NON-NLS-1$
removeReferencestableROProperty = new Button(result, SWT.NONE);
removeReferencestableROProperty.setText(EefnrMessages.PropertiesEditionPart_RemoveListViewerLabel);
GridData removeData = new GridData(GridData.FILL_HORIZONTAL);
removeReferencestableROProperty.setLayoutData(removeData);
removeReferencestableROProperty.addSelectionListener(new SelectionAdapter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*
*/
public void widgetSelected(SelectionEvent e) {
if (referencestableROProperty.getSelection() instanceof IStructuredSelection) {
removeReferencestableROProperty((IStructuredSelection) referencestableROProperty.getSelection());
}
}
});
EditingUtils.setID(removeReferencestableROProperty, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty);
EditingUtils.setEEFtype(removeReferencestableROProperty, "eef::ReferencesTable::removebutton"); //$NON-NLS-1$
}
/**
*
*/
protected void addReferencestableROProperty() {
EMFModelViewerDialog dialog = new EMFModelViewerDialog(new AdapterFactoryLabelProvider(adapterFactory), referencestableROProperty.getInput(), referencestableROPropertyFilters, referencestableROPropertyBusinessFilters, false, true) {
public void process(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
}
};
dialog.open();
// Start of user code for addReferencestableROProperty
// End of user code
referencestableROProperty.refresh();
}
/**
* @param selection the referencestableROProperty to remove
*
*/
protected void removeReferencestableROProperty(IStructuredSelection selection) {
for (Iterator iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ReferencesTableSamplePropertiesEditionPartImpl.this, EefnrViewsRepository.ReferencesTableSample.Properties.referencestableROProperty, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, elem));
}
referencestableROProperty.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.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#initReferencestableRequiredProperty(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)
*/
public void initReferencestableRequiredProperty(ReferencesTableSettings settings) {
if (current.eResource() != null && current.eResource().getResourceSet() != null)
this.resourceSet = current.eResource().getResourceSet();
ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
referencestableRequiredProperty.setContentProvider(contentProvider);
referencestableRequiredProperty.setInput(settings);
boolean eefElementEditorReadOnlyState = isReadOnly(EefnrViewsRepository.ReferencesTableSample.Properties.referencestableRequiredProperty);
if (eefElementEditorReadOnlyState && referencestableRequiredProperty.getTable().isEnabled()) {
referencestableRequiredProperty.getTable().setEnabled(false);
referencestableRequiredProperty.getTable().setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
addReferencestableRequiredProperty.setEnabled(false);
addReferencestableRequiredProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
removeReferencestableRequiredProperty.setEnabled(false);
removeReferencestableRequiredProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !referencestableRequiredProperty.getTable().isEnabled()) {
referencestableRequiredProperty.getTable().setEnabled(true);
addReferencestableRequiredProperty.setEnabled(true);
removeReferencestableRequiredProperty.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#updateReferencestableRequiredProperty()
*
*/
public void updateReferencestableRequiredProperty() {
referencestableRequiredProperty.refresh();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addFilterReferencestableRequiredProperty(ViewerFilter filter)
*
*/
public void addFilterToReferencestableRequiredProperty(ViewerFilter filter) {
referencestableRequiredPropertyFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addBusinessFilterReferencestableRequiredProperty(ViewerFilter filter)
*
*/
public void addBusinessFilterToReferencestableRequiredProperty(ViewerFilter filter) {
referencestableRequiredPropertyBusinessFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#isContainedInReferencestableRequiredPropertyTable(EObject element)
*
*/
public boolean isContainedInReferencestableRequiredPropertyTable(EObject element) {
return ((ReferencesTableSettings)referencestableRequiredProperty.getInput()).contains(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#initReferencestableOptionalProperty(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)
*/
public void initReferencestableOptionalProperty(ReferencesTableSettings settings) {
if (current.eResource() != null && current.eResource().getResourceSet() != null)
this.resourceSet = current.eResource().getResourceSet();
ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
referencestableOptionalProperty.setContentProvider(contentProvider);
referencestableOptionalProperty.setInput(settings);
boolean eefElementEditorReadOnlyState = isReadOnly(EefnrViewsRepository.ReferencesTableSample.Properties.referencestableOptionalProperty);
if (eefElementEditorReadOnlyState && referencestableOptionalProperty.getTable().isEnabled()) {
referencestableOptionalProperty.getTable().setEnabled(false);
referencestableOptionalProperty.getTable().setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
addReferencestableOptionalProperty.setEnabled(false);
addReferencestableOptionalProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
removeReferencestableOptionalProperty.setEnabled(false);
removeReferencestableOptionalProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
} else if (!eefElementEditorReadOnlyState && !referencestableOptionalProperty.getTable().isEnabled()) {
referencestableOptionalProperty.getTable().setEnabled(true);
addReferencestableOptionalProperty.setEnabled(true);
removeReferencestableOptionalProperty.setEnabled(true);
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#updateReferencestableOptionalProperty()
*
*/
public void updateReferencestableOptionalProperty() {
referencestableOptionalProperty.refresh();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addFilterReferencestableOptionalProperty(ViewerFilter filter)
*
*/
public void addFilterToReferencestableOptionalProperty(ViewerFilter filter) {
referencestableOptionalPropertyFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addBusinessFilterReferencestableOptionalProperty(ViewerFilter filter)
*
*/
public void addBusinessFilterToReferencestableOptionalProperty(ViewerFilter filter) {
referencestableOptionalPropertyBusinessFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#isContainedInReferencestableOptionalPropertyTable(EObject element)
*
*/
public boolean isContainedInReferencestableOptionalPropertyTable(EObject element) {
return ((ReferencesTableSettings)referencestableOptionalProperty.getInput()).contains(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#initReferencestableROProperty(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)
*/
public void initReferencestableROProperty(ReferencesTableSettings settings) {
if (current.eResource() != null && current.eResource().getResourceSet() != null)
this.resourceSet = current.eResource().getResourceSet();
ReferencesTableContentProvider contentProvider = new ReferencesTableContentProvider();
referencestableROProperty.setContentProvider(contentProvider);
referencestableROProperty.setInput(settings);
referencestableROProperty.getTable().setEnabled(false);
referencestableROProperty.getTable().setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
addReferencestableROProperty.setEnabled(false);
addReferencestableROProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
removeReferencestableROProperty.setEnabled(false);
removeReferencestableROProperty.setToolTipText(EefnrMessages.ReferencesTableSample_ReadOnly);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#updateReferencestableROProperty()
*
*/
public void updateReferencestableROProperty() {
referencestableROProperty.refresh();
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addFilterReferencestableROProperty(ViewerFilter filter)
*
*/
public void addFilterToReferencestableROProperty(ViewerFilter filter) {
referencestableROPropertyFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#addBusinessFilterReferencestableROProperty(ViewerFilter filter)
*
*/
public void addBusinessFilterToReferencestableROProperty(ViewerFilter filter) {
referencestableROPropertyBusinessFilters.add(filter);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.eefnr.parts.ReferencesTableSamplePropertiesEditionPart#isContainedInReferencestableROPropertyTable(EObject element)
*
*/
public boolean isContainedInReferencestableROPropertyTable(EObject element) {
return ((ReferencesTableSettings)referencestableROProperty.getInput()).contains(element);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.parts.IPropertiesEditionPart#getTitle()
*
*/
public String getTitle() {
return EefnrMessages.ReferencesTableSample_Part_Title;
}
// Start of user code additional methods
// End of user code
}