Skip to content

Commit

Permalink
Merge pull request #1499 from Haehnchen/feature/twig-icon-disable
Browse files Browse the repository at this point in the history
provide checkbox to disable Twig file icon decoration #1485
  • Loading branch information
Haehnchen authored Jun 24, 2020
2 parents 19ffb77 + 77b4964 commit c77afaa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import fr.adrienbrault.idea.symfony2plugin.dic.ContainerFile;
import fr.adrienbrault.idea.symfony2plugin.routing.dict.RoutingFile;
import fr.adrienbrault.idea.symfony2plugin.templating.path.TwigNamespaceSetting;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class Settings implements PersistentStateComponent<Settings> {
public boolean codeFoldingTwigRoute = true;
public boolean codeFoldingTwigTemplate = true;
public boolean codeFoldingTwigConstant = true;
public boolean featureTwigIcon = true;

public boolean twigBundleNamespaceSupport = true;

Expand Down Expand Up @@ -103,7 +105,7 @@ public Settings getState() {
}

@Override
public void loadState(Settings settings) {
public void loadState(@NotNull Settings settings) {
XmlSerializerUtil.copyBean(settings, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:max(d;4px):noGrow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:d:grow"/>
Expand Down Expand Up @@ -207,6 +211,25 @@
<text value="Download remote files (exp.)"/>
</properties>
</component>
<component id="24207" class="javax.swing.JLabel">
<constraints>
<grid row="24" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Custom Features"/>
</properties>
</component>
<component id="bcf9" class="javax.swing.JCheckBox" binding="featureTwigIcon">
<constraints>
<grid row="26" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Twig Icon Decoration"/>
<toolTipText value="Decorate Twig file icons with layer to show possible content type"/>
</properties>
</component>
</children>
</grid>
<component id="2ef99" class="javax.swing.JCheckBox" binding="pluginEnabled">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class SettingsForm implements Configurable {

private JButton buttonReindex;
private JCheckBox enableSchedulerCheckBox;
private JCheckBox featureTwigIcon;

public SettingsForm(@NotNull final Project project) {
this.project = project;
Expand Down Expand Up @@ -116,6 +117,7 @@ public boolean isModified() {
|| !codeFoldingTwigRoute.isSelected() == getSettings().codeFoldingTwigRoute
|| !codeFoldingTwigTemplate.isSelected() == getSettings().codeFoldingTwigTemplate
|| !codeFoldingTwigConstant.isSelected() == getSettings().codeFoldingTwigConstant
|| !featureTwigIcon.isSelected() == getSettings().featureTwigIcon

|| !directoryToApp.getText().equals(getSettings().directoryToApp)
|| !directoryToWeb.getText().equals(getSettings().directoryToWeb)
Expand All @@ -136,6 +138,7 @@ public void apply() throws ConfigurationException {
getSettings().codeFoldingTwigRoute = codeFoldingTwigRoute.isSelected();
getSettings().codeFoldingTwigTemplate = codeFoldingTwigTemplate.isSelected();
getSettings().codeFoldingTwigConstant = codeFoldingTwigConstant.isSelected();
getSettings().featureTwigIcon = featureTwigIcon.isSelected();

getSettings().directoryToApp = directoryToApp.getText();
getSettings().directoryToWeb = directoryToWeb.getText();
Expand Down Expand Up @@ -167,6 +170,7 @@ private void updateUIFromSettings() {
codeFoldingTwigRoute.setSelected(getSettings().codeFoldingTwigRoute);
codeFoldingTwigTemplate.setSelected(getSettings().codeFoldingTwigTemplate);
codeFoldingTwigConstant.setSelected(getSettings().codeFoldingTwigConstant);
featureTwigIcon.setSelected(getSettings().featureTwigIcon);

directoryToApp.setText(getSettings().directoryToApp);
directoryToWeb.setText(getSettings().directoryToWeb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.intellij.ui.LayeredIcon;
import com.jetbrains.twig.TwigFile;
import com.jetbrains.twig.elements.TwigExtendsTag;
import fr.adrienbrault.idea.symfony2plugin.Settings;
import fr.adrienbrault.idea.symfony2plugin.Symfony2Icons;
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
import fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil;
Expand All @@ -23,7 +24,7 @@
*/
public class TwigIconProvider extends IconProvider {
public Icon getIcon(@NotNull PsiElement element, @Iconable.IconFlags int flags) {
if (!(element instanceof TwigFile) || !Symfony2ProjectComponent.isEnabled(element.getProject()) || DumbService.getInstance(element.getProject()).isDumb()) {
if (!(element instanceof TwigFile) || !Settings.getInstance(element.getProject()).featureTwigIcon || !Symfony2ProjectComponent.isEnabled(element.getProject()) || DumbService.getInstance(element.getProject()).isDumb()) {
return null;
}

Expand Down

0 comments on commit c77afaa

Please sign in to comment.