Search in sources :

Example 1 with IDialogPage

use of org.eclipse.jface.dialogs.IDialogPage in project dbeaver by serge-rider.

the class ConnectionPageSettings method getSubPages.

@Nullable
@Override
public IDialogPage[] getSubPages() {
    if (subPages != null) {
        return subPages;
    }
    if (this.connectionEditor == null) {
        this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
        this.connectionEditor.setSite(this);
    }
    if (connectionEditor instanceof ICompositeDialogPage) {
        subPages = ((ICompositeDialogPage) connectionEditor).getSubPages();
        if (!ArrayUtils.isEmpty(subPages)) {
            for (IDialogPage page : subPages) {
                if (page instanceof IDataSourceConnectionEditor) {
                    ((IDataSourceConnectionEditor) page).setSite(this);
                }
            }
        }
        if (extraPages != null) {
            subPages = ArrayUtils.concatArrays(subPages, extraPages);
        }
        return subPages;
    } else {
        return extraPages;
    }
}
Also used : IDialogPage(org.eclipse.jface.dialogs.IDialogPage) Nullable(org.jkiss.code.Nullable)

Example 2 with IDialogPage

use of org.eclipse.jface.dialogs.IDialogPage in project dbeaver by serge-rider.

the class ConnectionPageSettings method activateCurrentItem.

private void activateCurrentItem() {
    if (tabFolder != null) {
        TabItem[] selection = tabFolder.getSelection();
        if (selection.length == 1) {
            IDialogPage page = (IDialogPage) selection[0].getData();
            page.setVisible(true);
        }
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) IDialogPage(org.eclipse.jface.dialogs.IDialogPage)

Example 3 with IDialogPage

use of org.eclipse.jface.dialogs.IDialogPage in project dbeaver by serge-rider.

the class ConnectionPageSettings method createProviderPage.

private void createProviderPage(Composite parent) {
    if (this.connectionEditor != null && this.connectionEditor.getControl() != null) {
        return;
    }
    if (getControl() != null) {
        getControl().dispose();
    }
    try {
        if (this.connectionEditor == null) {
            this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
            this.connectionEditor.setSite(this);
        }
        // init sub pages (if any)
        getSubPages();
        if (wizard.isNew() && !ArrayUtils.isEmpty(subPages)) {
            // Create tab folder
            List<IDialogPage> allPages = new ArrayList<>();
            allPages.add(connectionEditor);
            Collections.addAll(allPages, subPages);
            tabFolder = new TabFolder(parent, SWT.TOP);
            tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
            setControl(tabFolder);
            for (IDialogPage page : allPages) {
                TabItem item = new TabItem(tabFolder, SWT.NONE);
                page.createControl(tabFolder);
                item.setData(page);
                Control pageControl = page.getControl();
                item.setControl(pageControl);
                item.setText(CommonUtils.isEmpty(page.getTitle()) ? "General" : page.getTitle());
                item.setToolTipText(page.getDescription());
            }
            tabFolder.setSelection(0);
            tabFolder.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    activateCurrentItem();
                }
            });
        } else {
            // Create single editor control
            this.connectionEditor.createControl(parent);
            setControl(this.connectionEditor.getControl());
        }
        UIUtils.setHelp(getControl(), IHelpContextIds.CTX_CON_WIZARD_SETTINGS);
    } catch (Exception ex) {
        log.warn(ex);
        setErrorMessage("Can't create settings dialog: " + ex.getMessage());
    }
    parent.layout();
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Control(org.eclipse.swt.widgets.Control) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) TabFolder(org.eclipse.swt.widgets.TabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 4 with IDialogPage

use of org.eclipse.jface.dialogs.IDialogPage in project dbeaver by serge-rider.

the class ConnectionPageSettings method activatePage.

@Override
public void activatePage() {
    if (connectionEditor == null) {
        createProviderPage(getControl().getParent());
    //UIUtils.resizeShell(getWizard().getContainer().getShell());
    }
    setMessage(NLS.bind(CoreMessages.dialog_connection_message, getDriver().getFullName()));
    DataSourceDescriptor connectionInfo = getActiveDataSource();
    if (!activated.contains(connectionInfo)) {
        if (this.connectionEditor != null) {
            this.connectionEditor.loadSettings();
        }
        if (subPages != null) {
            for (IDialogPage page : subPages) {
                Control pageControl = page.getControl();
                //                    }
                if (pageControl != null && page instanceof IDataSourceConnectionEditor) {
                    ((IDataSourceConnectionEditor) page).loadSettings();
                }
            }
        }
        activated.add(connectionInfo);
    } else if (connectionEditor != null) {
        connectionEditor.loadSettings();
    }
    activateCurrentItem();
    getContainer().updateTitleBar();
}
Also used : Control(org.eclipse.swt.widgets.Control) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor)

Aggregations

IDialogPage (org.eclipse.jface.dialogs.IDialogPage)4 Control (org.eclipse.swt.widgets.Control)2 TabItem (org.eclipse.swt.widgets.TabItem)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 TabFolder (org.eclipse.swt.widgets.TabFolder)1 Nullable (org.jkiss.code.Nullable)1 DataSourceDescriptor (org.jkiss.dbeaver.registry.DataSourceDescriptor)1