package jetbrains.mps.ide.icons; /*Generated by MPS */ import jetbrains.mps.smodel.runtime.IconResource; import org.apache.log4j.Logger; import org.apache.log4j.LogManager; import org.jetbrains.annotations.NotNull; import java.io.InputStream; import jetbrains.mps.vfs.FileSystem; import java.io.IOException; import org.apache.log4j.Level; /** * * @deprecated this class is for compatibility purposes and must not be used except internally. It will be removed after 3.4 */ @Deprecated public class String2IconResourceAdapter_Deprecated extends IconResource { private static final Logger LOG = LogManager.getLogger(String2IconResourceAdapter_Deprecated.class); private final String myIcon; @Deprecated public String2IconResourceAdapter_Deprecated(@NotNull String icon) { super(null, null); myIcon = icon; } @Override public boolean isAlreadyReloaded() { return false; } @Override public InputStream getResource() { if (myIcon == null) { return null; } try { return FileSystem.getInstance().getFileByPath(myIcon).openInputStream(); } catch (IOException e) { if (LOG.isEnabledFor(Level.WARN)) { LOG.warn("Can't load icon " + myIcon, e); } return null; } } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } String2IconResourceAdapter_Deprecated that = (String2IconResourceAdapter_Deprecated) o; return myIcon.equals(that.myIcon); } @Override public int hashCode() { return myIcon.hashCode(); } }