Java Code Examples for com.intellij.openapi.application.RunResult#getResultObject()
The following examples show how to use
com.intellij.openapi.application.RunResult#getResultObject() .
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: GenerateViewHelperAction.java From idea-php-typo3-plugin with MIT License | 4 votes |
@Override protected void write(@NotNull Project project, @NotNull PsiDirectory extensionRootDirectory, @NotNull String className) { if (!className.endsWith("ViewHelper")) { className += "ViewHelper"; } final String finalClassName = className; RunResult<PsiElement> elementRunResult = new WriteCommandAction<PsiElement>(project) { @Override protected void run(@NotNull Result result) { PsiElement extensionFile; Map<String, String> context = new HashMap<>(); String calculatedNamespace = ExtensionUtility.findDefaultNamespace(extensionRootDirectory); if (calculatedNamespace == null) { result.setResult(null); return; } calculatedNamespace += "ViewHelpers"; context.put("namespace", calculatedNamespace); context.put("className", finalClassName); String majorVersion = null; if (TYPO3Utility.getTYPO3Version(project) != null && TYPO3Utility.isMajorMinorCmsVersion(project, "7.6")) { majorVersion = "7"; } else if (TYPO3Utility.getTYPO3Version(project) != null && TYPO3Utility.isMajorMinorCmsVersion(project, "8.7")) { majorVersion = "8"; } else if (TYPO3Utility.getTYPO3Version(project) != null && TYPO3Utility.getTYPO3Version(project).startsWith("9.")) { majorVersion = "9"; } if (majorVersion == null) { result.setResult(null); return; } try { extensionFile = ExtensionFileGenerationUtil.fromTemplate( "extension_file/" + majorVersion + "/ViewHelper.php", "Classes/ViewHelpers", finalClassName + ".php", extensionRootDirectory, context, project ); if (extensionFile != null) { result.setResult(extensionFile); } } catch (IncorrectOperationException e) { // file already exists } } }.execute(); if (elementRunResult.getResultObject() != null) { new OpenFileDescriptor(project, elementRunResult.getResultObject().getContainingFile().getVirtualFile(), 0).navigate(true); } else { Messages.showErrorDialog("Cannot create extension file", "Error"); } }
Example 2
Source File: GenerateExtbaseEntityAction.java From idea-php-typo3-plugin with MIT License | 4 votes |
@Override protected void write(@NotNull Project project, @NotNull PsiDirectory extensionRootDirectory, @NotNull String className) { final String finalClassName = className; RunResult<PsiElement> elementRunResult = new WriteCommandAction<PsiElement>(project) { @Override protected void run(@NotNull Result result) { PsiElement extensionFile; Map<String, String> context = new HashMap<>(); String calculatedNamespace = ExtensionUtility.findDefaultNamespace(extensionRootDirectory); if (calculatedNamespace == null) { result.setResult(null); return; } calculatedNamespace += "Domain\\Model"; context.put("namespace", calculatedNamespace); context.put("className", finalClassName); try { extensionFile = ExtensionFileGenerationUtil.fromTemplate( "extension_file/ExtbaseEntity.php", "Classes/Domain/Model", finalClassName + ".php", extensionRootDirectory, context, project ); if (extensionFile != null) { result.setResult(extensionFile); } } catch (IncorrectOperationException e) { // file already exists } } }.execute(); if (elementRunResult.getResultObject() != null) { new OpenFileDescriptor(project, elementRunResult.getResultObject().getContainingFile().getVirtualFile(), 0).navigate(true); } else { Messages.showErrorDialog("Cannot create extension file", "Error"); } }
Example 3
Source File: GenerateActionControllerAction.java From idea-php-typo3-plugin with MIT License | 4 votes |
@Override protected void write(@NotNull Project project, @NotNull PsiDirectory extensionRootDirectory, @NotNull String className) { if (!className.endsWith("Controller")) { className += "Controller"; } final String finalClassName = className; RunResult<PsiElement> elementRunResult = new WriteCommandAction<PsiElement>(project) { @Override protected void run(@NotNull Result result) { PsiElement extensionFile; Map<String, String> context = new HashMap<>(); String calculatedNamespace = ExtensionUtility.findDefaultNamespace(extensionRootDirectory); if (calculatedNamespace == null) { result.setResult(null); return; } calculatedNamespace += "Controller"; context.put("namespace", calculatedNamespace); context.put("className", finalClassName); try { extensionFile = ExtensionFileGenerationUtil.fromTemplate( "extension_file/ExtbaseActionController.php", "Classes/Controller", finalClassName + ".php", extensionRootDirectory, context, project ); if (extensionFile != null) { result.setResult(extensionFile); } } catch (IncorrectOperationException e) { // file already exists } } }.execute(); if (elementRunResult.getResultObject() != null) { new OpenFileDescriptor(project, elementRunResult.getResultObject().getContainingFile().getVirtualFile(), 0).navigate(true); } else { Messages.showErrorDialog("Cannot create extension file", "Error"); } }