提交 324714b5 编写于 作者: S serge-rider

Version update dialog refactoring

上级 558aef22
......@@ -8,7 +8,8 @@ Bundle-ActivationPolicy: lazy
Bundle-Version: 6.0.0.qualifier
Bundle-Release-Date: 20190311
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.jkiss.dbeaver.core.application
Export-Package: org.jkiss.dbeaver.core.application,
org.jkiss.dbeaver.core.application.update
Bundle-ClassPath: .
Require-Bundle: org.eclipse.osgi,
org.eclipse.equinox.app,
......
......@@ -37,10 +37,13 @@ import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.application.rpc.DBeaverInstanceServer;
import org.jkiss.dbeaver.core.application.rpc.IInstanceController;
import org.jkiss.dbeaver.core.application.update.VersionUpdateDialog;
import org.jkiss.dbeaver.model.app.DBASecureStorage;
import org.jkiss.dbeaver.model.app.DBPApplication;
import org.jkiss.dbeaver.model.impl.app.DefaultSecureStorage;
import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.registry.updater.VersionDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.SystemVariablesResolver;
import org.jkiss.utils.CommonUtils;
......@@ -423,6 +426,14 @@ public class DBeaverApplication implements IApplication, DBPApplication {
return msgResult;
}
public void notifyVersionUpgrade(VersionDescriptor versionDescriptor, boolean showSkip) {
VersionUpdateDialog dialog = new VersionUpdateDialog(
UIUtils.getActiveWorkbenchShell(),
versionDescriptor,
showSkip);
dialog.open();
}
private static class BundleLoadListener implements BundleListener {
@Override
public void bundleChanged(BundleEvent event) {
......
......@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Status;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.application.DBeaverApplication;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.registry.updater.VersionDescriptor;
......@@ -116,11 +117,7 @@ public class DBeaverVersionChecker extends AbstractJob {
private void showUpdaterDialog(final VersionDescriptor versionDescriptor)
{
UIUtils.asyncExec(() -> {
VersionUpdateDialog dialog = new VersionUpdateDialog(
UIUtils.getActiveWorkbenchShell(),
versionDescriptor,
!showAlways);
dialog.open();
DBeaverApplication.getInstance().notifyVersionUpgrade(versionDescriptor, !showAlways);
});
}
}
......@@ -33,19 +33,27 @@ import org.jkiss.dbeaver.ui.ActionUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.utils.GeneralUtils;
class VersionUpdateDialog extends Dialog {
public class VersionUpdateDialog extends Dialog {
private VersionDescriptor newVersion;
private static final int INFO_ID = 1000;
private Font boldFont;
private boolean autoCheck;
private boolean showConfig;
private Button dontShowAgainCheck;
public VersionUpdateDialog(Shell parentShell, VersionDescriptor newVersion, boolean autoCheck)
public VersionUpdateDialog(Shell parentShell, VersionDescriptor newVersion, boolean showConfig)
{
super(parentShell);
this.newVersion = newVersion;
this.autoCheck = autoCheck;
this.showConfig = showConfig;
}
public VersionDescriptor getNewVersion() {
return newVersion;
}
public boolean isShowConfig() {
return showConfig;
}
@Override
......@@ -63,6 +71,8 @@ class VersionUpdateDialog extends Dialog {
composite.setLayout(new GridLayout(1, false));
Composite propGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_version_update_title, 2, GridData.FILL_BOTH, 0);
createTopArea(composite);
boldFont = UIUtils.makeBoldFont(composite.getFont());
final Label titleLabel = new Label(propGroup, SWT.NONE);
......@@ -104,9 +114,19 @@ class VersionUpdateDialog extends Dialog {
hintLabel.setFont(boldFont);
}
createBottomArea(composite);
return parent;
}
protected void createTopArea(Composite composite) {
}
protected void createBottomArea(Composite composite) {
}
@Override
public boolean close()
{
......@@ -117,7 +137,7 @@ class VersionUpdateDialog extends Dialog {
@Override
protected void createButtonsForButtonBar(Composite parent)
{
if (autoCheck && newVersion != null) {
if (showConfig && newVersion != null) {
((GridLayout) parent.getLayout()).numColumns++;
dontShowAgainCheck = UIUtils.createCheckbox(parent, "Don't show for the version " + newVersion.getPlainVersion(), false);
}
......
......@@ -62,6 +62,10 @@ public class VersionDescriptor {
return programVersion;
}
public void setProgramVersion(Version programVersion) {
this.programVersion = programVersion;
}
public String getPlainVersion() {
return programVersion.getMajor() + "." + programVersion.getMinor() + "." + programVersion.getMicro();
}
......@@ -70,6 +74,10 @@ public class VersionDescriptor {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getBaseURL() {
return baseURL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册