提交 0ef10b1b 编写于 作者: J jurgen

Model code cleanup

上级 33a430b2
......@@ -45,7 +45,6 @@ public class LoadingJob<RESULT> extends AbstractJob {
this.loadingService = loadingService;
this.visualizer = visualizer;
setUser(false);
setRule(new NonConflictingRule());
}
public ILoadService<RESULT> getLoadingService()
......
......@@ -41,7 +41,6 @@ class LoadingUIJob<RESULT> extends AbstractUIJob {
this.visualizer = loadingJob.getVisualizer();
this.mainMonitor = mainMonitor;
setSystem(true);
setRule(new NonConflictingRule());
}
@Override
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.runtime.load.jobs;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
public class NonConflictingRule implements ISchedulingRule
{
@Override
public boolean contains(ISchedulingRule rule)
{
return rule == this;
}
@Override
public boolean isConflicting(ISchedulingRule rule)
{
return rule == this;
}
}
\ No newline at end of file
......@@ -23,20 +23,21 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPEvent;
import org.jkiss.dbeaver.model.access.DBAAuthInfo;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.runtime.DBRProcessListener;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer;
import org.jkiss.dbeaver.model.ui.DBUserInterface;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.runtime.jobs.ConnectJob;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.actions.DataSourceHandler;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionAuthDialog;
import org.jkiss.utils.ArrayUtils;
public class DataSourceConnectHandler extends DataSourceHandler
......@@ -96,8 +97,7 @@ public class DataSourceConnectHandler extends DataSourceHandler
if (onFinish != null) {
onFinish.onProcessFinish(result);
} else if (!result.isOK()) {
UIUtils.showErrorDialog(
null,
DBUserInterface.getInstance().showError(
connectJob.getName(),
null,//NLS.bind(CoreMessages.runtime_jobs_connect_status_error, dataSourceContainer.getName()),
result);
......@@ -156,27 +156,34 @@ public class DataSourceConnectHandler extends DataSourceHandler
false);
}
public static boolean askForPassword(@NotNull final DataSourceDescriptor dataSourceContainer, @Nullable final DBWHandlerConfiguration handler)
public static boolean askForPassword(@NotNull final DataSourceDescriptor dataSourceContainer, @Nullable final DBWHandlerConfiguration networkHandler)
{
final boolean[] authResult = new boolean[] { false };
UIUtils.runInUI(null, new Runnable() {
@Override
public void run()
{
ConnectionAuthDialog auth = new ConnectionAuthDialog(UIUtils.getActiveShell(), dataSourceContainer, handler);
int result = auth.open();
if (result == IDialogConstants.OK_ID) {
if (dataSourceContainer.isSavePassword()) {
// Update connection properties
dataSourceContainer.getRegistry().updateDataSource(dataSourceContainer);
}
authResult[0] = true;
} else {
authResult[0] = false;
}
}
});
return authResult[0];
String prompt = networkHandler != null ?
NLS.bind(CoreMessages.dialog_connection_auth_title_for_handler, networkHandler.getTitle()) :
"'" + dataSourceContainer.getName() + CoreMessages.dialog_connection_auth_title; //$NON-NLS-1$
String user = networkHandler != null ? networkHandler.getUserName() : dataSourceContainer.getConnectionInfo().getUserName();
String password = networkHandler != null ? networkHandler.getPassword() : dataSourceContainer.getConnectionInfo().getUserPassword();
DBAAuthInfo authInfo = DBUserInterface.getInstance().promptUserCredentials(prompt, user, password);
if (authInfo == null) {
return false;
}
if (networkHandler != null) {
networkHandler.setUserName(authInfo.getUserName());
networkHandler.setPassword(authInfo.getUserPassword());
networkHandler.setSavePassword(authInfo.isSavePassword());
} else {
dataSourceContainer.getConnectionInfo().setUserName(authInfo.getUserName());
dataSourceContainer.getConnectionInfo().setUserPassword(authInfo.getUserPassword());
dataSourceContainer.setSavePassword(authInfo.isSavePassword());
}
if (dataSourceContainer.isSavePassword()) {
// Update connection properties
dataSourceContainer.getRegistry().updateDataSource(dataSourceContainer);
}
return true;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.ui.dialogs.connection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.utils.CommonUtils;
/**
* Connection auth dialog
*/
public class ConnectionAuthDialog extends BaseAuthDialog
{
private DataSourceDescriptor dataSource;
private DBWHandlerConfiguration networkHandler;
public ConnectionAuthDialog(@NotNull Shell parentShell, @NotNull DataSourceDescriptor dataSource, @Nullable DBWHandlerConfiguration networkHandler)
{
super(parentShell,
networkHandler != null ?
NLS.bind(CoreMessages.dialog_connection_auth_title_for_handler, networkHandler.getTitle()) :
"'" + dataSource.getName() + CoreMessages.dialog_connection_auth_title //$NON-NLS-1$
);
this.dataSource = dataSource;
this.networkHandler = networkHandler;
if (networkHandler != null) {
setUserName(CommonUtils.notEmpty(networkHandler.getUserName()));
setUserPassword(CommonUtils.notEmpty(networkHandler.getPassword()));
} else {
setUserName(CommonUtils.notEmpty(dataSource.getConnectionInfo().getUserName()));
setUserPassword(CommonUtils.notEmpty(dataSource.getConnectionInfo().getUserPassword()));
}
}
@Override
protected void okPressed() {
super.okPressed();
if (networkHandler != null) {
networkHandler.setUserName(getUserName());
networkHandler.setPassword(getUserPassword());
networkHandler.setSavePassword(isSavePassword());
} else {
dataSource.getConnectionInfo().setUserName(getUserName());
dataSource.getConnectionInfo().setUserPassword(getUserPassword());
dataSource.setSavePassword(isSavePassword());
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册