private synchronized void loop() throws InterruptedException { long current= System.currentTimeMillis(); Task task= currentTask(); while (task != EXIT) { long delay= fNextWakeup - current; if (delay <= 0) { task.run(); task= task.nextTask(); schedule(task, current); } else { wait(delay); current= System.currentTimeMillis(); task= currentTask(); } } }
@Override public void run() { final ICompletionProposal proposal= getCurrentProposal(); if (!fDisplay.isDisposed()) { fDisplay.asyncExec(new Runnable() { @Override public void run() { synchronized (Timer.this) { if (proposal == getCurrentProposal()) { Object info= proposal.getAdditionalProposalInfo(); showInformation(proposal, info); } } } }); } }
private void triggerShowing() { final Object info= fCurrentInfo; if (!fDisplay.isDisposed()) { fDisplay.asyncExec(() -> { synchronized (Timer.this) { if (info == fCurrentInfo) { showInformation(fCurrentProposal, info); } } }); } }
/** * Creates a new timer. * * @param display the display to use for display thread posting. * @param delay the delay until to show additional info */ public Timer(Display display, int delay) { fDisplay= display; fDelay= delay; long current= System.currentTimeMillis(); schedule(IDLE, current); fThread= new Thread(new Runnable() { @Override public void run() { try { loop(); } catch (InterruptedException x) { } } }, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$ fThread.start(); }
@Override public void run() { final ICompletionProposalExtension5 proposal= getCurrentProposalEx(); Job job= new Job(JFaceTextMessages.getString("AdditionalInfoController.job_name")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { Object info; try { info= proposal.getAdditionalProposalInfo(monitor); } catch (RuntimeException x) { /* * XXX: This is the safest fix at this point so close to end of 3.2. * Will be revisited when fixing https://bugs.eclipse.org/bugs/show_bug.cgi?id=101033 */ return new Status(IStatus.WARNING, "org.eclipse.jface.text", IStatus.OK, "", x); //$NON-NLS-1$ //$NON-NLS-2$ } setInfo((ICompletionProposal) proposal, info); return Status.OK_STATUS; } }; job.schedule(); }
@Override public void run() { final ICompletionProposalExtension5 proposal= getCurrentProposalEx(); Job job= new Job(JFaceTextMessages.getString("AdditionalInfoController.job_name")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { Object info; try { info= proposal.getAdditionalProposalInfo(monitor); } catch (RuntimeException x) { /* * XXX: This is the safest fix at this point so close to end of 3.2. * Will be revisited when fixing https://bugs.eclipse.org/bugs/show_bug.cgi?id=101033 */ return new Status(IStatus.WARNING, "org.eclipse.jface.text", IStatus.OK, "", x); //$NON-NLS-1$ //$NON-NLS-2$ } setInfo((ICompletionProposal) proposal, info); return Status.OK_STATUS; } }; job.schedule(); }
/** * Creates a new timer. * * @param display the display to use for display thread posting. * @param delay the delay until to show additional info */ public Timer(Display display, int delay) { fDisplay= display; fDelay= delay; long current= System.currentTimeMillis(); schedule(IDLE, current); fThread= new Thread((Runnable) () -> { try { loop(); } catch (InterruptedException x) { } }, JFaceTextMessages.getString("InfoPopup.info_delay_timer_name")); //$NON-NLS-1$ fThread.start(); }
/** * Resets the timer thread as the selection has changed to a new proposal. * * @param p the new proposal */ public synchronized final void reset(ICompletionProposal p) { if (fCurrentProposal != p) { fCurrentProposal= p; fCurrentInfo= null; fAllowShowing= false; long oldWakeup= fNextWakeup; Task task= taskOnReset(p); schedule(task, System.currentTimeMillis()); if (fNextWakeup < oldWakeup) notifyAll(); } }
@Override public void disposeInformationControl() { if (fTimer !=null) { fTimer.terminate(); fTimer= null; } fProposal= null; fInformation= null; if (fProposalTable != null && !fProposalTable.isDisposed()) { fProposalTable.removeSelectionListener(fSelectionListener); fProposalTable= null; } super.disposeInformationControl(); }
/** * Resets the timer thread as the selection has changed to a new proposal. * * @param p the new proposal */ public synchronized final void reset(ICompletionProposal p) { if (fCurrentProposal != p) { fCurrentProposal= p; fCurrentInfo= null; fAllowShowing= false; long oldWakeup= fNextWakeup; Task task= taskOnReset(p); schedule(task, System.currentTimeMillis()); if (fNextWakeup < oldWakeup) notifyAll(); } }
@Override public void run() { final ICompletionProposal proposal= getCurrentProposal(); if (!fDisplay.isDisposed()) { fDisplay.asyncExec(() -> { synchronized (Timer.this) { if (proposal == getCurrentProposal()) { Object info= proposal.getAdditionalProposalInfo(); showInformation(proposal, info); } } }); } }
/** *Handles a change of the line selected in the associated selector. */ public void handleTableSelectionChanged() { if (fProposalTable != null && !fProposalTable.isDisposed() && fProposalTable.isVisible()) { TableItem[] selection= fProposalTable.getSelection(); if (selection != null && selection.length > 0) { TableItem item= selection[0]; Object d= item.getData(); if (d instanceof ICompletionProposal) { ICompletionProposal p= (ICompletionProposal) d; fTimer.reset(p); } } } }
private synchronized void loop() throws InterruptedException { long current= System.currentTimeMillis(); Task task= currentTask(); while (task != EXIT) { long delay= fNextWakeup - current; if (delay <= 0) { task.run(); task= task.nextTask(); schedule(task, current); } else { wait(delay); current= System.currentTimeMillis(); task= currentTask(); } } }
/** *Handles a change of the line selected in the associated selector. */ public void handleTableSelectionChanged() { if (fProposalTable != null && !fProposalTable.isDisposed() && fProposalTable.isVisible()) { TableItem[] selection= fProposalTable.getSelection(); if (selection != null && selection.length > 0) { TableItem item= selection[0]; Object d= item.getData(); if (d instanceof ICompletionProposal) { ICompletionProposal p= (ICompletionProposal) d; fTimer.reset(p); } } } }
@Override public void disposeInformationControl() { if (fTimer !=null) { fTimer.terminate(); fTimer= null; } fProposal= null; fInformation= null; if (fProposalTable != null && !fProposalTable.isDisposed()) { fProposalTable.removeSelectionListener(fSelectionListener); fProposalTable= null; } super.disposeInformationControl(); }
/** * Terminates the timer thread. */ public synchronized final void terminate() { schedule(EXIT, System.currentTimeMillis()); notifyAll(); }
@Override protected void hideInformationControl() { super.hideInformationControl(); if (fTimer != null) fTimer.reset(null); }
@Override public void run() { // show the info allowShowing(); }
private Task taskOnReset(ICompletionProposal p) { if (p == null) return IDLE; if (isExt5(p)) return FIRST_WAIT; return LEGACY_WAIT; }
private Task taskOnReset(ICompletionProposal p) { if (p == null) return IDLE; if (isExt5(p)) return FIRST_WAIT; return LEGACY_WAIT; }