Search in sources :

Example 26 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 27 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 28 with MessageDialog

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());
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) QualifiedName(org.eclipse.core.runtime.QualifiedName) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 29 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)

Example 30 with MessageDialog

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

Aggregations

MessageDialog (org.eclipse.jface.dialogs.MessageDialog)44 Shell (org.eclipse.swt.widgets.Shell)13 CoreException (org.eclipse.core.runtime.CoreException)7 File (java.io.File)5 IPath (org.eclipse.core.runtime.IPath)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IFile (org.eclipse.core.resources.IFile)4 Point (org.eclipse.swt.graphics.Point)4 Composite (org.eclipse.swt.widgets.Composite)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Path (org.eclipse.core.runtime.Path)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 CombinedQueryEditorComposite (com.cubrid.common.ui.query.control.CombinedQueryEditorComposite)2 URI (java.net.URI)2 LinkedList (java.util.LinkedList)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 IProject (org.eclipse.core.resources.IProject)2