diff --git a/uk/ac/sanger/artemis/components/NonModalDialog.java b/uk/ac/sanger/artemis/components/NonModalDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..bb344953c17c97cedc448683a74186983ef94405 --- /dev/null +++ b/uk/ac/sanger/artemis/components/NonModalDialog.java @@ -0,0 +1,95 @@ +/* NonModalDialog + * + * created: 2011 + * + * This file is part of Artemis + * + * Copyright(C) 2011 Genome Research Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +package uk.ac.sanger.artemis.components; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.FontMetrics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class NonModalDialog extends JDialog +{ + private static final long serialVersionUID = 1L; + + /** + * Create a non-modal dialog with an array of strings to + * display on separate lines. + * @param f + * @param labelStr + */ + public NonModalDialog(JFrame f, String labelStr[]) + { + super(f, "Check the reference is correctly selected", false); + + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice gd = ge.getDefaultScreenDevice(); + GraphicsConfiguration gc = gd.getDefaultConfiguration(); + Insets ins = Toolkit.getDefaultToolkit().getScreenInsets(gc); + int sw = gc.getBounds().width - ins.left - ins.right; + int sh = gc.getBounds().height - ins.top - ins.bottom; + + setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + Container cp = getContentPane(); + Box yBox = Box.createVerticalBox(); + cp.setLayout(new BorderLayout()); + + int width = 10; + for(int i=0; i<labelStr.length; i++) + { + JLabel label = new JLabel(labelStr[i]); + yBox.add(label); + + FontMetrics fm = label.getFontMetrics(label.getFont()); + int thisWidth = fm.stringWidth(label.getText()); + if(thisWidth > width) + width = thisWidth; + } + cp.add(yBox, BorderLayout.NORTH); + + JButton okButton = new JButton("OK"); + cp.add(okButton, BorderLayout.SOUTH); + okButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent arg0) + { + dispose(); + } + }); + + setBounds((sw - width)/2, sh/2, width, 100); + setVisible(true); + } +} \ No newline at end of file diff --git a/uk/ac/sanger/artemis/components/alignment/BamView.java b/uk/ac/sanger/artemis/components/alignment/BamView.java index 50c427cd5c32b97559f735d115d728543d8b5567..a5749e6e2c82e79d5c3e72c2f77582fe331d73cd 100644 --- a/uk/ac/sanger/artemis/components/alignment/BamView.java +++ b/uk/ac/sanger/artemis/components/alignment/BamView.java @@ -116,6 +116,7 @@ import uk.ac.sanger.artemis.components.EntryFileDialog; import uk.ac.sanger.artemis.components.FeatureDisplay; import uk.ac.sanger.artemis.components.FileViewer; import uk.ac.sanger.artemis.components.MessageDialog; +import uk.ac.sanger.artemis.components.NonModalDialog; import uk.ac.sanger.artemis.components.SwingWorker; import uk.ac.sanger.artemis.components.genebuilder.AutoCompleteComboDocument; import uk.ac.sanger.artemis.components.variant.FeatureContigPredicate; @@ -1980,13 +1981,16 @@ public class BamView extends JPanel } } - JOptionPane.showMessageDialog(null, - "The length of the sequence loaded does not match the length of\n"+ - "the default reference sequence in the BAM ("+seqNames.get(0)+").\n"+ - (newIndex == -1 ? "" : "The length does match the reference "+ - seqNames.get(newIndex)+" so this has been\nset as the default."), - "Check the reference is correctly selected", - JOptionPane.WARNING_MESSAGE); + if(!Options.isBlackBeltMode()) + { + String label[] = { + "The length of the sequence loaded does not match the length of", + "the default reference sequence in the BAM ("+seqNames.get(0)+").", + (newIndex == -1 ? "" : "The length does match the reference "+ + seqNames.get(newIndex)+" so this has been\nset as the default.") + }; + new NonModalDialog(frame, label); + } } } }