Skip to content

Commit

Permalink
Major JSplitPane update
Browse files Browse the repository at this point in the history
Split pane internal code have gone through a complete rework, so split pane now fully supports styling for all of its parts. Due to multiple limitations of `BasicSplitPaneUI` WebLaF now features its own basic UI in form of `WSplitPaneUI`. Also Swing divider component implementation was based on AWT `Component` which did not allow attaching WebLaF styling to it, so `BasicSplitPaneDivider` was also replaced with new `WebSplitPaneDivider` component (based on `JComponent`) which is fully supported by new styling system.

SplitPane [ #476 ]
- WSplitPaneUI.java - Now fully replaces `BasicSplitPaneUI` and has a few optimizations and adjustments
- WSplitPaneUI.java - Added non-continuous divider placement adjustment according to decoration border insets
- WSplitPaneUI.java - Now features a separate listener that updates divider visibility depending on the split pane sides availability
- WSplitPaneListener.java - New class containing basic listeners from `BasicSplitPaneUI` for `WSplitPaneUI`
- SplitPaneLayout.java - New basic layout for `WSplitPaneUI`
- WebSplitPaneUI.java - Optimized for new basic `WSplitPaneUI` usage, removed some redundant code parts
- WebSplitPaneDivider.java - New divider component that replaces `BasicSplitPaneDivider` and utilizes styling system
- ComponentType.xsd - Added new divider component type constant
- SplitPanePainter.java, SplitPaneDividerPainter.java - Added `JSplitPane` orientation -based states for styling convenience
- splitpanedivider.xml, StyleId.java - New styling for `JSplitPane` divider component
- splitpane.xml - Added `non-opaque`, `transparent`, `decorated` and `focusable` styles

Button
- WButtonListener.java - Reworked to separate instances of `Action` class for each of supported actions
- WButtonListener.java - Replaced `LazyActionMap` with `UIActionMap` usage, it will slightly affect memory but improve code a lot
- WButtonUI.java - Simplified `WButtonListener` usage

ScrollPane
- scrollpane.xml - Added `undecorated-buttonless` style to cover some additional use cases
- scrollbar.xml - Adjusted margin setting for `buttonless` style

ColorChooser
- WebColorChooserUI.java, colorchooser.xml - Now uses a separate style identifier for `WebColorChooserPanel`
- WebColorChooserPanel.java - Added constructors to allow providing custom style identifiers
- colorchooserpanel.xml - Separate style file for `WebColorChooserPanel`
- colorchooser.xml - Added separate dark style [ #54 ]

Canvas
- WebCanvas.java - States list now always exists for override convenience
- WebCanvas.java - Returns a copy of states for method override convenience
- WebCanvas.java - Added methods to add/remove `Collection` of states
- WebCanvas.java - Updated JavaDoc

Trees
- TreePainter.java - Enhanced full-line nodes selection on mouse events
- WebFileTree.java - Now shows root handles by default

StyleManager
- StyleData.java - Added install and uninstall methods to allow appropriate listeners handling
- StyleData.java - Added some missing EDT checks
- StyleManager.java, - Added separate `StyleData` install and uninstall calls for skin installation and uninstallation

Painter
- AbstractPainter.java - Separated `install` and `uninstall` methods into smaller pieces for override convenience
- AbstractDecorationPainter.java - Fixed issue with border not being initialized properly when based on specific decoration state
- Updated all painters related to `AbstractPainter` to use newly added methods instead of overriding `install` and `uninstall`

Decoration
- DecorationState.java - Added `one-touch` state and missing JavaDocs
- CheckIcon.java, MixedIcon.java, RadioIcon.java - Updated identifiers to be unique and replaceable
- AlignLayout.java - New `IContentLayout` implementation that copies `AlignLayout` behavior for contents
- AlignLayout.xsd, IContent.xsd - New XSD for `AlignLayout` class
- AlignLayout.java, BorderLayout.java, WebCanvas.java, AdaptiveCanvasPainter.java - Minor JavaDoc updates
- AlphaLayerBackground.java - Added default values for settings for convenience

IconManager
- LazyIcon.java - Added better `toString` implementation

Utilities
- CollectionUtils.java - Fixed non-strict lists equality check for cases with duplicate entries in first list
- CollectionUtils.java - Added method to remove `Collection` of elements from another `Collection`
- CollectionUtils.java - Added method to sort `List` of elements using any `Comparator`
- CollectionUtils.java - Renamed multiple methods for usage convenience
- ColorUtils.java - Simplified method names for convenient, refactored code, updated JavaDoc
- ColorUtils.java - Added color caching for methods with predictable outcome to optimize memory usage
- ColorConverter.java - Slightly refactored code, removed unnecessary variables
- AbstractUnits.java, ModifierType.java - Added `Locale.ROOT` usage to `toLowerCase` methods
- ValuesTable.java, ValuesTableConverter.java - Removed `ValuesTable` as deprecated and redundant feature
- DoubleMap.java, MapUtils.java - Removed `DoubleMap` as deprecated and redundant feature
- IndexedSupplier.java, CollectionUtils.java - Replaced `IndexedSupplier` with simple `Function` usage
- SelectorUtils.java - Separated from `LafUtils`, will be revamped later on
- LoremIpsum.java - Made serializable for convenience
- LafUtils.java - Cleared from deprecated methods

LookAndFeel
- UIAction.java - New custom `Action` for usage within `ActionMap`s in UI classes, unlike `sun.swing.UIAction` it is not designed to be used globally
- UIActionMap.java - New custom `ActionMap` for usage in UI classes instead of `LazyActionMap`
- LazyActionMap.java - Slightly updated code, marked as deprecated, added information on why usage will be halted in later updates
- WebLookAndFeel.java - Added small default divider size value to ensure it can size properly based on its style size

NinePatchEditor
- NinePatchEditor.java, LafUtils.java - Replaced alpha background painting with `AlphaLayerBackground` usage
- ninepatcheditor.xml - Added dark style, removed unnecessary default settings [ #54 ]

DemoApplication
- JSplitPaneExample.java, demo-language.xml, jsplitpane.png - Added `JSplitPane` examples
- JScrollPaneExample.java - Added extra style example
- AbstractExample.java - Adjusted example scroll pane to look better
- JPanelExample.java - Minor code refactoring
  • Loading branch information
mgarin committed Dec 19, 2017
1 parent a9d5aec commit 85ff9b1
Show file tree
Hide file tree
Showing 119 changed files with 6,936 additions and 2,519 deletions.
258 changes: 240 additions & 18 deletions modules/core/src/com/alee/utils/CollectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.alee.utils;

import com.alee.utils.collection.IndexedSupplier;
import com.alee.api.jdk.Function;
import com.alee.utils.compare.Filter;
import com.alee.utils.text.TextProvider;

Expand Down Expand Up @@ -307,13 +307,12 @@ public static <T> ArrayList<T> asNonNullList ( final T... data )
*
* @param collection list to fill
* @param objects objects
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean addAll ( final Collection<T> collection, final T... objects )
public static boolean addUnique ( final Collection<Boolean> collection, final boolean[] objects )
{
boolean result = false;
for ( final T object : objects )
for ( final boolean object : objects )
{
if ( !collection.contains ( object ) )
{
Expand All @@ -324,19 +323,159 @@ public static <T> boolean addAll ( final Collection<T> collection, final T... ob
}

/**
* Adds all non-null objects into the specified list.
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Integer> collection, final int[] objects )
{
boolean result = false;
for ( final int object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Character> collection, final char[] objects )
{
boolean result = false;
for ( final char object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Byte> collection, final byte[] objects )
{
boolean result = false;
for ( final byte object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Short> collection, final short[] objects )
{
boolean result = false;
for ( final short object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Long> collection, final long[] objects )
{
boolean result = false;
for ( final long object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Float> collection, final float[] objects )
{
boolean result = false;
for ( final float object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static boolean addUnique ( final Collection<Double> collection, final double[] objects )
{
boolean result = false;
for ( final double object : objects )
{
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean addAllNonNull ( final Collection<T> collection, final T... objects )
public static <T> boolean addUnique ( final Collection<T> collection, final T... objects )
{
boolean result = false;
for ( final T object : objects )
{
if ( !collection.contains ( object ) && object != null )
if ( !collection.contains ( object ) )
{
result |= collection.add ( object );
}
Expand All @@ -352,7 +491,7 @@ public static <T> boolean addAllNonNull ( final Collection<T> collection, final
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean addAll ( final Collection<T> collection, final Collection<T> objects )
public static <T> boolean addUnique ( final Collection<T> collection, final Collection<T> objects )
{
boolean result = false;
for ( final T object : objects )
Expand All @@ -373,7 +512,28 @@ public static <T> boolean addAll ( final Collection<T> collection, final Collect
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean addAllNonNull ( final Collection<T> collection, final Collection<T> objects )
public static <T> boolean addUniqueNonNull ( final Collection<T> collection, final T... objects )
{
boolean result = false;
for ( final T object : objects )
{
if ( !collection.contains ( object ) && object != null )
{
result |= collection.add ( object );
}
}
return result;
}

/**
* Adds all non-null objects into the specified list.
*
* @param collection list to fill
* @param objects objects
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean addUniqueNonNull ( final Collection<T> collection, final Collection<T> objects )
{
boolean result = false;
for ( final T object : objects )
Expand Down Expand Up @@ -404,6 +564,24 @@ public static <T> boolean removeAll ( final Collection<T> collection, final T...
return result;
}

/**
* Removes all objects from the specified list.
*
* @param collection list to fill
* @param objects objects
* @param <T> objects type
* @return {@code true} if list changed as the result of this operation, {@code false} otherwise
*/
public static <T> boolean removeAll ( final Collection<T> collection, final Collection<T> objects )
{
boolean result = false;
for ( final T object : objects )
{
result |= collection.remove ( object );
}
return result;
}

/**
* Returns collection that contains elements from all specified collections.
* Order in which collection are provided will be preserved.
Expand Down Expand Up @@ -518,6 +696,13 @@ else if ( list1 == null || list2 == null || list1.size () != list2.size () )
return false;
}
}
for ( final Object object : list2 )
{
if ( !list1.contains ( object ) )
{
return false;
}
}
}
return true;
}
Expand Down Expand Up @@ -650,6 +835,25 @@ public static <T> ArrayList<T> filter ( final Collection<T> collection, final Fi
return filtered;
}

/**
* Sorts {@link List} using the specified {@link Comparator}.
*
* @param list {@link List} to sort
* @param comparator {@link Comparator}
* @param <T> elements type
*/
public static <T> void sort ( final List<T> list, final Comparator<T> comparator )
{
final Object[] a = list.toArray ();
Arrays.sort ( a, ( Comparator ) comparator );
final ListIterator<T> i = list.listIterator ();
for ( final Object e : a )
{
i.next ();
i.set ( ( T ) e );
}
}

/**
* Returns map keys list.
*
Expand Down Expand Up @@ -703,19 +907,19 @@ public static <K, V> ArrayList<V> valuesSummaryList ( final Map<K, List<V>> map
}

/**
* Fills and returns list with data provided by supplier interface implementation.
* Returns {@link List} filled with data provided by index mapping {@link Function}.
*
* @param amount amount of list elements
* @param supplier data provider
* @param <T> data type
* @return list filled with data provided by supplier interface implementation
* @param size {@link List} size
* @param indexMapper index mapping {@link Function}
* @param <T> elements type
* @return {@link List} filled with data provided by index mapping {@link Function}
*/
public static <T> List<T> fillList ( final int amount, final IndexedSupplier<T> supplier )
public static <T> List<T> fillList ( final int size, final Function<Integer, T> indexMapper )
{
final List<T> list = new ArrayList<T> ( amount );
for ( int i = 0; i < amount; i++ )
final List<T> list = new ArrayList<T> ( size );
for ( int i = 0; i < size; i++ )
{
list.add ( supplier.get ( i ) );
list.add ( indexMapper.apply ( i ) );
}
return list;
}
Expand Down Expand Up @@ -745,4 +949,22 @@ public static <T> HashSet<T> asHashSet ( final T... data )
Collections.addAll ( set, data );
return set;
}

/**
* Returns new {@link List} filled with {@link Integer}s in the specified range.
*
* @param from first range integer, inclusive
* @param to last range integer, inclusive
* @return new {@link List} filled with {@link Integer}s in the specified range
*/
public static List<Integer> intRange ( final int from, final int to )
{
final List<Integer> range = new ArrayList<Integer> ( Math.max ( from, to ) - Math.min ( from, to ) + 1 );
for ( int i = from; i != to; i += from < to ? 1 : -1 )
{
range.add ( i );
}
range.add ( to );
return range;
}
}
Loading

0 comments on commit 85ff9b1

Please sign in to comment.