import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
+import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Enumeration;
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
return;
}
}
- // /////////////////////////////////
- // Check if there are other Jmol views involving this alignment
- // and prompt user about adding this molecule to one of them
- Vector existingViews = getJmolsFor(ap);
- if (existingViews.size() > 0)
+
+ /*
+ * Check if there are other Jmol views involving this alignment and prompt
+ * user about adding this molecule to one of them
+ */
+ for (AppJmol topJmol : getJmolsFor(ap))
{
- Enumeration jm = existingViews.elements();
- while (jm.hasMoreElements())
+ // TODO: highlight topJmol in view somehow
+ int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.add_pdbentry_to_view",
+ new String[]
+ { pdbentry.getId(), topJmol.getTitle() }),
+ MessageManager
+ .getString("label.align_to_existing_structure_view"),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
{
- AppJmol topJmol = (AppJmol) jm.nextElement();
- // TODO: highlight topJmol in view somehow
- int option = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager.formatMessage(
- "label.add_pdbentry_to_view", new String[]
- { pdbentry.getId(), topJmol.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_CANCEL_OPTION);
- if (option == JOptionPane.CANCEL_OPTION)
- {
- return;
- }
- if (option == JOptionPane.YES_OPTION)
- {
- topJmol.useAlignmentPanelForSuperposition(ap);
- topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
- return;
- }
+ return;
+ }
+ if (option == JOptionPane.YES_OPTION)
+ {
+ topJmol.useAlignmentPanelForSuperposition(ap);
+ topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
+ return;
}
}
// /////////////////////////////////
return;
}
- private Vector getJmolsFor(AlignmentPanel apanel)
+ private Vector<AppJmol> getJmolsFor(AlignmentPanel apanel)
{
- Vector result = new Vector();
+ Vector<AppJmol> result = new Vector<AppJmol>();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
for (JInternalFrame frame : frames)
{
if (frame instanceof AppJmol)
{
- if (((StructureViewerBase) frame).isLinkedWith(apanel))
+ if (((AppJmol) frame).isLinkedWith(apanel))
{
- result.addElement(frame);
+ result.addElement((AppJmol) frame);
}
}
}
scriptWindow = new JPanel(bl);
scriptWindow.setVisible(false);
}
- ;
+
jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow,
null);
- jmb.newJmolPopup("Jmol");
+ // jmb.newJmolPopup("Jmol");
if (command == null)
{
command = "";
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(Vector<String> chains)
{
chainMenu.removeAll();
if (chains == null)
chainMenu.add(menuItem);
- for (int c = 0; c < chains.size(); c++)
+ for (String chain : chains)
{
- menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);
+ menuItem = new JCheckBoxMenuItem(chain, true);
menuItem.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent evt)
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ Vector<String> toshow = new Vector<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
// need to wait around until script has finished
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
- : (jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
+ : (!jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
.getPdbFile().length != jmb.getPdbCount()))
{
try
{
}
}
+
// refresh the sequence colours for the new structure(s)
for (AlignmentPanel ap : _colourwith)
{
if (value == JalviewFileChooser.APPROVE_OPTION)
{
+ BufferedReader in = null;
try
{
// TODO: cope with multiple PDB files in view
- BufferedReader in = new BufferedReader(new FileReader(
+ in = new BufferedReader(new FileReader(
jmb.getPdbFile()[0]));
File outFile = chooser.getSelectedFile();
} catch (Exception ex)
{
ex.printStackTrace();
+ } finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ // ignore
+ }
+ }
}
}
}
// Set the colour using the current view for the associated alignframe
for (AlignmentPanel ap : _colourwith)
{
- jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
+ jmb.colourBySequence(ap);
}
}
}