Do not initialize icons while running the application

This commit is contained in:
Alexander Zolotov
2018-05-07 19:13:17 +03:00
parent e1fc982169
commit 4af2e12b66
3 changed files with 23 additions and 42 deletions
@@ -18,6 +18,7 @@ package org.intellij.lang.regexp;
import com.intellij.icons.AllIcons;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.LayeredIcon;
import icons.RegExpSupportIcons;
import org.jetbrains.annotations.NonNls;
@@ -33,10 +34,12 @@ public class RegExpFileType extends LanguageFileType {
private RegExpFileType() {
super(RegExpLanguage.INSTANCE);
myIcon = new LayeredIcon(2);
((LayeredIcon)myIcon).setIcon(AllIcons.FileTypes.Text, 0);
((LayeredIcon)myIcon).setIcon(RegExpSupportIcons.Regexp_filetype_icon, 1);
myIcon = new IconLoader.LazyIcon() {
@Override
protected Icon compute() {
return new LayeredIcon(AllIcons.FileTypes.Text, RegExpSupportIcons.Regexp_filetype_icon);
}
};
}
public RegExpFileType(@NotNull Language language) {
@@ -1,24 +1,11 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.file.exclude;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import com.intellij.openapi.fileTypes.ex.FileTypeIdentifiableByVirtualFile;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.PlatformIcons;
@@ -31,13 +18,18 @@ import javax.swing.*;
* @author Rustam Vishnyakov
*/
public class EnforcedPlainTextFileTypeFactory extends FileTypeFactory {
public static final LayeredIcon ENFORCED_PLAIN_TEXT_ICON = new LayeredIcon(2);
public static final String ENFORCED_PLAIN_TEXT = "Enforced Plain Text";
/**
* @deprecated use {@link #ENFORCED_PLAIN_TEXT_ICON_2} instead
*/
public static final LayeredIcon ENFORCED_PLAIN_TEXT_ICON = new LayeredIcon();
static {
ENFORCED_PLAIN_TEXT_ICON.setIcon(AllIcons.FileTypes.Text, 0);
ENFORCED_PLAIN_TEXT_ICON.setIcon(PlatformIcons.EXCLUDED_FROM_COMPILE_ICON, 1);
}
public static final Icon ENFORCED_PLAIN_TEXT_ICON_2 = new IconLoader.LazyIcon() {
@Override
protected Icon compute() {
return new LayeredIcon(AllIcons.FileTypes.Text, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
}
};
public static final String ENFORCED_PLAIN_TEXT = "Enforced Plain Text";
private final FileTypeIdentifiableByVirtualFile myFileType;
@@ -69,7 +61,7 @@ public class EnforcedPlainTextFileTypeFactory extends FileTypeFactory {
@Override
public Icon getIcon() {
return ENFORCED_PLAIN_TEXT_ICON;
return ENFORCED_PLAIN_TEXT_ICON_2;
}
@Override
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.file.exclude.ui;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -51,7 +37,7 @@ public class MarkAsPlainTextAction extends DumbAwareAction {
.filter(file -> isApplicableFor(file) && !typeManager.isMarkedAsPlainText(file));
boolean enabled = e.getProject() != null && !selectedFiles.isEmpty();
e.getPresentation().setEnabledAndVisible(enabled);
e.getPresentation().setIcon(EnforcedPlainTextFileTypeFactory.ENFORCED_PLAIN_TEXT_ICON);
e.getPresentation().setIcon(EnforcedPlainTextFileTypeFactory.ENFORCED_PLAIN_TEXT_ICON_2);
}
}