Search in sources :

Example 96 with DisposeListener

use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.

the class TabFolderEditors method addListenersToInputButtons.

/**
     * DOC amaumont Comment method "addListenersToInputButtons".
     */
private void addListenersToInputButtons() {
    MetadataToolbarEditorView toolBar = inputMetaEditor.getToolBar();
    inputToolBarButtons = toolBar.getButtons();
    beforeCommandListenerForInputButtons = new IExtendedButtonListener() {

        public void handleEvent(ExtendedButtonEvent event) {
            TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedInputTableView().getTableViewerCreatorForColumns();
            if (tableViewerCreator != null) {
                tableViewerCreator.applyActivatedCellEditor();
            }
        }
    };
    for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
        extendedPushButton.addListener(beforeCommandListenerForInputButtons, true);
    }
    this.addDisposeListener(new DisposeListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
             */
        public void widgetDisposed(DisposeEvent e) {
            for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
                extendedPushButton.removeListener(beforeCommandListenerForInputButtons, true);
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ExtendedPushButton(org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton) MetadataToolbarEditorView(org.talend.core.ui.metadata.editor.MetadataToolbarEditorView) IExtendedButtonListener(org.talend.commons.ui.swt.extended.table.IExtendedButtonListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)

Example 97 with DisposeListener

use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.

the class RadioFieldEditor method getChangeControl.

@Override
protected Button getChangeControl(Composite parent) {
    if (radio == null) {
        radio = new Button(parent, SWT.RADIO | SWT.LEFT);
        radio.setFont(parent.getFont());
        radio.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean isSelected = radio.getSelection();
                valueChanged(wasSelected, isSelected);
                wasSelected = isSelected;
            }
        });
        radio.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent event) {
                radio = null;
            }
        });
    } else {
        checkParent(radio, parent);
    }
    return radio;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 98 with DisposeListener

use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.

the class HL7Tree2SchemaLinker method initColors.

private void initColors(Display display) {
    // selectedLoopLinkColor = new Color(display, 255, 131, 0);
    selectedRelativeLinkColor = new Color(display, 110, 168, 255);
    getTree().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            // selectedLoopLinkColor.dispose();
            selectedRelativeLinkColor.dispose();
            getTree().removeDisposeListener(this);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 99 with DisposeListener

use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.

the class UIManager method modifySelectionChangedListener.

private void modifySelectionChangedListener(final Zone currentZone, final MetadataTableEditorView metadataTableEditorViewFinal, final TableViewerCreator metadataTVCreator, final MetadataTableEditor metadataTableEditor, final DataMapTableView dataMapTableView, DataMapTableView previousSelectedTableView) {
    final TableViewer tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    IModifiedBeanListener<IMetadataColumn> modifiedBeanListener = new IModifiedBeanListener<IMetadataColumn>() {

        public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
            if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId()) && !event.previousValue.equals(event.newValue)) {
                IMetadataColumn modifiedObject = event.bean;
                if (modifiedObject != null) {
                    TableEntryLocation tableEntryLocation = new TableEntryLocation(dataMapTableView.getDataMapTable().getName(), (String) event.previousValue);
                    final ITableEntry dataMapTableEntry = mapperManager.retrieveTableEntry(tableEntryLocation);
                    // see bug 7471,record the modification about the column value
                    String curConnName = null;
                    if (dataMapTableEntry != null) {
                        curConnName = dataMapTableEntry.getParentName();
                    }
                    List<? extends IConnection> curInConns = mapperManager.getAbstractMapComponent().getIncomingConnections();
                    List<? extends IConnection> curOutConns = mapperManager.getAbstractMapComponent().getOutgoingConnections();
                    for (IConnection curInConn : curInConns) {
                        if (curConnName.equals(curInConn.getUniqueName())) {
                            Map<String, String> changedNameInColumns = new HashMap<String, String>();
                            changedNameInColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curInConn, changedNameInColumns);
                        }
                    }
                    for (IConnection curOutConn : curOutConns) {
                        if (curConnName.equals(curOutConn.getUniqueName())) {
                            Map<String, String> changedNameOutColumns = new HashMap<String, String>();
                            changedNameOutColumns.put((String) event.newValue, (String) event.previousValue);
                            changedNameColumns.put(curOutConn, changedNameOutColumns);
                        }
                    }
                    processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry);
                    // related tables
                    List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
                    for (DataMapTableView relatedView : relatedOutputsTableView) {
                        TableEntryLocation relatedEntryLocation = new TableEntryLocation(relatedView.getDataMapTable().getName(), (String) event.previousValue);
                        ITableEntry relatedTableEntry = mapperManager.retrieveTableEntry(relatedEntryLocation);
                        processColumnNameChanged((String) event.previousValue, (String) event.newValue, relatedView, relatedTableEntry);
                    }
                }
                // dataMapTableViewer.refresh(event.bean, true);
                tableViewer.refresh(true);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_KEY.equals(event.column.getId())) {
                tableViewer.refresh(true);
                IColumnEntry entry = dataMapTableView.getDataMapTable().getColumnEntries().get(event.index);
                parseExpression(entry.getExpression(), entry, false, false, false);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_TYPE.equals(event.column.getId()) || AbstractMetadataTableEditorView.ID_COLUMN_NULLABLE.equals(event.column.getId())) {
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        }
    };
    ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        public void handle(LineSelectionEvent e) {
            if (metadataTableEditorViewFinal.getTableViewerCreator() == e.source) {
                if (metadataTableEditorViewFinal.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManager.getUiManager().selectLinkedTableEntries(metadataTableEditor.getMetadataTable(), metadataTVCreator.getTable().getSelectionIndices());
                }
            } else {
            // if (dataMapTableView.getExtendedTableViewerForColumns().isExecuteSelectionEvent()) {
            // int[] selectionIndices =
            // dataMapTableView.getTableViewerCreatorForColumns().getTable().getSelectionIndices();
            // mapperManager.getUiManager().selectLinkedMetadataEditorEntries(dataMapTableView,
            // selectionIndices);
            // }
            }
        }
    };
    // ISelectionChangedListener previousSelectionChangedListener = null;
    ILineSelectionListener previousSelectionChangedListener = null;
    IModifiedBeanListener<IMetadataColumn> previousModifiedBeanListener = null;
    if (currentZone == Zone.INPUTS) {
        previousSelectionChangedListener = inputsSelectionChangedListener;
        previousModifiedBeanListener = inputModifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        previousSelectionChangedListener = outputsSelectionChangedListener;
        previousModifiedBeanListener = outputModifiedBeanListener;
    }
    if (previousSelectionChangedListener != null) {
        // metadataTVCreator.removeSelectionChangedListener(previousSelectionChangedListener);
        metadataTVCreator.getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        if (previousSelectedTableView != null) {
            previousSelectedTableView.getTableViewerCreatorForColumns().getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        }
    }
    if (previousModifiedBeanListener != null) {
        metadataTableEditor.removeModifiedBeanListener(previousModifiedBeanListener);
    }
    if (currentZone == Zone.INPUTS) {
        inputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        inputModifiedBeanListener = modifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        outputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        outputModifiedBeanListener = modifiedBeanListener;
    }
    // metadataTVCreator.addSelectionChangedListener(metadataEditorViewerSelectionChangedListener);
    metadataTVCreator.getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    dataMapTableView.getTableViewerCreatorForColumns().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    metadataTableEditor.addModifiedBeanListener(modifiedBeanListener);
    if (this.commonMetadataDisposeListener == null) {
        this.commonMetadataDisposeListener = new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                if (inputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.INPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(inputsSelectionChangedListener);
                }
                if (outputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.OUTPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(outputsSelectionChangedListener);
                }
                if (inputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.INPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(inputModifiedBeanListener);
                    }
                }
                if (outputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.OUTPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(outputModifiedBeanListener);
                    }
                }
            }
        };
        metadataTVCreator.getTable().addDisposeListener(this.commonMetadataDisposeListener);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) HashMap(java.util.HashMap) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IConnection(org.talend.core.model.process.IConnection) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 100 with DisposeListener

use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.

the class SQLEditorProposalAdapter method openProposalPopup.

/**
     * Open the proposal popup and display the proposals provided by the proposal provider. This method returns
     * immediately. That is, it does not wait for a proposal to be selected.
     */
protected void openProposalPopup() {
    if (isValid()) {
        if (popup == null) {
            recordCursorPosition();
            popup = new ContentProposalPopup(null);
            popup.open();
            popup.getShell().addDisposeListener(new DisposeListener() {

                @Override
                public void widgetDisposed(DisposeEvent event) {
                    popup = null;
                }
            });
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Aggregations

DisposeListener (org.eclipse.swt.events.DisposeListener)118 DisposeEvent (org.eclipse.swt.events.DisposeEvent)117 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 GridData (org.eclipse.swt.layout.GridData)38 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)33 Image (org.eclipse.swt.graphics.Image)29 Cursor (org.eclipse.swt.graphics.Cursor)26 ToolBar (org.eclipse.swt.widgets.ToolBar)25 ToolItem (org.eclipse.swt.widgets.ToolItem)23 Composite (org.eclipse.swt.widgets.Composite)19 Color (org.eclipse.swt.graphics.Color)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Point (org.eclipse.swt.graphics.Point)16 ControlEvent (org.eclipse.swt.events.ControlEvent)11 SelectionListener (org.eclipse.swt.events.SelectionListener)10 Control (org.eclipse.swt.widgets.Control)10 TextLayout (org.eclipse.swt.graphics.TextLayout)9 Listener (org.eclipse.swt.widgets.Listener)9 ControlListener (org.eclipse.swt.events.ControlListener)8 MouseEvent (org.eclipse.swt.events.MouseEvent)8