use of org.talend.repository.nosql.metadata.IMetadataProvider in project tbd-studio-se by Talend.
the class AbstractNoSQLConnForm method addUtilsButtonListeners.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#addUtilsButtonListeners()
*/
@Override
protected void addUtilsButtonListeners() {
if (checkBtn != null) {
checkBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
try {
if (getConnection() != null) {
final AtomicBoolean checkedResult = new AtomicBoolean(true);
final Thread[] t = new Thread[1];
final Exception[] exception = new Exception[1];
IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
t[0] = Thread.currentThread();
IMetadataProvider metadataProvider = NoSQLRepositoryFactory.getInstance().getMetadataProvider(getConnection().getDbType());
if (metadataProvider != null) {
try {
checkedResult.set(metadataProvider.checkConnection(getConnection()));
} catch (NoSQLServerException e) {
exception[0] = e;
checkedResult.set(false);
ExceptionHandler.process(e);
}
}
}
};
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()) {
protected void cancelPressed() {
super.cancelPressed();
t[0].interrupt();
}
};
dialog.run(true, true, runnableWithProgress);
if (!checkedResult.get() && exception[0] != null) {
new ErrorDialogWidthDetailArea(getShell(), RepositoryNoSQLPlugin.PLUGIN_ID, // $NON-NLS-1$
Messages.getString("AbstractNoSQLConnForm.checkFailed"), ExceptionUtils.getFullStackTrace(exception[0]));
} else {
MessageDialog.openInformation(getShell(), Messages.getString("AbstractNoSQLConnForm.checkConn"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("AbstractNoSQLConnForm.checkSuccessful"));
}
}
} catch (Exception exception) {
new ErrorDialogWidthDetailArea(getShell(), RepositoryNoSQLPlugin.PLUGIN_ID, Messages.getString(// $NON-NLS-1$
"AbstractNoSQLConnForm.checkFailed"), ExceptionUtils.getFullStackTrace(exception));
ExceptionHandler.process(exception);
}
}
});
}
}
Aggregations