Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code completion for Impex 'cell-decorator' modifier #159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<li><i>Feature:</i> Added navigation to <code>beans.xml</code> Bean property declaration from generated classes (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/112" target="_blank" rel="nofollow">#112</a>)</li>
<li><i>Feature:</i> Added navigation to alternative declarations of the beans within <code>beans.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/78" target="_blank" rel="nofollow">#78</a>)</li>
<li><i>Feature:</i> Added code completion for Impex <code>translator</code> modifier (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/158" target="_blank" rel="nofollow">#158</a>)</li>
<li><i>Feature:</i> Added code completion for Impex <code>cell-decorator</code> modifier (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/159" target="_blank" rel="nofollow">#159</a>)</li>
<li><i>Feature:</i> Added extra visibility filters for Type and Bean System views (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/99" target="_blank" rel="nofollow">#99</a>)</li>
<li><i>Feature:</i> Added <code>dynamic</code> prefix getters/setters in the Java classes (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/74" target="_blank" rel="nofollow">#74</a>)</li>
<li><i>Feature:</i> Redesigned and improved performance of the Structure View for <code>items.xml</code> files (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/114" target="_blank" rel="nofollow">#114</a>)</li>
Expand Down
2 changes: 2 additions & 0 deletions src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ object HybrisConstants {
private const val WEB_XML_FILE_NAME = "web.xml"
private const val WEB_INF_DIRECTORY = "WEB-INF"

@JvmField val IMPEX_MODIFIER_BOOLEAN_VALUES = setOf("true", "false")
@JvmField val IMPEX_MODIFIER_MODE_VALUES = setOf("append", "remove")
const val IMPEX_CLASS_PROCESSOR = "de.hybris.platform.impex.jalo.imp.ImportProcessor"
const val IMPEX_CLASS_TRANSLATOR = "de.hybris.platform.impex.jalo.translators.AbstractValueTranslator"
const val IMPEX_CLASS_CELL_DECORATOR = "de.hybris.platform.util.CSVCellDecorator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.intellij.idea.plugin.hybris.impex.completion.impl

import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.icons.AllIcons
import com.intellij.idea.plugin.hybris.impex.completion.ImpexImplementationClassCompletionContributor
import com.intellij.openapi.project.Project
import com.intellij.psi.JavaPsiFacade
Expand All @@ -40,7 +40,7 @@ class ImpexImplementationClassCompletionContributorImpl(val myProject: Project)
.map {
LookupElementBuilder.create(it.qualifiedName!!)
.withPresentableText(it.name!!)
.withIcon(HybrisIcons.ITEM)
.withIcon(AllIcons.FileTypes.JavaClass)
}
.toSet()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,27 @@
import com.intellij.idea.plugin.hybris.common.HybrisConstants;
import com.intellij.idea.plugin.hybris.impex.completion.ImpexImplementationClassCompletionContributor;
import com.intellij.openapi.project.Project;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static com.intellij.idea.plugin.hybris.impex.constants.ImpexConstants.ModifierCommonValues.BOOLEAN;
import static com.intellij.idea.plugin.hybris.impex.constants.ImpexConstants.ModifierCommonValues.NONE;

/**
* https://help.sap.com/docs/SAP_COMMERCE/d0224eca81e249cb821f2cdf45a82ace/1c8f5bebdc6e434782ff0cfdb0ca1847.html?locale=en-US
*/
public enum AttributeModifier implements ImpexModifier {
UNIQUE("unique", BOOLEAN),
ALLOW_NULL("allownull", BOOLEAN),
FORCE_WRITE("forceWrite", BOOLEAN),
IGNORE_KEY_CASE("ignoreKeyCase", BOOLEAN),
IGNORE_NULL("ignorenull", BOOLEAN),
VIRTUAL("virtual", BOOLEAN),
MODE("mode", ModeModifierValue.values()),
UNIQUE("unique", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
ALLOW_NULL("allownull", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
FORCE_WRITE("forceWrite", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
IGNORE_KEY_CASE("ignoreKeyCase", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
IGNORE_NULL("ignorenull", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
VIRTUAL("virtual", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
MODE("mode", HybrisConstants.IMPEX_MODIFIER_MODE_VALUES),
ALIAS("alias"),
COLLECTION_DELIMITER("collection-delimiter"),
DATE_FORMAT("dateformat"),
Expand All @@ -59,7 +54,13 @@ public enum AttributeModifier implements ImpexModifier {
NUMBER_FORMAT("numberformat"),
PATH_DELIMITER("path-delimiter"),
POS("pos"),
CELL_DECORATOR("cellDecorator"),
CELL_DECORATOR("cellDecorator") {
@Override
public @NotNull Set<LookupElement> getLookupElements(final Project project) {
return ImpexImplementationClassCompletionContributor.Companion.getInstance(project)
.getImplementationsForClass(HybrisConstants.IMPEX_CLASS_CELL_DECORATOR);
}
},
TRANSLATOR("translator") {
@Override
public @NotNull Set<LookupElement> getLookupElements(final Project project) {
Expand All @@ -84,26 +85,20 @@ public enum AttributeModifier implements ImpexModifier {
AttributeModifier(
@NotNull final String modifierName
) {
this(modifierName, NONE);
this(modifierName, Collections.emptySet());
}

AttributeModifier(
@NotNull final String modifierName,
@NotNull final ImpexModifierValue[] modifierValues
@NotNull final Set<String> modifierValues
) {
Validate.notEmpty(modifierName);
Validate.notNull(modifierValues);

this.modifierName = modifierName;

if (ArrayUtils.isEmpty(modifierValues)) {
this.lookupElements = Collections.emptySet();
} else {
this.lookupElements = Arrays.stream(modifierValues)
.map(ImpexModifierValue::getModifierValue)
.map(LookupElementBuilder::create)
.collect(Collectors.toSet());
}
this.lookupElements = modifierValues.stream()
.map(LookupElementBuilder::create)
.collect(Collectors.toSet());
}

@Nullable
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,24 @@
import com.intellij.idea.plugin.hybris.common.HybrisConstants;
import com.intellij.idea.plugin.hybris.impex.completion.ImpexImplementationClassCompletionContributor;
import com.intellij.openapi.project.Project;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static com.intellij.idea.plugin.hybris.impex.constants.ImpexConstants.ModifierCommonValues.BOOLEAN;
import static com.intellij.idea.plugin.hybris.impex.constants.ImpexConstants.ModifierCommonValues.NONE;

/**
* https://help.sap.com/docs/SAP_COMMERCE/d0224eca81e249cb821f2cdf45a82ace/1c8f5bebdc6e434782ff0cfdb0ca1847.html?locale=en-US
*/
public enum TypeModifier implements ImpexModifier {

BATCH_MODE("batchmode", BOOLEAN),
CACHE_UNIQUE("cacheUnique", BOOLEAN),
IMPEX_LEGACY_MODE("impex.legacy.mode", BOOLEAN),
BATCH_MODE("batchmode", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
CACHE_UNIQUE("cacheUnique", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
IMPEX_LEGACY_MODE("impex.legacy.mode", HybrisConstants.IMPEX_MODIFIER_BOOLEAN_VALUES),
PROCESSOR("processor") {
@Override
public @NotNull Set<LookupElement> getLookupElements(final Project project) {
Expand All @@ -70,26 +65,20 @@ public enum TypeModifier implements ImpexModifier {
TypeModifier(
@NotNull final String modifierName
) {
this(modifierName, NONE);
this(modifierName, Collections.emptySet());
}

TypeModifier(
@NotNull final String modifierName,
@NotNull final ImpexModifierValue[] lookupElements
@NotNull final Set<String> modifierValues
) {
Validate.notEmpty(modifierName);
Validate.notNull(lookupElements);
Validate.notNull(modifierValues);

this.modifierName = modifierName;

if (ArrayUtils.isEmpty(lookupElements)) {
this.lookupElements = Collections.emptySet();
} else {
this.lookupElements = Arrays.stream(lookupElements)
.map(ImpexModifierValue::getModifierValue)
.map(LookupElementBuilder::create)
.collect(Collectors.toSet());
}
this.lookupElements = modifierValues.stream()
.map(LookupElementBuilder::create)
.collect(Collectors.toSet());
}

@Nullable
Expand Down