use of javax.swing.JPopupMenu in project MassBank-web by MassBank.
the class SearchPage method recListPopup.
/**
* ���R�[�h���X�g�p�|�b�v�A�b�v�\��
* @param e �}�E�X�C�x���g
*/
private void recListPopup(MouseEvent e) {
JTable tbl = null;
JScrollPane pane = null;
try {
tbl = (JTable) e.getSource();
} catch (ClassCastException cce) {
pane = (JScrollPane) e.getSource();
if (pane.equals(queryDbPane)) {
tbl = queryDbTable;
} else if (pane.equals(resultPane)) {
tbl = resultTable;
}
if (pane.equals(queryFilePane)) {
tbl = queryFileTable;
}
}
int rowCnt = tbl.getSelectedRows().length;
JMenuItem item1 = new JMenuItem("Show Record");
item1.addActionListener(new PopupShowRecordListener(tbl));
JMenuItem item2 = new JMenuItem("Multiple Display");
item2.addActionListener(new PopupMultipleDisplayListener(tbl));
// ���ݒ�
if (tbl.equals(queryFileTable)) {
item1.setEnabled(false);
item2.setEnabled(false);
} else if (rowCnt == 0) {
item1.setEnabled(false);
item2.setEnabled(false);
} else if (rowCnt == 1) {
item1.setEnabled(true);
item2.setEnabled(false);
} else if (rowCnt > 1) {
item1.setEnabled(false);
item2.setEnabled(true);
}
// �|�b�v�A�b�v���j���[�\��
JPopupMenu popup = new JPopupMenu();
popup.add(item1);
if (tbl.equals(resultTable)) {
popup.add(item2);
}
popup.show(e.getComponent(), e.getX(), e.getY());
}
use of javax.swing.JPopupMenu in project MassBank-web by MassBank.
the class ShowMass method mouseClicked.
/**
* mouseClicked����
* @param e mouseClicked�C�x���g
*/
public void mouseClicked(MouseEvent e) {
// ���N���b�N�̏ꍇ
if (SwingUtilities.isLeftMouseButton(e)) {
// �_�u���N���b�N�̏ꍇ
if (e.getClickCount() >= 2) {
// �I�����ꂽ�S�Ă̒l�̃p�X���擾
TreePath[] paths = BrowsePage.tree.getSelectionPaths();
if (paths == null || paths.length > 1) {
return;
}
// �I�����ꂽ�X�y�N�g�����̎擾
DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent();
if (node instanceof LeafNode) {
LeafNode leaf = (LeafNode) node;
String accs = (leaf.acc != null) ? leaf.acc : "";
try {
String typeName = MassBankCommon.CGI_TBL[MassBankCommon.CGI_TBL_NUM_TYPE][MassBankCommon.CGI_TBL_TYPE_DISP];
String reqStr = BrowsePage.baseUrl + MassBankCommon.DISPATCHER_NAME + "?type=" + typeName + "&id=" + accs;
reqStr += "&site=" + BrowsePage.site;
URL url = new URL(reqStr);
BrowsePage.applet.getAppletContext().showDocument(url, "_blank");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
// �E�N���b�N�̏ꍇ
} else if (SwingUtilities.isRightMouseButton(e)) {
// �I�����ꂽ�S�Ă̒l�̃p�X���擾
TreePath[] paths = BrowsePage.tree.getSelectionPaths();
if (paths == null) {
return;
}
// �I�����ꂽ�X�y�N�g�����̎擾
int l = paths.length;
ArrayList<String> accs = new ArrayList<String>();
ArrayList<String> names = new ArrayList<String>();
int num = 0;
for (int i = 0; i < l; i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
if (node instanceof LeafNode) {
LeafNode leaf = (LeafNode) node;
names.add(leaf.name);
accs.add(leaf.acc);
num++;
}
}
// �t�m�[�h��1���I������Ă��Ȃ��ꍇ
if (num == 0) {
return;
}
// �|�b�v�A�b�v���j���[�쐬
JPopupMenu popup = new JPopupMenu();
JMenuItem item1 = new JMenuItem("Show Record");
JMenuItem item2 = new JMenuItem("Multiple Display");
popup.add(item1);
popup.add(item2);
// �I���s��1�s�̏ꍇ
if (num == 1) {
item1.addActionListener(new PopupEntryListener(accs.get(0)));
item1.setEnabled(true);
item2.setEnabled(false);
} else // �I���s�������̏ꍇ
if (num > 1) {
item2.addActionListener(new PopupMultipleDisplayListener((String[]) accs.toArray(new String[accs.size()]), (String[]) names.toArray(new String[names.size()])));
item1.setEnabled(false);
item2.setEnabled(true);
}
// �|�b�v�A�b�v���j���[�\��
if (num > 0) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
use of javax.swing.JPopupMenu in project MassBank-web by MassBank.
the class PlotPane method mouseClicked.
/**
* �}�E�X�N���b�N�C�x���g
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
public void mouseClicked(MouseEvent e) {
if (timer != null && timer.isRunning()) {
return;
}
// ���N���b�N�̏ꍇ
if (SwingUtilities.isLeftMouseButton(e)) {
// �N���b�N�Ԋu�Z�o
long interSec = (e.getWhen() - lastClickedTime);
lastClickedTime = e.getWhen();
// �_�u���N���b�N�̏ꍇ�i�N���b�N�Ԋu280�~���b�ȓ��j
if (interSec <= 280) {
fromPos = toPos = null;
initMass();
} else // �V���O���N���b�N�̏ꍇ
{
// �}�E�X�N���b�N�|�C���g
Point p = e.getPoint();
ArrayList<Integer> tmpClickPeakList = new ArrayList<Integer>();
int height = getHeight();
float yscale = (height - 2.0f * MARGIN) / intensityRange;
int start, end, its, tmpX, tmpY, tmpWidth, tmpHight;
double mz;
start = peaks1.getIndex(massStart);
end = peaks1.getIndex(massStart + massRange);
for (int i = start; i < end; i++) {
mz = peaks1.getMz(i);
its = peaks1.getIntensity(i);
tmpX = MARGIN + (int) ((mz - massStart) * xscale) - // Peak�`��n�_�iX���W�j
(int) Math.floor(xscale / 8);
// Peak�`��n�_�iY���W�j
tmpY = height - MARGIN - (int) (its * yscale);
// �n�_����̕�
tmpWidth = (int) (xscale / 8);
// �n�_����̍���
tmpHight = (int) (its * yscale);
if (MARGIN > tmpX) {
tmpWidth = tmpWidth - (MARGIN - tmpX);
tmpX = MARGIN;
}
if (tmpWidth < 2) {
tmpWidth = 2;
} else if (tmpWidth < 3) {
tmpWidth = 3;
}
// �}�E�X�_�E�������ꏊ�iX/Y���W�j��Peak�̕`��G���A�Ɋ܂܂�Ă��邩��
if (tmpX <= p.getX() && p.getX() <= (tmpX + tmpWidth) && tmpY <= p.getY() && p.getY() <= (tmpY + tmpHight)) {
tmpClickPeakList.add(i);
}
}
// �}�E�X�N���b�N�Ɠ�����Peak�̐F��ύX����
if (tmpClickPeakList.size() == 1) {
int index = tmpClickPeakList.get(0);
if (!peaks1.isSelectPeakFlag(index)) {
if (peaks1.getSelectPeakNum() < MassBankCommon.PEAK_SEARCH_PARAM_NUM) {
// �I����Ԃ�ݒ�
selectPeakList.add(String.valueOf(peaks1.getMz(index)));
peaks1.setSelectPeakFlag(index, true);
} else {
JOptionPane.showMessageDialog(PlotPane.this, " m/z of " + MassBankCommon.PEAK_SEARCH_PARAM_NUM + " peak or more cannot be selected. ", "Warning", JOptionPane.WARNING_MESSAGE);
cursorPoint = new Point();
}
} else if (peaks1.isSelectPeakFlag(index)) {
// �I����Ԃ�����
selectPeakList.remove(String.valueOf(peaks1.getMz(index)));
peaks1.setSelectPeakFlag(index, false);
}
PlotPane.this.repaint();
} else // �}�E�X�N���b�N�Ɠ����Ƀ|�b�v�A�b�v���j���[��\������
if (tmpClickPeakList.size() >= 2) {
// �|�b�v�A�b�v���j���[�C���X�^���X����
selectPopup = new JPopupMenu();
JMenuItem item = null;
int index = -1;
// �|�b�v�A�b�v���j���[�lj�
for (int i = 0; i < tmpClickPeakList.size(); i++) {
index = tmpClickPeakList.get(i);
item = new JMenuItem(String.valueOf(peaks1.getMz(index)));
selectPopup.add(item);
item.addActionListener(new SelectMZPopupListener(index));
if (peaks1.getSelectPeakNum() >= MassBankCommon.PEAK_SEARCH_PARAM_NUM && !peaks1.isSelectPeakFlag(index)) {
// Peak�I�𐔂�MAX�̏ꍇ�A�I���ς�Peak�ȊO�͑I��s��ݒ�
item.setEnabled(false);
}
}
// �|�b�v�A�b�v���j���[�\��
selectPopup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class DialogComponentDateTimeSelection method setPopupProperty.
private void setPopupProperty(final JDateChooser dateChooser) {
try {
// Java will fetch a static field that is public, if you
// declare it to be non-static or give it the wrong scope, it
// automatically retrieves the static field from a super
// class/interface (from which super interface it gets it,
// depends pretty much on the order after the "extends ..."
// statement) If this field has the wrong type, a coding
// problem is reported.
final Field typeField = JDateChooser.class.getDeclaredField("popup");
typeField.setAccessible(true);
((JPopupMenu) typeField.get(dateChooser)).setFocusable(false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class NodeDialogPane method noLightWeight.
/*
* Converts the specified and all its parent Component object to no-light
* weight components if they are of type JComboBox, JPopupMenu, or
* BasicComboPopup.
*/
private static void noLightWeight(final Component c) {
if (c instanceof Container) {
if (c instanceof JComboBox) {
JComboBox cb = (JComboBox) c;
cb.setLightWeightPopupEnabled(false);
}
if (c instanceof JPopupMenu) {
JPopupMenu pm = (JPopupMenu) c;
pm.setLightWeightPopupEnabled(false);
}
if (c instanceof BasicComboPopup) {
BasicComboPopup cp = (BasicComboPopup) c;
cp.setLightWeightPopupEnabled(false);
}
Container o = (Container) c;
for (int cnt = o.getComponentCount(); --cnt >= 0; ) {
Component newComponent = o.getComponent(cnt);
noLightWeight(newComponent);
}
}
}
Aggregations