001package csheets.ext.share.ui; 002 003import java.awt.event.ActionEvent; 004import java.util.Observer; 005 006import csheets.core.Cell; 007import csheets.ext.share.controller.SendController; 008import csheets.ui.ctrl.*; 009 010/** 011 * An action for the send action in the sharing extension 012 * 013 * @see FocusOwnerAction 014 * @author Andre 015 * 016 */ 017public class SendAction extends FocusOwnerAction { 018 019 /** generated id */ 020 private static final long serialVersionUID = 1L; 021 /** User Interface Controller */ 022 protected UIController uiController; 023 024 /** The first instance of this action */ 025 protected static SendAction instance; 026 027 /** 028 * Method that returns the first instance of this action 029 * 030 * @return the first instance of this action 031 */ 032 public static SendAction getInstance() { 033 return instance; 034 } 035 036 /** 037 * Creates a new send action 038 * 039 * @param uiController 040 * user interface controller 041 */ 042 public SendAction(UIController uiController) { 043 this.uiController = uiController; 044 if (instance == null) { 045 instance = this; 046 } 047 } 048 049 @Override 050 public void actionPerformed(ActionEvent event) { 051 SendUI sui = new SendUI(); 052 Cell[][] cells = focusOwner.getSelectedCells(); 053 sui.createUI(cells); 054 055 } 056 057 /** 058 * Method that will get the active cell and sends that information to the 059 * controller 060 * 061 * @param port 062 * the connection port 063 * @param password 064 * the connection password 065 * @param observer 066 * the observer class 067 */ 068 public void clickOnSidebar(int port, String password, String properties, 069 Observer observer) { 070 Cell[][] cells = focusOwner.getSelectedCells(); 071 SendController sc = new SendController(); 072 sc.startServer(port, cells, password, properties, observer); 073 } 074 075 @Override 076 protected String getName() { 077 return "Send"; 078 } 079}