Skip to content

Commit

Permalink
Updates for v1.22 release
Browse files Browse the repository at this point in the history
TristateCheckIcon.java mixed state painting for disabled state improved
WebCheckBoxTree.java hide/disable checks options added
Demo application work w/o animation fixed
  • Loading branch information
mgarin committed Oct 1, 2013
1 parent 7c02861 commit c763fb6
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 100 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ You can find more information about the library on official site:<br>
http://weblookandfeel.com


Artifacts
Artifacts (v1.22)
----------
You can always find all WebLaF releases in the "releases" section:<br>
https://github.com/mgarin/weblaf/releases

Here are the direct links for the latest release:

1. [**weblaf-1.21.jar**](https://github.com/mgarin/weblaf/releases/download/v1.21/weblaf-1.21.jar) - library jar
2. [**weblaf-simple-1.21.jar**](https://github.com/mgarin/weblaf/releases/download/v1.21/weblaf-simple-1.21.jar) - library jar without dependencies
3. [**weblaf-src-1.21.zip**](https://github.com/mgarin/weblaf/releases/download/v1.21/weblaf-src-1.21.zip) - project sources zip
4. [**weblaf-demo-1.21.jar**](https://github.com/mgarin/weblaf/releases/download/v1.21/weblaf-demo-1.21.jar) - executable demo jar
5. [**weblaf-javadoc-1.21.zip**](https://github.com/mgarin/weblaf/releases/download/v1.21/weblaf-javadoc-1.21.zip) - JavaDoc zip
6. [**ninepatch-editor-1.21.jar**](https://github.com/mgarin/weblaf/releases/download/v1.21/ninepatch-editor-1.21.jar) - executable 9-patch editor jar
1. [**weblaf-1.22.jar**](https://github.com/mgarin/weblaf/releases/download/v1.22/weblaf-1.22.jar) - library jar
2. [**weblaf-simple-1.22.jar**](https://github.com/mgarin/weblaf/releases/download/v1.22/weblaf-simple-1.22.jar) - library jar without dependencies
3. [**weblaf-src-1.22.zip**](https://github.com/mgarin/weblaf/releases/download/v1.22/weblaf-src-1.22.zip) - project sources zip
4. [**weblaf-demo-1.22.jar**](https://github.com/mgarin/weblaf/releases/download/v1.22/weblaf-demo-1.22.jar) - executable demo jar
5. [**weblaf-javadoc-1.22.zip**](https://github.com/mgarin/weblaf/releases/download/v1.22/weblaf-javadoc-1.22.zip) - JavaDoc zip
6. [**ninepatch-editor-1.22.jar**](https://github.com/mgarin/weblaf/releases/download/v1.22/ninepatch-editor-1.22.jar) - executable 9-patch editor jar


Roadmap
Expand Down
4 changes: 2 additions & 2 deletions build/version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Mon Sep 16 17:44:45 MSK 2013
build.number=22
#Tue Oct 01 13:54:49 MSK 2013
build.number=23
version.number=1
1 change: 1 addition & 0 deletions src/com/alee/examples/groups/checkbox/CheckBoxExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public Component getPreview ( final WebLookAndFeelDemo owner )

// Static check box
final WebCheckBox checkBoxS = new WebCheckBox ( "Static checkbox" );
checkBoxS.setAnimated ( false );

return new GroupPanel ( 4, false, checkBoxA, checkBoxS );
}
Expand Down
8 changes: 4 additions & 4 deletions src/com/alee/extended/transition/ComponentTransition.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ private void performTransitionImpl ( final Component content )
return;
}

// Remember new content to which area is switched
lastContent = content;

// When animation disabled or component is not shown performing transition instantly
if ( !isShowing () )
if ( getTransitionEffect () == null || !isShowing () )
{
finishTransitionImpl ( content );
return;
}

// Remember new content to which area is switched
lastContent = content;

// Check for old transition
if ( transition != null )
{
Expand Down
14 changes: 0 additions & 14 deletions src/com/alee/extended/tree/CheckBoxTreeCellRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,6 @@ public interface CheckBoxTreeCellRenderer extends TreeCellRenderer
*/
public void setCheckBoxRendererGap ( int checkBoxRendererGap );

/**
* Returns actual cell renderer used to render cell content.
*
* @return actual cell renderer used to render cell content
*/
public TreeCellRenderer getActualRenderer ();

/**
* Sets actual cell renderer used to render cell content.
*
* @param actualRenderer actual cell renderer used to render cell content
*/
public void setActualRenderer ( TreeCellRenderer actualRenderer );

/**
* Returns checkbox part width in this cell renderer.
*
Expand Down
116 changes: 83 additions & 33 deletions src/com/alee/extended/tree/WebCheckBoxTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,10 @@ public class WebCheckBoxTree<E extends DefaultMutableTreeNode> extends WebTree<E
/**
* Style settings.
*/
protected int checkBoxRendererGap = WebCheckBoxTreeStyle.checkBoxRendererGap;

/**
* Whether user can interact with checkboxes to change their check state or not.
*/
protected boolean checkingEnabled = true;

/**
* Whether partially checked node should be checked or unchecked on toggle.
*/
protected boolean checkMixedOnToggle = true;
protected Integer checkBoxRendererGap = WebCheckBoxTreeStyle.checkBoxRendererGap;
protected Boolean checkBoxVisible = WebCheckBoxTreeStyle.checkBoxVisible;
protected Boolean checkingEnabled = WebCheckBoxTreeStyle.checkingEnabled;
protected Boolean checkMixedOnToggle = WebCheckBoxTreeStyle.checkMixedOnToggle;

/**
* Cusstom checking model.
Expand Down Expand Up @@ -189,30 +182,55 @@ public TreeCellRenderer getActualRenderer ()
@Override
public void setCellRenderer ( final TreeCellRenderer renderer )
{
if ( renderer instanceof CheckBoxTreeCellRenderer )
actualCellRenderer = renderer;
if ( checkBoxCellRenderer == null )
{
checkBoxCellRenderer = ( CheckBoxTreeCellRenderer ) renderer;
actualCellRenderer = checkBoxCellRenderer.getActualRenderer ();
checkBoxCellRenderer = createCheckBoxTreeCellRenderer ();
checkBoxCellRenderer.setCheckBoxRendererGap ( getCheckBoxRendererGap () );
}
else
{
checkBoxCellRenderer = createCheckBoxTreeCellRenderer ( renderer );
actualCellRenderer = renderer;
}
checkBoxCellRenderer.setCheckBoxRendererGap ( checkBoxRendererGap );
super.setCellRenderer ( checkBoxCellRenderer );
}

/**
* Sets special checkbox tree cell renderer.
*
* @param renderer checkbox tree cell renderer
*/
public void setCheckBoxTreeCellRenderer ( CheckBoxTreeCellRenderer renderer )
{
checkBoxCellRenderer = renderer;
checkBoxCellRenderer.setCheckBoxRendererGap ( getCheckBoxRendererGap () );
super.setCellRenderer ( checkBoxCellRenderer );
}

/**
* Creates and returns checkbox tree cell renderer.
*
* @param renderer actual cell renderer
* @return checkbox tree cell renderer
*/
protected WebCheckBoxTreeCellRenderer createCheckBoxTreeCellRenderer ( TreeCellRenderer renderer )
protected WebCheckBoxTreeCellRenderer createCheckBoxTreeCellRenderer ()
{
return new WebCheckBoxTreeCellRenderer ( renderer );
return new WebCheckBoxTreeCellRenderer ( WebCheckBoxTree.this );
}

/**
* Returns gap between checkbox and actual tree renderer.
*
* @return gap between checkbox and actual tree renderer
*/
public int getCheckBoxRendererGap ()
{
return checkBoxRendererGap != null ? checkBoxRendererGap : WebCheckBoxTreeStyle.checkBoxRendererGap;
}

/**
* Sets gap between checkbox and actual tree renderer.
*
* @param gap gap between checkbox and actual tree renderer
*/
public void setCheckBoxRendererGap ( int gap )
{
this.checkBoxRendererGap = gap;
}

/**
Expand Down Expand Up @@ -321,7 +339,7 @@ protected TreeCheckingModel createDefaultCheckingModel ( final WebCheckBoxTree c
* @param node tree node to process
* @return true if checkbox for the specified node should be enabled, false otherwise
*/
@SuppressWarnings ( "UnusedParameters" )
@SuppressWarnings ("UnusedParameters")
public boolean isCheckBoxEnabled ( final E node )
{
return true;
Expand All @@ -333,7 +351,7 @@ public boolean isCheckBoxEnabled ( final E node )
* @param node tree node to process
* @return true if checkbox for the specified node should be visible, false otherwise
*/
@SuppressWarnings ( "UnusedParameters" )
@SuppressWarnings ("UnusedParameters")
public boolean isCheckBoxVisible ( final E node )
{
return true;
Expand All @@ -344,30 +362,52 @@ public boolean isCheckBoxVisible ( final E node )
*
* @return true if checked or unchecked node childs should be checked or unchecked recursively, false otherwise
*/
@SuppressWarnings ( "UnusedParameters" )
@SuppressWarnings ("UnusedParameters")
public boolean isRecursiveCheckingEnabled ()
{
return true;
}

/**
* Returns whether checkboxes are visible in the tree or not.
*
* @return true if checkboxes are visible in the tree, false otherwise
*/
public boolean getCheckBoxVisible ()
{
return checkBoxVisible != null ? checkBoxVisible : WebCheckBoxTreeStyle.checkBoxVisible;
}

/**
* Sets whether checkboxes are visible in the tree or not.
*
* @param visible whether checkboxes are visible in the tree or not
*/
public void setCheckBoxVisible ( final boolean visible )
{
this.checkBoxVisible = visible;
updateAllVisibleNodes ();
}

/**
* Returns whether user can interact with checkboxes to change their check state or not.
*
* @return true if user can interact with checkboxes to change their check state, false otherwise
*/
public boolean isCheckingEnabled ()
{
return checkingEnabled;
return checkingEnabled != null ? checkingEnabled : WebCheckBoxTreeStyle.checkingEnabled;
}

/**
* Sets whether user can interact with checkboxes to change their check state or not.
*
* @param checkingEnabled whether user can interact with checkboxes to change their check state or not
* @param enabled whether user can interact with checkboxes to change their check state or not
*/
public void setCheckingEnabled ( final boolean checkingEnabled )
public void setCheckingEnabled ( final boolean enabled )
{
this.checkingEnabled = checkingEnabled;
this.checkingEnabled = enabled;
repaint ();
}

/**
Expand All @@ -377,7 +417,7 @@ public void setCheckingEnabled ( final boolean checkingEnabled )
*/
public boolean isCheckMixedOnToggle ()
{
return checkMixedOnToggle;
return checkMixedOnToggle != null ? checkMixedOnToggle : WebCheckBoxTreeStyle.checkMixedOnToggle;
}

/**
Expand Down Expand Up @@ -430,6 +470,16 @@ public Rectangle getCheckBoxBounds ( final TreePath treePath )
}
}

/**
* Returns whether user can change checkbox states or not.
*
* @return true if user can change checkbox states, false otherwise
*/
public boolean isCheckingByUserEnabled ()
{
return isEnabled () && getCheckBoxVisible () && isCheckingEnabled ();
}

/**
* WebCheckBoxTree mouse and key actions handler.
*/
Expand All @@ -441,7 +491,7 @@ protected class Handler implements MouseListener, KeyListener
@Override
public void keyPressed ( final KeyEvent e )
{
if ( Hotkey.SPACE.isTriggered ( e ) )
if ( isCheckingByUserEnabled () && Hotkey.SPACE.isTriggered ( e ) )
{
final List<E> nodes = getSelectedNodes ();
if ( nodes.size () > 0 )
Expand All @@ -457,7 +507,7 @@ public void keyPressed ( final KeyEvent e )
@Override
public void mousePressed ( final MouseEvent e )
{
if ( SwingUtils.isLeftMouseButton ( e ) )
if ( isCheckingByUserEnabled () && SwingUtils.isLeftMouseButton ( e ) )
{
final E node = getNodeForLocation ( e.getPoint () );
if ( node != null )
Expand Down
53 changes: 23 additions & 30 deletions src/com/alee/extended/tree/WebCheckBoxTreeCellRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
public class WebCheckBoxTreeCellRenderer extends WebPanel implements CheckBoxTreeCellRenderer
{
/**
* Actual content renderer.
* Checkbox tree.
*/
protected TreeCellRenderer actualRenderer;
protected WebCheckBoxTree checkBoxTree;

/**
* Checkbox component used to renderer checkbox on the tree.
Expand All @@ -46,12 +46,12 @@ public class WebCheckBoxTreeCellRenderer extends WebPanel implements CheckBoxTre
/**
* Constructs new checkbox tree cell renderer.
*
* @param actualRenderer actual content renderer
* @param checkBoxTree checkbox tree to process
*/
public WebCheckBoxTreeCellRenderer ( final TreeCellRenderer actualRenderer )
public WebCheckBoxTreeCellRenderer ( final WebCheckBoxTree checkBoxTree )
{
super ();
this.actualRenderer = actualRenderer;
this.checkBoxTree = checkBoxTree;

setOpaque ( false );

Expand Down Expand Up @@ -79,24 +79,6 @@ public void setCheckBoxRendererGap ( final int checkBoxRendererGap )
checkBox.getMargin ().right = checkBoxRendererGap;
}

/**
* {@inheritDoc}
*/
@Override
public TreeCellRenderer getActualRenderer ()
{
return actualRenderer;
}

/**
* {@inheritDoc}
*/
@Override
public void setActualRenderer ( final TreeCellRenderer actualRenderer )
{
this.actualRenderer = actualRenderer;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -131,12 +113,23 @@ public WebTristateCheckBox getCheckBox ()
public Component getTreeCellRendererComponent ( final JTree tree, final Object value, final boolean selected, final boolean expanded,
final boolean leaf, final int row, final boolean hasFocus )
{
// Updating check state
checkBox.setState ( ( ( WebCheckBoxTree ) tree ).getCheckState ( ( DefaultMutableTreeNode ) value ) );

// Updating actual cell renderer
add ( actualRenderer.getTreeCellRendererComponent ( tree, value, selected, expanded, leaf, row, hasFocus ), BorderLayout.CENTER );

return this;
if ( checkBoxTree.getCheckBoxVisible () )
{
// Updating check state
checkBox.setEnabled ( checkBoxTree.isCheckingByUserEnabled () );
checkBox.setState ( checkBoxTree.getCheckState ( ( DefaultMutableTreeNode ) value ) );

// Updating actual cell renderer
final TreeCellRenderer renderer = checkBoxTree.getActualRenderer ();
add ( renderer.getTreeCellRendererComponent ( tree, value, selected, expanded, leaf, row, hasFocus ), BorderLayout.CENTER );

return this;
}
else
{
// Returning actual cell renderer
final TreeCellRenderer renderer = checkBoxTree.getActualRenderer ();
return renderer.getTreeCellRendererComponent ( tree, value, selected, expanded, leaf, row, hasFocus );
}
}
}
15 changes: 15 additions & 0 deletions src/com/alee/extended/tree/WebCheckBoxTreeStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,19 @@ public final class WebCheckBoxTreeStyle
* Gap between checkbox and actual tree renderer.
*/
public static int checkBoxRendererGap = 0;

/**
* Whether checkboxes are visible in the tree or not.
*/
public static boolean checkBoxVisible = true;

/**
* Whether user can interact with checkboxes to change their check state or not.
*/
public static boolean checkingEnabled = true;

/**
* Whether partially checked node should be checked or unchecked on toggle.
*/
public static boolean checkMixedOnToggle = true;
}
Loading

0 comments on commit c763fb6

Please sign in to comment.