@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- coloursMenu.remove(radioItem);
- }
- else
+ offerRemoval(radioItem);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ coloursMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- user_actionPerformed(evt);
- }
- });
- }
+ user_actionPerformed(evt);
+ }
+ });
}
}
});
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+ offerRemoval(radioItem);
+ }
+ }
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ colourMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
}
}
});
{
getSelectedRow(evt.getY() - getScrollOffset());
oldY = evt.getY();
- if (!evt.isPopupTrigger())
+ if (evt.isPopupTrigger())
{
- return;
+ showPopupMenu(evt);
}
+ }
+
+ /**
+ * Build and show the Pop-up menu at the right-click mouse position
+ *
+ * @param evt
+ */
+ void showPopupMenu(MouseEvent evt)
+ {
evt.consume();
- // handle popup menu event
final AlignmentAnnotation[] aa = ap.av.getAlignment()
.getAlignmentAnnotation();
}
}
pop.show(this, evt.getX(), evt.getY());
-
}
/**
@Override
public void mouseReleased(MouseEvent evt)
{
+ if (evt.isPopupTrigger())
+ {
+ showPopupMenu(evt);
+ return;
+ }
+
int start = selectedRow;
getSelectedRow(evt.getY() - getScrollOffset());
int end = selectedRow;
int height = 0;
activeRow = -1;
+ final int y = evt.getY();
for (int i = 0; i < aa.length; i++)
{
if (aa[i].visible)
height += aa[i].height;
}
- if (evt.getY() < height)
+ if (y < height)
{
if (aa[i].editable)
{
{
// Stretch Graph
graphStretch = i;
- graphStretchY = evt.getY();
+ graphStretchY = y;
}
break;
if (evt.isPopupTrigger() && activeRow != -1)
{
- if (av.getColumnSelection() == null
- || av.getColumnSelection().isEmpty())
- {
- return;
- }
+ showPopupMenu(y, evt.getX());
+ return;
+ }
- JPopupMenu pop = new JPopupMenu(
- MessageManager.getString("label.structure_type"));
- JMenuItem item;
- /*
- * Just display the needed structure options
- */
- if (av.getAlignment().isNucleotide())
- {
- item = new JMenuItem(STEM);
- item.addActionListener(this);
- pop.add(item);
- }
- else
- {
- item = new JMenuItem(HELIX);
- item.addActionListener(this);
- pop.add(item);
- item = new JMenuItem(SHEET);
- item.addActionListener(this);
- pop.add(item);
- }
- item = new JMenuItem(LABEL);
+ ap.getScalePanel().mousePressed(evt);
+
+ }
+
+ /**
+ * Construct and display a context menu at the right-click position
+ *
+ * @param y
+ * @param x
+ */
+ void showPopupMenu(final int y, int x)
+ {
+ if (av.getColumnSelection() == null
+ || av.getColumnSelection().isEmpty())
+ {
+ return;
+ }
+
+ JPopupMenu pop = new JPopupMenu(
+ MessageManager.getString("label.structure_type"));
+ JMenuItem item;
+ /*
+ * Just display the needed structure options
+ */
+ if (av.getAlignment().isNucleotide())
+ {
+ item = new JMenuItem(STEM);
item.addActionListener(this);
pop.add(item);
- item = new JMenuItem(COLOUR);
+ }
+ else
+ {
+ item = new JMenuItem(HELIX);
item.addActionListener(this);
pop.add(item);
- item = new JMenuItem(REMOVE);
+ item = new JMenuItem(SHEET);
item.addActionListener(this);
pop.add(item);
- pop.show(this, evt.getX(), evt.getY());
-
- return;
}
-
- ap.getScalePanel().mousePressed(evt);
-
+ item = new JMenuItem(LABEL);
+ item.addActionListener(this);
+ pop.add(item);
+ item = new JMenuItem(COLOUR);
+ item.addActionListener(this);
+ pop.add(item);
+ item = new JMenuItem(REMOVE);
+ item.addActionListener(this);
+ pop.add(item);
+ pop.show(this, x, y);
}
/**
graphStretchY = -1;
mouseDragging = false;
ap.getScalePanel().mouseReleased(evt);
+
+ if (evt.isPopupTrigger() && activeRow != -1)
+ {
+ showPopupMenu(evt.getY(), evt.getX());
+ }
+
}
/**
@Override
public void textarea_mousePressed(MouseEvent e)
{
+ // isPopupTrigger is on mousePressed (Mac) or mouseReleased (Windows)
if (e.isPopupTrigger())
{
JPopupMenu popup = new JPopupMenu(
@Override
public void textarea_mousePressed(MouseEvent e)
{
+ /*
+ * isPopupTrigger is checked in mousePressed on Mac,
+ * in mouseReleased on Windows
+ */
if (e.isPopupTrigger())
{
JPopupMenu popup = new JPopupMenu(
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
+ {
+ showPasteMenu(evt.getX(), evt.getY());
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
{
showPasteMenu(evt.getX(), evt.getY());
}
public void mousePressed(MouseEvent evt)
{
selectedRow = table.rowAtPoint(evt.getPoint());
- boolean ctrlDown = Platform.isControlDown(evt);
- if (SwingUtilities.isRightMouseButton(evt) && !ctrlDown)
+ if (evt.isPopupTrigger())
{
popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0),
table.getValueAt(selectedRow, 1), fr.getMinMax(),
else if (evt.getClickCount() == 2)
{
boolean invertSelection = evt.isAltDown();
- boolean toggleSelection = ctrlDown;
+ boolean toggleSelection = Platform.isControlDown(evt);
boolean extendSelection = evt.isShiftDown();
fr.ap.alignFrame.avc.markColumnsContainingFeatures(
invertSelection, extendSelection, toggleSelection,
}
}
- // isPopupTrigger fires on mouseReleased on Mac
+ // isPopupTrigger fires on mouseReleased on Windows
@Override
public void mouseReleased(MouseEvent evt)
{
return;
}
- int seq = alignPanel.getSeqPanel().findSeq(e);
-
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // Mac reports this in mousePressed
{
- Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq);
- // build a new links menu based on the current links + any non-positional
- // features
- Vector<String> nlinks = new Vector<String>(
- Preferences.sequenceURLLinks);
- SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures();
- if (sfs != null)
- {
- for (SequenceFeature sf : sfs)
- {
- if (sf.begin == sf.end && sf.begin == 0)
- {
- if (sf.links != null && sf.links.size() > 0)
- {
- for (int l = 0, lSize = sf.links.size(); l < lSize; l++)
- {
- nlinks.addElement(sf.links.elementAt(l));
- }
- }
- }
- }
- }
-
- PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks,
- Preferences.getGroupURLLinks());
- pop.show(this, e.getX(), e.getY());
+ showPopupMenu(e);
return;
}
+
if ((av.getSelectionGroup() == null)
|| (!jalview.util.Platform.isControlDown(e)
&& !e.isShiftDown() && av.getSelectionGroup() != null))
av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
+ int seq = alignPanel.getSeqPanel().findSeq(e);
if (e.isShiftDown() && (lastid != -1))
{
selectSeqs(lastid, seq);
}
/**
+ * Build and show the popup-menu at the right-click mouse position
+ *
+ * @param e
+ */
+ void showPopupMenu(MouseEvent e)
+ {
+ int seq2 = alignPanel.getSeqPanel().findSeq(e);
+ Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2);
+ // build a new links menu based on the current links + any non-positional
+ // features
+ Vector<String> nlinks = new Vector<String>(
+ Preferences.sequenceURLLinks);
+ SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures();
+ if (sfs != null)
+ {
+ for (SequenceFeature sf : sfs)
+ {
+ if (sf.begin == sf.end && sf.begin == 0)
+ {
+ if (sf.links != null && sf.links.size() > 0)
+ {
+ for (int l = 0, lSize = sf.links.size(); l < lSize; l++)
+ {
+ nlinks.addElement(sf.links.elementAt(l));
+ }
+ }
+ }
+ }
+ }
+
+ PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks,
+ Preferences.getGroupURLLinks());
+ pop.show(this, e.getX(), e.getY());
+ }
+
+ /**
* Toggle whether the sequence is part of the current selection group.
*
* @param seq
PaintRefresher.Refresh(this, av.getSequenceSetId());
// always send selection message when mouse is released
av.sendSelection();
+
+ if (e.isPopupTrigger()) // Windows reports this in mouseReleased
+ {
+ showPopupMenu(e);
+ }
}
/**
@Override
public void mouseClicked(MouseEvent e)
{
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // for Windows
{
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
@Override
public void mousePressed(MouseEvent e)
{
- // TODO Auto-generated method stub
-
+ if (e.isPopupTrigger()) // Mac
+ {
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
+ }
}
@Override
public void mouseReleased(MouseEvent e)
{
- // TODO Auto-generated method stub
-
}
public void resetToDefault(boolean setDefaultParams)
@Override
public void mouseClicked(MouseEvent e)
{
- if (e.isPopupTrigger())
+ if (e.isPopupTrigger()) // for Windows
{
showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
@Override
public void mousePressed(MouseEvent e)
{
- // TODO Auto-generated method stub
-
+ if (e.isPopupTrigger()) // for Mac
+ {
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
+ }
}
@Override
min = res;
max = res;
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac: mousePressed
{
rightMouseButtonPressed(evt, res);
}
if (!stretchingGroup)
{
- ap.paintAlignment(false);
-
+ if (evt.isPopupTrigger()) // Windows: mouseReleased
+ {
+ rightMouseButtonPressed(evt, res);
+ }
+ else
+ {
+ ap.paintAlignment(false);
+ }
return;
}
mouseDragging = false;
mouseWheelPressed = false;
+ if (evt.isPopupTrigger()) // Windows: mouseReleased
+ {
+ showPopupMenu(evt);
+ evt.consume();
+ return;
+ }
+
if (!editingSeqs)
{
doMouseReleasedDefineMode(evt);
*/
public void doMousePressedDefineMode(MouseEvent evt)
{
- int res = findRes(evt);
- int seq = findSeq(evt);
+ final int res = findRes(evt);
+ final int seq = findSeq(evt);
oldSeq = seq;
startWrapBlock = wrappedBlock;
}
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac: mousePressed
{
- List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
- .findFeaturesAtRes(sequence.getDatasetSequence(),
- sequence.findPosition(res));
- List<String> links = new ArrayList<String>();
- for (SequenceFeature sf : allFeatures)
- {
- if (sf.links != null)
- {
- for (String link : sf.links)
- {
- links.add(link);
- }
- }
- }
-
- PopupMenu pop = new PopupMenu(ap, null, links);
- pop.show(this, evt.getX(), evt.getY());
+ showPopupMenu(evt);
return;
}
}
/**
+ * Build and show a pop-up menu at the right-click mouse position
+ *
+ * @param evt
+ * @param res
+ * @param sequence
+ */
+ void showPopupMenu(MouseEvent evt)
+ {
+ final int res = findRes(evt);
+ final int seq = findSeq(evt);
+ SequenceI sequence = av.getAlignment().getSequenceAt(seq);
+ List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
+ .findFeaturesAtRes(sequence.getDatasetSequence(),
+ sequence.findPosition(res));
+ List<String> links = new ArrayList<String>();
+ for (SequenceFeature sf : allFeatures)
+ {
+ if (sf.links != null)
+ {
+ for (String link : sf.links)
+ {
+ links.add(link);
+ }
+ }
+ }
+
+ PopupMenu pop = new PopupMenu(ap, null, links);
+ pop.show(this, evt.getX(), evt.getY());
+ }
+
+ /**
* DOCUMENT ME!
*
* @param evt
@Override
public void mousePressed(MouseEvent evt)
{
- if (evt.isPopupTrigger())
+ if (evt.isPopupTrigger()) // Mac
{
- radioItem.removeActionListener(radioItem.getActionListeners()[0]);
-
- int option = JOptionPane.showInternalConfirmDialog(
- jalview.gui.Desktop.desktop,
- MessageManager
- .getString("label.remove_from_default_list"),
- MessageManager
- .getString("label.remove_user_defined_colour"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- jalview.gui.UserDefinedColours
- .removeColourFromDefaults(radioItem.getText());
- colourMenu.remove(radioItem);
- }
- else
+ offerRemoval(radioItem);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent evt)
+ {
+ if (evt.isPopupTrigger()) // Windows
+ {
+ offerRemoval(radioItem);
+ }
+ }
+
+ /**
+ * @param radioItem
+ */
+ void offerRemoval(final JRadioButtonMenuItem radioItem)
+ {
+ radioItem.removeActionListener(radioItem.getActionListeners()[0]);
+
+ int option = JOptionPane.showInternalConfirmDialog(
+ jalview.gui.Desktop.desktop,
+ MessageManager
+ .getString("label.remove_from_default_list"),
+ MessageManager
+ .getString("label.remove_user_defined_colour"),
+ JOptionPane.YES_NO_OPTION);
+ if (option == JOptionPane.YES_OPTION)
+ {
+ jalview.gui.UserDefinedColours
+ .removeColourFromDefaults(radioItem.getText());
+ colourMenu.remove(radioItem);
+ }
+ else
+ {
+ radioItem.addActionListener(new ActionListener()
{
- radioItem.addActionListener(new ActionListener()
+ @Override
+ public void actionPerformed(ActionEvent evt)
{
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- userDefinedColour_actionPerformed(evt);
- }
- });
- }
+ userDefinedColour_actionPerformed(evt);
+ }
+ });
}
}
});
@Override
public void mousePressed(MouseEvent e)
{
- tabbedPane_mousePressed(e);
+ if (e.isPopupTrigger()) // Mac
+ {
+ tabbedPane_mousePressed(e);
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ if (e.isPopupTrigger()) // Windows
+ {
+ tabbedPane_mousePressed(e);
+ }
}
});
tabbedPane.addFocusListener(new FocusAdapter()
ok.setText(MessageManager.getString("label.new_window"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
cancel.setText(MessageManager.getString("action.close"));
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
close.setText(MessageManager.getString("action.close"));
close.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
selectAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
selectAll_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
save.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save_actionPerformed(e);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
textarea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
textarea_mousePressed(e);
}
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ textarea_mousePressed(e);
+ }
});
editMenu.setText(MessageManager.getString("action.edit"));
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyItem_actionPerformed(e);
ok.setText(MessageManager.getString("label.new_window"));
ok.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
cancel.setText(MessageManager.getString("action.close"));
cancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
selectAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
selectAll_actionPerformed(e);
.getMenuShortcutKeyMask(), false));
save.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
save_actionPerformed(e);
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12));
textarea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
- textarea_mousePressed(e);
+ textarea_mousePressed(e); // on Mac
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ textarea_mousePressed(e); // on Windows
}
});
editMenu.setText(MessageManager.getString("action.edit"));
pasteMenu.setText(MessageManager.getString("action.paste"));
pasteMenu.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
pasteMenu_actionPerformed(e);
copyItem.setText(MessageManager.getString("action.copy"));
copyItem.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
copyItem_actionPerformed(e);