提交 28b60e66 编写于 作者: J jurgen

Driver files download wizard & driver editor dialog

上级 e041f4fe
......@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.jkiss.code.NotNull;
......@@ -41,6 +40,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.runtime.OSDescriptor;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.AcceptLicenseDialog;
import org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog;
......@@ -958,7 +958,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
@Override
public void run() {
// Open vendor's web site
Program.launch(fileSource.getUrl());
RuntimeUtils.openWebBrowser(fileSource.getUrl());
// Open driver editor
DriverEditDialog dialog = new DriverEditDialog(DBeaverUI.getActiveWorkbenchShell(), DriverDescriptor.this);
dialog.open();
......
......@@ -174,6 +174,15 @@ public class RuntimeUtils {
Program.launch(path);
}
public static void openWebBrowser(String url)
{
url = url.trim();
if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("ftp://")) {
url = "http://" + url;
}
Program.launch(url);
}
public static File getPlatformFile(String platformURL) throws IOException
{
URL url = new URL(platformURL);
......
......@@ -968,7 +968,12 @@ public class UIUtils {
public static void showPreferencesFor(Shell shell, Object element, String defPageID)
{
PreferenceDialog propDialog = PreferencesUtil.createPropertyDialogOn(shell, element, defPageID, null, null, PreferencesUtil.OPTION_NONE);
PreferenceDialog propDialog;
if (element == null) {
propDialog = PreferencesUtil.createPreferenceDialogOn(shell, defPageID, new String[] { defPageID }, null, PreferencesUtil.OPTION_NONE);
} else {
propDialog = PreferencesUtil.createPropertyDialogOn(shell, element, defPageID, null, null, PreferencesUtil.OPTION_NONE);
}
if (propDialog != null) {
propDialog.open();
}
......
......@@ -17,19 +17,21 @@
*/
package org.jkiss.dbeaver.ui.dialogs.driver;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor;
import org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
import org.jkiss.dbeaver.ui.preferences.PrefPageDrivers;
import org.jkiss.utils.CommonUtils;
class DriverDownloadAutoPage extends WizardPage {
......@@ -44,7 +46,7 @@ class DriverDownloadAutoPage extends WizardPage {
@Override
public void createControl(Composite parent) {
DriverDownloadWizard wizard = (DriverDownloadWizard) getWizard();
DriverDescriptor driver = wizard.getDriver();
final DriverDescriptor driver = wizard.getDriver();
setMessage("Download " + driver.getFullName() + " driver files");
......@@ -70,43 +72,36 @@ class DriverDownloadAutoPage extends WizardPage {
{
Composite linksGroup = UIUtils.createPlaceholder(composite, 2);
linksGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite configGroup = UIUtils.createPlaceholder(linksGroup, 1);
configGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Maven/repo config
UIUtils.createLink(
configGroup,
"<a>Repository configuration</a>",
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
// Proxy config
UIUtils.createLink(
configGroup,
"<a>Proxy configration</a>",
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
Composite webGroup = UIUtils.createPlaceholder(linksGroup, 1);
webGroup.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END));
// Vendor site
if (!CommonUtils.isEmpty(driver.getWebURL())) {
Link link = UIUtils.createLink(
webGroup,
linksGroup,
"Vendor's website: <a href=\"" + driver.getWebURL() + "\">" + driver.getWebURL() + "</a>",
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
RuntimeUtils.openWebBrowser(driver.getWebURL());
}
});
link.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END));
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
} else {
UIUtils.createPlaceholder(linksGroup, 1).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Link link = UIUtils.createLink(
linksGroup,
"<a>Download configuration</a>",
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIUtils.showPreferencesFor(
DBeaverUI.getActiveWorkbenchShell(),
null,
PrefPageDrivers.PAGE_ID);
}
});
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END));
}
setControl(composite);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册