Java Code Examples for org.eclipse.core.runtime.IStatus#getPlugin()

The following examples show how to use org.eclipse.core.runtime.IStatus#getPlugin() . 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: StatusUtil.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
public static IStatus merge(IStatus status, IStatus newStatus) {
  if (status == null) {
    return newStatus;
  } else {
    if (status instanceof MultiStatus) {
      ((MultiStatus) status).merge(newStatus);
      return status;
    } else {
      MultiStatus merged = new MultiStatus(status.getPlugin(), status.getCode(),
          status.getMessage(), status.getException());
      merged.merge(newStatus);
      return merged;
    }
  }
  
}
 
Example 2
Source File: StatusUtil.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Return a simplified status by discarding all OK child statuses.
 */
public static IStatus filter(IStatus status) {
  if (!status.isMultiStatus()) {
    return status;
  } else if (status.isOK()) {
    // return OK_STATUS to avoids oddities like Progress View showing the MultiStatus's
    // error message
    return Status.OK_STATUS;
  }
  MultiStatus newStatus = new MultiStatus(status.getPlugin(), status.getCode(),
      status.getMessage(), status.getException());
  for (IStatus child : status.getChildren()) {
    if (!child.isOK()) {
      newStatus.add(filter(child));
    }
  }
  return newStatus;
}
 
Example 3
Source File: CloudSdkManager.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Installs a Cloud SDK, if the preferences are configured to auto-manage the SDK. Blocks callers
 * 1) if the managed SDK is being installed concurrently by others; and 2) until the installation
 * is complete.
 *
 * @param consoleStream stream to which the install output is written
 * @param monitor the progress monitor that can also be used to cancel the installation
 */
public IStatus installManagedSdk(MessageConsoleStream consoleStream, IProgressMonitor monitor) {
  if (CloudSdkPreferences.isAutoManaging()) {
    // We don't check if the Cloud SDK installed but always schedule the install job; such check
    // may pass while the SDK is being installed and in an incomplete state.
    // Mark installation failure as non-ERROR to avoid job failure reporting dialogs from the
    // overly helpful Eclipse UI ProgressManager
    CloudSdkInstallJob installJob = new CloudSdkInstallJob(
        consoleStream, modifyLock, IStatus.WARNING);

    IStatus result = runInstallJob(consoleStream, installJob, monitor);
    if (!result.isOK()) {
      // recast result as an IStatus.ERROR
      return new Status(
          IStatus.ERROR,
          result.getPlugin(),
          result.getCode(),
          result.getMessage(),
          result.getException());
    }
  }
  return Status.OK_STATUS;
}
 
Example 4
Source File: NewCheckCatalogWizardPage.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IStatus typeNameChanged() {
  super.typeNameChanged();
  IStatus status = validator.checkCatalogName(getCatalogName());

  if (!previousPageIsProjectPage()) {

    IPackageFragment packageFragment = getPackageFragment();

    if (packageFragment != null && catalogExists(packageFragment.getResource())) {
      return new Status(IStatus.ERROR, status.getPlugin(), NLS.bind(com.avaloq.tools.ddk.check.validation.Messages.CheckJavaValidator_CATALOG_NAME_STATUS, com.avaloq.tools.ddk.check.validation.Messages.CheckJavaValidator_EXISTS));
    }
  }
  if (!status.matches(IStatus.ERROR)) {
    projectInfo.setCatalogName(getCatalogName());
  }
  return status;
}
 
Example 5
Source File: ModelEditor.java    From tlaplus with MIT License 6 votes vote down vote up
private static IStatus shortenStatusMessage(IStatus status) {
	if (status.isMultiStatus()) {
		final IStatus[] convertedChildren = new Status[status.getChildren().length];
		// convert nested status objects.
		final IStatus[] children = status.getChildren();
		for (int i = 0; i < children.length; i++) {
			final IStatus child = children[i];
			convertedChildren[i] = new Status(child.getSeverity(), child.getPlugin(), child.getCode(),
					substring(child.getMessage()),
					child.getException());
		}
		return new MultiStatus(status.getPlugin(), status.getCode(), convertedChildren,
				substring(status.getMessage()),
				status.getException());
	} else {
		return new Status(status.getSeverity(), status.getPlugin(), status.getCode(),
				substring(status.getMessage()),
				status.getException());
	}
}
 
Example 6
Source File: IBDMValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
default IStatus validate(Optional<String> name, T value) {
    IStatus status = validate(value);
    if (!status.isOK()) {
        if (status instanceof MultiStatus) {
            MultiStatus statusWithType = new MultiStatus(status.getPlugin(), status.getCode(), "", null);
            Arrays.asList(status.getChildren())
                    .stream()
                    .filter(s -> !s.isOK())
                    .map(s -> createStatus(s, name))
                    .forEach(statusWithType::add);
            return statusWithType;
        }
        return createStatus(status, name);
    }
    return status;
}
 
Example 7
Source File: NewClientBundleWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private IStatus getBundledResourcesStatus() {
  IStatus status = bundledResourcesBlock.getStatus();
  if (status.isOK()) {
    return status;
  }
  return new Status(status.getSeverity(), status.getPlugin(),
      "Bundled resource problem: " + status.getMessage());
}
 
Example 8
Source File: BonitaErrorDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param parentShell
 * @param dialogTitle
 * @param message
 * @param status
 * @param displayMask
 */
public BonitaErrorDialog(final Shell parentShell, final String dialogTitle, final String message, final IStatus status, final int displayMask) {
	super(parentShell, dialogTitle, message, status, displayMask);
	this.message = message;
	if(status.getException() == null){
		this.status = new Status(status.getSeverity(), status.getPlugin(), status.getMessage(), new Exception(status.getMessage()));
	}else{
		this.status = status;
	}
	setStatus(this.status);
}
 
Example 9
Source File: GroupIdValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IStatus validate(Object value) {
    final IStatus status = super.validate(value);
    if (status.isOK()) {
        final IStatus packageNameStatus = validateJavaPackageName(value);
        return new Status(packageNameStatus.getSeverity(), packageNameStatus.getPlugin(),
                fieldName + ": " + packageNameStatus.getMessage());
    }
    return status;
}
 
Example 10
Source File: SVNException.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public CoreException toCoreException() {
	IStatus status = getStatus();
	return new CoreException(new Status(status.getSeverity(), status.getPlugin(), 0, status.getMessage(), this));
}
 
Example 11
Source File: ElexisStatus.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public ElexisStatus(IStatus status){
	super(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(),
		status.getException());
}
 
Example 12
Source File: ObjectStatus.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public ObjectStatus(IStatus status, Object object) {
	super(status.getSeverity(), status.getPlugin(), status.getMessage());
	this.object = object;
}
 
Example 13
Source File: IBDMValidator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
default Status createStatus(IStatus status, Optional<String> name) {
    return name.isPresent()
            ? new Status(status.getSeverity(), status.getPlugin(),
                    messageWithNameAndType(name.get(), status.getMessage()))
            : new Status(status.getSeverity(), status.getPlugin(), messageWithType(status.getMessage()));
}
 
Example 14
Source File: ProcessValidationStatus.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ProcessValidationStatus(final AbstractProcess process, final IStatus status) {
    super(status.getSeverity(), status.getPlugin(), status.getMessage());
    this.process = process;
    validationStatus = status;
}
 
Example 15
Source File: ServerStatus.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
public ServerStatus(IStatus status, int httpCode) {
	super(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
	this.httpCode = httpCode;
}
 
Example 16
Source File: WorkspaceFile.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private static void fileNotFoundError(CoreException cause, IPath path) throws CoreException {
	IStatus status = cause.getStatus();
	throw new CoreException(new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), new FileNotFoundException(path.toPortableString())));
}
 
Example 17
Source File: ServerStatus.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
public ServerStatus(IStatus status, int httpCode, JSONObject jsonData) {
	super(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), status.getException());
	this.httpCode = httpCode;
	this.jsonData = jsonData;
}
 
Example 18
Source File: NewFolderDialogOfHs.java    From translationstudio8 with GNU General Public License v2.0 votes vote down vote up
/**
		 * Update the dialog's status line to reflect the given status. It is safe to call
		 * this method before the dialog has been opened.
		 */
		protected void updateStatus(IStatus status) {
			if (firstLinkCheck && status != null) {
				// don't show the first validation result as an error.
				// fixes bug 29659
				Status newStatus = new Status(IStatus.OK, status.getPlugin(),
						status.getCode(), status.getMessage(), status
								.getException());
				super.updateStatus(newStatus);
			} else {
				super.updateStatus(status);
			}
		}