当前位置: 首页>>代码示例>>Java>>正文


Java PlainTextFileType.INSTANCE属性代码示例

本文整理汇总了Java中com.intellij.openapi.fileTypes.PlainTextFileType.INSTANCE属性的典型用法代码示例。如果您正苦于以下问题:Java PlainTextFileType.INSTANCE属性的具体用法?Java PlainTextFileType.INSTANCE怎么用?Java PlainTextFileType.INSTANCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.openapi.fileTypes.PlainTextFileType的用法示例。


在下文中一共展示了PlainTextFileType.INSTANCE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNotificationPanel

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
  if (file.getFileType() != PlainTextFileType.INSTANCE) return null;

  final String extension = file.getExtension();
  final String fileName = file.getName();
  if (extension != null && isIgnored("*." + extension) || isIgnored(fileName)) return null;

  final PluginsAdvertiser.KnownExtensions knownExtensions = PluginsAdvertiser.loadExtensions();
  if (knownExtensions != null) {
    final EditorNotificationPanel panel = extension != null ? createPanel("*." + extension, knownExtensions) : null;
    if (panel != null) {
      return panel;
    }
    return createPanel(fileName, knownExtensions);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PluginAdvertiserEditorNotificationProvider.java

示例2: getFile

@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
  VcsFileRevision revision = getFileRevision(e);
  if (revision == null) return null;

  final FileType currentFileType = myAnnotation.getFile().getFileType();
  FilePath filePath =
    (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
  return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
    @NotNull
    @Override
    public FileType getFileType() {
      FileType type = super.getFileType();
      if (!type.isBinary()) return type;
      if (!currentFileType.isBinary()) return currentFileType;
      return PlainTextFileType.INSTANCE;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AnnotateRevisionAction.java

示例3: showUsages

private static void showUsages(@NotNull JPanel panel, @Nullable TextDescriptor exampleUsage) {
  String text = "";
  FileType fileType = PlainTextFileType.INSTANCE;
  if (exampleUsage != null) {
    try {
      text = exampleUsage.getText();
      String name = exampleUsage.getFileName();
      FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      String extension = fileTypeManager.getExtension(name);
      fileType = fileTypeManager.getFileTypeByExtension(extension);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }

  ((ActionUsagePanel)panel.getComponent(0)).reset(text, fileType);
  panel.repaint();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PostfixDescriptionPanel.java

示例4: updateFileTypeForEditorComponent

private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
  final Component editorComponent = inputComboBox.getEditor().getEditorComponent();

  if (editorComponent instanceof EditorTextField) {
    boolean isRegexp = myCbRegularExpressions.isSelectedWhenSelectable();
    FileType fileType = PlainTextFileType.INSTANCE;
    if (isRegexp) {
      Language regexpLanguage = Language.findLanguageByID("RegExp");
      if (regexpLanguage != null) {
        LanguageFileType regexpFileType = regexpLanguage.getAssociatedFileType();
        if (regexpFileType != null) {
          fileType = regexpFileType;
        }
      }
    }
    String fileName = isRegexp ? "a.regexp" : "a.txt";
    final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, ((EditorTextField)editorComponent).getText(), -1, true);

    ((EditorTextField)editorComponent).setNewDocumentAndFileType(fileType, PsiDocumentManager.getInstance(myProject).getDocument(file));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FindDialog.java

示例5: createEditorHighlighter

@javax.annotation.Nullable
private static EditorHighlighter createEditorHighlighter(@Nullable Project project, @Nonnull DocumentContent content) {
  FileType type = content.getContentType();
  VirtualFile file = content.getHighlightFile();
  Language language = content.getUserData(DiffUserDataKeys.LANGUAGE);

  EditorHighlighterFactory highlighterFactory = EditorHighlighterFactory.getInstance();
  if (language != null) {
    SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(language, project, file);
    return highlighterFactory.createEditorHighlighter(syntaxHighlighter, EditorColorsManager.getInstance().getGlobalScheme());
  }
  if (file != null) {
    if ((type == null || type == PlainTextFileType.INSTANCE) || file.getFileType() == type || file instanceof LightVirtualFile) {
      return highlighterFactory.createEditorHighlighter(project, file);
    }
  }
  if (type != null) {
    return highlighterFactory.createEditorHighlighter(project, type);
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:DiffUtil.java

示例6: createNewNameComponent

protected void createNewNameComponent() {
  String[] suggestedNames = getSuggestedNames();
  myOldName = UsageViewUtil.getShortName(myPsiElement);
  myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, PlainTextFileType.INSTANCE, myEditor) {
    @Override
    protected boolean shouldSelectAll() {
      return myEditor == null || myEditor.getSettings().isPreselectRename();
    }
  };
  if (myPsiElement instanceof PsiFile && myEditor == null) {
    myNameSuggestionsField.selectNameWithoutExtension();
  }
  myNameChangedListener = new NameSuggestionsField.DataChanged() {
    @Override
    public void dataChanged() {
      processNewNameChanged();
    }
  };
  myNameSuggestionsField.addDataChangedListener(myNameChangedListener);

}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:RenameDialog.java

示例7: createNewNameComponent

private void createNewNameComponent()
{
	myNameSuggestionsField = new NameSuggestionsField(new String[]{myTag.getName()}, myProject, PlainTextFileType.INSTANCE, myEditor);
	myNameChangedListener = new NameSuggestionsField.DataChanged()
	{
		@Override
		public void dataChanged()
		{
			validateButtons();
		}
	};
	myNameSuggestionsField.addDataChangedListener(myNameChangedListener);

	myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			completeVariable(myNameSuggestionsField.getEditor());
		}
	}, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:22,代码来源:XmlTagRenameDialog.java

示例8: getFile

@Nullable
@Override
protected VirtualFile getFile(@Nonnull AnActionEvent e) {
  VcsFileRevision revision = getFileRevision(e);
  if (revision == null) return null;

  final FileType currentFileType = myAnnotation.getFile().getFileType();
  FilePath filePath =
          (revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
  return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
    @Nonnull
    @Override
    public FileType getFileType() {
      FileType type = super.getFileType();
      if (!type.isBinary()) return type;
      if (!currentFileType.isBinary()) return currentFileType;
      return PlainTextFileType.INSTANCE;
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:AnnotateRevisionAction.java

示例9: createEditorField

@Nonnull
private static EditorTextField createEditorField(@Nonnull String text, @Nullable TextRange rangeToSelect) {
  Document document = EditorFactory.getInstance().createDocument(text);
  EditorTextField field = new EditorTextField(document, null, PlainTextFileType.INSTANCE, false, false);
  field.setPreferredSize(new Dimension(200, 350));
  field.addSettingsProvider(editor -> {
    editor.setVerticalScrollbarVisible(true);
    editor.setHorizontalScrollbarVisible(true);
    editor.getSettings().setAdditionalLinesCount(2);
    if (rangeToSelect != null) {
      editor.getCaretModel().moveToOffset(rangeToSelect.getStartOffset());
      editor.getScrollingModel().scrollVertically(document.getTextLength() - 1);
      editor.getSelectionModel().setSelection(rangeToSelect.getStartOffset(), rangeToSelect.getEndOffset());
    }
  });
  return field;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ParameterNameHintsConfigurable.java

示例10: showUsages

private static void showUsages(@Nonnull JPanel panel, @Nullable TextDescriptor exampleUsage) {
  String text = "";
  FileType fileType = PlainTextFileType.INSTANCE;
  if (exampleUsage != null) {
    try {
      text = exampleUsage.getText();
      String name = exampleUsage.getFileName();
      FileTypeManagerEx fileTypeManager = FileTypeManagerEx.getInstanceEx();
      String extension = fileTypeManager.getExtension(name);
      fileType = fileTypeManager.getFileTypeByExtension(extension);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }

  ((ActionUsagePanel)panel.getComponent(0)).reset(text, fileType);
  panel.repaint();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:PostfixDescriptionPanel.java

示例11: actionPerformed

@Override
public void actionPerformed(AnActionEvent e) {
  logger.info("Gathering information for create paste");
  // Gets the selected text
  Editor editor = e.getData(CommonDataKeys.EDITOR);

  // Default plain text
  FileType fileType = PlainTextFileType.INSTANCE;

  final Paste paste = new Paste();

  // If there are something selected
  if (editor != null && editor.getSelectionModel().getSelectedText() != null) {
    logger.info("Using selected text as content");
    paste.setContent(editor.getSelectionModel().getSelectedText());
  } else {
    logger.info("No text selected, checking for files selected");
    // Gets all the selected files
    VirtualFile[] selectedFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);

    // When there is multiple files selected, i do nothing
    if (selectedFiles != null && selectedFiles.length == 1 && !selectedFiles[0].isDirectory()) {
      final VirtualFile selectedFile = selectedFiles[0];
      logger.info("Getting content from selected file: " + selectedFile);
      fileType = selectedFile.getFileType();

      // Try to get the Highlight based on the file, if not found use the Text
      paste.setHighLight(UltimatePasteBinUtils.getHighlighFromVirtualFile(selectedFile).orElse(PasteHighLight.TEXT));

      // Set the content of the selected file to paste
      UltimatePasteBinUtils.getFileContent(selectedFile).ifPresent(paste::setContent);
    } else {
      logger.info("Multiple files selected, ignoring");
    }
  }

  CreatePasteForm.createAndShowForm(paste, e.getProject(), fileType);
}
 
开发者ID:kennedyoliveira,项目名称:ultimate-pastebin-intellij-plugin,代码行数:38,代码来源:CreatePasteAction.java

示例12: createExpressionCodeFragment

@Override
@RequiredReadAction
protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull String text, @Nullable PsiElement context, boolean isPhysical)
{
	if(context == null)
	{
		XDebugSession session = mySession;
		XSourcePosition currentPosition = session == null ? null : session.getCurrentPosition();
		if(currentPosition != null)
		{
			VirtualFile file = currentPosition.getFile();
			PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
			if(psiFile != null)
			{
				context = psiFile.findElementAt(currentPosition.getOffset());
			}
		}
	}

	DotNetDebuggerProvider debuggerProvider = context == null ? null : DotNetDebuggerProviders.findByPsiFile(context.getContainingFile());
	if(debuggerProvider == null)
	{
		LightVirtualFile virtualFile = new LightVirtualFile("test.txt", PlainTextFileType.INSTANCE, text);
		return new PsiPlainTextFileImpl(new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true));
	}

	return debuggerProvider.createExpressionCodeFragment(project, context, text, isPhysical);
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:28,代码来源:DotNetEditorsProvider.java

示例13: RevealingSpaceComboboxEditor

public RevealingSpaceComboboxEditor(final Project project, ComboBox comboBox) {
  super(project, PlainTextFileType.INSTANCE, comboBox);

  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      Editor editor = getEditor();
      if (editor != null) {
        editor.getSettings().setWhitespacesShown(true);
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:RevealingSpaceComboboxEditor.java

示例14: substituteIcon

@Nullable
@Override
public Icon substituteIcon(@Nonnull Project project, @Nonnull VirtualFile file) {
  FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(file.getName());
  if (fileType == UnknownFileType.INSTANCE || fileType == PlainTextFileType.INSTANCE) {
    return AllIcons.Debugger.ToolConsole;
  }
  Icon icon = fileType.getIcon();
  Icon subscript = ((ScalableIcon)AllIcons.Debugger.ToolConsole).scale(.5f);
  LayeredIcon icons = new LayeredIcon(2);
  icons.setIcon(icon, 0);
  icons.setIcon(subscript, 1, 8, 8);
  return icons;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:IdeConsoleRootType.java

示例15: EditorComboWithBrowseButton

public EditorComboWithBrowseButton(final ActionListener browseActionListener,
                                   final String text,
                                   @Nonnull final Project project,
                                   final String recentsKey) {
  super(new EditorComboBox(text, project, PlainTextFileType.INSTANCE), browseActionListener);
  final List<String> recentEntries = RecentsManager.getInstance(project).getRecentEntries(recentsKey);
  if (recentEntries != null) {
    setHistory(ArrayUtil.toStringArray(recentEntries));
  }
  if (text != null && text.length() > 0) {
    prependItem(text);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:EditorComboWithBrowseButton.java


注:本文中的com.intellij.openapi.fileTypes.PlainTextFileType.INSTANCE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。