Exemplo n.º 1
0
 public void testExtractRootCauseErrorStatusWithException() throws Exception {
   IStatus status =
       extractRootCause(new Status(IStatus.ERROR, "id1", "Test", new IOException("IO")));
   assertNotNull(status);
   assertEquals("id1", status.getPlugin());
   assertEquals("Test", status.getMessage());
   assertEquals("IO", status.getException().getMessage());
 }
 @Override
 public String getToolTipText() {
   if (status != null && !status.isOK()) {
     return status.getMessage();
   }
   if (gotoAction != null) {
     return gotoAction.getToolTipText();
   }
   return Utils.shortenText(
       SynchronizeView.MAX_NAME_LENGTH, RefreshParticipantJob.this.getName());
 }
 /**
  * Add this exception to the collector. If a log was specified in the constructor then the
  * exception will be output to the log. You can retreive exceptions using <code>getStatus</code>.
  *
  * @param exception the exception to collect
  */
 public void handleException(CoreException exception) {
   // log the exception if we have a log
   if (log != null) {
     log.log(new Status(severity, pluginId, 0, message, exception));
   }
   // Record each status individually to flatten the resulting multi-status
   IStatus exceptionStatus = exception.getStatus();
   // Wrap the exception so the stack trace is not lost.
   IStatus status =
       new Status(
           exceptionStatus.getSeverity(),
           exceptionStatus.getPlugin(),
           exceptionStatus.getCode(),
           exceptionStatus.getMessage(),
           exception);
   recordStatus(status);
   IStatus[] children = status.getChildren();
   for (int i = 0; i < children.length; i++) {
     IStatus status2 = children[i];
     recordStatus(status2);
   }
 }
Exemplo n.º 4
0
    public void update(Observable o, Object arg) {
      final IWorkspace workspace = DLTKUIPlugin.getWorkspace();
      final String name = fNameGroup.getName();
      // check whether the project name field is empty
      if (name.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterProjectName);
        setPageComplete(false);
        return;
      }
      // check whether the project name is valid
      final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
      if (!nameStatus.isOK()) {
        setErrorMessage(nameStatus.getMessage());
        setPageComplete(false);
        return;
      }
      // check whether project already exists
      final IProject handle = getProjectHandle();

      if (!isInLocalServer()) {
        if (handle.exists()) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      String newProjectNameLowerCase = name.toLowerCase();
      for (IProject currentProject : projects) {
        String existingProjectName = currentProject.getName();
        if (existingProjectName.toLowerCase().equals(newProjectNameLowerCase)) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      final String location = fPHPLocationGroup.getLocation().toOSString();
      // check whether location is empty
      if (location.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterLocation);
        setPageComplete(false);
        return;
      }
      // check whether the location is a syntactically correct path
      if (!Path.EMPTY.isValidPath(location)) {
        setErrorMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
        setPageComplete(false);
        return;
      }
      // check whether the location has the workspace as prefix
      IPath projectPath = Path.fromOSString(location);
      if (!fPHPLocationGroup.isInWorkspace() && Platform.getLocation().isPrefixOf(projectPath)) {
        setErrorMessage(
            NewWizardMessages.ScriptProjectWizardFirstPage_Message_cannotCreateInWorkspace);
        setPageComplete(false);
        return;
      }
      // If we do not place the contents in the workspace validate the
      // location.
      if (!fPHPLocationGroup.isInWorkspace()) {
        IEnvironment environment = getEnvironment();
        if (EnvironmentManager.isLocal(environment)) {
          final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
          File file = projectPath.toFile();
          if (!locationStatus.isOK()) {
            setErrorMessage(locationStatus.getMessage());
            setPageComplete(false);
            return;
          }

          if (!canCreate(projectPath.toFile())) {
            setErrorMessage(
                NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
            setPageComplete(false);
            return;
          }
        }
      }

      if (fragment != null) {
        fragment.getWizardModel().putObject("ProjectName", fNameGroup.getName());
        if (!fragment.isComplete()) {
          setErrorMessage((String) fragment.getWizardModel().getObject(ERROR_MESSAGE));
          setPageComplete(false);
          return;
        }
      }

      setPageComplete(true);
      setErrorMessage(null);
      setMessage(null);
    }
 /* (non-Javadoc)
  * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setBlocked(org.eclipse.core.runtime.IStatus)
  */
 public void setBlocked(IStatus reason) {
   subTask(reason.getMessage());
 }
Exemplo n.º 6
0
 /**
  * Creates a new exception with the given status object. The message of the given status is used
  * as the exception message.
  *
  * @param status the status object to be associated with this exception
  */
 public CoreException(IStatus status) {
   super(status.getMessage());
   this.status = status;
 }