import jalview.schemes.FeatureColour;
import jalview.util.ColorUtils;
import jalview.util.MessageManager;
-import jalview.util.dialogrunner.RunResponse;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
});
description = new JTextArea(3, 25);
+
start = new JSpinner();
end = new JSpinner();
start.setPreferredSize(new Dimension(80, 20));
end.setPreferredSize(new Dimension(80, 20));
+
+ /*
+ * ensure that start can never be more than end
+ */
+ start.addChangeListener(new ChangeListener()
+ {
+ @Override
+ public void stateChanged(ChangeEvent e)
+ {
+ Integer startVal = (Integer) start.getValue();
+ ((SpinnerNumberModel) end.getModel()).setMinimum(startVal);
+ }
+ });
+ end.addChangeListener(new ChangeListener()
+ {
+ @Override
+ public void stateChanged(ChangeEvent e)
+ {
+ Integer endVal = (Integer) end.getValue();
+ ((SpinnerNumberModel) start.getModel()).setMaximum(endVal);
+ }
+ });
+
final JLabel colour = new JLabel();
colour.setOpaque(true);
colour.setMaximumSize(new Dimension(30, 16));
group.setText(sf.getFeatureGroup());
start.setValue(new Integer(sf.getBegin()));
end.setValue(new Integer(sf.getEnd()));
+ ((SpinnerNumberModel) start.getModel()).setMaximum(sf.getEnd());
+ ((SpinnerNumberModel) end.getModel()).setMinimum(sf.getBegin());
SearchResultsI highlight = new SearchResults();
highlight.addResult(sequences.get(0), sf.getBegin(),
start.setValue(new Integer(firstFeature.getBegin()));
end.setValue(new Integer(firstFeature.getEnd()));
+ ((SpinnerNumberModel) start.getModel()).setMaximum(firstFeature.getEnd());
+ ((SpinnerNumberModel) end.getModel()).setMinimum(firstFeature.getBegin());
+
description.setText(firstFeature.getDescription());
featureColour = fr.getFeatureStyle(featureType);
oldColour = featureColour;
*/
public void showDialog()
{
- RunResponse okAction = forCreate ? getCreateAction() : getAmendAction();
- RunResponse cancelAction = getCancelAction();
+ Runnable okAction = forCreate ? getCreateAction() : getAmendAction();
+ Runnable cancelAction = getCancelAction();
/*
* set dialog action handlers for OK (create/Amend) and Cancel options
* also for Delete if applicable (when amending features)
*/
JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop)
- .response(okAction).response(cancelAction);
+ .setResponseHandler(0, okAction).setResponseHandler(2, cancelAction);
if (!forCreate)
{
- dialog.response(getDeleteAction());
+ dialog.setResponseHandler(1, getDeleteAction());
}
String title = null;
dialog.showInternalDialog(mainPanel, title,
JvOptionPane.YES_NO_CANCEL_OPTION,
- JvOptionPane.QUESTION_MESSAGE, null, options,
+ JvOptionPane.PLAIN_MESSAGE, null, options,
MessageManager.getString("action.ok"));
}
*
* @return
*/
- protected RunResponse getCancelAction()
+ protected Runnable getCancelAction()
{
- RunResponse okAction = new RunResponse(JvOptionPane.CANCEL_OPTION)
+ Runnable okAction = new Runnable()
{
@Override
public void run()
*
* @return
*/
- protected RunResponse getCreateAction()
+ protected Runnable getCreateAction()
{
- RunResponse okAction = new RunResponse(JvOptionPane.OK_OPTION)
+ Runnable okAction = new Runnable()
{
boolean useLastDefaults = features.get(0).getType() == null;
*
* @return
*/
- protected RunResponse getDeleteAction()
+ protected Runnable getDeleteAction()
{
- RunResponse deleteAction = new RunResponse(JvOptionPane.NO_OPTION)
+ Runnable deleteAction = new Runnable()
{
public void run()
{
*
* @return
*/
- protected RunResponse getAmendAction()
+ protected Runnable getAmendAction()
{
- RunResponse okAction = new RunResponse(JvOptionPane.OK_OPTION)
+ Runnable okAction = new Runnable()
{
boolean useLastDefaults = features.get(0).getType() == null;