/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
package jalview.jbgui;
-import jalview.datamodel.SequenceI;
-import jalview.fts.api.FTSDataColumnI;
-import jalview.fts.core.FTSDataColumnPreferences;
-import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
-import jalview.fts.service.pdb.PDBFTSRestClient;
-import jalview.gui.AlignmentPanel;
-import jalview.gui.Desktop;
-import jalview.gui.JvSwingUtils;
-import jalview.gui.StructureViewer;
-import jalview.util.MessageManager;
-
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.Point;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
+import javax.swing.SwingConstants;
+import javax.swing.Timer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.InternalFrameEvent;
import javax.swing.table.TableColumn;
+import jalview.datamodel.SequenceI;
+import jalview.fts.api.FTSDataColumnI;
+import jalview.fts.core.FTSDataColumnPreferences;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.Desktop;
+import jalview.gui.JvSwingUtils;
+import jalview.gui.StructureViewer;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
{
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";
protected JButton btn_pdbFromFile = new JButton();
+ // holder for icon and button
+ protected JPanel pnl_queryTDB;
+
+ protected JButton btn_queryTDB = new JButton();
+
protected JCheckBox chk_superpose = new JCheckBox(
MessageManager.getString("label.superpose_structures"));
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);
protected JTabbedPane pnl_filter = new JTabbedPane();
- protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
- PreferenceSource.STRUCTURE_CHOOSER,
- PDBFTSRestClient.getInstance());
+ protected abstract FTSDataColumnPreferences getFTSDocFieldPrefs();
+
+ protected abstract void setFTSDocFieldPrefs(
+ FTSDataColumnPreferences newPrefs);
protected FTSDataColumnI[] previousWantedFields;
public GStructureChooser()
{
+ }
+
+ protected void initDialog()
+ {
+
try
{
jbInit();
mainFrame.pack();
} catch (Exception e)
{
+ System.out.println(e); // for JavaScript TypeError
e.printStackTrace();
}
}
+ // BH SwingJS optimization
+ // (a) 100-ms interruptable timer for text entry -- BH 1/10/2019
+ // (b) two-character minimum, at least for JavaScript.
+
+ private Timer timer;
+
+ protected void txt_search_ActionPerformedDelayed()
+ {
+ if (timer != null)
+ {
+ timer.stop();
+ }
+ timer = new Timer(300, new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ txt_search_ActionPerformed();
+ }
+ });
+ timer.setRepeats(false);
+ timer.start();
+ }
+ //
+
/**
* Initializes the GUI default properties
*
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)
{
- validateSelections();
+ 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()
}
});
- 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()
{
}
});
+ // 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);
btn_add.addActionListener(new java.awt.event.ActionListener()
@Override
public void insertUpdate(DocumentEvent e)
{
- txt_search_ActionPerformed();
+ txt_search_ActionPerformedDelayed();
}
@Override
public void removeUpdate(DocumentEvent e)
{
- txt_search_ActionPerformed();
+ txt_search_ActionPerformedDelayed();
}
@Override
public void changedUpdate(DocumentEvent e)
{
- txt_search_ActionPerformed();
+ txt_search_ActionPerformedDelayed();
}
});
});
chk_invertFilter.addItemListener(this);
+ btn_queryTDB = new JButton();
+ if (Platform.isMac())
+ {
+ // needed to make icon button have round corners in vaqua
+ btn_queryTDB.putClientProperty("JButton.buttonType", "bevel");
+ }
+ btn_queryTDB.setMargin(new Insets(0, 16, 0, 20));
+ btn_queryTDB
+ .setText(MessageManager.getString("label.search_3dbeacons"));
+ btn_queryTDB.setIconTextGap(12);
+ btn_queryTDB.setIcon(tdbImage);
+ btn_queryTDB.setVerticalTextPosition(SwingConstants.CENTER);
+ btn_queryTDB.setHorizontalTextPosition(SwingConstants.TRAILING);
+ btn_queryTDB.setFont(VERDANA_12);
+ btn_queryTDB.setToolTipText(
+ MessageManager.getString("label.find_models_from_3dbeacons"));
+ // btn_queryTDB.setPreferredSize(new Dimension(200, 32));
+ btn_queryTDB.setVisible(false);
targetView.setVisible(false);
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_queryTDB = new JPanel();
+ pnl_queryTDB.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4));
+ pnl_queryTDB.setBackground(getBackground());
+ pnl_queryTDB.add(btn_queryTDB);
+
+ pnl_queryTDB.setVisible(false);
+ pnl_main.add(pnl_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());
btn_add.setVisible(false);
btn_newView.setEnabled(false);
btn_cancel.setVisible(false);
- previousWantedFields = pdbDocFieldPrefs
+ previousWantedFields = getFTSDocFieldPrefs()
.getStructureSummaryFields()
.toArray(new FTSDataColumnI[0]);
}
pnl_filter.addChangeListener(changeListener);
pnl_filter.setPreferredSize(new Dimension(width, height));
pnl_filter.add(foundStructureSummary, scrl_foundStructures);
- pnl_filter.add(configureCols, pdbDocFieldPrefs);
+ pnl_filter.add(configureCols, getFTSDocFieldPrefs());
JPanel pnl_locPDB = new JPanel(new BorderLayout());
pnl_locPDB.add(scrl_localPDB);
Desktop.addInternalFrame(mainFrame, frameTitle, width, height);
}
+ protected abstract boolean showPopupFor(int selectedRow, int x, int y);
+
protected void closeAction(int preferredHeight)
{
// System.out.println(">>>>>>>>>> closing internal frame!!!");
return true;
}
- FTSDataColumnI[] currentWantedFields = pdbDocFieldPrefs
+ FTSDataColumnI[] currentWantedFields = getFTSDocFieldPrefs()
.getStructureSummaryFields().toArray(new FTSDataColumnI[0]);
return Arrays.equals(currentWantedFields, previousWantedFields) ? false
: true;
}
/**
- * 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
*
protected abstract void tabRefresh();
protected abstract void validateSelections();
-}
\ No newline at end of file
+
+ public JInternalFrame getFrame()
+ {
+ return mainFrame;
+ }
+}