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;
}
}
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);
}
}
}
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();
}
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();
}
Aggregations