Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed history arrows, started adding tabs instead. jdesktop lib src

moved
here
temporarily - probably won't need to modify after all
  • Loading branch information...
commit 2a8fb2836d0c094d1982200f57e72e6cebad10d1 1 parent 833cf78
@danja authored
Showing with 32,537 additions and 11 deletions.
  1. +0 −2  .classpath
  2. +19 −1 data/default.ttl
  3. +2 −2 data/working.ttl
  4. BIN  lib/swingx/swingx-beaninfo-1.6.2.jar
  5. BIN  lib/swingx/swingx-core-1.6.2.jar
  6. +21 −6 src/org/hyperdata/scute/main/ScuteCopy.java → old/ScuteCopy-pre-tabs.java
  7. +501 −0 src/org/hdesktop/beans/AbstractBean.java
  8. +103 −0 src/org/hdesktop/beans/AbstractSerializableBean.java
  9. +26 −0 src/org/hdesktop/beans/package-info.java
  10. +4 −0 src/org/hdesktop/license.txt
  11. +444 −0 src/org/hdesktop/swingx/AbstractPatternPanel.java
  12. +45 −0 src/org/hdesktop/swingx/BackgroundPaintable.java
  13. +57 −0 src/org/hdesktop/swingx/BackgroundPainter.java
  14. +220 −0 src/org/hdesktop/swingx/ForwardingRepaintManager.java
  15. +94 −0 src/org/hdesktop/swingx/HorizontalLayout.java
  16. +384 −0 src/org/hdesktop/swingx/JXBusyLabel.java
  17. +765 −0 src/org/hdesktop/swingx/JXButton.java
  18. +997 −0 src/org/hdesktop/swingx/JXCollapsiblePane.java
  19. +258 −0 src/org/hdesktop/swingx/JXColorSelectionButton.java
  20. +718 −0 src/org/hdesktop/swingx/JXComboBox.java
  21. +1,026 −0 src/org/hdesktop/swingx/JXDatePicker.java
  22. +400 −0 src/org/hdesktop/swingx/JXDialog.java
  23. +872 −0 src/org/hdesktop/swingx/JXEditorPane.java
  24. +181 −0 src/org/hdesktop/swingx/JXFindBar.java
  25. +299 −0 src/org/hdesktop/swingx/JXFindPanel.java
  26. +154 −0 src/org/hdesktop/swingx/JXFormattedTextField.java
  27. +576 −0 src/org/hdesktop/swingx/JXFrame.java
  28. +800 −0 src/org/hdesktop/swingx/JXGradientChooser.java
  29. +1,758 −0 src/org/hdesktop/swingx/JXGraph.java
  30. +359 −0 src/org/hdesktop/swingx/JXHeader.java
  31. +348 −0 src/org/hdesktop/swingx/JXHyperlink.java
  32. +430 −0 src/org/hdesktop/swingx/JXImagePanel.java
  33. +779 −0 src/org/hdesktop/swingx/JXImageView.java
  34. +1,348 −0 src/org/hdesktop/swingx/JXLabel.java
  35. +1,579 −0 src/org/hdesktop/swingx/JXList.java
  36. +2,003 −0 src/org/hdesktop/swingx/JXLoginPane.java
  37. +1,895 −0 src/org/hdesktop/swingx/JXMonthView.java
  38. +566 −0 src/org/hdesktop/swingx/JXMultiSplitPane.java
  39. +409 −0 src/org/hdesktop/swingx/JXMultiThumbSlider.java
  40. +518 −0 src/org/hdesktop/swingx/JXPanel.java
  41. +355 −0 src/org/hdesktop/swingx/JXRadioGroup.java
  42. +520 −0 src/org/hdesktop/swingx/JXRootPane.java
  43. +829 −0 src/org/hdesktop/swingx/JXSearchField.java
  44. +252 −0 src/org/hdesktop/swingx/JXSearchPanel.java
  45. +317 −0 src/org/hdesktop/swingx/JXStatusBar.java
  46. +4,554 −0 src/org/hdesktop/swingx/JXTable.java
  47. +824 −0 src/org/hdesktop/swingx/JXTableHeader.java
  48. +672 −0 src/org/hdesktop/swingx/JXTaskPane.java
  49. +189 −0 src/org/hdesktop/swingx/JXTaskPaneContainer.java
  50. +107 −0 src/org/hdesktop/swingx/JXTextArea.java
  51. +153 −0 src/org/hdesktop/swingx/JXTextField.java
  52. +458 −0 src/org/hdesktop/swingx/JXTipOfTheDay.java
  53. +305 −0 src/org/hdesktop/swingx/JXTitledPanel.java
  54. +401 −0 src/org/hdesktop/swingx/JXTitledSeparator.java
  55. +1,643 −0 src/org/hdesktop/swingx/JXTree.java
Sorry, we could not display the entire diff because too many files (461) changed.
View
2  .classpath
@@ -29,8 +29,6 @@
<classpathentry kind="lib" path="lib/jena/xercesImpl-2.7.1.jar"/>
<classpathentry kind="lib" path="lib/jena/xml-apis.jar"/>
<classpathentry kind="lib" path="lib/Filters.jar"/>
- <classpathentry kind="lib" path="lib/swingx/swingx-beaninfo-1.6.2.jar"/>
- <classpathentry kind="lib" path="lib/swingx/swingx-core-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/http/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="lib/http/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/http/httpclient-4.1.jar"/>
View
20 data/default.ttl
@@ -1,7 +1,25 @@
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+@prefix rev: <http://purl.org/stuff/rev#> .
+@prefix mo: <http://purl.org/ontology/mo/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix wo: <http://purl.org/ontology/wo/> .
+@prefix void: <http://rdfs.org/ns/void#> .
+@prefix yagop: <http://dbpedia.org/property/yago/> .
+@prefix dcterms: <http://purl.org/dc/terms/> .
+@prefix dbpr: <http://dbpedia.org/resource/> .
+@prefix dbpo: <http://dbpedia.org/ontology/> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix dbpp: <http://dbpedia.org/property/> .
+@prefix yagoc: <http://dbpedia.org/class/yago/> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix po: <http://purl.org/ontology/po/> .
+@prefix rel: <http://purl.org/vocab/relationship/> .
+@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
-@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix x: <http://purl.org/stuff/> .
+<http://purl.org/stuff/scute/danny>
+ foaf:name "danny" .
View
4 data/working.ttl
@@ -2,14 +2,14 @@
@prefix rev: <http://purl.org/stuff/rev#> .
@prefix mo: <http://purl.org/ontology/mo/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix wo: <http://purl.org/ontology/wo/> .
+@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix void: <http://rdfs.org/ns/void#> .
@prefix yagop: <http://dbpedia.org/property/yago/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dbpr: <http://dbpedia.org/resource/> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dbpo: <http://dbpedia.org/ontology/> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dbpp: <http://dbpedia.org/property/> .
@prefix yagoc: <http://dbpedia.org/class/yago/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
View
BIN  lib/swingx/swingx-beaninfo-1.6.2.jar
Binary file not shown
View
BIN  lib/swingx/swingx-core-1.6.2.jar
Binary file not shown
View
27 src/org/hyperdata/scute/main/ScuteCopy.java → old/ScuteCopy-pre-tabs.java
@@ -15,6 +15,7 @@
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.Graphics;
import java.awt.Toolkit;
import java.util.Arrays;
import java.util.List;
@@ -31,12 +32,12 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.Document;
-import org.jdesktop.swingx.JXMultiSplitPane;
-import org.jdesktop.swingx.JXTitledPanel;
-import org.jdesktop.swingx.MultiSplitLayout;
-import org.jdesktop.swingx.MultiSplitLayout.Divider;
-import org.jdesktop.swingx.MultiSplitLayout.Leaf;
-import org.jdesktop.swingx.MultiSplitLayout.Split;
+import org.hdesktop.swingx.JXMultiSplitPane;
+import org.hdesktop.swingx.JXTitledPanel;
+import org.hdesktop.swingx.MultiSplitLayout;
+import org.hdesktop.swingx.MultiSplitLayout.Divider;
+import org.hdesktop.swingx.MultiSplitLayout.Leaf;
+import org.hdesktop.swingx.MultiSplitLayout.Split;
import org.hyperdata.resources.scute.ScuteIcons;
import org.hyperdata.scute.autosave.AutoSave;
@@ -655,4 +656,18 @@ public void showTools(boolean b) {
public void showStatusBar(boolean b) {
statusBar.setVisible(b);
}
+
+ /* (non-Javadoc)
+ * @see org.hyperdata.scute.main.ScuteIF#showTabs(boolean)
+ */
+ @Override
+ public void showTabs(boolean b) {
+ if(b){
+ cardsPanelTabs.setUI(tabUI);
+ } else {
+ cardsPanelTabs.setUI(new javax.swing.plaf.metal.MetalTabbedPaneUI(){
+ protected void paintTabArea(Graphics g,int tabPlacement,int selectedIndex){}
+ });
+ }
+ }
}
View
501 src/org/hdesktop/beans/AbstractBean.java
@@ -0,0 +1,501 @@
+/*
+ * $Id: AbstractBean.java 3100 2008-10-14 22:33:10Z rah003 $
+ *
+ * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.hdesktop.beans;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+
+/**
+ * <p>
+ * A convenience class from which to extend all non-visual AbstractBeans. It
+ * manages the PropertyChange notification system, making it relatively trivial
+ * to add support for property change events in getters/setters.
+ * </p>
+ *
+ * <p>
+ * A non-visual java bean is a Java class that conforms to the AbstractBean
+ * patterns to allow visual manipulation of the bean's properties and event
+ * handlers at design-time.
+ * </p>
+ *
+ * <p>
+ * Here is a simple example bean that contains one property, foo, and the proper
+ * pattern for implementing property change notification:
+ *
+ * <pre><code>
+ * public class ABean extends AbstractBean {
+ * private String foo;
+ *
+ * public void setFoo(String newFoo) {
+ * String old = getFoo();
+ * this.foo = newFoo;
+ * firePropertyChange(&quot;foo&quot;, old, getFoo());
+ * }
+ *
+ * public String getFoo() {
+ * return foo;
+ * }
+ * }
+ * </code></pre>
+ *
+ * </p>
+ *
+ * <p>
+ * You will notice that "getFoo()" is used in the setFoo method rather than
+ * accessing "foo" directly for the gets. This is done intentionally so that if
+ * a subclass overrides getFoo() to return, for instance, a constant value the
+ * property change notification system will continue to work properly.
+ * </p>
+ *
+ * <p>
+ * The firePropertyChange method takes into account the old value and the new
+ * value. Only if the two differ will it fire a property change event. So you
+ * can be assured from the above code fragment that a property change event will
+ * only occur if old is indeed different from getFoo()
+ * </p>
+ *
+ * <p>
+ * <code>AbstractBean</code> also supports vetoable
+ * {@link PropertyChangeEvent} events. These events are similar to
+ * <code>PropertyChange</code> events, except a special exception can be used
+ * to veto changing the property. For example, perhaps the property is changing
+ * from "fred" to "red", but a listener deems that "red" is unexceptable. In
+ * this case, the listener can fire a veto exception and the property must
+ * remain "fred". For example:
+ *
+ * <pre><code>
+ * public class ABean extends AbstractBean {
+ * private String foo;
+ *
+ * public void setFoo(String newFoo) throws PropertyVetoException {
+ * String old = getFoo();
+ * this.foo = newFoo;
+ * fireVetoableChange(&quot;foo&quot;, old, getFoo());
+ * }
+ * public String getFoo() {
+ * return foo;
+ * }
+ * }
+ *
+ * public class Tester {
+ * public static void main(String... args) {
+ * try {
+ * ABean a = new ABean();
+ * a.setFoo(&quot;fred&quot;);
+ * a.addVetoableChangeListener(new VetoableChangeListener() {
+ * public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
+ * if (&quot;red&quot;.equals(evt.getNewValue()) {
+ * throw new PropertyVetoException(&quot;Cannot be red!&quot;, evt);
+ * }
+ * }
+ * }
+ * a.setFoo(&quot;red&quot;);
+ * } catch (Exception e) {
+ * e.printStackTrace(); // this will be executed
+ * }
+ * }
+ * }
+ * </code></pre>
+ *
+ * </p>
+ * <p>
+ * {@code AbstractBean} is not {@link java.io.Serializable}. Special care must
+ * be taken when creating {@code Serializable} subclasses, as the
+ * {@code Serializable} listeners will not be saved. Subclasses will need to
+ * manually save the serializable listeners. The {@link AbstractSerializableBean}
+ * is {@code Serializable} and already handles the listeners correctly. If
+ * possible, it is recommended that {@code Serializable} beans should extend
+ * {@code AbstractSerializableBean}. If it is not possible, the
+ * {@code AbstractSerializableBean} bean implementation provides details on
+ * how to correctly serialize an {@code AbstractBean} subclass.
+ * </p>
+ *
+ * @see AbstractSerializableBean
+ * @status REVIEWED
+ * @author rbair
+ */
+public abstract class AbstractBean {
+ /**
+ * Helper class that manages all the property change notification machinery.
+ * PropertyChangeSupport cannot be extended directly because it requires
+ * a bean in the constructor, and the "this" argument is not valid until
+ * after super construction. Hence, delegation instead of extension
+ */
+ private transient PropertyChangeSupport pcs;
+
+ /**
+ * Helper class that manages all the veto property change notification machinery.
+ */
+ private transient VetoableChangeSupport vcs;
+
+ /** Creates a new instance of AbstractBean */
+ protected AbstractBean() {
+ pcs = new PropertyChangeSupport(this);
+ vcs = new VetoableChangeSupport(this);
+ }
+
+ /**
+ * Creates a new instance of AbstractBean, using the supplied PropertyChangeSupport and
+ * VetoableChangeSupport delegates. Neither of these may be null.
+ */
+ protected AbstractBean(PropertyChangeSupport pcs, VetoableChangeSupport vcs) {
+ if (pcs == null) {
+ throw new NullPointerException("PropertyChangeSupport must not be null");
+ }
+ if (vcs == null) {
+ throw new NullPointerException("VetoableChangeSupport must not be null");
+ }
+
+ this.pcs = pcs;
+ this.vcs = vcs;
+ }
+
+ /**
+ * Add a PropertyChangeListener to the listener list.
+ * The listener is registered for all properties.
+ * The same listener object may be added more than once, and will be called
+ * as many times as it is added.
+ * If <code>listener</code> is null, no exception is thrown and no action
+ * is taken.
+ *
+ * @param listener The PropertyChangeListener to be added
+ */
+ public final void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * Remove a PropertyChangeListener from the listener list.
+ * This removes a PropertyChangeListener that was registered
+ * for all properties.
+ * If <code>listener</code> was added more than once to the same event
+ * source, it will be notified one less time after being removed.
+ * If <code>listener</code> is null, or was never added, no exception is
+ * thrown and no action is taken.
+ *
+ * @param listener The PropertyChangeListener to be removed
+ */
+ public final void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Returns an array of all the listeners that were added to the
+ * PropertyChangeSupport object with addPropertyChangeListener().
+ * <p>
+ * If some listeners have been added with a named property, then
+ * the returned array will be a mixture of PropertyChangeListeners
+ * and <code>PropertyChangeListenerProxy</code>s. If the calling
+ * method is interested in distinguishing the listeners then it must
+ * test each element to see if it's a
+ * <code>PropertyChangeListenerProxy</code>, perform the cast, and examine
+ * the parameter.
+ *
+ * <pre>
+ * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
+ * for (int i = 0; i < listeners.length; i++) {
+ * if (listeners[i] instanceof PropertyChangeListenerProxy) {
+ * PropertyChangeListenerProxy proxy =
+ * (PropertyChangeListenerProxy)listeners[i];
+ * if (proxy.getPropertyName().equals("foo")) {
+ * // proxy is a PropertyChangeListener which was associated
+ * // with the property named "foo"
+ * }
+ * }
+ * }
+ *</pre>
+ *
+ * @see java.beans.PropertyChangeListenerProxy
+ * @return all of the <code>PropertyChangeListeners</code> added or an
+ * empty array if no listeners have been added
+ */
+ public final PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ /**
+ * Add a PropertyChangeListener for a specific property. The listener
+ * will be invoked only when a call on firePropertyChange names that
+ * specific property.
+ * The same listener object may be added more than once. For each
+ * property, the listener will be invoked the number of times it was added
+ * for that property.
+ * If <code>propertyName</code> or <code>listener</code> is null, no
+ * exception is thrown and no action is taken.
+ *
+ * @param propertyName The name of the property to listen on.
+ * @param listener The PropertyChangeListener to be added
+ */
+ public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Remove a PropertyChangeListener for a specific property.
+ * If <code>listener</code> was added more than once to the same event
+ * source for the specified property, it will be notified one less time
+ * after being removed.
+ * If <code>propertyName</code> is null, no exception is thrown and no
+ * action is taken.
+ * If <code>listener</code> is null, or was never added for the specified
+ * property, no exception is thrown and no action is taken.
+ *
+ * @param propertyName The name of the property that was listened on.
+ * @param listener The PropertyChangeListener to be removed
+ */
+ public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Returns an array of all the listeners which have been associated
+ * with the named property.
+ *
+ * @param propertyName The name of the property being listened to
+ * @return all of the <code>PropertyChangeListeners</code> associated with
+ * the named property. If no such listeners have been added,
+ * or if <code>propertyName</code> is null, an empty array is
+ * returned.
+ */
+ public final PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ /**
+ * Report a bound property update to any registered listeners.
+ * No event is fired if old and new are equal and non-null.
+ *
+ * <p>
+ * This is merely a convenience wrapper around the more general
+ * firePropertyChange method that takes {@code
+ * PropertyChangeEvent} value.
+ *
+ * @param propertyName The programmatic name of the property
+ * that was changed.
+ * @param oldValue The old value of the property.
+ * @param newValue The new value of the property.
+ */
+ protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ /**
+ * Fire an existing PropertyChangeEvent to any registered listeners.
+ * No event is fired if the given event's old and new values are
+ * equal and non-null.
+ * @param evt The PropertyChangeEvent object.
+ */
+ protected final void firePropertyChange(PropertyChangeEvent evt) {
+ pcs.firePropertyChange(evt);
+ }
+
+
+ /**
+ * Report a bound indexed property update to any registered
+ * listeners.
+ * <p>
+ * No event is fired if old and new values are equal
+ * and non-null.
+ *
+ * <p>
+ * This is merely a convenience wrapper around the more general
+ * firePropertyChange method that takes {@code PropertyChangeEvent} value.
+ *
+ * @param propertyName The programmatic name of the property that
+ * was changed.
+ * @param index index of the property element that was changed.
+ * @param oldValue The old value of the property.
+ * @param newValue The new value of the property.
+ */
+ protected final void fireIndexedPropertyChange(String propertyName, int index,
+ Object oldValue, Object newValue) {
+ pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
+ }
+
+ /**
+ * Check if there are any listeners for a specific property, including
+ * those registered on all properties. If <code>propertyName</code>
+ * is null, only check for listeners registered on all properties.
+ *
+ * @param propertyName the property name.
+ * @return true if there are one or more listeners for the given property
+ */
+ protected final boolean hasPropertyChangeListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ /**
+ * Check if there are any listeners for a specific property, including
+ * those registered on all properties. If <code>propertyName</code>
+ * is null, only check for listeners registered on all properties.
+ *
+ * @param propertyName the property name.
+ * @return true if there are one or more listeners for the given property
+ */
+ protected final boolean hasVetoableChangeListeners(String propertyName) {
+ return vcs.hasListeners(propertyName);
+ }
+
+ /**
+ * Add a VetoableListener to the listener list.
+ * The listener is registered for all properties.
+ * The same listener object may be added more than once, and will be called
+ * as many times as it is added.
+ * If <code>listener</code> is null, no exception is thrown and no action
+ * is taken.
+ *
+ * @param listener The VetoableChangeListener to be added
+ */
+
+ public final void addVetoableChangeListener(VetoableChangeListener listener) {
+ vcs.addVetoableChangeListener(listener);
+ }
+
+ /**
+ * Remove a VetoableChangeListener from the listener list.
+ * This removes a VetoableChangeListener that was registered
+ * for all properties.
+ * If <code>listener</code> was added more than once to the same event
+ * source, it will be notified one less time after being removed.
+ * If <code>listener</code> is null, or was never added, no exception is
+ * thrown and no action is taken.
+ *
+ * @param listener The VetoableChangeListener to be removed
+ */
+ public final void removeVetoableChangeListener(VetoableChangeListener listener) {
+ vcs.removeVetoableChangeListener(listener);
+ }
+
+ /**
+ * Returns the list of VetoableChangeListeners. If named vetoable change listeners
+ * were added, then VetoableChangeListenerProxy wrappers will returned
+ * <p>
+ * @return List of VetoableChangeListeners and VetoableChangeListenerProxys
+ * if named property change listeners were added.
+ */
+ public final VetoableChangeListener[] getVetoableChangeListeners(){
+ return vcs.getVetoableChangeListeners();
+ }
+
+ /**
+ * Add a VetoableChangeListener for a specific property. The listener
+ * will be invoked only when a call on fireVetoableChange names that
+ * specific property.
+ * The same listener object may be added more than once. For each
+ * property, the listener will be invoked the number of times it was added
+ * for that property.
+ * If <code>propertyName</code> or <code>listener</code> is null, no
+ * exception is thrown and no action is taken.
+ *
+ * @param propertyName The name of the property to listen on.
+ * @param listener The VetoableChangeListener to be added
+ */
+
+ public final void addVetoableChangeListener(String propertyName,
+ VetoableChangeListener listener) {
+ vcs.addVetoableChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Remove a VetoableChangeListener for a specific property.
+ * If <code>listener</code> was added more than once to the same event
+ * source for the specified property, it will be notified one less time
+ * after being removed.
+ * If <code>propertyName</code> is null, no exception is thrown and no
+ * action is taken.
+ * If <code>listener</code> is null, or was never added for the specified
+ * property, no exception is thrown and no action is taken.
+ *
+ * @param propertyName The name of the property that was listened on.
+ * @param listener The VetoableChangeListener to be removed
+ */
+
+ public final void removeVetoableChangeListener(String propertyName,
+ VetoableChangeListener listener) {
+ vcs.removeVetoableChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Returns an array of all the listeners which have been associated
+ * with the named property.
+ *
+ * @param propertyName The name of the property being listened to
+ * @return all the <code>VetoableChangeListeners</code> associated with
+ * the named property. If no such listeners have been added,
+ * or if <code>propertyName</code> is null, an empty array is
+ * returned.
+ */
+ public final VetoableChangeListener[] getVetoableChangeListeners(String propertyName) {
+ return vcs.getVetoableChangeListeners(propertyName);
+ }
+
+ /**
+ * Report a vetoable property update to any registered listeners. If
+ * anyone vetos the change, then fire a new event reverting everyone to
+ * the old value and then rethrow the PropertyVetoException.
+ * <p>
+ * No event is fired if old and new are equal and non-null.
+ *
+ * @param propertyName The programmatic name of the property
+ * that is about to change..
+ * @param oldValue The old value of the property.
+ * @param newValue The new value of the property.
+ * @exception PropertyVetoException if the recipient wishes the property
+ * change to be rolled back.
+ */
+ protected final void fireVetoableChange(String propertyName,
+ Object oldValue, Object newValue)
+ throws PropertyVetoException {
+ vcs.fireVetoableChange(propertyName, oldValue, newValue);
+ }
+
+ /**
+ * Fire a vetoable property update to any registered listeners. If
+ * anyone vetos the change, then fire a new event reverting everyone to
+ * the old value and then rethrow the PropertyVetoException.
+ * <p>
+ * No event is fired if old and new are equal and non-null.
+ *
+ * @param evt The PropertyChangeEvent to be fired.
+ * @exception PropertyVetoException if the recipient wishes the property
+ * change to be rolled back.
+ */
+ protected final void fireVetoableChange(PropertyChangeEvent evt)
+ throws PropertyVetoException {
+ vcs.fireVetoableChange(evt);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ AbstractBean result = (AbstractBean) super.clone();
+ result.pcs = new PropertyChangeSupport(result);
+ result.vcs = new VetoableChangeSupport(result);
+ return result;
+ }
+}
View
103 src/org/hdesktop/beans/AbstractSerializableBean.java
@@ -0,0 +1,103 @@
+/*
+ * $Id: AbstractSerializableBean.java 3100 2008-10-14 22:33:10Z rah003 $
+ *
+ * Copyright 2008 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.hdesktop.beans;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * This subclass enhances {@code AbstractBean} by implementing the
+ * {@code Serializable} interface. {@code AbstractSerializableBean} correctly
+ * serializes all {@code Serializable} listeners that it contains. Implementors
+ * that need to extends {@code AbstractBean} or one of its subclasses and
+ * require serialization should use this class if possible. If it is not
+ * possible to extend this class, the implementation can guide implementors on
+ * how to properly serialize the listeners.
+ *
+ * @author Karl George Schaefer
+ *
+ * @see Serializable
+ * @see ObjectInputStream
+ * @see ObjectOutputStream
+ */
+public abstract class AbstractSerializableBean extends AbstractBean implements
+ Serializable {
+ /**
+ * Creates a new instance of {@code AbstractSerializableBean}.
+ */
+ protected AbstractSerializableBean() {
+ super();
+ }
+
+ /**
+ * Creates a new instance of {@code AbstractSerializableBean}, using the
+ * supplied support delegates. Neither of these may be {@code null}.
+ *
+ * @param pcs
+ * the property change support class to use
+ * @param vcs
+ * the vetoable change support class to use
+ * @throws NullPointerException
+ * if any parameter is {@code null}
+ */
+ protected AbstractSerializableBean(PropertyChangeSupport pcs,
+ VetoableChangeSupport vcs) {
+ super(pcs, vcs);
+ }
+
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ s.defaultWriteObject();
+
+ for (PropertyChangeListener l : getPropertyChangeListeners()) {
+ if (l instanceof Serializable) {
+ s.writeObject(l);
+ }
+ }
+
+ for (VetoableChangeListener l : getVetoableChangeListeners()) {
+ if (l instanceof Serializable) {
+ s.writeObject(l);
+ }
+ }
+
+ s.writeObject(null);
+ }
+
+ private void readObject(ObjectInputStream s) throws ClassNotFoundException,
+ IOException {
+ s.defaultReadObject();
+
+ Object listenerOrNull;
+ while (null != (listenerOrNull = s.readObject())) {
+ if (listenerOrNull instanceof PropertyChangeListener) {
+ addPropertyChangeListener((PropertyChangeListener) listenerOrNull);
+ } else if (listenerOrNull instanceof VetoableChangeListener) {
+ addVetoableChangeListener((VetoableChangeListener) listenerOrNull);
+ }
+ }
+ }
+}
View
26 src/org/hdesktop/beans/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * $Id: package-info.java 3100 2008-10-14 22:33:10Z rah003 $
+ *
+ * Copyright 2008 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/**
+ * Contains classes to extend the functionality defined in the
+ * {@code java.beans} package.
+ */
+package org.hdesktop.beans;
+
View
4 src/org/hdesktop/license.txt
@@ -0,0 +1,4 @@
+The material under org.hdesktop is derived from org.jdesktop, the SwingX libraries.
+While this material is currently in the same tree as org.hyperdata, that's only for convenience during development.
+For release purpose it will be packaged separately retaining the original LGPL license, whereas org.hyperdata will
+be under the (more liberal) Apache2 license.
View
444 src/org/hdesktop/swingx/AbstractPatternPanel.java
@@ -0,0 +1,444 @@
+/*
+ * $Id: AbstractPatternPanel.java 2948 2008-06-16 15:02:14Z kleopatra $
+ *
+ * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.hdesktop.swingx;
+
+import java.awt.Dimension;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Locale;
+
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import org.hdesktop.swingx.action.AbstractActionExt;
+import org.hdesktop.swingx.action.ActionContainerFactory;
+import org.hdesktop.swingx.action.BoundAction;
+import org.hdesktop.swingx.plaf.LookAndFeelAddons;
+import org.hdesktop.swingx.plaf.UIManagerExt;
+import org.hdesktop.swingx.search.PatternModel;
+
+/**
+ * Common base class of ui clients.
+ *
+ * Implements basic synchronization between PatternModel state and
+ * actions bound to it.
+ *
+ *
+ *
+ * PENDING: extending JXPanel is a convenience measure, should be extracted
+ * into a dedicated controller.
+ * PENDING: should be re-visited when swingx goes binding-aware
+ *
+ * @author Jeanette Winzenburg
+ */
+public abstract class AbstractPatternPanel extends JXPanel {
+
+ public static final String SEARCH_FIELD_LABEL = "searchFieldLabel";
+ public static final String SEARCH_FIELD_MNEMONIC = SEARCH_FIELD_LABEL + ".mnemonic";
+ public static final String SEARCH_TITLE = "searchTitle";
+ public static final String MATCH_ACTION_COMMAND = "match";
+
+ static {
+ // Hack to enforce loading of SwingX framework ResourceBundle
+ LookAndFeelAddons.getAddon();
+ }
+
+ protected JLabel searchLabel;
+ protected JTextField searchField;
+ protected JCheckBox matchCheck;
+
+ protected PatternModel patternModel;
+ private ActionContainerFactory actionFactory;
+
+
+//------------------------ actions
+
+ /**
+ * Callback action bound to MATCH_ACTION_COMMAND.
+ */
+ public abstract void match();
+
+ /**
+ * convenience method for type-cast to AbstractActionExt.
+ *
+ * @param key Key to retrieve action
+ * @return Action bound to this key
+ * @see AbstractActionExt
+ */
+ protected AbstractActionExt getAction(String key) {
+ // PENDING: outside clients might add different types?
+ return (AbstractActionExt) getActionMap().get(key);
+ }
+
+ /**
+ * creates and registers all actions for the default the actionMap.
+ */
+ protected void initActions() {
+ initPatternActions();
+ initExecutables();
+ }
+
+ /**
+ * creates and registers all "executable" actions.
+ * Meaning: the actions bound to a callback method on this.
+ *
+ * PENDING: not quite correctly factored? Name?
+ *
+ */
+ protected void initExecutables() {
+ Action execute = createBoundAction(MATCH_ACTION_COMMAND, "match");
+ getActionMap().put(JXDialog.EXECUTE_ACTION_COMMAND,
+ execute);
+ getActionMap().put(MATCH_ACTION_COMMAND, execute);
+ refreshEmptyFromModel();
+ }
+
+ /**
+ * creates actions bound to PatternModel's state.
+ */
+ protected void initPatternActions() {
+ ActionMap map = getActionMap();
+ map.put(PatternModel.MATCH_CASE_ACTION_COMMAND,
+ createModelStateAction(PatternModel.MATCH_CASE_ACTION_COMMAND,
+ "setCaseSensitive", getPatternModel().isCaseSensitive()));
+ map.put(PatternModel.MATCH_WRAP_ACTION_COMMAND,
+ createModelStateAction(PatternModel.MATCH_WRAP_ACTION_COMMAND,
+ "setWrapping", getPatternModel().isWrapping()));
+ map.put(PatternModel.MATCH_BACKWARDS_ACTION_COMMAND,
+ createModelStateAction(PatternModel.MATCH_BACKWARDS_ACTION_COMMAND,
+ "setBackwards", getPatternModel().isBackwards()));
+ map.put(PatternModel.MATCH_INCREMENTAL_ACTION_COMMAND,
+ createModelStateAction(PatternModel.MATCH_INCREMENTAL_ACTION_COMMAND,
+ "setIncremental", getPatternModel().isIncremental()));
+ }
+
+ /**
+ * Returns a potentially localized value from the UIManager. The given key
+ * is prefixed by this component|s <code>UIPREFIX</code> before doing the
+ * lookup. The lookup respects this table's current <code>locale</code>
+ * property. Returns the key, if no value is found.
+ *
+ * @param key the bare key to look up in the UIManager.
+ * @return the value mapped to UIPREFIX + key or key if no value is found.
+ */
+ protected String getUIString(String key) {
+ return getUIString(key, getLocale());
+ }
+
+ /**
+ * Returns a potentially localized value from the UIManager for the
+ * given locale. The given key
+ * is prefixed by this component's <code>UIPREFIX</code> before doing the
+ * lookup. Returns the key, if no value is found.
+ *
+ * @param key the bare key to look up in the UIManager.
+ * @param locale the locale use for lookup
+ * @return the value mapped to UIPREFIX + key in the given locale,
+ * or key if no value is found.
+ */
+ protected String getUIString(String key, Locale locale) {
+ String text = UIManagerExt.getString(PatternModel.SEARCH_PREFIX + key, locale);
+ return text != null ? text : key;
+ }
+
+
+ /**
+ * creates, configures and returns a bound state action on a boolean property
+ * of the PatternModel.
+ *
+ * @param command the actionCommand - same as key to find localizable resources
+ * @param methodName the method on the PatternModel to call on item state changed
+ * @param initial the initial value of the property
+ * @return newly created action
+ */
+ protected AbstractActionExt createModelStateAction(String command, String methodName, boolean initial) {
+ String actionName = getUIString(command);
+ BoundAction action = new BoundAction(actionName,
+ command);
+ action.setStateAction();
+ action.registerCallback(getPatternModel(), methodName);
+ action.setSelected(initial);
+ return action;
+ }
+
+ /**
+ * creates, configures and returns a bound action to the given method of
+ * this.
+ *
+ * @param actionCommand the actionCommand, same as key to find localizable resources
+ * @param methodName the method to call an actionPerformed.
+ * @return newly created action
+ */
+ protected AbstractActionExt createBoundAction(String actionCommand, String methodName) {
+ String actionName = getUIString(actionCommand);
+ BoundAction action = new BoundAction(actionName,
+ actionCommand);
+ action.registerCallback(this, methodName);
+ return action;
+ }
+
+//------------------------ dynamic locale support
+
+
+ /**
+ * {@inheritDoc} <p>
+ * Overridden to update locale-dependent properties.
+ *
+ * @see #updateLocaleState(Locale)
+ */
+ @Override
+ public void setLocale(Locale l) {
+ updateLocaleState(l);
+ super.setLocale(l);
+ }
+
+ /**
+ * Updates locale-dependent state.
+ *
+ * Here: updates registered column actions' locale-dependent state.
+ * <p>
+ *
+ * PENDING: Try better to find all column actions including custom
+ * additions? Or move to columnControl?
+ *
+ * @see #setLocale(Locale)
+ */
+ protected void updateLocaleState(Locale locale) {
+ for (Object key : getActionMap().allKeys()) {
+ if (key instanceof String) {
+ String keyString = getUIString((String) key, locale);
+ if (!key.equals(keyString)) {
+ getActionMap().get(key).putValue(Action.NAME, keyString);
+
+ }
+ }
+ }
+ bindSearchLabel(locale);
+ }
+
+
+ //---------------------- synch patternModel <--> components
+
+ /**
+ * called from listening to pattern property of PatternModel.
+ *
+ * This implementation calls match() if the model is in
+ * incremental state.
+ *
+ */
+ protected void refreshPatternFromModel() {
+ if (getPatternModel().isIncremental()) {
+ match();
+ }
+ }
+
+
+ /**
+ * returns the patternModel. Lazyly creates and registers a
+ * propertyChangeListener if null.
+ *
+ * @return current <code>PatternModel</code> if it exists or newly created
+ * one if it was not initialized before this call
+ */
+ protected PatternModel getPatternModel() {
+ if (patternModel == null) {
+ patternModel = createPatternModel();
+ patternModel.addPropertyChangeListener(getPatternModelListener());
+ }
+ return patternModel;
+ }
+
+
+ /**
+ * factory method to create the PatternModel.
+ * Hook for subclasses to install custom models.
+ *
+ * @return newly created <code>PatternModel</code>
+ */
+ protected PatternModel createPatternModel() {
+ return new PatternModel();
+ }
+
+ /**
+ * creates and returns a PropertyChangeListener to the PatternModel.
+ *
+ * NOTE: the patternModel is totally under control of this class - currently
+ * there's no need to keep a reference to the listener.
+ *
+ * @return created and bound to appropriate callback methods
+ * <code>PropertyChangeListener</code>
+ */
+ protected PropertyChangeListener getPatternModelListener() {
+ return new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ String property = evt.getPropertyName();
+ if ("pattern".equals(property)) {
+ refreshPatternFromModel();
+ } else if ("rawText".equals(property)) {
+ refreshDocumentFromModel();
+ } else if ("caseSensitive".equals(property)){
+ getAction(PatternModel.MATCH_CASE_ACTION_COMMAND).
+ setSelected(((Boolean) evt.getNewValue()).booleanValue());
+ } else if ("wrapping".equals(property)) {
+ getAction(PatternModel.MATCH_WRAP_ACTION_COMMAND).
+ setSelected(((Boolean) evt.getNewValue()).booleanValue());
+ } else if ("backwards".equals(property)) {
+ getAction(PatternModel.MATCH_BACKWARDS_ACTION_COMMAND).
+ setSelected(((Boolean) evt.getNewValue()).booleanValue());
+ } else if ("incremental".equals(property)) {
+ getAction(PatternModel.MATCH_INCREMENTAL_ACTION_COMMAND).
+ setSelected(((Boolean) evt.getNewValue()).booleanValue());
+
+ } else if ("empty".equals(property)) {
+ refreshEmptyFromModel();
+ }
+
+ }
+
+ };
+ }
+
+ /**
+ * called from listening to empty property of PatternModel.
+ *
+ * this implementation synch's the enabled state of the action with
+ * MATCH_ACTION_COMMAND to !empty.
+ *
+ */
+ protected void refreshEmptyFromModel() {
+ boolean enabled = !getPatternModel().isEmpty();
+ getAction(MATCH_ACTION_COMMAND).setEnabled(enabled);
+
+ }
+
+ /**
+ * callback method from listening to searchField.
+ *
+ */
+ protected void refreshModelFromDocument() {
+ getPatternModel().setRawText(searchField.getText());
+ }
+
+ /**
+ * callback method that updates document from the search field
+ *
+ */
+ protected void refreshDocumentFromModel() {
+ if (searchField.getText().equals(getPatternModel().getRawText())) return;
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ searchField.setText(getPatternModel().getRawText());
+ }
+ });
+ }
+
+ /**
+ * Create <code>DocumentListener</code> for the search field that calls
+ * corresponding callback method whenever the search field contents is being changed
+ *
+ * @return newly created <code>DocumentListener</code>
+ */
+ protected DocumentListener getSearchFieldListener() {
+ return new DocumentListener() {
+ public void changedUpdate(DocumentEvent ev) {
+ // JW - really?? we've a PlainDoc without Attributes
+ refreshModelFromDocument();
+ }
+
+ public void insertUpdate(DocumentEvent ev) {
+ refreshModelFromDocument();
+ }
+
+ public void removeUpdate(DocumentEvent ev) {
+ refreshModelFromDocument();
+ }
+
+ };
+ }
+
+//-------------------------- config helpers
+
+ /**
+ * configure and bind components to/from PatternModel
+ */
+ protected void bind() {
+ bindSearchLabel(getLocale());
+ searchField.getDocument().addDocumentListener(getSearchFieldListener());
+ getActionContainerFactory().configureButton(matchCheck,
+ (AbstractActionExt) getActionMap().get(PatternModel.MATCH_CASE_ACTION_COMMAND),
+ null);
+
+ }
+
+ /**
+ * Configures the searchLabel.
+ * Here: sets text and mnenomic properties form ui values,
+ * configures as label for searchField.
+ */
+ protected void bindSearchLabel(Locale locale) {
+ searchLabel.setText(getUIString(SEARCH_FIELD_LABEL, locale));
+ String mnemonic = getUIString(SEARCH_FIELD_MNEMONIC, locale);
+ if (mnemonic != SEARCH_FIELD_MNEMONIC) {
+ searchLabel.setDisplayedMnemonic(mnemonic.charAt(0));
+ }
+ searchLabel.setLabelFor(searchField);
+ }
+
+ /**
+ * @return current <code>ActionContainerFactory</code>.
+ * Will lazily create new factory if it does not exist
+ */
+ protected ActionContainerFactory getActionContainerFactory() {
+ if (actionFactory == null) {
+ actionFactory = new ActionContainerFactory(null);
+ }
+ return actionFactory;
+ }
+
+ /**
+ * Initialize all the incorporated components and models
+ */
+ protected void initComponents() {
+ searchLabel = new JLabel();
+ searchField = new JTextField(getSearchFieldWidth()) {
+ @Override
+ public Dimension getMaximumSize() {
+ Dimension superMax = super.getMaximumSize();
+ superMax.height = getPreferredSize().height;
+ return superMax;
+ }
+ };
+ matchCheck = new JCheckBox();
+ }
+
+ /**
+ * @return width in characters of the search field
+ */
+ protected int getSearchFieldWidth() {
+ return 15;
+ }
+}
View
45 src/org/hdesktop/swingx/BackgroundPaintable.java
@@ -0,0 +1,45 @@
+/*
+ * $Id: BackgroundPaintable.java 3728 2010-07-19 21:10:39Z kschaefe $
+ *
+ * Copyright 2010 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.hdesktop.swingx;
+
+import org.hdesktop.swingx.painter.Painter;
+
+/**
+ * An interface to define the common methods that are required for defining a background painter.
+ *
+ * @author kschaefer
+ */
+interface BackgroundPaintable {
+ /**
+ * Returns the current background painter.
+ *
+ * @return the current painter
+ * @see #setBackgroundPainter(Painter)
+ * @see #isPaintBorderInsets()
+ */
+ Painter getBackgroundPainter();
+
+ void setBackgroundPainter(Painter painter);
+
+ boolean isPaintBorderInsets();
+
+ void setPaintBorderInsets(boolean paintBorderInsets);
+}
View
57 src/org/hdesktop/swingx/BackgroundPainter.java
@@ -0,0 +1,57 @@
+/*
+ * $Id: BackgroundPainter.java 3713 2010-07-13 14:07:40Z kschaefe $
+ *
+ * Copyright 2010 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.hdesktop.swingx;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import javax.swing.JComponent;
+import javax.swing.UIManager;
+
+import org.hdesktop.swingx.painter.Painter;
+
+/**
+ * @author kschaefer
+ *
+ */
+
+class BackgroundPainter implements Painter<JComponent> {
+ private final Color color;
+
+ public BackgroundPainter(Color color) {
+ this.color = color;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void paint(Graphics2D g, JComponent object, int width, int height) {
+ if (color == null) {
+ return;
+ }
+
+ if (object.isOpaque() || UIManager.getLookAndFeel().getID().equals("Nimbus")) {
+ g.setColor(color);
+ g.fillRect(0, 0, width, height);
+ }
+ }
+}
View
220 src/org/hdesktop/swingx/ForwardingRepaintManager.java
@@ -0,0 +1,220 @@
+/*
+ * $Id: ForwardingRepaintManager.java 3690 2010-05-03 17:55:44Z kschaefe $
+ *
+ * Copyright 2009 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.hdesktop.swingx;
+
+import java.applet.Applet;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Window;
+
+import javax.swing.JComponent;
+import javax.swing.RepaintManager;
+
+import org.hdesktop.swingx.util.Contract;
+
+/**
+ * A {@code RepaintManager} that is designed to forward all calls to a contained
+ * delegate. This class is designed for extension, such that subclasses should
+ * override method as appropriate and allow the original repaint manager to
+ * handle the rest of the work.
+ * <p>
+ * Install a forwarding repaint manager:
+ *
+ * <pre>
+ * RepaintManager manager = RepaintManager.currentManager(this);
+ * RepaintManager frm = new ForwardingRepaintManager(manager);
+ * RepaintManager.setCurrentManager(frm);
+ * </pre>
+ *
+ * @author Karl George Schaefer
+ * @author pietblok (original facade/delegate idea)
+ */
+public class ForwardingRepaintManager extends RepaintManager {
+ private RepaintManager delegate;
+
+ /**
+ * Creates a new forwarding manager that forwards all calls to the delegate.
+ *
+ * @param delegate
+ * the manager backing this {@code ForwardingRepaintManager}
+ * @throws NullPointerException
+ * if {@code delegate} is {@code null}
+ */
+ public ForwardingRepaintManager(RepaintManager delegate) {
+ this.delegate = Contract.asNotNull(delegate, "delegate is null");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDirtyRegion(Applet applet, int x, int y, int w, int h) {
+ delegate.addDirtyRegion(applet, x, y, w, h);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
+ delegate.addDirtyRegion(c, x, y, w, h);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDirtyRegion(Window window, int x, int y, int w, int h) {
+ delegate.addDirtyRegion(window, x, y, w, h);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void addInvalidComponent(JComponent invalidComponent) {
+ delegate.addInvalidComponent(invalidComponent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Rectangle getDirtyRegion(JComponent component) {
+ return delegate.getDirtyRegion(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Dimension getDoubleBufferMaximumSize() {
+ return delegate.getDoubleBufferMaximumSize();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) {
+ return delegate.getOffscreenBuffer(c, proposedWidth, proposedHeight);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) {
+ return delegate.getVolatileOffscreenBuffer(c, proposedWidth, proposedHeight);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isCompletelyDirty(JComponent component) {
+ return delegate.isCompletelyDirty(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isDoubleBufferingEnabled() {
+ return delegate.isDoubleBufferingEnabled();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void markCompletelyClean(JComponent component) {
+ delegate.markCompletelyClean(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void markCompletelyDirty(JComponent component) {
+ delegate.markCompletelyDirty(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void paintDirtyRegions() {
+ delegate.paintDirtyRegions();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void removeInvalidComponent(JComponent component) {
+ delegate.removeInvalidComponent(component);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDoubleBufferingEnabled(boolean flag) {
+ delegate.setDoubleBufferingEnabled(flag);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setDoubleBufferMaximumSize(Dimension d) {
+ delegate.setDoubleBufferMaximumSize(d);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized String toString() {
+ return delegate.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void validateInvalidComponents() {
+ delegate.validateInvalidComponents();
+ }
+
+ /**
+ * Gets the delegate repaint manager backing this forwarding repaint
+ * manager.
+ *
+ * @return the delegate for this forwarding manager
+ */
+ public final RepaintManager getDelegateManager() {
+ return delegate;
+ }
+}
View
94 src/org/hdesktop/swingx/HorizontalLayout.java
@@ -0,0 +1,94 @@
+/*
+ * $Id: HorizontalLayout.java 2857 2008-03-28 00:18:32Z kschaefe $
+ *
+ * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.hdesktop.swingx;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Organizes components in a horizontal layout.
+ *
+ * @author Romain Guy <romain.guy@mac.com>
+ */
+public class HorizontalLayout implements LayoutManager {
+ private int gap = 0;
+
+ public HorizontalLayout() {
+ }
+
+ public HorizontalLayout(int gap) {
+ this.gap = gap;
+ }
+
+ public int getGap() {
+ return gap;
+ }
+
+ public void setGap(int gap) {
+ this.gap = gap;
+ }
+
+ public void addLayoutComponent(String name, Component c) {
+ }
+
+ public void layoutContainer(Container parent) {
+ Insets insets = parent.getInsets();
+ Dimension size = parent.getSize();
+ int height = size.height - insets.top - insets.bottom;
+ int width = insets.left;
+ for (int i = 0, c = parent.getComponentCount(); i < c; i++) {
+ Component m = parent.getComponent(i);
+ if (m.isVisible()) {
+ m.setBounds(width, insets.top,
+ m.getPreferredSize().width, height);
+ width += m.getSize().width + gap;
+ }
+ }
+ }
+
+ public Dimension minimumLayoutSize(Container parent) {
+ return preferredLayoutSize(parent);
+ }
+
+ public Dimension preferredLayoutSize(Container parent) {
+ Insets insets = parent.getInsets();
+ Dimension pref = new Dimension(0, 0);
+ for (int i = 0, c = parent.getComponentCount(); i < c; i++) {
+ Component m = parent.getComponent(i);
+ if (m.isVisible()) {
+ Dimension componentPreferredSize =
+ parent.getComponent(i).getPreferredSize();
+ pref.height = Math.max(pref.height, componentPreferredSize.height);
+ pref.width += componentPreferredSize.width + gap;
+ }
+ }
+ pref.width += insets.left + insets.right;
+ pref.height += insets.top + insets.bottom;
+ return pref;
+ }
+
+ public void removeLayoutComponent(Component c) {
+ }
+}
View
384 src/org/hdesktop/swingx/JXBusyLabel.java
@@ -0,0 +1,384 @@
+/*
+ * $Id: JXBusyLabel.java 3502 2009-09-11 01:21:00Z kschaefe $
+ *
+ * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.hdesktop.swingx;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JLabel;
+import javax.swing.Timer;
+import javax.swing.plaf.LabelUI;
+
+import org.hdesktop.swingx.icon.PainterIcon;
+import org.hdesktop.swingx.painter.BusyPainter;
+import org.hdesktop.swingx.plaf.BusyLabelAddon;
+import org.hdesktop.swingx.plaf.BusyLabelUI;
+import org.hdesktop.swingx.plaf.LookAndFeelAddons;
+
+/**
+ * <p>A simple circular animation, useful for denoting an action is taking
+ * place that may take an unknown length of time to complete. Similar to an
+ * indeterminant JProgressBar, but with a different look.</p>
+ *
+ * <p>For example:
+ * <pre><code>
+ * JXFrame frame = new JXFrame("test", true);
+ * JXBusyLabel label = new JXBusyLabel();
+ * frame.add(label);
+ * //...
+ * label.setBusy(true);
+ * </code></pre></p>
+ * Another more complicated example:
+ * <pre><code>
+ * JXBusyLabel label = new JXBusyLabel(new Dimension(100,84));
+ * BusyPainter painter = new BusyPainter(
+ * new Rectangle2D.Float(0, 0,13.500001f,1),
+ * new RoundRectangle2D.Float(12.5f,12.5f,59.0f,59.0f,10,10));
+ * painter.setTrailLength(5);
+ * painter.setPoints(31);
+ * painter.setFrame(1);
+ * label.setPreferredSize(new Dimension(100,84));
+ * label.setIcon(new EmptyIcon(100,84));
+ * label.setBusyPainter(painter);
+ *</code></pre>
+ *
+ * Another example:
+ * <pre><code>
+ * JXBusyLabel label = new MyBusyLabel(new Dimension(100, 84));
+ * </code></pre>
+ *
+ * where MyBusyLabel is:<br>
+ * <pre><code>
+ * public class MyBusyLabel extends JXBusyLabel {
+ * public MyBusyLabel(Dimension prefSize) {
+ * super(prefSize);
+ * }
+ *
+ * protected BusyLabel createBusyLabel(Dimension dim) {
+ * BusyPainter painter = new BusyPainter(
+ * new Rectangle2D.Float(0, 0,13.500001f,1),
+ * new RoundRectangle2D.Float(12.5f,12.5f,59.0f,59.0f,10,10));
+ * painter.setTrailLength(5);
+ * painter.setPoints(31);
+ * painter.setFrame(1);
+ *
+ * return painter;
+ * }
+ * }
+ * </code></pre>
+ *
+ * @author rbair
+ * @author joshy
+ * @author rah003
+ * @author headw01
+ */
+public class JXBusyLabel extends JLabel {
+
+ private static final long serialVersionUID = 5979268460848257147L;
+ private BusyPainter busyPainter;
+ private Timer busy;
+ private int delay;
+ /** Status flag to save/restore status of timer when moving component between containers. */
+ private boolean wasBusyOnNotify = false;
+
+ /**
+ * UI Class ID
+ */
+ public final static String uiClassID = "BusyLabelUI";
+
+ /**
+ * Direction is used to set the initial direction in which the
+ * animation starts.
+ *
+ * @see JXBusyLabel#setDirection(org.hdesktop.swingx.JXBusyLabel.Direction)
+ */
+ public static enum Direction {
+ /**
+ * cycle proceeds forward
+ */
+ RIGHT,
+ /** cycle proceeds backward */
+ LEFT,
+ };
+
+ /**
+ * Sets direction of rotation. <code>Direction.RIGHT</code> is the default
+ * value. Direction is taken from the very top point so <code>Direction.RIGHT</code> enables rotation clockwise.
+ * @param dir Direction of rotation.
+ */
+ public void setDirection(Direction dir) {
+ direction = dir;
+ getBusyPainter().setDirection(dir);
+ }
+
+ private Direction direction;
+
+ /**
+ * Creates a default JXLoginPane instance
+ */
+ static {
+ LookAndFeelAddons.contribute(new BusyLabelAddon());
+ }
+
+ {
+ // Initialize the delay from the UI class.
+ BusyLabelUI ui = (BusyLabelUI)getUI();
+ if (ui != null) {
+ delay = ui.getDelay();
+ }
+ }
+
+ /** Creates a new instance of <code>JXBusyLabel</code> initialized to circular shape in bounds of 26 by 26 points.*/
+ public JXBusyLabel() {
+ this(null);
+ }
+
+ /**
+ * Creates a new instance of <code>JXBusyLabel</code> initialized to the arbitrary size and using default circular progress indicator.
+ * @param dim Preferred size of the label.
+ */
+ public JXBusyLabel(Dimension dim) {
+ super();
+ this.setPreferredSize(dim);
+
+ // Initialize the BusyPainter.
+ getBusyPainter();
+ }
+
+ /**
+ * Initialize the BusyPainter and (this) JXBusyLabel with the given
+ * preferred size. This method is called automatically when the
+ * BusyPainter is set/changed.
+ *
+ * @param dim The new Preferred Size for the BusyLabel.
+ *
+ * @see #getBusyPainter()
+ * @see #setBusyPainter(BusyPainter)
+ */
+ protected void initPainter(Dimension dim) {
+ BusyPainter busyPainter = getBusyPainter();
+
+ // headw01
+ // TODO: Should we force the busyPainter to NOT be cached?
+ // I think we probably should, otherwise the UI will never
+ // be updated after the first paint.
+ if (null != busyPainter) {
+ busyPainter.setCacheable(false);
+ }
+
+ PainterIcon icon = new PainterIcon(dim);
+ icon.setPainter(busyPainter);
+ this.setIcon(icon);
+ }
+ /**
+ * Create and return a BusyPpainter to use for the Label. This may
+ * be overridden to return any painter you like. By default, this
+ * method uses the UI (BusyLabelUI)to create a BusyPainter.
+ * @param dim Painter size.
+ *
+ * @see #getUI()
+ */
+ protected BusyPainter createBusyPainter(Dimension dim) {
+ BusyPainter busyPainter = null;
+
+ BusyLabelUI ui = (BusyLabelUI)getUI();
+ if (ui != null) {
+ busyPainter = ui.getBusyPainter(dim);
+
+ }
+
+ return busyPainter;
+ }
+
+ /**
+ * <p>Gets whether this <code>JXBusyLabel</code> is busy. If busy, then
+ * the <code>JXBusyLabel</code> instance will indicate that it is busy,
+ * generally by animating some state.</p>
+ *
+ * @return true if this instance is busy
+ */
+ public boolean isBusy() {
+ return busy != null;
+ }
+
+ /**
+ * <p>Sets whether this <code>JXBusyLabel</code> instance should consider
+ * itself busy. A busy component may indicate that it is busy via animation,
+ * or some other means.</p>
+ *
+ * @param busy whether this <code>JXBusyLabel</code> instance should
+ * consider itself busy
+ */
+ public void setBusy(boolean busy) {
+ boolean old = isBusy();
+ if (!old && busy) {
+ startAnimation();
+ firePropertyChange("busy", old, isBusy());
+ } else if (old && !busy) {
+ stopAnimation();
+ firePropertyChange("busy", old, isBusy());
+ }
+ }
+
+ private void startAnimation() {
+ if(busy != null) {
+ stopAnimation();
+ }
+
+ busy = new Timer(delay, new ActionListener() {
+ BusyPainter busyPainter = getBusyPainter();
+ int frame = busyPainter.getPoints();
+ public void actionPerformed(ActionEvent e) {
+ frame = (frame+1)%busyPainter.getPoints();
+ busyPainter.setFrame(direction == Direction.LEFT ? busyPainter.getPoints() - frame : frame);
+ frameChanged();
+ }
+ });
+ busy.start();
+ }
+
+
+
+
+ private void stopAnimation() {
+ if (busy != null) {
+ busy.stop();
+ getBusyPainter().setFrame(-1);
+ repaint();
+ busy = null;
+ }
+ }
+
+ @Override
+ public void removeNotify() {
+ // fix for #698
+ wasBusyOnNotify = isBusy();
+ // fix for #626
+ stopAnimation();
+ super.removeNotify();
+ }
+
+ @Override
+ public void addNotify() {
+ super.addNotify();
+ // fix for #698
+ if (wasBusyOnNotify) {
+ // fix for #626
+ startAnimation();
+ }
+ }
+
+ protected void frameChanged() {
+ repaint();
+ }
+
+ /**
+ * Returns the current BusyPainter. If no BusyPainter is currently
+ * set on this BusyLabel, the {@link #createBusyPainter(Dimension)}
+ * method is called to create one. Afterwards,
+ * {@link #initPainter(Dimension)} is called to update the BusyLabel
+ * with the created BusyPainter.
+ *
+ * @return the busyPainter
+ *
+ * @see #createBusyPainter(Dimension)
+ * @see #initPainter(Dimension)
+ */
+ public final BusyPainter getBusyPainter() {
+ if (null == busyPainter) {
+ Dimension prefSize = getPreferredSize();
+
+ busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize);
+
+ if (null != busyPainter) {
+ if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) {
+ Rectangle rt = busyPainter.getTrajectory().getBounds();
+ Rectangle rp = busyPainter.getPointShape().getBounds();
+ int max = Math.max(rp.width, rp.height);
+ prefSize = new Dimension(rt.width + max, rt.height + max);
+ }
+
+ initPainter(prefSize);
+ }
+ }
+ return busyPainter;
+ }
+
+ /**
+ * @param busyPainter the busyPainter to set
+ */
+ public final void setBusyPainter(BusyPainter busyPainter) {
+ this.busyPainter = busyPainter;
+ initPainter(new Dimension(getIcon().getIconWidth(), getIcon().getIconHeight()));
+ }
+
+ /**
+ * @return the delay
+ */
+ public int getDelay() {
+ return delay;
+ }
+
+ /**
+ * @param delay the delay to set
+ */
+ public void setDelay(int delay) {
+ int old = getDelay();
+ this.delay = delay;
+ if (old != getDelay()) {
+ if (busy != null && busy.isRunning()) {
+ busy.setDelay(getDelay());
+ }
+ firePropertyChange("delay", old, getDelay());
+ }
+ }
+ //------------------------------------------------------------- UI Logic
+
+ /**
+ * Notification from the <code>UIManager</code> that the L&F has changed.
+ * Replaces the current UI object with the latest version from the
+ * <code>UIManager</code>.
+ *
+ * @see javax.swing.JComponent#updateUI
+ */
+ @Override
+ public void updateUI() {
+ setUI((LabelUI) LookAndFeelAddons.getUI(this, BusyLabelUI.class));
+ }
+
+ /**
+ * Returns the name of the L&F class that renders this component.
+ *
+ * @return the string {@link #uiClassID}
+ * @see javax.swing.JComponent#getUIClassID
+ * @see javax.swing.UIDefaults#getUI
+ */
+ @Override
+ public String getUIClassID() {
+ return uiClassID;
+ }
+
+
+}
+
View
765 src/org/hdesktop/swingx/JXButton.java
@@ -0,0 +1,765 @@
+/*
+ * $Id: JXButton.java 3742 2010-08-05 03:25:09Z kschaefe $
+ *
+ * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle,
+ * Santa Clara, California 95054, U.S.A. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.hdesktop.swingx;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+
+import javax.swing.Action;
+import javax.swing.ButtonModel;
+import javax.swing.CellRendererPane;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
+
+import org.hdesktop.swingx.color.ColorUtil;
+import org.hdesktop.swingx.graphics.GraphicsUtilities;
+import org.hdesktop.swingx.painter.AbstractPainter;
+import org.hdesktop.swingx.painter.Painter;
+import org.hdesktop.swingx.painter.PainterPaint;
+
+/**
+ * <p>A {@link org.hdesktop.swingx.painter.Painter} enabled subclass of {@link javax.swing.JButton}.
+ * This class supports setting the foreground and background painters of the button separately.</p>
+ *
+ * <p>For example, if you wanted to blur <em>just the text</em> on the button, and let everything else be
+ * handled by the UI delegate for your look and feel, then you could:
+ * <pre><code>
+ * JXButton b = new JXButton("Execute");
+ * AbstractPainter fgPainter = (AbstractPainter)b.getForegroundPainter();
+ * StackBlurFilter filter = new StackBlurFilter();
+ * fgPainter.setFilters(filter);
+ * </code></pre>
+ *
+ * <p>If <em>either</em> the foreground painter or the background painter is set,
+ * then super.paintComponent() is not called. By setting both the foreground and background
+ * painters to null, you get <em>exactly</em> the same painting behavior as JButton.</p>
+ *
+ * @author rbair
+ * @author rah003
+ * @author Jan Stola
+ * @author Karl George Schaefer
+ */
+public class JXButton extends JButton implements BackgroundPaintable {
+ private class BackgroundButton extends JButton {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isDefaultButton() {
+ return JXButton.this.isDefaultButton();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getDisabledIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getDisabledSelectedIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getDisplayedMnemonicIndex() {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getHorizontalAlignment() {
+ return JXButton.this.getHorizontalAlignment();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getHorizontalTextPosition() {
+ return JXButton.this.getHorizontalTextPosition();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getIconTextGap() {
+ return JXButton.this.getIconTextGap();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Insets getMargin() {
+ return JXButton.this.getMargin();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getMnemonic() {
+ return -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ButtonModel getModel() {
+ return JXButton.this.getModel();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getPressedIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getRolloverIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getRolloverSelectedIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getSelectedIcon() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText() {
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getVerticalAlignment() {
+ return JXButton.this.getVerticalAlignment();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getVerticalTextPosition() {
+ return JXButton.this.getVerticalTextPosition();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isBorderPainted() {
+ return JXButton.this.isBorderPainted();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isContentAreaFilled() {
+ return JXButton.this.isContentAreaFilled();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isFocusPainted() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRolloverEnabled() {
+ return JXButton.this.isRolloverEnabled();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isSelected() {
+ return JXButton.this.isSelected();
+ }
+
+ }
+
+ private class ForegroundButton extends JButton {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Color getForeground() {
+ if (fgPainter == null) {
+ return JXButton.this.getForeground();
+ }
+
+ return ColorUtil.setAlpha(JXButton.this.getForeground(), 0);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isDefaultButton() {
+ return JXButton.this.isDefaultButton();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getDisabledIcon() {
+ return JXButton.this.getDisabledIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getDisabledSelectedIcon() {
+ return JXButton.this.getDisabledSelectedIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getDisplayedMnemonicIndex() {
+ return JXButton.this.getDisplayedMnemonicIndex();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getHorizontalAlignment() {
+ return JXButton.this.getHorizontalAlignment();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getHorizontalTextPosition() {
+ return JXButton.this.getHorizontalTextPosition();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getIcon() {
+ return JXButton.this.getIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getIconTextGap() {
+ return JXButton.this.getIconTextGap();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Insets getMargin() {
+ return JXButton.this.getMargin();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getMnemonic() {
+ return JXButton.this.getMnemonic();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ButtonModel getModel() {
+ return JXButton.this.getModel();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getPressedIcon() {
+ return JXButton.this.getPressedIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getRolloverIcon() {
+ return JXButton.this.getRolloverIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getRolloverSelectedIcon() {
+ return JXButton.this.getRolloverSelectedIcon();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Icon getSelectedIcon() {
+ return JXButton.this.getSelectedIcon();
+ }
+