Java Code Examples for com.intellij.openapi.fileTypes.FileTypes#PLAIN_TEXT

The following examples show how to use com.intellij.openapi.fileTypes.FileTypes#PLAIN_TEXT . 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: ExtensionFileGenerationUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
/**
 * @param templateFile        Name of the generated file
 * @param destinationPath     Relative path to the target file system entry
 * @param extensionDefinition Extension definition containing all relevant metadata
 * @param context             Template Context variables
 * @param project             Project in context
 */
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull TYPO3ExtensionDefinition extensionDefinition, @NotNull Map<String, String> context, Project project) {
    String template = readTemplateToString(templateFile, context);

    VirtualFile targetDirectory = getOrCreateDestinationPath(extensionDefinition.getRootDirectory(), destinationPath);

    LanguageFileType fileType = FileTypes.PLAIN_TEXT;
    if (templateFile.endsWith(".php")) {
        fileType = PhpFileType.INSTANCE;
    }

    PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
    CodeStyleManager.getInstance(project).reformat(fileFromText);
    return PsiDirectoryFactory
            .getInstance(project)
            .createDirectory(targetDirectory)
            .add(fileFromText);
}
 
Example 2
Source File: ExtensionFileGenerationUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
/**
 * @param templateFile           Name of the generated file
 * @param destinationPath        Relative path to the target file system entry
 * @param extensionRootDirectory Extension definition containing all relevant metadata
 * @param context                Template Context variables
 * @param project                Project in context
 */
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull PsiDirectory extensionRootDirectory, @NotNull Map<String, String> context, Project project) {
    String template = readTemplateToString(templateFile, context);

    VirtualFile targetDirectory = getOrCreateDestinationPath(extensionRootDirectory.getVirtualFile(), destinationPath);

    LanguageFileType fileType = FileTypes.PLAIN_TEXT;
    if (templateFile.endsWith(".php")) {
        fileType = PhpFileType.INSTANCE;
    }

    PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
    CodeStyleManager.getInstance(project).reformat(fileFromText);
    return PsiDirectoryFactory
            .getInstance(project)
            .createDirectory(targetDirectory)
            .add(fileFromText);
}
 
Example 3
Source File: FlowRenameDialog.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
private void createNewNameComponent() {
    String flowName = this.myTag.getAttribute("name").getValue();
    this.myNameSuggestionsField = new NameSuggestionsField(new String[]{ flowName }, this.myProject, FileTypes.PLAIN_TEXT, this.myEditor);
    this.myNameChangedListener = new NameSuggestionsField.DataChanged() {
        public void dataChanged() {
            FlowRenameDialog.this.validateButtons();
        }
    };
    this.myNameSuggestionsField.addDataChangedListener(this.myNameChangedListener);
    this.myNameSuggestionsField.getComponent().registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlowRenameDialog.this.completeVariable(FlowRenameDialog.this.myNameSuggestionsField.getEditor());
        }
    }, KeyStroke.getKeyStroke(32, 2), 2);
}
 
Example 4
Source File: PlainTextEditor.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
public EmptyTextEditor(final Project project) {
  super("", project, FileTypes.PLAIN_TEXT);
  setOneLineMode(false);
  setAutoscrolls(true);
}
 
Example 5
Source File: ExtractPartialViewDialog.java    From idea-php-laravel-plugin with MIT License 3 votes vote down vote up
public ExtractPartialViewDialog(@NotNull Project project, VirtualFile targetDirectory) {
    super(project);

    panel = new JPanel(new BorderLayout());

    panel.add(new JLabel("View name (example: partials.header)"), BorderLayout.NORTH);

    viewNameEditor = new EditorTextField("", project, FileTypes.PLAIN_TEXT);
    new NewViewNameCompletionProvider(targetDirectory).apply(viewNameEditor);
    panel.add(viewNameEditor.getComponent(), BorderLayout.CENTER);

    setTitle("Extract Partial View");

    init();
}