pullUpJMenuItem.setEnabled(s.canPullUp(i)); pushDownJMenuItem.setEnabled(s.canPushDown(i)); gotoStationJMenuItem.setEnabled(s.canSetGotoStation(i));
pullUpJMenuItem.setEnabled(i > 0); pushDownJMenuItem.setEnabled(s.getNumOrders() > i + 1); gotoStationJMenuItem.setEnabled(true);
	public void triggerPopup(MouseEvent e) {	    int i = orders.getSelectedIndex();	    MutableSchedule s = getSchedule();	    if(i >= s.getNumOrders()){		//The selected index does not exist!		//For some reason, the JList hasn't updated yet.		i = -1;	    }	    if(-1 != i) {		TrainOrdersModel order = s.getOrder(i);		pullUpJMenuItem.setEnabled(s.canPullUp(i));		pushDownJMenuItem.setEnabled(s.canPushDown(i));		gotoStationJMenuItem.setEnabled(s.canSetGotoStation(i));		removeWagonsJMenu.setEnabled(order.orderHasWagons());		waitJMenu.setEnabled(order.orderHasWagons());		addWagonJMenu.setEnabled(order.hasLessThanMaxiumNumberOfWagons());		setupWagonsPopup();		editOrderJPopupMenu.show(e.getComponent(), e.getX(),			e.getY());	    }	}