Search in sources :

Example 1 with UIManager

use of org.talend.designer.mapper.managers.UIManager in project tdi-studio-se by Talend.

the class VarsDataMapTableView method addListeners.

@Override
protected void addListeners() {
    super.addListeners();
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        public void handle(LineSelectionEvent e) {
            if (!getMapperManager().componentIsReadOnly()) {
                boolean atLeastOneItemIsSelected = tableViewerCreatorForColumns.getTable().getSelectionCount() > 0;
                removeEntryItem.setEnabled(atLeastOneItemIsSelected);
                moveUpEntryItem.setEnabled(atLeastOneItemIsSelected);
                moveDownEntryItem.setEnabled(atLeastOneItemIsSelected);
            }
        }
    });
    getExtendedTableViewerForColumns().getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {

        public void handleEvent(ListenableListEvent event) {
            if (event.type == ListenableListEvent.TYPE.SWAPED) {
                DataMapTableView varsDataMapTableView = mapperManager.retrieveDataMapTableView(getExtendedTableViewerForColumns().getTable());
                UIManager uiManager = mapperManager.getUiManager();
                uiManager.parseAllExpressions(varsDataMapTableView, false);
                mapperManager.getProblemsManager().checkProblemsForAllEntries(varsDataMapTableView, true);
                uiManager.refreshBackground(true, false);
                List<ITableEntry> list = uiManager.extractSelectedTableEntries(varsDataMapTableView.getTableViewerCreatorForColumns().getTableViewer().getSelection());
                uiManager.selectLinks(varsDataMapTableView, list, false, false);
            }
        }
    });
}
Also used : ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) UIManager(org.talend.designer.mapper.managers.UIManager) List(java.util.List) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener)

Example 2 with UIManager

use of org.talend.designer.mapper.managers.UIManager in project tdi-studio-se by Talend.

the class OutputDataMapTableView method createFiltersTable.

protected void createFiltersTable() {
    this.extendedTableViewerForFilters = new AbstractExtendedTableViewer<FilterTableEntry>(((OutputTable) abstractDataMapTable).getTableFiltersEntriesModel(), centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<FilterTableEntry> tableViewerCreator, Table table) {
            createFiltersColumns(tableViewerCreator);
        }

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
             * (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
             */
        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<FilterTableEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(false);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(true);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
            // instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
        }
    };
    tableViewerCreatorForFilters = this.extendedTableViewerForFilters.getTableViewerCreator();
    this.extendedTableViewerForFilters.setCommandStack(mapperManager.getCommandStack());
    tableForConstraints = tableViewerCreatorForFilters.getTable();
    tableForConstraintsGridData = new GridData(GridData.FILL_HORIZONTAL);
    tableForConstraints.setLayoutData(tableForConstraintsGridData);
    boolean tableConstraintsVisible = false;
    if (abstractDataMapTable instanceof OutputTable) {
        tableConstraintsVisible = ((OutputTable) abstractDataMapTable).getFilterEntries().size() > 0;
    }
    tableForConstraintsGridData.exclude = !tableConstraintsVisible;
    tableForConstraints.setVisible(tableConstraintsVisible);
    if (!mapperManager.componentIsReadOnly()) {
        new DragNDrop(mapperManager, tableForConstraints, false, true);
    }
    tableViewerCreatorForFilters.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    final TableViewer tableViewer = tableViewerCreatorForFilters.getTableViewer();
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            selectThisDataMapTableView();
            UIManager uiManager = mapperManager.getUiManager();
            uiManager.selectLinks(OutputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
        }
    });
    tableForConstraints.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForFilters, event);
        }
    });
    tableViewerCreatorForFilters.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForFilters) {

        @Override
        public Color getBackground(Object element, int columnIndex) {
            return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
        }

        @Override
        public Color getForeground(Object element, int columnIndex) {
            return getForegroundCellColor(tableViewerCreator, element, columnIndex);
        }
    });
    initShowMessageErrorListener(tableForConstraints);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Color(org.eclipse.swt.graphics.Color) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) UIManager(org.talend.designer.mapper.managers.UIManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.mapper.model.table.OutputTable) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) DefaultTableLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider) FocusEvent(org.eclipse.swt.events.FocusEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 3 with UIManager

use of org.talend.designer.mapper.managers.UIManager in project tdi-studio-se by Talend.

the class MapperUI method createWindow.

/**
     * DOC amaumont Comment method "createUI".
     * 
     * @param display
     */
public Shell createWindow(final Display display, MapperModel model) {
    Shell activeShell = display.getActiveShell();
    Shell mapperShell = null;
    int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
    if (activeShell == null) {
        mapperShell = new Shell(mapperShell, style);
    } else {
        mapperShell = new Shell(activeShell, style);
    }
    this.mapperUIParent = mapperShell;
    final Shell mapperShellFinal = mapperShell;
    mapperShell.addShellListener(new ShellListener() {

        public void shellActivated(ShellEvent e) {
        }

        public void shellClosed(ShellEvent e) {
            UIManager uiManager = mapperManager.getUiManager();
            if (uiManager.getMapperResponse() == SWT.NONE) {
                for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                uiManager.setMapperResponse(SWT.CANCEL);
                uiManager.prepareClosing(uiManager.getMapperResponse());
            }
            if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
                    mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
                }
            }
        }

        public void shellDeactivated(ShellEvent e) {
        }

        public void shellDeiconified(ShellEvent e) {
        }

        public void shellIconified(ShellEvent e) {
        }
    });
    MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
    ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
    mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
    component.getUniqueName()));
    Rectangle boundsMapper = uiProperties.getBoundsMapper();
    if (uiProperties.isShellMaximized()) {
        mapperShell.setMaximized(uiProperties.isShellMaximized());
    } else {
        if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
            mapperShell.setMaximized(true);
        // boundsMapper = display.getBounds(); //no need this, will cause the full problems.
        } else {
            // // move shell at outer of display zone to avoid visual effect on loading
            // Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
            // boundsMapper.height);
            // shell.setBounds(tmpBoundsMapper);
            boundsMapper = uiProperties.getBoundsMapper();
            if (boundsMapper.x < 0) {
                boundsMapper.x = 0;
            }
            if (boundsMapper.y < 0) {
                boundsMapper.y = 0;
            }
            mapperShell.setBounds(boundsMapper);
        }
    }
    createCompositeContent(model);
    mapperShell.open();
    return mapperShell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ExternalMapperUiProperties(org.talend.designer.mapper.external.data.ExternalMapperUiProperties) ShellListener(org.eclipse.swt.events.ShellListener) Rectangle(org.eclipse.swt.graphics.Rectangle) ShellEvent(org.eclipse.swt.events.ShellEvent) UIManager(org.talend.designer.mapper.managers.UIManager) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IBrandingService(org.talend.core.ui.branding.IBrandingService) MapperComponent(org.talend.designer.mapper.MapperComponent)

Example 4 with UIManager

use of org.talend.designer.mapper.managers.UIManager in project tdi-studio-se by Talend.

the class InsertionIndicator method updatePosition.

/**
     * Update position of the indicator at top of <code>itemIndexTarget</code> position of the
     * <code>draggableTable</code>.
     * 
     * @param currentTable
     * @param itemIndexTarget
     */
public void updatePosition(Table currentTable, int itemIndexTarget) {
    //        System.out.println(itemIndexTarget);
    this.draggableTable = currentTable;
    removeTablePaintListener();
    if (tablePaintListener == null) {
        tablePaintListener = new Listener() {

            public void handleEvent(Event event) {
                drawIndicatorLineInTable(event);
            }
        };
    }
    FormLayout formLayout = tablesZoneViewParent.getLayout();
    UIManager uiManager = mapperManager.getUiManager();
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    Display display = tablesZoneViewOutputs.getDisplay();
    Point tablePositionRefZone = display.map(currentTable, tablesZoneViewParent, new Point(0, 0));
    FormData formDataLeftArrow = (FormData) leftArrowDraggingIndicator.getLayoutData();
    FormData formDataRightArrow = (FormData) rightArrowDraggingIndicator.getLayoutData();
    ScrollBar verticalBar = currentTable.getVerticalBar();
    // System.out.println("verticalBar.getSelection()="+verticalBar.getSelection() + "
    // currentTable.getItemHeight()="+currentTable.getItemHeight());
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTable);
    int indicYPositionRefZone = 0;
    if (WindowSystem.isGTK()) {
        int offsetVerticalBar = -verticalBar.getSelection();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * (currentTable.getItemHeight() + 2) + offsetVerticalBar;
        }
        // System.out.println("indicYPositionRefTable="+indicYPositionRefTable);
        indicYPositionRefZone = indicYPositionRefTable + tablePositionRefZone.y + formLayout.marginTop - HEIGHT_INDICATOR / 2;
        indicYPositionRefZone -= currentTable.getItemHeight() + 1;
    // System.out.println("indicYPositionRefZone="+indicYPositionRefZone);
    } else {
        int offsetVerticalBar = -verticalBar.getSelection() * currentTable.getItemHeight();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * currentTable.getItemHeight() - 1 + offsetVerticalBar;
        }
        Point point = currentTable.getDisplay().map(currentTable, tablesZoneViewParent, new Point(0, indicYPositionRefTable));
        indicYPositionRefZone = point.y + 5;
    }
    Rectangle boundsTableView = dataMapTableView.getBounds();
    int testValue = boundsTableView.y + boundsTableView.height - formLayout.marginTop - HEIGHT_INDICATOR / 2 - 5;
    if (indicYPositionRefZone > testValue) {
        indicYPositionRefZone = testValue;
    }
    currentTable.addListener(SWT.Paint, tablePaintListener);
    if (lastIndicYPositionRefZone != indicYPositionRefZone) {
        formDataLeftArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.left.offset = currentTable.getSize().x + 2;
        currentTable.redraw();
        tablesZoneViewParent.layout();
    }
    lastIndicYPositionRefZone = indicYPositionRefZone;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Listener(org.eclipse.swt.widgets.Listener) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) UIManager(org.talend.designer.mapper.managers.UIManager) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) Point(org.eclipse.swt.graphics.Point) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 5 with UIManager

use of org.talend.designer.mapper.managers.UIManager in project tdi-studio-se by Talend.

the class MapperUI method selectFirstInOutTablesView.

private void selectFirstInOutTablesView() {
    List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
    UIManager uiManager = mapperManager.getUiManager();
    if (inputsTablesView.size() > 0) {
        uiManager.selectDataMapTableView(inputsTablesView.get(0), true, false);
    }
    List<DataMapTableView> outputsTablesView = mapperManager.getUiManager().getOutputsTablesView();
    if (outputsTablesView.size() > 0) {
        uiManager.selectDataMapTableView(outputsTablesView.get(0), true, false);
    }
}
Also used : UIManager(org.talend.designer.mapper.managers.UIManager) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)

Aggregations

UIManager (org.talend.designer.mapper.managers.UIManager)19 DraggedData (org.talend.designer.abstractmap.ui.dnd.DraggedData)6 DraggingInfosPopup (org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup)6 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)6 Point (org.eclipse.swt.graphics.Point)4 GridData (org.eclipse.swt.layout.GridData)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 AbstractUIManager (org.talend.designer.abstractmap.managers.AbstractUIManager)4 ISelection (org.eclipse.jface.viewers.ISelection)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 FocusListener (org.eclipse.swt.events.FocusListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Color (org.eclipse.swt.graphics.Color)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 FormData (org.eclipse.swt.layout.FormData)2