prettier variant and block display

This commit is contained in:
Branislav Stojkovic
2019-02-09 09:47:13 +01:00
parent 6d2e876381
commit 0acca63ccd
6 changed files with 34 additions and 5 deletions
@@ -2592,7 +2592,7 @@ public class Presenter implements IPlugInPort {
variantMap.put(entry.getKey(), templates);
}
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()) {
blocks.put(entry.getKey() + " by " + pkg.getOwner(), entry.getValue());
blocks.put(entry.getKey() + " [" + pkg.getOwner() + "]", entry.getValue());
}
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() {
if (positionLabel == null) {
positionLabel = new JLabel();
positionLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
positionLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
}
return positionLabel;
}
@@ -28,6 +28,8 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.JButton;
@@ -105,10 +107,22 @@ public class ComponentButtonFactory {
});
return button;
}
private static final Pattern contributedPattern = Pattern.compile("^(.*)\\[(.*)\\]");
public static JMenuItem createVariantItem(final IPlugInPort plugInPort, final Template variant,
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;
@@ -44,6 +44,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.AbstractAction;
import javax.swing.Icon;
@@ -669,6 +671,8 @@ public class TreePanel extends JPanel {
private String category;
private boolean isVisible;
private MouseListener clickListener;
private final Pattern contributedPattern = Pattern.compile("^(.*)\\[(.*)\\]");
public Payload(ComponentType componentType, MouseListener clickListener) {
super();
@@ -699,10 +703,21 @@ public class TreePanel extends JPanel {
public MouseListener getClickListener() {
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
public String toString() {
return componentType == null ? category : componentType.getName();
return componentType == null ? categoryForDisplay() : componentType.getName();
}
}