Search in sources :

Example 66 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.

the class TabbedFolderPageEditor method createControl.

@Override
public void createControl(Composite parent) {
    editor = editorDescriptor.createEditor();
    final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
    if (ownerSite instanceof MultiPageEditorSite) {
        final MultiPageEditorPart ownerMultiPageEditor = ((MultiPageEditorSite) ownerSite).getMultiPageEditor();
        nestedEditorSite = new TabbedFolderPageEditorSite(ownerMultiPageEditor, editor);
        // We need it to tell owner editor about dirty state change
        if (ownerMultiPageEditor instanceof IPropertyChangeReflector) {
            editor.addPropertyListener(new IPropertyListener() {

                @Override
                public void propertyChanged(Object source, int propId) {
                    ((IPropertyChangeReflector) ownerMultiPageEditor).handlePropertyChange(propId);
                }
            });
        }
    } else {
        nestedEditorSite = new SubEditorSite(mainEditor.getEditorSite());
    }
    try {
        editor.init(nestedEditorSite, editorDescriptor.getNestedEditorInput(mainEditor.getEditorInput()));
    } catch (PartInitException e) {
        DBUserInterface.getInstance().showError("Create SQL viewer", null, e);
    }
    editor.createPartControl(parent);
    if (editor instanceof ISingleControlEditor) {
        // Use focus to active selection provider and contributed actions
        Control editorControl = ((ISingleControlEditor) editor).getEditorControl();
        assert editorControl != null;
        editorControl.addFocusListener(new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {
                ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
                mainEditor.getSite().setSelectionProvider(selectionProvider);
                if (actionContributor != null) {
                    actionContributor.setActiveEditor(editor);
                }
                activateNestedSite(true);
            }

            @Override
            public void focusLost(FocusEvent e) {
                activateNestedSite(false);
                if (actionContributor != null) {
                    actionContributor.setActiveEditor(null);
                }
            }
        });
    }
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (editor != null) {
                editor.dispose();
                editor = null;
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) FocusListener(org.eclipse.swt.events.FocusListener)

Example 67 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.

the class MetaDataPanel method createContents.

@Override
public Control createContents(final IResultSetPresentation presentation, Composite parent) {
    this.presentation = presentation;
    this.colorDisabled = presentation.getControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
    this.attributeList = new MetaDataTable(parent);
    this.attributeList.setFitWidth(false);
    this.attributeList.getItemsViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            DBDAttributeBinding attr = getSelectedAttribute();
            if (attr != null && !updateSelection) {
                if (isAttributeVisible(attr)) {
                    updateSelection = true;
                    try {
                        presentation.setCurrentAttribute(attr);
                    } finally {
                        updateSelection = false;
                    }
                }
            }
        }
    });
    if (this.presentation instanceof ISelectionProvider) {
        final ISelectionChangedListener listener = new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (!updateSelection && MetaDataPanel.this.presentation.getController().getVisiblePanel() == MetaDataPanel.this) {
                    DBDAttributeBinding attr = presentation.getCurrentAttribute();
                    if (attr != null && attr != getSelectedAttribute()) {
                        updateSelection = true;
                        try {
                            attributeList.getItemsViewer().setSelection(new StructuredSelection(attr));
                        } finally {
                            updateSelection = false;
                        }
                    }
                }
            }
        };
        ((ISelectionProvider) this.presentation).addSelectionChangedListener(listener);
        attributeList.getControl().addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                ((ISelectionProvider) presentation).removeSelectionChangedListener(listener);
            }
        });
    }
    return this.attributeList;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 68 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project dbeaver by dbeaver.

the class EmptyPresentation method createPresentation.

@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    UIUtils.createHorizontalLine(parent);
    placeholder = new Canvas(parent, SWT.NONE);
    placeholder.setLayoutData(new GridData(GridData.FILL_BOTH));
    placeholder.setBackground(controller.getDefaultBackground());
    final Font normalFont = parent.getFont();
    FontData[] fontData = normalFont.getFontData();
    fontData[0].setStyle(fontData[0].getStyle() | SWT.BOLD);
    fontData[0].setHeight(18);
    final Font largeFont = new Font(normalFont.getDevice(), fontData[0]);
    placeholder.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            UIUtils.dispose(largeFont);
        }
    });
    placeholder.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (controller.isRefreshInProgress()) {
                return;
            }
            e.gc.setFont(largeFont);
            int fontSize = largeFont.getFontData()[0].getHeight();
            UIUtils.drawMessageOverControl(placeholder, e, CoreMessages.sql_editor_resultset_filter_panel_control_no_data, -(fontSize / 2));
            e.gc.setFont(normalFont);
            if (controller.getDataContainer() instanceof SQLEditor.QueryResultsContainer) {
                String execQuery = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_STATEMENT, controller.getSite(), true);
                String execScript = ActionUtils.findCommandDescription(CoreCommands.CMD_EXECUTE_SCRIPT, controller.getSite(), true);
                UIUtils.drawMessageOverControl(placeholder, e, NLS.bind(CoreMessages.sql_editor_resultset_filter_panel_control_execute_to_see_reslut, execQuery, execScript), fontSize + fontSize / 3);
            }
        }
    });
    trackPresentationControl();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) FontData(org.eclipse.swt.graphics.FontData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData)

Example 69 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project yamcs-studio by yamcs.

the class OverviewOutlinePage method createControl.

@Override
public void createControl(Composite parent) {
    overview = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(overview);
    thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
    thumbnail.setBorder(new MarginBorder(3));
    thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
    lws.setContents(thumbnail);
    disposeListener = new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (thumbnail != null) {
                thumbnail.deactivate();
                thumbnail = null;
            }
        }
    };
    rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Canvas(org.eclipse.swt.widgets.Canvas) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Example 70 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project tmdm-studio-se by Talend.

the class ValidationRuleDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(this.title);
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(2, false));
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.ValidationRuleDialog_);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
    text = new Text(composite, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
    columns = new ComplexTableViewerColumn[] { new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Type", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.COMBO_STYLE, IConstants.SCHEMATRON_TYPES, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Context XPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", ComplexTableViewerColumn.XPATH_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Expression", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.VALIDATIONRULE_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Message", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.MULTIMESSAGE_STYLE, new String[] {}, 0) };
    columns[0].setColumnWidth(70);
    columns[1].setColumnWidth(130);
    columns[2].setColumnWidth(300);
    columns[3].setColumnWidth(300);
    viewer = getNewTisTableViewer(Arrays.asList(columns), WidgetFactory.getWidgetFactory(), composite);
    Map<ComplexTableViewerColumn, IXPathValidator> validators = new HashMap<ComplexTableViewerColumn, IXPathValidator>();
    // set to "Context XPath" column the xpath validator
    validators.put(columns[1], new DefaultXPathValidator());
    viewer.setValidators(validators);
    // Modified by hhb,to fix bug 21784
    TreeParent treeParent = (TreeParent) page.getAdapter(TreeParent.class);
    viewer.setTreeParent(treeParent);
    // The ending| bug:21784
    viewer.setXpath(true);
    // viewer.setMainPage(page);
    String modelName = page.getDataModel().getName();
    viewer.setDatamodelName(modelName);
    viewer.setConceptName(conceptName);
    viewer.setContext(true);
    viewer.create();
    viewer.getViewer().setInput(parseRules());
    viewer.setHeight(110);
    viewer.setWidth(800);
    viewer.getMainComposite().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3));
    parent.getShell().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            XpathSelectDialog.setContext(null);
        }
    });
    return composite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) ComplexTableViewerColumn(com.amalto.workbench.widgets.ComplexTableViewerColumn) DefaultXPathValidator(com.amalto.workbench.widgets.celleditor.DefaultXPathValidator) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IXPathValidator(com.amalto.workbench.widgets.celleditor.IXPathValidator) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)366 DisposeListener (org.eclipse.swt.events.DisposeListener)363 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)75 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)70 Image (org.eclipse.swt.graphics.Image)53 Cursor (org.eclipse.swt.graphics.Cursor)49 Label (org.eclipse.swt.widgets.Label)42 ToolBar (org.eclipse.swt.widgets.ToolBar)42 Point (org.eclipse.swt.graphics.Point)38 Control (org.eclipse.swt.widgets.Control)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 Color (org.eclipse.swt.graphics.Color)34 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31