mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
rename template->variant in the code
This commit is contained in:
@@ -1011,7 +1011,7 @@ public class ActionFactory {
|
||||
String templateName =
|
||||
JOptionPane.showInputDialog(null, "Variant name:", "Save as Variant", JOptionPane.PLAIN_MESSAGE);
|
||||
if (templateName != null && !templateName.trim().isEmpty()) {
|
||||
plugInPort.saveSelectedComponentAsTemplate(templateName);
|
||||
plugInPort.saveSelectedComponentAsVariant(templateName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,14 +413,16 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
List<Template> templates = null;
|
||||
|
||||
try {
|
||||
templates = plugInPort.getTemplatesForSelection();
|
||||
templates = plugInPort.getVariantsForSelection();
|
||||
} catch (Exception e) {
|
||||
LOG.info("Could not load variants for selection");
|
||||
getApplyTemplateMenu().setEnabled(false);
|
||||
}
|
||||
|
||||
if (templates == null)
|
||||
if (templates == null) {
|
||||
getApplyTemplateMenu().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
getApplyTemplateMenu().setEnabled(templates.size() > 0);
|
||||
|
||||
@@ -431,7 +433,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
plugInPort.applyTemplateToSelection(finalTemplate);
|
||||
plugInPort.applyVariantToSelection(finalTemplate);
|
||||
}
|
||||
});
|
||||
getApplyTemplateMenu().add(item);
|
||||
|
||||
@@ -106,9 +106,9 @@ public class ComponentButtonFactory {
|
||||
return button;
|
||||
}
|
||||
|
||||
public static JMenuItem createTemplateItem(final IPlugInPort plugInPort, final Template template,
|
||||
public static JMenuItem createVariantItem(final IPlugInPort plugInPort, final Template variant,
|
||||
final ComponentType componentType) {
|
||||
final JMenuItem item = new JMenuItem(template.getName()) {
|
||||
final JMenuItem item = new JMenuItem(variant.getName()) {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -122,14 +122,14 @@ public class ComponentButtonFactory {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
plugInPort.setNewComponentTypeSlot(componentType, template);
|
||||
plugInPort.setNewComponentTypeSlot(componentType, variant);
|
||||
}
|
||||
});
|
||||
|
||||
String defaultVariant = plugInPort.getDefaultTemplate(componentType.getCategory(), componentType.getName());
|
||||
String defaultVariant = plugInPort.getDefaultVariant(componentType.getCategory(), componentType.getName());
|
||||
|
||||
JLabel label = new JLabel(template.getName().equals(defaultVariant) ? IconLoader.PinGreen.getIcon() : IconLoader.PinGrey.getIcon());
|
||||
label.setToolTipText(template.getName().equals(defaultVariant) ? "Remove default variant" : "Set default variant");
|
||||
JLabel label = new JLabel(variant.getName().equals(defaultVariant) ? IconLoader.PinGreen.getIcon() : IconLoader.PinGrey.getIcon());
|
||||
label.setToolTipText(variant.getName().equals(defaultVariant) ? "Remove default variant" : "Set default variant");
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class ComponentButtonFactory {
|
||||
JPopupMenu m = (JPopupMenu) c;
|
||||
m.setVisible(false);
|
||||
}
|
||||
plugInPort.setTemplateDefault(componentType.getCategory(), componentType.getName(), template.getName());
|
||||
plugInPort.setDefaultVariant(componentType.getCategory(), componentType.getName(), variant.getName());
|
||||
e.consume();
|
||||
}
|
||||
});
|
||||
@@ -163,11 +163,11 @@ public class ComponentButtonFactory {
|
||||
}
|
||||
int result =
|
||||
JOptionPane.showConfirmDialog(SwingUtilities.getRoot(item), "Are you sure you want to delete variant \""
|
||||
+ template.getName() + "\"", "Delete", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
+ variant.getName() + "\"", "Delete", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
if (result != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
plugInPort.deleteTemplate(componentType.getCategory(), componentType.getName(), template.getName());
|
||||
plugInPort.deleteVariant(componentType.getCategory(), componentType.getName(), variant.getName());
|
||||
e.consume();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -160,7 +160,7 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS));
|
||||
for (ComponentType componentType : componentTypes) {
|
||||
try {
|
||||
Component button = ComponentButtonFactory.create(plugInPort, componentType, createTemplatePopup(componentType));
|
||||
Component button = ComponentButtonFactory.create(plugInPort, componentType, createVariantPopup(componentType));
|
||||
toolbar.add(button);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not create recent component button for " + componentType.getName(), e);
|
||||
@@ -204,7 +204,7 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
componentType =
|
||||
ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) Class.forName(componentClassName));
|
||||
Component button = ComponentButtonFactory.create(plugInPort, componentType, createTemplatePopup(componentType));
|
||||
Component button = ComponentButtonFactory.create(plugInPort, componentType, createVariantPopup(componentType));
|
||||
toolbar.add(button);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not create recent component button for " + componentClassName, e);
|
||||
@@ -212,23 +212,23 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
}
|
||||
}
|
||||
|
||||
private JPopupMenu createTemplatePopup(final ComponentType componentType) {
|
||||
final JPopupMenu templatePopup = new JPopupMenu();
|
||||
templatePopup.add("Loading...");
|
||||
templatePopup.addPopupMenuListener(new PopupMenuListener() {
|
||||
private JPopupMenu createVariantPopup(final ComponentType componentType) {
|
||||
final JPopupMenu variantPopup = new JPopupMenu();
|
||||
variantPopup.add("Loading...");
|
||||
variantPopup.addPopupMenuListener(new PopupMenuListener() {
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
templatePopup.removeAll();
|
||||
List<Template> templates = plugInPort.getTemplatesFor(componentType.getCategory(), componentType.getName());
|
||||
if (templates == null || templates.isEmpty()) {
|
||||
variantPopup.removeAll();
|
||||
List<Template> variants = plugInPort.getVariantsFor(componentType.getCategory(), componentType.getName());
|
||||
if (variants == null || variants.isEmpty()) {
|
||||
JMenuItem item = new JMenuItem("<no variants>");
|
||||
item.setEnabled(false);
|
||||
templatePopup.add(item);
|
||||
variantPopup.add(item);
|
||||
} else {
|
||||
for (Template template : templates) {
|
||||
JMenuItem item = ComponentButtonFactory.createTemplateItem(plugInPort, template, componentType);
|
||||
templatePopup.add(item);
|
||||
for (Template variant : variants) {
|
||||
JMenuItem item = ComponentButtonFactory.createVariantItem(plugInPort, variant, componentType);
|
||||
variantPopup.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,6 +239,6 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {}
|
||||
});
|
||||
return templatePopup;
|
||||
return variantPopup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,14 +441,14 @@ public class TreePanel extends JPanel {
|
||||
popup.add(shortcutSubmenu);
|
||||
popup.add(new JSeparator());
|
||||
|
||||
List<Template> templates = plugInPort.getTemplatesFor(componentType.getCategory(), componentType.getName());
|
||||
List<Template> templates = plugInPort.getVariantsFor(componentType.getCategory(), componentType.getName());
|
||||
if (templates == null || templates.isEmpty()) {
|
||||
JMenuItem item = new JMenuItem("<no variants>");
|
||||
item.setEnabled(false);
|
||||
popup.add(item);
|
||||
} else {
|
||||
for (Template template : templates) {
|
||||
JMenuItem item = ComponentButtonFactory.createTemplateItem(plugInPort, template, componentType);
|
||||
JMenuItem item = ComponentButtonFactory.createVariantItem(plugInPort, template, componentType);
|
||||
popup.add(item);
|
||||
}
|
||||
}
|
||||
@@ -628,7 +628,7 @@ public class TreePanel extends JPanel {
|
||||
}
|
||||
|
||||
if (payload.getComponentType() != null) {
|
||||
List<Template> variants = plugInPort.getTemplatesFor(payload.getComponentType().getCategory(), payload.getComponentType().getName());
|
||||
List<Template> variants = plugInPort.getVariantsFor(payload.getComponentType().getCategory(), payload.getComponentType().getName());
|
||||
if (variants != null && !variants.isEmpty()) {
|
||||
variantsHtml = " <a style=\"text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; background-color: #D7FFC6; color: #666666;\">[+"
|
||||
+ variants.size() + "]</a>";
|
||||
|
||||
Reference in New Issue
Block a user