Index: trunk/src/Client/ChangeGroup.java =================================================================== --- trunk/src/Client/ChangeGroup.java (revision 0) +++ trunk/src/Client/ChangeGroup.java (revision 0) @@ -0,0 +1,63 @@ +/* + * ChangeGroup.java + * + * Created on April 25, 2007, 8:05 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package Client; + +import com.alsutton.jabber.datablocks.IqQueryRoster; +import java.util.Enumeration; +import javax.microedition.lcdui.Command; +import javax.microedition.lcdui.CommandListener; +import javax.microedition.lcdui.Display; +import javax.microedition.lcdui.Displayable; +import javax.microedition.lcdui.Form; +import javax.microedition.lcdui.StringItem; +import javax.microedition.lcdui.TextField; +import locale.SR; +import ui.controls.TextFieldCombo; + +/** + * + * @author ad + */ +public class ChangeGroup implements CommandListener{ + + private Display display; + private Form f; + private TextFieldCombo groupName; + private Group group; + + private Command cmdOk=new Command(SR.MS_OK, Command.SCREEN, 1); + private Command cmdCancel=new Command(SR.MS_CANCEL, Command.BACK, 99); + + Roster roster; + + public ChangeGroup(Display display, Group group) { + + this.group=group; + this.display=display; + + f=new Form(SR.MS_NEWGROUP); + + groupName=new TextFieldCombo(SR.MS_NEWGROUP, group.getName(), 256, TextField.ANY, "groups", display); + f.append(groupName); + + f.addCommand(cmdOk); + f.addCommand(cmdCancel); + + f.setCommandListener(this); + + display.setCurrent(f); + } + + public void commandAction(Command command, Displayable displayable) { + if (command==cmdOk) + StaticData.getInstance().roster.changeGroup(group.getName(), groupName.getString()); + display.setCurrent(StaticData.getInstance().roster); + } +} Index: trunk/src/Client/Roster.java =================================================================== --- trunk/src/Client/Roster.java (revision 1075) +++ trunk/src/Client/Roster.java (working copy) @@ -1685,7 +1685,25 @@ //System.out.println("Do autostatus change"); setAutoStatus(Presence.PRESENCE_AWAY); } + + public void changeGroup(String sourceGroup, String destGroup) { + for (Enumeration e=hContacts.elements(); e.hasMoreElements();){ + Contact cr=(Contact)e.nextElement(); + if (cr.getGroup().getName()==sourceGroup) { + theStream.send(new IqQueryRoster(cr.getBareJid(), cr.nick, destGroup, null)); + } + + } + } + public void deleteGroup(Group deleteGroup) { + for (Enumeration e=hContacts.elements(); e.hasMoreElements();){ + Contact cr=(Contact)e.nextElement(); + if (cr.getGroup()==deleteGroup) + deleteContact(cr); + } + } + private class ReEnumerator implements Runnable{ Thread thread; Index: trunk/src/Client/RosterItemActions.java =================================================================== --- trunk/src/Client/RosterItemActions.java (revision 1075) +++ trunk/src/Client/RosterItemActions.java (working copy) @@ -58,14 +58,18 @@ public class RosterItemActions extends Menu implements YesNoAlert.YesNoListener{ public final static int DELETE_CONTACT=4; + public final static int DELETE_GROUP=1004; Object item; Roster roster; + + private int action; + /** Creates a new instance of RosterItemActions */ public RosterItemActions(Display display, Object item, int action) { super(item.toString()); - + this.action=action; roster=StaticData.getInstance().roster; if (!roster.isLoggedIn()) return; @@ -190,11 +194,21 @@ addItem(SR.MS_BANNED,14); } } - } - //m.addItem(new MenuItem("Cleanup offlines")) + } else { + if ( group.index!=Groups.TYPE_IGNORE + && group.index!=Groups.TYPE_NOT_IN_LIST + && group.index!=Groups.TYPE_SEARCH_RESULT + && group.index!=Groups.TYPE_SELF + && group.index!=Groups.TYPE_TRANSP) + { + addItem(SR.MS_RENAME,1001); + addItem(SR.MS_DELETE, DELETE_GROUP); + } + } } if (getItemCount()>0) { - if (action<0) attachDisplay(display); + if (action<0) + attachDisplay(display); else try { this.display=display; // to invoke dialog Y/N doAction(action); @@ -208,7 +222,7 @@ MenuItem me=(MenuItem) getFocusedObject(); destroyView(); if (me==null) return; - int index=me.index; + int index=action=me.index; doAction(index); //destroyView(); } catch (Exception e) { e.printStackTrace(); } @@ -402,11 +416,44 @@ return; } } + } else { + Group sg=(Group)item; + + if ( sg.index!=Groups.TYPE_IGNORE + && sg.index!=Groups.TYPE_NOT_IN_LIST + && sg.index!=Groups.TYPE_SEARCH_RESULT + && sg.index!=Groups.TYPE_SELF + && sg.index!=Groups.TYPE_TRANSP) + { + switch (index) { + case 1001: //rename + { + new ChangeGroup(display, sg); + return; + } + case DELETE_GROUP: //delete + { + new YesNoAlert(display, SR.MS_DELETE_GROUP_ASK, sg.getName(), this); + return; + } + } + } } } public void ActionConfirmed() { - roster.deleteContact((Contact)item); + switch (action) { + case DELETE_CONTACT: + { + roster.deleteContact((Contact)item); + break; + } + case DELETE_GROUP: + { + roster.deleteGroup((Group)item); + break; + } + } display.setCurrent(roster); } } Index: trunk/src/locale/SR.java =================================================================== --- trunk/src/locale/SR.java (revision 1075) +++ trunk/src/locale/SR.java (working copy) @@ -306,7 +306,8 @@ public static String MS_AWAY_LOCK = loadString( "keyblock / flip" ); public static String MS_AWAY_IDLE = loadString( "idle" ); public static String MS_ADD_AUTOJ = loadString( "Add autojoin bookmark" ); - + public static String MS_RENAME = loadString( "Rename/Move" ); + public static String MS_DELETE_GROUP_ASK = loadString( "Delete group?" ); //2007-04-12 @@ -327,7 +328,6 @@ - private SR() { } private static Hashtable lang;