From 422fd57f6ed8ff7a6744aee2497e90f80f46686f Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Thu, 26 Oct 2017 14:53:04 +0100 Subject: [PATCH] named most Jalview threads --- src/jalview/appletgui/OverviewPanel.java | 2 +- src/jalview/appletgui/PCAPanel.java | 6 +-- src/jalview/appletgui/RedundancyPanel.java | 2 +- src/jalview/bin/Jalview.java | 14 +++--- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 12 ++--- src/jalview/fts/core/GFTSPanel.java | 10 ++-- src/jalview/fts/service/pdb/PDBFTSPanel.java | 6 +-- src/jalview/gui/AlignFrame.java | 9 ++-- src/jalview/gui/AppJmol.java | 2 +- src/jalview/gui/ChimeraViewFrame.java | 2 +- src/jalview/gui/Console.java | 8 +-- src/jalview/gui/DasSourceBrowser.java | 15 +++--- src/jalview/gui/Desktop.java | 20 ++++---- src/jalview/gui/JalviewDialog.java | 2 +- src/jalview/gui/OverviewPanel.java | 2 +- src/jalview/gui/StructureViewerBase.java | 4 +- src/jalview/gui/TreeCanvas.java | 4 +- src/jalview/gui/VamsasApplication.java | 2 +- src/jalview/gui/WebserviceInfo.java | 9 +++- src/jalview/gui/WsPreferences.java | 17 +++---- src/jalview/io/BioJsHTMLOutput.java | 4 +- src/jalview/io/FileLoader.java | 4 +- src/jalview/io/HtmlSvgOutput.java | 2 +- src/jalview/javascript/JSFunctionExec.java | 3 +- src/jalview/util/AWTConsole.java | 26 +++++++--- src/jalview/ws/DBRefFetcher.java | 24 ++++----- src/jalview/ws/DasSequenceFeatureFetcher.java | 5 +- src/jalview/ws/jws1/Discoverer.java | 2 +- src/jalview/ws/jws2/Jws2Discoverer.java | 52 ++++++++++---------- 29 files changed, 144 insertions(+), 126 deletions(-) diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 8ce597d..1855c3d 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -235,7 +235,7 @@ public class OverviewPanel extends Panel implements Runnable, updateRunning = true; } - Thread thread = new Thread(this); + Thread thread = new Thread(this, "OverviewUpdateThread"); thread.start(); repaint(); updateRunning = false; diff --git a/src/jalview/appletgui/PCAPanel.java b/src/jalview/appletgui/PCAPanel.java index fc1d359..ea6eda6 100644 --- a/src/jalview/appletgui/PCAPanel.java +++ b/src/jalview/appletgui/PCAPanel.java @@ -117,7 +117,7 @@ public class PCAPanel extends EmbmenuFrame MessageManager.getString("label.principal_component_analysis"), 475, 400); - Thread worker = new Thread(this); + Thread worker = new Thread(this, "PCACalcThread"); worker.start(); } @@ -220,7 +220,7 @@ public class PCAPanel extends EmbmenuFrame ScoreModelI scoreModel = ScoreModels.getInstance() .getDefaultModel(false); pcaModel.setScoreModel(scoreModel); - new Thread(this).start(); + new Thread(this, "PCARecalcThread").start(); } } else if (evt.getSource() == protSetting) @@ -231,7 +231,7 @@ public class PCAPanel extends EmbmenuFrame ScoreModelI scoreModel = ScoreModels.getInstance() .getDefaultModel(true); pcaModel.setScoreModel(scoreModel); - new Thread(this).start(); + new Thread(this, "PCARecalcThread").start(); } } } diff --git a/src/jalview/appletgui/RedundancyPanel.java b/src/jalview/appletgui/RedundancyPanel.java index bd36b0d..c7d8157 100644 --- a/src/jalview/appletgui/RedundancyPanel.java +++ b/src/jalview/appletgui/RedundancyPanel.java @@ -89,7 +89,7 @@ public class RedundancyPanel extends SliderPanel frame.addWindowListener(this); - Thread worker = new Thread(this); + Thread worker = new Thread(this, "RedundancyCalcThread"); worker.start(); } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 9ec0033..245a63c 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -20,9 +20,6 @@ */ package jalview.bin; -import groovy.lang.Binding; -import groovy.util.GroovyScriptEngine; - import jalview.ext.so.SequenceOntology; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -66,6 +63,9 @@ import java.util.Vector; import javax.swing.UIManager; +import groovy.lang.Binding; +import groovy.util.GroovyScriptEngine; + /** * Main class for Jalview Application
*
@@ -155,7 +155,7 @@ public class Jalview running--; } } - }).start(); + }, "FeatureFetcherThread").start(); } public synchronized boolean allFinished() @@ -970,7 +970,7 @@ public class Jalview } try { - Map vbinding = new HashMap(); + Map vbinding = new HashMap<>(); vbinding.put("Jalview", this); if (af != null) { @@ -1036,7 +1036,7 @@ public class Jalview + nickname + "|" + url); if (source == null) { - source = new Vector(); + source = new Vector<>(); } source.addElement(nickname); } @@ -1054,7 +1054,7 @@ public class Jalview System.out.println("adding source '" + data + "'"); if (source == null) { - source = new Vector(); + source = new Vector<>(); } source.addElement(data); } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 00446f2..82cba86 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -76,9 +76,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel private static final String ALPHACARBON = "CA"; - private List chainNames = new ArrayList(); + private List chainNames = new ArrayList<>(); - private Hashtable chainFile = new Hashtable(); + private Hashtable chainFile = new Hashtable<>(); /* * Object through which we talk to Chimera @@ -106,7 +106,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /* * Map of ChimeraModel objects keyed by PDB full local file name */ - private Map> chimeraMaps = new LinkedHashMap>(); + private Map> chimeraMaps = new LinkedHashMap<>(); String lastHighlightCommand; @@ -133,7 +133,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel String file = pe.getFile(); try { - List modelsToMap = new ArrayList(); + List modelsToMap = new ArrayList<>(); List oldList = viewer.getModelList(); boolean alreadyOpen = false; @@ -226,7 +226,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel // exit thread if Chimera Viewer is closed in Jalview } } - }); + }, "ChimeraMonitorThread"); chimeraMonitor.start(); } @@ -857,7 +857,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel protected List convertStructureResiduesToAlignment( List structureSelection) { - List atomSpecs = new ArrayList(); + List atomSpecs = new ArrayList<>(); for (String atomSpec : structureSelection) { try diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index c0d005f..e0bf9b2 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -90,7 +90,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected IProgressIndicator progressIndicator; - protected JComboBox cmb_searchTarget = new JComboBox(); + protected JComboBox cmb_searchTarget = new JComboBox<>(); protected JButton btn_ok = new JButton(); @@ -147,7 +147,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected int pageLimit; - protected HashSet paginatorCart = new HashSet(); + protected HashSet paginatorCart = new HashSet<>(); private static final int MIN_WIDTH = 670; @@ -267,7 +267,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI private void jbInit() throws Exception { - txt_search = new JvCacheableInputBox(getCacheKey()); + txt_search = new JvCacheableInputBox<>(getCacheKey()); populateCmbSearchTargetOptions(); Integer width = getTempUserPrefs().get("FTSPanel.width") == null ? 800 : getTempUserPrefs().get("FTSPanel.width"); @@ -797,7 +797,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI */ public void populateCmbSearchTargetOptions() { - List searchableTargets = new ArrayList(); + List searchableTargets = new ArrayList<>(); try { Collection foundFTSTargets = getFTSRestClient() @@ -826,7 +826,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI public void transferToSequenceFetcher(String ids) { seqFetcher.getTextArea().setText(ids); - Thread worker = new Thread(seqFetcher); + Thread worker = new Thread(seqFetcher, "GFTSSeqFetcherThread"); worker.start(); } diff --git a/src/jalview/fts/service/pdb/PDBFTSPanel.java b/src/jalview/fts/service/pdb/PDBFTSPanel.java index 19f7db4..753cc2e 100644 --- a/src/jalview/fts/service/pdb/PDBFTSPanel.java +++ b/src/jalview/fts/service/pdb/PDBFTSPanel.java @@ -39,7 +39,7 @@ public class PDBFTSPanel extends GFTSPanel private static String defaultFTSFrameTitle = MessageManager .getString("label.pdb_sequence_fetcher"); - private static Map tempUserPrefs = new HashMap(); + private static Map tempUserPrefs = new HashMap<>(); private static final String PDB_FTS_CACHE_KEY = "CACHE.PDB_FTS"; @@ -188,7 +188,7 @@ public class PDBFTSPanel extends GFTSPanel // mainFrame.dispose(); disableActionButtons(); StringBuilder selectedIds = new StringBuilder(); - HashSet selectedIdsSet = new HashSet(); + HashSet selectedIdsSet = new HashSet<>(); int primaryKeyColIndex = 0; try { @@ -220,7 +220,7 @@ public class PDBFTSPanel extends GFTSPanel String ids = selectedIds.toString(); // System.out.println(">>>>>>>>>>>>>>>> selected Ids: " + ids); seqFetcher.getTextArea().setText(ids); - Thread worker = new Thread(seqFetcher); + Thread worker = new Thread(seqFetcher, "PDBFTSSeqFetcherThread"); worker.start(); delayAndEnableActionButtons(); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 2ac6b19..fe0d220 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4154,7 +4154,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } buildingMenu = false; } - }).start(); + }, "BuildWebServiceThread").start(); } @@ -4262,7 +4262,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, protected void showProductsFor(final SequenceI[] sel, final boolean _odna, final String source) { - new Thread(CrossRefAction.showProductsFor(sel, _odna, source, this)) + new Thread(CrossRefAction.showProductsFor(sel, _odna, source, this), + "CrossReferencesThread") .start(); } @@ -4541,7 +4542,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, ex.printStackTrace(); } } - }).start(); + }, "DropFileThread").start(); } } @@ -4912,7 +4913,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, }); dbRefFetcher.fetchDBRefs(false); } - }).start(); + }, "BuildFetchDBMenuThread").start(); } diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index fef7451..d5eb2ae 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -218,7 +218,7 @@ public class AppJmol extends StructureViewerBase setSize(400, 400); // probably should be a configurable/dynamic default here initMenus(); addingStructures = false; - worker = new Thread(this); + worker = new Thread(this, "OpenJmolThread"); worker.start(); this.addInternalFrameListener(new InternalFrameAdapter() diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 89de2e8..48565eb 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -272,7 +272,7 @@ public class ChimeraViewFrame extends StructureViewerBase initMenus(); addingStructures = false; - worker = new Thread(this); + worker = new Thread(this, "OpenChimeraThread"); worker.start(); this.addInternalFrameListener(new InternalFrameAdapter() diff --git a/src/jalview/gui/Console.java b/src/jalview/gui/Console.java index 4c019a6..5fee61f 100644 --- a/src/jalview/gui/Console.java +++ b/src/jalview/gui/Console.java @@ -138,15 +138,15 @@ public class Console extends WindowAdapter // Starting two seperate threads to read from the PipedInputStreams // - reader = new Thread(this); + reader = new Thread(this, "ConsoleReader1Thread"); reader.setDaemon(true); reader.start(); // - reader2 = new Thread(this); + reader2 = new Thread(this, "ConsoleReader2Thread"); reader2.setDaemon(true); reader2.start(); // and a thread to append text to the textarea - textAppender = new Thread(this); + textAppender = new Thread(this, "ConsoleTextAppendThread"); textAppender.setDaemon(true); textAppender.start(); } @@ -255,7 +255,7 @@ public class Console extends WindowAdapter // We do it with a seperate Thread becasue we don't wan't to break a Thread // used by the Console. System.out.println("\nLets throw an error on this console"); - errorThrower = new Thread(this); + errorThrower = new Thread(this, "ConsoleErrorLogThread"); errorThrower.setDaemon(true); errorThrower.start(); } diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 8570ac3..a1b67e7 100644 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -38,7 +38,6 @@ import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.ListSelectionModel; @@ -125,7 +124,7 @@ public class DasSourceBrowser extends GDasSourceBrowser { if (sourceRegistry == null) { - Thread worker = new Thread(this); + Thread worker = new Thread(this, "PaintDasThread"); worker.start(); } } @@ -352,7 +351,7 @@ public class DasSourceBrowser extends GDasSourceBrowser } } - Vector selected = new Vector(); + Vector selected = new Vector<>(); for (String source : selectedSources) { jalviewSourceI srce = sourceRegistry.getSource(source); @@ -369,16 +368,16 @@ public class DasSourceBrowser extends GDasSourceBrowser { saveProperties(jalview.bin.Cache.applicationProperties); - Thread worker = new Thread(this); + Thread worker = new Thread(this, "RepaintDasThread"); worker.start(); } private void setCapabilities(DasSourceRegistryI sourceRegistry2) { - Vector authority = new Vector(); - Vector type = new Vector(); - Vector label = new Vector(); - Vector taxIds = new Vector(); + Vector authority = new Vector<>(); + Vector type = new Vector<>(); + Vector label = new Vector<>(); + Vector taxIds = new Vector<>(); authority.add("Any"); type.add("Any"); label.add("Any"); diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2d1ba12..f90752b 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -456,7 +456,7 @@ public class Desktop extends jalview.jbgui.GDesktop fileFormat); Cache.log.debug("Filechooser init thread finished."); } - }).start(); + }, "InitFileChooserThread").start(); // Add the service change listener changeSupport.addJalviewPropertyChangeListener("services", new PropertyChangeListener() @@ -575,7 +575,7 @@ public class Desktop extends jalview.jbgui.GDesktop Desktop.instance.setProgressBar(null, now); jvnews.showNews(); } - }).start(); + }, "ShowNewsWindowThread").start(); } } } @@ -1271,7 +1271,7 @@ public class Desktop extends jalview.jbgui.GDesktop { new SplashScreen(true); } - }).start(); + }, "ShowAboutMenuThread").start(); } public StringBuffer getAboutMessage(boolean shortv) @@ -1613,7 +1613,7 @@ public class Desktop extends jalview.jbgui.GDesktop } setProgressBar(null, choice.hashCode()); } - }).start(); + }, "SaveJalviewProjectThread").start(); } } @@ -1681,7 +1681,7 @@ public class Desktop extends jalview.jbgui.GDesktop } setProgressBar(null, choice.hashCode()); } - }).start(); + }, "LoadJalviewProjectThread").start(); } } @@ -2191,7 +2191,7 @@ public class Desktop extends jalview.jbgui.GDesktop dsktp.v_client.initial_update(); } - }); + }, "VamsasSessionThread"); rthr.start(); } }; @@ -2311,7 +2311,7 @@ public class Desktop extends jalview.jbgui.GDesktop { UserQuestionnaireCheck jvq = new UserQuestionnaireCheck(url); // javax.swing.SwingUtilities.invokeLater(jvq); - new Thread(jvq).start(); + new Thread(jvq, "CheckQuestionnaireThread").start(); } public void checkURLLinks() @@ -2424,7 +2424,7 @@ public class Desktop extends jalview.jbgui.GDesktop this.showMemoryUsage = showMemory; if (showMemory) { - Thread worker = new Thread(this); + Thread worker = new Thread(this, "ShowMemoryUsageThread"); worker.start(); } repaint(); @@ -2849,7 +2849,7 @@ public class Desktop extends jalview.jbgui.GDesktop } // JAL-940 - disabled JWS1 service configuration - always start discoverer // until we phase out completely - (t0 = new Thread(discoverer)).start(); + (t0 = new Thread(discoverer, "DiscovererThread")).start(); } if (Cache.getDefault("SHOW_JWS2_SERVICES", true)) @@ -3005,7 +3005,7 @@ public class Desktop extends jalview.jbgui.GDesktop progress.setProgressBar(null, this.hashCode()); } } - }).start(); + }, "OpenURLThread").start(); } public static WsParamSetManager wsparamManager = null; diff --git a/src/jalview/gui/JalviewDialog.java b/src/jalview/gui/JalviewDialog.java index 05f5ffc..a6f2d2a 100644 --- a/src/jalview/gui/JalviewDialog.java +++ b/src/jalview/gui/JalviewDialog.java @@ -66,7 +66,7 @@ public abstract class JalviewDialog extends JPanel frame.setVisible(true); } - }).start(); + }, "UnblockedDialogThread").start(); } else { diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 9ddb751..a39944d 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -304,7 +304,7 @@ public class OverviewPanel extends JPanel return; } - Thread thread = new Thread(this); + Thread thread = new Thread(this, "UpdateOverviewThread"); thread.start(); repaint(); diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 31c20ed..aa07b7c 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -352,7 +352,7 @@ public abstract class StructureViewerBase extends GStructureViewer // and call ourselves again. addStructure(pdbentry, seqs, chains, align, alignFrame); } - }).start(); + }, "Adding3DStructureQueueThread").start(); return; } } @@ -363,7 +363,7 @@ public abstract class StructureViewerBase extends GStructureViewer addingStructures = true; _started = false; alignAddedStructures = align; - worker = new Thread(this); + worker = new Thread(this, "Adding3DStructureThread"); worker.start(); return; } diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 7dc1a99..6780921 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -542,7 +542,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, */ void startPrinting() { - Thread thread = new Thread(this); + Thread thread = new Thread(this, "PrintTreeCanvasThread"); thread.start(); } @@ -981,7 +981,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Vector l = tree.findLeaves(groups.get(i)); - Vector sequences = new Vector(); + Vector sequences = new Vector<>(); for (int j = 0; j < l.size(); j++) { diff --git a/src/jalview/gui/VamsasApplication.java b/src/jalview/gui/VamsasApplication.java index d2086e0..f855474 100644 --- a/src/jalview/gui/VamsasApplication.java +++ b/src/jalview/gui/VamsasApplication.java @@ -326,7 +326,7 @@ public class VamsasApplication implements SelectionSource, VamsasSource Cache.log.info("Jalview finished updating to the Vamsas Session."); } - }); + }, "UpdateVamsasThread"); udthread.start(); } diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 2fc08e1..be812b5 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; @@ -345,12 +344,13 @@ public class WebserviceInfo extends GWebserviceInfo AnimatedPanel ap = new AnimatedPanel(); titlePanel.add(ap, BorderLayout.CENTER); - Thread thread = new Thread(ap); + Thread thread = new Thread(ap, "AnimatedPanelThread"); thread.start(); final WebserviceInfo thisinfo = this; 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/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java index 850ef21..dc3cadd 100644 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@ -37,7 +37,6 @@ import java.util.List; import java.util.Vector; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTextField; @@ -68,12 +67,12 @@ public class WsPreferences extends GWsPreferences wsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls(); if (!wsUrls.isEmpty()) { - oldUrls = new Vector(wsUrls); + oldUrls = new Vector<>(wsUrls); } else { oldUrls = null; - wsUrls = new Vector(); + wsUrls = new Vector<>(); } wsList.setDefaultRenderer(Integer.class, new JabaWSStatusRenderer()); wsList.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); @@ -81,12 +80,12 @@ public class WsPreferences extends GWsPreferences rsbsUrls = jalview.ws.rest.RestClient.getRsbsDescriptions(); if (rsbsUrls != null) { - oldRsbsUrls = new Vector(rsbsUrls); + oldRsbsUrls = new Vector<>(rsbsUrls); } else { oldRsbsUrls = null; - rsbsUrls = new Vector(); + rsbsUrls = new Vector<>(); } updateRsbsList(); enableEnfinServices.setSelected( @@ -568,7 +567,7 @@ public class WsPreferences extends GWsPreferences updateWsMenuConfig(false); refreshWsMenu(true); } - }).start(); + }, "RefreshWebServicesThread").start(); } @@ -604,7 +603,7 @@ public class WsPreferences extends GWsPreferences progressBar.setVisible(false); validate(); } - }).start(); + }, "RefreshWebServicesMenuProgressBarThread").start(); } else @@ -627,7 +626,7 @@ public class WsPreferences extends GWsPreferences Desktop.instance.setProgressBar(null, ct); } - }).start(); + }, "RefreshWebServicesMenuThread").start(); } } @@ -676,7 +675,7 @@ public class WsPreferences extends GWsPreferences updateWsMenuConfig(false); refreshWsMenu(showProgressInDialog); } - }).start(); + }, "UpdateAndRefreshWebServicesMenuThread").start(); } } diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 52ce845..045fc7e 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -84,7 +84,7 @@ public class BioJsHTMLOutput extends HTMLOutput e.printStackTrace(); return; } - new Thread(this).start(); + new Thread(this, "ExportBioJsHTMLThread").start(); } @@ -94,7 +94,7 @@ public class BioJsHTMLOutput extends HTMLOutput File directory = new File(BJS_TEMPLATES_LOCAL_DIRECTORY); Objects.requireNonNull(dirName, "dirName MUST not be null!"); Objects.requireNonNull(directory, "directory MUST not be null!"); - TreeMap versionFileMap = new TreeMap(); + TreeMap versionFileMap = new TreeMap<>(); for (File file : directory.listFiles()) { diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 26641b1..50bcbe1 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -104,7 +104,7 @@ public class FileLoader implements Runnable this.protocol = protocol; this.format = format; - final Thread loader = new Thread(this); + final Thread loader = new Thread(this, "LoadFileThread"); SwingUtilities.invokeLater(new Runnable() { @@ -183,7 +183,7 @@ public class FileLoader implements Runnable */ protected AlignFrame _LoadFileWaitTillLoaded() { - Thread loader = new Thread(this); + Thread loader = new Thread(this, "LoadFileWithWaitingThread"); loader.start(); while (loader.isAlive()) diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 948578a..87be23e 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -67,7 +67,7 @@ public class HtmlSvgOutput extends HTMLOutput e.printStackTrace(); return; } - new Thread(this).start(); + new Thread(this, "ExportSvgHTMLThread").start(); } public int printUnwrapped(int pwidth, int pheight, int pi, diff --git a/src/jalview/javascript/JSFunctionExec.java b/src/jalview/javascript/JSFunctionExec.java index 083cd26..c516a9f 100644 --- a/src/jalview/javascript/JSFunctionExec.java +++ b/src/jalview/javascript/JSFunctionExec.java @@ -261,7 +261,8 @@ public class JSFunctionExec implements Runnable { if (executor == null) { - executor = new Thread(new JSFunctionExec(jvlite)); + executor = new Thread(new JSFunctionExec(jvlite), + "JavaScriptThread"); executor.start(); } synchronized (jsExecQueue) diff --git a/src/jalview/util/AWTConsole.java b/src/jalview/util/AWTConsole.java index 6698414..be03591 100644 --- a/src/jalview/util/AWTConsole.java +++ b/src/jalview/util/AWTConsole.java @@ -72,10 +72,10 @@ public class AWTConsole extends WindowAdapter // create all components and add them frame = new Frame("Java Console"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension frameSize = new Dimension((int) (screenSize.width / 2), - (int) (screenSize.height / 2)); - int x = (int) (frameSize.width / 2); - int y = (int) (frameSize.height / 2); + Dimension frameSize = new Dimension(screenSize.width / 2, + screenSize.height / 2); + int x = frameSize.width / 2; + int y = frameSize.height / 2; frame.setBounds(x, y, frameSize.width, frameSize.height); textArea = new TextArea(); @@ -125,11 +125,11 @@ public class AWTConsole extends WindowAdapter // Starting two seperate threads to read from the PipedInputStreams // - reader = new Thread(this); + reader = new Thread(this, "AWTConsoleReader1Thread"); reader.setDaemon(true); reader.start(); // - reader2 = new Thread(this); + reader2 = new Thread(this, "AWTConsoleReader2Thread"); reader2.setDaemon(true); reader2.start(); @@ -142,17 +142,20 @@ public class AWTConsole extends WindowAdapter .getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); for (int n = 0; n < fontNames.length; n++) + { System.out.println(fontNames[n]); + } // Testing part: simple an error thrown anywhere in this JVM will be printed // on the Console // We do it with a seperate Thread becasue we don't wan't to break a Thread // used by the Console. System.out.println("\nLets throw an error on this console"); - errorThrower = new Thread(this); + errorThrower = new Thread(this, "AWTConsoleErrorLogThread"); errorThrower.setDaemon(true); errorThrower.start(); } + @Override public synchronized void windowClosed(WindowEvent evt) { quit = true; @@ -174,17 +177,20 @@ public class AWTConsole extends WindowAdapter System.exit(0); } + @Override public synchronized void windowClosing(WindowEvent evt) { frame.setVisible(false); // default behaviour of JFrame frame.dispose(); } + @Override public synchronized void actionPerformed(ActionEvent evt) { textArea.setText(""); } + @Override public synchronized void run() { try @@ -203,7 +209,9 @@ public class AWTConsole extends WindowAdapter textArea.append(input); } if (quit) + { return; + } } while (Thread.currentThread() == reader2) @@ -220,7 +228,9 @@ public class AWTConsole extends WindowAdapter textArea.append(input); } if (quit) + { return; + } } } catch (Exception e) { @@ -251,7 +261,9 @@ public class AWTConsole extends WindowAdapter { int available = in.available(); if (available == 0) + { break; + } byte b[] = new byte[available]; in.read(b); input = input + new String(b, 0, b.length); diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index fb8864d..2b7c6df 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -117,7 +117,7 @@ public class DBRefFetcher implements Runnable DbSourceProxy[] sources, FeatureSettings featureSettings, boolean isNucleotide) { - listeners = new ArrayList(); + listeners = new ArrayList<>(); this.progressWindow = progressIndicatorFrame; alseqs = new SequenceI[seqs.length]; SequenceI[] ds = new SequenceI[seqs.length]; @@ -163,7 +163,7 @@ public class DBRefFetcher implements Runnable { // af.featureSettings_actionPerformed(null); String[] defdb = null; - List selsources = new ArrayList(); + List selsources = new ArrayList<>(); Vector dasselsrc = (featureSettings != null) ? featureSettings.getSelectedSources() : new DasSourceBrowser().getSelectedSources(); @@ -189,7 +189,7 @@ public class DBRefFetcher implements Runnable { defdb = DBRefSource.PROTEINDBS; } - List srces = new ArrayList(); + List srces = new ArrayList<>(); for (String ddb : defdb) { List srcesfordb = sfetcher.getSourceProxy(ddb); @@ -267,7 +267,7 @@ public class DBRefFetcher implements Runnable // TODO can we not simply write // if (waitTillFinished) { run(); } else { new Thread(this).start(); } - Thread thread = new Thread(this); + Thread thread = new Thread(this, "FetchDBRefThread"); thread.start(); running = true; @@ -309,14 +309,14 @@ public class DBRefFetcher implements Runnable } else if (seqs == null) { - seqs = new Vector(); + seqs = new Vector<>(); seqs.addElement(seq); } } else { - seqs = new Vector(); + seqs = new Vector<>(); seqs.addElement(seq); } @@ -355,9 +355,9 @@ public class DBRefFetcher implements Runnable e.printStackTrace(); } - Vector sdataset = new Vector( + Vector sdataset = new Vector<>( Arrays.asList(dataset)); - List warningMessages = new ArrayList(); + List warningMessages = new ArrayList<>(); int db = 0; while (sdataset.size() > 0 && db < dbSources.length) @@ -369,8 +369,8 @@ public class DBRefFetcher implements Runnable SequenceI[] currSeqs = new SequenceI[sdataset.size()]; sdataset.copyInto(currSeqs);// seqs that are to be validated against // dbSources[db] - Vector queries = new Vector(); // generated queries curSeq - seqRefs = new Hashtable>(); + Vector queries = new Vector<>(); // generated queries curSeq + seqRefs = new Hashtable<>(); int seqIndex = 0; @@ -572,7 +572,7 @@ public class DBRefFetcher implements Runnable { // Work out which sequences this sequence matches, // taking into account all accessionIds and names in the file - Vector sequenceMatches = new Vector(); + Vector sequenceMatches = new Vector<>(); // look for corresponding accession ids DBRefEntry[] entryRefs = DBRefUtils .selectRefs(retrievedSeq.getDBRefs(), new String[] @@ -824,7 +824,7 @@ public class DBRefFetcher implements Runnable */ private SequenceI[] recoverDbSequences(SequenceI[] sequencesArray) { - Vector nseq = new Vector(); + Vector nseq = new Vector<>(); for (int i = 0; sequencesArray != null && i < sequencesArray.length; i++) { diff --git a/src/jalview/ws/DasSequenceFeatureFetcher.java b/src/jalview/ws/DasSequenceFeatureFetcher.java index c661e2c..06d176e 100644 --- a/src/jalview/ws/DasSequenceFeatureFetcher.java +++ b/src/jalview/ws/DasSequenceFeatureFetcher.java @@ -212,7 +212,8 @@ public class DasSequenceFeatureFetcher if (reply == JvOptionPane.YES_OPTION) { - Thread thread = new Thread(new FetchDBRefs()); + Thread thread = new Thread(new FetchDBRefs(), + "FetchDBReferenceManagerThread"); thread.start(); } else @@ -230,7 +231,7 @@ public class DasSequenceFeatureFetcher private void _startFetching() { running = true; - new Thread(new FetchSeqFeatures()).start(); + new Thread(new FetchSeqFeatures(), "FetchSeqFeaturesThread").start(); } class FetchSeqFeatures implements Runnable diff --git a/src/jalview/ws/jws1/Discoverer.java b/src/jalview/ws/jws1/Discoverer.java index ea883c8..51e7b1a 100644 --- a/src/jalview/ws/jws1/Discoverer.java +++ b/src/jalview/ws/jws1/Discoverer.java @@ -379,7 +379,7 @@ public class Discoverer implements Runnable public void run() { final Discoverer discoverer = this; - Thread discoverThread = new Thread() + Thread discoverThread = new Thread() // no function? { @Override public void run() diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index 5319eab..fe303f8 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -178,7 +178,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI running = true; // first set up exclusion list if needed - final Set ignoredServices = new HashSet(); + final Set ignoredServices = new HashSet<>(); for (String ignored : Cache .getDefault("IGNORED_JABAWS_SERVICETYPES", "").split("\\|")) { @@ -217,9 +217,9 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { validServiceUrls.removeAllElements(); } - ArrayList svctypes = new ArrayList(); + ArrayList svctypes = new ArrayList<>(); - List qrys = new ArrayList(); + List qrys = new ArrayList<>(); for (final String jwsserver : getServiceUrls()) { JabaWsServerQuery squery = new JabaWsServerQuery(this, jwsserver); @@ -237,7 +237,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } qrys.add(squery); - new Thread(squery).start(); + new Thread(squery, "JabaQueryThread").start(); } boolean finished = true; do @@ -285,7 +285,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI + svctypes.indexOf(svc.serviceType); } jalview.util.QuickSort.sort(spos, svcs); - services = new Vector(); + services = new Vector<>(); for (Jws2Instance svc : svcs) { if (!ignoredServices.contains(svc.serviceType)) @@ -312,7 +312,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (services == null) { - services = new Vector(); + services = new Vector<>(); } System.out.println( "Discovered service: " + jwsservers + " " + service.toString()); @@ -329,7 +329,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI service.hasParameters(); if (validServiceUrls == null) { - validServiceUrls = new Vector(); + validServiceUrls = new Vector<>(); } validServiceUrls.add(jwsservers); } @@ -363,10 +363,10 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI * for moment we keep them separate. */ JMenu atpoint; - List enumerableServices = new ArrayList(); + List enumerableServices = new ArrayList<>(); // jws2al.removeAll(); - Map preferredHosts = new HashMap(); - Map> alternates = new HashMap>(); + Map preferredHosts = new HashMap<>(); + Map> alternates = new HashMap<>(); for (Jws2Instance service : services.toArray(new Jws2Instance[0])) { if (!isRecalculable(service.action)) @@ -395,7 +395,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (ph == null) { - ph = new ArrayList(); + ph = new ArrayList<>(); } ph.add(service); alternates.put(service.serviceType, ph); @@ -458,7 +458,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI changeSupport.firePropertyChange("services", new Vector(), services); }; - }).start(); + }, "LoadPreferredServiceThread").start(); } }); @@ -483,17 +483,17 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ JMenu atpoint; - List hostLabels = new ArrayList(); - Hashtable lasthostFor = new Hashtable(); - Hashtable> hosts = new Hashtable>(); - ArrayList hostlist = new ArrayList(); + List hostLabels = new ArrayList<>(); + Hashtable lasthostFor = new Hashtable<>(); + Hashtable> hosts = new Hashtable<>(); + ArrayList hostlist = new ArrayList<>(); for (Jws2Instance service : enumerableServices) { ArrayList hostservices = hosts.get(service.getHost()); if (hostservices == null) { hosts.put(service.getHost(), - hostservices = new ArrayList()); + hostservices = new ArrayList<>()); hostlist.add(service.getHost()); } hostservices.add(service); @@ -581,7 +581,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (args.length > 0) { - testUrls = new ArrayList(); + testUrls = new ArrayList<>(); for (String url : args) { testUrls.add(url); @@ -685,7 +685,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI // return test urls, if there are any, instead of touching cache return testUrls; } - List urls = new ArrayList(); + List urls = new ArrayList<>(); if (this.preferredUrl != null) { @@ -734,7 +734,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI public Vector getServices() { return (services == null) ? new Vector() - : new Vector(services); + : new Vector<>(services); } /** @@ -839,7 +839,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (urlsWithoutServices == null) { - urlsWithoutServices = new Vector(); + urlsWithoutServices = new Vector<>(); } if ((invalidServiceUrls == null @@ -859,7 +859,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (invalidServiceUrls == null) { - invalidServiceUrls = new Vector(); + invalidServiceUrls = new Vector<>(); } if (!invalidServiceUrls.contains(jwsservers)) { @@ -947,7 +947,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ public Jws2Instance getPreferredServiceFor(String[] serviceURLs) { - HashSet urls = new HashSet(); + HashSet urls = new HashSet<>(); urls.addAll(Arrays.asList(serviceURLs)); Jws2Instance match = null; if (services != null) @@ -974,7 +974,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI return match; } - Map> preferredServiceMap = new HashMap>();; + Map> preferredServiceMap = new HashMap<>();; /** * get current preferred service of the given type, or global default @@ -1026,12 +1026,12 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI String afid = (af == null) ? "" : af.getViewport().getSequenceSetId(); if (preferredServiceMap == null) { - preferredServiceMap = new HashMap>(); + preferredServiceMap = new HashMap<>(); } Map prefmap = preferredServiceMap.get(afid); if (prefmap == null) { - prefmap = new HashMap(); + prefmap = new HashMap<>(); preferredServiceMap.put(afid, prefmap); } prefmap.put(serviceType, selectedServer.getHost()); -- 1.7.10.2