+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview 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 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview 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 Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.gui;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.gui.StructureViewer.ViewerType;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.jbgui.GStructureViewer;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
+import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
protected Thread worker = null;
+ protected boolean allChainsSelected = false;
+
/**
*
* @param ap2
this.ap = alp;
}
+ @Override
public AlignmentPanel[] getAllAlignmentPanels()
{
AlignmentPanel[] t, list = new AlignmentPanel[0];
// queue.
new Thread(new Runnable()
{
+ @Override
public void run()
{
while (worker != null && worker.isAlive() && _started)
*
* @param pdbId
* @param view
- * @return YES, NO or CANCEL JOptionPane code
+ * @return YES, NO or CANCEL JvOptionPane code
*/
protected int chooseAlignStructureToViewer(String pdbId,
StructureViewerBase view)
{
- int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
MessageManager.formatMessage("label.add_pdbentry_to_view",
new Object[] { pdbId, view.getTitle() }),
MessageManager
.getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_CANCEL_OPTION);
+ JvOptionPane.YES_NO_CANCEL_OPTION);
return option;
}
continue;
}
int option = chooseAlignStructureToViewer(pdbId, view);
- if (option == JOptionPane.CANCEL_OPTION)
+ if (option == JvOptionPane.CANCEL_OPTION)
{
return true;
}
- else if (option == JOptionPane.YES_OPTION)
+ else if (option == JvOptionPane.YES_OPTION)
{
view.useAlignmentPanelForSuperposition(apanel);
view.addStructure(pdbentry, seq, chains, true, apanel.alignFrame);
* create the mappings
*/
apanel.getStructureSelectionManager().setMapping(seq, chains,
- pdbFilename, AppletFormatAdapter.FILE);
+ pdbFilename, DataSourceType.FILE);
/*
* alert the FeatureRenderer to show new (PDB RESNUM) features
/*
* the PDB file is already loaded
*/
- int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ int option = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
MessageManager.formatMessage(
"label.pdb_entry_is_already_displayed",
new Object[] { pdbId }), MessageManager
.formatMessage(
"label.map_sequences_to_visible_window",
new Object[] { pdbId }),
- JOptionPane.YES_NO_CANCEL_OPTION);
- if (option == JOptionPane.CANCEL_OPTION)
+ JvOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JvOptionPane.CANCEL_OPTION)
{
finished = true;
}
- else if (option == JOptionPane.YES_OPTION)
+ else if (option == JvOptionPane.YES_OPTION)
{
addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped);
finished = true;
}
return finished;
}
+
+ void setChainMenuItems(List<String> chainNames)
+ {
+ chainMenu.removeAll();
+ if (chainNames == null || chainNames.isEmpty())
+ {
+ return;
+ }
+ JMenuItem menuItem = new JMenuItem(
+ MessageManager.getString("label.all"));
+ menuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent evt)
+ {
+ allChainsSelected = true;
+ for (int i = 0; i < chainMenu.getItemCount(); i++)
+ {
+ if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
+ }
+ showSelectedChains();
+ allChainsSelected = false;
+ }
+ });
+
+ chainMenu.add(menuItem);
+
+ for (String chain : chainNames)
+ {
+ menuItem = new JCheckBoxMenuItem(chain, true);
+ menuItem.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent evt)
+ {
+ if (!allChainsSelected)
+ {
+ showSelectedChains();
+ }
+ }
+ });
+
+ chainMenu.add(menuItem);
+ }
+ }
+
+ abstract void showSelectedChains();
+
}