Java 类com.intellij.openapi.vfs.impl.http.HttpVirtualFile 实例源码

项目:intellij-ce-playground    文件:HttpFileEditor.java   
public HttpFileEditor(@NotNull Project project, @NotNull HttpVirtualFile virtualFile) {
  super(project);

  myPanel = new RemoteFilePanel(project, virtualFile, this);
  RemoteFileInfo fileInfo = virtualFile.getFileInfo();
  assert fileInfo != null;
  fileInfo.download()
    .done(new Consumer<VirtualFile>() {
      @Override
      public void consume(VirtualFile file) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            contentLoaded();
          }
        }, myProject.getDisposed());
      }
    })
    .rejected(new Consumer<Throwable>() {
      @Override
      public void consume(Throwable throwable) {
        contentRejected();
      }
    });
}
项目:consulo-xml    文件:SelectInDefaultBrowserTarget.java   
@Override
public boolean canSelect(SelectInContext context)
{
    Object selectorInFile = context.getSelectorInFile();
    OpenInBrowserRequest request = selectorInFile instanceof PsiElement ? OpenInBrowserRequest.create((PsiElement) selectorInFile) : null;
    if(request == null)
    {
        return false;
    }

    WebBrowserUrlProvider urlProvider = WebBrowserServiceImpl.getProvider(request);
    if(urlProvider == null)
    {
        VirtualFile virtualFile = request.getVirtualFile();
        return virtualFile instanceof HttpVirtualFile || (HtmlUtil.isHtmlFile(request.getFile()) && !(virtualFile instanceof LightVirtualFile));
    }
    return true;
}
项目:intellij-ce-playground    文件:BuiltInWebBrowserUrlProvider.java   
@Override
public boolean canHandleElement(@NotNull OpenInBrowserRequest request) {
  if (request.getVirtualFile() instanceof HttpVirtualFile) {
    return true;
  }

  // we must use base language because we serve file - not part of file, but the whole file
  // handlebars, for example, contains HTML and HBS psi trees, so, regardless of context, we should not handle such file
  FileViewProvider viewProvider = request.getFile().getViewProvider();
  return viewProvider.isPhysical() &&
         !(request.getVirtualFile() instanceof LightVirtualFile) &&
         isMyLanguage(viewProvider.getBaseLanguage());
}
项目:intellij-ce-playground    文件:BuiltInWebBrowserUrlProvider.java   
@Nullable
@Override
protected Url getUrl(@NotNull OpenInBrowserRequest request, @NotNull VirtualFile file) throws BrowserException {
  if (file instanceof HttpVirtualFile) {
    return Urls.newFromVirtualFile(file);
  }
  else {
    return ContainerUtil.getFirstItem(getUrls(file, request.getProject(), null));
  }
}
项目:intellij-ce-playground    文件:ContextMenuImpl.java   
public static boolean mayShowToolbar(@Nullable final Document document) {
  if (document == null) {
    return false;
  }

  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  return file != null && file.isValid() && (file.isInLocalFileSystem() || file instanceof HttpVirtualFile);
}
项目:intellij-ce-playground    文件:XSourcePositionImpl.java   
/**
 * do not call this method from plugins, use {@link com.intellij.xdebugger.XDebuggerUtil#createPosition(com.intellij.openapi.vfs.VirtualFile, int)} instead
 */
@Nullable
public static XSourcePositionImpl create(@Nullable VirtualFile file, int line) {
  if (file == null) {
    return null;
  }

  AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    int offset;
    if (file instanceof LightVirtualFile || file instanceof HttpVirtualFile) {
      offset = -1;
    }
    else {

      Document document = file.isValid() ? FileDocumentManager.getInstance().getDocument(file) : null;
      if (document == null) {
        return null;
      }
      if (line < 0) {
        line = 0;
      }

      offset = line < document.getLineCount() ? document.getLineStartOffset(line) : -1;
    }
    return new XSourcePositionImpl(file, line, offset);
  }
  finally {
    lock.finish();
  }
}
项目:intellij-ce-playground    文件:HtmlFileImpl.java   
@Nullable
@Override
public PsiFileSystemItem resolveFileReference(@NotNull FileReference reference, @NotNull String name) {
  VirtualFile file = getVirtualFile();
  if (!(file instanceof HttpVirtualFile)) {
    return null;
  }

  VirtualFile parent = file;
  if (!parent.isDirectory()) {
    parent = parent.getParent();
    if (parent == null) {
      parent = file;
    }
  }

  VirtualFile childFile = parent.findChild(name);
  HttpFileSystem fileSystem = (HttpFileSystem)parent.getFileSystem();
  if (childFile == null) {
    childFile = fileSystem.createChild(parent, name, !reference.isLast());
  }
  if (childFile.isDirectory()) {
    // pre create children
    VirtualFile childParent = childFile;
    FileReference[] references = reference.getFileReferenceSet().getAllReferences();
    for (int i = reference.getIndex() + 1, n = references.length; i < n; i++) {
      FileReference childReference = references[i];
      childParent = fileSystem.createChild(childParent, childReference.decode(childReference.getText()), i != (n - 1));
    }
    return getManager().findDirectory(childFile);
  }
  else {
    return getManager().findFile(childFile);
  }
}
项目:intellij-ce-playground    文件:BreadcrumbsLoaderComponent.java   
private static boolean isSuitable(@NotNull Project project, @NotNull VirtualFile file) {
  if (file instanceof HttpVirtualFile) {
    return false;
  }

  final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(file);
  return provider != null && BreadcrumbsXmlWrapper.findInfoProvider(provider) != null;
}
项目:intellij-ce-playground    文件:SelectInDefaultBrowserTarget.java   
@Override
public boolean canSelect(SelectInContext context) {
  Object selectorInFile = context.getSelectorInFile();
  OpenInBrowserRequest request = selectorInFile instanceof PsiElement ? OpenInBrowserRequest.create((PsiElement)selectorInFile) : null;
  if (request == null) {
    return false;
  }

  WebBrowserUrlProvider urlProvider = WebBrowserServiceImpl.getProvider(request);
  if (urlProvider == null) {
    VirtualFile virtualFile = request.getVirtualFile();
    return virtualFile instanceof HttpVirtualFile || (HtmlUtil.isHtmlFile(request.getFile()) && !(virtualFile instanceof LightVirtualFile));
  }
  return true;
}
项目:tools-idea    文件:ContextMenuImpl.java   
public static boolean mayShowToolbar(@Nullable final Document document) {
  if (document == null) {
    return false;
  }

  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  return file != null && file.isValid() && (file.getFileSystem() == LocalFileSystem.getInstance() || file instanceof HttpVirtualFile);
}
项目:tools-idea    文件:BreadcrumbsLoaderComponent.java   
private static boolean isSuitable(final Project project, final VirtualFile file) {
  if (file instanceof HttpVirtualFile) {
    return false;
  }

  final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(file);

  return provider != null && BreadcrumbsXmlWrapper.findInfoProvider(provider) != null;
}
项目:tools-idea    文件:WebBrowserServiceImpl.java   
@Override
@Nullable
public Url getUrlToOpen(@NotNull PsiElement psiElement, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException {
  final PsiFile psiFile = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile();
  if (psiFile == null) {
    return null;
  }
  VirtualFile virtualFile = psiFile.getVirtualFile();
  if (virtualFile == null) {
    return null;
  }
  if (virtualFile instanceof HttpVirtualFile) {
    return Urls.newFromVirtualFile(virtualFile);
  }

  if (!(preferLocalUrl && HtmlUtil.isHtmlFile(psiFile))) {
    Pair<WebBrowserUrlProvider, Url> provider = getProvider(psiElement);
    if (provider != null) {
      if (provider.second != null) {
        return provider.second;
      }

      try {
        Url url = provider.first.getUrl(psiElement, psiFile, virtualFile);
        if (url != null) {
          return url;
        }
      }
      catch (WebBrowserUrlProvider.BrowserException e) {
        if (!HtmlUtil.isHtmlFile(psiFile)) {
          throw e;
        }
      }
    }
  }
  return virtualFile instanceof LightVirtualFile ? null : Urls.newFromVirtualFile(virtualFile);
}
项目:consulo    文件:ContextMenuImpl.java   
public static boolean mayShowToolbar(@Nullable final Document document) {
  if (document == null) {
    return false;
  }

  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
  return file != null && file.isValid() && (file.getFileSystem() == LocalFileSystem.getInstance() || file instanceof HttpVirtualFile);
}
项目:consulo    文件:XSourcePositionImpl.java   
/**
 * do not call this method from plugins, use {@link com.intellij.xdebugger.XDebuggerUtil#createPosition(com.intellij.openapi.vfs.VirtualFile, int)} instead
 */
@Nullable
public static XSourcePositionImpl create(@Nullable VirtualFile file, int line) {
  if (file == null) {
    return null;
  }

  AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    int offset;
    if (file instanceof LightVirtualFile || file instanceof HttpVirtualFile) {
      offset = -1;
    }
    else {

      Document document = file.isValid() ? FileDocumentManager.getInstance().getDocument(file) : null;
      if (document == null) {
        return null;
      }
      if (line < 0) {
        line = 0;
      }

      offset = line < document.getLineCount() ? document.getLineStartOffset(line) : -1;
    }
    return new XSourcePositionImpl(file, line, offset);
  }
  finally {
    lock.finish();
  }
}
项目:consulo    文件:BreadcrumbsInitializingActivity.java   
private static boolean isSuitable(@Nonnull TextEditor editor, @Nonnull VirtualFile file) {
  if (file instanceof HttpVirtualFile) {
    return false;
  }

  return editor.isValid() && BreadcrumbsWrapper.findInfoProvider(editor.getEditor(), file) != null;
}
项目:consulo-xml    文件:WebBrowserServiceImpl.java   
@NotNull
@Override
public Collection<Url> getUrlsToOpen(@NotNull OpenInBrowserRequest request, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException
{
    VirtualFile virtualFile = request.getVirtualFile();
    if(virtualFile instanceof HttpVirtualFile)
    {
        return Collections.singleton(Urls.newFromVirtualFile(virtualFile));
    }

    if(!preferLocalUrl || !HtmlUtil.isHtmlFile(request.getFile()))
    {
        WebBrowserUrlProvider provider = getProvider(request);
        if(provider != null)
        {
            if(request.getResult() != null)
            {
                return request.getResult();
            }

            try
            {
                Collection<Url> urls = provider.getUrls(request);
                if(!urls.isEmpty())
                {
                    return urls;
                }
            }
            catch(WebBrowserUrlProvider.BrowserException e)
            {
                if(!HtmlUtil.isHtmlFile(request.getFile()))
                {
                    throw e;
                }
            }
        }
    }
    return virtualFile instanceof LightVirtualFile || !request.getFile().getViewProvider().isPhysical() ? Collections.<Url>emptySet() :
            Collections.singleton(Urls.newFromVirtualFile(virtualFile));
}
项目:intellij-ce-playground    文件:RemoteFilePanel.java   
public RemoteFilePanel(final Project project, final HttpVirtualFile virtualFile, @NotNull PropertyChangeListener propertyChangeListener) {
  myProject = project;
  myVirtualFile = virtualFile;
  myPropertyChangeListener = propertyChangeListener;
  myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning);
  myUrlTextField.setText(virtualFile.getUrl());
  myProgressUpdatesQueue = new MergingUpdateQueue("downloading progress updates", 300, false, myMainPanel);
  initToolbar(project);

  final RemoteFileInfo remoteFileInfo = virtualFile.getFileInfo();
  myDownloadingListener = new MyDownloadingListener();
  assert remoteFileInfo != null;
  remoteFileInfo.addDownloadingListener(myDownloadingListener);
  myCancelButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(@NotNull final ActionEvent e) {
      remoteFileInfo.cancelDownloading();
    }
  });

  myTryAgainButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(@NotNull final ActionEvent e) {
      showCard(DOWNLOADING_CARD);
      remoteFileInfo.restartDownloading();
    }
  });
  myChangeProxySettingsButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(@NotNull ActionEvent e) {
      HttpConfigurable.editConfigurable(myMainPanel);
    }
  });

  if (remoteFileInfo.getState() != RemoteFileState.DOWNLOADED) {
    showCard(DOWNLOADING_CARD);
    remoteFileInfo.startDownloading();
  }

  // file could be from cache
  if (remoteFileInfo.getState() == RemoteFileState.DOWNLOADED) {
    switchEditor();
  }
  else {
    String errorMessage = remoteFileInfo.getErrorMessage();
    if (errorMessage != null) {
      myDownloadingListener.errorOccurred(errorMessage);
    }
  }
}
项目:intellij-ce-playground    文件:RemoteFileEditorActionProvider.java   
@NotNull
public abstract AnAction[] createToolbarActions(@NotNull Project project, @NotNull HttpVirtualFile file);
项目:intellij-ce-playground    文件:HttpFileEditorProvider.java   
@Override
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file) {
  return file instanceof HttpVirtualFile && !file.isDirectory();
}
项目:intellij-ce-playground    文件:HttpFileEditorProvider.java   
@Override
@NotNull
public FileEditor createEditor(@NotNull final Project project, @NotNull final VirtualFile file) {
  return new HttpFileEditor(project, (HttpVirtualFile)file);
}
项目:intellij-ce-playground    文件:RefreshRemoteFileAction.java   
public RefreshRemoteFileAction(HttpVirtualFile file) {
  super("Reload File", "", AllIcons.Actions.Refresh);
  myFile = file;
}
项目:intellij-ce-playground    文件:JumpFromRemoteFileToLocalAction.java   
public JumpFromRemoteFileToLocalAction(HttpVirtualFile file, Project project) {
  super("Find Local File", "", AllIcons.General.AutoscrollToSource);

  myFile = file;
  myProject = project;
}
项目:intellij-ce-playground    文件:LangRemoteFileEditorActionProvider.java   
@NotNull
@Override
public AnAction[] createToolbarActions(@NotNull Project project, @NotNull HttpVirtualFile file) {
  return new AnAction[] {new JumpFromRemoteFileToLocalAction(file, project)};
}
项目:intellij-ce-playground    文件:HttpFileReferenceHelper.java   
@Override
public boolean isMine(Project project, @NotNull VirtualFile file) {
  return file instanceof HttpVirtualFile;
}
项目:tools-idea    文件:RemoteFileEditorActionProvider.java   
@NotNull
public abstract AnAction[] createToolbarActions(@NotNull Project project, @NotNull HttpVirtualFile file);
项目:tools-idea    文件:HttpFileEditorProvider.java   
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file) {
  return file instanceof HttpVirtualFile && !file.isDirectory();
}
项目:tools-idea    文件:HttpFileEditorProvider.java   
@NotNull
public FileEditor createEditor(@NotNull final Project project, @NotNull final VirtualFile file) {
  return new HttpFileEditor(project, (HttpVirtualFile)file); 
}
项目:tools-idea    文件:RefreshRemoteFileAction.java   
public RefreshRemoteFileAction(HttpVirtualFile file) {
  super("Reload File", "", AllIcons.Actions.Refresh);
  myFile = file;
}
项目:tools-idea    文件:HttpFileEditor.java   
public HttpFileEditor(final Project project, final HttpVirtualFile virtualFile) {
  myProject = project;
  myPanel = new RemoteFilePanel(project, virtualFile);
}
项目:tools-idea    文件:JumpFromRemoteFileToLocalAction.java   
public JumpFromRemoteFileToLocalAction(HttpVirtualFile file, Project project) {
  super("Find Local File", "", AllIcons.General.AutoscrollToSource);
  myFile = file;
  myProject = project;
}
项目:tools-idea    文件:LangRemoteFileEditorActionProvider.java   
@NotNull
@Override
public AnAction[] createToolbarActions(@NotNull Project project, @NotNull HttpVirtualFile file) {
  return new AnAction[] {new JumpFromRemoteFileToLocalAction(file, project)};
}
项目:consulo    文件:RemoteFileEditorActionProvider.java   
@Nonnull
public abstract AnAction[] createToolbarActions(@Nonnull Project project, @Nonnull HttpVirtualFile file);
项目:consulo    文件:HttpFileEditorProvider.java   
public boolean accept(@Nonnull final Project project, @Nonnull final VirtualFile file) {
  return file instanceof HttpVirtualFile && !file.isDirectory();
}
项目:consulo    文件:HttpFileEditorProvider.java   
@Nonnull
public FileEditor createEditor(@Nonnull final Project project, @Nonnull final VirtualFile file) {
  return new HttpFileEditor(project, (HttpVirtualFile)file); 
}
项目:consulo    文件:RefreshRemoteFileAction.java   
public RefreshRemoteFileAction(HttpVirtualFile file) {
  super("Reload File", "", AllIcons.Actions.Refresh);
  myFile = file;
}
项目:consulo    文件:HttpFileEditor.java   
public HttpFileEditor(final Project project, final HttpVirtualFile virtualFile) {
  myProject = project;
  myPanel = new RemoteFilePanel(project, virtualFile);
}
项目:consulo    文件:JumpFromRemoteFileToLocalAction.java   
public JumpFromRemoteFileToLocalAction(HttpVirtualFile file, Project project) {
  super("Find Local File", "", AllIcons.General.AutoscrollToSource);
  myFile = file;
  myProject = project;
}
项目:consulo    文件:LangRemoteFileEditorActionProvider.java   
@Nonnull
@Override
public AnAction[] createToolbarActions(@Nonnull Project project, @Nonnull HttpVirtualFile file) {
  return new AnAction[] {new JumpFromRemoteFileToLocalAction(file, project)};
}
项目:consulo    文件:HttpFileReferenceHelper.java   
@Override
public boolean isMine(Project project, @Nonnull VirtualFile file) {
  return file instanceof HttpVirtualFile;
}