use of org.eclipse.emf.edit.provider.IItemPropertyDescriptor in project tdi-studio-se by Talend.
the class EditAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
Shell shell = ShellUtil.getShell();
if (shell != null) {
IItemPropertySource itemPropertySource = EmfPropertyHelper.getItemPropertySource(adapterFactory, eObject);
IItemPropertyDescriptor itemPropertyDescriptor = EmfPropertyHelper.getItemPropertyDescriptor(itemPropertySource, eObject, structuralFeature);
if (itemPropertySource != null) {
EditAction.EditDialog editDialog = new EditDialog(shell, adapterFactory, itemPropertyDescriptor, eObject);
if (editDialog.open() == Dialog.OK) {
itemPropertyDescriptor.setPropertyValue(eObject, editDialog.getValue());
}
}
}
}
use of org.eclipse.emf.edit.provider.IItemPropertyDescriptor in project tdi-studio-se by Talend.
the class BusinessAssignmentComposite method createControls.
public void createControls(Composite parent) {
composite = widgetFactory.createFlatFormComposite(parent);
adapterFactory = new BusinessItemProviderAdapterFactory();
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("AssignmentPropertySection.Comment") };
TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column3.setText(columnProperties[2]);
tableViewer.setColumnProperties(columnProperties);
final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
tableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(Object element, String property) {
return property.equals(columnProperties[2]);
}
@Override
public Object getValue(Object element, String property) {
return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
}
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
TableItem tableItem = (TableItem) element;
itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
}
}
});
CellEditor[] cellEditors = new CellEditor[3];
cellEditors[2] = new TextCellEditor(table);
tableViewer.setCellEditors(cellEditors);
// createKeyListener(table);
createSelectionListener();
createPopupMenu();
createDoubleClickListener();
handleLayout(parent, table, column1, column2, column3);
}
use of org.eclipse.emf.edit.provider.IItemPropertyDescriptor in project tdi-studio-se by Talend.
the class AssignmentPropertySection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
// PTODO mhelleboid externalize tableviewer creation
adapterFactory = new BusinessItemProviderAdapterFactory();
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
tableViewer.setLabelProvider(new RepositoryFactoryProxyLabelProvider(adapterFactory));
Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { Messages.getString("AssignmentPropertySection.Type"), Messages.getString("AssignmentPropertySection.Name"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("AssignmentPropertySection.Comment") };
TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column3.setText(columnProperties[2]);
tableViewer.setColumnProperties(columnProperties);
final IItemPropertyDescriptor itemPropertyDescriptor = getItemPropertyDescriptor();
tableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return property.equals(columnProperties[2]);
}
public Object getValue(Object element, String property) {
return EmfPropertyHelper.getValue(itemPropertyDescriptor, element);
}
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
TableItem tableItem = (TableItem) element;
itemPropertyDescriptor.setPropertyValue(tableItem.getData(), value);
}
}
});
CellEditor[] cellEditors = new CellEditor[3];
cellEditors[2] = new TextCellEditor(table);
tableViewer.setCellEditors(cellEditors);
createKeyListener(table);
createSelectionListener();
createPopupMenu();
createDoubleClickListener();
handleLayout(parent, table, column1, column2, column3);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.eclipse.emf.edit.provider.IItemPropertyDescriptor in project tdi-studio-se by Talend.
the class EmfPropertyHelper method getItemPropertyDescriptor.
/**
* DOC mhelleboid Comment method "getItemPropertyDescriptor".
*
* @param itemPropertySource
* @param eObject TODO
* @param structuralFeature TODO
* @return
*/
public static IItemPropertyDescriptor getItemPropertyDescriptor(IItemPropertySource itemPropertySource, EObject eObject, EStructuralFeature structuralFeature) {
IItemPropertyDescriptor itemPropertyDescriptor = null;
List propertyDescriptors = itemPropertySource.getPropertyDescriptors(eObject);
for (Iterator iter = propertyDescriptors.iterator(); iter.hasNext(); ) {
IItemPropertyDescriptor tempItemPropertyDescriptor = (IItemPropertyDescriptor) iter.next();
if (tempItemPropertyDescriptor.getFeature(eObject).equals(structuralFeature)) {
itemPropertyDescriptor = tempItemPropertyDescriptor;
}
}
return itemPropertyDescriptor;
}
use of org.eclipse.emf.edit.provider.IItemPropertyDescriptor in project tdi-studio-se by Talend.
the class EmfPropertyHelper method getItemPropertyDescriptor.
/**
* DOC mhelleboid Comment method "getItemPropertyDescriptor".
*
* @param itemPropertySource
* @param eObject TODO
* @param structuralFeature TODO
* @return
*/
public static IItemPropertyDescriptor getItemPropertyDescriptor(IItemPropertySource itemPropertySource, EObject eObject, EStructuralFeature structuralFeature) {
IItemPropertyDescriptor itemPropertyDescriptor = null;
List propertyDescriptors = itemPropertySource.getPropertyDescriptors(eObject);
for (Iterator iter = propertyDescriptors.iterator(); iter.hasNext(); ) {
IItemPropertyDescriptor tempItemPropertyDescriptor = (IItemPropertyDescriptor) iter.next();
if (tempItemPropertyDescriptor.getFeature(eObject).equals(structuralFeature)) {
itemPropertyDescriptor = tempItemPropertyDescriptor;
}
}
return itemPropertyDescriptor;
}
Aggregations