Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple TaskManager implementation #576

Closed
mgarin opened this issue Oct 29, 2019 · 1 comment
Closed

Simple TaskManager implementation #576

mgarin opened this issue Oct 29, 2019 · 1 comment

Comments

@mgarin
Copy link
Owner

mgarin commented Oct 29, 2019

At this point WebLaF has quite a few things that are executed on separate threads - thumbnail generation, asynchronous tree data loading, link actions, file system interactions, animations and some other minor things. A few new things are also coming in future updates.

As of right now - there is no convenient way to configure (and primarily limit) how those threads are created and managed which might be quite inconvenient depending on application and system specifics. There are also quite a few different solutions created across WebLaF code that manage threads for specific tasks which only makes it more complicated.

That is why I've been working on a new and rather small TaskManager that would allow managing custom TaskGroups which will be used to run all asynchronous tasks within WebLaF and can also be used to manage such tasks for your own application as well. TaskManager won't have anything ground-breaking - it will simply provide a simple API for managing task groups and executing tasks within a particular group.

I also plan to expand this feature in the future with it's own custom UI that would provide visual feedback for all running tasks and ability to manage them.

@mgarin mgarin added this to the v1.2.11 milestone Oct 29, 2019
@mgarin mgarin self-assigned this Oct 29, 2019
mgarin added a commit that referenced this issue Nov 28, 2019
- TaskManager.java - New manager that handles all concurrent tasks within library except for animation which is currently handled by `AnimationManager`
- TaskManager.java - There are a few predefined `TaskGroup`s available that are used by various WebLaF parts, but they can be reconfigured
- TaskGroup.java - Object with unique identifier that represents a specific group of tasks
- TaskException.java - Custom exception for any problems that might occur in `TaskManager`
- Multiple classes like `ThumbnailGenerator` or `AsyncTreeModel` now use `TaskManager` for concurrent tasks execution

AnimationManager
- ThreadGroupHandler.java - Renamed from `DaemonThreadHandler` and is now based on the `TaskGroup` identifier it uses

LazyContent [ #577 ]
- LazyContent.java - Custom utility allowing convenient UI initialization involving heavy data loading
- LazyLoadTrigger.java - Enumeration representing trigger types for data and UI loading start
- LazyContentListener.java, LazyContentAdapter.java - `LazyContent` data and UI event listener and adapter for it
- LazyState.java - Enumeration representing all possible data and UI states
- LazyStateListener.java, LazyStateAdapter.java - `LazyContent` states listener and adapter for it
- DataLoadProgress.java - Object passed to progress display component for feedback on asynchronous task completion progress
- ProgressCallback.java - Object passed to asynchronous task to provide information about it's progress if necessary
- LazyDataLoadProgress.java - Bridge object for passing data loading events to progress component
- LazyProgressOverlay.java - Default progress display component that can show both indeterminate and determinate progress and can switch between them

LazyPanel [ #577 ]
- LazyPanel.java - Custom container that provides means for more convenient `LazyContent` feature usage
- LazyPanelLayout.java - Custom layout for `LazyPanel` for displaying various components for each of loading stages
- lazypanel.xml, StyleId.java - Default style for `LazyPanel` component similar to default `JPanel` styles

Overlay [ #568 ]
- WebOverlay.java - Completely reworked overlay component with more convenient support for custom overlay locations and complete styling support
- WOverlayUI.java, WebOverlayUI.java, IOverlayPainter.java, OverlayPainter.java - Basic UI and painter implementations for `WebOverlay`
- WebProgressOverlay.java - Implementation based on new `WebOverlay` that can display indeterminate progress on a custom canvas overlay
- Overlay.java - New interface for overlays to be added to `WebOverlay`
- FillOverlay.java, AlignedOverlay.java - Basic `Overlay` implementations for most common use cases
- WebOverlay.java, OverlayData.java, OverlayLayout.java, OverlayLocation.java - Replaced with new `WebOverlay` implementation
- WebProgressOverlay.java - Replaced with new `WebProgressOverlay` implementation
- overlay.xml, StyleId.java - Default styles for `WebOverlay` and `WebProgressOverlay` components

AsyncTree
- AsyncTreeDataProvider.java - Added `getThreadGroupId` method for returning identifier of `ThreadGroup` on which data loading should be performed
- AsyncTreeModel.java - Reworked to incorporate new `TaskManager` instead of a custom `AsyncTreeQueue` class
- AsyncTreeQueue.java - Removed as redundant, `TaskManager` is used instead

NinePatchEditor
- NinePatchEditor.java - Added proper usage of alpha background texture

Utilities
- NoOpMouseListener.java - Changed to singleton to avoid unnecessary instances creation
- NoOpKeyListener.java - `KeyListener` implementation similar to `NoOpMouseListener`
- CoreSwingUtils.java - Added `invokeOnEventDispatchThread` method for convenience
- SwingUtils.java - Added `maxNonNull` method for convenience
- facebook.gif - Fixed loader icon size to be 16x16 like other icons
- LazyLoadBehavior.java - Added `TaskGroup` identifier usage for concurrent task running
- LazyLoadBehavior.java - Marked as `@Deprecated` and will be removed or reworked in future releases
- ComponentUpdater.java - Marked as `@Deprecated` and will be removed before v1.2.11 release

DemoApplication.java
- DemoTaskGroup.java - New `TaskGroup` for demo application concurrent tasks
- LazyPanelExample.java - New example for `LazyPanel` component
- WebOverlayExample.java - New example for `WebOverlay` component
- WebProgressOverlayExample.java - New example for `WebProgressOverlay` component
- JProgressBarExample.java - Slowed down progress animation
- SampleInterface.java - New class providing some basic UI elements for use in examples
- SampleData.java, demo-language.xml - Regrouped sample data translations for convenience
- demo-language.xml - Added translations for new examples
@mgarin
Copy link
Owner Author

mgarin commented Nov 28, 2019

TaskManager have was added in recent commit and will be available in v1.2.11 release.
It will also be available quite soon in SNAPSHOT artifacts:
https://oss.sonatype.org/content/repositories/snapshots/com/weblookandfeel/

@mgarin mgarin closed this as completed Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant