X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fproject%2FJalview2XML.java;h=56185293fac412c92d87c64a440b6d0b337613d3;hb=4f77328104498504339216829abf5ea87e2791ec;hp=e29383162afb1c93f8597ec15b4aae23d27e762e;hpb=ad1f4306281b0894fa42394b9a68da834cf14af6;p=jalview.git diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index e293831..5618529 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -82,6 +82,7 @@ import jalview.schemes.ColourSchemeProperty; import jalview.schemes.FeatureColour; import jalview.schemes.ResidueProperties; import jalview.schemes.UserColourScheme; +import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.Format; import jalview.util.MessageManager; @@ -1080,7 +1081,7 @@ public class Jalview2XML * only view *should* be coped with sensibly. */ // This must have been loaded, is it still visible? - JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames(); + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); String matchedFile = null; for (int f = frames.length - 1; f > -1; f--) { @@ -1232,9 +1233,9 @@ public class Jalview2XML { // FIND ANY ASSOCIATED TREES // NOT IMPLEMENTED FOR HEADLESS STATE AT PRESENT - if (Desktop.getDesktopPane() != null) + if (Desktop.desktop != null) { - JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames(); + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int t = 0; t < frames.length; t++) { @@ -1278,9 +1279,9 @@ public class Jalview2XML /* * save PCA viewers */ - if (!storeDS && Desktop.getDesktopPane() != null) + if (!storeDS && Desktop.desktop != null) { - for (JInternalFrame frame : Desktop.getDesktopPane().getAllFrames()) + for (JInternalFrame frame : Desktop.desktop.getAllFrames()) { if (frame instanceof PCAPanel) { @@ -1671,7 +1672,7 @@ public class Jalview2XML // using save and then load try { - fileName = fileName.replace('\\', '/'); + fileName = fileName.replace('\\', '/'); System.out.println("Writing jar entry " + fileName); JarEntry entry = new JarEntry(fileName); jout.putNextEntry(entry); @@ -1918,11 +1919,11 @@ public class Jalview2XML final SequenceI jds, List viewIds, AlignmentPanel ap, boolean storeDataset) { - if (Desktop.getDesktopPane() == null) + if (Desktop.desktop == null) { return; } - JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames(); + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); for (int f = frames.length - 1; f > -1; f--) { if (frames[f] instanceof AppVarna) @@ -2378,7 +2379,7 @@ public class Jalview2XML if (calcIdParam.getVersion().equals("1.0")) { final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]); - Jws2Instance service = Jws2Discoverer.getInstance() + Jws2Instance service = Jws2Discoverer.getDiscoverer() .getPreferredServiceFor(calcIds); if (service != null) { @@ -2770,52 +2771,52 @@ public class Jalview2XML return af; } - @SuppressWarnings("unused") - private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { + @SuppressWarnings("unused") + private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { - // BH 2018 allow for bytes already attached to File object - try { - String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); + // BH 2018 allow for bytes already attached to File object + try { + String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile) : null; - URL url = null; - errorMessage = null; - uniqueSetSuffix = null; - seqRefIds = null; - viewportsAdded.clear(); - frefedSequence = null; - - if (file.startsWith("http://")) { - url = new URL(file); - } - final URL _url = url; - return new jarInputStreamProvider() { - - @Override - public JarInputStream getJarInputStream() throws IOException { - if (bytes != null) { -// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); - return new JarInputStream(new ByteArrayInputStream(bytes)); - } - if (_url != null) { -// System.out.println("Jalview2XML: opening url jarInputStream for " + _url); - return new JarInputStream(_url.openStream()); - } else { -// System.out.println("Jalview2XML: opening file jarInputStream for " + file); - return new JarInputStream(new FileInputStream(file)); - } - } - - @Override - public String getFilename() { - return file; - } - }; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } + URL url = null; + errorMessage = null; + uniqueSetSuffix = null; + seqRefIds = null; + viewportsAdded.clear(); + frefedSequence = null; + + if (file.startsWith("http://")) { + url = new URL(file); + } + final URL _url = url; + return new jarInputStreamProvider() { + + @Override + public JarInputStream getJarInputStream() throws IOException { + if (bytes != null) { +// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); + return new JarInputStream(new ByteArrayInputStream(bytes)); + } + if (_url != null) { +// System.out.println("Jalview2XML: opening url jarInputStream for " + _url); + return new JarInputStream(_url.openStream()); + } else { +// System.out.println("Jalview2XML: opening file jarInputStream for " + file); + return new JarInputStream(new FileInputStream(file)); + } + } + + @Override + public String getFilename() { + return file; + } + }; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } /** * Recover jalview session from a jalview project archive. Caller may @@ -2914,9 +2915,9 @@ public class Jalview2XML { // used to attempt to parse as V1 castor-generated xml } - if (Desktop.getInstance() != null) + if (Desktop.instance != null) { - Desktop.getInstance().stopLoading(); + Desktop.instance.stopLoading(); } if (af != null) { @@ -2944,7 +2945,7 @@ public class Jalview2XML */ for (AlignFrame fr : gatherToThisFrame.values()) { - Desktop.getInstance().gatherViews(fr); + Desktop.instance.gatherViews(fr); } restoreSplitFrames(); @@ -2952,7 +2953,8 @@ public class Jalview2XML { if (ds.getCodonFrames() != null) { - Desktop.getStructureSelectionManager() + StructureSelectionManager + .getStructureSelectionManager(Desktop.instance) .registerMappings(ds.getCodonFrames()); } } @@ -2961,9 +2963,9 @@ public class Jalview2XML reportErrors(); } - if (Desktop.getInstance() != null) + if (Desktop.instance != null) { - Desktop.getInstance().stopLoading(); + Desktop.instance.stopLoading(); } return af; @@ -3044,7 +3046,7 @@ public class Jalview2XML */ for (SplitFrame sf : gatherTo) { - Desktop.getInstance().gatherViews(sf); + Desktop.instance.gatherViews(sf); } splitFrameCandidates.clear(); @@ -3103,7 +3105,7 @@ public class Jalview2XML @Override public void run() { - JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), + JvOptionPane.showInternalMessageDialog(Desktop.desktop, finalErrorMessage, "Error " + (saving ? "saving" : "loading") + " Jalview file", @@ -3573,7 +3575,9 @@ public class Jalview2XML { entry.setProperty(prop.getName(), prop.getValue()); } - Desktop.getStructureSelectionManager().registerPDBEntry(entry); + StructureSelectionManager + .getStructureSelectionManager(Desktop.instance) + .registerPDBEntry(entry); // adds PDBEntry to datasequence's set (since Jalview 2.10) if (al.getSequenceAt(i).getDatasetSequence() != null) { @@ -4290,7 +4294,7 @@ public class Jalview2XML int height = safeInt(structureState.getHeight()); // Probably don't need to do this anymore... - // Desktop.getDesktop().getComponentAt(x, y); + // Desktop.desktop.getComponentAt(x, y); // TODO: NOW: check that this recovers the PDB file correctly. String pdbFile = loadPDBFile(jprovider, pdbid.getId(), pdbid.getFile()); @@ -4532,7 +4536,7 @@ public class Jalview2XML String reformatedOldFilename = oldfilenam.replaceAll("/", "\\\\"); filedat = oldFiles.get(new File(reformatedOldFilename)); } - newFileLoc.append(Platform.escapeString(filedat.getFilePath())); + newFileLoc.append(Platform.escapeBackslashes(filedat.getFilePath())); pdbfilenames.add(filedat.getFilePath()); pdbids.add(filedat.getPdbId()); seqmaps.add(filedat.getSeqList().toArray(new SequenceI[0])); @@ -4774,7 +4778,7 @@ public class Jalview2XML { try { - frames = Desktop.getDesktopPane().getAllFrames(); + frames = Desktop.desktop.getAllFrames(); } catch (ArrayIndexOutOfBoundsException e) { // occasional No such child exceptions are thrown here... @@ -4853,14 +4857,14 @@ public class Jalview2XML af = new AlignFrame(al, safeInt(view.getWidth()), safeInt(view.getHeight()), uniqueSeqSetId, viewId) // { -// -// @Override -// protected void processKeyEvent(java.awt.event.KeyEvent e) { -// System.out.println("Jalview2XML AF " + e); -// super.processKeyEvent(e); -// -// } -// +// +// @Override +// protected void processKeyEvent(java.awt.event.KeyEvent e) { +// System.out.println("Jalview2XML AF " + e); +// super.processKeyEvent(e); +// +// } +// // } ; @@ -5136,7 +5140,7 @@ public class Jalview2XML } else { - featureOrder.put(featureType, new Float( + featureOrder.put(featureType, Float.valueOf( fs / jm.getFeatureSettings().getSetting().size())); } if (safeBoolean(setting.isDisplay())) @@ -5148,7 +5152,7 @@ public class Jalview2XML for (int gs = 0; gs < jm.getFeatureSettings().getGroup().size(); gs++) { Group grp = jm.getFeatureSettings().getGroup().get(gs); - fgtable.put(grp.getName(), new Boolean(grp.isDisplay())); + fgtable.put(grp.getName(), Boolean.valueOf(grp.isDisplay())); } // FeatureRendererSettings frs = new FeatureRendererSettings(renderOrder, // fgtable, featureColours, jms.getFeatureSettings().hasTransparency() ?