Java Code Examples for org.eclipse.core.databinding.validation.ValidationStatus#cancel()

The following examples show how to use org.eclipse.core.databinding.validation.ValidationStatus#cancel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BusinessObjectModelFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus export(String targetAbsoluteFilePath) throws IOException {
    checkWritePermission(new File(targetAbsoluteFilePath));
    final IResource file = getResource();
    if (file != null) {
        final File to = new File(targetAbsoluteFilePath);
        to.mkdirs();
        final File target = new File(to, ZIP_FILENAME);
        if (target.exists()) {
            if (FileActionDialog.overwriteQuestion(file.getName())) {
                PlatformUtil.delete(target, Repository.NULL_PROGRESS_MONITOR);
            } else {
                return ValidationStatus.cancel("");
            }
        }
        try (InputStream inputStream = ByteSource.wrap(toByteArray()).openBufferedStream();) {
            Files.copy(inputStream, target.toPath());
            return ValidationStatus.ok();
        }
    }
    return ValidationStatus.error(
            String.format(org.bonitasoft.studio.common.repository.Messages.failedToRetrieveResourceToExport,
                    getName()));
}
 
Example 2
Source File: AbstractFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus export(final String targetAbsoluteFilePath) throws IOException {
    checkWritePermission(new File(targetAbsoluteFilePath));
    final IResource file = getResource();
    if (file != null) {
        final File to = new File(targetAbsoluteFilePath);
        to.mkdirs();
        final File target = new File(to, file.getName());
        if (target.exists()) {
            if (FileActionDialog.overwriteQuestion(file.getName())) {
                PlatformUtil.delete(target, Repository.NULL_PROGRESS_MONITOR);
            } else {
                return ValidationStatus.cancel("");
            }
        }
        PlatformUtil.copyResource(to, file.getLocation().toFile(), Repository.NULL_PROGRESS_MONITOR);
        return ValidationStatus.ok();
    }
    return ValidationStatus.error(String.format(Messages.failedToRetrieveResourceToExport, getName()));
}
 
Example 3
Source File: DeployDiagramHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private IStatus validateDiagram(List<AbstractProcess> processes) {
    RunProcessesValidationOperation validationOperation = new RunProcessesValidationOperation(
            new BatchValidationOperation(
                    new OffscreenEditPartFactory(
                            org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory.getInstance()),
                    new ValidationMarkerProvider()));
    validationOperation.addProcesses(processes);
    try {
        new SkippableProgressMonitorJobsDialog(Display.getDefault().getActiveShell()).canBeSkipped().run(true, false,
                validationOperation);
    } catch (InvocationTargetException | InterruptedException e) {
        return new Status(IStatus.ERROR, EnginePlugin.PLUGIN_ID, e.getMessage(), e);
    }
    return validationOperation.displayConfirmationDialog()
            ? ValidationStatus.ok()
            : ValidationStatus.cancel("");
}
 
Example 4
Source File: StringValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected IStatus createFailureStatus(String message) {
    switch (severity) {
        case IStatus.WARNING:
            return ValidationStatus.warning(message);
        case IStatus.CANCEL:
            return ValidationStatus.cancel(message);
        case IStatus.INFO:
            return ValidationStatus.info(message);
        case IStatus.ERROR:
        default:
            return ValidationStatus.error(message);
    }
}