Skip to content

Commit

Permalink
#127 - Hotkey tooltips display style fixed
Browse files Browse the repository at this point in the history
Input prompt added for WebTextArea similar to WebTextField/WebPasswordField input prompt
Field "closeable" added for DocumentData to show/hide document tab close button
SizeMethods is implemented by WebToolBar now
A few critical bugfixes and improvements for StyleManager skin behavior
StyleEditor visual representation slightly improved
Major performance improvements for ReflectUtils methods
A few additional methods for WebList and WebListModel
Additional WebPanel constructor with "styleId" argument
  • Loading branch information
mgarin committed Jun 6, 2014
1 parent 7c48cae commit ecad0f3
Show file tree
Hide file tree
Showing 25 changed files with 860 additions and 303 deletions.
21 changes: 4 additions & 17 deletions src/com/alee/extended/dock/WebDockableFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,20 @@ public WebDockableFrame ( final String frameId, final Icon frameIcon, final Stri
setWebColoredBackground ( false );
setPaintSides ( false, false, false, false );

titlePanel = new WebPanel ( true )
{
@Override
protected void paintComponent ( final Graphics g )
{
super.paintComponent ( g );
g.setColor ( Color.WHITE );
g.drawLine ( 0, 0, 0, getHeight () - 2 );
g.drawLine ( 0, 0, getWidth () - 1, 0 );
g.drawLine ( getWidth () - 1, 0, getWidth () - 1, getHeight () - 2 );
}
};
titlePanel.setPaintSides ( false, false, true, false );
titlePanel.setShadeWidth ( 0 );
titlePanel = new WebPanel ( "dockable-frame-title" );
add ( titlePanel, BorderLayout.NORTH );

titleLabel = new WebLabel ( frameTitle, frameIcon );
titleLabel.setMargin ( 3, 3, 3, 20 );
titleLabel.setDrawShade ( true );
titleLabel.setStyleId ( "dockable-frame-title" );
titlePanel.add ( titleLabel, BorderLayout.CENTER );

buttonsPanel = new WebPanel ( new HorizontalFlowLayout ( 0, false ) );
buttonsPanel = new WebPanel ( "dockable-frame-buttons", new HorizontalFlowLayout ( 0, false ) );
titlePanel.add ( buttonsPanel, BorderLayout.EAST );

dockButton = new WebButton ();
dockButton.setLeftRightSpacing ( 0 );
dockButton.setShadeWidth ( 0 );
dockButton.setFocusable ( false );
dockButton.setDrawSides ( false, true, false, false );
buttonsPanel.add ( dockButton );
}
Expand Down
1 change: 0 additions & 1 deletion src/com/alee/extended/dock/WebDockablePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public static void main ( final String[] args )
{
WebButtonStyle.round = 0;
WebButtonStyle.drawFocus = false;
WebButtonStyle.rolloverDecoratedOnly = true;
// WebButtonStyle.shadeWidth = 0;
WebLookAndFeel.install ();

Expand Down
43 changes: 43 additions & 0 deletions src/com/alee/extended/tab/DocumentData.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public class DocumentData
*/
protected Color background;

/**
* Whether this document is closeable or not.
* All documents are closeable by default, but you may change that.
*/
protected boolean closeable;

/**
* Document content.
* A component that represents document tab content.
Expand Down Expand Up @@ -110,12 +116,29 @@ public DocumentData ( final String id, final Icon icon, final String title, fina
* @param component document content
*/
public DocumentData ( final String id, final Icon icon, final String title, final Color background, final Component component )
{
this ( id, icon, title, background, true, component );
}

/**
* Constructs new document.
*
* @param id document ID
* @param icon document icon
* @param title document title
* @param background document tab background color
* @param closeable whether document is closeable or not
* @param component document content
*/
public DocumentData ( final String id, final Icon icon, final String title, final Color background, final boolean closeable,
final Component component )
{
super ();
this.id = id;
this.icon = icon;
this.title = title;
this.background = background;
this.closeable = closeable;
this.component = component;
}

Expand Down Expand Up @@ -209,6 +232,26 @@ public void setBackground ( final Color background )
this.background = background;
}

/**
* Returns whether document is closeable or not.
*
* @return true if document is closeable, false otherwise
*/
public boolean isCloseable ()
{
return closeable;
}

/**
* Sets whether document is closeable or not.
*
* @param closeable whether document is closeable or not
*/
public void setCloseable ( final boolean closeable )
{
this.closeable = closeable;
}

/**
* Returns document content.
*
Expand Down
31 changes: 19 additions & 12 deletions src/com/alee/extended/tab/PaneData.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public void mousePressed ( final MouseEvent e )
final int index = tabbedPane.getTabAt ( e.getPoint () );
if ( index != -1 )
{
close ( get ( index ) );
final T document = get ( index );
if ( document.isCloseable () )
{
close ( document );
}
}
}
}
Expand All @@ -116,7 +120,7 @@ else if ( SwingUtils.isPopupTrigger ( e ) )

// Variables
final T document = get ( index );
final boolean csb = documentPane.isCloseable ();
final boolean csb = documentPane.isCloseable () && document.isCloseable ();
final boolean spb = data.size () > 1;
final boolean spl = tabbedPane.getParent () instanceof WebSplitPane;

Expand Down Expand Up @@ -319,18 +323,21 @@ protected JComponent createTabComponent ( final T document )
tabPanel.add ( new WebLabel ( document.getIcon () ), BorderLayout.CENTER );
}

final WebButton closeButton = new WebButton ( closeTabIcon, closeTabRolloverIcon );
closeButton.setUndecorated ( true );
closeButton.setFocusable ( false );
closeButton.addActionListener ( new ActionListener ()
if ( getDocumentPane ().isCloseable () && document.isCloseable () )
{
@Override
public void actionPerformed ( final ActionEvent e )
final WebButton closeButton = new WebButton ( closeTabIcon, closeTabRolloverIcon );
closeButton.setUndecorated ( true );
closeButton.setFocusable ( false );
closeButton.addActionListener ( new ActionListener ()
{
close ( document );
}
} );
tabPanel.add ( closeButton, BorderLayout.LINE_END );
@Override
public void actionPerformed ( final ActionEvent e )
{
close ( document );
}
} );
tabPanel.add ( closeButton, BorderLayout.LINE_END );
}

return tabPanel;
}
Expand Down
1 change: 0 additions & 1 deletion src/com/alee/extended/tree/AsyncTreeTransferHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ public boolean importData ( final TransferHandler.TransferSupport support )
final T tree = ( T ) support.getComponent ();
final AsyncTreeModel<N> model = ( AsyncTreeModel<N> ) tree.getModel ();


if ( allowUncheckedDrop )
{
// Acting differently in case parent node childs are not yet loaded
Expand Down
2 changes: 1 addition & 1 deletion src/com/alee/extended/tree/WebCheckBoxTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public void keyPressed ( final KeyEvent e )
final List<E> nodes = getSelectedNodes ();

// Removing invisible nodes from checking list
Iterator<E> nodesIterator = nodes.iterator ();
final Iterator<E> nodesIterator = nodes.iterator ();
while ( nodesIterator.hasNext () )
{
final E node = nodesIterator.next ();
Expand Down
11 changes: 11 additions & 0 deletions src/com/alee/laf/list/WebList.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ public WebListCellRenderer getWebListCellRenderer ()
return renderer instanceof WebListCellRenderer ? ( WebListCellRenderer ) renderer : null;
}

/**
* Returns specific web list model or null if another type of model is used.
*
* @return specific web list model or null if another type of model is used
*/
public WebListModel getWebModel ()
{
final ListModel model = getModel ();
return model instanceof WebListModel ? ( WebListModel ) model : null;
}

/**
* Sets selected value and scrolls view to its cell.
*
Expand Down
24 changes: 24 additions & 0 deletions src/com/alee/laf/list/WebListModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ public void removeAllAfter ( final int index )
*
* @return a String representation of this object
*/
@Override
public String toString ()
{
return delegate.toString ();
Expand Down Expand Up @@ -565,6 +566,16 @@ public T set ( final int index, final T element )
return rv;
}

/**
* Adds the specified element to this list.
*
* @param element element to be added
*/
public void add ( final T element )
{
add ( size (), element );
}

/**
* Inserts the specified element at the specified position in this list.
* <p/>
Expand All @@ -579,13 +590,26 @@ public void add ( final int index, final T element )
fireIntervalAdded ( this, index, index );
}

/**
* Removes the specified element from this list.
*
* @param element element to remove
* @return removed element
*/
public T remove ( final T element )
{
final int index = indexOf ( element );
return index != -1 ? remove ( index ) : null;
}

/**
* Removes the element at the specified position in this list. Returns the element that was removed from the list.
* <p/>
* Throws an {@code ArrayIndexOutOfBoundsException} if the index is out of range ({@code index &lt; 0 || index &gt;=
* size()}).
*
* @param index the index of the element to removed
* @return removed element
*/
public T remove ( final int index )
{
Expand Down
12 changes: 12 additions & 0 deletions src/com/alee/laf/panel/WebPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ public WebPanel ( final String styleId )
setStyleId ( styleId );
}

/**
* onstructs new panel with the specified style ID.
*
* @param styleId style ID
* @param layout panel layout
*/
public WebPanel ( final String styleId, final LayoutManager layout )
{
super ( layout );
setStyleId ( styleId );
}

/**
* onstructs new panel with the specified style ID.
*
Expand Down
12 changes: 7 additions & 5 deletions src/com/alee/laf/text/WebPasswordFieldUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.alee.extended.painter.PainterSupport;
import com.alee.laf.StyleConstants;
import com.alee.laf.WebLookAndFeel;
import com.alee.managers.language.LM;
import com.alee.utils.LafUtils;
import com.alee.utils.SwingUtils;
import com.alee.utils.laf.ShapeProvider;
Expand Down Expand Up @@ -52,13 +53,13 @@ public class WebPasswordFieldUI extends BasicPasswordFieldUI implements ShapePro
private int shadeWidth = WebPasswordFieldStyle.shadeWidth;
private boolean drawBackground = WebPasswordFieldStyle.drawBackground;
private boolean webColored = WebPasswordFieldStyle.webColored;
private Painter painter = WebPasswordFieldStyle.painter;
private Insets fieldMargin = WebPasswordFieldStyle.fieldMargin;
private String inputPrompt = WebTextFieldStyle.inputPrompt;
private Font inputPromptFont = WebTextFieldStyle.inputPromptFont;
private Color inputPromptForeground = WebTextFieldStyle.inputPromptForeground;
private int inputPromptPosition = WebTextFieldStyle.inputPromptPosition;
private boolean hideInputPromptOnFocus = WebTextFieldStyle.hideInputPromptOnFocus;
private Painter painter = WebPasswordFieldStyle.painter;

private JPasswordField passwordField;
private JComponent leadingComponent = null;
Expand Down Expand Up @@ -590,21 +591,22 @@ else if ( drawBorder )
g2d.setFont ( inputPromptFont != null ? inputPromptFont : c.getFont () );
g2d.setPaint ( inputPromptForeground != null ? inputPromptForeground : c.getForeground () );

final String text = LM.get ( inputPrompt );
final FontMetrics fm = g2d.getFontMetrics ();
final int x;
if ( inputPromptPosition == CENTER )
{
x = b.x + b.width / 2 - fm.stringWidth ( inputPrompt ) / 2;
x = b.x + b.width / 2 - fm.stringWidth ( text ) / 2;
}
else if ( ltr && inputPromptPosition == LEADING || !ltr && inputPromptPosition == TRAILING )
else if ( ltr && inputPromptPosition == LEADING || !ltr && inputPromptPosition == TRAILING || inputPromptPosition == LEFT )
{
x = b.x;
}
else
{
x = b.x + b.width - fm.stringWidth ( inputPrompt );
x = b.x + b.width - fm.stringWidth ( text );
}
g2d.drawString ( inputPrompt, x, getBaseline ( c, c.getWidth (), c.getHeight () ) );
g2d.drawString ( text, x, getBaseline ( c, c.getWidth (), c.getHeight () ) );

g2d.setClip ( oc );
}
Expand Down
Loading

0 comments on commit ecad0f3

Please sign in to comment.