use of org.eclipse.jface.dialogs.MessageDialog in project cubrid-manager by CUBRID.
the class QueryEditorDNDController method openTransactionDialog.
/**
* Open transaction confirm dialog
*
* @param selectedDb the CubridDatabase
* @return <code>true</code> if continuous;<code>false</code>otherwise
*/
private boolean openTransactionDialog(final CubridDatabase selectedDb) {
String title = com.cubrid.common.ui.common.Messages.titleConfirm;
String msg = Messages.bind(Messages.connCloseConfirm, new String[] { selectedDb.getLabel() });
String[] buttons = new String[] { Messages.btnYes, Messages.btnNo, Messages.cancel };
MessageDialog dialog = new MessageDialog(editor.getSite().getShell(), title, null, msg, MessageDialog.QUESTION, buttons, 2) {
protected void buttonPressed(int buttonId) {
switch(buttonId) {
case 0:
editor.commit();
setReturnCode(0);
close();
break;
case 1:
editor.rollback();
setReturnCode(1);
close();
break;
case 2:
setReturnCode(2);
close();
break;
default:
break;
}
}
};
int returnVal = dialog.open();
if (returnVal == 2 || returnVal == -1) {
return false;
}
return true;
}
use of org.eclipse.jface.dialogs.MessageDialog in project cubrid-manager by CUBRID.
the class QueryEditorPart method dispose.
/**
* When dispose query editor, interrupt query thread, clear result and query
* plan, reset query connection
*/
public void dispose() {
if (isTransaction()) {
String msg = Messages.bind(Messages.connCloseConfirm, new String[] { this.getSelectedDatabase().getLabel() });
String[] buttons = new String[] { Messages.btnYes, Messages.btnNo };
MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), com.cubrid.common.ui.common.Messages.titleConfirm, null, msg, MessageDialog.QUESTION, buttons, 0) {
protected void buttonPressed(int buttonId) {
switch(buttonId) {
case 0:
try {
queryAction(QUERY_ACTION.COMMIT);
} catch (SQLException ex) {
CommonUITool.openErrorBox(Messages.bind(com.cubrid.common.ui.common.Messages.errCommonTip, ex.getErrorCode(), ex.getMessage()));
LOGGER.error("", ex);
}
setReturnCode(0);
close();
break;
case 1:
try {
queryAction(QUERY_ACTION.ROLLBACK);
} catch (SQLException ex) {
CommonUITool.openErrorBox(Messages.bind(com.cubrid.common.ui.common.Messages.errCommonTip, ex.getErrorCode(), ex.getMessage()));
LOGGER.error("", ex);
}
setReturnCode(1);
close();
break;
default:
break;
}
}
};
int returnVal = dialog.open();
if (returnVal != 0 && returnVal != 1) {
try {
queryAction(QUERY_ACTION.ROLLBACK);
} catch (SQLException ex) {
LOGGER.error("", ex);
String errmsg = Messages.bind(com.cubrid.common.ui.common.Messages.errCommonTip, ex.getErrorCode(), ex.getMessage());
CommonUITool.openErrorBox(errmsg);
}
}
}
try {
if (connection.hasConnection()) {
queryAction(QUERY_ACTION.CLOSE);
}
if (queryThread != null && !queryThread.isInterrupted()) {
queryThread.interrupt();
queryThread = null;
}
for (CombinedQueryEditorComposite combinedQueryEditorComposite : getAllCombinedQueryEditorComposite()) {
clearResult(combinedQueryEditorComposite);
clearPlan(combinedQueryEditorComposite);
combinedQueryEditorComposite.getSqlEditorComp().release();
}
} catch (Exception event) {
LOGGER.error("", event);
} finally {
connection.close();
connection = null;
}
if (result != null) {
result.dispose();
}
super.dispose();
}
use of org.eclipse.jface.dialogs.MessageDialog in project ow by vtst.
the class NatureAddingEditorCallback method afterCreatePartControl.
@Override
public void afterCreatePartControl(XtextEditor editor) {
try {
super.afterCreatePartControl(editor);
IResource resource = editor.getResource();
if (resource == null)
return;
IProject project = resource.getProject();
if (DISABLE.equals(project.getPersistentProperty(new QualifiedName(QUALIFIER, projectNature.getId()))))
return;
if (!ProjectNatureUtil.hasNature(getNature().getId(), project) && project.isAccessible()) {
MessageDialog dialog = new MessageDialog(editor.getEditorSite().getShell(), messages.format("add_nature_to_project_title", getNature().getName()), null, messages.format("add_nature_to_project_message", getNature().getName(), project.getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
int ret = dialog.open();
if (ret == 0) {
ProjectNatureUtil.addNatureRequiringXtext(getNature().getId(), project);
} else if (ret == 1) {
project.setPersistentProperty(new QualifiedName(QUALIFIER, projectNature.getId()), DISABLE);
}
}
} catch (CoreException e) {
ErrorDialog.openError(editor.getSite().getShell(), messages.format("add_nature_to_project_title", getNature().getName()), messages.getString("add_nature_to_project_error"), e.getStatus());
}
}
use of org.eclipse.jface.dialogs.MessageDialog in project cubrid-manager by CUBRID.
the class FormatXMLAction method showErrorMessage.
/**
* Show error message in a dialog.
*
*/
private void showErrorMessage() {
Shell shell = editor.getSite().getShell();
MessageDialog dialog = new MessageDialog(shell, Messages.titleError, null, Messages.invalidateXML, MessageDialog.WARNING, new String[] { Messages.btnClose }, 0);
dialog.open();
}
use of org.eclipse.jface.dialogs.MessageDialog in project azure-tools-for-java by Microsoft.
the class AzureDockerUIResources method deleteAzureDockerHostConfirmationDialog.
public static int deleteAzureDockerHostConfirmationDialog(Shell shell, Azure azureClient, DockerHost dockerHost) {
String promptMessageDeleteAll = String.format("This operation will delete virtual machine %s and its resources:\n" + "\t - network interface: %s\n" + "\t - public IP: %s\n" + "\t - virtual network: %s\n" + "The associated disks and storage account will not be deleted\n", dockerHost.hostVM.name, dockerHost.hostVM.nicName, dockerHost.hostVM.publicIpName, dockerHost.hostVM.vnetName);
String promptMessageDelete = String.format("This operation will delete virtual machine %s.\n" + "The associated disks and storage account will not be deleted\n\n" + "Are you sure you want to continue?\n", dockerHost.hostVM.name);
String[] options;
String promptMessage;
if (AzureDockerVMOps.isDeletingDockerHostAllSafe(azureClient, dockerHost.hostVM.resourceGroupName, dockerHost.hostVM.name)) {
promptMessage = promptMessageDeleteAll;
options = new String[] { "Cancel", "Delete VM Only", "Delete All" };
} else {
promptMessage = promptMessageDelete;
options = new String[] { "Cancel", "Delete" };
}
MessageDialog deleteDialog = new MessageDialog(shell, "Delete Docker Host", null, promptMessage, MessageDialog.ERROR, options, 0);
int dialogReturn = deleteDialog.open();
switch(dialogReturn) {
case 0:
if (AzureDockerUtils.DEBUG)
System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
break;
case 1:
if (AzureDockerUtils.DEBUG)
System.out.println("Delete VM only: " + dockerHost.name);
break;
case 2:
if (AzureDockerUtils.DEBUG)
System.out.println("Delete VM and resources: " + dockerHost.name);
break;
default:
if (AzureDockerUtils.DEBUG)
System.out.format("Delete Docker Host op was canceled %s\n", dialogReturn);
}
return dialogReturn;
}
Aggregations