From bba1381449408269047715a41a43115621d1045a Mon Sep 17 00:00:00 2001 From: BobHanson Date: Sat, 6 Jun 2020 17:37:22 -0500 Subject: [PATCH] JAL-3446 no actual changes; just using meaningful frame options --- src/jalview/gui/AlignFrame.java | 4 +- src/jalview/gui/AnnotationChooser.java | 4 +- src/jalview/gui/AnnotationExporter.java | 4 +- src/jalview/gui/CalculationChooser.java | 2 +- src/jalview/gui/Desktop.java | 161 ++++++++++++++++++------------- src/jalview/gui/FeatureSettings.java | 4 +- src/jalview/gui/Finder.java | 4 +- src/jalview/gui/FontChooser.java | 8 +- src/jalview/gui/RedundancyPanel.java | 4 +- src/jalview/gui/SequenceFetcher.java | 4 +- src/jalview/gui/SliderPanel.java | 8 +- src/jalview/gui/UserDefinedColours.java | 4 +- src/jalview/gui/WebserviceInfo.java | 3 +- src/jalview/ws/jws1/JPredClient.java | 2 +- src/jalview/ws/jws1/WS1Client.java | 5 +- src/jalview/ws/jws2/Jws2Client.java | 4 +- src/jalview/ws/rest/RestClient.java | 2 +- 17 files changed, 128 insertions(+), 99 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 1850984..4e50439 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3375,8 +3375,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, "resize") != "none"); Desktop.addInternalFrame(frame, MessageManager .formatMessage("label.overview_params", new Object[] - { this.getTitle() }), true, dim.width, dim.height, resizable, - true); + { this.getTitle() }), Desktop.FRAME_MAKE_VISIBLE, dim.width, dim.height, resizable, + Desktop.FRAME_ALLOW_ANY_SIZE); frame.pack(); frame.setLayer(JLayeredPane.PALETTE_LAYER); frame.addInternalFrameListener( diff --git a/src/jalview/gui/AnnotationChooser.java b/src/jalview/gui/AnnotationChooser.java index 791421d..233f280 100644 --- a/src/jalview/gui/AnnotationChooser.java +++ b/src/jalview/gui/AnnotationChooser.java @@ -605,8 +605,8 @@ public class AnnotationChooser extends JPanel frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, - MessageManager.getString("label.choose_annotations"), - MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true); + MessageManager.getString("label.choose_annotations"), Desktop.FRAME_MAKE_VISIBLE, + MY_FRAME_WIDTH, MY_FRAME_HEIGHT, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300); } protected void setShowSelected(boolean showSelected) diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index d84287f..541c63a 100644 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -109,8 +109,8 @@ public class AnnotationExporter extends JPanel frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); Dimension preferredSize = frame.getPreferredSize(); - Desktop.addInternalFrame(frame, "", true, preferredSize.width, - preferredSize.height, true, true); + Desktop.addInternalFrame(frame, "", Desktop.FRAME_MAKE_VISIBLE, preferredSize.width, + preferredSize.height, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_ALLOW_ANY_SIZE); } /** diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index 5248306..c69d0a8 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -319,7 +319,7 @@ public class CalculationChooser extends JPanel title = title + " (" + af.getViewport().getViewName() + ")"; } - Desktop.addInternalFrame(frame, title, width, height, false); + Desktop.addInternalFrame(frame, title, Desktop.FRAME_MAKE_VISIBLE, width, height, Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_SET_MIN_SIZE_300); calcChoicePanel.doLayout(); revalidate(); /* diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index d11813d..7115e18 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -482,7 +482,6 @@ public class Desktop extends GDesktop experimentalFeatures.setSelected(showExperimental()); - checkURLLinks(); // Spawn a thread that shows the splashscreen @@ -659,8 +658,8 @@ public class Desktop extends GDesktop public void run() { long now = System.currentTimeMillis(); - setProgressBar( - MessageManager.getString("status.refreshing_news"), now); + setProgressBar(MessageManager.getString("status.refreshing_news"), + now); jvnews.refreshNews(); setProgressBar(null, now); jvnews.showNews(); @@ -768,48 +767,60 @@ public class Desktop extends GDesktop } } - /** - * Adds and opens the given frame to the desktop - * - * @param frame - * Frame to show - * @param title - * Visible Title - * @param w - * width - * @param h - * height - */ - public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, int w, int h) - { - addInternalFrame(frame, title, true, w, h, true, false); - } - - /** - * Add an internal frame to the Jalview desktop - * - * @param frame - * Frame to show - * @param title - * Visible Title - * @param makeVisible - * When true, display frame immediately, otherwise, caller must call - * setVisible themselves. - * @param w - * width - * @param h - * height - */ - public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, boolean makeVisible, - int w, int h) - { - addInternalFrame(frame, title, makeVisible, w, h, true, false); - } +// /** +// * Add an internal frame to the Jalview desktop that is allowed to be resized, +// * has a minimum size of 300px and might or might not be visible +// * +// * @param frame +// * Frame to show +// * @param title +// * Visible Title +// * @param makeVisible +// * When true, display frame immediately, otherwise, caller must call +// * setVisible themselves. +// * @param w +// * width +// * @param h +// * height +// */ +// @Deprecated +// public static synchronized void addInternalFrame( +// final JInternalFrame frame, String title, boolean makeVisible, +// int w, int h) +// { +// // textbox, web services, sequenceFetcher, featureSettings +// getInstance().addFrame(frame, title, makeVisible, w, h, +// FRAME_ALLOW_RESIZE, FRAME_SET_MIN_SIZE_300); +// } +// +// /** +// * Add an internal frame to the Jalview desktop that is visible, has a minimum +// * size of 300px, and may or may not be resizable +// * +// * @param frame +// * Frame to show +// * @param title +// * Visible Title +// * @param w +// * width +// * @param h +// * height +// * @param resizable +// * Allow resize +// */ +// @Deprecated +// public static synchronized void addInternalFrame( +// final JInternalFrame frame, String title, int w, int h, +// boolean resizable) +// { +// // annotation, font, calculation, user-defined colors +// getInstance().addFrame(frame, title, FRAME_MAKE_VISIBLE, w, h, +// resizable, FRAME_SET_MIN_SIZE_300); +// } /** - * Add an internal frame to the Jalview desktop and make it visible + * Adds and opens the given frame to the desktop that is visible, allowed to + * resize, and has a 300px minimum width. * * @param frame * Frame to show @@ -819,18 +830,18 @@ public class Desktop extends GDesktop * width * @param h * height - * @param resizable - * Allow resize */ public static synchronized void addInternalFrame( - final JInternalFrame frame, String title, int w, int h, - boolean resizable) + final JInternalFrame frame, String title, int w, int h) { - addInternalFrame(frame, title, true, w, h, resizable, false); + // 58 classes + getInstance().addFrame(frame, title, Desktop.FRAME_MAKE_VISIBLE, w, h, + FRAME_ALLOW_RESIZE, FRAME_SET_MIN_SIZE_300); } /** - * Add an internal frame to the Jalview desktop + * Add an internal frame to the Jalview desktop that may optionally be + * visible, resizable, and allowed to be any size * * @param frame * Frame to show @@ -852,21 +863,36 @@ public class Desktop extends GDesktop final JInternalFrame frame, String title, boolean makeVisible, int w, int h, boolean resizable, boolean ignoreMinSize) { - - getInstance().addFrame(frame, title, makeVisible, w, h, resizable, ignoreMinSize); + // 15 classes + getInstance().addFrame(frame, title, makeVisible, w, h, resizable, + ignoreMinSize); } + + // These can now by put into a single int flag, if desired: - private void addFrame(JInternalFrame frame, String title, + public final static boolean FRAME_MAKE_VISIBLE = true; + + public final static boolean FRAME_NOT_VISIBLE = false; + + public final static boolean FRAME_ALLOW_RESIZE = true; + + public final static boolean FRAME_NOT_RESIZABLE = false; + + public final static boolean FRAME_ALLOW_ANY_SIZE = true; + + public final static boolean FRAME_SET_MIN_SIZE_300 = false; + + private void addFrame(JInternalFrame frame, String title, boolean makeVisible, int w, int h, boolean resizable, boolean ignoreMinSize) { - // TODO: allow callers to determine X and Y position of frame (eg. via - // bounds object). - // TODO: consider fixing method to update entries in the window submenu with - // the current window title + // TODO: allow callers to determine X and Y position of frame (eg. via + // bounds object). + // TODO: consider fixing method to update entries in the window submenu with + // the current window title - frame.setTitle(title); - if (frame.getWidth() < 1 || frame.getHeight() < 1) + frame.setTitle(title); + if (frame.getWidth() < 1 || frame.getHeight() < 1) { frame.setSize(w, h); } @@ -921,7 +947,7 @@ public class Desktop extends GDesktop public void internalFrameActivated(InternalFrameEvent evt) { JInternalFrame itf = getDesktopPane().getSelectedFrame(); - if (itf != null) + if (itf != null) { if (itf instanceof AlignFrame) { @@ -1311,8 +1337,9 @@ public class Desktop extends GDesktop CutAndPasteTransfer cap = new CutAndPasteTransfer(); cap.setForInput(viewPanel); addInternalFrame(cap, - MessageManager.getString("label.cut_paste_alignmen_file"), true, - 600, 500); + MessageManager.getString("label.cut_paste_alignmen_file"), + FRAME_MAKE_VISIBLE, 600, 500, FRAME_ALLOW_RESIZE, + FRAME_SET_MIN_SIZE_300); } /* @@ -1808,7 +1835,7 @@ public class Desktop extends GDesktop { Cache.log.error( "Problems whilst loading project from " + choice, ex); - JvOptionPane.showMessageDialog( getDesktopPane(), + JvOptionPane.showMessageDialog(getDesktopPane(), MessageManager.formatMessage( "label.error_whilst_loading_project_from", new Object[] @@ -1961,7 +1988,7 @@ public class Desktop extends GDesktop public static AlignmentViewport[] getViewports(String sequenceSetId) { List viewp = new ArrayList<>(); - if ( getDesktopPane() != null) + if (getDesktopPane() != null) { AlignFrame[] frames = getAlignFrames(); @@ -2328,7 +2355,7 @@ public class Desktop extends GDesktop return new AlignFrame[] { Jalview.getInstance().currentAlignFrame }; } - JInternalFrame[] frames = getDesktopPane().getAllFrames(); + JInternalFrame[] frames = getDesktopPane().getAllFrames(); if (frames == null) { @@ -2610,7 +2637,7 @@ public class Desktop extends GDesktop */ public static AlignFrame getAlignFrameFor(AlignViewportI viewport) { - if ( getDesktopPane() != null) + if (getDesktopPane() != null) { AlignmentPanel[] aps = getAlignmentPanels( viewport.getSequenceSetId()); @@ -2821,7 +2848,7 @@ public class Desktop extends GDesktop jalview.util.BrowserLauncher.openURL(url); } catch (Exception ex) { - JvOptionPane.showInternalMessageDialog( getDesktopPane(), + JvOptionPane.showInternalMessageDialog(getDesktopPane(), MessageManager .getString("label.web_browser_not_found_unix"), MessageManager.getString("label.web_browser_not_found"), @@ -2924,7 +2951,7 @@ public class Desktop extends GDesktop { return; } - try + try { SwingUtilities.invokeAndWait(prompter); } catch (Exception q) diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index b49593a..8c4b355 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -436,8 +436,8 @@ public class FeatureSettings extends JPanel } else { - Desktop.addInternalFrame(frame, title, false, bounds.width, - bounds.height); + Desktop.addInternalFrame(frame, title, Desktop.FRAME_NOT_VISIBLE, bounds.width, + bounds.height, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300); frame.setBounds(bounds); frame.setVisible(true); } diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 2a6adda..01c8a16 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -121,8 +121,8 @@ public class Finder extends GFinder } }); addEscapeHandler(); - Desktop.addInternalFrame(frame, MessageManager.getString("label.find"), - true, MY_WIDTH, MY_HEIGHT, true, true); + Desktop.addInternalFrame(frame, MessageManager.getString("label.find"), + Desktop.FRAME_MAKE_VISIBLE, MY_WIDTH, MY_HEIGHT, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_ALLOW_ANY_SIZE); searchBox.getComponent().requestFocus(); } diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 92cc4c6..2d9682b 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -137,14 +137,14 @@ public class FontChooser extends GFontChooser if (isTreeFont()) { Desktop.addInternalFrame(frame, - MessageManager.getString("action.change_font_tree_panel"), - 400, 200, false); + MessageManager.getString("action.change_font_tree_panel"), Desktop.FRAME_MAKE_VISIBLE, + 400, 200, Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_SET_MIN_SIZE_300); } else { Desktop.addInternalFrame(frame, - MessageManager.getString("action.change_font"), 380, 220, - false); + MessageManager.getString("action.change_font"), Desktop.FRAME_MAKE_VISIBLE, 380, 220, + Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_SET_MIN_SIZE_300); } frame.setLayer(JLayeredPane.PALETTE_LAYER); diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index 6ed3248..1725a8a 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -103,8 +103,8 @@ public class RedundancyPanel extends GSliderPanel implements Runnable frame.setContentPane(this); Desktop.addInternalFrame(frame, MessageManager - .getString("label.redundancy_threshold_selection"), - true, FRAME_WIDTH, FRAME_HEIGHT, false, true); + .getString("label.redundancy_threshold_selection"), Desktop.FRAME_MAKE_VISIBLE, + FRAME_WIDTH, FRAME_HEIGHT, Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_ALLOW_ANY_SIZE); frame.addInternalFrameListener(new InternalFrameAdapter() { @Override diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 7c83259..3d09f99 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -145,8 +145,8 @@ public class SequenceFetcher extends JPanel implements Runnable frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, getFrameTitle(), true, 400, - Platform.isAMacAndNotJS() ? 240 : 180); + Desktop.addInternalFrame(frame, getFrameTitle(), Desktop.FRAME_MAKE_VISIBLE, 400, + Platform.isAMacAndNotJS() ? 240 : 180, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300); } private String getFrameTitle() diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index 46b47a2..7effb0f 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -231,8 +231,8 @@ public class SliderPanel extends GSliderPanel if (!conservationSlider.isVisible()) { Desktop.addInternalFrame(conservationSlider, - conservationSlider.getTitle(), true, FRAME_WIDTH, - FRAME_HEIGHT, false, true); + conservationSlider.getTitle(), Desktop.FRAME_MAKE_VISIBLE, FRAME_WIDTH, + FRAME_HEIGHT, Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_ALLOW_ANY_SIZE); conservationSlider.addInternalFrameListener(new InternalFrameAdapter() { @Override @@ -307,8 +307,8 @@ public class SliderPanel extends GSliderPanel if (!PIDSlider.isVisible()) { - Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), true, - FRAME_WIDTH, FRAME_HEIGHT, false, true); + Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), Desktop.FRAME_MAKE_VISIBLE, + FRAME_WIDTH, FRAME_HEIGHT, Desktop.FRAME_NOT_RESIZABLE, Desktop.FRAME_ALLOW_ANY_SIZE); PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); PIDSlider.addInternalFrameListener(new InternalFrameAdapter() { diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 2f18f43..1139ae0 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -149,8 +149,8 @@ public class UserDefinedColours extends GUserDefinedColours frame = new JInternalFrame(); frame.setContentPane(this); Desktop.addInternalFrame(frame, - MessageManager.getString("label.user_defined_colours"), - MY_FRAME_WIDTH, MY_FRAME_HEIGHT, true); + MessageManager.getString("label.user_defined_colours"), Desktop.FRAME_MAKE_VISIBLE, + MY_FRAME_WIDTH, MY_FRAME_HEIGHT, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300); } /** diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 101acbe..ab9444e 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -259,6 +259,7 @@ public class WebserviceInfo extends GWebserviceInfo public WebserviceInfo(String title, String info, int width, int height, boolean makeVisible) { + // no references init(title, info, width, height, makeVisible); } @@ -322,7 +323,7 @@ public class WebserviceInfo extends GWebserviceInfo { frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, title, makeVisible, width, height); + Desktop.addInternalFrame(frame, title, makeVisible, width, height, Desktop.FRAME_ALLOW_RESIZE, Desktop.FRAME_SET_MIN_SIZE_300); frame.setClosable(false); progressBar = new ProgressBar(statusPanel, statusBar); diff --git a/src/jalview/ws/jws1/JPredClient.java b/src/jalview/ws/jws1/JPredClient.java index 3dd8104..1c625fa 100644 --- a/src/jalview/ws/jws1/JPredClient.java +++ b/src/jalview/ws/jws1/JPredClient.java @@ -304,7 +304,7 @@ public class JPredClient extends WS1Client WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, - WebServiceReference, true); + WebServiceReference, Desktop.FRAME_MAKE_VISIBLE); return wsInfo; } diff --git a/src/jalview/ws/jws1/WS1Client.java b/src/jalview/ws/jws1/WS1Client.java index 6fa41fc..7bffe43 100644 --- a/src/jalview/ws/jws1/WS1Client.java +++ b/src/jalview/ws/jws1/WS1Client.java @@ -21,6 +21,7 @@ package jalview.ws.jws1; import jalview.gui.AlignFrame; +import jalview.gui.Desktop; import jalview.gui.WebserviceInfo; import jalview.util.MessageManager; import jalview.ws.WSClient; @@ -92,8 +93,8 @@ public abstract class WS1Client extends WSClient WebserviceInfo wsInfo = null; if (!headless) { - wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference, - true); + wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference, + Desktop.FRAME_MAKE_VISIBLE); } return wsInfo; } diff --git a/src/jalview/ws/jws2/Jws2Client.java b/src/jalview/ws/jws2/Jws2Client.java index 62f2a03..004a845 100644 --- a/src/jalview/ws/jws2/Jws2Client.java +++ b/src/jalview/ws/jws2/Jws2Client.java @@ -154,8 +154,8 @@ public abstract class Jws2Client extends jalview.ws.WSClient return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle + " using service hosted at " + serv.hosturl + "\n" - + (serv.description != null ? serv.description : ""), - false); + + (serv.description != null ? serv.description : ""), + Desktop.FRAME_NOT_VISIBLE); } return null; } diff --git a/src/jalview/ws/rest/RestClient.java b/src/jalview/ws/rest/RestClient.java index 41c5716..5d1a288 100644 --- a/src/jalview/ws/rest/RestClient.java +++ b/src/jalview/ws/rest/RestClient.java @@ -130,7 +130,7 @@ public static final String RSBS_SERVICES = "RSBS_SERVICES"; if (!headless) { wsInfo = new WebserviceInfo(WebServiceJobTitle, - WebServiceName + "\n" + WebServiceReference, true); + WebServiceName + "\n" + WebServiceReference, Desktop.FRAME_MAKE_VISIBLE); wsInfo.setRenderAsHtml(true); } -- 1.7.10.2