X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fjbgui%2FGStructureChooser.java;h=70d99c12bc3fd1878e0744ab5144de9e2a328635;hb=45bf1ca88efba1a6510947bbad6667a210ccd752;hp=d43495ea41b2ba4889311efe9920a26c530cecd6;hpb=97a1f5a89f698f1117dbd6606c5a24089b582440;p=jalview.git diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index d43495e..70d99c1 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -39,6 +39,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -67,6 +68,7 @@ import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListCellRenderer; import javax.swing.Timer; +import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; @@ -88,7 +90,7 @@ public abstract class GStructureChooser extends JPanel { private static final Font VERDANA_12 = new Font("Verdana", 0, 12); - protected static final String VIEWS_FILTER = "VIEWS_FILTER"; + public static final String VIEWS_FILTER = "VIEWS_FILTER"; protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE"; @@ -119,6 +121,8 @@ public abstract class GStructureChooser extends JPanel protected JButton btn_newView; protected JButton btn_pdbFromFile = new JButton(); + + protected JButton btn_queryTDB = new JButton(); protected JCheckBox chk_superpose = new JCheckBox( MessageManager.getString("label.superpose_structures")); @@ -145,6 +149,9 @@ public abstract class GStructureChooser extends JPanel protected ImageIcon warningImage = new ImageIcon( getClass().getResource("/images/warning.gif")); + protected ImageIcon tdbImage = new ImageIcon( + getClass().getResource("/images/3d-beacons-logo-transparent.png")); + protected JLabel lbl_loading = new JLabel(loadingImage); protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage); @@ -244,7 +251,7 @@ public abstract class GStructureChooser extends JPanel + "...\"") : JvSwingUtils.wrapTooltip(true, toolTipText))); return toolTipText; - } + } }; public GStructureChooser() @@ -306,15 +313,42 @@ public abstract class GStructureChooser extends JPanel tbl_summary.addMouseListener(new MouseAdapter() { @Override + public void mousePressed(MouseEvent e) + { + if (!popupAction(e)) + { + super.mousePressed(e); + } + } + @Override public void mouseClicked(MouseEvent e) { - validateSelections(); + if (!popupAction(e)) + { + validateSelections(); + } } @Override public void mouseReleased(MouseEvent e) { + if (!popupAction(e)) + { validateSelections(); + } + } + boolean popupAction(MouseEvent e) + { + if (e.isPopupTrigger()) + { + Point pt = e.getPoint(); + int selectedRow = tbl_summary.rowAtPoint(pt); + if (showPopupFor(selectedRow,pt.x,pt.y)) + { + return true; + } + } + return false; } }); tbl_summary.addKeyListener(new KeyAdapter() @@ -431,7 +465,9 @@ public abstract class GStructureChooser extends JPanel } }); - btn_newView = new JButton(MessageManager.getString("action.new_view")); + btn_newView = new JButton( + MessageManager.formatMessage("action.new_structure_view_with", + StructureViewer.getViewerType().toString())); btn_newView.setFont(VERDANA_12); btn_newView.addActionListener(new java.awt.event.ActionListener() { @@ -452,6 +488,8 @@ public abstract class GStructureChooser extends JPanel } } }); + + // TODO: JAL-3898 - get list of available external programs to view structures with btn_add = new JButton(MessageManager.getString("action.add")); btn_add.setFont(VERDANA_12); @@ -547,6 +585,12 @@ public abstract class GStructureChooser extends JPanel }); chk_invertFilter.addItemListener(this); + btn_queryTDB.setFont(VERDANA_12); + //btn_queryTDB.setPreferredSize(new Dimension(200,22)); + btn_queryTDB.setText(MessageManager.getString("label.search_3dbeacons")); + btn_queryTDB.setToolTipText(MessageManager.getString("label.find_models_from_3dbeacons")); + btn_queryTDB.setIcon(tdbImage); + btn_queryTDB.setVisible(false); targetView.setVisible(false); @@ -557,10 +601,13 @@ public abstract class GStructureChooser extends JPanel actionsPanel.add(btn_newView); actionsPanel.add(btn_cancel, "right"); - JPanel pnl_main = new JPanel(); - pnl_main.add(cmb_filterOption); - pnl_main.add(lbl_loading); - pnl_main.add(chk_invertFilter); + JPanel pnl_main = new JPanel(new BorderLayout()); + JPanel pnl_controls = new JPanel(); + pnl_main.add(btn_queryTDB,BorderLayout.NORTH); + pnl_controls.add(cmb_filterOption); + pnl_controls.add(lbl_loading); + pnl_controls.add(chk_invertFilter); + pnl_main.add(pnl_controls,BorderLayout.CENTER); lbl_loading.setVisible(false); JPanel pnl_fileChooser = new JPanel(new FlowLayout()); @@ -666,6 +713,7 @@ public abstract class GStructureChooser extends JPanel } +protected abstract boolean showPopupFor(int selectedRow, int x, int y); protected void closeAction(int preferredHeight) { // System.out.println(">>>>>>>>>> closing internal frame!!!"); @@ -704,91 +752,6 @@ protected void closeAction(int preferredHeight) } /** - * This inner class provides the data model for the structure filter combo-box - * - * @author tcnofoegbu - * - */ - public class FilterOption - { - private String name; - - private String value; - - private String view; - - private boolean addSeparatorAfter; - - /** - * Model for structure filter option - * - * @param name - * - the name of the Option - * @param value - * - the value of the option - * @param view - * - the category of the filter option - * @param addSeparatorAfter - * - if true, a horizontal separator is rendered immediately after - * this filter option, otherwise - */ - public FilterOption(String name, String value, String view, - boolean addSeparatorAfter) - { - this.name = name; - this.value = value; - this.view = view; - this.addSeparatorAfter = addSeparatorAfter; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public String getView() - { - return view; - } - - public void setView(String view) - { - this.view = view; - } - - @Override - public String toString() - { - return this.name; - } - - public boolean isAddSeparatorAfter() - { - return addSeparatorAfter; - } - - public void setAddSeparatorAfter(boolean addSeparatorAfter) - { - this.addSeparatorAfter = addSeparatorAfter; - } - } - - /** * This inner class provides the provides the data model for associate * sequence combo-box - cmb_assSeq *