From ea1b74357e517baef19ef6f862bc7775f7a7804e Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 25 Nov 2016 09:01:54 +0000 Subject: [PATCH] JAL-2344 use .equals() to compare FileFormatI objects --- src/jalview/gui/AlignFrame.java | 13 +++++++------ src/jalview/gui/Desktop.java | 4 ++-- src/jalview/io/AppletFormatAdapter.java | 14 ++++++-------- src/jalview/io/FileLoader.java | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 453fd3a..8cc1dd5 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1011,7 +1011,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // originating file's format // TODO: work out how to recover feature settings for correct view(s) when // file is reloaded. - if (currentFileFormat == FileFormat.Jalview) + if (FileFormat.Jalview.equals(currentFileFormat)) { JInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int i = 0; i < frames.length; i++) @@ -1155,7 +1155,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { boolean success = true; - if (format == FileFormat.Jalview) + if (FileFormat.Jalview.equals(format)) { String shortName = title; @@ -5099,7 +5099,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } if (type != null) { - if (type == FileFormat.PDB) + if (FileFormat.PDB.equals(type)) { filesmatched.add(new Object[] { file, protocol, mtch }); continue; @@ -5210,7 +5210,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // if the file isn't identified, or not positively identified as some // other filetype (PFAM is default unidentified alignment file type) then // try to parse as annotation. - boolean isAnnotation = (format == null || format == FileFormat.Pfam) ? new AnnotationFile() + boolean isAnnotation = (format == null || FileFormat.Pfam + .equals(format)) ? new AnnotationFile() .annotateAlignmentView(viewport, file, sourceType) : false; if (!isAnnotation) @@ -5267,7 +5268,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { format = new IdentifyFile().identify(file, sourceType); } - if (format == FileFormat.Jnet) + if (FileFormat.Jnet.equals(format)) { JPredFile predictions = new JPredFile( file, sourceType); @@ -5282,7 +5283,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, isAnnotation = true; } // else if (IdentifyFile.FeaturesFile.equals(format)) - else if (format == FileFormat.Features) + else if (FileFormat.Features.equals(format)) { if (parseFeaturesFile(file, sourceType)) { diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 624054b..3fa5387 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1031,8 +1031,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements .getSelectedFile().getParent()); FileFormatI format = null; - if (chooser.getSelectedFormat() != null - && chooser.getSelectedFormat() == FileFormat.Jalview) + FileFormatI selectedFormat = chooser.getSelectedFormat(); + if (FileFormat.Jalview.equals(selectedFormat)) { format = FileFormat.Jalview; } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 5f40713..4ffb86d 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -194,10 +194,9 @@ public class AppletFormatAdapter this.inFile = file; try { - if (fileFormat == FileFormat.PDB || fileFormat == FileFormat.MMCif) + if (FileFormat.PDB.equals(fileFormat) + || FileFormat.MMCif.equals(fileFormat)) { - // TODO obtain config value from preference settings. - // Set value to 'true' to test PDB processing with Jmol: JAL-1213 boolean isParseWithJMOL = StructureImportSettings .getDefaultPDBFileParser().equalsIgnoreCase( StructureImportSettings.StructureParser.JMOL_PARSER @@ -219,9 +218,8 @@ public class AppletFormatAdapter localSecondaryStruct, serviceSecondaryStruct, inFile, sourceType); } - ((StructureFile) alignFile) - .setDbRefType(fileFormat == FileFormat.PDB ? Type.PDB - : Type.MMCIF); + ((StructureFile) alignFile).setDbRefType(FileFormat.PDB + .equals(fileFormat) ? Type.PDB : Type.MMCIF); } else { @@ -276,7 +274,7 @@ public class AppletFormatAdapter ex.printStackTrace(); } } - if (fileFormat == FileFormat.Html) + if (FileFormat.Html.equals(fileFormat)) { throw new IOException(e.getMessage()); } @@ -301,7 +299,7 @@ public class AppletFormatAdapter DataSourceType type = source.dataSourceType; try { - if (format == FileFormat.PDB || format == FileFormat.MMCif) + if (FileFormat.PDB.equals(format) || FileFormat.MMCif.equals(format)) { // TODO obtain config value from preference settings boolean isParseWithJMOL = false; diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index e17fe04..830efe2 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -298,7 +298,7 @@ public class FileLoader implements Runnable loadtime = -System.currentTimeMillis(); AlignmentI al = null; - if (format == FileFormat.Jalview) + if (FileFormat.Jalview.equals(format)) { if (source != null) { -- 1.7.10.2