Search in sources :

Example 31 with DisposeListener

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

the class TabFolderEditors method addListenersToOutputButtons.

/**
     * DOC amaumont Comment method "addListenersToInputButtons".
     */
private void addListenersToOutputButtons() {
    MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
    outputToolBarButtons = toolBar.getButtons();
    beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {

        public void handleEvent(ExtendedButtonEvent event) {
            TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
            if (tableViewerCreator != null) {
                tableViewerCreator.applyActivatedCellEditor();
            }
        }
    };
    for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
        extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
        if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
            removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
        }
    }
    if (removeButton != null) {
        final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
        tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

            public void handle(LineSelectionEvent e) {
                for (TableItem item : tableViewerCreator.getTable().getSelection()) {
                    if (item.getData() instanceof MetadataColumn) {
                        MetadataColumn column = (MetadataColumn) item.getData();
                        removeButton.getButton().setEnabled(!column.isCustom());
                        break;
                    }
                }
            }
        });
    }
    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 : outputToolBarButtons) {
                extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
            }
        }
    });
}
Also used : MetadataColumn(org.talend.core.model.metadata.MetadataColumn) DisposeListener(org.eclipse.swt.events.DisposeListener) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) RemovePushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButton) ExtendedPushButton(org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton) TableItem(org.eclipse.swt.widgets.TableItem) MetadataToolbarEditorView(org.talend.core.ui.metadata.editor.MetadataToolbarEditorView) IExtendedButtonListener(org.talend.commons.ui.swt.extended.table.IExtendedButtonListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)

Example 32 with DisposeListener

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

the class SQLResultComposite method createTabItem.

/**
     * 
     * DOC dev Comment method "createTabItem".
     * 
     * @throws Exception throw all exception
     */
private void createTabItem() throws Exception {
    lastTabNumber = lastTabNumber + 1;
    final CTabItem tabItem = new CTabItem(tabFolder, SWT.NULL);
    String labelText = Messages.getString("SQLResultComposite.Result") + ": " + lastTabNumber;
    tabItem.setText(labelText);
    //$NON-NLS-1$
    tabItem.setData("tabLabel", labelText);
    tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
    Composite composite = new Composite(tabFolder, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginLeft = 0;
    layout.marginTop = 0;
    layout.marginBottom = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    tabItem.setControl(composite);
    tabItem.setData(sqlExecution);
    tabItem.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(final DisposeEvent e) {
            BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                public void run() {
                    CTabItem tabItem = (CTabItem) e.getSource();
                    AbstractSQLExecution sqlExe = (AbstractSQLExecution) tabItem.getData();
                    sqlExe.stop();
                    tabItem.setData(null);
                    if (tabFolder != null && !tabFolder.isDisposed()) {
                        if (tabFolder.getItemCount() == 0) {
                            // this is last tab..
                            clearParent();
                            setDefaultMessage();
                        }
                    } else if (tabFolder.isDisposed()) {
                        clearParent();
                        setDefaultMessage();
                    }
                }
            });
        }
    });
    createHeaderComposite(composite, tabItem);
    createDetailComposite(composite, tabItem);
    // refresh view
    composite.layout();
    tabFolder.layout();
    tabFolder.redraw();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) AbstractSQLExecution(org.talend.sqlbuilder.sqlcontrol.AbstractSQLExecution) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 33 with DisposeListener

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

the class TableField method getButtonBoxControl.

/**
     * Returns this field editor's button box containing the Add, Remove, Up, and Down button.
     * 
     * @param parent the parent control
     * @return the button box
     */
public Composite getButtonBoxControl(Composite parent) {
    buttonBox = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 5;
    layout.marginTop = 0;
    buttonBox.setLayout(layout);
    createButtons(buttonBox);
    buttonBox.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            addButton = null;
            removeButton = null;
            upButton = null;
            downButton = null;
            buttonBox = null;
        }
    });
    selectionChanged();
    return buttonBox;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 34 with DisposeListener

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

the class MapperUI method addParentListeners.

private void addParentListeners(final UIManager uiManager, final ExternalDbMapUiProperties uiProperties) {
    mapperUIParent.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            release();
        }
    });
    mapperUIParent.addListener(SWT.Close, new Listener() {

        public void handleEvent(Event event) {
            if (uiManager.getMapperResponse() == SWT.NONE) {
                uiManager.setMapperResponse(SWT.CANCEL);
            }
        }
    });
    mapperUIParent.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            updateBackground(false, true);
        }

        public void focusLost(FocusEvent e) {
        }
    });
    // store size if not maximized
    if (mapperUIParent instanceof Shell) {
        ((Shell) mapperUIParent).addControlListener(new ControlListener() {

            public void controlMoved(ControlEvent e) {
            }

            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 35 with DisposeListener

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

the class MapperUI method createWindow.

public Shell createWindow(final Display display) {
    Shell activeShell = display.getActiveShell();
    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);
    }
    mapperShell.addShellListener(new ShellListener() {

        @Override
        public void shellActivated(ShellEvent e) {
        }

        @Override
        public void shellClosed(ShellEvent e) {
            if (editor != null && editor.isDirty() && !closeWithoutPrompt) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShell, "Close without save", Messages.getString("MapperUI.CloseWindow.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    prepareClosing(SWT.CANCEL);
                }
            }
        }

        @Override
        public void shellDeactivated(ShellEvent e) {
        }

        @Override
        public void shellDeiconified(ShellEvent e) {
        }

        @Override
        public void shellIconified(ShellEvent e) {
        }
    });
    mapperShell.setMaximized(true);
    mapperShell.setImage(CoreImageProvider.getComponentIcon(mapperComponent.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(productName + " - " + mapperComponent.getComponent().getName() + " - " + //$NON-NLS-1$
    mapperComponent.getUniqueName());
    GridLayout parentLayout = new GridLayout(1, true);
    mapperShell.setLayout(parentLayout);
    // Composite composite = new Composite(mapperShell, SWT.NONE);
    // composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
    mainSashForm = new SashForm(mapperShell, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    editor = new XmlMapEditor(mapperManager);
    editor.createPartControl(datasViewSashForm);
    if (copyOfMapData.getVarTables().isEmpty()) {
        VarTable varTable1 = XmlmapFactory.eINSTANCE.createVarTable();
        varTable1.setName("Var");
        varTable1.setMinimized(true);
        copyOfMapData.getVarTables().add(varTable1);
    }
    editor.setContent(copyOfMapData);
    tabFolderEditors = new TabFolderEditors(mainSashForm, mapperManager, SWT.BORDER);
    // selectFirstInOutTree();
    mainSashForm.setWeights(new int[] { 70, 30 });
    footerComposite = new FooterComposite(mapperShell, this);
    footerComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mapperShell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            ColorProviderMapper.releaseColors();
            FontProviderMapper.releaseFonts();
            ImageProviderMapper.releaseImages();
        }
    });
    editor.makeDefaultSelection();
    mapperShell.open();
    return mapperShell;
}
Also used : TabFolderEditors(org.talend.designer.xmlmap.ui.tabs.TabFolderEditors) DisposeListener(org.eclipse.swt.events.DisposeListener) FooterComposite(org.talend.designer.xmlmap.ui.footer.FooterComposite) ShellEvent(org.eclipse.swt.events.ShellEvent) IBrandingService(org.talend.core.ui.branding.IBrandingService) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XmlMapEditor(org.talend.designer.xmlmap.editor.XmlMapEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) SashForm(org.eclipse.swt.custom.SashForm) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ShellListener(org.eclipse.swt.events.ShellListener) GridData(org.eclipse.swt.layout.GridData)

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