mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
basic Vaadin support (IDEA-75348)
This commit is contained in:
+3
@@ -46,6 +46,9 @@ public abstract class FrameworkSupportInModuleConfigurable implements Disposable
|
||||
return FrameworkLibraryVersionFilter.ALL;
|
||||
}
|
||||
|
||||
public void onFrameworkSelectionChanged(boolean selected) {
|
||||
}
|
||||
|
||||
public boolean isOnlyLibraryAdded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+5
-5
@@ -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);
|
||||
|
||||
+5
@@ -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();
|
||||
|
||||
+3
-2
@@ -89,12 +89,13 @@ public abstract class FacetBasedPackagingSourceItemsProvider<F extends Facet, E
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof FacetBasedSourceItem && myFacet.equals(((FacetBasedSourceItem)obj).myFacet);
|
||||
return obj instanceof FacetBasedSourceItem && myFacet.equals(((FacetBasedSourceItem)obj).myFacet)
|
||||
&& myProvider.equals(((FacetBasedSourceItem)obj).myProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myFacet.hashCode();
|
||||
return myFacet.hashCode() + 31*myProvider.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -372,4 +372,13 @@ public class PackageUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiDirectory findOrCreateSubdirectory(@NotNull PsiDirectory directory, @NotNull String directoryName) {
|
||||
PsiDirectory subDirectory = directory.findSubdirectory(directoryName);
|
||||
if (subDirectory == null) {
|
||||
subDirectory = directory.createSubdirectory(directoryName);
|
||||
}
|
||||
return subDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class JavaDirectoryServiceImpl extends CoreJavaDirectoryService {
|
||||
@@ -72,7 +74,15 @@ public class JavaDirectoryServiceImpl extends CoreJavaDirectoryService {
|
||||
@NotNull String name,
|
||||
@NotNull String templateName,
|
||||
boolean askForUndefinedVariables) throws IncorrectOperationException {
|
||||
return createClassFromTemplate(dir, name, templateName, askForUndefinedVariables);
|
||||
return createClass(dir, name, templateName, askForUndefinedVariables, Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass createClass(@NotNull PsiDirectory dir,
|
||||
@NotNull String name,
|
||||
@NotNull String templateName,
|
||||
boolean askForUndefinedVariables, @NotNull final Map<String, String> 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.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
private static PsiClass createClassFromTemplate(@NotNull PsiDirectory dir,
|
||||
String name,
|
||||
String templateName,
|
||||
boolean askToDefineVariables) throws IncorrectOperationException {
|
||||
boolean askToDefineVariables, @NotNull Map<String, String> 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<String, String> entry : additionalProperties.entrySet()) {
|
||||
properties.setProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
String ext = StdFileTypes.JAVA.getDefaultExtension();
|
||||
String fileName = name + "." + ext;
|
||||
|
||||
@@ -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<String, String> 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
|
||||
|
||||
@@ -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<String, String> additionalProperties) throws IncorrectOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCreateClass(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
+1
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user