Search in sources :

Example 1 with BusinessItemProviderAdapterFactory

use of org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory 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);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) RepositoryFactoryProxyLabelProvider(org.talend.designer.business.diagram.custom.properties.RepositoryFactoryProxyLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 2 with BusinessItemProviderAdapterFactory

use of org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory 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);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IItemPropertyDescriptor(org.eclipse.emf.edit.provider.IItemPropertyDescriptor) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 3 with BusinessItemProviderAdapterFactory

use of org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory in project tdi-studio-se by Talend.

the class ElementHelper method updateTooltipFigure.

/**
     * DOC Administrator Comment method "getTooltipFigure".
     * 
     * @param figure
     */
public void updateTooltipFigure(Figure figure, BusinessTooltipFigure tooltipFigure, EditPart editPart) {
    EObject element = ((View) editPart.getModel()).getElement();
    if (element instanceof BusinessItem) {
        List assignements = ((BusinessItem) element).getAssignments();
        BusinessItemProviderAdapterFactory adapterFactory = new BusinessItemProviderAdapterFactory();
        BusinessAssignmentItemProvider provider = (BusinessAssignmentItemProvider) adapterFactory.createBusinessAssignmentAdapter();
        Image img = null;
        Label label = null;
        List<Label> labels = new ArrayList();
        try {
            for (Object assignment : assignements) {
                if (assignment instanceof BusinessAssignment) {
                    TalendItem talendItem = ((BusinessAssignment) assignment).getTalendItem();
                    if (talendItem != null) {
                        IRepositoryViewObject obj = CorePlugin.getDefault().getProxyRepositoryFactory().getLastVersion(talendItem.getId());
                        if (obj != null) {
                            ERepositoryObjectType type = obj.getRepositoryObjectType();
                            Item item = obj.getProperty().getItem();
                            if (item instanceof JobletProcessItem) {
                                JobletProcessItem jobletItem = (JobletProcessItem) item;
                                Image jobletCustomIcon = RepositoryLabelProvider.getJobletCustomIcon(jobletItem.getProperty());
                                if (jobletCustomIcon != null) {
                                    img = ImageUtils.scale(jobletCustomIcon, ICON_SIZE.ICON_16);
                                }
                            } else {
                                img = CoreImageProvider.getImage(type);
                            }
                            //$NON-NLS-1$ //$NON-NLS-2$
                            label = new Label(obj.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", img);
                            labels.add(label);
                        } else {
                            MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(talendItem.getId());
                            Query query = MetadataToolHelper.getQueryFromRepository(talendItem.getId());
                            SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(talendItem.getId());
                            if (table != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_TABLE_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else if (query != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_QUERY_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else if (talendItem instanceof SQLPattern) {
                                List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
                                for (IRepositoryViewObject object : list) {
                                    if (talendItem.getLabel().equals(object.getLabel())) {
                                        img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SQLPATTERN_ICON.getPath()).createImage();
                                        label = new Label(//$NON-NLS-1$
                                        talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
                                        img);
                                        labels.add(label);
                                    }
                                }
                            } else if (talendItem instanceof Routine) {
                                List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
                                for (IRepositoryViewObject object : list) {
                                    if (talendItem.getLabel().equals(object.getLabel())) {
                                        img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.ROUTINE_ICON.getPath()).createImage();
                                        label = new Label(//$NON-NLS-1$
                                        talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$
                                        img);
                                        labels.add(label);
                                    }
                                }
                            } else if (function != null) {
                                img = ImageDescriptor.createFromFile(ECoreImage.class, ECoreImage.METADATA_SAPCONNECTION_ICON.getPath()).createImage();
                                label = new Label(talendItem.getLabel() + " (" + provider.getColumnText(assignment, 0) + ")", //$NON-NLS-1$ //$NON-NLS-2$
                                img);
                                labels.add(label);
                            } else {
                                img = (Image) provider.getImage(assignment);
                                img = new OverlayImage(img, ImageProvider.getImageDesc(ECoreImage.DELETED_OVERLAY), EPosition.BOTTOM_RIGHT).createImage();
                                String text = provider.getText(assignment) + " (" + provider.getColumnText(assignment, 0) + //$NON-NLS-1$ //$NON-NLS-2$
                                ")";
                                label = new Label(text, img);
                                labels.add(label);
                            }
                        }
                    }
                }
            }
            if (tooltipFigure == null) {
                tooltipFigure = new BusinessTooltipFigure();
            }
            if (labels.size() == 0) {
                figure.setToolTip(null);
            } else {
                tooltipFigure.buildFigures(labels);
                figure.setToolTip(tooltipFigure);
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.core.model.metadata.builder.connection.Query) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) Label(org.eclipse.draw2d.Label) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) BusinessItem(org.talend.designer.business.model.business.BusinessItem) Item(org.talend.core.model.properties.Item) TalendItem(org.talend.designer.business.model.business.TalendItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) BusinessAssignmentItemProvider(org.talend.designer.business.model.business.provider.BusinessAssignmentItemProvider) EObject(org.eclipse.emf.ecore.EObject) OverlayImage(org.talend.commons.ui.runtime.image.OverlayImage) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessTooltipFigure(org.talend.designer.business.diagram.custom.figures.BusinessTooltipFigure) Routine(org.talend.designer.business.model.business.Routine) View(org.eclipse.gmf.runtime.notation.View) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 4 with BusinessItemProviderAdapterFactory

use of org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory in project tdi-studio-se by Talend.

the class BusinessDiagramEditorPlugin method fillItemProviderFactories.

/**
     * @generated
     */
protected void fillItemProviderFactories(List factories) {
    factories.add(new BusinessItemProviderAdapterFactory());
    factories.add(new ResourceItemProviderAdapterFactory());
    factories.add(new ReflectiveItemProviderAdapterFactory());
}
Also used : ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) BusinessItemProviderAdapterFactory(org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory)

Aggregations

BusinessItemProviderAdapterFactory (org.talend.designer.business.model.business.provider.BusinessItemProviderAdapterFactory)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 IItemPropertyDescriptor (org.eclipse.emf.edit.provider.IItemPropertyDescriptor)2 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)2 CellEditor (org.eclipse.jface.viewers.CellEditor)2 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)2 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)2 ICellModifier (org.eclipse.jface.viewers.ICellModifier)2 TableLayout (org.eclipse.jface.viewers.TableLayout)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)2 Table (org.eclipse.swt.widgets.Table)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 TableItem (org.eclipse.swt.widgets.TableItem)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Label (org.eclipse.draw2d.Label)1 EObject (org.eclipse.emf.ecore.EObject)1 ReflectiveItemProviderAdapterFactory (org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory)1