本文整理汇总了Java中com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable类的典型用法代码示例。如果您正苦于以下问题:Java AllFileTemplatesConfigurable类的具体用法?Java AllFileTemplatesConfigurable怎么用?Java AllFileTemplatesConfigurable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AllFileTemplatesConfigurable类属于com.intellij.ide.fileTemplates.impl包,在下文中一共展示了AllFileTemplatesConfigurable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e){
Project project = e.getData(PlatformDataKeys.PROJECT);
String fileText = e.getData(PlatformDataKeys.FILE_TEXT);
VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
String extension = file.getExtension();
String nameWithoutExtension = file.getNameWithoutExtension();
AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable();
ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions);
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
for(SaveFileAsTemplateHandler handler: Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) {
String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension);
if (textFromHandler != null) {
fileText = textFromHandler;
break;
}
}
fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText);
dialog.show();
}
示例2: actionPerformed
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e){
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
String fileText = e.getData(PlatformDataKeys.FILE_TEXT);
VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
String extension = file.getExtension();
String nameWithoutExtension = file.getNameWithoutExtension();
AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable(project);
ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions);
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
for(SaveFileAsTemplateHandler handler: Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) {
String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension);
if (textFromHandler != null) {
fileText = textFromHandler;
break;
}
}
fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText);
dialog.show();
}
示例3: createEditTemplateAction
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@Nullable
@Override
public AnAction createEditTemplateAction(DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
final PsiClass targetClass = editor == null || file == null ? null : getTargetClass(editor, file);
if (targetClass != null) {
final List<TestFramework> frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass);
final TestIntegrationUtils.MethodKind methodKind = ((MyHandler)getHandler()).myMethodKind;
if (!frameworks.isEmpty()) {
return new AnAction("Edit Template") {
@Override
public void actionPerformed(AnActionEvent e) {
chooseAndPerform(editor, frameworks, new Consumer<TestFramework>() {
@Override
public void consume(TestFramework framework) {
final FileTemplateDescriptor descriptor = methodKind.getFileTemplateDescriptor(framework);
if (descriptor != null) {
final String fileName = descriptor.getFileName();
AllFileTemplatesConfigurable.editCodeTemplate(FileUtil.getNameWithoutExtension(fileName), project);
} else {
HintManager.getInstance().showErrorHint(editor, "No template found for " + framework.getName() + ":" + BaseGenerateTestSupportMethodAction.this.getTemplatePresentation().getText());
}
}
});
}
};
}
}
return null;
}
示例4: testFindCodeTemplates
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public void testFindCodeTemplates() {
ConfigurableGroup[] groups = {new ProjectConfigurablesGroup(getProject())};
ConfigurableHit configurables = SearchableOptionsRegistrar.getInstance().getConfigurables(groups, DocumentEvent.EventType.INSERT, null, "method", getProject());
Set<Configurable> configurableSet = configurables.getAll();
for (Configurable configurable : configurableSet) {
if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable(getProject()).getDisplayName())) {
return;
}
}
fail("File Templates are not found");
}
示例5: testFindCodeTemplates
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public void testFindCodeTemplates() throws Exception {
final ConfigurableHit configurables =
SearchableOptionsRegistrar.getInstance().getConfigurables(new ConfigurableGroup[]{new IdeConfigurablesGroup()}, DocumentEvent.EventType.INSERT, null, "method", getProject());
final Set<Configurable> configurableSet = configurables.getAll();
for (Configurable configurable : configurableSet) {
if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable().getDisplayName())) {
return;
}
}
fail("File Templates are not found");
}
示例6: ConfigureTemplatesDialog
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public ConfigureTemplatesDialog(Project project){
this(project, new AllFileTemplatesConfigurable(project));
}
示例7: ConfigureTemplatesDialog
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public ConfigureTemplatesDialog(Project project){
this(project, new AllFileTemplatesConfigurable());
}