Java Code Examples for com.intellij.openapi.vfs.VirtualFile#PropName

The following examples show how to use com.intellij.openapi.vfs.VirtualFile#PropName . These examples are extracted from open source projects. 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
public VFilePropertyChangeEvent(Object requestor,
                                @Nonnull VirtualFile file,
                                @VirtualFile.PropName @Nonnull String propertyName,
                                @Nullable Object oldValue,
                                @Nullable Object newValue,
                                boolean isFromRefresh) {
  super(requestor, isFromRefresh);
  myFile = file;
  myPropertyName = propertyName;
  myOldValue = oldValue;
  myNewValue = newValue;
  checkPropertyValuesCorrect(requestor, propertyName, oldValue, newValue);
}
 
Example 2
public static void checkPropertyValuesCorrect(Object requestor, @VirtualFile.PropName @Nonnull String propertyName, Object oldValue, Object newValue) {
  if (Comparing.equal(oldValue, newValue) && FileContentUtilCore.FORCE_RELOAD_REQUESTOR != requestor) {
    throw new IllegalArgumentException("Values must be different, got the same: " + oldValue);
  }
  switch (propertyName) {
    case VirtualFile.PROP_NAME:
      if (oldValue == null) throw new IllegalArgumentException("oldName must not be null");
      if (!(oldValue instanceof String)) throw new IllegalArgumentException("oldName must be String, got " + oldValue);
      if (newValue == null) throw new IllegalArgumentException("newName must not be null");
      if (!(newValue instanceof String)) throw new IllegalArgumentException("newName must be String, got " + newValue);
      break;
    case VirtualFile.PROP_ENCODING:
      if (oldValue == null) throw new IllegalArgumentException("oldCharset must not be null");
      if (!(oldValue instanceof Charset)) throw new IllegalArgumentException("oldValue must be Charset, got " + oldValue);
      break;
    case VirtualFile.PROP_WRITABLE:
      if (!(oldValue instanceof Boolean)) throw new IllegalArgumentException("oldWriteable must be boolean, got " + oldValue);
      if (!(newValue instanceof Boolean)) throw new IllegalArgumentException("newWriteable must be boolean, got " + newValue);
      break;
    case VirtualFile.PROP_HIDDEN:
      if (!(oldValue instanceof Boolean)) throw new IllegalArgumentException("oldHidden must be boolean, got " + oldValue);
      if (!(newValue instanceof Boolean)) throw new IllegalArgumentException("newHidden must be boolean, got " + newValue);
      break;
    case VirtualFile.PROP_SYMLINK_TARGET:
      if (oldValue != null && !(oldValue instanceof String)) {
        throw new IllegalArgumentException("oldSymTarget must be String, got " + oldValue);
      }
      if (newValue != null && !(newValue instanceof String)) {
        throw new IllegalArgumentException("newSymTarget must be String, got " + newValue);
      }
      break;
    default:
      throw new IllegalArgumentException("Unknown property name '" + propertyName + "'. " + "Must be one of VirtualFile.{PROP_NAME|PROP_ENCODING|PROP_WRITABLE|PROP_HIDDEN|PROP_SYMLINK_TARGET}");
  }
}
 
Example 3
@Nonnull
@VirtualFile.PropName
public String getPropertyName() {
  return myPropertyName;
}
 
Example 4
void scheduleAttributeChange(@Nonnull VirtualFile file, @VirtualFile.PropName @Nonnull String property, Object current, Object upToDate) {
  if (LOG.isTraceEnabled()) LOG.trace("update file=" + file + ' ' + property + '=' + current + "->" + upToDate);
  myEvents.add(new VFilePropertyChangeEvent(null, file, property, current, upToDate, true));
}