/** * Tells this console to watch the run state of the provided job, and prepares the console to * receive the job's output (ie is activated & cleared). If this console is already running a job, * it will be stopped. * * @param rpmJob The job to watch. If <code>null</code> or equal to the currently running job, * this method will have no effect. * @return This console's output stream where the linked job may send its output, or <code>null * </code> if an invalid job is provided. */ public synchronized IOConsoleOutputStream linkJob(RPMExportOperation rpmJob) { if (rpmJob == null || rpmJob.equals(currentJob)) { return null; } if (currentJob != null) { if (currentJob.getResult() == null) { showErrorDialog(); return null; } currentJob.removeJobChangeListener(jobWatcher); clearConsole(); } activate(); currentJob = rpmJob; currentJob.addJobChangeListener(jobWatcher); running = currentJob.getState() == Job.RUNNING; notifyConsoleObservers(); return newOutputStream(); }
/** Cancels the currently-running job. */ public synchronized void stop() { if (currentJob != null && running) { currentJob.cancel(); } }