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());
}
}
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;
}
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()];
}
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;
}
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);
}
Aggregations