Beispiel #1
0
  @Override
  public RefactoringStatus initializeRefactoring(IProgressMonitor pm) {
    RefactoringStatus ret = new RefactoringStatus();
    ProjectUtil projectUtil = getProjectUtil();
    try {
      if (!isApplicable()) {
        ret.addFatalError("The Refactoring is no Accessable");
      }
      if (!findComponentDefinition(ret)) {
        return ret;
      }
      declaringFile = getIFile4ParseFile(componentDefinition.getParseFile());
      affectedIdentifiers = gatherAffectedIdentifiers(pm);

    } catch (Exception e) {
      ret.addFatalError("Exception during initialization. See project log for more information.");
      projectUtil.log("Exception during initialization.", e);
    }
    return ret;
  }
Beispiel #2
0
 /**
  * Find the component definition. If couldnt find fatalError is addet to Refactoringstatus.
  *
  * @return false if couldnt find definition, true otherwise.
  * @param ret
  * @throws CoreException
  * @throws MissingNatureException
  */
 private boolean findComponentDefinition(RefactoringStatus ret)
     throws CoreException, MissingNatureException {
   Identifier selectedIdentifier = getSelectedIdentifier();
   ComponentSelectionIdentifier selectionIdentifier =
       new ComponentSelectionIdentifier(selectedIdentifier);
   if (!selectionIdentifier.isComponent()) {
     ret.addFatalError("No Component selected.");
     return false;
   }
   componentDefinition = getProjectUtil().getComponentDefinition(selectedIdentifier.getName());
   if (componentDefinition == null) {
     ret.addFatalError(
         "Did not find an component Definition, for selection: "
             + selectedIdentifier.getName()
             + "!");
     return false;
   } else if (!componentDefinition.getParseFile().isProjectFile()) {
     ret.addFatalError("Component definition is out of project range!");
     return false;
   }
   return true;
 }