mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
prettier variant and block display
This commit is contained in:
@@ -2592,7 +2592,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
variantMap.put(entry.getKey(), templates);
|
variantMap.put(entry.getKey(), templates);
|
||||||
}
|
}
|
||||||
for (Template t : entry.getValue()) {
|
for (Template t : entry.getValue()) {
|
||||||
templates.add(new Template(t.getName() + " by " + pkg.getOwner(), t.getValues(), t.getPoints()));
|
templates.add(new Template(t.getName() + " [" + pkg.getOwner() + "]", t.getValues(), t.getPoints()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2624,7 +2624,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, Collection<IDIYComponent<?>>> entry : pkg.getBlocks().entrySet()) {
|
for (Map.Entry<String, Collection<IDIYComponent<?>>> entry : pkg.getBlocks().entrySet()) {
|
||||||
blocks.put(entry.getKey() + " by " + pkg.getOwner(), entry.getValue());
|
blocks.put(entry.getKey() + " [" + pkg.getOwner() + "]", entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -310,7 +310,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
private JLabel getPositionLabel() {
|
private JLabel getPositionLabel() {
|
||||||
if (positionLabel == null) {
|
if (positionLabel == null) {
|
||||||
positionLabel = new JLabel();
|
positionLabel = new JLabel();
|
||||||
positionLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
|
positionLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
|
||||||
}
|
}
|
||||||
return positionLabel;
|
return positionLabel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -105,10 +107,22 @@ public class ComponentButtonFactory {
|
|||||||
});
|
});
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Pattern contributedPattern = Pattern.compile("^(.*)\\[(.*)\\]");
|
||||||
|
|
||||||
public static JMenuItem createVariantItem(final IPlugInPort plugInPort, final Template variant,
|
public static JMenuItem createVariantItem(final IPlugInPort plugInPort, final Template variant,
|
||||||
final ComponentType componentType) {
|
final ComponentType componentType) {
|
||||||
final JMenuItem item = new JMenuItem(variant.getName()) {
|
|
||||||
|
String display = variant.getName();
|
||||||
|
|
||||||
|
Matcher match = contributedPattern.matcher(display);
|
||||||
|
if (match.find()) {
|
||||||
|
String name = match.group(1);
|
||||||
|
String owner = match.group(2);
|
||||||
|
display = "<html>" + name + "<font color='gray'>[" + owner + "]</font></html>";
|
||||||
|
}
|
||||||
|
|
||||||
|
final JMenuItem item = new JMenuItem(display) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@@ -669,6 +671,8 @@ public class TreePanel extends JPanel {
|
|||||||
private String category;
|
private String category;
|
||||||
private boolean isVisible;
|
private boolean isVisible;
|
||||||
private MouseListener clickListener;
|
private MouseListener clickListener;
|
||||||
|
|
||||||
|
private final Pattern contributedPattern = Pattern.compile("^(.*)\\[(.*)\\]");
|
||||||
|
|
||||||
public Payload(ComponentType componentType, MouseListener clickListener) {
|
public Payload(ComponentType componentType, MouseListener clickListener) {
|
||||||
super();
|
super();
|
||||||
@@ -699,10 +703,21 @@ public class TreePanel extends JPanel {
|
|||||||
public MouseListener getClickListener() {
|
public MouseListener getClickListener() {
|
||||||
return clickListener;
|
return clickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String categoryForDisplay() {
|
||||||
|
String display = category;
|
||||||
|
Matcher match = contributedPattern.matcher(display);
|
||||||
|
if (match.find()) {
|
||||||
|
String name = match.group(1);
|
||||||
|
String owner = match.group(2);
|
||||||
|
display = name + "<font color='gray'>[" + owner + "]</font>";
|
||||||
|
}
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return componentType == null ? category : componentType.getName();
|
return componentType == null ? categoryForDisplay() : componentType.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user