|
|
|
@ -7,18 +7,20 @@ import com.fr.base.theme.TemplateTheme;
|
|
|
|
|
import com.fr.base.theme.settings.ThemedCellStyle; |
|
|
|
|
import com.fr.design.beans.FurtherBasicBeanPane; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.mainframe.DesignerBean; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.DefaultListCellRenderer; |
|
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JList; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.ListCellRenderer; |
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
@ -28,52 +30,21 @@ import java.awt.Graphics;
|
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.io.Serializable; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> implements DesignerBean { |
|
|
|
|
|
|
|
|
|
private static final int LEFT_BORDER = 10; |
|
|
|
|
private static final int RIGHT_BORDER = 10; |
|
|
|
|
private DefaultListModel<NameStyle> defaultListModel; |
|
|
|
|
private JList<NameStyle> styleList; |
|
|
|
|
private final DefaultListModel<NameStyle> defaultListModel; |
|
|
|
|
private final JList<NameStyle> styleList; |
|
|
|
|
private ChangeListener changeListener; |
|
|
|
|
|
|
|
|
|
public ThemedCellStyleListPane() { |
|
|
|
|
defaultListModel = new DefaultListModel<>(); |
|
|
|
|
styleList = new JList<>(defaultListModel); |
|
|
|
|
DefaultListCellRenderer render = new DefaultListCellRenderer() { |
|
|
|
|
private Style nameStyle; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
|
|
|
|
|
|
if (value instanceof Style) { |
|
|
|
|
this.nameStyle = (Style) value; |
|
|
|
|
this.setText(" "); |
|
|
|
|
} |
|
|
|
|
this.setPreferredSize(new Dimension(210, 22)); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
super.paintComponent(g); |
|
|
|
|
|
|
|
|
|
if (nameStyle == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
String text = "abcedfgh"; |
|
|
|
|
if (nameStyle instanceof NameStyle) { |
|
|
|
|
text = ((NameStyle) nameStyle).getName(); |
|
|
|
|
} |
|
|
|
|
Style.paintBackground((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
|
|
|
|
Style.paintContent((Graphics2D) g, text, nameStyle, getWidth() - 1, getHeight() - 1, ScreenResolution.getScreenResolution()); |
|
|
|
|
Style.paintBorder((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
styleList.setCellRenderer(render); |
|
|
|
|
styleList.setCellRenderer(new RadioButtonListCellRenderer()); |
|
|
|
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
add(styleList, BorderLayout.CENTER); |
|
|
|
|
setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER)); |
|
|
|
@ -167,4 +138,66 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane<NameStyle> imp
|
|
|
|
|
styleList.setModel(defaultListModel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static class RadioButtonListCellRenderer extends JPanel implements ListCellRenderer<Object>, Serializable { |
|
|
|
|
|
|
|
|
|
private final UIRadioButton button; |
|
|
|
|
private final PreviewArea previewArea; |
|
|
|
|
|
|
|
|
|
public RadioButtonListCellRenderer() { |
|
|
|
|
super(); |
|
|
|
|
setLayout(new BorderLayout(20, 0)); |
|
|
|
|
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
|
|
|
setPreferredSize(new Dimension(getPreferredSize().width, 40)); |
|
|
|
|
button = new UIRadioButton(); |
|
|
|
|
previewArea = new PreviewArea(); |
|
|
|
|
add(button, BorderLayout.WEST); |
|
|
|
|
add(previewArea, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
button.setSelected(isSelected); |
|
|
|
|
previewArea.setStyle((Style) value); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static class PreviewArea extends JComponent { |
|
|
|
|
|
|
|
|
|
private String paintText = "Report"; |
|
|
|
|
private Style style = Style.DEFAULT_STYLE; |
|
|
|
|
|
|
|
|
|
public void setStyle(Style style) { |
|
|
|
|
this.style = style; |
|
|
|
|
if (style instanceof NameStyle) { |
|
|
|
|
paintText = ((NameStyle) style).getName(); |
|
|
|
|
} |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
int resolution = ScreenResolution.getScreenResolution(); |
|
|
|
|
|
|
|
|
|
g.clipRect(0, 0, getWidth() - 3, getHeight() - 3); |
|
|
|
|
|
|
|
|
|
if (style == Style.DEFAULT_STYLE) { |
|
|
|
|
// 如果是默认的style,就只写"Report"上去
|
|
|
|
|
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3); |
|
|
|
|
|
|
|
|
|
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); |
|
|
|
|
|
|
|
|
|
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getMinimumSize() { |
|
|
|
|
return getPreferredSize(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |