import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
-import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
/**
if (haveData)
{
cmb_filterOption.addItem(new FilterOption("Best Quality",
- "overall_quality", VIEWS_FILTER));
+ "overall_quality", VIEWS_FILTER, false));
cmb_filterOption.addItem(new FilterOption("Best Resolution",
- "resolution", VIEWS_FILTER));
+ "resolution", VIEWS_FILTER, false));
cmb_filterOption.addItem(new FilterOption("Most Protein Chain",
- "number_of_protein_chains", VIEWS_FILTER));
+ "number_of_protein_chains", VIEWS_FILTER, false));
cmb_filterOption.addItem(new FilterOption("Most Bound Molecules",
- "number_of_bound_molecules", VIEWS_FILTER));
+ "number_of_bound_molecules", VIEWS_FILTER, false));
cmb_filterOption.addItem(new FilterOption("Most Polymer Residues",
- "number_of_polymer_residues", VIEWS_FILTER));
+ "number_of_polymer_residues", VIEWS_FILTER, true));
}
cmb_filterOption.addItem(new FilterOption("Enter PDB Id", "-",
- VIEWS_ENTER_ID));
+ VIEWS_ENTER_ID, false));
cmb_filterOption.addItem(new FilterOption("From File", "-",
- VIEWS_FROM_FILE));
- FilterOption cachedOption = new FilterOption("Cached PDB Entries", "-",
- VIEWS_LOCAL_PDB);
- cmb_filterOption.addItem(cachedOption);
+ VIEWS_FROM_FILE, false));
- if (/*!haveData &&*/cachedPDBExists)
+ if (cachedPDBExists)
{
+ FilterOption cachedOption = new FilterOption("Cached PDB Entries",
+ "-", VIEWS_LOCAL_PDB, false);
+ cmb_filterOption.addItem(cachedOption);
cmb_filterOption.setSelectedItem(cachedOption);
}
import java.awt.BorderLayout;
import java.awt.CardLayout;
+import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
+import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
});
cmb_filterOption.addItemListener(this);
+
+ // add CustomComboSeparatorsRenderer to filter option combo-box
+ cmb_filterOption.setRenderer(new CustomComboSeparatorsRenderer(
+ (ListCellRenderer<Object>) cmb_filterOption.getRenderer())
+ {
+ @Override
+ protected boolean addSeparatorAfter(JList list, FilterOption value,
+ int index)
+ {
+ return value.isAddSeparatorAfter();
+ }
+ });
+
chk_invertFilter.addItemListener(this);
pnl_actions.add(chk_rememberSettings);
private String view;
- public FilterOption(String name, String value, 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 this.name;
}
+
+ public boolean isAddSeparatorAfter()
+ {
+ return addSeparatorAfter;
+ }
+
+ public void setAddSeparatorAfter(boolean addSeparatorAfter)
+ {
+ this.addSeparatorAfter = addSeparatorAfter;
+ }
}
/**
return cmb_filterOption;
}
+ /**
+ * Custom ListCellRenderer for adding a separator between different categories
+ * of structure chooser filter option drop-down.
+ *
+ * @author tcnofoegbu
+ *
+ */
+ public abstract class CustomComboSeparatorsRenderer implements
+ ListCellRenderer<Object>
+ {
+ private ListCellRenderer<Object> regent;
+
+ private JPanel separatorPanel = new JPanel(new BorderLayout());
+
+ private JSeparator jSeparator = new JSeparator();
+
+ public CustomComboSeparatorsRenderer(ListCellRenderer<Object> listCellRenderer)
+ {
+ this.regent = listCellRenderer;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index, boolean isSelected, boolean cellHasFocus)
+ {
+
+ Component comp = regent.getListCellRendererComponent(list, value,
+ index, isSelected, cellHasFocus);
+ if (index != -1
+ && addSeparatorAfter(list, (FilterOption) value, index))
+ {
+ separatorPanel.removeAll();
+ separatorPanel.add(comp, BorderLayout.CENTER);
+ separatorPanel.add(jSeparator, BorderLayout.SOUTH);
+ return separatorPanel;
+ }
+ else
+ {
+ return comp;
+ }
+ }
+
+ protected abstract boolean addSeparatorAfter(JList list,
+ FilterOption value,
+ int index);
+ }
+
protected abstract void stateChanged(ItemEvent e);
protected abstract void ok_ActionPerformed();
public abstract void tabRefresh();
public abstract void validateSelections();
-}
+}
\ No newline at end of file