if (desktop.getSelectedFrame() instanceof PatchBasket && (!(desktop.getSelectedFrame() instanceof PatchEditorFrame))) { if (desktop.getSelectedFrame() instanceof LibraryFrame && ((LibraryFrame) ((desktop.getSelectedFrame()))).table.getSelectedRowCount() == 0)
if (JSLDesktop.getSelectedFrame() instanceof PatchBasket && (!(JSLDesktop.getSelectedFrame() instanceof PatchEditorFrame))) { if (JSLDesktop.getSelectedFrame() instanceof LibraryFrame && ((LibraryFrame) ((JSLDesktop.getSelectedFrame()))).table.getSelectedRowCount() == 0)
    private static void beginEcho() {        echoTimer = new javax.swing.Timer(5, new ActionListener() {		public void actionPerformed(ActionEvent evt) {		    try {			//FIXME there is a bug in the javaMIDI classes			//so this routine gets the input messages from			//the faderbox as well as the master			//controller. I cant figure out a way to fix			//it so let's just handle them here.			int mstPort = appConfig.getMasterController();			if (appConfig.getMasterInEnable() || appConfig.getFaderEnable()) {			    while (PatchEdit.MidiIn.messagesWaiting(mstPort) > 0) { 				MidiMessage msg = PatchEdit.MidiIn.readMessage(mstPort);				ErrorMsg.reportStatus("beginEcho: " + msg);				Patch p = PatchEdit.Clipboard; // save Clipboard				// When no frame is selected this code cose error. Hiroo				if (desktop.getSelectedFrame() instanceof PatchBasket				    && (!(desktop.getSelectedFrame() instanceof PatchEditorFrame))) {				    if (desktop.getSelectedFrame() instanceof LibraryFrame					&& ((LibraryFrame) ((desktop.getSelectedFrame()))).table.getSelectedRowCount() == 0)					break; // Is this OK for master controller?				    ((PatchBasket) desktop.getSelectedFrame()).CopySelectedPatch();				} else				    Clipboard = ((PatchEditorFrame) desktop.getSelectedFrame()).p;				if (msg.getStatus() == SysexMessage.SYSTEM_EXCLUSIVE) {				    PatchEdit.MidiOut.send(Clipboard.getDevice().getPort(),							   (SysexMessage) msg);				} else {				    ShortMessage smsg = (ShortMessage) msg;				    int cmd = smsg.getCommand();				    if (appConfig.getFaderEnable()					&& desktop.getSelectedFrame() instanceof PatchEditorFrame					&& cmd == ShortMessage.CONTROL_CHANGE) {					sendFaderMessage(smsg);				    } else if (cmd == ShortMessage.CHANNEL_PRESSURE) {					//do nothing for now				    } else {					if ((0x80 <= cmd) && (cmd < 0xF0)) { // MIDI channel Voice Message					    smsg.setMessage(cmd, Clipboard.getDevice().getChannel() - 1,							    smsg.getData1(), smsg.getData2());					}					PatchEdit.MidiOut.send(Clipboard.getDevice().getPort(), smsg);				    }				}				PatchEdit.Clipboard = p; // restore Clipboard			    }			}		    } catch (Exception ex) {			ErrorMsg.reportStatus(ex);		    }		}	    });        echoTimer.start();    }