protected void setStatus(IStatus status) {
   if (status == null || status.isOK()) {
     errorLabel.setText("");
     errorImage.setImage(null);
   } else {
     errorLabel.setText(status.getMessage());
     errorLabel.setToolTipText(status.getMessage());
     Image toUse = null;
     switch (status.getSeverity()) {
       case IStatus.WARNING:
         toUse =
             PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
         break;
       case IStatus.ERROR:
         toUse =
             PlatformUI.getWorkbench()
                 .getSharedImages()
                 .getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
         break;
       case IStatus.INFO:
         toUse =
             PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
         break;
     }
     errorImage.setImage(toUse);
     errorImage.setVisible(true);
   }
 }
Esempio n. 2
0
 /**
  * Compares two instances of <code>IStatus</code>. The more severe is returned: An error is more
  * severe than a warning, and a warning is more severe than ok. If the two stati have the same
  * severity, the second is returned.
  *
  * @param s1 first status
  * @param s2 second status
  * @return the more severe status
  */
 public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
   if (s1.getSeverity() > s2.getSeverity()) {
     return s1;
   } else {
     return s2;
   }
 }
  public void createProject(
      AndroidSDK target, String projectName, File path, String activity, String packageName)
      throws CoreException {
    IStatus status = HybridProjectConventions.validateProjectName(projectName);
    if (!status.isOK()) throw new CoreException(status);
    // activity class name matches the project name
    status = HybridProjectConventions.validateProjectName(activity);
    if (!status.isOK()) throw new CoreException(status);

    status = HybridProjectConventions.validateProjectID(packageName);
    if (!status.isOK()) throw new CoreException(status);

    ExternalProcessUtility processUtility = new ExternalProcessUtility();
    StringBuilder command = new StringBuilder();
    command.append(getAndroidCommand());
    command.append(" create project");
    command.append(" --target ").append(target.getId());
    command.append(" --path ").append('"').append(path.getPath()).append('"');
    command.append(" --name ").append('"').append(projectName).append('"');
    command.append(" --activity ").append(activity);
    command.append(" --package ").append(packageName);

    CreateProjectResultParser parser = new CreateProjectResultParser();
    processUtility.execSync(
        command.toString(), null, parser, parser, new NullProgressMonitor(), null, null);
    if (parser.getErrorString() != null) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              AndroidCore.PLUGIN_ID,
              "Error creating the Android project: " + parser.getErrorString()));
    }
  }
  @Override
  public boolean performFinish() {
    newProject = mainPage.getProjectHandle();
    destPath = mainPage.getLocationPath();
    location = null;
    if (!mainPage.useDefaults()) {
      location = mainPage.getLocationURI();
    } else {
      destPath = destPath.append(newProject.getName());
    }

    if (templatesPage != null) {
      selectedTemplate = templatesPage.getSelectedTemplate();
    }

    if (referencePage != null) {
      refProjects = referencePage.getReferencedProjects();
    }

    if (!deferCreatingProject()) {
      IStatus projectStatus = createAndRefreshProject(true, true, new NullProgressMonitor());
      return projectStatus.isOK();
    }
    return true;
  }
 /**
  * Download the remote content and store it the temp directory.
  *
  * @param URLs
  * @param progressMonitor
  */
 public IStatus download(String[] URLs, IProgressMonitor progressMonitor) {
   if (URLs.length == 0) {
     String err = Messages.InstallerConfigurationProcessor_missingDownloadTargets;
     applyErrorAttributes(err);
     IdeLog.logError(
         PortalUIPlugin.getDefault(),
         "We expected an array of URLs, but got an empty array.",
         new Exception(err)); // $NON-NLS-1$
     return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err);
   }
   downloadedPaths = null;
   DownloadManager downloadManager = new DownloadManager();
   List<URI> urlsList = new ArrayList<URI>(URLs.length);
   for (int i = 0; i < URLs.length; i++) {
     try {
       urlsList.add(new URI(urls[i]));
     } catch (URISyntaxException mue) {
       IdeLog.logError(PortalUIPlugin.getDefault(), mue);
     }
   }
   try {
     downloadManager.addURIs(urlsList);
     IStatus status = downloadManager.start(progressMonitor);
     if (status.isOK()) {
       downloadedPaths = downloadManager.getContentsLocations();
     }
     return status;
   } catch (Exception e) {
     IdeLog.logError(PortalUIPlugin.getDefault(), e);
   }
   return Status.CANCEL_STATUS;
 }
 public void helpIsValidJdbcDriver(
     final JdbcDriver driver, final int expectedCode, final int expectedSeverity) {
   final IStatus status = mgr.isValid(driver);
   assertNotNull(status);
   assertEquals(expectedCode, status.getCode());
   assertEquals(expectedSeverity, status.getSeverity());
 }
Esempio n. 7
0
 public void run() {
   while (true) {
     synchronized (JobManagerImpl.this.mySemaphor) {
       if (JobManagerImpl.this.mySemaphor.isClosed()) {
         try {
           JobManagerImpl.this.mySemaphor.wait();
         } catch (InterruptedException e) {
           cleanJobs();
         }
       }
     }
     synchronized (myJobs) {
       if (myJobs.isEmpty()) {
         try {
           myJobs.wait();
         } catch (InterruptedException e) {
           cleanJobs();
         }
       } else {
         InternalJobImpl next = (InternalJobImpl) myJobs.removeFirst();
         IStatus result = next.run(myProgressMonitor);
         next.setResult(result);
         if (result.isOK()) {
         } else {
           cleanJobs();
         }
       }
     }
   }
 }
Esempio n. 8
0
  @Override
  public Status validate() {
    final Value<String> packagePath = context().find(ServiceBuilder.class).getPackagePath();
    String packPathVal = packagePath.getContent();

    if (packPathVal == null) {
      return Status.createErrorStatus(Msgs.packagePathNotEmpty);
    }

    // Use standard java conventions to validate the package name
    IStatus javaStatus =
        JavaConventions.validatePackageName(
            packPathVal, CompilerOptions.VERSION_1_5, CompilerOptions.VERSION_1_5);

    if (javaStatus.getSeverity() == IStatus.ERROR) {
      return Status.createErrorStatus(
          J2EECommonMessages.ERR_JAVA_PACAKGE_NAME_INVALID + javaStatus.getMessage());
    }

    if (javaStatus.getSeverity() == IStatus.WARNING) {
      return Status.createWarningStatus(
          J2EECommonMessages.ERR_JAVA_PACKAGE_NAME_WARNING + javaStatus.getMessage());
    }

    return Status.createOkStatus();
  }
  public static final Status execute(final NewLiferayPluginProjectOp op, final ProgressMonitor pm) {
    final IProgressMonitor monitor = ProgressMonitorBridge.create(pm);

    monitor.beginTask(
        "Creating Liferay plugin project (this process may take several minutes)",
        100); //$NON-NLS-1$

    Status retval = null;

    try {
      final NewLiferayProjectProvider<NewLiferayPluginProjectOp> projectProvider =
          op.getProjectProvider().content(true);

      // IDE-1306  If the user types too quickly all the model changes may not have propagated
      final Path projectLocation = op.getLocation().content();
      updateLocation(op, projectLocation);

      final IStatus status = projectProvider.createNewProject(op, monitor);

      if (status.isOK()) {
        updateProjectPrefs(op);

        removeSampleCodeAndFiles(op);
      }

      retval = StatusBridge.create(status);
    } catch (Exception e) {
      final String msg = "Error creating Liferay plugin project."; // $NON-NLS-1$
      ProjectCore.logError(msg, e);

      return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
    }

    return retval;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal#getAdditionalProposalInfo()
   */
  public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
    StringBuffer result = new StringBuffer();

    IStatus status = getFixStatus();
    if (status != null && !status.isOK()) {
      result.append("<b>"); // $NON-NLS-1$
      if (status.getSeverity() == IStatus.WARNING) {
        result.append(CorrectionMessages.FixCorrectionProposal_WarningAdditionalProposalInfo);
      } else if (status.getSeverity() == IStatus.ERROR) {
        result.append(CorrectionMessages.FixCorrectionProposal_ErrorAdditionalProposalInfo);
      }
      result.append("</b>"); // $NON-NLS-1$
      result.append(status.getMessage());
      result.append("<br><br>"); // $NON-NLS-1$
    }

    String info = fFix.getAdditionalProposalInfo();
    if (info != null) {
      result.append(info);
    } else {
      result.append(super.getAdditionalProposalInfo(monitor));
    }

    return result.toString();
  }
  /*
   * Consult the IOperationApprovers to see if the proposed execution should
   * be allowed.
   *
   * @since 3.2
   */
  private IStatus getExecuteApproval(IUndoableOperation operation, IAdaptable info) {

    final Object[] approverArray = approvers.getListeners();

    for (int i = 0; i < approverArray.length; i++) {
      if (approverArray[i] instanceof IOperationApprover2) {
        IOperationApprover2 approver = (IOperationApprover2) approverArray[i];
        IStatus approval = approver.proceedExecuting(operation, this, info);
        if (!approval.isOK()) {
          if (DEBUG_OPERATION_HISTORY_APPROVAL) {
            Tracing.printTrace(
                "OPERATIONHISTORY", //$NON-NLS-1$
                "Execute not approved by "
                    + approver //$NON-NLS-1$
                    + "for operation "
                    + operation //$NON-NLS-1$
                    + " with status "
                    + approval); //$NON-NLS-1$
          }
          return approval;
        }
      }
    }
    return Status.OK_STATUS;
  }
        public Map<String, IStatus> validate(Object value, Object context) {
          if (!(context instanceof Object[])) {
            throw new IllegalArgumentException(
                "Context parameter should be instance of Object[]"); //$NON-NLS-1$
          }

          Object[] contextArray = ((Object[]) context);
          String targetName = contextArray[0].toString();
          IProject project = (IProject) contextArray[1];
          IJavaProject jProject = JavaCore.create(project);

          IStatus status =
              JavaConventions.validateMethodName(
                  value.toString(),
                  getCompilerSourceLevel(jProject),
                  getCompilerComplianceLevel(jProject));

          if (status.getSeverity() == IStatus.ERROR) {
            return createErrormessage(
                new Status(
                    IStatus.ERROR,
                    SeamCorePlugin.PLUGIN_ID,
                    NLS.bind(SeamCoreMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID, targetName)));
          }

          return NO_ERRORS;
        }
        public Map<String, IStatus> validate(Object value, Object context) {
          if (!(context instanceof Object[])) {
            throw new IllegalArgumentException(
                "Context parameter should be instance of Object[]"); //$NON-NLS-1$
          }

          Object[] contextArray = ((Object[]) context);
          IProject project = (IProject) contextArray[1];
          IJavaProject jProject = JavaCore.create(project);

          IStatus status =
              JavaConventions.validateJavaTypeName(
                  value.toString(),
                  getCompilerSourceLevel(jProject),
                  getCompilerComplianceLevel(jProject));
          if (((IStatus.ERROR | IStatus.WARNING) & status.getSeverity()) != 0) {
            return createErrormessage(
                new Status(
                    IStatus.ERROR,
                    SeamCorePlugin.PLUGIN_ID,
                    SeamCoreMessages.VALIDATOR_FACTORY_LOCAL_INTERFACE_NAME_IS_NOT_VALID
                        + status.getMessage()));
          }
          return NO_ERRORS;
        }
        public Map<String, IStatus> validate(Object value, Object context) {
          String name = value.toString();
          if (context != null && context instanceof ISeamProject) {
            ISeamProject seamProject = (ISeamProject) context;
            ISeamComponent component = seamProject.getComponent(name);
            if (component != null)
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      NLS.bind(SeamCoreMessages.VALIDATOR_FACTORY_COMPONENT_ALREADY_EXISTS, name)));
          }

          String[] segs = name.split("\\."); // $NON-NLS-1$
          for (String segm : segs) {
            if (!segm.trim().equals(segm))
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      SeamCoreMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID));

            IStatus status =
                JavaConventions.validateClassFileName(
                    segm + ".class", DEFAULT_SOURCE_LEVEL, DEFAULT_COMPLIANCE_LEVEL); // $NON-NLS-1$
            if (!status.isOK())
              return createErrormessage(
                  new Status(
                      IStatus.ERROR,
                      SeamCorePlugin.PLUGIN_ID,
                      SeamCoreMessages.VALIDATOR_FACTORY_NAME_IS_NOT_VALID));
          }
          return NO_ERRORS;
        }
  private IProject createProject(final GridProjectProperties props, final IProgressMonitor monitor)
      throws CoreException {

    monitor.subTask(Messages.getString("GridProjectCreationOperation.init_task")); // $NON-NLS-1$

    String projectName = props.getProjectName();
    IPath projectPath = props.getProjectLocation();
    IProject[] referencesProjects = props.getReferencesProjects();

    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = workspaceRoot.getProject(projectName);

    IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocation(project, projectPath);
    if (status.getSeverity() != IStatus.OK) {
      throw new CoreException(status);
    }

    IProjectDescription desc = project.getWorkspace().newProjectDescription(projectName);
    desc.setLocation(projectPath);
    if (referencesProjects != null) {
      desc.setReferencedProjects(referencesProjects);
    }
    project.create(desc, new SubProgressMonitor(monitor, 50));
    project.open(new SubProgressMonitor(monitor, 50));

    createProjectStructure(project, props);
    setProjectProperties(project, props);

    if (monitor.isCanceled()) {
      throw new OperationCanceledException();
    }

    return project;
  }
  protected IStatus validateServer(IProgressMonitor monitor) {
    String host = serverWC.getHost();

    if (CoreUtil.isNullOrEmpty(host)) {
      return LiferayServerUI.createErrorStatus(Msgs.specifyHostname);
    }

    String username = remoteServerWC.getUsername();

    if (CoreUtil.isNullOrEmpty(username)) {
      return LiferayServerUI.createErrorStatus(Msgs.specifyUsernamePassword);
    }

    String port = remoteServerWC.getHTTPPort();

    if (CoreUtil.isNullOrEmpty(port)) {
      return LiferayServerUI.createErrorStatus(Msgs.specifyHTTPPort);
    }

    IStatus status = remoteServerWC.validate(monitor);

    if (status != null && status.getSeverity() == IStatus.ERROR) {
      fragment.lastServerStatus =
          new Status(
              IStatus.WARNING, status.getPlugin(), status.getMessage(), status.getException());
    } else {
      fragment.lastServerStatus = status;
    }

    return status;
  }
 public void helpIsValidJdbcSource(
     final JdbcSource source, final int expectedCode, final int expectedSeverity) {
   final IStatus status = mgr.isValid(source);
   assertNotNull(status);
   assertEquals(expectedCode, status.getCode());
   assertEquals(expectedSeverity, status.getSeverity());
 }
  @Override
  protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException {
    if (getServer().getRuntime() == null) return;

    IPath confDir = getBaseDirectory();
    getJonasVersionHandler()
        .createJonasBase(
            getServer().getRuntime().getLocation(),
            this.getJonasRuntimeInstance().getInstanceDirectory());
    IStatus status = getJonasVersionHandler().prepareDeployDirectory(confDir);

    if (status != null && !status.isOK()) throw new CoreException(status);

    IProgressMonitor monitor2 = ProgressUtil.getMonitorFor(monitor);
    monitor2.beginTask(Messages.publishServerTask, 600);

    // TODO OSAMI 1) Cleanup 2) Backup and Publish,

    // if (status != null && !status.isOK())
    // throw new CoreException(status);

    monitor2.done();

    setServerPublishState(IServer.PUBLISH_STATE_NONE);
  }
Esempio n. 19
0
  @Override
  protected boolean validatePage() {
    IStatus status =
        JavaConventions.validateCompilationUnitName(
            this.getFileName() + ".java", CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3);
    if (!status.isOK()) {
      setErrorMessage(status.getMessage());
      return false;
    }
    IProject project =
        ResourcesPlugin.getWorkspace().getRoot().getProject(getContainerFullPath().segment(0));

    // This may need to change depending on how we want to deal with localized components in future.
    LocatePlugin locatePlugin = LocatePlugin.getDefault();
    try {
      LocalizedComponentsLocateResult result =
          locatePlugin.getLocalizedComponentsLocateResult(project, getFileName());
      if (result.getResources().length > 0) {
        setErrorMessage("A component by that name already exists");
        return false;
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // Check that we aren't going to create a wocomponent inside another wocomponent
    IPath path = getContainerFullPath();
    if (path.lastSegment().endsWith(".wo")) {
      setErrorMessage("Cannot create a component within another component");
      return false;
    }

    return super.validatePage();
  }
  public void testAddExternalJarBug132827() throws Exception {
    fJavaProject = createProject(DEFAULT_OUTPUT_FOLDER_NAME);

    IPath[] jarPaths = new IPath[] {JavaProjectHelper.MYLIB.makeAbsolute()};

    CPJavaProject cpProject = CPJavaProject.createFromExisting(fJavaProject);
    ClasspathModifier.addExternalJars(jarPaths, cpProject);
    ClasspathModifier.commitClassPath(cpProject, null);

    cpProject = CPJavaProject.createFromExisting(fJavaProject);
    IStatus status = ClasspathModifier.checkAddExternalJarsPrecondition(jarPaths, cpProject);
    assertTrue(status.getSeverity() == IStatus.INFO);

    BuildpathDelta delta = ClasspathModifier.addExternalJars(jarPaths, cpProject);
    assertDeltaResources(delta, new IPath[0], new IPath[0], new IPath[0], new IPath[0]);
    assertDeltaDefaultOutputFolder(delta, fJavaProject.getOutputLocation());
    assertDeltaRemovedEntries(delta, new IPath[0]);
    assertDeltaAddedEntries(delta, new IPath[0]);

    ClasspathModifier.commitClassPath(cpProject, null);

    IClasspathEntry[] classpathEntries = fJavaProject.getRawClasspath();
    assertNumberOfEntries(classpathEntries, 2);
    assertIsOnBuildpath(classpathEntries, JavaProjectHelper.MYLIB.makeAbsolute());
  }
 /* (non-Javadoc)
  * @see org.apache.tools.ant.Task#execute()
  */
 public void execute() throws BuildException {
   try {
     prepareSourceRepos();
     application.initializeRepos(null);
     List<IInstallableUnit> ius = prepareIUs();
     if ((ius == null || ius.size() == 0)
         && !(application.hasArtifactSources() || application.hasMetadataSources()))
       throw new BuildException(Messages.exception_needIUsOrNonEmptyRepo);
     application.setSourceIUs(ius);
     ((Repo2Runnable) application).setFlagAsRunnable(flagAsRunnable);
     ((Repo2Runnable) application).setCreateFragments(createFragments);
     IStatus result = application.run(null);
     if (failOnError && result.matches(IStatus.ERROR)) throw new ProvisionException(result);
   } catch (ProvisionException e) {
     if (failOnError)
       throw new BuildException(
           NLS.bind(
               Messages.Repo2RunnableTask_errorTransforming,
               null != e.getMessage() ? e.getMessage() : e.toString()),
           e);
     /* else */
     getProject()
         .log(
             NLS.bind(
                 Messages.Repo2RunnableTask_errorTransforming,
                 null != e.getMessage() ? e.getMessage() : e.toString()),
             Project.MSG_WARN);
     getProject().log(e.getMessage(), Project.MSG_WARN);
   }
 }
  public void testEditOutputFolder01SetOutputFolderForSourceFolder() throws Exception {
    fJavaProject = createProject(DEFAULT_OUTPUT_FOLDER_NAME);
    IPackageFragmentRoot src = JavaProjectHelper.addSourceContainer(fJavaProject, "src");

    IPath projectPath = fJavaProject.getProject().getFullPath();
    IPath outputPath = projectPath.append("srcbin");

    CPJavaProject cpProject = CPJavaProject.createFromExisting(fJavaProject);
    CPListElement element =
        cpProject.getCPElement(
            CPListElement.createFromExisting(src.getRawClasspathEntry(), fJavaProject));
    IStatus status =
        ClasspathModifier.checkSetOutputLocationPrecondition(element, outputPath, false, cpProject);
    assertTrue(status.getMessage(), status.getSeverity() != IStatus.ERROR);

    BuildpathDelta delta =
        ClasspathModifier.setOutputLocation(element, outputPath, false, cpProject);
    assertDeltaResources(delta, new IPath[] {outputPath}, new IPath[0], new IPath[0], new IPath[0]);
    assertDeltaDefaultOutputFolder(delta, fJavaProject.getOutputLocation());
    assertDeltaAddedEntries(delta, new IPath[0]);
    assertDeltaRemovedEntries(delta, new IPath[0]);

    ClasspathModifier.commitClassPath(cpProject, null);

    IClasspathEntry[] classpathEntries = fJavaProject.getRawClasspath();
    assertNumberOfEntries(classpathEntries, 2);
    IClasspathEntry entry = classpathEntries[1];
    assertTrue(src.getRawClasspathEntry() == entry);
    IPath location = entry.getOutputLocation();
    assertTrue(
        "Output path is " + location + " expected was " + outputPath, outputPath.equals(location));
  }
 /* (non-Javadoc)
  * @see org.eclipse.core.databinding.validation.IValidator#validate(java.lang.Object)
  */
 @Override
 public IStatus validate(Object value) {
   IStatus validate = validator.validate(value);
   int severity = validate.getSeverity();
   if (severity > IStatus.OK) {
     controlDecoration.show();
     if (severity >= IStatus.ERROR) {
       controlDecoration.setImage(error);
     } else if (severity == IStatus.WARNING) {
       controlDecoration.setImage(warn);
     } else if (severity == IStatus.INFO) {
       controlDecoration.setImage(info);
     }
     if (updateMessage) {
       controlDecoration.setDescriptionText(validate.getMessage());
     }
   } else {
     controlDecoration.hide();
   }
   if (onlyChangeDecoration) {
     return Status.OK_STATUS;
   } else {
     return validate;
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.papyrus.commands.ICreationCommand#createDiagram(org.eclipse.emf.ecore.resource.Resource, org.eclipse.emf.ecore.EObject,
   * org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype, java.lang.String)
   */
  @Override
  public final Diagram createDiagram(
      ModelSet modelSet, EObject owner, EObject element, ViewPrototype prototype, String name) {
    ICommand createCmd = getCreateDiagramCommand(modelSet, owner, element, prototype, name);
    TransactionalEditingDomain dom = modelSet.getTransactionalEditingDomain();
    CompositeCommand cmd = new CompositeCommand("Create diagram");
    cmd.add(createCmd);
    cmd.add(new OpenDiagramCommand(dom, createCmd));

    try {

      IStatus status =
          CheckedOperationHistory.getInstance().execute(cmd, new NullProgressMonitor(), null);
      if (status.isOK()) {
        CommandResult result = cmd.getCommandResult();
        Object returnValue = result.getReturnValue();

        // CompositeCommands should always return a collection
        if (returnValue instanceof Collection<?>) {
          for (Object returnElement : (Collection<?>) returnValue) {
            if (returnElement instanceof Diagram) {
              return (Diagram) returnElement;
            }
          }
        }
      } else if (status.getSeverity() != IStatus.CANCEL) {
        StatusManager.getManager().handle(status, StatusManager.SHOW);
      }
    } catch (ExecutionException ex) {
      Activator.log.error(ex);
    }

    return null;
  }
  void doAction() {

    JobTreeElement[] jobTreeElements = FinishedJobs.getInstance().getKeptElements();
    // search from end (youngest)
    for (int i = jobTreeElements.length - 1; i >= 0; i--) {
      if (jobTreeElements[i] instanceof JobInfo) {
        JobInfo ji = (JobInfo) jobTreeElements[i];
        Job job = ji.getJob();
        if (job != null) {

          IStatus status = job.getResult();
          if (status != null && status.getSeverity() == IStatus.ERROR) {
            StatusAdapter statusAdapter = StatusAdapterHelper.getInstance().getStatusAdapter(ji);

            if (statusAdapter == null) statusAdapter = new StatusAdapter(status);

            StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);

            removeTopElement(ji);
          }

          execute(ji, job);
        }
      }
    }

    progressRegion.processDoubleClick();
    refresh();
  }
  private IStatus validateLocation() {
    String location = projectLocationField.getText();

    if (!new Path(location).isValidPath(getProjectName())) {
      return new Status(
          IStatus.ERROR,
          DartToolsPlugin.PLUGIN_ID,
          ProjectMessages.NewProjectCreationPage_invalid_loc);
    }

    if (doesProjectExist()) {
      return new Status(
          IStatus.ERROR,
          DartToolsPlugin.PLUGIN_ID,
          NLS.bind(ProjectMessages.NewApplicationWizardPage_error_existing, getProjectName()));
    }

    IStatus status = DirectoryVerification.getOpenDirectoryLocationStatus(new File(location));

    if (!status.isOK()) {
      return status;
    }

    return Status.OK_STATUS;
  }
Esempio n. 27
0
  /**
   * Applies the status to the status line of a dialog page.
   *
   * @param page the dialog page
   * @param status the status to apply
   */
  public static void applyToStatusLine(DialogPage page, IStatus status) {
    if (status == null) {
      page.setMessage(null, IMessageProvider.NONE);
      page.setErrorMessage(null);
      return;
    }

    String message = status.getMessage();

    if (message != null && message.length() == 0) {
      message = null;
    }

    switch (status.getSeverity()) {
      case IStatus.OK:
        page.setMessage(message, IMessageProvider.NONE);
        page.setErrorMessage(null);
        break;
      case IStatus.WARNING:
        page.setMessage(message, IMessageProvider.WARNING);
        page.setErrorMessage(null);
        break;
      case IStatus.INFO:
        page.setMessage(message, IMessageProvider.INFORMATION);
        page.setErrorMessage(null);
        break;
      default:
        page.setMessage(null);
        page.setErrorMessage(message);
        break;
    }
  }
Esempio n. 28
0
 private IIndexFragmentName createPDOMName(PDOMLinkage linkage, IASTName name, PDOMName caller)
     throws CoreException {
   final IBinding binding = name.getBinding();
   if (binding instanceof IParameter) {
     return null;
   }
   try {
     if (binding instanceof IMacroBinding
         || (binding == null
             && name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME)) {
       return createPDOMMacroReferenceName(linkage, name);
     }
     PDOMBinding pdomBinding = linkage.addBinding(name);
     if (pdomBinding != null) {
       final PDOMName result = new PDOMName(fLinkage, name, this, pdomBinding, caller);
       linkage.onCreateName(this, name, result);
       return result;
     }
   } catch (CoreException e) {
     final IStatus status = e.getStatus();
     if (status != null && status.getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE) {
       if (CCorePlugin.PLUGIN_ID.equals(status.getPlugin())) throw e;
     }
     CCorePlugin.log(e);
   }
   return null;
 }
  private IStatus validateFileName() {
    fileName = null;

    String str = fileNameField.getText().trim();
    if (str.length() == 0) {
      return Util.newErrorStatus("Enter a file name");
    }

    // Validate the file name
    IStatus nameStatus = ResourcesPlugin.getWorkspace().validateName(str, IResource.FILE);
    if (nameStatus.matches(IStatus.ERROR)) {
      return Util.newErrorStatus("Invalid file name. {0}", nameStatus.getMessage());
    }

    // Make sure the host page doesn't already exist in the public path
    if (hostPagePath != null) {
      IPath htmlFilePath =
          hostPagePath
              .append(str)
              .removeFileExtension()
              .addFileExtension(((AbstractNewFileWizard) getWizard()).getFileExtension());
      IFile htmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(htmlFilePath);
      if (htmlFile.exists()) {
        return Util.newErrorStatus("''{0}'' already exists", htmlFilePath.toString());
      }
    }

    fileName = str;
    return Status.OK_STATUS;
  }
Esempio n. 30
0
  protected void checkIfPathValid() {
    fFolder = null;
    IContainer folder = null;
    if (fUseFolderButton.isSelected()) {
      String pathStr = fContainerDialogField.getText();
      if (pathStr.length() == 0) {
        fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_enterpath);
        return;
      }
      IPath path = fCurrProject.getFullPath().append(pathStr);
      IWorkspace workspace = fCurrProject.getWorkspace();

      IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
      if (!pathValidation.isOK()) {
        fContainerFieldStatus.setError(
            Messages.format(
                NewWizardMessages.NewSourceFolderDialog_error_invalidpath,
                pathValidation.getMessage()));
        return;
      }
      folder = fCurrProject.getFolder(pathStr);
    } else {
      folder = fCurrProject;
    }
    if (isExisting(folder)) {
      fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_pathexists);
      return;
    }
    fContainerFieldStatus.setOK();
    fFolder = folder;
  }