import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
/**
* DOCUMENT ME!
featureIndex = 0;
final JPanel mainPanel = new JPanel(new BorderLayout());
+
final JTextField name = new JTextField(25);
- final JTextField source = new JTextField(25);
+ name.getDocument().addDocumentListener(new DocumentListener()
+ {
+ @Override
+ public void insertUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent e)
+ {
+ warnIfTypeHidden(mainPanel, name.getText());
+ }
+ });
+
+ final JTextField group = new JTextField(25);
+ group.getDocument().addDocumentListener(new DocumentListener()
+ {
+ @Override
+ public void insertUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent e)
+ {
+ warnIfGroupHidden(mainPanel, group.getText());
+ }
+ });
+
final JTextArea description = new JTextArea(3, 25);
final JSpinner start = new JSpinner();
final JSpinner end = new JSpinner();
{
if (fcc == null)
{
- final String type = features.get(featureIndex).getType();
+ final String ft = features.get(featureIndex).getType();
+ final String type = ft == null ? lastFeatureAdded : ft;
fcc = new FeatureColourChooser(me, type);
fcc.setRequestFocusEnabled(true);
fcc.requestFocus();
SequenceFeature sf = features.get(index);
name.setText(sf.getType());
description.setText(sf.getDescription());
- source.setText(sf.getFeatureGroup());
+ group.setText(sf.getFeatureGroup());
start.setValue(new Integer(sf.getBegin()));
end.setValue(new Integer(sf.getEnd()));
gridPanel.add(choosePanel);
}
- // ////////
- // ////////////////////////////////////
JPanel namePanel = new JPanel();
gridPanel.add(namePanel);
gridPanel.add(groupPanel);
groupPanel.add(new JLabel(MessageManager.getString("label.group:"),
JLabel.RIGHT));
- groupPanel.add(source);
+ groupPanel.add(group);
JPanel colourPanel = new JPanel();
gridPanel.add(colourPanel);
if (create)
{
name.setText(lastFeatureAdded);
- source.setText(lastFeatureGroupAdded);
+ group.setText(lastFeatureGroupAdded);
}
else
{
name.setText(firstFeature.getType());
- source.setText(firstFeature.getFeatureGroup());
+ group.setText(firstFeature.getFeatureGroup());
}
start.setValue(new Integer(firstFeature.getBegin()));
: MessageManager.formatMessage("label.amend_delete_features",
new String[] { sequences.get(0).getName() });
+ /*
+ * show the dialog
+ */
int reply = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
mainPanel, title, JvOptionPane.YES_NO_CANCEL_OPTION,
JvOptionPane.QUESTION_MESSAGE, null, options,
if (reply == JvOptionPane.OK_OPTION && name.getText().length() > 0)
{
lastFeatureAdded = name.getText().trim();
- lastFeatureGroupAdded = source.getText().trim();
+ lastFeatureGroupAdded = group.getText().trim();
lastDescriptionAdded = description.getText().replaceAll("\n", " ");
// TODO: determine if the null feature group is valid
if (lastFeatureGroupAdded.length() < 1)
if (reply == JvOptionPane.NO_OPTION)
{
+ /*
+ * NO_OPTION corresponds to the Delete button
+ */
sequences.get(0).getDatasetSequence().deleteFeature(sf);
+ // update Feature Settings for removal of feature / group
+ featuresAdded();
}
else if (reply == JvOptionPane.YES_OPTION)
{
+ /*
+ * YES_OPTION corresponds to the Amend button
+ */
+ boolean typeOrGroupChanged = (!lastFeatureAdded.equals(sf.type) || !lastFeatureGroupAdded
+ .equals(sf.featureGroup));
sf.type = lastFeatureAdded;
sf.featureGroup = lastFeatureGroupAdded;
sf.description = lastDescriptionAdded;
setColour(sf.type, fcol);
- getFeaturesDisplayed().setVisible(sf.type);
try
{
}
ffile.parseDescriptionHTML(sf, false);
+ if (typeOrGroupChanged)
+ {
+ featuresAdded();
+ }
}
}
else
ffile.parseDescriptionHTML(sf, false);
}
- if (lastFeatureGroupAdded != null)
- {
- setGroupVisibility(lastFeatureGroupAdded, true);
- }
setColour(lastFeatureAdded, fcol);
- setVisible(lastFeatureAdded);
- findAllFeatures(false);
+ featuresAdded();
alignPanel.paintAlignment(true);
}
/**
+ * Show a warning message if the entered type is one that is currently hidden
+ *
+ * @param panel
+ * @param type
+ */
+ protected void warnIfTypeHidden(JPanel panel, String type)
+ {
+ if (getRenderOrder().contains(type))
+ {
+ if (!showFeatureOfType(type))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.feature_type"), type);
+ JvOptionPane.showMessageDialog(panel, msg, "",
+ JvOptionPane.OK_OPTION);
+ }
+ }
+ }
+
+ /**
+ * Show a warning message if the entered group is one that is currently hidden
+ *
+ * @param panel
+ * @param group
+ */
+ protected void warnIfGroupHidden(JPanel panel, String group)
+ {
+ if (featureGroups.containsKey(group) && !featureGroups.get(group))
+ {
+ String msg = MessageManager.formatMessage("label.warning_hidden",
+ MessageManager.getString("label.group"), group);
+ JvOptionPane.showMessageDialog(panel, msg, "", JvOptionPane.OK_OPTION);
+ }
+ }
+
+ /**
* update the amend feature button dependent on the given style
*
* @param bigPanel