001: /*
002: * Copyright 2005-2008 Kirill Grouchnikov, based on work by
003: * Sun Microsystems, Inc. All rights reserved.
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
018: */
019: package org.jvnet.substance.swingx;
020:
021: import javax.swing.*;
022: import javax.swing.plaf.ComponentUI;
023:
024: import org.jdesktop.swingx.JXErrorPane;
025: import org.jdesktop.swingx.plaf.basic.BasicErrorPaneUI;
026: import org.jvnet.lafwidget.LafWidgetUtilities;
027: import org.jvnet.lafwidget.animation.*;
028: import org.jvnet.lafwidget.utils.LafConstants;
029: import org.jvnet.substance.SubstanceLookAndFeel;
030: import org.jvnet.substance.utils.icon.GlowingIcon;
031:
032: /**
033: * UI delegate for the {@link JXErrorPane} component.
034: *
035: * @author Kirill Grouchnikov
036: */
037: public class SubstanceErrorPaneUI extends BasicErrorPaneUI {
038: /**
039: * Fade ID of the icon glow fade sequence.
040: */
041: protected long glowFadeId = -1;
042:
043: static {
044: FadeConfigurationManager.getInstance().allowFades(
045: FadeKind.ICON_GLOW, JXErrorPane.class);
046: }
047:
048: public static ComponentUI createUI(JComponent c) {
049: return new SubstanceErrorPaneUI();
050: }
051:
052: /*
053: * (non-Javadoc)
054: *
055: * @see org.jdesktop.swingx.plaf.basic.BasicErrorPaneUI#installComponents()
056: */
057: @Override
058: protected void installComponents() {
059: super .installComponents();
060:
061: this .errorMessage.setBorder(null);
062: this .errorScrollPane.setOpaque(false);
063: this .errorScrollPane.getViewport().setOpaque(false);
064:
065: this .pane.putClientProperty(
066: SubstanceLookAndFeel.NO_EXTRA_ELEMENTS, Boolean.TRUE);
067: }
068:
069: /*
070: * (non-Javadoc)
071: *
072: * @see org.jdesktop.swingx.plaf.basic.BasicErrorPaneUI#getDefaultErrorIcon()
073: */
074: @Override
075: protected Icon getDefaultErrorIcon() {
076: Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon");
077: return new GlowingIcon(errorIcon, this .pane);
078: }
079:
080: /*
081: * (non-Javadoc)
082: *
083: * @see org.jdesktop.swingx.plaf.basic.BasicErrorPaneUI#getDefaultWarningIcon()
084: */
085: @Override
086: protected Icon getDefaultWarningIcon() {
087: Icon errorIcon = UIManager.getIcon("OptionPane.warningIcon");
088: return new GlowingIcon(errorIcon, this .pane);
089: }
090:
091: /*
092: * (non-Javadoc)
093: *
094: * @see org.jdesktop.swingx.plaf.basic.BasicErrorPaneUI#reinit()
095: */
096: @Override
097: protected void reinit() {
098: super .reinit();
099:
100: if (this .iconLabel.getIcon() != null) {
101: final LafConstants.AnimationKind currAnimKind = LafWidgetUtilities
102: .getAnimationKind(this .pane);
103: if (this .glowFadeId > 0) {
104: FadeTracker.getInstance().requestStopOnCycleBreak(
105: this .glowFadeId);
106: }
107: this .glowFadeId = FadeTracker.getInstance()
108: .trackFadeLooping(FadeKind.ICON_GLOW,
109: currAnimKind.derive(0.2f), this .pane, null,
110: false, new FadeTrackerAdapter() {
111: public void fadeEnded(FadeKind fadeKind) {
112: iconLabel.repaint();
113: }
114:
115: public void fadePerformed(
116: FadeKind fadeKind,
117: float fadeCycle10) {
118: iconLabel.repaint();
119: }
120: }, 3, true);
121: }
122: }
123: }
|