Search in sources :

Example 66 with MessageDialog

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];
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 67 with MessageDialog

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()];
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 68 with MessageDialog

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;
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 69 with MessageDialog

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();
}
Also used : CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) SQLException(java.sql.SQLException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Point(org.eclipse.swt.graphics.Point) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Example 70 with MessageDialog

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)129 Shell (org.eclipse.swt.widgets.Shell)27 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)14 File (java.io.File)10 ArrayList (java.util.ArrayList)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Composite (org.eclipse.swt.widgets.Composite)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Point (org.eclipse.swt.graphics.Point)7 IOException (java.io.IOException)6 IFile (org.eclipse.core.resources.IFile)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 List (java.util.List)5 IStatus (org.eclipse.core.runtime.IStatus)5 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)5 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)4 Path (org.eclipse.core.runtime.Path)4