Kaynağa Gözat

Rename EquipItemPanel and EquipItemHelper

Sam Jaffe 8 yıl önce
ebeveyn
işleme
32796da643

+ 11 - 11
src/main/lombok/org/leumasjaffe/charsheet/controller/EquipItemHelper.java

@@ -7,12 +7,12 @@ import javax.swing.JOptionPane;
 import org.leumasjaffe.charsheet.model.inventory.DDInventory;
 import org.leumasjaffe.charsheet.model.inventory.DDItem;
 import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
-import org.leumasjaffe.charsheet.view.dialog.EquipItemPanel;
+import org.leumasjaffe.charsheet.view.dialog.EquipItemDialog;
 import org.leumasjaffe.observer.ObserverDispatch;
 
 import lombok.RequiredArgsConstructor;
 
-public class EquipItemHelper {	
+public class EquipItemController {	
 
 	public static void accept(final DDInventory inv, final DDItem item) {
 		if ( item.getUnequippedCount() == 0 ) { return; }
@@ -38,14 +38,14 @@ public class EquipItemHelper {
 
 		private boolean selectToReplaceAllOf(final EquipmentSlot base,
 				final EquipmentSlot slot1, final EquipmentSlot slot2) {
-			final EquipItemPanel panel;
+			final EquipItemDialog panel;
 			if ( inv.getEquipment().get(slot1).getSlot() == base ) {
-				panel = new EquipItemPanel("Do you want to replace the following item?", 
+				panel = new EquipItemDialog("Do you want to replace the following item?", 
 						slot1, inv.getEquipment().get(slot1));
 			} else {
-				panel = new EquipItemPanel("Do you want to replace both of the following items?", 
-						new EquipItemPanel.Tuple(slot1, inv.getEquipment().get(slot1)),
-						new EquipItemPanel.Tuple(slot2, inv.getEquipment().get(slot2)));
+				panel = new EquipItemDialog("Do you want to replace both of the following items?", 
+						new EquipItemDialog.Tuple(slot1, inv.getEquipment().get(slot1)),
+						new EquipItemDialog.Tuple(slot2, inv.getEquipment().get(slot2)));
 			}
 			if ( JOptionPane.showConfirmDialog(null, 
 					panel, "Replace Equipped Item", JOptionPane.YES_NO_OPTION) 
@@ -60,9 +60,9 @@ public class EquipItemHelper {
 		private boolean selectToReplaceOneOf(final EquipmentSlot slot1, 
 				final EquipmentSlot slot2) {
 			final int choice = JOptionPane.showOptionDialog(null, 
-					new EquipItemPanel("Which of the following items would you like to replace?", 
-							new EquipItemPanel.Tuple(slot1, inv.getEquipment().get(slot1)),
-							new EquipItemPanel.Tuple(slot2, inv.getEquipment().get(slot2))), 
+					new EquipItemDialog("Which of the following items would you like to replace?", 
+							new EquipItemDialog.Tuple(slot1, inv.getEquipment().get(slot1)),
+							new EquipItemDialog.Tuple(slot2, inv.getEquipment().get(slot2))), 
 					"Replace Equipped Item", JOptionPane.YES_NO_CANCEL_OPTION,
 					JOptionPane.QUESTION_MESSAGE, null, 
 					new String[] {"Cancel", slot1.toString(), slot2.toString()}, null );
@@ -78,7 +78,7 @@ public class EquipItemHelper {
 
 		private boolean selectToReplace(final EquipmentSlot slot) {
 			if ( JOptionPane.showConfirmDialog(null, 
-					new EquipItemPanel("Do you want to replace the following item?", slot, inv.getEquipment().get(slot)), 
+					new EquipItemDialog("Do you want to replace the following item?", slot, inv.getEquipment().get(slot)), 
 					"Replace Equipped Item", JOptionPane.YES_NO_OPTION) 
 					== JOptionPane.YES_OPTION ) {
 				inv.unequip( slot );

+ 3 - 3
src/main/lombok/org/leumasjaffe/charsheet/view/dialog/EquipItemPanel.java

@@ -17,18 +17,18 @@ import lombok.AllArgsConstructor;
 
 import java.awt.Font;
 
-public class EquipItemPanel extends JPanel {
+public class EquipItemDialog extends JPanel {
 	@AllArgsConstructor
 	public static class Tuple { EquipmentSlot slot; DDItem item; }
 	/**
 	 * 
 	 */
 	private static final long serialVersionUID = 1L;
-	public EquipItemPanel(final String title, final EquipmentSlot slot, final DDItem item) {
+	public EquipItemDialog(final String title, final EquipmentSlot slot, final DDItem item) {
 		this(title, new Tuple(slot, item));
 	}
 	
-	public EquipItemPanel(final String title, final Tuple... tuples) {
+	public EquipItemDialog(final String title, final Tuple... tuples) {
 		setOpaque(false);
 		setLayout(new VerticalLayout(5));
 

+ 3 - 3
src/main/lombok/org/leumasjaffe/charsheet/view/inventory/ItemInfoMenu.java

@@ -2,7 +2,7 @@ package org.leumasjaffe.charsheet.view.inventory;
 
 import javax.swing.JPopupMenu;
 
-import org.leumasjaffe.charsheet.controller.EquipItemHelper;
+import org.leumasjaffe.charsheet.controller.EquipItemController;
 import org.leumasjaffe.charsheet.model.inventory.DDInventory;
 import org.leumasjaffe.charsheet.model.inventory.DDItem;
 import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
@@ -19,13 +19,13 @@ class ItemInfoMenu extends JPopupMenu {
 	public ItemInfoMenu(final DDInventory inv, final DDItem item) {
 		
 		JMenuItem mntmInfo = new JMenuItem("Info");
-		add(mntmInfo);
 		mntmInfo.addActionListener(e -> {
 			JFrame frame = new JFrame(item.getName());
 			frame.add(new ItemInfoPanel(item));
 			frame.pack();
 			frame.setVisible(true);
 		});
+		add(mntmInfo);
 
 		JMenuItem mntmBuy = new JMenuItem("Purchase");
 		add(mntmBuy);
@@ -37,7 +37,7 @@ class ItemInfoMenu extends JPopupMenu {
 		if (item.getSlot() != EquipmentSlot.NONE) {
 			JMenuItem mntmEquip = new JMenuItem("Equip");
 			mntmEquip.setEnabled(item.getUnequippedCount() > 0);
-			mntmEquip.addActionListener(e -> EquipItemHelper.accept(inv, item));
+			mntmEquip.addActionListener(e -> EquipItemController.accept(inv, item));
 			add(mntmEquip);
 		}
 	}