public void show(Component invoker, int x, int y) { ViperViewMediator mediator = getMediator(); Point pnt = new Point(x, y); EnhancedTable tab = getTable(); int row = tab.rowAtPoint(pnt); desc = getCurrentModel().getDescriptorAtRow(row); int col = tab.columnAtPoint(pnt); Object cellValue = tab.getValueAt(row, col); if (cellValue instanceof Attribute) { attr = (Attribute) cellValue; // hide the "Occlusions..." option when we're not dealing with a Textline object boolean isTextline = attr.getAttrConfig().getAttrType().endsWith("textline"); occlusions.setVisible(isTextline); occSeparator.setVisible(isTextline); Instant now = mediator.getCurrentFrame(); if (now == null) { mediator.getDisplayWRTManager().setAttribute(null, null); wrt.setEnabled(false); wrt.setSelected(false); } else { boolean isDwrt = attr == mediator.getDisplayWRTManager().getAttribute(); boolean dwrtable = (attr.getAttrValueAtInstant(now) instanceof HasCentroid && attr.getDescriptor().getValidRange().contains(now)); wrt.setEnabled(dwrtable); wrt.setSelected(isDwrt); } } else { attr = null; wrt.setEnabled(false); wrt.setSelected(false); } if (null != desc) { PropagateInterpolateModule proper = getMediator().getPropagator(); p.setSelected(proper.isPropagatingThis(desc)); v.setSelected(mediator.isThisValidNow(desc)); resetMarks(); super.show(invoker, x, y); } }
private void showPopup() { if (isEnabled()) { if (popup.isVisible()) { popup.setVisible(false); } else { Component[] components = popup.getComponents(); if (components != null) { for (int i = 0; i < components.length; i++) { if (components[i] instanceof Item) ((Item) components[i]).removeActionListener(this); else if (components[i] instanceof MenuItem) { Component[] subcomponents = ((MenuItem) components[i]).getComponents(); for (int j = 0; j < components.length; j++) { if (components[j] instanceof Item) ((Item) components[j]).removeActionListener(this); } } } } popup.removeAll(); if (values == null) return; for (int i = 0; i < values.length; i++) { JMenuItem item = null; if (values[i] instanceof ListDescriptor) { ListDescriptor descriptor = (ListDescriptor) values[i]; Icon icon = descriptor.getIcon(); item = new Item(values[i].toString(), icon, i); item.addActionListener(this); } else if (values[i] instanceof AddElement) { AddElement element = (AddElement) values[i]; Icon icon = element.getIcon(); Object[] choiceValues = element.getChoiceValues(); if (choiceValues != null) { item = new MenuItem(element.toString(), icon, i); for (int j = 0; j < choiceValues.length; j++) { if (choiceValues[j] == null) { ((JMenu) item).addSeparator(); continue; } Item subItem = new Item(choiceValues[j].toString(), j); ((JMenu) item).add(subItem); subItem.setParentIndex(i); subItem.addActionListener(this); } } else { item = new Item(element.toString(), icon, i); item.addActionListener(this); } item.setVisible(element.isVisible()); item.setEnabled(element.isEnabled()); } else { if (values[i] != null) { item = new Item(values[i].toString(), i); item.addActionListener(this); } } if (item != null) { popup.add(item); } else popup.addSeparator(); } SwingUtilities.invokeLater( new Runnable() { public void run() { AwtUtil.showPopupPanel(PopupMenuButton.this, popup); } }); } } }