Skip to content

Commit

Permalink
issue #1578-swingx: remove dependency on core module
Browse files Browse the repository at this point in the history
- applied the fix as suggested in the bug report

git-svn-id: https://svn.java.net/svn/swingx~svn/trunk@4316 1312f61e-266d-0410-97fa-c3b71232c9ac
  • Loading branch information
kleopatra committed Oct 9, 2013
1 parent 61d32b2 commit 820656c
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import junit.framework.TestCase;

import org.jdesktop.swingx.InteractiveTestCase;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -43,7 +43,7 @@ public void testMatchingAddon() throws Exception {
try {
assertTrue("sanity: addon is configured to update on LAF change",
LookAndFeelAddons.isTrackingLookAndFeelChanges());
InteractiveTestCase.setLookAndFeel("Nimbus");
setLookAndFeel("Nimbus");
LookAndFeelAddons addon = LookAndFeelAddons.getAddon();
assertTrue("addon must match Nimbus, but was: " + addon, addon.matches());

Expand Down Expand Up @@ -79,4 +79,38 @@ public static void install() {
}
}

/**
* Fix issue #1578-swingx: remove dependency on core module.
*
* C&p'd from InteractiveTestCase: accessing that class here
* will break maven builds by introducing a cyclic dependency.
*
* @param nameSnippet
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws UnsupportedLookAndFeelException
*/
public static void setLookAndFeel(final String nameSnippet)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException, UnsupportedLookAndFeelException {
final String laf = getLookAndFeelClassName(nameSnippet);
if (laf != null) {
UIManager.setLookAndFeel(laf);
return;
}
throw new UnsupportedLookAndFeelException(
"no LAF installed with name snippet " + nameSnippet);
}

public static String getLookAndFeelClassName(final String nameSnippet) {
final UIManager.LookAndFeelInfo[] plafs = UIManager
.getInstalledLookAndFeels();
for (final UIManager.LookAndFeelInfo info : plafs) {
if (info.getName().contains(nameSnippet)) {
return info.getClassName();
}
}
return null;
}
}

0 comments on commit 820656c

Please sign in to comment.