From dba0722bc528b3d127901ddbf2074120082f0035 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 14 Nov 2012 15:18:00 +0400 Subject: [PATCH] basic Vaadin support (IDEA-75348) --- .../FrameworkSupportInModuleConfigurable.java | 3 +++ .../AddSupportForFrameworksPanel.java | 10 +++++----- .../OldFrameworkSupportProviderWrapper.java | 5 +++++ ...acetBasedPackagingSourceItemsProvider.java | 5 +++-- .../com/intellij/ide/util/PackageUtil.java | 9 +++++++++ .../impl/file/JavaDirectoryServiceImpl.java | 19 ++++++++++++++++--- .../intellij/psi/JavaDirectoryService.java | 11 +++++++++++ .../core/CoreJavaDirectoryService.java | 9 +++++++++ .../FrameworkSupportProviderTestCase.java | 5 +---- 9 files changed, 62 insertions(+), 14 deletions(-) diff --git a/java/idea-ui/src/com/intellij/framework/addSupport/FrameworkSupportInModuleConfigurable.java b/java/idea-ui/src/com/intellij/framework/addSupport/FrameworkSupportInModuleConfigurable.java index 816c16aea28d..b1ad3f66192f 100644 --- a/java/idea-ui/src/com/intellij/framework/addSupport/FrameworkSupportInModuleConfigurable.java +++ b/java/idea-ui/src/com/intellij/framework/addSupport/FrameworkSupportInModuleConfigurable.java @@ -46,6 +46,9 @@ public abstract class FrameworkSupportInModuleConfigurable implements Disposable return FrameworkLibraryVersionFilter.ALL; } + public void onFrameworkSelectionChanged(boolean selected) { + } + public boolean isOnlyLibraryAdded() { return false; } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index e7ad42d35b14..f50c98ae37a6 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -81,12 +81,11 @@ public class AddSupportForFrameworksPanel implements Disposable { if (!(node instanceof FrameworkSupportNode)) return; final FrameworkSupportNode frameworkSupportNode = (FrameworkSupportNode)node; - updateOptionsPanel(); - final FrameworkSupportInModuleConfigurable configurable = frameworkSupportNode.getConfigurable(); - if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) { - ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper)configurable).getConfigurable().onFrameworkSelectionChanged( - node.isChecked()); + if (frameworkSupportNode == getSelectedNode()) { + updateOptionsPanel(); } + final FrameworkSupportInModuleConfigurable configurable = frameworkSupportNode.getConfigurable(); + configurable.onFrameworkSelectionChanged(node.isChecked()); myModel.onFrameworkSelectionChanged(frameworkSupportNode); onFrameworkStateChanged(); } @@ -144,6 +143,7 @@ public class AddSupportForFrameworksPanel implements Disposable { initializeOptionsPanel(node); showCard(node.getProvider().getFrameworkType().getId()); UIUtil.setEnabled(myOptionsPanel, node.isChecked(), true); + node.getConfigurable().onFrameworkSelectionChanged(node.isChecked()); } else { showCard(EMPTY_CARD); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java index 2c5b8b22201d..00950ea16ea5 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/OldFrameworkSupportProviderWrapper.java @@ -151,6 +151,11 @@ public class OldFrameworkSupportProviderWrapper extends FrameworkSupportInModule return myConfigurable; } + @Override + public void onFrameworkSelectionChanged(boolean selected) { + myConfigurable.onFrameworkSelectionChanged(selected); + } + @Override public boolean isVisible() { return myConfigurable.isVisible(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/FacetBasedPackagingSourceItemsProvider.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/FacetBasedPackagingSourceItemsProvider.java index 2fb47877608e..3d15845a4f3a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/FacetBasedPackagingSourceItemsProvider.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/sourceItems/FacetBasedPackagingSourceItemsProvider.java @@ -89,12 +89,13 @@ public abstract class FacetBasedPackagingSourceItemsProvideremptyMap()); + } + + @Override + public PsiClass createClass(@NotNull PsiDirectory dir, + @NotNull String name, + @NotNull String templateName, + boolean askForUndefinedVariables, @NotNull final Map additionalProperties) throws IncorrectOperationException { + return createClassFromTemplate(dir, name, templateName, askForUndefinedVariables, additionalProperties); } @Override @@ -109,13 +119,13 @@ public class JavaDirectoryServiceImpl extends CoreJavaDirectoryService { } private static PsiClass createClassFromTemplate(@NotNull PsiDirectory dir, String name, String templateName) throws IncorrectOperationException { - return createClassFromTemplate(dir, name, templateName, false); + return createClassFromTemplate(dir, name, templateName, false, Collections.emptyMap()); } private static PsiClass createClassFromTemplate(@NotNull PsiDirectory dir, String name, String templateName, - boolean askToDefineVariables) throws IncorrectOperationException { + boolean askToDefineVariables, @NotNull Map additionalProperties) throws IncorrectOperationException { //checkCreateClassOrInterface(dir, name); FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName); @@ -123,6 +133,9 @@ public class JavaDirectoryServiceImpl extends CoreJavaDirectoryService { Properties defaultProperties = FileTemplateManager.getInstance().getDefaultProperties(dir.getProject()); Properties properties = new Properties(defaultProperties); properties.setProperty(FileTemplate.ATTRIBUTE_NAME, name); + for (Map.Entry entry : additionalProperties.entrySet()) { + properties.setProperty(entry.getKey(), entry.getValue()); + } String ext = StdFileTypes.JAVA.getDefaultExtension(); String fileName = name + "." + ext; diff --git a/java/java-psi-api/src/com/intellij/psi/JavaDirectoryService.java b/java/java-psi-api/src/com/intellij/psi/JavaDirectoryService.java index 098d60d49896..1f669eabf1e4 100644 --- a/java/java-psi-api/src/com/intellij/psi/JavaDirectoryService.java +++ b/java/java-psi-api/src/com/intellij/psi/JavaDirectoryService.java @@ -25,6 +25,8 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Map; + public abstract class JavaDirectoryService { public static JavaDirectoryService getInstance() { return ServiceManager.getService(JavaDirectoryService.class); @@ -75,6 +77,15 @@ public abstract class JavaDirectoryService { */ public abstract PsiClass createClass(@NotNull PsiDirectory dir, @NotNull String name, @NotNull String templateName, boolean askForUndefinedVariables) throws IncorrectOperationException; + /** + * @param additionalProperties additional properties to be substituted in the template + */ + public abstract PsiClass createClass(@NotNull PsiDirectory dir, + @NotNull String name, + @NotNull String templateName, + boolean askForUndefinedVariables, + @NotNull final Map additionalProperties) throws IncorrectOperationException; + /** * Checks if it's possible to create a class with the specified name in the directory, * and throws an exception if the creation is not possible. Does not actually modify diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaDirectoryService.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaDirectoryService.java index 0c5c1ee2ac2e..be7fec104b72 100644 --- a/java/java-psi-impl/src/com/intellij/core/CoreJavaDirectoryService.java +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaDirectoryService.java @@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @author yole @@ -85,6 +86,14 @@ public class CoreJavaDirectoryService extends JavaDirectoryService { throw new UnsupportedOperationException(); } + @Override + public PsiClass createClass(@NotNull PsiDirectory dir, + @NotNull String name, + @NotNull String templateName, + boolean askForUndefinedVariables, @NotNull final Map additionalProperties) throws IncorrectOperationException { + throw new UnsupportedOperationException(); + } + @Override public void checkCreateClass(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException { throw new UnsupportedOperationException(); diff --git a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java index 3e717d3985f8..9a14e602a230 100644 --- a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java +++ b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java @@ -99,10 +99,7 @@ public abstract class FrameworkSupportProviderTestCase extends IdeaTestCase { protected FrameworkSupportInModuleConfigurable selectFramework(@NotNull FrameworkSupportInModuleProvider provider) { final FrameworkSupportInModuleConfigurable configurable = getOrCreateConfigurable(provider); myNodes.get(provider.getFrameworkType()).setChecked(true); - if (configurable instanceof OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper) { - ((OldFrameworkSupportProviderWrapper.FrameworkSupportConfigurableWrapper)configurable).getConfigurable().onFrameworkSelectionChanged( - true); - } + configurable.onFrameworkSelectionChanged(true); return configurable; }