Java Code Examples for sun.swing.AccumulativeRunnable

The following examples show how to use sun.swing.AccumulativeRunnable. These examples are extracted from open source projects. 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 Project: ghidra   Source File: CachingSwingWorkerTest.java    License: 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 Project: jdk1.8-source-analysis   Source File: SwingWorker.java    License: 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 3
Source Project: jdk1.8-source-analysis   Source File: SwingWorker.java    License: 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 4
Source Project: dragonwell8_jdk   Source File: SwingWorker.java    License: 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 5
Source Project: dragonwell8_jdk   Source File: SwingWorker.java    License: 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 6
Source Project: TencentKona-8   Source File: SwingWorker.java    License: 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 Project: TencentKona-8   Source File: SwingWorker.java    License: 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 Project: jdk8u60   Source File: SwingWorker.java    License: 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 9
Source Project: jdk8u60   Source File: SwingWorker.java    License: 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 10
Source Project: JDKSourceCode1.8   Source File: SwingWorker.java    License: MIT License 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 Project: JDKSourceCode1.8   Source File: SwingWorker.java    License: MIT License 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 Project: openjdk-jdk8u   Source File: SwingWorker.java    License: 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 Project: openjdk-jdk8u   Source File: SwingWorker.java    License: 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 14
/**
 * 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
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 Project: Bytecoder   Source File: SwingWorker.java    License: 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 17
Source Project: Bytecoder   Source File: SwingWorker.java    License: 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 18
Source Project: openjdk-jdk9   Source File: SwingWorker.java    License: 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 Project: openjdk-jdk9   Source File: SwingWorker.java    License: 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 20
Source Project: jdk8u-jdk   Source File: SwingWorker.java    License: 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 Project: jdk8u-jdk   Source File: SwingWorker.java    License: 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 Project: Java8CN   Source File: SwingWorker.java    License: 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 23
Source Project: Java8CN   Source File: SwingWorker.java    License: 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 24
Source Project: hottub   Source File: SwingWorker.java    License: 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 25
Source Project: hottub   Source File: SwingWorker.java    License: 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 26
Source Project: openjdk-8-source   Source File: SwingWorker.java    License: 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 27
Source Project: openjdk-8-source   Source File: SwingWorker.java    License: 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 28
Source Project: openjdk-8   Source File: SwingWorker.java    License: 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 29
Source Project: openjdk-8   Source File: SwingWorker.java    License: 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 30
Source Project: jdk8u_jdk   Source File: SwingWorker.java    License: 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);
}