use of jmri.jmrit.display.LinkingObject in project JMRI by JMRI.
the class ControlPanelEditor method showPopUp.
/**
* Create popup for a Positionable object Popup items common to all
* positionable objects are done before and after the items that pertain
* only to specific Positionable types.
*/
@Override
protected void showPopUp(Positionable p, MouseEvent event) {
if (!((JComponent) p).isVisible()) {
// component must be showing on the screen to determine its location
return;
}
JPopupMenu popup = new JPopupMenu();
PositionablePopupUtil util = p.getPopupUtility();
if (p.isEditable()) {
// items common to all
if (p.doViemMenu()) {
popup.add(p.getNameString());
setPositionableMenu(p, popup);
if (p.isPositionable()) {
setShowCoordinatesMenu(p, popup);
setShowAlignmentMenu(p, popup);
}
setDisplayLevelMenu(p, popup);
setHiddenMenu(p, popup);
popup.addSeparator();
setCopyMenu(p, popup);
}
// items with defaults or using overrides
boolean popupSet = false;
// popupSet |= p.setRotateOrthogonalMenu(popup);
popupSet |= p.setRotateMenu(popup);
popupSet |= p.setScaleMenu(popup);
if (popupSet) {
popup.addSeparator();
popupSet = false;
}
popupSet = p.setEditItemMenu(popup);
if (popupSet) {
popup.addSeparator();
popupSet = false;
}
if (p instanceof PositionableLabel) {
PositionableLabel pl = (PositionableLabel) p;
/* if (pl.isIcon() && "javax.swing.JLabel".equals(pl.getClass().getSuperclass().getName()) ) {
popupSet |= setTextAttributes(pl, popup); // only for plain icons
} Add backgrounds & text over icons later */
if (!pl.isIcon()) {
popupSet |= setTextAttributes(pl, popup);
if (p instanceof MemoryIcon) {
popupSet |= p.setTextEditMenu(popup);
}
} else if (p instanceof SensorIcon) {
popup.add(CoordinateEdit.getTextEditAction(p, "OverlayText"));
if (pl.isText()) {
popupSet |= setTextAttributes(p, popup);
}
} else {
popupSet = p.setTextEditMenu(popup);
}
} else if (p instanceof PositionableJPanel) {
popupSet |= setTextAttributes(p, popup);
}
if (p instanceof LinkingObject) {
((LinkingObject) p).setLinkMenu(popup);
}
if (popupSet) {
popup.addSeparator();
popupSet = false;
}
p.setDisableControlMenu(popup);
if (util != null) {
util.setAdditionalEditPopUpMenu(popup);
}
// for Positionables with unique settings
p.showPopUp(popup);
if (p.doViemMenu()) {
setShowTooltipMenu(p, popup);
setRemoveMenu(p, popup);
}
} else {
if (p instanceof LocoIcon) {
setCopyMenu(p, popup);
}
p.showPopUp(popup);
if (util != null) {
util.setAdditionalViewPopUpMenu(popup);
}
}
popup.show((Component) p, p.getWidth() / 2 + (int) ((getPaintScale() - 1.0) * p.getX()), p.getHeight() / 2 + (int) ((getPaintScale() - 1.0) * p.getY()));
_currentSelection = null;
}
Aggregations