sun.swing.AccumulativeRunnable Java Examples

The following examples show how to use sun.swing.AccumulativeRunnable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CachingSwingWorkerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void disasbleTimerUsage() {
	AccumulativeRunnable<Runnable> nonTimerAccumulativeRunnable =
		new AccumulativeRunnable<Runnable>() {
			@Override
			protected void run(List<Runnable> args) {
				for (Runnable runnable : args) {
					runnable.run();
				}
			}
		};

	Object key = getInstanceField("DO_SUBMIT_KEY", SwingWorker.class);

	AppContext appContext = AppContext.getAppContext();
	appContext.put(key, nonTimerAccumulativeRunnable);
}
 
Example #2
Source File: SwingWorker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #3
Source File: SwingWorker.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #4
Source File: SwingWorker.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        @SuppressWarnings("unchecked")
        AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
        return tmp;
    }
}
 
Example #5
Source File: SwingWorker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        @SuppressWarnings("unchecked")
        AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
        return tmp;
    }
}
 
Example #6
Source File: SwingWorker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #7
Source File: SwingWorker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #8
Source File: SwingWorker.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #9
Source File: SwingWorker.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #10
Source File: SwingWorker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #11
Source File: SwingWorker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #12
Source File: SwingWorker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #13
Source File: SwingWorker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #14
Source File: SwingWorker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #15
Source File: SwingWorker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #16
Source File: SwingWorker.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #17
Source File: SwingWorker.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #18
Source File: SwingWorker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #19
Source File: SwingWorker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #20
Source File: SwingWorker.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #21
Source File: SwingWorker.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #22
Source File: SwingWorker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #23
Source File: SwingWorker.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #24
Source File: SwingWorker.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #25
Source File: SwingWorker.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #26
Source File: SwingWorker.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #27
Source File: SwingWorker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #28
Source File: SwingWorker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}
 
Example #29
Source File: SwingWorker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the {@code progress} bound property.
 * The value should be from 0 to 100.
 *
 * <p>
 * Because {@code PropertyChangeListener}s are notified asynchronously on
 * the <i>Event Dispatch Thread</i> multiple invocations to the
 * {@code setProgress} method might occur before any
 * {@code PropertyChangeListeners} are invoked. For performance purposes
 * all these invocations are coalesced into one invocation with the last
 * invocation argument only.
 *
 * <p>
 * For example, the following invokations:
 *
 * <pre>
 * setProgress(1);
 * setProgress(2);
 * setProgress(3);
 * </pre>
 *
 * might result in a single {@code PropertyChangeListener} notification with
 * the value {@code 3}.
 *
 * @param progress the progress value to set
 * @throws IllegalArgumentException is value not from 0 to 100
 */
protected final void setProgress(int progress) {
    if (progress < 0 || progress > 100) {
        throw new IllegalArgumentException("the value should be from 0 to 100");
    }
    if (this.progress == progress) {
        return;
    }
    int oldProgress = this.progress;
    this.progress = progress;
    if (! getPropertyChangeSupport().hasListeners("progress")) {
        return;
    }
    synchronized (this) {
        if (doNotifyProgressChange == null) {
            doNotifyProgressChange =
                new AccumulativeRunnable<Integer>() {
                    @Override
                    public void run(List<Integer> args) {
                        firePropertyChange("progress",
                           args.get(0),
                           args.get(args.size() - 1));
                    }
                    @Override
                    protected void submit() {
                        doSubmit.add(this);
                    }
                };
        }
    }
    doNotifyProgressChange.add(oldProgress, progress);
}
 
Example #30
Source File: SwingWorker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static AccumulativeRunnable<Runnable> getDoSubmit() {
    synchronized (DO_SUBMIT_KEY) {
        final AppContext appContext = AppContext.getAppContext();
        Object doSubmit = appContext.get(DO_SUBMIT_KEY);
        if (doSubmit == null) {
            doSubmit = new DoSubmitAccumulativeRunnable();
            appContext.put(DO_SUBMIT_KEY, doSubmit);
        }
        return (AccumulativeRunnable<Runnable>) doSubmit;
    }
}