import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.Arrays;
import javax.swing.ImageIcon;
import javax.swing.JButton;
private BorderLayout mainLayout = new BorderLayout();
+ protected PDBDocField[] previousWantedFields;
+
public GPDBSearchPanel()
{
try
final String searchTabTitle = MessageManager
.getString("label.search_result");
+ final String configureCols = MessageManager.getString("label.configure_displayed_columns");
ChangeListener changeListener = new ChangeListener()
{
public void stateChanged(ChangeEvent changeEvent)
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
.getSource();
int index = sourceTabbedPane.getSelectedIndex();
+ btn_ok.setEnabled(false);
+ if (sourceTabbedPane.getTitleAt(index).equals(configureCols))
+ {
+ previousWantedFields = PDBDocFieldPreferences
+ .getSearchSummaryFields().toArray(new PDBDocField[0]);
+ }
if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle))
{
- txt_search_ActionPerformed();
+ if (wantedFieldsUpdated())
+ {
+ txt_search_ActionPerformed();
+ }
+ else
+ {
+ validateSelection();
+ }
}
}
};
tabbedPane.addChangeListener(changeListener);
tabbedPane.setPreferredSize(new Dimension(500, 300));
tabbedPane.add(searchTabTitle, scrl_searchResult);
- tabbedPane.add(
- MessageManager.getString("label.configure_displayed_columns"),
- pdbDocFieldPrefs);
+ tabbedPane.add(configureCols, pdbDocFieldPrefs);
pnl_actions.add(btn_back);
pnl_actions.add(btn_ok);
Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
}
+ public boolean wantedFieldsUpdated()
+ {
+ if (previousWantedFields == null)
+ {
+ return true;
+ }
+
+ return Arrays.equals(PDBDocFieldPreferences.getSearchSummaryFields()
+ .toArray(new PDBDocField[0]), previousWantedFields) ? false
+ : true;
+
+ }
public void validateSelection()
{
if (tbl_summary.getSelectedRows().length > 0)
import jalview.gui.Desktop;
import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource;
import jalview.util.MessageManager;
+import jalview.ws.dbsources.PDBRestClient;
+import jalview.ws.dbsources.PDBRestClient.PDBDocField;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.util.Arrays;
import javax.swing.ImageIcon;
import javax.swing.JButton;
private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
PreferenceSource.STRUCTURE_CHOOSER);
+ protected PDBDocField[] previousWantedFields;
public GStructureChooser()
{
try
final String foundStructureSummary = MessageManager
.getString("label.found_structures_summary");
-
+ final String configureCols = MessageManager
+ .getString("label.configure_displayed_columns");
ChangeListener changeListener = new ChangeListener()
{
public void stateChanged(ChangeEvent changeEvent)
{
JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent
.getSource();
+ btn_view.setEnabled(false);
int index = sourceTabbedPane.getSelectedIndex();
if (sourceTabbedPane.getTitleAt(index)
+.equals(configureCols))
+ {
+ previousWantedFields = PDBDocFieldPreferences
+ .getStructureSummaryFields().toArray(
+ new PDBRestClient.PDBDocField[0]);
+ }
+ if (sourceTabbedPane.getTitleAt(index)
.equals(foundStructureSummary))
{
- tabRefresh();
+ if (wantedFieldsUpdated())
+ {
+ tabRefresh();
+ }
+ else
+ {
+ validateSelections();
+ }
}
}
};
pnl_filter.addChangeListener(changeListener);
pnl_filter.setPreferredSize(new Dimension(500, 300));
pnl_filter.add(foundStructureSummary, scrl_foundStructures);
- pnl_filter.add(
- MessageManager.getString("label.configure_displayed_columns"),
- pdbDocFieldPrefs);
+ pnl_filter.add(configureCols, pdbDocFieldPrefs);
pnl_locPDB.add(scrl_localPDB);
Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
}
+ public boolean wantedFieldsUpdated()
+ {
+ if (previousWantedFields == null)
+ {
+ return true;
+ }
+
+ return Arrays.equals(PDBDocFieldPreferences.getStructureSummaryFields()
+ .toArray(new PDBRestClient.PDBDocField[0]),
+ previousWantedFields) ? false : true;
+
+ }
@Override
/**
public abstract void cmbAssSeqStateChanged();
public abstract void tabRefresh();
+
+ public abstract void validateSelections();
}