/** Attaches asynchronous init job to given component. * {@link AsyncGUIJob#construct()} will be called after first * paint, when paint event arrives. Later, {@link AsyncGUIJob#finished()} * will be called according to the rules of the <code>AsyncGUIJob</code> interface. * * Useful for components that have slower initialization phase, component * can benefit from more responsive behaviour during init. * * @param comp4Init Regular component in its pre-inited state, state in which * component will be shown between first paint and init completion. * @param initJob Initialization job to be called asynchronously. Job can * optionally implement {@link Cancellable} * interface for proper cancel logic. Cancel method will be called * when component stops to be showing during job's progress. * See {@link java.awt.Component#isShowing} * * @since 3.36 */ @SuppressWarnings("ResultOfObjectAllocationIgnored") public static void attachInitJob(Component comp4Init, AsyncGUIJob initJob) { new AsyncInitSupport(comp4Init, initJob); }
/** Impl of HierarchyListener, starts init job with delay when component shown, * stops listening to asociated component it isn't showing anymore, * calls cancel if desirable. * @param evt hierarchy event */ @Override public void hierarchyChanged(HierarchyEvent evt) { final boolean hierachyChanged = (evt.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0; LOG.log(Level.FINE, "Hierarchy Changed {0}", hierachyChanged); if (hierachyChanged) { boolean isShowing = comp4Init.isShowing(); if (timer == null && isShowing) { timer = new Timer(20, this); timer.setRepeats(false); timer.start(); LOG.log(Level.FINE, "Timer started for {0}", comp4Init); } else if (!isShowing) { comp4Init.removeHierarchyListener(this); LOG.log(Level.FINE, "Not showing, cancling for {0}", comp4Init); cancel(); } } }
/** Impl of ActionListener, called from hierarchyChanged through a Timer, * starts the job */ @Override public void actionPerformed(ActionEvent ae) { if (wasCancelled || (initTask != null)) { //If cancelled or already started, our job is done, go away. LOG.log(Level.FINE, "Detaching {0}", comp4Init); detach(); return; } if ((comp4Init != null) && comp4Init.isDisplayable()) { //If the component has a parent onscreen, we're ready to run. LOG.log(Level.FINE, "Starting {0}", comp4Init); start(); } }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** Invokes execution of init code in non-ED thread. * @param evt ignored */ public void eventDispatched (AWTEvent event) { if (event.getSource() instanceof Component && SwingUtilities.isDescendingFrom(comp4Init, (Component)(event.getSource()))) { start(); } }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** Invokes execution of init code in non-ED thread. * @param evt ignored */ public void eventDispatched (AWTEvent event) { if (event.getSource() instanceof Component && SwingUtilities.isDescendingFrom(comp4Init, (Component)(event.getSource()))) { start(); } }
/** Impl of ActionListener, called from hierarchyChanged through a Timer, * starts the job */ @Override public void actionPerformed(ActionEvent ae) { if (wasCancelled || (initTask != null)) { //If cancelled or already started, our job is done, go away. LOG.log(Level.FINE, "Detaching {0}", comp4Init); detach(); return; } if ((comp4Init != null) && comp4Init.isDisplayable()) { //If the component has a parent onscreen, we're ready to run. LOG.log(Level.FINE, "Starting {0}", comp4Init); start(); } }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** Attaches asynchronous init job to given component. * {@link AsyncGUIJob#construct()} will be called after first * paint, when paint event arrives. Later, {@link AsyncGUIJob#finished()} * will be called according to the rules of the <code>AsyncGUIJob</code> interface. * * Useful for components that have slower initialization phase, component * can benefit from more responsive behaviour during init. * * @param comp4Init Regular component in its pre-inited state, state in which * component will be shown between first paint and init completion. * @param initJob Initialization job to be called asynchronously. Job can * optionally implement {@link Cancellable} * interface for proper cancel logic. Cancel method will be called * when component stops to be showing during job's progress. * See {@link java.awt.Component#isShowing} * * @since 3.36 */ @SuppressWarnings("ResultOfObjectAllocationIgnored") public static void attachInitJob(Component comp4Init, AsyncGUIJob initJob) { new AsyncInitSupport(comp4Init, initJob); }
/** Impl of HierarchyListener, starts init job with delay when component shown, * stops listening to asociated component it isn't showing anymore, * calls cancel if desirable. * @param evt hierarchy event */ @Override public void hierarchyChanged(HierarchyEvent evt) { final boolean hierachyChanged = (evt.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0; LOG.log(Level.FINE, "Hierarchy Changed {0}", hierachyChanged); if (hierachyChanged) { boolean isShowing = comp4Init.isShowing(); if (timer == null && isShowing) { timer = new Timer(20, this); timer.setRepeats(false); timer.start(); LOG.log(Level.FINE, "Timer started for {0}", comp4Init); } else if (!isShowing) { comp4Init.removeHierarchyListener(this); LOG.log(Level.FINE, "Not showing, cancling for {0}", comp4Init); cancel(); } } }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** Attaches asynchronous init job to given component. * {@link AsyncGUIJob#construct()} will be called after first * paint, when paint event arrives. Later, {@link AsyncGUIJob#finished()} * will be called according to the rules of the <code>AsyncGUIJob</code> interface. * * Useful for components that have slower initialization phase, component * can benefit from more responsive behaviour during init. * * @param comp4Init Regular component in its pre-inited state, state in which * component will be shown between first paint and init completion. * @param initJob Initialization job to be called asynchronously. Job can * optionally implement {@link Cancellable} * interface for proper cancel logic. Cancel method will be called * when component stops to be showing during job's progress. * See {@link java.awt.Component#isShowing} * * @since 3.36 */ public static final void attachInitJob(Component comp4Init, AsyncGUIJob initJob) { new AsyncInitSupport(comp4Init, initJob); }
/** Impl of HierarchyListener, starts init job with delay when component shown, * stops listening to asociated component it isn't showing anymore, * calls cancel if desirable. * @param evt hierarchy event */ @Override public void hierarchyChanged(HierarchyEvent evt) { final boolean hierachyChanged = (evt.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0; LOG.log(Level.FINE, "Hierarchy Changed {0}", hierachyChanged); if (hierachyChanged) { boolean isShowing = comp4Init.isShowing(); if (timer == null && isShowing) { timer = new Timer(20, this); timer.setRepeats(false); timer.start(); LOG.log(Level.FINE, "Timer started for {0}", comp4Init); } else if (!isShowing) { comp4Init.removeHierarchyListener(this); LOG.log(Level.FINE, "Not showing, cancling for {0}", comp4Init); cancel(); } } }
private void start() { detach(); if (initTask == null) { initTask = RequestProcessor.getDefault().post(this); } }
/** Attaches asynchronous init job to given component. * {@link AsyncGUIJob#construct()} will be called after first * paint, when paint event arrives. Later, {@link AsyncGUIJob#finished()} * will be called according to the rules of the <code>AsyncGUIJob</code> interface. * * Useful for components that have slower initialization phase, component * can benefit from more responsive behaviour during init. * * @param comp4Init Regular component in its pre-inited state, state in which * component will be shown between first paint and init completion. * @param initJob Initialization job to be called asynchronously. Job can * optionally implement {@link Cancellable} * interface for proper cancel logic. Cancel method will be called * when component stops to be showing during job's progress. * See {@link java.awt.Component#isShowing} * * @since 3.36 */ public static final void attachInitJob (Component comp4Init, AsyncGUIJob initJob) { new AsyncInitSupport(comp4Init, initJob); }
/** Impl of HierarchyListener, starts init job with delay when component shown, * stops listening to asociated component it isn't showing anymore, * calls cancel if desirable. * @param evt hierarchy event */ public void hierarchyChanged(HierarchyEvent evt) { if (((evt.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0)) { boolean isShowing = comp4Init.isShowing(); if (timer == null && isShowing) { timer = new Timer(20, this); timer.setRepeats(false); timer.start(); } else if (!isShowing) { comp4Init.removeHierarchyListener(this); cancel(); } } }
/** Impl of ActionListener, called from hierarchyChanged through a Timer, * starts the job */ public void actionPerformed(ActionEvent ae) { if (wasCancelled || (initTask != null)) { //If cancelled or already started, our job is done, go away. detach(); return; } if ((comp4Init != null) && comp4Init.isDisplayable()) { //If the component has a parent onscreen, we're ready to run. start(); } }