fr = alignPanel.getSeqPanel().seqCanvas.fr;
}
+ public void amendFeatures(final List<SequenceI> sequences,
+ final List<SequenceFeature> features,
+ final Runnable responseHandler)
+ {
+ amendFeatures(sequences, features, false, responseHandler);
+ }
+
+ public void createFeatures(final List<SequenceI> sequences,
+ final List<SequenceFeature> features,
+ final Runnable responseHandler)
+ {
+ amendFeatures(sequences, features, true, responseHandler);
+ }
+
/**
* Presents a dialog allowing the user to add new features, or amend or delete
* existing features. Currently this can be on
* @param responseHandler
* boolean true RunResponse is run if features are created
*/
- public boolean amendFeatures(final List<SequenceI> sequences,
+ private void amendFeatures(final List<SequenceI> sequences,
final List<SequenceFeature> features, boolean create,
final Runnable responseHandler)
{
featureIndex = 0;
-
+
final JPanel mainPanel = new JPanel(new BorderLayout());
-
+
final JTextField name = new JTextField(25);
name.getDocument().addDocumentListener(new DocumentListener()
{
{
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()
{
{
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();
*/
final String ft = features.get(featureIndex).getType();
final String type = ft == null ? lastFeatureAdded : ft;
- FeatureTypeSettings fcc = new FeatureTypeSettings(
- fr, type);
+ FeatureTypeSettings fcc = new FeatureTypeSettings(fr, type);
fcc.setRequestFocusEnabled(true);
fcc.requestFocus();
fcc.addActionListener(new ActionListener()
}
});
JPanel gridPanel = new JPanel(new GridLayout(3, 1));
-
+
if (!create && features.size() > 1)
{
/*
added.add(text);
}
choosePanel.add(overlaps);
-
+
overlaps.addItemListener(new ItemListener()
{
@Override
group.setText(sf.getFeatureGroup());
start.setValue(new Integer(sf.getBegin()));
end.setValue(new Integer(sf.getEnd()));
-
+
SearchResultsI highlight = new SearchResults();
highlight.addResult(sequences.get(0), sf.getBegin(),
sf.getEnd());
-
- ap.getSeqPanel().seqCanvas
- .highlightSearchResults(highlight, false);
+
+ ap.getSeqPanel().seqCanvas.highlightSearchResults(highlight,
+ false);
}
FeatureColourI col = fr.getFeatureStyle(name.getText());
if (col == null)
updateColourButton(mainPanel, colour, col);
}
});
-
+
gridPanel.add(choosePanel);
}
-
+
JPanel namePanel = new JPanel();
gridPanel.add(namePanel);
namePanel.add(new JLabel(MessageManager.getString("label.name:"),
JLabel.RIGHT));
namePanel.add(name);
-
+
JPanel groupPanel = new JPanel();
gridPanel.add(groupPanel);
groupPanel.add(new JLabel(MessageManager.getString("label.group:"),
JLabel.RIGHT));
groupPanel.add(group);
-
+
JPanel colourPanel = new JPanel();
gridPanel.add(colourPanel);
colourPanel.add(new JLabel(MessageManager.getString("label.colour"),
colour.setHorizontalTextPosition(SwingConstants.CENTER);
colour.setVerticalTextPosition(SwingConstants.CENTER);
mainPanel.add(gridPanel, BorderLayout.NORTH);
-
+
JPanel descriptionPanel = new JPanel();
descriptionPanel.add(new JLabel(
MessageManager.getString("label.description:"), JLabel.RIGHT));
description.setFont(JvSwingUtils.getTextAreaFont());
description.setLineWrap(true);
descriptionPanel.add(new JScrollPane(description));
-
+
if (!create)
{
mainPanel.add(descriptionPanel, BorderLayout.SOUTH);
-
+
JPanel startEndPanel = new JPanel();
startEndPanel.add(new JLabel(MessageManager.getString("label.start"),
JLabel.RIGHT));
{
mainPanel.add(descriptionPanel, BorderLayout.CENTER);
}
-
+
/*
* default feature type and group to that of the first feature supplied,
* or to the last feature created if not supplied (null value)
: firstFeature.getFeatureGroup();
name.setText(featureType);
group.setText(featureGroup);
-
+
start.setValue(new Integer(firstFeature.getBegin()));
end.setValue(new Integer(firstFeature.getEnd()));
description.setText(firstFeature.getDescription());
options = new Object[] { MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") };
}
-
+
String title = create
? MessageManager.getString("label.create_new_sequence_features")
: MessageManager.formatMessage("label.amend_delete_features",
new String[]
{ sequences.get(0).getName() });
-
+
/*
* register responses and show the dialog
*/
JvOptionPane.newOptionDialog(Desktop.desktop).response(
-
+
new RunResponse(JvOptionPane.OK_OPTION)
{
public void run()
final String enteredDescription = description.getText()
.replaceAll("\n", " ");
if (enteredType.length() > 0)
-
+
{
/*
* update default values only if creating using default values
}
}
}
-
+
if (create)
{
// NEW FEATURES ADDED
new FeaturesFile().parseDescriptionHTML(sf2, false);
sequences.get(i).addSequenceFeature(sf2);
}
-
+
fr.setColour(enteredType, featureColour);
-
+
fr.featuresAdded();
-
+
responseHandler.run();
}
- } else {
+ }
+ else
+ {
SequenceFeature sf = features.get(featureIndex);
/*
* Feature amended - YES_OPTION corresponds to the Amend button
* note we don't force the feature to be visible - the user has been
* warned if a hidden feature type or group was entered
*/
- boolean refreshSettings = (!featureType.equals(enteredType)
+ boolean refreshSettings = (!featureType
+ .equals(enteredType)
|| !featureGroup.equals(enteredGroup));
refreshSettings |= (featureColour != oldColour);
fr.setColour(enteredType, featureColour);
{
// JSpinner doesn't accept invalid format data :-)
}
-
+
/*
* replace the feature by deleting it and adding a new one
* (to ensure integrity of SequenceFeatures data store)
*/
sequences.get(0).deleteFeature(sf);
- SequenceFeature newSf = new SequenceFeature(sf, enteredType,
- newBegin, newEnd, enteredGroup, sf.getScore());
+ SequenceFeature newSf = new SequenceFeature(sf,
+ enteredType, newBegin, newEnd, enteredGroup,
+ sf.getScore());
newSf.setDescription(enteredDescription);
new FeaturesFile().parseDescriptionHTML(newSf, false);
// amend features dialog only updates one sequence at a time
sequences.get(0).addSequenceFeature(newSf);
-
+
if (refreshSettings)
{
fr.featuresAdded();
}
}
+
ap.getSeqPanel().seqCanvas.highlightSearchResults(null,
false);
ap.paintAlignment(true, true);
JvOptionPane.YES_NO_CANCEL_OPTION,
JvOptionPane.QUESTION_MESSAGE, null, options,
MessageManager.getString("action.ok"));
- return true;
}
/**
colour.setIcon(null);
colour.setToolTipText(null);
colour.setText("");
-
+
if (col.isSimpleColour())
{
colour.setBackground(col.getColour());