public void removeSelected() { for (Object obj : theView.getLoadedList().getSelectedValuesList()) { PlayerCharacter pc = model.get(obj); model.removeElement(obj); messageHandler.handleMessage(new PlayerCharacterWasClosedMessage(this, pc)); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == theView.getRemoveButton()) { removeSelected(); } if (e.getSource() == theView.getSaveButton()) { for (Object obj : theView.getLoadedList().getSelectedValuesList()) { PlayerCharacter pc = model.get(obj); savePC(pc, false); } } if (e.getSource() == theView.getSaveAsButton()) { for (Object obj : theView.getLoadedList().getSelectedValuesList()) { PlayerCharacter pc = model.get(obj); savePC(pc, true); } } if (e.getSource() == theView.getLoadButton()) { handleOpen(); } theView.getLoadedList().repaint(); }
/** Starts the plugin, registering itself with the <code>TabAddMessage</code>. */ @Override public void start(PCGenMessageHandler mh) { messageHandler = mh; theView = new PCGTrackerView(); theView.getLoadedList().setModel(model); initListeners(); messageHandler.handleMessage( new RequestAddTabToGMGenMessage(this, getLocalizedName(), getView())); initMenus(); }
/** Registers all the listeners for any actions. */ public void initListeners() { theView.getRemoveButton().addActionListener(this); theView.getSaveButton().addActionListener(this); theView.getSaveAsButton().addActionListener(this); theView.getLoadButton().addActionListener(this); }