Debian Codegraph @

substance-swingx/src/main/java/org/pushingpixels/substance/swingx/SubstanceTableUI.java

raw symbols SCIP
1 /*
2 * Copyright 2005-2010 Kirill Grouchnikov, based on work by
3 * Sun Microsystems, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 package org.pushingpixels.substance.swingx;
20
21 import javax.swing.JComponent;
22 import javax.swing.plaf.ComponentUI;
23 import javax.swing.table.DefaultTableCellRenderer;
24 import javax.swing.table.TableCellRenderer;
25
26 import org.jdesktop.swingx.JXPanel;
27 import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
28
29 /**
30 * Substance-consistent UI delegate for {@link JXPanel}.
31 *
32 * @author Kirill Grouchnikov
33 */
34 public class SubstanceTableUI extends
35 org.pushingpixels.substance.internal.ui.SubstanceTableUI {
36
37 public static ComponentUI createUI(JComponent comp) {
38 SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp);
39 return new SubstanceTableUI();
40 }
41
42 @Override
43 protected void installRendererIfNecessary(java.lang.Class<?> clazz,
44 javax.swing.table.TableCellRenderer renderer) {
45 TableCellRenderer currRenderer = this.table.getDefaultRenderer(clazz);
46 if (currRenderer != null) {
47 boolean isCore = (currRenderer instanceof DefaultTableCellRenderer.UIResource)
48 || (currRenderer.getClass().getName().startsWith(
49 "javax.swing.JTable") || (currRenderer instanceof org.jdesktop.swingx.renderer.DefaultTableRenderer));
50 if (!isCore)
51 return;
52 }
53 // System.out.println(clazz.getSimpleName() + " : overriding "
54 // + currRenderer.getClass().getName() + "["
55 // + currRenderer.hashCode() + "] with "
56 // + renderer.getClass().getName() + "[" + renderer.hashCode()
57 // + "]");
58 this.table.setDefaultRenderer(clazz, renderer);
59 }
60
61 }