예제 #1
0
 @Override
 public void appendContents(InputStream content, int updateFlags, IProgressMonitor monitor)
     throws CoreException {
   monitor = Policy.monitorFor(monitor);
   try {
     String message = NLS.bind(Messages.resources_settingContents, getFullPath());
     monitor.beginTask(message, Policy.totalWork);
     Assert.isNotNull(content, "Content cannot be null."); // $NON-NLS-1$
     if (workspace.shouldValidate) workspace.validateSave(this);
     final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
     try {
       workspace.prepareOperation(rule, monitor);
       ResourceInfo info = getResourceInfo(false, false);
       checkAccessible(getFlags(info));
       workspace.beginOperation(true);
       IFileInfo fileInfo = getStore().fetchInfo();
       internalSetContents(
           content, fileInfo, updateFlags, true, Policy.subMonitorFor(monitor, Policy.opWork));
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } finally {
     monitor.done();
     FileUtil.safeClose(content);
   }
 }
예제 #2
0
  /**
   * Returns the charset explicitly set by the user for the given resource, or <code>null</code>. If
   * no setting exists for the given resource and <code>recurse</code> is <code>true</code>, every
   * parent up to the workspace root will be checked until a charset setting can be found.
   *
   * @param resourcePath the path for the resource
   * @param recurse whether the parent should be queried
   * @return the charset setting for the given resource
   */
  public String getCharsetFor(IPath resourcePath, boolean recurse) {
    Assert.isLegal(resourcePath.segmentCount() >= 1);
    IProject project = workspace.getRoot().getProject(resourcePath.segment(0));

    Preferences prefs = getPreferences(project, false, false);
    Preferences derivedPrefs = getPreferences(project, false, true);

    if (prefs == null && derivedPrefs == null)
      // no preferences found - for performance reasons, short-circuit
      // lookup by falling back to workspace's default setting
      return recurse ? ResourcesPlugin.getEncoding() : null;

    return internalGetCharsetFor(prefs, derivedPrefs, resourcePath, recurse);
  }
예제 #3
0
  /**
   * Checks whether the given move included is vaild
   *
   * @param destination
   * @return a staus indicating whether the included is valid or not
   */
  public RefactoringStatus verifyDestination(IResource destination) {
    RefactoringStatus status = new RefactoringStatus();

    Assert.isNotNull(destination);
    if (!destination.exists() || destination.isPhantom())
      return RefactoringStatus.createFatalErrorStatus(
          PhpRefactoringCoreMessages.getString("MoveDelegate.2")); // $NON-NLS-1$
    if (!destination.isAccessible())
      return RefactoringStatus.createFatalErrorStatus(
          PhpRefactoringCoreMessages.getString("MoveDelegate.3")); // $NON-NLS-1$
    Assert.isTrue(destination.getType() != IResource.ROOT);

    IResource[] sourceResources = fProcessor.getSourceSelection();
    for (IResource element : sourceResources) {
      if (destination.equals(element.getParent()))
        return RefactoringStatus.createFatalErrorStatus(
            PhpRefactoringCoreMessages.getString("MoveDelegate.4")); // $NON-NLS-1$
      if (destination.equals(element)) {
        return RefactoringStatus.createFatalErrorStatus(
            PhpRefactoringCoreMessages.getString("MoveDelegate.5")); // $NON-NLS-1$
      }
    }
    return status;
  }
예제 #4
0
  /** {@inheritDoc} */
  public void open(PharPackage jarPackage, Shell displayShell, MultiStatus statusMsg)
      throws CoreException {
    super.open(jarPackage, displayShell, statusMsg);
    fJarPackage = jarPackage;
    Assert.isTrue(
        fJarPackage.isValid(), "The PHAR package specification is invalid"); // $NON-NLS-1$
    if (!canCreateJar(displayShell)) throw new OperationCanceledException();

    try {
      fileExporter = PharExportHelper.createFileExporter(fJarPackage);
    } catch (IOException ex) {
      throw PharUIUtil.createCoreException(ex.getLocalizedMessage(), ex);
    }
    // fJarWriter= new PharWriter3(fJarPackage, displayShell);
  }