/*
userHomeGroupDelWizard.java
A wizard to handle the wizard interactions required when a user attempts
to delete the group that they have selected for their default group.
Created: 29 January 1998
Version: 1.13 98/08/11
Module By: Jonathan Abbey
Applied Research Laboratories, The University of Texas at Austin
*/
package arlut.csd.ganymede.custom;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import arlut.csd.ganymede.*;
import arlut.csd.JDialog.JDialogBuff;
/*------------------------------------------------------------------------------
class
userHomeGroupDelWizard
------------------------------------------------------------------------------*/
/**
*
* A wizard to handle the wizard interactions required when a user attempts
* to delete the group that they have selected for their default group.
*
*
When a user deletes a group from their list of groups (264)
* that they are a member of, the userCustom object will check to see
* if that group is the one they have selected as their default (home)
* group in field 265. If so, this wizard gets invoked to make sure
* that the user understands the consequences of this act, and to solicit
* from the user their choice of other group to set as their default (home)
* group.
*
*
See userSchema.java for a list of field definitions used by this wizard.
*
* @see arlut.csd.ganymede.ReturnVal
* @see arlut.csd.ganymede.Ganymediator
* @see arlut.csd.ganymede.custom.userSchema
*/
public class userHomeGroupDelWizard extends GanymediatorWizard implements userSchema {
/**
* The user-level session context that this wizard is acting in. This
* object is used to handle necessary checkpoint/rollback activity by
* this wizard, as well as to handle any necessary label lookups.
*/
GanymedeSession session;
/**
* Keeps track of the state of the wizard. Each time respond() is called,
* state is checked to see what results from the user are expected and
* what the appropriate dialogs or actions to perform in turn are.
*
* state is also used by the userCustom object to make sure that
* we have finished our interactions with the user when we tell the
* user object to go ahead and remove the group.
*
*
* Values: * 1 - Wizard has been initialized, initial explanatory dialog * has been generated. * 2 - Wizard has generated the second dialog and is waiting * for the user to either choose a new home group, or * cancel out. * DONE (99) - Wizard has approved the proposed action, and is signalling * the user object code that it is okay to proceed with the * action without further consulting this wizard. **/ // int state; We don't want to shadow the state variable from GanymediatorWizard /** * The actual user object that this wizard is acting on. */ userCustom userObject; /** * The Integer index of the group entry that we are being asked to * help delete. We keep track of this so that when the user finishes * the interaction sequence we know which element to go ahead and * remove. */ int index; /* -- */ /** * * This constructor registers the wizard as an active wizard * on the provided session. * * @param session The GanymedeSession object that this wizard will * use to interact with the Ganymede data store. * @param userObject The user object that this wizard will work with. * @param param An Integer object specifying the index of the GROUPLIST * field that the user wishes to delete. * */ public userHomeGroupDelWizard(GanymedeSession session, userCustom userObject, Object param) throws RemoteException { super(session); // register ourselves this.session = session; this.userObject = userObject; if (!(param instanceof Integer)) { throw new IllegalArgumentException("Error, expecting an Integer array index"); } this.index = ((Integer) param).intValue(); } /** * * This method provides a default response if a user * hits cancel on a wizard dialog. This should be * subclassed if a wizard wants to provide a more * detailed cancel response. * */ public ReturnVal cancel() { return fail("Home Group Removal Canceled", "Home Group Removal Canceled", "OK", null, "ok.gif"); } public ReturnVal processDialog1() { ReturnVal retVal = null; /* -- */ System.err.println("userHomeGroupDelWizard.respond(): state == 1"); retVal = continueOn("Home Group Change", "What group do you want to set as the new default for this user?", "OK", "Cancel", "question.gif"); // get the list of choices, synthesize a list that contains every choice but // the one being deleted userObject.updateGroupChoiceList(); QueryResult groupChoice = userObject.groupChoices; // Which group is being deleted? Invid val = (Invid) userObject.getFieldValuesLocal(GROUPLIST).elementAt(index); // Make a list of all choices except the one being deleted Vector choices = new Vector(); for (int i = 0; i < groupChoice.size(); i++) { if (!groupChoice.getInvid(i).equals(val)) { choices.addElement(groupChoice.getLabel(i)); } } retVal.getDialog().addChoice("New Home Group", choices, (String) choices.elementAt(0)); System.err.println("userHomeGroupDelWizard.respond(): state == 2, returning dialog"); return retVal; } /** * * This method will be called if the client progressed from the second * dialog.
* Keys: * * "New Home Group" ** */ public ReturnVal processDialog2() { ReturnVal retVal = null; String checkPointKey = "homegroupdel" + userObject.getLabel(); /* -- */ System.err.println("userHomeGroupDelWizard.respond(): state == 2"); String group = (String) getParam("New Home Group"); // get the list of groups userObject.updateGroupChoiceList(); QueryResult groupChoice = userObject.groupChoices; // find the group we're changing to, find the id, change it boolean found = false; // we're going to check point here, so that we can undo things if // we can't complete all parts of this operation. This is needed // because we are doing two separate operations together.. the // InvidDBField logic does its own checkpointing, but we need // one that includes the two operations <