提交 e041f4fe 编写于 作者: J jurgen

Driver files download wizard & driver editor dialog

上级 6422df6a
......@@ -152,28 +152,24 @@ public class AboutBoxDialog extends Dialog
gd.horizontalAlignment = GridData.CENTER;
authorLabel.setLayoutData(gd);
Link siteLink = new Link(group, SWT.NONE);
siteLink.setText(UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)));
siteLink.setBackground(background);
siteLink.addSelectionListener(new SelectionAdapter() {
Link siteLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RuntimeUtils.launchProgram(e.text);
}
});
siteLink.setBackground(background);
gd = new GridData();
gd.horizontalAlignment = GridData.CENTER;
siteLink.setLayoutData(gd);
Link emailLink = new Link(group, SWT.NONE);
emailLink.setText(UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_EMAIL)));
emailLink.setBackground(background);
emailLink.addSelectionListener(new SelectionAdapter() {
Link emailLink = UIUtils.createLink(group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_EMAIL)), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RuntimeUtils.launchProgram("mailto:" + e.text); //$NON-NLS-1$
}
});
emailLink.setBackground(background);
gd = new GridData();
gd.horizontalAlignment = GridData.CENTER;
emailLink.setLayoutData(gd);
......
......@@ -825,10 +825,10 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
public void loadDriver(DBRRunnableContext runnableContext)
throws DBException
{
this.loadDriver(runnableContext, false);
this.loadDriver(runnableContext, false, false);
}
public void loadDriver(DBRRunnableContext runnableContext, boolean forceReload)
public void loadDriver(DBRRunnableContext runnableContext, boolean forceReload, boolean omitDownload)
throws DBException
{
if (isLoaded && !forceReload) {
......@@ -836,7 +836,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
}
isLoaded = false;
loadLibraries(runnableContext);
loadLibraries(runnableContext, omitDownload);
if (!acceptDriverLicenses(runnableContext)) {
throw new DBException("You have to accept driver '" + getFullName() + "' license to be able to connect");
......@@ -872,12 +872,14 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
}
}
private void loadLibraries(DBRRunnableContext runnableContext)
private void loadLibraries(DBRRunnableContext runnableContext, boolean omitDownload)
throws DBException
{
this.classLoader = null;
validateFilesPresence(runnableContext);
if (!omitDownload) {
validateFilesPresence(runnableContext);
}
List<URL> libraryURLs = new ArrayList<URL>();
// Load libraries
......@@ -920,7 +922,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
final List<DriverFileDescriptor> downloadCandidates = new ArrayList<DriverFileDescriptor>();
for (DriverFileDescriptor file : files) {
if (file.isDisabled() || !file.isLocal()) {
if (file.isDisabled() || !file.isDownloadable()) {
// Nothing we can do about it
continue;
}
......
......@@ -138,7 +138,7 @@ public class DriverFileDescriptor implements DBPDriverFile
}
@Override
public boolean isLocal()
public boolean isDownloadable()
{
return isRepositoryArtifact() || isMavenArtifact();
}
......
......@@ -1226,6 +1226,13 @@ public class UIUtils {
return saveRunner.getResult();
}
public static Link createLink(Composite parent, String text, SelectionListener listener) {
Link link = new Link(parent, SWT.NONE);
link.setText(text);
link.addSelectionListener(listener);
return link;
}
public static CellEditor createPropertyEditor(Composite parent, DBPPropertySource source, DBPPropertyDescriptor property)
{
if (source == null) {
......
......@@ -425,9 +425,7 @@ class ConnectionPageGeneral extends ActiveWizardPage<ConnectionWizard> {
for (int i = 0; i < filters.size(); i++) {
final FilterInfo filterInfo = filters.get(i);
filterInfo.link = new Link(filtersGroup,SWT.NONE);
filterInfo.link.setText("<a>" + filterInfo.title + "</a>");
filterInfo.link.addSelectionListener(new SelectionAdapter() {
filterInfo.link = UIUtils.createLink(filtersGroup, "<a>" + filterInfo.title + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EditObjectFilterDialog dialog = new EditObjectFilterDialog(
......
......@@ -81,9 +81,7 @@ public class EditObjectFilterDialog extends HelpEnabledDialog {
enableButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
enableButton.setSelection(filter.isEnabled());
if (!globalFilter) {
Link globalLink = new Link(topPanel, SWT.NONE);
globalLink.setText(CoreMessages.dialog_filter_global_link);
globalLink.addSelectionListener(new SelectionAdapter() {
Link globalLink = UIUtils.createLink(topPanel, CoreMessages.dialog_filter_global_link, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setReturnCode(SHOW_GLOBAL_FILTERS_ID);
......
......@@ -17,12 +17,10 @@
*/
package org.jkiss.dbeaver.ui.dialogs.data;
import org.eclipse.jface.action.IContributionManager;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
......@@ -39,8 +37,10 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
......@@ -52,8 +52,8 @@ import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.runtime.jobs.DataSourceJob;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIIcon;
......@@ -61,8 +61,6 @@ import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerObjectOpen;
import org.jkiss.dbeaver.ui.controls.ColumnInfoPanel;
import org.jkiss.dbeaver.ui.data.*;
import org.jkiss.dbeaver.ui.data.IAttributeController;
import org.jkiss.dbeaver.ui.data.IValueController;
import org.jkiss.dbeaver.ui.data.managers.BaseValueManager;
import org.jkiss.dbeaver.ui.dialogs.struct.EditDictionaryDialog;
import org.jkiss.dbeaver.ui.editors.data.DatabaseDataEditor;
......@@ -439,11 +437,10 @@ public abstract class ValueViewDialog extends Dialog implements IValueEditorStan
final DBSEntityAssociation association = (DBSEntityAssociation)refConstraint;
final DBSEntity refTable = association.getReferencedConstraint().getParentObject();
Composite labelGroup = UIUtils.createPlaceholder(parent, 2);
labelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_HORIZONTAL));
Link dictLabel = new Link(labelGroup, SWT.NONE);
dictLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
dictLabel.setText(NLS.bind(CoreMessages.dialog_value_view_label_dictionary, refTable.getName()));
dictLabel.addSelectionListener(new SelectionAdapter() {
labelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Link dictLabel = UIUtils.createLink(
labelGroup,
NLS.bind(CoreMessages.dialog_value_view_label_dictionary, refTable.getName()), new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Open
......@@ -465,11 +462,9 @@ public abstract class ValueViewDialog extends Dialog implements IValueEditorStan
});
}
});
dictLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Link hintLabel = new Link(labelGroup, SWT.NONE);
hintLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END));
hintLabel.setText("(<a>Define Description</a>)");
hintLabel.addSelectionListener(new SelectionAdapter() {
Link hintLabel = UIUtils.createLink(labelGroup, "(<a>Define Description</a>)", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EditDictionaryDialog dialog = new EditDictionaryDialog(getShell(), "Dictionary structure", refTable);
......@@ -478,6 +473,7 @@ public abstract class ValueViewDialog extends Dialog implements IValueEditorStan
}
}
});
hintLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END));
}
editorSelector = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
......
......@@ -20,15 +20,17 @@ 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.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor;
import org.jkiss.dbeaver.tools.transfer.wizard.DataTransferWizard;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
import org.jkiss.utils.CommonUtils;
class DriverDownloadAutoPage extends WizardPage {
......@@ -42,13 +44,17 @@ class DriverDownloadAutoPage extends WizardPage {
@Override
public void createControl(Composite parent) {
DriverDownloadWizard wizard = (DriverDownloadWizard) getWizard();
DriverDescriptor driver = wizard.getDriver();
setMessage("Download " + driver.getFullName() + " driver files");
StringBuilder message = new StringBuilder();
message.append("Download ").append(wizard.getDriver().getFullName()).append(" driver files:\n");
for (DriverFileDescriptor file : wizard.getDriver().getDriverFiles()) {
message.append("\t-").append(file.getPath()).append("\n");
message.append("").append(driver.getFullName())
.append(" driver files are missing.\nDBeaver can download these files automatically.\n\nFiles required by driver:");
for (DriverFileDescriptor file : driver.getDriverFiles()) {
message.append("\n\t-").append(file.getPath());
}
message.append("\n\nOr you can obtain driver files by yourself and add them in driver editor.");
initializeDialogUnits(parent);
Composite composite = UIUtils.createPlaceholder(parent, 1);
......@@ -56,11 +62,54 @@ class DriverDownloadAutoPage extends WizardPage {
Text infoText = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
infoText.setText(message.toString());
infoText.setLayoutData(new GridData(GridData.FILL_BOTH));
infoText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
setControl(composite);
//UIUtils.createHorizontalLine(composite);
UIUtils.createPlaceholder(composite, 1).setLayoutData(new GridData(GridData.FILL_BOTH));
{
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) {
setMessage("Download " + wizard.getDriver().getFullName() + " driver files");
}
});
// 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,
"Vendor's website: <a href=\"" + driver.getWebURL() + "\">" + driver.getWebURL() + "</a>",
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
}
});
link.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END));
}
}
setControl(composite);
}
......
......@@ -23,7 +23,9 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils;
/**
......@@ -54,4 +56,14 @@ public class DriverDownloadDialog extends WizardDialog
finishButton.setText("Open Download Page");
}
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == EDIT_DRIVER_BUTTON_ID) {
cancelPressed();
DriverEditDialog dialog = new DriverEditDialog(DBeaverUI.getActiveWorkbenchShell(), driver);
dialog.open();
}
super.buttonPressed(buttonId);
}
}
......@@ -72,4 +72,6 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard {
return true;
}
}
\ No newline at end of file
......@@ -17,12 +17,10 @@
*/
package org.jkiss.dbeaver.ui.dialogs.driver;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CellLabelProvider;
......@@ -37,15 +35,18 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDriverFile;
import org.jkiss.dbeaver.registry.DataSourceProviderDescriptor;
import org.jkiss.dbeaver.registry.DriverDescriptor;
import org.jkiss.dbeaver.registry.DriverFileDescriptor;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIIcon;
......@@ -55,7 +56,6 @@ import org.jkiss.dbeaver.ui.controls.ConnectionPropertiesControl;
import org.jkiss.dbeaver.ui.controls.ListContentProvider;
import org.jkiss.dbeaver.ui.dialogs.HelpEnabledDialog;
import org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.ArrayUtils;
......@@ -220,9 +220,7 @@ public class DriverEditDialog extends HelpEnabledDialog
gl.horizontalSpacing = 5;
UIUtils.createControlLabel(ph, CoreMessages.dialog_edit_driver_label_website);
Link urlLabel = new Link(ph, SWT.NONE);
urlLabel.setText("<a>" + driver.getWebURL() + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
urlLabel.addSelectionListener(new SelectionAdapter() {
Link urlLabel = UIUtils.createLink(ph, "<a>" + driver.getWebURL() + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
......@@ -711,7 +709,7 @@ public class DriverEditDialog extends HelpEnabledDialog
provider.getRegistry().saveDrivers();
try {
driver.loadDriver(DBeaverUI.getDefaultRunnableContext(), true);
driver.loadDriver(DBeaverUI.getDefaultRunnableContext(), true, true);
} catch (Throwable ex) {
UIUtils.showErrorDialog(getShell(), CoreMessages.dialog_edit_driver_dialog_driver_error_title, CoreMessages.dialog_edit_driver_dialog_driver_error_message, ex);
}
......
......@@ -34,9 +34,9 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPContextProvider;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
......@@ -198,11 +198,7 @@ public abstract class TargetPrefPage extends PreferencePage implements IWorkbenc
private Link createLink(Composite composite, String text)
{
Link link = new Link(composite, SWT.NONE);
link.setFont(composite.getFont());
link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
link.addSelectionListener(new SelectionListener()
{
Link link = UIUtils.createLink(composite, "<A>" + text + "</A>", new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e)
{
......@@ -215,6 +211,7 @@ public abstract class TargetPrefPage extends PreferencePage implements IWorkbenc
widgetSelected(e);
}
});
link.setFont(composite.getFont());
return link;
}
......
......@@ -57,7 +57,7 @@ public interface DBPDriverFile
boolean isDisabled();
boolean isLocal();
boolean isDownloadable();
@Nullable
File getLocalFile();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册