com.intellij.openapi.fileEditor.FileEditorPolicy Java Examples

The following examples show how to use com.intellij.openapi.fileEditor.FileEditorPolicy. 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
Source File: CsvTableEditorProviderTest.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
public void testCsvTableEditorProviderIsAvailableAndHasCorrectNameAndPolicy() {
    FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(getProject(), myFixture.getFile().getVirtualFile());
    assertEquals(2, fileEditorProviders.length);
    assertInstanceOf(fileEditorProviders[1], CsvTableEditorProvider.class);

    FileEditorProvider fileEditorProvider = fileEditorProviders[1];
    assertEquals(CsvTableEditorProvider.EDITOR_TYPE_ID, fileEditorProvider.getEditorTypeId());
    assertEquals(FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR, fileEditorProvider.getPolicy());
    assertEquals(true, fileEditorProvider.accept(getProject(), myFixture.getFile().getVirtualFile()));

    CsvEditorSettings csvEditorSettings = CsvEditorSettings.getInstance();
    csvEditorSettings.setEditorPrio(CsvEditorSettings.EditorPrio.TEXT_ONLY);
    assertEquals(FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR, fileEditorProvider.getPolicy());
    assertEquals(false, fileEditorProvider.accept(getProject(), myFixture.getFile().getVirtualFile()));

    csvEditorSettings.setEditorPrio(CsvEditorSettings.EditorPrio.TABLE_FIRST);
    assertEquals(FileEditorPolicy.HIDE_DEFAULT_EDITOR, fileEditorProvider.getPolicy());
    assertEquals(true, fileEditorProvider.accept(getProject(), myFixture.getFile().getVirtualFile()));
}
 
Example #2
Source File: CsvTableEditorProvider.java    From intellij-csv-validator with Apache License 2.0 5 votes vote down vote up
@Override
public FileEditorPolicy getPolicy() {
    switch (CsvEditorSettings.getInstance().getEditorPrio()) {
        case TEXT_FIRST:
        case TEXT_ONLY:
            return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR;
        case TABLE_FIRST:
            return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
        default:
            throw new IllegalArgumentException("unhandled EditorPrio: " + CsvEditorSettings.getInstance().getEditorPrio());
    }
}
 
Example #3
Source File: FileEditorProviderManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public FileEditorProvider[] getProviders(@Nonnull final Project project, @Nonnull final VirtualFile file) {
  // Collect all possible editors
  List<FileEditorProvider> sharedProviders = new ArrayList<>();
  boolean doNotShowTextEditor = false;
  for (final FileEditorProvider provider : myProviders) {
    ThrowableComputable<Boolean, RuntimeException> action = () -> {
      if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) {
        return false;
      }
      return provider.accept(project, file);
    };
    if (AccessRule.read(action)) {
      sharedProviders.add(provider);
      doNotShowTextEditor |= provider.getPolicy() == FileEditorPolicy.HIDE_DEFAULT_EDITOR;
    }
  }

  // Throw out default editors provider if necessary
  if (doNotShowTextEditor) {
    ContainerUtil.retainAll(sharedProviders, provider -> !(provider instanceof TextEditorProvider));
  }

  // Sort editors according policies
  Collections.sort(sharedProviders, MyComparator.ourInstance);

  return sharedProviders.toArray(new FileEditorProvider[sharedProviders.size()]);
}
 
Example #4
Source File: CmtFileEditorProvider.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
@Override
public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR;
}
 
Example #5
Source File: BPMNFileEditorProvider.java    From intellij-bpmn-editor with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
@Override
public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.PLACE_BEFORE_DEFAULT_EDITOR;
}
 
Example #6
Source File: WeaveEditorProvider.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.PLACE_BEFORE_DEFAULT_EDITOR;
}
 
Example #7
Source File: ApiFileViewEditorProvider.java    From ApiDebugger with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.PLACE_BEFORE_DEFAULT_EDITOR;
}
 
Example #8
Source File: MindMapDocumentEditorProvider.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public FileEditorPolicy getPolicy() {
  return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
}
 
Example #9
Source File: NoSqlDatabaseDataEditorProvider.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public FileEditorPolicy getPolicy() {
    return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
}
 
Example #10
Source File: CSharpAssemblyFileEditorProvider.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public FileEditorPolicy getPolicy()
{
	return FileEditorPolicy.PLACE_BEFORE_DEFAULT_EDITOR;
}
 
Example #11
Source File: MyFileEditorProvider.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
@NotNull
public FileEditorPolicy getPolicy() {
	return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR;
}
 
Example #12
Source File: HttpFileEditorProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public FileEditorPolicy getPolicy() {
  return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
}
 
Example #13
Source File: SandFileEditorProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public FileEditorPolicy getPolicy() {
  return FileEditorPolicy.PLACE_AFTER_DEFAULT_EDITOR;
}