/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package midlets;
import aplicacion.TweeterFacade;
import com.twitterapime.model.MetadataSet;
import com.twitterapime.search.Tweet;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Alan
*/
public class TwiterMidlet extends MIDlet implements CommandListener, ItemCommandListener {
private boolean midletPaused = false;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
private java.util.Hashtable __previousDisplayables = new java.util.Hashtable();
private Command guardarCommand;
private Command postTweetCommand;
private Command backTweetCommand;
private Command screenCommand;
private Command buscarCommand;
private Command cfgCommand;
private Command tweetCommand;
private Command buscarContenidoCommand;
private Command buscarTagCommand;
private Command explorarTweetsCommand;
private Command siguientePaginaCommand;
private Command buscarAutorCommand;
private Command reTweetCommand;
private Command backCommand;
private Command editarCommand;
private Command eliminarCommand;
private Command tweetPendienteCommand;
private Command salirCommand;
private Form configuracionForm;
private TextField userTF;
private TextField passTF;
private ChoiceGroup opcionesCG;
private TextField tweetsPorPaginaTF;
private Form tweetFrom;
private TextField tweetTF;
private StringItem caracteresSI;
private Form inicialForm;
private StringItem tweetsPendientesSI;
private StringItem usuarioSI;
private Form buscarForm;
private TextField buscarTF;
private List resultadosList;
private List tweetsPendientesList;
private Form editarPendienteForm;
private TextField editarTweetTF;
//</editor-fold>//GEN-END:|fields|0|
/**
* The HelloMIDlet constructor.
*/
public TwiterMidlet() {
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
/**
* Switches a display to previous displayable of the current displayable.
* The <code>display</code> instance is obtain from the <code>getDisplay</code> method.
*/
private void switchToPreviousDisplayable() {
Displayable __currentDisplayable = getDisplay().getCurrent();
if (__currentDisplayable != null) {
Displayable __nextDisplayable = (Displayable) __previousDisplayables.get(__currentDisplayable);
if (__nextDisplayable != null) {
switchDisplayable(null, __nextDisplayable);
}
}
}
//</editor-fold>//GEN-END:|methods|0|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
// write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
// write post-initialize user code here
}//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
// write pre-action user code here
switchDisplayable(null, getInicialForm());//GEN-LINE:|3-startMIDlet|1|3-postAction
// write post-action user code here
}//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
// write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
// write post-action user code here
}//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
// write pre-switch user code here
if (nextDisplayable == getInicialForm()) {
getTweetsPendientesSI().setText(Integer.toString(facade.getNumeroTweetsSalvados()));
getUsuarioSI().setText(facade.getUsuario());
}
if (nextDisplayable == getConfiguracionForm()) {
getUserTF().setString(facade.getUsuario());
getPassTF().setString(facade.getContrasena());
boolean[] sf = new boolean[2];
sf[0] = facade.getAutoSend();
sf[1] = facade.getTruncarTweets();
getOpcionesCG().setSelectedFlags(sf);
getTweetsPorPaginaTF().setString(Integer.toString(facade.getTweetsPagina()));
}
Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
Displayable __currentDisplayable = display.getCurrent();
if (__currentDisplayable != null && nextDisplayable != null) {
__previousDisplayables.put(nextDisplayable, __currentDisplayable);
}
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}//GEN-END:|5-switchDisplayable|1|5-postSwitch
// write post-switch user code here
}//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
// write pre-action user code here
if (displayable == buscarForm) {//GEN-BEGIN:|7-commandAction|1|140-preAction
if (command == backCommand) {//GEN-END:|7-commandAction|1|140-preAction
// write pre-action user code here
switchDisplayable(null, getInicialForm());//GEN-LINE:|7-commandAction|2|140-postAction
// write post-action user code here
} else if (command == buscarAutorCommand) {//GEN-LINE:|7-commandAction|3|113-preAction
// write pre-action user code here
buscarAutor();//GEN-LINE:|7-commandAction|4|113-postAction
// write post-action user code here
} else if (command == buscarContenidoCommand) {//GEN-LINE:|7-commandAction|5|111-preAction
// write pre-action user code here
buscarContenido();//GEN-LINE:|7-commandAction|6|111-postAction
// write post-action user code here
} else if (command == buscarTagCommand) {//GEN-LINE:|7-commandAction|7|109-preAction
// write pre-action user code here
buscarTag();//GEN-LINE:|7-commandAction|8|109-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|9|179-preAction
} else if (displayable == configuracionForm) {
if (command == backCommand) {//GEN-END:|7-commandAction|9|179-preAction
// write pre-action user code here
switchDisplayable(null, getInicialForm());//GEN-LINE:|7-commandAction|10|179-postAction
// write post-action user code here
} else if (command == guardarCommand) {//GEN-LINE:|7-commandAction|11|180-preAction
// write pre-action user code here
salvarConfiguracion();//GEN-LINE:|7-commandAction|12|180-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|13|152-preAction
} else if (displayable == editarPendienteForm) {
if (command == backCommand) {//GEN-END:|7-commandAction|13|152-preAction
// write pre-action user code here
salvarPendienteYVolver();//GEN-LINE:|7-commandAction|14|152-postAction
// write post-action user code here
} else if (command == postTweetCommand) {//GEN-LINE:|7-commandAction|15|155-preAction
// write pre-action user code here
enviarTweetEditado();//GEN-LINE:|7-commandAction|16|155-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|17|102-preAction
} else if (displayable == inicialForm) {
if (command == buscarCommand) {//GEN-END:|7-commandAction|17|102-preAction
// write pre-action user code here
switchDisplayable(null, getBuscarForm());//GEN-LINE:|7-commandAction|18|102-postAction
// write post-action user code here
} else if (command == cfgCommand) {//GEN-LINE:|7-commandAction|19|100-preAction
// write pre-action user code here
switchDisplayable(null, getConfiguracionForm());//GEN-LINE:|7-commandAction|20|100-postAction
// write post-action user code here
} else if (command == explorarTweetsCommand) {//GEN-LINE:|7-commandAction|21|105-preAction
// write pre-action user code here
verTweetsPendientes();//GEN-LINE:|7-commandAction|22|105-postAction
// write post-action user code here
} else if (command == tweetCommand) {//GEN-LINE:|7-commandAction|23|98-preAction
// write pre-action user code here
switchDisplayable(null, getTweetFrom());//GEN-LINE:|7-commandAction|24|98-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|25|121-preAction
} else if (displayable == resultadosList) {
if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|25|121-preAction
// write pre-action user code here
resultadosListAction();//GEN-LINE:|7-commandAction|26|121-postAction
// write post-action user code here
} else if (command == backCommand) {//GEN-LINE:|7-commandAction|27|125-preAction
// write pre-action user code here
switchDisplayable(null, getBuscarForm());//GEN-LINE:|7-commandAction|28|125-postAction
// write post-action user code here
} else if (command == reTweetCommand) {//GEN-LINE:|7-commandAction|29|127-preAction
// write pre-action user code here
reTweet();//GEN-LINE:|7-commandAction|30|127-postAction
// write post-action user code here
} else if (command == siguientePaginaCommand) {//GEN-LINE:|7-commandAction|31|123-preAction
// write pre-action user code here
buscarSiguientePagina();//GEN-LINE:|7-commandAction|32|123-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|33|86-preAction
} else if (displayable == tweetFrom) {
if (command == postTweetCommand) {//GEN-END:|7-commandAction|33|86-preAction
// write pre-action user code here
tweet();//GEN-LINE:|7-commandAction|34|86-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|35|144-preAction
} else if (displayable == tweetsPendientesList) {
if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|35|144-preAction
// write pre-action user code here
tweetsPendientesListAction();//GEN-LINE:|7-commandAction|36|144-postAction
// write post-action user code here
} else if (command == backCommand) {//GEN-LINE:|7-commandAction|37|146-preAction
// write pre-action user code here
switchDisplayable(null, getInicialForm());//GEN-LINE:|7-commandAction|38|146-postAction
// write post-action user code here
} else if (command == editarCommand) {//GEN-LINE:|7-commandAction|39|160-preAction
// write pre-action user code here
editarPendiente();//GEN-LINE:|7-commandAction|40|160-postAction
// write post-action user code here
} else if (command == eliminarCommand) {//GEN-LINE:|7-commandAction|41|164-preAction
// write pre-action user code here
eliminarPendiente();//GEN-LINE:|7-commandAction|42|164-postAction
// write post-action user code here
} else if (command == tweetPendienteCommand) {//GEN-LINE:|7-commandAction|43|167-preAction
// write pre-action user code here
tweetPendiente();//GEN-LINE:|7-commandAction|44|167-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|45|7-postCommandAction
}//GEN-END:|7-commandAction|45|7-postCommandAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|46|
//</editor-fold>//GEN-END:|7-commandAction|46|
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: guardarCommand ">//GEN-BEGIN:|78-getter|0|78-preInit
/**
* Returns an initiliazed instance of guardarCommand component.
* @return the initialized component instance
*/
public Command getGuardarCommand() {
if (guardarCommand == null) {//GEN-END:|78-getter|0|78-preInit
// write pre-init user code here
guardarCommand = new Command("Guardar", Command.OK, 0);//GEN-LINE:|78-getter|1|78-postInit
// write post-init user code here
}//GEN-BEGIN:|78-getter|2|
return guardarCommand;
}
//</editor-fold>//GEN-END:|78-getter|2|
//</editor-fold>
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: configuracionForm ">//GEN-BEGIN:|75-getter|0|75-preInit
/**
* Returns an initiliazed instance of configuracionForm component.
* @return the initialized component instance
*/
public Form getConfiguracionForm() {
if (configuracionForm == null) {//GEN-END:|75-getter|0|75-preInit
// write pre-init user code here
configuracionForm = new Form("Configuracion", new Item[] { getUserTF(), getPassTF(), getOpcionesCG(), getTweetsPorPaginaTF() });//GEN-BEGIN:|75-getter|1|75-postInit
configuracionForm.addCommand(getGuardarCommand());
configuracionForm.addCommand(getBackCommand());
configuracionForm.setCommandListener(this);//GEN-END:|75-getter|1|75-postInit
// write post-init user code here
}//GEN-BEGIN:|75-getter|2|
return configuracionForm;
}
//</editor-fold>//GEN-END:|75-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: userTF ">//GEN-BEGIN:|76-getter|0|76-preInit
/**
* Returns an initiliazed instance of userTF component.
* @return the initialized component instance
*/
public TextField getUserTF() {
if (userTF == null) {//GEN-END:|76-getter|0|76-preInit
// write pre-init user code here
userTF = new TextField("Ususario", "", 32, TextField.ANY);//GEN-LINE:|76-getter|1|76-postInit
// write post-init user code here
}//GEN-BEGIN:|76-getter|2|
return userTF;
}
//</editor-fold>//GEN-END:|76-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: passTF ">//GEN-BEGIN:|77-getter|0|77-preInit
/**
* Returns an initiliazed instance of passTF component.
* @return the initialized component instance
*/
public TextField getPassTF() {
if (passTF == null) {//GEN-END:|77-getter|0|77-preInit
// write pre-init user code here
passTF = new TextField("Contrase\u00F1a", "", 32, TextField.ANY);//GEN-LINE:|77-getter|1|77-postInit
// write post-init user code here
}//GEN-BEGIN:|77-getter|2|
return passTF;
}
//</editor-fold>//GEN-END:|77-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetFrom ">//GEN-BEGIN:|80-getter|0|80-preInit
/**
* Returns an initiliazed instance of tweetFrom component.
* @return the initialized component instance
*/
public Form getTweetFrom() {
if (tweetFrom == null) {//GEN-END:|80-getter|0|80-preInit
// write pre-init user code here
tweetFrom = new Form("Tweet", new Item[] { getTweetTF(), getCaracteresSI() });//GEN-BEGIN:|80-getter|1|80-postInit
tweetFrom.addCommand(getPostTweetCommand());
tweetFrom.setCommandListener(this);//GEN-END:|80-getter|1|80-postInit
// write post-init user code here
}//GEN-BEGIN:|80-getter|2|
return tweetFrom;
}
//</editor-fold>//GEN-END:|80-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetTF ">//GEN-BEGIN:|81-getter|0|81-preInit
/**
* Returns an initiliazed instance of tweetTF component.
* @return the initialized component instance
*/
public TextField getTweetTF() {
if (tweetTF == null) {//GEN-END:|81-getter|0|81-preInit
// write pre-init user code here
tweetTF = new TextField("Nuevo Tweet", "", 500, TextField.ANY);//GEN-BEGIN:|81-getter|1|81-postInit
tweetTF.setLayout(ImageItem.LAYOUT_DEFAULT);
tweetTF.setPreferredSize(-1, -1);//GEN-END:|81-getter|1|81-postInit
// write post-init user code here
}//GEN-BEGIN:|81-getter|2|
return tweetTF;
}
//</editor-fold>//GEN-END:|81-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: caracteresSI ">//GEN-BEGIN:|83-getter|0|83-preInit
/**
* Returns an initiliazed instance of caracteresSI component.
* @return the initialized component instance
*/
public StringItem getCaracteresSI() {
if (caracteresSI == null) {//GEN-END:|83-getter|0|83-preInit
// write pre-init user code here
caracteresSI = new StringItem("Caracteres", "");//GEN-BEGIN:|83-getter|1|83-postInit
caracteresSI.addCommand(getBackTweetCommand());
caracteresSI.setItemCommandListener(this);
caracteresSI.setLayout(ImageItem.LAYOUT_DEFAULT);//GEN-END:|83-getter|1|83-postInit
// write post-init user code here
}//GEN-BEGIN:|83-getter|2|
return caracteresSI;
}
//</editor-fold>//GEN-END:|83-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Items ">//GEN-BEGIN:|17-itemCommandAction|0|17-preItemCommandAction
/**
* Called by a system to indicated that a command has been invoked on a particular item.
* @param command the Command that was invoked
* @param displayable the Item where the command was invoked
*/
public void commandAction(Command command, Item item) {//GEN-END:|17-itemCommandAction|0|17-preItemCommandAction
// write pre-action user code here
if (item == caracteresSI) {//GEN-BEGIN:|17-itemCommandAction|1|88-preAction
if (command == backTweetCommand) {//GEN-END:|17-itemCommandAction|1|88-preAction
// write pre-action user code here
switchToPreviousDisplayable();//GEN-LINE:|17-itemCommandAction|2|88-postAction
// write post-action user code here
}//GEN-BEGIN:|17-itemCommandAction|3|17-postItemCommandAction
}//GEN-END:|17-itemCommandAction|3|17-postItemCommandAction
// write post-action user code here
}//GEN-BEGIN:|17-itemCommandAction|4|
//</editor-fold>//GEN-END:|17-itemCommandAction|4|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: postTweetCommand ">//GEN-BEGIN:|85-getter|0|85-preInit
/**
* Returns an initiliazed instance of postTweetCommand component.
* @return the initialized component instance
*/
public Command getPostTweetCommand() {
if (postTweetCommand == null) {//GEN-END:|85-getter|0|85-preInit
// write pre-init user code here
postTweetCommand = new Command("Tweet!", Command.ITEM, 0);//GEN-LINE:|85-getter|1|85-postInit
// write post-init user code here
}//GEN-BEGIN:|85-getter|2|
return postTweetCommand;
}
//</editor-fold>//GEN-END:|85-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: backTweetCommand ">//GEN-BEGIN:|87-getter|0|87-preInit
/**
* Returns an initiliazed instance of backTweetCommand component.
* @return the initialized component instance
*/
public Command getBackTweetCommand() {
if (backTweetCommand == null) {//GEN-END:|87-getter|0|87-preInit
// write pre-init user code here
backTweetCommand = new Command("Atras", Command.BACK, 0);//GEN-LINE:|87-getter|1|87-postInit
// write post-init user code here
}//GEN-BEGIN:|87-getter|2|
return backTweetCommand;
}
//</editor-fold>//GEN-END:|87-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: screenCommand ">//GEN-BEGIN:|93-getter|0|93-preInit
/**
* Returns an initiliazed instance of screenCommand component.
* @return the initialized component instance
*/
public Command getScreenCommand() {
if (screenCommand == null) {//GEN-END:|93-getter|0|93-preInit
// write pre-init user code here
screenCommand = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|93-getter|1|93-postInit
// write post-init user code here
}//GEN-BEGIN:|93-getter|2|
return screenCommand;
}
//</editor-fold>//GEN-END:|93-getter|2|
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: inicialForm ">//GEN-BEGIN:|92-getter|0|92-preInit
/**
* Returns an initiliazed instance of inicialForm component.
* @return the initialized component instance
*/
public Form getInicialForm() {
if (inicialForm == null) {//GEN-END:|92-getter|0|92-preInit
// write pre-init user code here
inicialForm = new Form("Tweeter", new Item[] { getTweetsPendientesSI(), getUsuarioSI() });//GEN-BEGIN:|92-getter|1|92-postInit
inicialForm.addCommand(getTweetCommand());
inicialForm.addCommand(getCfgCommand());
inicialForm.addCommand(getBuscarCommand());
inicialForm.addCommand(getExplorarTweetsCommand());
inicialForm.setCommandListener(this);//GEN-END:|92-getter|1|92-postInit
// write post-init user code here
}//GEN-BEGIN:|92-getter|2|
return inicialForm;
}
//</editor-fold>//GEN-END:|92-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetsPendientesSI ">//GEN-BEGIN:|95-getter|0|95-preInit
/**
* Returns an initiliazed instance of tweetsPendientesSI component.
* @return the initialized component instance
*/
public StringItem getTweetsPendientesSI() {
if (tweetsPendientesSI == null) {//GEN-END:|95-getter|0|95-preInit
// write pre-init user code here
tweetsPendientesSI = new StringItem("Tweets Pendientes", "");//GEN-LINE:|95-getter|1|95-postInit
// write post-init user code here
}//GEN-BEGIN:|95-getter|2|
return tweetsPendientesSI;
}
//</editor-fold>//GEN-END:|95-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: usuarioSI ">//GEN-BEGIN:|96-getter|0|96-preInit
/**
* Returns an initiliazed instance of usuarioSI component.
* @return the initialized component instance
*/
public StringItem getUsuarioSI() {
if (usuarioSI == null) {//GEN-END:|96-getter|0|96-preInit
// write pre-init user code here
usuarioSI = new StringItem("Usuario", "");//GEN-LINE:|96-getter|1|96-postInit
// write post-init user code here
}//GEN-BEGIN:|96-getter|2|
return usuarioSI;
}
//</editor-fold>//GEN-END:|96-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetCommand ">//GEN-BEGIN:|97-getter|0|97-preInit
/**
* Returns an initiliazed instance of tweetCommand component.
* @return the initialized component instance
*/
public Command getTweetCommand() {
if (tweetCommand == null) {//GEN-END:|97-getter|0|97-preInit
// write pre-init user code here
tweetCommand = new Command("NuevoTweet", Command.ITEM, 0);//GEN-LINE:|97-getter|1|97-postInit
// write post-init user code here
}//GEN-BEGIN:|97-getter|2|
return tweetCommand;
}
//</editor-fold>//GEN-END:|97-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: cfgCommand ">//GEN-BEGIN:|99-getter|0|99-preInit
/**
* Returns an initiliazed instance of cfgCommand component.
* @return the initialized component instance
*/
public Command getCfgCommand() {
if (cfgCommand == null) {//GEN-END:|99-getter|0|99-preInit
// write pre-init user code here
cfgCommand = new Command("Configuracion", Command.ITEM, 0);//GEN-LINE:|99-getter|1|99-postInit
// write post-init user code here
}//GEN-BEGIN:|99-getter|2|
return cfgCommand;
}
//</editor-fold>//GEN-END:|99-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarCommand ">//GEN-BEGIN:|101-getter|0|101-preInit
/**
* Returns an initiliazed instance of buscarCommand component.
* @return the initialized component instance
*/
public Command getBuscarCommand() {
if (buscarCommand == null) {//GEN-END:|101-getter|0|101-preInit
// write pre-init user code here
buscarCommand = new Command("Buscar", Command.ITEM, 0);//GEN-LINE:|101-getter|1|101-postInit
// write post-init user code here
}//GEN-BEGIN:|101-getter|2|
return buscarCommand;
}
//</editor-fold>//GEN-END:|101-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: explorarTweetsCommand ">//GEN-BEGIN:|104-getter|0|104-preInit
/**
* Returns an initiliazed instance of explorarTweetsCommand component.
* @return the initialized component instance
*/
public Command getExplorarTweetsCommand() {
if (explorarTweetsCommand == null) {//GEN-END:|104-getter|0|104-preInit
// write pre-init user code here
explorarTweetsCommand = new Command("Ver Tweets pendientes", Command.ITEM, 0);//GEN-LINE:|104-getter|1|104-postInit
// write post-init user code here
}//GEN-BEGIN:|104-getter|2|
return explorarTweetsCommand;
}
//</editor-fold>//GEN-END:|104-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarTagCommand ">//GEN-BEGIN:|108-getter|0|108-preInit
/**
* Returns an initiliazed instance of buscarTagCommand component.
* @return the initialized component instance
*/
public Command getBuscarTagCommand() {
if (buscarTagCommand == null) {//GEN-END:|108-getter|0|108-preInit
// write pre-init user code here
buscarTagCommand = new Command("Buscar Tag", Command.ITEM, 0);//GEN-LINE:|108-getter|1|108-postInit
// write post-init user code here
}//GEN-BEGIN:|108-getter|2|
return buscarTagCommand;
}
//</editor-fold>//GEN-END:|108-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarContenidoCommand ">//GEN-BEGIN:|110-getter|0|110-preInit
/**
* Returns an initiliazed instance of buscarContenidoCommand component.
* @return the initialized component instance
*/
public Command getBuscarContenidoCommand() {
if (buscarContenidoCommand == null) {//GEN-END:|110-getter|0|110-preInit
// write pre-init user code here
buscarContenidoCommand = new Command("Buscar Contenido", Command.ITEM, 0);//GEN-LINE:|110-getter|1|110-postInit
// write post-init user code here
}//GEN-BEGIN:|110-getter|2|
return buscarContenidoCommand;
}
//</editor-fold>//GEN-END:|110-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarAutorCommand ">//GEN-BEGIN:|112-getter|0|112-preInit
/**
* Returns an initiliazed instance of buscarAutorCommand component.
* @return the initialized component instance
*/
public Command getBuscarAutorCommand() {
if (buscarAutorCommand == null) {//GEN-END:|112-getter|0|112-preInit
// write pre-init user code here
buscarAutorCommand = new Command("Buscar Autor", Command.ITEM, 0);//GEN-LINE:|112-getter|1|112-postInit
// write post-init user code here
}//GEN-BEGIN:|112-getter|2|
return buscarAutorCommand;
}
//</editor-fold>//GEN-END:|112-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: siguientePaginaCommand ">//GEN-BEGIN:|115-getter|0|115-preInit
/**
* Returns an initiliazed instance of siguientePaginaCommand component.
* @return the initialized component instance
*/
public Command getSiguientePaginaCommand() {
if (siguientePaginaCommand == null) {//GEN-END:|115-getter|0|115-preInit
// write pre-init user code here
siguientePaginaCommand = new Command("Siguiente", Command.ITEM, 0);//GEN-LINE:|115-getter|1|115-postInit
// write post-init user code here
}//GEN-BEGIN:|115-getter|2|
return siguientePaginaCommand;
}
//</editor-fold>//GEN-END:|115-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarForm ">//GEN-BEGIN:|106-getter|0|106-preInit
/**
* Returns an initiliazed instance of buscarForm component.
* @return the initialized component instance
*/
public Form getBuscarForm() {
if (buscarForm == null) {//GEN-END:|106-getter|0|106-preInit
// write pre-init user code here
buscarForm = new Form("Buscar", new Item[] { getBuscarTF() });//GEN-BEGIN:|106-getter|1|106-postInit
buscarForm.addCommand(getBuscarContenidoCommand());
buscarForm.addCommand(getBuscarTagCommand());
buscarForm.addCommand(getBuscarAutorCommand());
buscarForm.addCommand(getBackCommand());
buscarForm.setCommandListener(this);//GEN-END:|106-getter|1|106-postInit
// write post-init user code here
}//GEN-BEGIN:|106-getter|2|
return buscarForm;
}
//</editor-fold>//GEN-END:|106-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: buscarTF ">//GEN-BEGIN:|114-getter|0|114-preInit
/**
* Returns an initiliazed instance of buscarTF component.
* @return the initialized component instance
*/
public TextField getBuscarTF() {
if (buscarTF == null) {//GEN-END:|114-getter|0|114-preInit
// write pre-init user code here
buscarTF = new TextField("Buscar", "", 140, TextField.ANY);//GEN-LINE:|114-getter|1|114-postInit
// write post-init user code here
}//GEN-BEGIN:|114-getter|2|
return buscarTF;
}
//</editor-fold>//GEN-END:|114-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|124-getter|0|124-preInit
/**
* Returns an initiliazed instance of backCommand component.
* @return the initialized component instance
*/
public Command getBackCommand() {
if (backCommand == null) {//GEN-END:|124-getter|0|124-preInit
// write pre-init user code here
backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|124-getter|1|124-postInit
// write post-init user code here
}//GEN-BEGIN:|124-getter|2|
return backCommand;
}
//</editor-fold>//GEN-END:|124-getter|2|
//</editor-fold>
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: resultadosList ">//GEN-BEGIN:|120-getter|0|120-preInit
/**
* Returns an initiliazed instance of resultadosList component.
* @return the initialized component instance
*/
public List getResultadosList() {
if (resultadosList == null) {//GEN-END:|120-getter|0|120-preInit
// write pre-init user code here
resultadosList = new List("Resultados", Choice.MULTIPLE);//GEN-BEGIN:|120-getter|1|120-postInit
resultadosList.addCommand(getSiguientePaginaCommand());
resultadosList.addCommand(getReTweetCommand());
resultadosList.addCommand(getBackCommand());
resultadosList.setCommandListener(this);//GEN-END:|120-getter|1|120-postInit
// write post-init user code here
}//GEN-BEGIN:|120-getter|2|
return resultadosList;
}
//</editor-fold>//GEN-END:|120-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resultadosListAction ">//GEN-BEGIN:|120-action|0|120-preAction
/**
* Performs an action assigned to the selected list element in the resultadosList component.
*/
public void resultadosListAction() {//GEN-END:|120-action|0|120-preAction
// enter pre-action user code here
String __selectedString = getResultadosList().getString(getResultadosList().getSelectedIndex());//GEN-LINE:|120-action|1|120-postAction
// enter post-action user code here
}//GEN-BEGIN:|120-action|2|
//</editor-fold>//GEN-END:|120-action|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: reTweetCommand ">//GEN-BEGIN:|126-getter|0|126-preInit
/**
* Returns an initiliazed instance of reTweetCommand component.
* @return the initialized component instance
*/
public Command getReTweetCommand() {
if (reTweetCommand == null) {//GEN-END:|126-getter|0|126-preInit
// write pre-init user code here
reTweetCommand = new Command("ReTweet", Command.ITEM, 0);//GEN-LINE:|126-getter|1|126-postInit
// write post-init user code here
}//GEN-BEGIN:|126-getter|2|
return reTweetCommand;
}
//</editor-fold>//GEN-END:|126-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetsPendientesList ">//GEN-BEGIN:|143-getter|0|143-preInit
/**
* Returns an initiliazed instance of tweetsPendientesList component.
* @return the initialized component instance
*/
public List getTweetsPendientesList() {
if (tweetsPendientesList == null) {//GEN-END:|143-getter|0|143-preInit
// write pre-init user code here
tweetsPendientesList = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|143-getter|1|143-postInit
tweetsPendientesList.addCommand(getBackCommand());
tweetsPendientesList.addCommand(getTweetPendienteCommand());
tweetsPendientesList.addCommand(getEditarCommand());
tweetsPendientesList.addCommand(getEliminarCommand());
tweetsPendientesList.setCommandListener(this);//GEN-END:|143-getter|1|143-postInit
// write post-init user code here
}//GEN-BEGIN:|143-getter|2|
return tweetsPendientesList;
}
//</editor-fold>//GEN-END:|143-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: tweetsPendientesListAction ">//GEN-BEGIN:|143-action|0|143-preAction
/**
* Performs an action assigned to the selected list element in the tweetsPendientesList component.
*/
public void tweetsPendientesListAction() {//GEN-END:|143-action|0|143-preAction
// enter pre-action user code here
String __selectedString = getTweetsPendientesList().getString(getTweetsPendientesList().getSelectedIndex());//GEN-LINE:|143-action|1|143-postAction
// enter post-action user code here
}//GEN-BEGIN:|143-action|2|
//</editor-fold>//GEN-END:|143-action|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: editarCommand ">//GEN-BEGIN:|159-getter|0|159-preInit
/**
* Returns an initiliazed instance of editarCommand component.
* @return the initialized component instance
*/
public Command getEditarCommand() {
if (editarCommand == null) {//GEN-END:|159-getter|0|159-preInit
// write pre-init user code here
editarCommand = new Command("Editar", Command.ITEM, 0);//GEN-LINE:|159-getter|1|159-postInit
// write post-init user code here
}//GEN-BEGIN:|159-getter|2|
return editarCommand;
}
//</editor-fold>//GEN-END:|159-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: eliminarCommand ">//GEN-BEGIN:|163-getter|0|163-preInit
/**
* Returns an initiliazed instance of eliminarCommand component.
* @return the initialized component instance
*/
public Command getEliminarCommand() {
if (eliminarCommand == null) {//GEN-END:|163-getter|0|163-preInit
// write pre-init user code here
eliminarCommand = new Command("Eliminar", Command.ITEM, 0);//GEN-LINE:|163-getter|1|163-postInit
// write post-init user code here
}//GEN-BEGIN:|163-getter|2|
return eliminarCommand;
}
//</editor-fold>//GEN-END:|163-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetPendienteCommand ">//GEN-BEGIN:|166-getter|0|166-preInit
/**
* Returns an initiliazed instance of tweetPendienteCommand component.
* @return the initialized component instance
*/
public Command getTweetPendienteCommand() {
if (tweetPendienteCommand == null) {//GEN-END:|166-getter|0|166-preInit
// write pre-init user code here
tweetPendienteCommand = new Command("Tweet", Command.ITEM, 0);//GEN-LINE:|166-getter|1|166-postInit
// write post-init user code here
}//GEN-BEGIN:|166-getter|2|
return tweetPendienteCommand;
}
//</editor-fold>//GEN-END:|166-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: editarPendienteForm ">//GEN-BEGIN:|150-getter|0|150-preInit
/**
* Returns an initiliazed instance of editarPendienteForm component.
* @return the initialized component instance
*/
public Form getEditarPendienteForm() {
if (editarPendienteForm == null) {//GEN-END:|150-getter|0|150-preInit
// write pre-init user code here
editarPendienteForm = new Form("form", new Item[] { getEditarTweetTF() });//GEN-BEGIN:|150-getter|1|150-postInit
editarPendienteForm.addCommand(getBackCommand());
editarPendienteForm.addCommand(getPostTweetCommand());
editarPendienteForm.setCommandListener(this);//GEN-END:|150-getter|1|150-postInit
// write post-init user code here
}//GEN-BEGIN:|150-getter|2|
return editarPendienteForm;
}
//</editor-fold>//GEN-END:|150-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: editarTweetTF ">//GEN-BEGIN:|154-getter|0|154-preInit
/**
* Returns an initiliazed instance of editarTweetTF component.
* @return the initialized component instance
*/
public TextField getEditarTweetTF() {
if (editarTweetTF == null) {//GEN-END:|154-getter|0|154-preInit
// write pre-init user code here
editarTweetTF = new TextField("Tweet", "", 32, TextField.ANY);//GEN-LINE:|154-getter|1|154-postInit
// write post-init user code here
}//GEN-BEGIN:|154-getter|2|
return editarTweetTF;
}
//</editor-fold>//GEN-END:|154-getter|2|
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: opcionesCG ">//GEN-BEGIN:|175-getter|0|175-preInit
/**
* Returns an initiliazed instance of opcionesCG component.
* @return the initialized component instance
*/
public ChoiceGroup getOpcionesCG() {
if (opcionesCG == null) {//GEN-END:|175-getter|0|175-preInit
// write pre-init user code here
opcionesCG = new ChoiceGroup("Opciones", Choice.MULTIPLE);//GEN-BEGIN:|175-getter|1|175-postInit
opcionesCG.append("Enviar Tweets Automaticamente", null);
opcionesCG.append("Truncar Tweets de mas de 140 caracteres", null);
opcionesCG.setSelectedFlags(new boolean[] { false, false });//GEN-END:|175-getter|1|175-postInit
// write post-init user code here
}//GEN-BEGIN:|175-getter|2|
return opcionesCG;
}
//</editor-fold>//GEN-END:|175-getter|2|
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tweetsPorPaginaTF ">//GEN-BEGIN:|178-getter|0|178-preInit
/**
* Returns an initiliazed instance of tweetsPorPaginaTF component.
* @return the initialized component instance
*/
public TextField getTweetsPorPaginaTF() {
if (tweetsPorPaginaTF == null) {//GEN-END:|178-getter|0|178-preInit
// write pre-init user code here
tweetsPorPaginaTF = new TextField("Tweets por Pagina", "", 6, TextField.NUMERIC);//GEN-LINE:|178-getter|1|178-postInit
// write post-init user code here
}//GEN-BEGIN:|178-getter|2|
return tweetsPorPaginaTF;
}
//</editor-fold>//GEN-END:|178-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: salirCommand ">//GEN-BEGIN:|185-getter|0|185-preInit
/**
* Returns an initiliazed instance of salirCommand component.
* @return the initialized component instance
*/
public Command getSalirCommand() {
if (salirCommand == null) {//GEN-END:|185-getter|0|185-preInit
// write pre-init user code here
salirCommand = new Command("Salir", Command.ITEM, 0);//GEN-LINE:|185-getter|1|185-postInit
// write post-init user code here
}//GEN-BEGIN:|185-getter|2|
return salirCommand;
}
//</editor-fold>//GEN-END:|185-getter|2|
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (facade == null) {
facade = new TweeterFacade();
}
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
ItemStateListener itmListener = new ItemStateListener() {
public void itemStateChanged(Item item) {
try {
getCaracteresSI().setText(Integer.toString(tweetTF.getString().length()));
} catch (Exception e) {
e.printStackTrace();
}
}
};
getTweetFrom().setItemStateListener(itmListener);
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
facade=null;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
facade.cerrarConfiguracion();
facade=null;
}
/*
* *********METODOS MIOS******************
*/
private TweeterFacade facade;
private Tweet[] resultados;
private dbtweets.Tweet[] pendientes;
private int editando;
public void tweet() {
boolean b = facade.tweet(tweetTF.getString());
System.out.println("*************" + b + "*********************");
}
public void login() {
if (!facade.credencialesValidas()) {
// while(!facade.setCredenciales(userTF.getString(),passTF.getString())){
// }
}
}
public void buscarAutor() {
resultados = facade.buscarAutor(getBuscarTF().getString());
this.switchDisplayable(null, armarListaBuscar(resultados));
}
public void buscarContenido() {
resultados = facade.buscarContenido(getBuscarTF().getString());
this.switchDisplayable(null, armarListaBuscar(resultados));
}
public void buscarTag() {
resultados = facade.buscarTag(getBuscarTF().getString());
this.switchDisplayable(null, armarListaBuscar(resultados));
}
public void buscarSiguientePagina() {
resultados = facade.buscarSiguientePagina();
this.switchDisplayable(null, armarListaBuscar(resultados));
}
private List armarListaBuscar(Tweet[] tweets) {
List l = getResultadosList();
l.deleteAll();
for (int i = 0; i < tweets.length; i++) {
l.append(tweets[i].getString(MetadataSet.TWEET_AUTHOR_USERNAME) + ": " + tweets[i].getString(MetadataSet.TWEET_CONTENT), null);
}
return l;
}
public void verTweetsPendientes() {
pendientes = facade.getTweetsSalvados();
this.switchDisplayable(null, armarListaPendientes(pendientes));
}
private List armarListaPendientes(dbtweets.Tweet[] tweets) {
List l = getTweetsPendientesList();
l.deleteAll();
for (int i = 0; i < tweets.length; i++) {
l.append((i + 1) + ". " + tweets[i].getContenido(), null);
}
return l;
}
public void reTweet() {
try {
boolean[] selecteds = new boolean[resultados.length];
getResultadosList().getSelectedFlags(selecteds);
for (int i = 0; i < resultados.length; i++) {
if (selecteds[i]) {
facade.reTweet(resultados[i]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void tweetPendiente() {
facade.eliminarTweetSalvado(pendientes[getTweetsPendientesList().getSelectedIndex()]);
facade.tweet(pendientes[getTweetsPendientesList().getSelectedIndex()].getContenido());
verTweetsPendientes();
}
public void eliminarPendiente() {
facade.eliminarTweetSalvado(pendientes[getTweetsPendientesList().getSelectedIndex()]);
verTweetsPendientes();
}
public void editarPendiente() {
editando = getTweetsPendientesList().getSelectedIndex();
getEditarTweetTF().setString(pendientes[editando].getContenido());
this.switchDisplayable(null, getEditarPendienteForm());
}
public void salvarPendienteYVolver() {
pendientes[editando].setContenido(getEditarTweetTF().getString());
facade.salvarTweetEditado(pendientes[editando]);
verTweetsPendientes();
}
public void enviarTweetEditado() {
facade.eliminarTweetSalvado(pendientes[editando]);
facade.tweet(pendientes[editando].getContenido());
verTweetsPendientes();
}
public void salvarConfiguracion() {
facade.setUsuario(getUserTF().getString());
facade.setContrasena(getPassTF().getString());
boolean[] sf = new boolean[2];
getOpcionesCG().getSelectedFlags(sf);
facade.setAutoSend(sf[0]);
facade.setTruncarTweets(sf[1]);
facade.setTweetsPagina(Integer.parseInt(getTweetsPorPaginaTF().getString()));
facade.guardarConfiguracion();
this.switchDisplayable(null, getInicialForm());
}
}