mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
Better component value render in explorer
This commit is contained in:
@@ -78,9 +78,9 @@ public class ExplorerPane extends JPanel {
|
||||
gbc.weighty = 0;
|
||||
gbc.gridwidth = 1;
|
||||
|
||||
// add(getTitleLabel(), gbc);
|
||||
//
|
||||
// gbc.gridy++;
|
||||
// add(getTitleLabel(), gbc);
|
||||
//
|
||||
// gbc.gridy++;
|
||||
|
||||
add(getSearchField(), gbc);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ExplorerPane extends JPanel {
|
||||
if (titleLabel == null) {
|
||||
titleLabel = new JLabel(getName());
|
||||
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
|
||||
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
|
||||
}
|
||||
return titleLabel;
|
||||
}
|
||||
@@ -345,16 +345,16 @@ public class ExplorerPane extends JPanel {
|
||||
|
||||
private static class ComponentListCellRenderer implements ListCellRenderer<IDIYComponent<?>> {
|
||||
|
||||
// private static Color[] layerColors = new Color[] { Color.gray, Color.decode("#ff6363"), Color.decode("#293462"), Color.decode("#138588"),
|
||||
// Color.decode("#c0ca03"), Color.decode("#990000") };
|
||||
// private static Color[] layerColors = new Color[] { Color.gray, Color.decode("#ff6363"),
|
||||
// Color.decode("#293462"), Color.decode("#138588"),
|
||||
// Color.decode("#c0ca03"), Color.decode("#990000") };
|
||||
|
||||
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
|
||||
|
||||
private Map<String, ComponentType> componentTypes;
|
||||
|
||||
public ComponentListCellRenderer(Map<String, List<ComponentType>> componentTypeMap) {
|
||||
this.componentTypes = componentTypeMap.values().stream()
|
||||
.flatMap(x -> x.stream())
|
||||
this.componentTypes = componentTypeMap.values().stream().flatMap(x -> x.stream())
|
||||
.collect(Collectors.toMap(x -> x.getInstanceClass().getCanonicalName(), x -> x));
|
||||
}
|
||||
|
||||
@@ -367,10 +367,26 @@ public class ExplorerPane extends JPanel {
|
||||
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
|
||||
int layerId = (int)Math.round(componentType.getZOrder());
|
||||
int layerId = (int) Math.round(componentType.getZOrder());
|
||||
|
||||
|
||||
renderer.setText(String.format("<html><font color='#c0c0c0'>[L%s]</font> %s (<font color='#666666'>%s</font>)</html>", layerId, value.getName(), value.getValueForDisplay()));
|
||||
String valueForDisplay = value.getValueForDisplay();
|
||||
if (isSelected) {
|
||||
if (valueForDisplay == null || valueForDisplay.trim().isEmpty()) {
|
||||
renderer.setText(String.format("[L%s] %s", layerId, value.getName()));
|
||||
} else {
|
||||
renderer
|
||||
.setText(String.format("[L%s] %s (%s)", layerId, value.getName(), valueForDisplay));
|
||||
}
|
||||
} else {
|
||||
if (valueForDisplay == null || valueForDisplay.trim().isEmpty()) {
|
||||
renderer.setText(String.format("<html><font color='#c0c0c0'>[L%s]</font> %s</html>",
|
||||
layerId, value.getName()));
|
||||
} else {
|
||||
renderer.setText(String.format(
|
||||
"<html><font color='#c0c0c0'>[L%s]</font> %s (<font color='#666666'>%s</font>)</html>",
|
||||
layerId, value.getName(), valueForDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user