use of org.eclipse.jface.dialogs.MessageDialog in project translationstudio8 by heartsome.
the class ExportExternal method openConfirmDialog.
public static int openConfirmDialog(final Shell shell, final String message) {
final int[] bools = new int[1];
bools[0] = 0;
if (shell != null) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog md = new MessageDialog(shell, Messages.getString("all.dialog.confirm"), null, message, 0, new String[] { Messages.getString("all.dialog.yes"), Messages.getString("all.dialog.yestoall"), Messages.getString("all.dialog.no"), Messages.getString("all.dialog.notoall") }, CONFIRM_NO);
bools[0] = md.open();
}
});
}
return bools[0];
}
use of org.eclipse.jface.dialogs.MessageDialog in project translationstudio8 by heartsome.
the class ImportProjectWizardPage method queryOverwrite.
/**
* The <code>WizardDataTransfer</code> implementation of this
* <code>IOverwriteQuery</code> method asks the user whether the existing
* resource at the given path should be overwritten.
*
* @param pathString
* @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
* <code>"ALL"</code>, or <code>"CANCEL"</code>
*/
public String queryOverwrite(String pathString) {
Path path = new Path(pathString);
String messageString;
// and there are at least 2 segments.
if (path.getFileExtension() == null || path.segmentCount() < 2) {
messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_existsQuestion, pathString);
} else {
messageString = NLS.bind(IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString());
}
final MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) {
protected int getShellStyle() {
return super.getShellStyle() | SWT.SHEET;
}
};
String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
// run in syncExec because callback is from an operation,
// which is probably not running in the UI thread.
getControl().getDisplay().syncExec(new Runnable() {
public void run() {
dialog.open();
}
});
return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}
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 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();
}
Aggregations