| 1 | |
package org.jtheque.core.utils.ui; |
| 2 | |
|
| 3 | |
import org.jdesktop.swingx.JXTree; |
| 4 | |
import org.jtheque.core.managers.view.impl.components.JThequeI18nLabel; |
| 5 | |
import org.jtheque.core.managers.view.impl.components.filthy.FilthyComboBox; |
| 6 | |
import org.jtheque.core.managers.view.impl.components.filthy.FilthyList; |
| 7 | |
import org.jtheque.core.managers.view.impl.components.filthy.FilthyPanel; |
| 8 | |
|
| 9 | |
import javax.swing.DefaultComboBoxModel; |
| 10 | |
import javax.swing.JComboBox; |
| 11 | |
import javax.swing.JComponent; |
| 12 | |
import javax.swing.JLabel; |
| 13 | |
import javax.swing.JList; |
| 14 | |
import javax.swing.JPanel; |
| 15 | |
import javax.swing.JScrollPane; |
| 16 | |
import javax.swing.ListCellRenderer; |
| 17 | |
import javax.swing.ListModel; |
| 18 | |
import javax.swing.ListSelectionModel; |
| 19 | |
import javax.swing.tree.TreeCellRenderer; |
| 20 | |
import javax.swing.tree.TreeModel; |
| 21 | |
import java.awt.Color; |
| 22 | |
import java.awt.LayoutManager; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
public final class FilthyPanelBuilder extends PanelBuilder { |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
public FilthyPanelBuilder() { |
| 51 | 0 | super(); |
| 52 | 0 | } |
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
public FilthyPanelBuilder(JPanel panel) { |
| 60 | 0 | super(panel); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
public FilthyPanelBuilder(LayoutManager layout){ |
| 69 | 0 | super(new FilthyPanel(layout), false); |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
public FilthyPanelBuilder(JPanel panel, boolean layout) { |
| 79 | 0 | super(panel, layout); |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
@Override |
| 83 | |
public JLabel addLabel(String text, Object constraints) { |
| 84 | 0 | JLabel label = super.addLabel(text, constraints); |
| 85 | |
|
| 86 | 0 | label.setForeground(Color.white); |
| 87 | |
|
| 88 | 0 | return label; |
| 89 | |
} |
| 90 | |
|
| 91 | |
@Override |
| 92 | |
public JThequeI18nLabel addI18nLabel(String key, Object constraints) { |
| 93 | 0 | JThequeI18nLabel label = super.addI18nLabel(key, constraints); |
| 94 | |
|
| 95 | 0 | label.setForeground(Color.white); |
| 96 | |
|
| 97 | 0 | return label; |
| 98 | |
} |
| 99 | |
|
| 100 | |
@Override |
| 101 | |
public JThequeI18nLabel addI18nLabel(String key, int style, Object constraints) { |
| 102 | 0 | JThequeI18nLabel label = super.addI18nLabel(key, style, constraints); |
| 103 | |
|
| 104 | 0 | label.setForeground(Color.white); |
| 105 | |
|
| 106 | 0 | return label; |
| 107 | |
} |
| 108 | |
|
| 109 | |
@Override |
| 110 | |
void initJThequeDefaults() { |
| 111 | 0 | getPanel().setOpaque(false); |
| 112 | 0 | getPanel().setBorder(Borders.EMPTY_BORDER); |
| 113 | 0 | } |
| 114 | |
|
| 115 | |
@Override |
| 116 | |
public JList addList(ListModel model, ListCellRenderer renderer, Object constraints) { |
| 117 | 0 | JList list = new FilthyList(model); |
| 118 | |
|
| 119 | 0 | list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 120 | 0 | list.setVisibleRowCount(10); |
| 121 | 0 | list.setValueIsAdjusting(true); |
| 122 | |
|
| 123 | 0 | if (renderer != null) { |
| 124 | 0 | list.setCellRenderer(renderer); |
| 125 | |
} |
| 126 | |
|
| 127 | 0 | addScrolled(list, constraints); |
| 128 | |
|
| 129 | 0 | return list; |
| 130 | |
} |
| 131 | |
|
| 132 | |
@Override |
| 133 | |
public void addScrolled(JComponent view, Object constraints) { |
| 134 | 0 | JScrollPane scrollPane = new JScrollPane(view); |
| 135 | |
|
| 136 | 0 | scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
| 137 | 0 | scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
| 138 | 0 | scrollPane.setOpaque(false); |
| 139 | 0 | scrollPane.setBorder(Borders.EMPTY_BORDER); |
| 140 | 0 | scrollPane.getViewport().setOpaque(false); |
| 141 | |
|
| 142 | 0 | add(scrollPane, constraints); |
| 143 | 0 | } |
| 144 | |
|
| 145 | |
@Override |
| 146 | |
public JComboBox addComboBox(DefaultComboBoxModel model, Object constraints) { |
| 147 | 0 | return add(new FilthyComboBox(model), constraints); |
| 148 | |
} |
| 149 | |
|
| 150 | |
@Override |
| 151 | |
public JComboBox addComboBox(DefaultComboBoxModel model, ListCellRenderer renderer, Object constraints) { |
| 152 | 0 | JComboBox combo = add(new FilthyComboBox(model), constraints); |
| 153 | |
|
| 154 | 0 | combo.setRenderer(renderer); |
| 155 | |
|
| 156 | 0 | return combo; |
| 157 | |
} |
| 158 | |
|
| 159 | |
@Override |
| 160 | |
public PanelBuilder addPanel(Object constraints) { |
| 161 | 0 | PanelBuilder builder = new FilthyPanelBuilder(); |
| 162 | |
|
| 163 | 0 | add(builder.getPanel(), constraints); |
| 164 | |
|
| 165 | 0 | return builder; |
| 166 | |
} |
| 167 | |
|
| 168 | |
@Override |
| 169 | |
public PanelBuilder addPanel(LayoutManager layout, Object constraints){ |
| 170 | 0 | PanelBuilder builder = new FilthyPanelBuilder(layout); |
| 171 | |
|
| 172 | 0 | add(builder.getPanel(), constraints); |
| 173 | |
|
| 174 | 0 | return builder; |
| 175 | |
} |
| 176 | |
|
| 177 | |
@Override |
| 178 | |
public JXTree addScrolledTree(TreeModel model, TreeCellRenderer renderer, Object constraints){ |
| 179 | 0 | JXTree tree = new JXTree(model); |
| 180 | 0 | tree.setRootVisible(false); |
| 181 | 0 | tree.setShowsRootHandles(true); |
| 182 | 0 | tree.setOpaque(false); |
| 183 | 0 | tree.setBorder(Borders.EMPTY_BORDER); |
| 184 | 0 | tree.putClientProperty("JTree.lineStyle", "None"); |
| 185 | |
|
| 186 | 0 | if(renderer != null){ |
| 187 | 0 | tree.setCellRenderer(renderer); |
| 188 | |
} |
| 189 | |
|
| 190 | 0 | addScrolled(tree, constraints); |
| 191 | |
|
| 192 | 0 | return tree; |
| 193 | |
} |
| 194 | |
} |