From: hansonr Date: Wed, 3 Apr 2019 13:41:19 +0000 (-0500) Subject: j2sNative clean-up. Fixes problem with second try of sequence fetching X-Git-Tag: Release_2_11_4_0~45^2~18^2~178 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8fa69554edf6aeb278b4a4afd8e2b60264fdccd8;p=jalview.git j2sNative clean-up. Fixes problem with second try of sequence fetching not retrieving (cached) data --- diff --git a/_j2sclasslist.txt b/_j2sclasslist.txt index 8fd8415..9a790a0 100644 --- a/_j2sclasslist.txt +++ b/_j2sclasslist.txt @@ -804,3 +804,156 @@ jalview/util/LinkedIdentityHashSet.js jalview/util/ParseHtmlBodyAndLinks.js java/util/function/Function.js swingjs/a2s/A2SContainer.js + +jalview/fts/api/FTSData.js +jalview/fts/api/FTSDataColumnI.js +jalview/fts/api/FTSRestClientI.js +jalview/fts/core/DecimalFormatTableCellRenderer.js +jalview/fts/core/FTSDataColumnPreferences.js +jalview/fts/core/FTSRestClient.js +jalview/fts/core/FTSRestRequest.js +jalview/fts/core/FTSRestResponse.js +jalview/fts/service/pdb/PDBFTSRestClient.js +jalview/gui/StructureChooser.js +jalview/javascript/json/JSON.js +jalview/javascript/web/Client.js +jalview/javascript/web/ClientResponse.js +jalview/javascript/web/WebResource.js +jalview/jbgui/BackupFilesPresetEntry.js +jalview/jbgui/GStructureChooser.js +jalview/jbgui/IntKeyStringValueEntry.js +java/awt/CardLayout.js +java/awt/TextComponent.js +java/awt/image/ImageConsumer.js +java/io/ObjectStreamField.js +java/net/HttpsURLConnection.js +java/net/URI.js +java/util/ComparableTimSort.js +java/util/LinkedHashSet.js +java/util/WeakHashMap.js +javajs/util/Base64.js +javax/swing/CellRendererPane.js +javax/swing/DefaultListSelectionModel.js +javax/swing/DefaultRowSorter.js +javax/swing/DropMode.js +javax/swing/Icon.js +javax/swing/ImageIcon.js +javax/swing/JTable.js +javax/swing/JTextField.js +javax/swing/ListSelectionModel.js +javax/swing/RowSorter.js +javax/swing/SortOrder.js +javax/swing/event/CaretEvent.js +javax/swing/event/CaretListener.js +javax/swing/event/CellEditorListener.js +javax/swing/event/DocumentListener.js +javax/swing/event/ListSelectionEvent.js +javax/swing/event/ListSelectionListener.js +javax/swing/event/MouseInputListener.js +javax/swing/event/RowSorterEvent.js +javax/swing/event/RowSorterListener.js +javax/swing/event/SwingPropertyChangeSupport.js +javax/swing/event/TableColumnModelEvent.js +javax/swing/event/TableColumnModelListener.js +javax/swing/event/TableModelEvent.js +javax/swing/plaf/InputMapUIResource.js +javax/swing/table/DefaultTableCellRenderer.js +javax/swing/table/DefaultTableColumnModel.js +javax/swing/table/DefaultTableModel.js +javax/swing/table/JTableHeader.js +javax/swing/table/TableCellRenderer.js +javax/swing/table/TableColumn.js +javax/swing/table/TableColumnModel.js +javax/swing/table/TableRowSorter.js +javax/swing/text/Caret.js +javax/swing/text/DefaultCaret.js +javax/swing/text/DefaultEditorKit.js +javax/swing/text/Document.js +javax/swing/text/EditorKit.js +javax/swing/text/Element.js +javax/swing/text/JTextComponent.js +javax/swing/text/Position.js +javax/swing/text/TextAction.js +javax/swing/text/View.js +net/miginfocom/layout/AC.js +net/miginfocom/layout/AnimSpec.js +net/miginfocom/layout/BoundSize.js +net/miginfocom/layout/CC.js +net/miginfocom/layout/ComponentWrapper.js +net/miginfocom/layout/ConstraintParser.js +net/miginfocom/layout/ContainerWrapper.js +net/miginfocom/layout/DimConstraint.js +net/miginfocom/layout/Grid.js +net/miginfocom/layout/LC.js +net/miginfocom/layout/LayoutUtil.js +net/miginfocom/layout/LinkHandler.js +net/miginfocom/layout/PlatformDefaults.js +net/miginfocom/layout/ResizeConstraint.js +net/miginfocom/layout/UnitValue.js +net/miginfocom/swing/MigLayout.js +net/miginfocom/swing/SwingComponentWrapper.js +net/miginfocom/swing/SwingContainerWrapper.js +sun/swing/StringUIClientPropertyKey.js +sun/swing/SwingUtilities2.js +sun/swing/UIClientPropertyKey.js +sun/swing/table/DefaultTableCellHeaderRenderer.js +swingjs/JSAbstractDocument.js +swingjs/JSImage.js +swingjs/JSImagekit.js +swingjs/JSPlainDocument.js +swingjs/api/JSMinimalAbstractDocument.js +swingjs/json/JSON.js +swingjs/plaf/BasicHTML.js +swingjs/plaf/CellHolder.js +swingjs/plaf/JSTableHeaderUI.js +swingjs/plaf/JSTableUI.js +swingjs/plaf/JSTextFieldUI.js +swingjs/plaf/JSTextUI.js +swingjs/plaf/TextListener.js + +com/stevesoft/pat/Bracket.js +com/stevesoft/pat/CaseMgr.js +com/stevesoft/pat/FastMulti.js +com/stevesoft/pat/NUnicodeAlpha.js +com/stevesoft/pat/NUnicodeCurrency.js +com/stevesoft/pat/NUnicodeDigit.js +com/stevesoft/pat/NUnicodeMath.js +com/stevesoft/pat/NUnicodePunct.js +com/stevesoft/pat/NUnicodeW.js +com/stevesoft/pat/NUnicodeWhite.js +com/stevesoft/pat/NoPattern.js +com/stevesoft/pat/Or.js +com/stevesoft/pat/OrMark.js +com/stevesoft/pat/Pattern.js +com/stevesoft/pat/PatternSub.js +com/stevesoft/pat/Pthings.js +com/stevesoft/pat/Range.js +com/stevesoft/pat/RegOpt.js +com/stevesoft/pat/RegRes.js +com/stevesoft/pat/Regex.js +com/stevesoft/pat/Rthings.js +com/stevesoft/pat/StrPos.js +com/stevesoft/pat/StringLike.js +com/stevesoft/pat/SubMark.js +com/stevesoft/pat/UniValidator.js +com/stevesoft/pat/UnicodeAlpha.js +com/stevesoft/pat/UnicodeCurrency.js +com/stevesoft/pat/UnicodeDigit.js +com/stevesoft/pat/UnicodeLower.js +com/stevesoft/pat/UnicodeMath.js +com/stevesoft/pat/UnicodePunct.js +com/stevesoft/pat/UnicodeUpper.js +com/stevesoft/pat/UnicodeW.js +com/stevesoft/pat/UnicodeWhite.js +com/stevesoft/pat/Validator.js +com/stevesoft/pat/oneChar.js +com/stevesoft/pat/parsePerl.js +com/stevesoft/pat/patInt.js +com/stevesoft/pat/wrap/StringWrap.js + +jalview/api/DBRefEntryI.js +jalview/api/SequenceStructureBinding.js +jalview/api/structures/JalviewStructureDisplayI.js +jalview/datamodel/DBRefEntry.js +jalview/datamodel/Mapping.js +jalview/datamodel/features/FeatureAttributes.js diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index fda04cb..9dcc949 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -278,8 +278,7 @@ public class Cache /** Default file is ~/.jalview_properties */ static String propertiesFile; - private static boolean propsAreReadOnly = Platform.isJS();/// ** @j2sNative - /// true || */false; + private static boolean propsAreReadOnly = Platform.isJS(); private final static String JS_PROPERTY_PREFIX = "jalview_"; diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 66375e1..330919b 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -240,7 +240,7 @@ public class Jalview private static void setLogging() { // BH - for event debugging in JavaScript (Java mode only) - if (!Platform.isJS())// !(/** @j2sNative true ||*/false)) + if (!Platform.isJS()) /** * Java only * @@ -290,7 +290,7 @@ public class Jalview if (!Platform.isJS()) /** - * ignore in JavaScript + * Java only * * @j2sNative */ @@ -838,8 +838,8 @@ public class Jalview // And the user // //////////////////// - if (!Platform.isJS() && // /** @j2sNative false && */ // BH 2018 - !headless && file == null && vamsasImport == null + if (!Platform.isJS() && !headless && file == null + && vamsasImport == null && jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true)) /** * Java only diff --git a/src/jalview/bin/JalviewJS2.java b/src/jalview/bin/JalviewJS2.java index 6767912..70e8946 100644 --- a/src/jalview/bin/JalviewJS2.java +++ b/src/jalview/bin/JalviewJS2.java @@ -1,5 +1,7 @@ package jalview.bin; +import jalview.util.Platform; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -44,28 +46,30 @@ public class JalviewJS2 protected static int focusTime = 0; -private static void showFocusTimer() { - - Timer t = new Timer(100, new ActionListener() { + private static void showFocusTimer() + { - @Override - public void actionPerformed(ActionEvent e) { - String s = /** @j2sNative document.activeElement.id || */ - null; + if (Platform.isJS()) + { + Timer t = new Timer(100, new ActionListener() + { - s += " " + (++focusTime); + @Override + public void actionPerformed(ActionEvent e) + { + String s = /** @j2sNative document.activeElement.id || */ + null; - /** @j2sNative document.title = s; */ - } + s += " " + (++focusTime); - }); + /** @j2sNative document.title = s; */ + } - t.setRepeats(true); - if (/** @j2sNative true || */ - false) - { - t.start(); - } + }); + + t.setRepeats(true); + t.start(); + } } diff --git a/src/jalview/datamodel/DBRefSource.java b/src/jalview/datamodel/DBRefSource.java index c1e1741..2f94884 100755 --- a/src/jalview/datamodel/DBRefSource.java +++ b/src/jalview/datamodel/DBRefSource.java @@ -91,7 +91,9 @@ public class DBRefSource public static int getSourceKey(String name) { for (int i = 0; i < MASK_COUNT; i++) { if (name.equals(allSources[i])) - return 1< src = new ArrayList<>(); -// for (Field f : DBRefSource.class.getFields()) -// { -// if (String.class.equals(f.getType())) -// { -// try -// { -// src.add((String) f.get(null)); -// } catch (Exception x) -// { -// x.printStackTrace(); -// } -// } -// } -// allSourcesFromReflection = src.toArray(new String[0]); -// } -// return allSourcesFromReflection; -// } -// } - public static boolean isPrimaryCandidate(String ucversion) { // tricky - this test really needs to search the sequence's set of dbrefs to // see if there is a primary reference that derived this reference. diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index 47e9440..7ff0f75 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -93,7 +93,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected JInternalFrame mainFrame = new JInternalFrame( getFTSFrameTitle()); - protected JTabbedPane tabs = jalview.jbgui.GDesktop.createTabbedPane(); + protected JTabbedPane tabs = new JTabbedPane(); protected IProgressIndicator progressIndicator; @@ -136,7 +136,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected JLabel lbl_blank = new JLabel(balnkPlaceholderImage); - JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane(); + JTabbedPane tabbedPane = new JTabbedPane(); private JPanel pnl_actions = new JPanel(); diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 7d54255..b7e1117 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -406,7 +406,6 @@ public class Desktop extends jalview.jbgui.GDesktop setBounds(xPos, yPos, 900, 650); } - // boolean doFullLoad = /** @j2sNative ! */true; if (!Platform.isJS()) /** * Java only @@ -890,7 +889,7 @@ public class Desktop extends jalview.jbgui.GDesktop frame.setResizable(resizable); frame.setMaximizable(resizable); frame.setIconifiable(resizable); - frame.setOpaque(Platform.isJS());/// ** @j2sNative true || */false); + frame.setOpaque(Platform.isJS()); if (frame.getX() < 1 && frame.getY() < 1) { diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 84e3313..a5aaf7c 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -249,7 +249,6 @@ public class OverviewPanel extends JPanel * Javascript does not call componentResized on initial display, * so do the update here */ - // boolean doUpdate = /** @j2sNative true || */ false; if (Platform.isJS()) { updateOverviewImage(); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 4193143..3a6f9e4 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -791,7 +791,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener protected void showFeatureDetails(SequenceFeature sf) { JInternalFrame details; - if (Platform.isJS())// ** @j2sNative true || */ false) + if (Platform.isJS()) { details = new JInternalFrame(); JPanel panel = new JPanel(new BorderLayout()); diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 6bb96c0..f7d7cbf 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -88,7 +88,6 @@ public class SplashScreen extends JPanel this.interactiveDialog = interactive; // show a splashscreen that will disapper if (Platform.isJS()) // BH 2019 - // if (/** @j2sNative true || */ false) { authlist = new JLabel(""); run(); @@ -173,8 +172,13 @@ public class SplashScreen extends JPanel this.setLayout(new BorderLayout()); iframe.setContentPane(this); iframe.setLayer(JLayeredPane.PALETTE_LAYER); + if (Platform.isJS()) + { + // ignore in JavaScript + } + else /** - * we add image directly in html for javascript ? + * Java only * * @j2sNative */ @@ -206,7 +210,6 @@ public class SplashScreen extends JPanel iframe.setVisible(false); oldtext = newtext.length(); if (Platform.isJS()) // BH 2019 - // if (/** @j2sNative true || */ false) { authlist = new JLabel( "


" @@ -215,19 +218,17 @@ public class SplashScreen extends JPanel ((JLabel) authlist).setBackground(Color.white); } else + /** + * Java only + * + * @j2sNative + */ { - /** - * Java only - * - * @j2sNative - */ - { - authlist = new JTextPane(); - ((JTextPane) authlist).setEditable(false); - ((JTextPane) authlist).setContentType("text/html"); - ((JTextPane) authlist).setText(newtext); - ((JTextPane) authlist).addHyperlinkListener(this); - } + authlist = new JTextPane(); + ((JTextPane) authlist).setEditable(false); + ((JTextPane) authlist).setContentType("text/html"); + ((JTextPane) authlist).setText(newtext); + ((JTextPane) authlist).addHyperlinkListener(this); } authlist.addMouseListener(closer); diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 8720341..621f49d 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -748,17 +748,24 @@ public class UserDefinedColours extends GUserDefinedColours JvOptionPane.WARNING_MESSAGE); } - if (ColourSchemes.getInstance().nameExists(name)) - { - // BH 2018 SwingJS bypasses this question with YES_OPTION - int reply = /** @j2sNative 0 && */ JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.formatMessage( - "label.colour_scheme_exists_overwrite", new Object[] - { name, name }), - MessageManager.getString("label.duplicate_scheme_name"), - JvOptionPane.YES_NO_OPTION); - if (reply != JvOptionPane.YES_OPTION) + if (!Platform.isJS() && ColourSchemes.getInstance().nameExists(name)) + { + /** + * java only + * + * @j2sNative + */ { + int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, + MessageManager.formatMessage( + "label.colour_scheme_exists_overwrite", new Object[] + { name, name }), + MessageManager.getString("label.duplicate_scheme_name"), + JvOptionPane.YES_NO_OPTION); + if (reply != JvOptionPane.YES_OPTION) + { + return; + } } } @@ -771,24 +778,24 @@ public class UserDefinedColours extends GUserDefinedColours MessageManager.getString("label.save_colour_scheme")); chooser.setToolTipText(MessageManager.getString("action.save")); int option = chooser.showSaveDialog(this); - if (option == JalviewFileChooser.APPROVE_OPTION) - { - File file = chooser.getSelectedFile(); - UserColourScheme updatedScheme = addNewColourScheme(file.getPath()); - saveToFile(file); - changedButNotSaved = false; - - /* - * changes saved - apply to alignment if we are changing - * the currently selected colour scheme; also make the updated - * colours the 'backout' scheme on Cancel - */ - if (oldColourScheme != null - && name.equals(oldColourScheme.getSchemeName())) - { - oldColourScheme = updatedScheme; - applyButton_actionPerformed(); - } + if (option == JalviewFileChooser.APPROVE_OPTION) + { + File file = chooser.getSelectedFile(); + UserColourScheme updatedScheme = addNewColourScheme(file.getPath()); + saveToFile(file); + changedButNotSaved = false; + + /* + * changes saved - apply to alignment if we are changing + * the currently selected colour scheme; also make the updated + * colours the 'backout' scheme on Cancel + */ + if (oldColourScheme != null + && name.equals(oldColourScheme.getSchemeName())) + { + oldColourScheme = updatedScheme; + applyButton_actionPerformed(); + } } } diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index ca45407..c6137cc 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -39,7 +39,6 @@ import java.util.Vector; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JInternalFrame; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; @@ -216,7 +215,7 @@ public class WebserviceInfo extends GWebserviceInfo // revert to a tabbed pane. JScrollPane firstpane; this.remove(firstpane = (JScrollPane) jobPanes.get(0)); - subjobs = jalview.jbgui.GDesktop.createTabbedPane(); + subjobs = new JTabbedPane(); this.add(subjobs, BorderLayout.CENTER); subjobs.add(firstpane); subjobs.setTitleAt(0, firstpane.getName()); @@ -351,6 +350,7 @@ public class WebserviceInfo extends GWebserviceInfo frame.addInternalFrameListener( new javax.swing.event.InternalFrameAdapter() { + @Override public void internalFrameClosed( javax.swing.event.InternalFrameEvent evt) { @@ -676,6 +676,7 @@ public class WebserviceInfo extends GWebserviceInfo * @param e * DOCUMENT ME! */ + @Override protected void cancel_actionPerformed(ActionEvent e) { if (!serviceIsCancellable) @@ -707,6 +708,7 @@ public class WebserviceInfo extends GWebserviceInfo { javax.swing.SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { JvOptionPane.showInternalMessageDialog(Desktop.desktop, message, @@ -756,6 +758,7 @@ public class WebserviceInfo extends GWebserviceInfo BufferedImage offscreen; + @Override public void run() { startTime = System.currentTimeMillis(); @@ -865,6 +868,7 @@ public class WebserviceInfo extends GWebserviceInfo } } + @Override public void paintComponent(Graphics g1) { drawPanel(); @@ -880,6 +884,7 @@ public class WebserviceInfo extends GWebserviceInfo renderAsHtml = b; } + @Override public void hyperlinkUpdate(HyperlinkEvent e) { Desktop.hyperlinkUpdate(e); diff --git a/src/jalview/io/ModellerDescription.java b/src/jalview/io/ModellerDescription.java index 7e05b15..f4de52d 100755 --- a/src/jalview/io/ModellerDescription.java +++ b/src/jalview/io/ModellerDescription.java @@ -25,6 +25,8 @@ import jalview.datamodel.SequenceI; import java.util.List; +import com.stevesoft.pat.Regex; + public class ModellerDescription { /** @@ -96,7 +98,7 @@ public class ModellerDescription private resCode validResidueCode(String field) { Integer val = null; - com.stevesoft.pat.Regex r = new com.stevesoft.pat.Regex( + Regex r = new Regex( "\\s*((([-0-9]+).?)|FIRST|LAST|@)"); if (!r.search(field)) diff --git a/src/jalview/io/NewickFile.java b/src/jalview/io/NewickFile.java index c414145..517701b 100755 --- a/src/jalview/io/NewickFile.java +++ b/src/jalview/io/NewickFile.java @@ -35,6 +35,8 @@ import java.io.FileReader; import java.io.IOException; import java.util.StringTokenizer; +import com.stevesoft.pat.Regex; + /** * Parse a new hanpshire style tree Caveats: NHX files are NOT supported and the * tree distances and topology are unreliable when they are parsed. TODO: on @@ -87,13 +89,13 @@ public class NewickFile extends FileParse boolean printRootInfo = true; - private com.stevesoft.pat.Regex[] NodeSafeName = new com.stevesoft.pat.Regex[] { - new com.stevesoft.pat.Regex().perlCode("m/[\\[,:'()]/"), // test for + private Regex[] NodeSafeName = new Regex[] { + new Regex().perlCode("m/[\\[,:'()]/"), // test for // requiring // quotes - new com.stevesoft.pat.Regex().perlCode("s/'/''/"), // escaping quote + new Regex().perlCode("s/'/''/"), // escaping quote // characters - new com.stevesoft.pat.Regex().perlCode("s/\\/w/_/") // unqoted whitespace + new Regex().perlCode("s/\\/w/_/") // unqoted whitespace // transformation }; @@ -292,7 +294,7 @@ public class NewickFile extends FileParse boolean ascending = false; // flag indicating that we are leaving the // current node - com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex( + Regex majorsyms = new Regex( "[(\\['),;]"); int nextcp = 0; @@ -354,7 +356,7 @@ public class NewickFile extends FileParse // Deal with quoted fields case '\'': - com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex( + Regex qnodename = new Regex( "'([^']|'')+'"); if (qnodename.searchFrom(nf, fcp)) @@ -363,7 +365,7 @@ public class NewickFile extends FileParse nodename = new String( qnodename.stringMatched().substring(1, nl - 1)); // unpack any escaped colons - com.stevesoft.pat.Regex xpandquotes = com.stevesoft.pat.Regex + Regex xpandquotes = Regex .perlCode("s/''/'/"); String widernodename = xpandquotes.replaceAll(nodename); nodename = widernodename; @@ -398,7 +400,7 @@ public class NewickFile extends FileParse * '"+nf.substring(cp,fcp)+"'"); } */ // verify termination. - com.stevesoft.pat.Regex comment = new com.stevesoft.pat.Regex( + Regex comment = new Regex( "]"); if (comment.searchFrom(nf, fcp)) { @@ -432,11 +434,11 @@ public class NewickFile extends FileParse + fstring.substring(cend + 1); } - com.stevesoft.pat.Regex uqnodename = new com.stevesoft.pat.Regex( + Regex uqnodename = new Regex( "\\b([^' :;\\](),]+)"); - com.stevesoft.pat.Regex nbootstrap = new com.stevesoft.pat.Regex( + Regex nbootstrap = new Regex( "\\s*([0-9+]+)\\s*:"); - com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex( + Regex ndist = new Regex( ":([-0-9Ee.+]+)"); if (!parsednodename && uqnodename.search(fstring) @@ -970,7 +972,7 @@ public class NewickFile extends FileParse trf.parse(); System.out.println("Original file :\n"); - com.stevesoft.pat.Regex nonl = new com.stevesoft.pat.Regex("\n+", ""); + Regex nonl = new Regex("\n+", ""); System.out.println(nonl.replaceAll(newickfile.toString()) + "\n"); System.out.println("Parsed file.\n"); diff --git a/src/jalview/javascript/json/JSON.java b/src/jalview/javascript/json/JSON.java index 4642bd3..4e9d1dd 100644 --- a/src/jalview/javascript/json/JSON.java +++ b/src/jalview/javascript/json/JSON.java @@ -40,7 +40,7 @@ public class JSON { public static BufferedReader getJSONReader(InputStream is) { return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null; - } + } /** * diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 65c6a5b..8bbfb8d 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -177,8 +177,7 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem(); - protected JTabbedPane tabbedPane = jalview.jbgui.GDesktop - .createTabbedPane(); + protected JTabbedPane tabbedPane = new JTabbedPane(); protected JMenuItem reload = new JMenuItem(); diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 315c2f7..2ea3774 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -46,22 +46,6 @@ import javax.swing.JMenuItem; public class GDesktop extends JFrame { - public static javax.swing.JTabbedPane createTabbedPane() - { - // now just always return JTabbedPane - return new javax.swing.JTabbedPane(); -// // BH 2018 coercing jalview.jbgui.swing.JTabbedPane() for now -// if (/** @j2sNative false && */ -// true) -// { -// // Java -// return new javax.swing.JTabbedPane(); -// } -// // JavaScript -// return (javax.swing.JTabbedPane) (Object) new jalview.jbgui.swing.JTabbedPane(); - } - - protected static JMenu windowMenu = new JMenu(); JMenuBar desktopMenubar = new JMenuBar(); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 361ba71..3c35e4e 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -352,7 +352,7 @@ public class GPreferences extends JPanel */ private void jbInit() throws Exception { - final JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane(); + final JTabbedPane tabbedPane = new JTabbedPane(); this.setLayout(new BorderLayout()); JPanel okCancelPanel = initOkCancelPanel(); this.add(tabbedPane, BorderLayout.CENTER); diff --git a/src/jalview/jbgui/GRestServiceEditorPane.java b/src/jalview/jbgui/GRestServiceEditorPane.java index b5baa2d..a4dca4b 100644 --- a/src/jalview/jbgui/GRestServiceEditorPane.java +++ b/src/jalview/jbgui/GRestServiceEditorPane.java @@ -98,7 +98,7 @@ public class GRestServiceEditorPane extends JPanel paste.setLayout( new MigLayout("", "[grow 100, fill]", "[][grow 100,fill]")); - panels = jalview.jbgui.GDesktop.createTabbedPane(); + panels = new JTabbedPane(); panels.addTab(details.getName(), details); panels.addTab(inputs.getName(), inputs); panels.addTab(paste.getName(), paste); diff --git a/src/jalview/jbgui/GSplitFrame.java b/src/jalview/jbgui/GSplitFrame.java index 3e04f03..353c494 100644 --- a/src/jalview/jbgui/GSplitFrame.java +++ b/src/jalview/jbgui/GSplitFrame.java @@ -209,6 +209,9 @@ public class GSplitFrame extends JInternalFrame { this.dividerRatio = r; /** + * + * BH need for this? - NOT setting the location? + * * @j2sNative */ { @@ -224,6 +227,8 @@ public class GSplitFrame extends JInternalFrame protected void setDividerLocation(int p) { /** + * BH: Why are we not setting the location? + * * @j2sNative */ { diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index be94301..b9c9267 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -47,8 +47,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -68,7 +66,6 @@ import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListCellRenderer; -import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -162,7 +159,7 @@ public abstract class GStructureChooser extends JPanel protected JTable tbl_local_pdb = new JTable(); - protected JTabbedPane pnl_filter = jalview.jbgui.GDesktop.createTabbedPane(); + protected JTabbedPane pnl_filter = new JTabbedPane(); protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences( PreferenceSource.STRUCTURE_CHOOSER, diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java index f47ca23..45b7551 100755 --- a/src/jalview/util/BrowserLauncher.java +++ b/src/jalview/util/BrowserLauncher.java @@ -236,7 +236,9 @@ public class BrowserLauncher loadedWithoutErrors = true; + if (!Platform.isJS()) /** + * Java only * * @j2sNative * @@ -334,7 +336,10 @@ public class BrowserLauncher private static boolean loadClasses() { + if (!Platform.isJS()) /** + * Java only + * * @j2sNative * */ @@ -538,7 +543,10 @@ public class BrowserLauncher */ private static Object locateBrowser() { + if (!Platform.isJS()) /** + * Java only + * * @j2sNative * */ @@ -735,10 +743,12 @@ public class BrowserLauncher public static void openURL(String url) throws IOException { - if (Platform.openURL(url)) + if (Platform.isJS()) { + Platform.openURL(url); return; } + else /** * Java only * diff --git a/src/jalview/util/JSONUtils.java b/src/jalview/util/JSONUtils.java index 656da48..dde1662 100644 --- a/src/jalview/util/JSONUtils.java +++ b/src/jalview/util/JSONUtils.java @@ -26,6 +26,8 @@ public class JSONUtils } /** + * BH TODO to Platform? + * * @j2sNative * * return jsonArray.elementData.slice(0, n).join(","); diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index b2bc3f4..68985b5 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -26,6 +26,7 @@ import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; @@ -463,7 +464,7 @@ public class Platform try { br = new BufferedReader(new InputStreamReader(response, "UTF-8")); - return parseJSON(br); + return new JSONParser().parse(br); } finally { if (br != null) @@ -508,4 +509,38 @@ public class Platform } + /** + * Dump the input stream to an output file. + * + * @param is + * @param outFile + * @throws IOException + * if the file cannot be created or there is a problem reading the + * input stream. + */ + public static void streamToFile(InputStream is, File outFile) + throws IOException + { + if (!isJS() || /** + * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) || + */ + false) + { + return; + } + FileOutputStream fio = new FileOutputStream(outFile); + try + { + byte[] bb = new byte[32 * 1024]; + int l; + while ((l = is.read(bb)) > 0) + { + fio.write(bb, 0, l); + } + } finally + { + fio.close(); + } + } + } diff --git a/src/jalview/ws/ebi/EBIFetchClient.java b/src/jalview/ws/ebi/EBIFetchClient.java index 5dc3c94..b5a7328 100644 --- a/src/jalview/ws/ebi/EBIFetchClient.java +++ b/src/jalview/ws/ebi/EBIFetchClient.java @@ -22,11 +22,11 @@ package jalview.ws.ebi; import jalview.datamodel.DBRefSource; import jalview.util.MessageManager; +import jalview.util.Platform; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -193,56 +193,39 @@ public class EBIFetchClient * @param database * @param format * @param outFile - * @return + * @return array of lines from EBI only if outFile is null (which it will not + * be) * @throws OutOfMemoryError */ String[] fetchBatch(String ids, String database, String format, File outFile) throws OutOfMemoryError { - // long time = System.currentTimeMillis(); String url = buildUrl(ids, database, format); - + InputStream is = null; try { URL rcall = new URL(url); - HttpURLConnection conn = (HttpURLConnection) rcall.openConnection(); int responseCode = conn.getResponseCode(); - if (responseCode != 200) - { - System.err.println("Warning: response code " + responseCode - + " for " + url); - } - InputStream is = new BufferedInputStream(conn.getInputStream()); - if (outFile != null) + if (responseCode == 200) { - /**@j2sNative - * if (outFile._isTemp) { - * outFile._bytes = is.$in.$in.buf; - * return null; - * } - */ - FileOutputStream fio = new FileOutputStream(outFile); - byte[] bb = new byte[32 * 1024]; - int l; - while ((l = is.read(bb)) > 0) + is = conn.getInputStream(); + if (outFile != null) { - fio.write(bb, 0, l); + Platform.streamToFile(is, outFile); + return null; } - fio.close(); - is.close(); - } - else - { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String rtn; - List arl = new ArrayList(); + List arl = new ArrayList<>(); while ((rtn = br.readLine()) != null) { arl.add(rtn); } - return arl.toArray(new String[arl.size()]); + return (String[]) arl.toArray(); } + System.err.println( + "Warning: response code " + responseCode + " for " + url); } catch (OutOfMemoryError er) { System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + database @@ -250,19 +233,24 @@ public class EBIFetchClient throw er; } catch (Exception ex) { - if (ex.getMessage().startsWith( + if (!ex.getMessage().startsWith( "uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException")) { - return null; + System.err.println("Unexpected exception when retrieving from " + + database + "\nQuery was : '" + ids + "'"); + ex.printStackTrace(System.err); } - System.err.println("Unexpected exception when retrieving from " - + database + "\nQuery was : '" + ids + "'"); - ex.printStackTrace(System.err); - return null; } finally { - // System.err.println("EBIFetch took " + (System.currentTimeMillis() - - // time) + " ms"); + if (is != null) + { + try + { + is.close(); + } catch (IOException e) + { + } + } } return null; } diff --git a/swingjs/SwingJS-site.zip b/swingjs/SwingJS-site.zip index 2424b3c..6c6d9f5 100644 Binary files a/swingjs/SwingJS-site.zip and b/swingjs/SwingJS-site.zip differ diff --git a/swingjs/timestamp b/swingjs/timestamp index 5ed2bf5..57e631c 100644 --- a/swingjs/timestamp +++ b/swingjs/timestamp @@ -1 +1 @@ -20190331212928 +20190403083450 diff --git a/swingjs/ver/3.2.4/SwingJS-site.zip b/swingjs/ver/3.2.4/SwingJS-site.zip index 2424b3c..6c6d9f5 100644 Binary files a/swingjs/ver/3.2.4/SwingJS-site.zip and b/swingjs/ver/3.2.4/SwingJS-site.zip differ diff --git a/swingjs/ver/3.2.4/timestamp b/swingjs/ver/3.2.4/timestamp index 5ed2bf5..57e631c 100644 --- a/swingjs/ver/3.2.4/timestamp +++ b/swingjs/ver/3.2.4/timestamp @@ -1 +1 @@ -20190331212928 +20190403083450