本文整理汇总了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;
}
};
}
示例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();
}
示例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));
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
};
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
});
}
示例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;
}
示例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);
}
}