From f7775ab8e5622ab365c1e178c79ec78a707aad1f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 9 Apr 2018 10:17:12 +0100 Subject: [PATCH] =?utf8?q?JAL-2944=20=E2=80=99new=20view=E2=80=99=20and=20=E2?= =?utf8?q?=80=98add=20to=20view=E2=80=99=20button=20rather=20than=20selectin?= =?utf8?q?g=20from=20combo=20box=20to=20make=20it=20easier=20to=20successive?= =?utf8?q?ly=20add=20structures=20to=20existing=20view=20(which=20is=20the=20?= =?utf8?q?default=20action=20when=20return=20is=20pressed)=E2=80=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/StructureChooser.java | 32 ++++++++++++------ src/jalview/jbgui/GStructureChooser.java | 53 +++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 1b69989..cd1cfc3 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -142,13 +142,11 @@ public class StructureChooser extends GStructureChooser if (Desktop.instance != null) { targetView.removeAllItems(); - targetView.addItem( - new StructureViewer(ap.getStructureSelectionManager())); if (lastTargetedView != null && !lastTargetedView.isVisible()) { lastTargetedView = null; } - int linkedViewsAt = 1; + int linkedViewsAt = 0; for (StructureViewerBase view : Desktop.instance .getStructureViewers(null, null)) { @@ -166,12 +164,16 @@ public class StructureChooser extends GStructureChooser targetView.addItem(viewHandler); } } - targetView.setVisible(targetView.getItemCount() > 1); - - // finally, restore last targeted view by default. - if (lastTargetedView != null) - { - targetView.setSelectedItem(lastTargetedView); + targetView.setVisible(targetView.getItemCount() > 0); + btn_view.setVisible(targetView.isVisible()); + if (targetView.isVisible()) { + // finally, restore last targeted view by default. + if (lastTargetedView != null) + { + targetView.setSelectedItem(lastTargetedView); + } else { + targetView.setSelectedIndex(0); + } } } } @@ -817,7 +819,17 @@ public class StructureChooser extends GStructureChooser * Handles action event for btn_ok */ @Override - public void ok_ActionPerformed() + public void newview_ActionPerformed() + { + targetView.setSelectedItem(null); + showStructures(false); + } + + /** + * Handles action event for btn_ok + */ + @Override + public void view_ActionPerformed() { showStructures(false); } diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 810813b..523ab7e 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -105,6 +105,9 @@ public abstract class GStructureChooser extends JPanel protected JButton btn_view = new JButton(); + protected JButton btn_newview = new JButton( + MessageManager.getString("label.new_view")); + protected JButton btn_cancel = new JButton(); protected JButton btn_pdbFromFile = new JButton(); @@ -329,7 +332,7 @@ public abstract class GStructureChooser extends JPanel case KeyEvent.VK_ENTER: // enter key if (btn_view.isEnabled()) { - ok_ActionPerformed(); + view_ActionPerformed(); } break; case KeyEvent.VK_TAB: // tab key @@ -378,7 +381,7 @@ public abstract class GStructureChooser extends JPanel case KeyEvent.VK_ENTER: // enter key if (btn_view.isEnabled()) { - ok_ActionPerformed(); + view_ActionPerformed(); } break; case KeyEvent.VK_TAB: // tab key @@ -404,14 +407,36 @@ public abstract class GStructureChooser extends JPanel } } }); + btn_newview.setFont(new java.awt.Font("Verdana", 0, 12)); + btn_newview.setText(MessageManager.getString("action.new_view")); + btn_newview.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + newview_ActionPerformed(); + } + }); + btn_newview.addKeyListener(new KeyAdapter() + { + @Override + public void keyPressed(KeyEvent evt) + { + if (evt.getKeyCode() == KeyEvent.VK_ENTER) + { + newview_ActionPerformed(); + } + } + }); + btn_view.setFont(new java.awt.Font("Verdana", 0, 12)); - btn_view.setText(MessageManager.getString("action.view")); + btn_view.setText(MessageManager.getString("action.add")); btn_view.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ok_ActionPerformed(); + view_ActionPerformed(); } }); btn_view.addKeyListener(new KeyAdapter() @@ -421,7 +446,7 @@ public abstract class GStructureChooser extends JPanel { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { - ok_ActionPerformed(); + view_ActionPerformed(); } } }); @@ -523,11 +548,13 @@ public abstract class GStructureChooser extends JPanel chk_invertFilter.addItemListener(this); targetView.setVisible(false); - pnl_actions.add(targetView,"wrap"); - pnl_actions.add(chk_rememberSettings); - pnl_actions.add(btn_view); - pnl_actions.add(btn_cancel); + pnl_actions.add(targetView, "left"); + pnl_actions.add(btn_view, "wrap"); pnl_actions.add(chk_superpose, "left"); + pnl_actions.add(btn_newview); + pnl_actions.add(btn_cancel, "right"); + + // pnl_actions.add(chk_rememberSettings); // pnl_filter.add(lbl_result); pnl_main.add(cmb_filterOption); @@ -557,13 +584,15 @@ public abstract class GStructureChooser extends JPanel JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent .getSource(); int index = sourceTabbedPane.getSelectedIndex(); - btn_view.setVisible(true); + btn_view.setVisible(targetView.isVisible()); + btn_newview.setVisible(true); btn_cancel.setVisible(true); if (sourceTabbedPane.getTitleAt(index).equals(configureCols)) { btn_view.setEnabled(false); btn_cancel.setEnabled(false); btn_view.setVisible(false); + btn_newview.setEnabled(false); btn_cancel.setVisible(false); previousWantedFields = pdbDocFieldPrefs .getStructureSummaryFields() @@ -912,7 +941,9 @@ public abstract class GStructureChooser extends JPanel protected abstract void stateChanged(ItemEvent e); - protected abstract void ok_ActionPerformed(); + protected abstract void view_ActionPerformed(); + + protected abstract void newview_ActionPerformed(); protected abstract void pdbFromFile_actionPerformed(); -- 1.7.10.2