package _VisualDVM.ProjectData.Files; import Common.CommonConstants; import Common.Database.Objects.DBObject; import Common.Utils.Utils_; import _VisualDVM.Constants; import _VisualDVM.ProjectData.LanguageName; import javax.swing.*; import java.io.File; import java.net.URL; public class ProjectFile extends projectFile_ { public File file = null; //собственно, файл на который ссылаемся. public FileState state = FileState.Undefined; //состояние файла. public ProjectFile() { } public ProjectFile(File file_in) { super(file_in); file = file_in; } @Override public Object getPK() { return file.getName(); } @Override public void AutoDetectProperties(String name_in) { super.AutoDetectProperties(name_in); if (fileType.equals(FileType.forbidden) || fileType.equals(FileType.none)) state= FileState.Excluded; } public String ImageKey() { //icons/files/Excludeddata.png String pref = "/icons/files/"; String body; switch (fileType) { case program: body = state.toString() + languageName.toString(); break; case data: body = "Undefined"; // иных состояний у данных не бывает. ситуация возникает если по ошибке поменяли тип //нормальных файлов с сообщениями на дату. break; default: body = state.toString(); break; } return pref + body + fileType + ".png"; } public ImageIcon GetIcon() { URL imageUrl = getClass().getResource(ImageKey()); if (imageUrl == null) { System.out.println(ImageKey() + "not found"); } return new ImageIcon(imageUrl); } public String getUnixName() { return Utils_.toU(file.getName()); } @Override public String toString() { return file.getName(); } public String getQSourceName() { return Utils_.DQuotes(getUnixName()); } public boolean isNotExcludedProgram() { return fileType.equals(FileType.program) && !languageName.equals(LanguageName.n) && !state.equals(FileState.Excluded); } }