/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.dialogs;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.utils.GeneralUtils;
/**
* ConnectionLostDialog
*/
public class ConnectionLostDialog extends ErrorDialog {
private final String stopButtonName;
public ConnectionLostDialog(Shell parentShell, DBPDataSourceContainer container, Throwable error, String stopButtonName) {
super(
parentShell,
"Connection lost",
"Connection to '" + container.getName() + "' was lost and cannot be re-established.\nWhat to you want to do?",
GeneralUtils.makeExceptionStatus(error),
IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
this.stopButtonName = stopButtonName;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.STOP_ID, stopButtonName, true);
createButton(parent, IDialogConstants.RETRY_ID, IDialogConstants.RETRY_LABEL, false);
createButton(parent, IDialogConstants.IGNORE_ID, IDialogConstants.IGNORE_LABEL, false);
createDetailsButton(parent);
}
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.DETAILS_ID) {
super.buttonPressed(buttonId);
return;
}
setReturnCode(buttonId);
close();
}
}