use of javax.swing.JPopupMenu in project knime-core by knime.
the class AbstractPlotter method showPopupMenu.
/* ---------- relevant mouse methods ----------- */
/**
* Calls the {@link #fillPopupMenu(JPopupMenu)} and then shows the popup
* menu at the position of the mouse click.
*/
private void showPopupMenu(final Point at) {
m_drawingPane.setMouseDown(false);
m_isDragged = false;
JPopupMenu menu = new JPopupMenu();
fillPopupMenu(menu);
if (menu.isEnabled()) {
menu.show(m_drawingPane, (int) at.getX(), (int) at.getY());
}
return;
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class Axis method createPopupMenu.
private JPopupMenu createPopupMenu() {
if (getCoordinate() == null) {
return null;
}
m_currFormat = NORMAL;
JPopupMenu popupMenu = new JPopupMenu();
createNotationMenu(popupMenu);
// policies
if (m_coordinate != null) {
List<PolicyStrategy> strategies = new LinkedList<PolicyStrategy>();
Set<PolicyStrategy> policies = m_coordinate.getCompatiblePolicies();
if (policies != null) {
strategies.addAll(policies);
Collections.sort(strategies, new Comparator<PolicyStrategy>() {
/**
* {@inheritDoc}
*/
@Override
public int compare(final PolicyStrategy o1, final PolicyStrategy o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
}
JMenu tickPolicyMenu = new JMenu("Tick policies");
ButtonGroup tickPolicyButtons = new ButtonGroup();
if (strategies.size() > 0) {
popupMenu.add(tickPolicyMenu);
for (PolicyStrategy strategy : strategies) {
final PolicyStrategy tempStrategy = strategy;
JRadioButtonMenuItem tickPolicy = new JRadioButtonMenuItem(strategy.getDisplayName());
tickPolicyButtons.add(tickPolicy);
tickPolicyMenu.add(tickPolicy);
if (strategy.equals(m_coordinate.getCurrentPolicy())) {
tickPolicy.setSelected(true);
}
tickPolicy.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setPolicy(tempStrategy);
// recreate popup menu
setComponentPopupMenu(createPopupMenu());
if (tempStrategy.isMappingAllowed()) {
m_mappingMethodMenu.setEnabled(true);
m_notationsMenu.setEnabled(true);
} else {
// hide mapping methods
m_mappingMethodMenu.setEnabled(false);
m_notationsMenu.setEnabled(false);
if (getCoordinate() != null) {
getCoordinate().setActiveMappingMethod(null);
}
}
notifyChangeListeners();
}
}
});
}
}
// add strategies
Set<MappingMethod> mappingMethods = m_coordinate.getCompatibleMappingMethods();
m_mappingMethodMenu = new JMenu("Mapping Methods");
if (mappingMethods != null && mappingMethods.size() > 0) {
popupMenu.add(m_mappingMethodMenu);
ButtonGroup buttons = new ButtonGroup();
final Map<MappingMethod, JRadioButtonMenuItem> checkboxes = new HashMap<MappingMethod, JRadioButtonMenuItem>();
JRadioButtonMenuItem none = new JRadioButtonMenuItem("none", true);
buttons.add(none);
none.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(null);
notifyChangeListeners();
}
}
});
m_mappingMethodMenu.add(none);
for (MappingMethod method : mappingMethods) {
// final needed
final MappingMethod tempMethod = method;
JRadioButtonMenuItem checkbox = new JRadioButtonMenuItem(method.getDisplayName(), false);
checkbox.setEnabled(method.isCompatibleWithDomain(getCoordinate().getDomain()));
checkboxes.put(method, checkbox);
buttons.add(checkbox);
if (method.equals(m_coordinate.getActiveMappingMethod())) {
checkbox.setSelected(true);
}
checkbox.addItemListener(new ItemListener() {
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
m_coordinate.setActiveMappingMethod(tempMethod);
}
notifyChangeListeners();
}
});
m_mappingMethodMenu.add(checkbox);
}
for (Map.Entry<MappingMethod, JRadioButtonMenuItem> entry : checkboxes.entrySet()) {
if (entry.getKey().isCompatibleWithDomain(getCoordinate().getDomain())) {
entry.getValue().setEnabled(true);
}
}
}
}
if (popupMenu.getComponentCount() < 1) {
return null;
}
return popupMenu;
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class ClusterNodeView method openPopupMenu.
private void openPopupMenu(final MouseEvent e) {
JPopupMenu menu = new JPopupMenu();
JMenuItem item = new JMenuItem(HILITE);
item.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent arg0) {
getNodeModel().getHiLiteHandler().fireHiLiteEvent(m_selected);
}
});
menu.add(item);
item = new JMenuItem(UNHILITE);
item.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent arg0) {
getNodeModel().getHiLiteHandler().fireUnHiLiteEvent(m_selected);
}
});
menu.add(item);
item = new JMenuItem(UNHILITE_ALL);
item.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent arg0) {
getNodeModel().getHiLiteHandler().fireClearHiLiteEvent();
}
});
menu.add(item);
menu.show(e.getComponent(), e.getX(), e.getY());
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class DnDColumnSelectionSearchableListPanel method enableDragAndDropSupport.
/**
* Convenient method to enable the drag and drop support of the list view at the left side.
*
* @param dndStateListener notified if drag is started and finished
* @since 2.11
*/
public void enableDragAndDropSupport(final DnDStateListener dndStateListener) {
ColumnSelectionList columnList = getColumnList();
columnList.setDragEnabled(true);
JPopupMenu popup = new JPopupMenu();
final JMenuItem jMenuItem = new JMenuItem("New Configuration", DnDConfigurationPanel.ADD_ICON_16);
popup.add(jMenuItem);
popup.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(final PopupMenuEvent e) {
boolean enable = true;
for (DataColumnSpec col : getSelectedColumns()) {
if (m_configuredColumnDeterminer.isConfiguredColumn(col)) {
enable = false;
break;
}
}
jMenuItem.setEnabled(enable);
}
@Override
public void popupMenuWillBecomeInvisible(final PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(final PopupMenuEvent e) {
}
});
jMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
fireConfigurationRequested(Type.CREATION);
}
});
columnList.setComponentPopupMenu(popup);
final TransferHandler handler = columnList.getTransferHandler();
columnList.setTransferHandler(new DnDColumnSpecSourceTransferHandler(handler, dndStateListener) {
@Override
protected List<DataColumnSpec> getColumnsSpecsToDrag() {
return getSelectedColumns();
}
});
}
use of javax.swing.JPopupMenu in project knime-core by knime.
the class DBDataTypeAggregationFunctionPanel method createTablePopupMenu.
/**
* {@inheritDoc}
*/
@Override
protected JPopupMenu createTablePopupMenu() {
final JPopupMenu menu = new JPopupMenu();
final JMenuItem invalidRowsMenu = createInvalidRowsSelectionMenu();
if (invalidRowsMenu != null) {
menu.add(invalidRowsMenu);
menu.addSeparator();
}
createColumnSelectionMenu(menu);
menu.addSeparator();
createAggregationSection(menu);
return menu;
}
Aggregations