import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
import jalview.ws.DBRefFetcher.FetchFinishedListenerI;
-import jalview.ws.datamodel.alphafold.PAEContactMatrix;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2Instance;
protected void htmlMenuItem_actionPerformed(ActionEvent e)
{
HtmlSvgOutput htmlSVG = new HtmlSvgOutput(alignPanel);
- try {
+ try
+ {
htmlSVG.exportHTML(null);
- } catch (ImageOutputException x) {
+ } catch (ImageOutputException x)
+ {
// report problem to console and raise dialog
}
}
public void bioJSMenuItem_actionPerformed(ActionEvent e)
{
BioJsHTMLOutput bjs = new BioJsHTMLOutput(alignPanel);
- try {
- bjs.exportHTML(null);
- } catch (ImageOutputException x) {
- // report problem to console and raise dialog
- }
+ try
+ {
+ bjs.exportHTML(null);
+ } catch (ImageOutputException x)
+ {
+ // report problem to console and raise dialog
+ }
}
public void createImageMap(File file, String image)
{
- try {
- alignPanel.makePNGImageMap(file, image);
- } catch (ImageOutputException x) {
+ try
+ {
+ alignPanel.makePNGImageMap(file, image);
+ } catch (ImageOutputException x)
+ {
// report problem to console and raise dialog
}
}
@Override
- public void createPNG_actionPerformed(ActionEvent e) {
- try{
+ public void createPNG_actionPerformed(ActionEvent e)
+ {
+ try
+ {
createPNG(null);
} catch (ImageOutputException ioex)
{
// raise dialog, and report via console
}
}
+
@Override
- public void createEPS_actionPerformed(ActionEvent e) {
- try{
+ public void createEPS_actionPerformed(ActionEvent e)
+ {
+ try
+ {
createEPS(null);
} catch (ImageOutputException ioex)
{
// raise dialog, and report via console
}
-
+
}
+
@Override
- public void createSVG_actionPerformed(ActionEvent e) {
- try{
+ public void createSVG_actionPerformed(ActionEvent e)
+ {
+ try
+ {
createSVG(null);
} catch (ImageOutputException ioex)
{
// raise dialog, and report via console
}
-
+
}
+
/**
* Creates a PNG image of the alignment and writes it to the given file. If
* the file is null, the user is prompted to choose a file.
createPNG(f, null, BitmapImageSizing.nullBitmapImageSizing());
}
- public void createPNG(File f, String renderer, BitmapImageSizing userBis) throws ImageOutputException
+ public void createPNG(File f, String renderer, BitmapImageSizing userBis)
+ throws ImageOutputException
{
alignPanel.makeAlignmentImage(TYPE.PNG, f, renderer, userBis);
}
*
* @param f
*/
- public void createEPS(File f) throws ImageOutputException
+ public void createEPS(File f) throws ImageOutputException
{
createEPS(f, null);
}
*
* @param f
*/
- public void createSVG(File f) throws ImageOutputException
+ public void createSVG(File f) throws ImageOutputException
{
createSVG(f, null);
}
closeAllTabs = true;
}
+ Desktop.closeModal(this);
+
try
{
if (alignPanels != null)
featureSettings.close();
featureSettings = null;
}
+
/*
* this will raise an INTERNAL_FRAME_CLOSED event and this method will
* be called recursively, with the frame now in 'closed' state
// annotation was duplicated earlier
alignment.addAnnotation(sequences[i].getAnnotation()[a]);
// take care of contact matrix too
- ContactMatrixI cm=sequences[i].getContactMatrixFor(sequences[i].getAnnotation()[a]);
- if (cm!=null)
+ ContactMatrixI cm = sequences[i]
+ .getContactMatrixFor(sequences[i].getAnnotation()[a]);
+ if (cm != null)
{
- alignment.addContactListFor(sequences[i].getAnnotation()[a], cm);
+ alignment.addContactListFor(sequences[i].getAnnotation()[a],
+ cm);
}
-
+
alignment.setAnnotationIndex(sequences[i].getAnnotation()[a],
a);
}
return tp;
}
- public void showContactMapTree(AlignmentAnnotation aa,
- ContactMatrixI cm)
+ public void showContactMapTree(AlignmentAnnotation aa, ContactMatrixI cm)
{
int x = 4, y = 5;
int w = 400, h = 500;
import java.awt.geom.AffineTransform;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
+import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
}
/**
- * checks if any progress bars are being displayed in any of the windows managed by the desktop
+ * checks if any progress bars are being displayed in any of the windows
+ * managed by the desktop
+ *
* @return
*/
public boolean operationsAreInProgress()
{
JInternalFrame[] frames = getAllFrames();
- for (JInternalFrame frame:frames)
+ for (JInternalFrame frame : frames)
{
if (frame instanceof IProgressIndicator)
{
- if (((IProgressIndicator)frame).operationInProgress())
+ if (((IProgressIndicator) frame).operationInProgress())
{
return true;
}
}
return operationInProgress();
}
+
+ /**
+ * keep track of modal JvOptionPanes open as modal dialogs for AlignFrames.
+ * The way the modal JInternalFrame is made means it cannot be a child of an
+ * AlignFrame, so closing the AlignFrame might leave the modal open :(
+ */
+ private static Map<AlignFrame, JInternalFrame> alignFrameModalMap = new HashMap<>();
+
+ protected static void addModal(AlignFrame af, JInternalFrame jif)
+ {
+ alignFrameModalMap.put(af, jif);
+ }
+
+ protected static void closeModal(AlignFrame af)
+ {
+ if (!alignFrameModalMap.containsKey(af))
+ {
+ return;
+ }
+ JInternalFrame jif = alignFrameModalMap.get(af);
+ if (jif != null)
+ {
+ try
+ {
+ jif.setClosed(true);
+ } catch (PropertyVetoException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ alignFrameModalMap.remove(af);
+ }
+
}
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseMotionAdapter;
import java.beans.PropertyChangeEvent;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.InternalFrameEvent;
if (parentComponent != this
&& !(parentComponent == null && Desktop.instance == null))
{
+ // note the parent goes back to a JRootPane so is probably
+ // Desktop.getDesktop()
JInternalFrame jif = this.createInternalFrame(
parentComponent != null ? parentComponent : Desktop.instance,
title);
+ // connect to the alignFrame using a map in Desktop
+ if (parentComponent instanceof AlignFrame)
+ {
+ Desktop.addModal((AlignFrame) parentComponent, jif);
+ }
jif.setFrameIcon(null);
jif.addInternalFrameListener(new InternalFrameListener()
{
lp.add(modalInterceptor);
f.toFront();
+ // disable the main menu bar if in Linux
+ JMenuBar menubar = null;
+ if (Platform.isLinux())
+ {
+ JRootPane rootpane = Desktop.getDesktop().getRootPane();
+ menubar = rootpane.getJMenuBar();
+ }
+
// We need to explicitly dispatch events when we are blocking the event
// dispatch thread.
EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
try
{
+ if (menubar != null)
+ {
+ // don't allow clicks on main menu on linux due to a hanging bug.
+ // see JAL-4214.
+ setMenusEnabled(menubar, false);
+ }
+
while (!f.isClosed())
{
if (EventQueue.isDispatchThread())
{
((ActiveEvent) ev).dispatch();
}
+ else if (ev instanceof KeyEvent && ((KeyEvent) ev).isControlDown()
+ && menubar != null)
+ {
+ // temporarily enable menus to send Ctrl+? KeyEvents
+ setMenusEnabled(menubar, true);
+ ((Component) ev.getSource()).dispatchEvent(ev);
+ setMenusEnabled(menubar, false);
+ }
else if (ev.getSource() instanceof MenuComponent)
{
((MenuComponent) ev.getSource()).dispatchEvent(ev);
else if (ev.getSource() instanceof Component)
{
((Component) ev.getSource()).dispatchEvent(ev);
- // remove the modal frame if clicked on main menu on linux due to
- // hanging bug.
- // see JAL-4214.
- if (Platform.isLinux() && ev.getSource()
- .equals(Desktop.getDesktop().getRootPane()))
- {
- break;
- }
}
// Other events are ignored as per spec in
// EventQueue.dispatchEvent
// If we get interrupted, then leave the modal state.
} finally
{
+ // re-enable the main menu bar
+ if (menubar != null)
+ {
+ setMenusEnabled(menubar, true);
+ }
+
// Clean up the modal interceptor.
lp.remove(modalInterceptor);
return jvop;
}
+
+ private static void setMenusEnabled(JMenuBar menubar, boolean b)
+ {
+ for (int i = 0; i < menubar.getMenuCount(); i++)
+ {
+ JMenu menu = menubar.getMenu(i);
+ menu.setEnabled(b);
+ }
+ }
+
}