private void format() { if (commit == null) { setDocument(new Document("")); // $NON-NLS-1$ return; } if (formatJob != null && formatJob.getState() != Job.NONE) formatJob.cancel(); scheduleFormatJob(); }
@Override protected void handleDispose() { if (formatJob != null) { formatJob.cancel(); formatJob = null; } Activator.getDefault().getPreferenceStore().removePropertyChangeListener(listener); if (refsChangedListener != null) refsChangedListener.remove(); refsChangedListener = null; super.handleDispose(); }
void addDoneListenerToFormatJob() { formatJob.addJobChangeListener( new JobChangeAdapter() { public void done(IJobChangeEvent event) { if (!event.getResult().isOK()) return; final StyledText text = getTextWidget(); if (text == null || text.isDisposed()) return; final FormatJob job = (FormatJob) event.getJob(); text.getDisplay() .asyncExec( new Runnable() { public void run() { if (text.isDisposed()) return; setDocument(new Document(job.getFormatResult().getCommitInfo())); text.setStyleRanges(job.getFormatResult().getStyleRange()); } }); } }); }