Search in sources :

Example 46 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project eclipse-cs by checkstyle.

the class CheckConfigurationPropertiesDialog method okPressed.

/**
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 */
@Override
protected void okPressed() {
    try {
        // Check if the configuration is valid
        mCheckConfig = mConfigurationEditor.getEditedWorkingCopy();
        CheckConfigurationTester tester = new CheckConfigurationTester(mCheckConfig);
        List<ResolvableProperty> unresolvedProps = tester.getUnresolvedProperties();
        if (!unresolvedProps.isEmpty()) {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.CheckConfigurationPropertiesDialog_titleUnresolvedProps, null, NLS.bind(Messages.CheckConfigurationPropertiesDialog_msgUnresolvedProps, // $NON-NLS-1$
            "" + unresolvedProps.size()), MessageDialog.WARNING, new String[] { Messages.CheckConfigurationPropertiesDialog_btnEditProps, Messages.CheckConfigurationPropertiesDialog_btnContinue, Messages.CheckConfigurationPropertiesDialog_btnCancel }, 0);
            int result = dialog.open();
            if (0 == result) {
                ResolvablePropertiesDialog propsDialog = new ResolvablePropertiesDialog(getShell(), mCheckConfig);
                propsDialog.open();
                return;
            } else if (1 == result) {
                super.okPressed();
            } else if (2 == result) {
                return;
            }
        } else {
            super.okPressed();
        }
    } catch (CheckstylePluginException e) {
        CheckstyleLog.log(e);
        this.setErrorMessage(e.getLocalizedMessage());
    }
}
Also used : ResolvableProperty(net.sf.eclipsecs.core.config.ResolvableProperty) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) CheckConfigurationTester(net.sf.eclipsecs.core.config.CheckConfigurationTester) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Point(org.eclipse.swt.graphics.Point)

Example 47 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project n4js by eclipse.

the class N4JSBuilderPreferencePage method processChanges.

/**
 * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock.
 */
@Override
protected boolean processChanges(IWorkbenchPreferenceContainer container) {
    boolean needsBuild = !getPreferenceChanges().isEmpty() | projectSpecificChanged;
    boolean doBuild = false;
    if (needsBuild) {
        int count = getRebuildCount();
        if (count > rebuildCount) {
            needsBuild = false;
            rebuildCount = count;
        }
    }
    if (needsBuild) {
        String[] strings = getFullBuildDialogStrings(project == null);
        if (strings != null) {
            MessageDialog dialog = new MessageDialog(this.getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
            int res = dialog.open();
            if (res == 0) {
                doBuild = true;
            } else if (res != 1) {
                return false;
            }
        }
    }
    if (container != null) {
        if (doBuild) {
            incrementRebuildCount();
            container.registerUpdateJob(getBuildJob(getProject()));
        }
    } else {
        if (doBuild) {
            getBuildJob(getProject()).schedule();
        }
    }
    return true;
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 48 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project n4js by eclipse.

the class AbstractExportToSingleFileWizardPage method queryOverwrite.

/**
 * The default implementation of this <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 *
 * @param pathString
 *            the path of the archive
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or
 *         <code>"CANCEL"</code>
 */
@Override
public String queryOverwrite(String pathString) {
    IPath path = Path.fromOSString(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) {

        @Override
        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() {

        @Override
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}
Also used : IPath(org.eclipse.core.runtime.IPath) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 49 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project egit by eclipse.

the class GitCreatePatchWizard method validateFile.

private boolean validateFile(File file) {
    if (file == null)
        return false;
    // Consider file valid if it doesn't exist for now.
    if (!file.exists())
        return true;
    // The file exists.
    if (!file.canWrite()) {
        final String title = UIText.GitCreatePatchWizard_ReadOnlyTitle;
        final String msg = UIText.GitCreatePatchWizard_ReadOnlyMsg;
        final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
        dialog.open();
        return false;
    }
    final String title = UIText.GitCreatePatchWizard_OverwriteTitle;
    final String msg = UIText.GitCreatePatchWizard_OverwriteMsg;
    final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    dialog.open();
    if (dialog.getReturnCode() != 0)
        return false;
    return true;
}
Also used : MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 50 with MessageDialog

use of org.eclipse.jface.dialogs.MessageDialog in project egit by eclipse.

the class DeleteBranchDialog method buttonPressed.

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == Window.OK) {
        try {
            int result = deleteBranch(selectedRefs, false);
            if (result == DeleteBranchOperation.REJECTED_UNMERGED) {
                List<RefNode> nodes = extractSelectedRefNodes();
                MessageDialog messageDialog = new UnmergedBranchDialog<>(getShell(), nodes);
                if (messageDialog.open() == Window.OK)
                    deleteBranch(selectedRefs, true);
                else
                    return;
            } else if (result == DeleteBranchOperation.REJECTED_CURRENT)
                Activator.handleError(UIText.DeleteBranchCommand_CannotDeleteCheckedOutBranch, null, true);
        } catch (CoreException e) {
            Activator.handleError(e.getMessage(), e, true);
        }
    }
    super.buttonPressed(buttonId);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode)

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