Search in sources :

Example 1 with DragNDrop

use of org.talend.designer.mapper.ui.dnd.DragNDrop in project tdi-studio-se by Talend.

the class MapperUI method createInputZoneWithTables.

private void createInputZoneWithTables(MapperModel mapperModel, final Display display) {
    inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
    inputsZone.createHeaderZoneComponents();
    sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
    // this.dropTargetOperationListener.addControl(sc1);
    GridData sc1GridData = new GridData(GridData.FILL_BOTH);
    sc1.setLayoutData(sc1GridData);
    sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        // System.out.println("sc1 controlMoved");
        }

        public void controlResized(ControlEvent e) {
            // System.out.println("sc1 controlResized");
            onSashResized(display);
        }
    });
    // add for auto scroll
    new DragNDrop(mapperManager, sc1, true, true);
    inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
    // this.dropTargetOperationListener.addControl(inputTablesZoneView);
    inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
    sc1.setExpandHorizontal(true);
    sc1.setContent(inputTablesZoneView);
    sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
    inputTablesZoneView.initInsertionIndicator();
    Control previousControl = null;
    List<InputTable> tables = mapperModel.getInputDataMapTables();
    Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
    if (minimizeStateOfTables != null) {
        inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
    }
    for (InputTable inputTable : tables) {
        InputDataMapTableView dataMapTableView = new InputDataMapTableView(inputTablesZoneView, SWT.BORDER, inputTable, mapperManager);
        FormData formData = new FormData();
        formData.left = new FormAttachment(0, 0);
        formData.right = new FormAttachment(100, 0);
        formData.top = new FormAttachment(previousControl);
        dataMapTableView.setLayoutData(formData);
        previousControl = dataMapTableView;
        boolean tableIsMinimized = inputTable.isMinimized();
        dataMapTableView.minimizeTable(tableIsMinimized);
        dataMapTableView.registerStyledExpressionEditor(getTabFolderEditors().getStyledTextHandler());
        dataMapTableView.loaded();
    // dataMapTableView.fillMinimumSize(false);
    }
    inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc1MSListener.addMouseWheelListener(sc1);
}
Also used : FormData(org.eclipse.swt.layout.FormData) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) InputTable(org.talend.designer.mapper.model.table.InputTable) Control(org.eclipse.swt.widgets.Control) InputsZone(org.talend.designer.mapper.ui.visualmap.zone.InputsZone) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) InputTablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.InputTablesZoneView) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with DragNDrop

use of org.talend.designer.mapper.ui.dnd.DragNDrop 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 DragNDrop

use of org.talend.designer.mapper.ui.dnd.DragNDrop in project tdi-studio-se by Talend.

the class InputDataMapTableView method createGlobalMapTable.

protected void createGlobalMapTable() {
    this.extendedTableViewerForGlobalMap = new AbstractExtendedTableViewer<GlobalMapEntry>(((InputTable) abstractDataMapTable).getTableGlobalMapEntriesModel(), centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
            createGlobalMapColumns(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<GlobalMapEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(true);
            newTableViewerCreator.setShowLineSelection(SHOW_ROW_SELECTION.FULL);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(true);
            newTableViewerCreator.setHorizontalScroll(false);
            newTableViewerCreator.setVerticalScroll(false);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
            // instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
        }
    };
    tableViewerCreatorForGlobalMap = this.extendedTableViewerForGlobalMap.getTableViewerCreator();
    if (mapperManager.componentIsReadOnly()) {
        tableViewerCreatorForGlobalMap.setReadOnly(true);
    }
    this.extendedTableViewerForGlobalMap.setCommandStack(mapperManager.getCommandStack());
    tableForGlobalMap = tableViewerCreatorForGlobalMap.getTable();
    tableForGlobalMapGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    tableForGlobalMap.setLayoutData(tableForGlobalMapGridData);
    boolean tableGlobalMapVisible = false;
    if (abstractDataMapTable instanceof InputTable) {
        IUILookupMode lookupMode = ((InputTable) abstractDataMapTable).getLookupMode();
        tableGlobalMapVisible = lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD;
    }
    tableForGlobalMapGridData.exclude = !tableGlobalMapVisible;
    tableForGlobalMap.setVisible(tableGlobalMapVisible);
    if (!mapperManager.componentIsReadOnly()) {
        new DragNDrop(mapperManager, tableForGlobalMap, false, true);
    }
    tableViewerCreatorForGlobalMap.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

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

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

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

        @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(tableForGlobalMap);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputTable(org.talend.designer.mapper.model.table.InputTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) DefaultHeaderColumnSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultHeaderColumnSelectionListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArmListener(org.eclipse.swt.events.ArmListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IUILookupMode(org.talend.designer.mapper.model.table.IUILookupMode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Color(org.eclipse.swt.graphics.Color) 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) Point(org.eclipse.swt.graphics.Point) InputTable(org.talend.designer.mapper.model.table.InputTable) 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) ArmEvent(org.eclipse.swt.events.ArmEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Aggregations

GridData (org.eclipse.swt.layout.GridData)3 DragNDrop (org.talend.designer.mapper.ui.dnd.DragNDrop)3 ISelection (org.eclipse.jface.viewers.ISelection)2 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 Color (org.eclipse.swt.graphics.Color)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 Table (org.eclipse.swt.widgets.Table)2 DefaultTableLabelProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider)2 ITableCellValueModifiedListener (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener)2 TableCellValueModifiedEvent (org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent)2 AbstractExtendedTableViewer (org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 UIManager (org.talend.designer.mapper.managers.UIManager)2 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)2 InputTable (org.talend.designer.mapper.model.table.InputTable)2