mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added support for component templates
This commit is contained in:
+13
-3
@@ -16,7 +16,9 @@ import javax.swing.BorderFactory;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
@@ -151,15 +153,23 @@ class ComponentButtonFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
plugInPort.deleteTemplate(componentType.getCategory(),
|
|
||||||
componentType.getName(), template.getName());
|
|
||||||
e.consume();
|
|
||||||
// Hide the menu
|
// Hide the menu
|
||||||
Container c = item.getParent();
|
Container c = item.getParent();
|
||||||
if (c != null && c instanceof JPopupMenu) {
|
if (c != null && c instanceof JPopupMenu) {
|
||||||
JPopupMenu m = (JPopupMenu) c;
|
JPopupMenu m = (JPopupMenu) c;
|
||||||
m.setVisible(false);
|
m.setVisible(false);
|
||||||
}
|
}
|
||||||
|
int result = JOptionPane.showConfirmDialog(SwingUtilities
|
||||||
|
.getRoot(item),
|
||||||
|
"Are you sure you want to delete template \""
|
||||||
|
+ template.getName() + "\"", "Delete",
|
||||||
|
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||||
|
if (result != JOptionPane.YES_OPTION) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plugInPort.deleteTemplate(componentType.getCategory(),
|
||||||
|
componentType.getName(), template.getName());
|
||||||
|
e.consume();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
|
item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user