Sei sulla pagina 1di 15

package com.scholarone.s1agxt.client.session.

popup;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.BaseObservable;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ContainerEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.event.WindowEvent;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.RootPanel;
import com.scholarone.s1agxt.client.S1AMain;
import com.scholarone.s1agxt.client.S1AServiceAsync;
import com.scholarone.s1agxt.client.common.constants.IConstants;
import com.scholarone.s1agxt.client.common.constants.IParameterNames;
import com.scholarone.s1agxt.client.common.constants.IResourceNames;
import com.scholarone.s1agxt.client.model.ProgramItem;
import com.scholarone.s1agxt.client.model.SessionHostItem;
import com.scholarone.s1agxt.client.model.SessionItem;
import com.scholarone.s1agxt.client.model.search.AbstractSummaryItem;
import com.scholarone.s1agxt.client.utility.ClientUtility;
import com.scholarone.s1agxt.client.utility.DisplayUtility;
import com.scholarone.s1agxt.client.utility.event.S1AEvents;
import java.util.Map;
/**
* @author
*
*/
public class EditSession extends BaseObservable
{
// Variable declarations for the popup

Window w;

TabPanel tabsMain;

public TabItem tabItemSessionInfo;

public TabItem tabItemAddEditHosts;

public TabItem tabItemAddRemoveAbstracts;

public EditSession_Tab_SessionInfo sessionInfoTab;

public EditSession_Tab_Hosts sessionHostsTab = new EditSession_Tab_Hosts();

public EditSession_Tab_Abstracts sessionAbstractsTab = new EditSession_Tab_Abs
tracts();

public SessionItem selectedSessionEventItem;

Button button_Save = null;

Button button_Close = null;

int performActionAfterSave = 0;

boolean sessionTypeChangedFl = false;

private String source; // US-000052

boolean switchInfoTabFl = false;

boolean switchAbstractsTabFl = false;

boolean hideWindow = false;
/**
* EditSession constructor
* US-000052
*
* @param source
*/
public EditSession(String sourceEl)
{
this.source = sourceEl;
this.sessionInfoTab = new EditSession_Tab_SessionInfo(sourceEl);
}
AsyncCallback sessionEditSaveCallback = new AsyncCallback()
{
public void onSuccess(Object result)
{
// take the result coming from the server
Integer sessionId = (Integer)result;
if (sessionId != null)
{
// Successful save...

if (selectedSessionEventItem.getSessionId() == null)
{
selectedSessionEventItem.setSessionId(sessionId);
sessionInfoTab.refreshSessionInfoFromDB(); // SF-10566
}

S1AMain.sessionsAndEventsRenderer.sessionsEventsGrid.reloadGrid();
Info.display("Information", "Successfully Saved");
// US-000053 s
StoreEvent<SessionItem> event = new StoreEvent<SessionItem>(null);
event.setModel(selectedSessionEventItem);
fireEvent(S1AEvents.SaveSuccess, event);
// US-000053 e
if (performActionAfterSave == IConstants.SESSION_EVENT_TAB_HOSTS.intVa
lue())
{
tabItemAddEditHosts.enable();
tabsMain.setSelection(tabItemAddEditHosts);
performActionAfterSave = 0;
}

if (performActionAfterSave == IConstants.SESSION_EVENT_TAB_ADD_REMOVE_
ABSTRACTS.intValue())
{
tabItemAddRemoveAbstracts.enable();
tabsMain.setSelection(tabItemAddRemoveAbstracts);
performActionAfterSave = 0;
}

if (performActionAfterSave == IConstants.SESSION_EVENT_TAB_SHOW_OWNERS
_WINDOW.intValue())
{
sessionInfoTab.openSessionOwnersWindow();
performActionAfterSave = 0;
}

sessionTypeChangedFl = false;

w.setHeading(getWindowHeading());
sessionInfoTab.prepareSessionInfoTabComponents(); // SF_10608
}
else
{
MessageBox.alert("Error", IConstants.STANDARD_GENERIC_ERROR_MESSAGE, nul
l);
}
}
public void onFailure(Throwable caught)
{
MessageBox.alert("Error", IConstants.STANDARD_GENERIC_ERROR_MESSAGE, null)
;
}
};

Listener<MessageBoxEvent> switchTabSaveSessionListener = new Listener<MessageB
oxEvent>()
{
public void handleEvent(MessageBoxEvent ce)
{
Button btn = ce.getButtonClicked();

if (IConstants.MESSAGE_BOX_YES_STR.equals(btn.getText()))
{
sessionTypeChangedFl = false;
saveSessionInfo();
}
else
{
onCancelSaveSession();
}
}
};

/**
* Gets the main edit session or event window
*
* @param siIn
* @param showTabNo
* @return
*/
public Window getAddEditSessionWindow(SessionItem siIn, int showTabNo)
{
selectedSessionEventItem = siIn;

performActionAfterSave = 0;
w = new Window();
w.setSize(940, 600);
w.setPlain(true);
w.setModal(true);
w.setHeading(getWindowHeading());
w.setLayout(new FitLayout());
w.setMaximizable(true);
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());

boolean isReadOnlyFl = DisplayUtility.getIsSessionEventPopupReadOnly();
tabsMain = new TabPanel();
tabsMain.setMinTabWidth(215);
tabsMain.setAutoHeight(true);
tabsMain.setResizeTabs(true);
// SF_10582 s
tabsMain.addListener(Events.Select, new Listener<TabPanelEvent>()
{
public void handleEvent(TabPanelEvent event)
{
event.getItem().layout(true);
}
});
// SF_10582 e
tabItemSessionInfo = new TabItem("Information");
tabItemSessionInfo.addStyleName("pad-text");
tabsMain.add(tabItemSessionInfo);
tabItemSessionInfo.addListener(Events.Show, new Listener<BaseEvent>()
{
public void handleEvent(BaseEvent event)
{
tabItemSessionInfo.layout(true);
}
});

tabItemSessionInfo.addListener(Events.BeforeSelect, new Listener<BaseEvent>(
)
{
public void handleEvent(BaseEvent be)
{
if (!switchInfoTabFl && validateHostRolesOnSwitch())
{
Listener<MessageBoxEvent> ignoreErrorListener = new Listener<MessageBo
xEvent>()
{
public void handleEvent(MessageBoxEvent mbe)
{
if (IConstants.MESSAGE_BOX_YES_STR.equals(mbe.getButtonClicked().g
etText()))
{
tabItemSessionInfo.enable();
switchInfoTabFl = true;
switchAbstractsTabFl = true;
hideWindow = true;
tabsMain.setSelection(tabItemSessionInfo);
//switchInfoTabFl = false;
}
else
{
switchInfoTabFl = false;
}
}
};
String error = ClientUtility.getResourceValue(IResourceNames.HOST)
+ " Role is not set for one or more assigned " + ClientUtility.get
ResourceValue(IResourceNames.HOSTS)
+ ".";
MessageBox.confirm("Confirm", error + " Do you want to continue?", ign
oreErrorListener);
be.setCancelled(true);
}
}
});

sessionInfoTab.addSessionInformationTabComponents(tabItemSessionInfo);
if (showTabNo != IConstants.SESSION_EVENT_TAB_DETAILS.intValue())
{
sessionInfoTab.populateFields();
}

tabItemAddEditHosts = new TabItem((isReadOnlyFl ? "View " : "Add/Edit ") + C
lientUtility.getResourceValue(IResourceNames.HOSTS));
tabItemAddEditHosts.addStyleName("pad-text");
tabItemAddEditHosts.addListener(Events.BeforeSelect, new Listener<BaseEvent>
()
{
// SF-12186. remove check for max/min number of abstract/host limits
public void handleEvent(final BaseEvent event)
{
boolean hasSessionIdFl = (S1AMain.sessionsAndEventsRenderer.editSessionE
ventPopup.selectedSessionEventItem != null &&
S1AMain.sessionsAndEventsRenderer.editSessionEventPopup.selectedSess
ionEventItem.getSessionId() != null);
if (!DisplayUtility.getIsSessionEventPopupReadOnly())
{
if (!hasSessionIdFl || sessionTypeChangedFl || sessionInfoTab.isAnyFie
ldChanged()
&& tabItemSessionInfo.equals(tabsMain.getSelectedItem())) // S
F-15043. check only on switching from 'Information' tab
{
performActionAfterSave = IConstants.SESSION_EVENT_TAB_HOSTS.intValue
();

String itemName = ClientUtility.getResourceValue(IResourceNames.SESS
ION).toLowerCase();
if (S1AMain.sessionsAndEventsRenderer.editSessionEventPopup.selected
SessionEventItem.getSessionKindId().equals(IConstants.KIND_EVENT))
itemName = ClientUtility.getResourceValue(IResourceNames.EVENT).to
LowerCase();
else if (S1AMain.sessionsAndEventsRenderer.editSessionEventPopup.sel
ectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_SYMPOSIA))
itemName = ClientUtility.getResourceValue(IResourceNames.SYMPOSIA)
.toLowerCase();

MessageBox.confirm("Confirm", "The " + itemName + " is not saved. Is
it Ok to save it before switching tabs?", switchTabSaveSessionListener);

event.setCancelled(true);
}
else
{
Map<String, Object> params = ClientUtility.getParamsForService();

sessionInfoTab.saveFields(params);
}
}
}
});
tabsMain.add(tabItemAddEditHosts);

sessionHostsTab.addAddRemoveHostsTabComponents(tabItemAddEditHosts);
// Only sessions get add/remove abstracts
if (selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_SESSI
ON) ||
selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_SYMPO
SIA))
{
tabItemAddRemoveAbstracts = new TabItem((isReadOnlyFl ? "View " : "Add/Rem
ove/Withdraw ") + "Abstracts");
tabItemAddRemoveAbstracts.addStyleName("pad-text");
tabItemAddRemoveAbstracts.addListener(Events.BeforeSelect, new Listener<Ba
seEvent>()
{
// SF-12186. remove check for max/min number of abstract/host limits
public void handleEvent(final BaseEvent event)
{
if (!DisplayUtility.getIsSessionEventPopupReadOnly())
{
boolean hasSessionIdFl = (S1AMain.sessionsAndEventsRenderer.editSess
ionEventPopup.selectedSessionEventItem != null && S1AMain.sessionsAndEventsRende
rer.editSessionEventPopup.selectedSessionEventItem
.getSessionId() != null);

if (!hasSessionIdFl || sessionTypeChangedFl || sessionInfoTab.isAnyF
ieldChanged()
&& tabItemSessionInfo.equals(tabsMain.getSelectedItem())) // SF-
15043. check only on switching from
// 'In
formation' tab)
{
performActionAfterSave = IConstants.SESSION_EVENT_TAB_ADD_REMOVE_A
BSTRACTS.intValue();

String itemName = ClientUtility.getResourceValue(IResourceNames.SE
SSION).toLowerCase();
if (S1AMain.isSymposiaBuilder)
itemName = ClientUtility.getResourceValue(IResourceNames.SYMPOSI
A).toLowerCase();

MessageBox.confirm("Confirm", "The " + itemName
+ " is not saved. Ok to save it before switching tabs?", switc
hTabSaveSessionListener);
event.setCancelled(true);
}
else
{
Map<String, Object> params = ClientUtility.getParamsForService();

sessionInfoTab.saveFields(params);
sessionAbstractsTab.refreshDurationLabel();
}
if (!switchAbstractsTabFl && validateHostRolesOnSwitch())
{
Listener<MessageBoxEvent> ignoreErrorListener = new Listener<Messa
geBoxEvent>()
{
public void handleEvent(MessageBoxEvent mbe)
{
if (IConstants.MESSAGE_BOX_YES_STR.equals(mbe.getButtonClicked
().getText()))
{
tabItemAddRemoveAbstracts.enable();
switchAbstractsTabFl = true;
switchInfoTabFl = true;
hideWindow = true;
tabsMain.setSelection(tabItemAddRemoveAbstracts);
//switchAbstractsTabFl = false;
}
else
{
switchAbstractsTabFl = false;
}
}
};
String error = ClientUtility.getResourceValue(IResourceNames.HOST)
+ " Role is not set for one or more assigned " + ClientUtility
.getResourceValue(IResourceNames.HOSTS)
+ ".";

MessageBox.confirm("Confirm", error + " Do you want to continue?",
ignoreErrorListener);
event.setCancelled(true);
}
}
}
});
tabsMain.add(tabItemAddRemoveAbstracts);
tabItemAddRemoveAbstracts.addListener(Events.Show, new Listener<BaseEvent>
()
{
public void handleEvent(BaseEvent event)
{
tabItemAddRemoveAbstracts.layout(true);
}
});
sessionAbstractsTab.addAddRemoveAbstractsTabComponents(tabItemAddRemoveAbs
tracts);
}

viewport.add(tabsMain);
w.add(viewport);

if (showTabNo == IConstants.SESSION_EVENT_TAB_DETAILS.intValue())
{
tabsMain.setSelection(tabItemSessionInfo);
}
else if (showTabNo == IConstants.SESSION_EVENT_TAB_HOSTS.intValue())
{
tabsMain.setSelection(tabItemAddEditHosts);
}
else if (showTabNo == IConstants.SESSION_EVENT_TAB_ADD_REMOVE_ABSTRACTS.intV
alue())
{
tabsMain.setSelection(tabItemAddRemoveAbstracts);
sessionAbstractsTab.refreshSearchButton();
}
button_Save = new Button("Save", new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent ce)
{
saveSessionInfo(); // SF-12186. remove check for max/min number of abstr
act/host limits
}
});
button_Save.setIcon(AbstractImagePrototype.create(S1AMain.icons.disk()));

if (!isReadOnlyFl)
w.addButton(button_Save);
button_Close = new Button("Close", new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent ce)
{
// SF-12186 s. revert session type if it was changed but not saved
if (sessionTypeChangedFl)
{
sessionInfoTab.revertSessionTypeToPreviousValue();
}
w.hide();
}
});

button_Close.setIcon(AbstractImagePrototype.create(S1AMain.icons.cancel()));
w.addButton(button_Close);
w.addListener(Events.BeforeHide, new Listener<BaseEvent>()
{
public void handleEvent(BaseEvent be)
{
if (!hideWindow && validateHostRolesOnSwitch())
{
Listener<MessageBoxEvent> ignoreErrorListener = new Listener<MessageBo
xEvent>()
{
public void handleEvent(MessageBoxEvent mbe)
{
if (IConstants.MESSAGE_BOX_YES_STR.equals(mbe.getButtonClicked().g
etText()))
{
hideWindow = true;
w.hide();
}
else
{
hideWindow = false;
}
}
};
String error = ClientUtility.getResourceValue(IResourceNames.HOST)
+ " Role is not set for one or more assigned " + ClientUtility.get
ResourceValue(IResourceNames.HOSTS)
+ ".";
MessageBox.confirm("Confirm", error + " Do you want to continue?", ign
oreErrorListener);
be.setCancelled(true);
}
}
});
//
// This does a lot for now. Might want to try to do it a different way
// It resizes components in the edit session/event popup when the main windo
w
// is resized.
//
w.addListener(Events.Resize, new Listener<WindowEvent>()
{
public void handleEvent(final WindowEvent event)
{
boolean isMaximizedFl = event.getWindow().isMaximized();
// Info tab resizing here...
sessionInfoTab.lc.setWidth(event.getWidth() - 16);
sessionInfoTab.lc.setHeight(event.getHeight() - 100);
sessionInfoTab.lc.layout(true);

// Hosts tab resizing here...
sessionHostsTab.cpOuter.setWidth(event.getWidth() - 16);
sessionHostsTab.cpOuter.setHeight(event.getHeight() - 100);

sessionHostsTab.cpAvailableHosts.setWidth(event.getWidth() - 44);
sessionHostsTab.cpAvailableHosts.layout(true);

sessionHostsTab.cpCurrentHosts.setWidth(event.getWidth() - 44);
sessionHostsTab.cpCurrentHosts.layout(true);

sessionHostsTab.cpOuter.layout(true);

// Abstracts tab resizing here (Only sessions have the add/remove abstra
ct tabs)
if (selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_S
ESSION) ||
selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_S
YMPOSIA))
{
sessionAbstractsTab.cpOuter.setWidth(event.getWidth() - 16);
sessionAbstractsTab.cpOuter.setHeight(event.getHeight() - 100);

sessionAbstractsTab.cpSearchAbstracts.setWidth(event.getWidth() - 44);
sessionAbstractsTab.cpSearchAbstracts.layout(true);

sessionAbstractsTab.cpSearchResultsGrid.setWidth(event.getWidth() - 44
);
sessionAbstractsTab.cpSearchResultsGrid.layout(true);

sessionAbstractsTab.cpCurrentlyAssignedAbstracts.setWidth(event.getWid
th() - 44);
sessionAbstractsTab.cpCurrentlyAssignedAbstracts.layout(true);

sessionAbstractsTab.refreshSearchButton();
sessionAbstractsTab.refreshDurationLabel();
}

tabItemSessionInfo.layout(true);
sessionInfoTab.refreshButtons();
}
});
w.addListener(Events.Hide, new Listener<WindowEvent>()
{
public void handleEvent(final WindowEvent event)
{
// Must be bug in EXT GWT. We need to put scrollbars back on the main wi
ndow...
Element e = RootPanel.get().getBodyElement();
DOM.setStyleAttribute(e, "overflow", "auto");
}
});

viewport.addListener(Events.AfterLayout, new Listener<ContainerEvent>()
{
public void handleEvent(final ContainerEvent event)
{
if (selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_S
ESSION))
sessionAbstractsTab.refreshSearchButton();
}
});
//SF-9924 Set focus
w.setFocusWidget(sessionInfoTab.field_sessionTitle);
return w;
}

/**
* Saves the session info. Called from other methods.
*/
public void saveSessionInfo()
{
// SF-11675 s. Check session duration for 0.
Integer newDuration = ClientUtility.getIntegerFromString(sessionInfoTab.fiel
d_sessionDuration.getRawValue());

// 0 duration and session or event (not symposia)
if (new Integer(0).equals(newDuration) && !IConstants.KIND_SYMPOSIA.equals(s
electedSessionEventItem.getSessionKindId()))
{
String kind = ClientUtility.getResourceValue(IResourceNames.SESSION);
if (IConstants.KIND_EVENT.equals(selectedSessionEventItem.getSessionKindId
()))
kind = ClientUtility.getResourceValue(IResourceNames.EVENT);

MessageBox.confirm("Comfirm", "You are about to save " + kind
+ " with duration set to 0. Are you sure you want to continue?", new L
istener<MessageBoxEvent>()
{
public void handleEvent(MessageBoxEvent be)
{
Button btn = be.getButtonClicked();
if (IConstants.MESSAGE_BOX_YES_STR.equals(btn.getText()))
{
saveSessionInfoWithCheckedDuration();
}
else
{
onCancelSaveSession();
}
}
});
}
else
{
saveSessionInfoWithCheckedDuration();
}
// SF-11675 e
}
/**
* Saves Session info. Called after session duration check.
* SF-11675
*/
protected void saveSessionInfoWithCheckedDuration()
{
final S1AServiceAsync service = (S1AServiceAsync) Registry.get(S1AMain.SERVI
CE);
// US-000053 s
Integer newDuration = ClientUtility.getIntegerFromString(sessionInfoTab.fiel
d_sessionDuration.getRawValue());
if (newDuration == null)
newDuration = new Integer(0);

Integer prevDuration = selectedSessionEventItem.getSessionDuration();
if (prevDuration == null)
prevDuration = new Integer(0);

boolean isDurationChanged = (!newDuration.equals(prevDuration));
// US-000053 e
// SF-10692. If the session is already scheduled and its duration is changed
,
// then display a confirmation message box.
if (selectedSessionEventItem.getSessionLocationId() != null // is scheduled
&& isDurationChanged == true // is changed
&& sessionInfoTab.isDurationEditable() == false) // US-000053
{
String sessionEvent = ClientUtility.getResourceValue(IResourceNames.SESSIO
N);
if (IConstants.KIND_EVENT.equals(selectedSessionEventItem.getSessionKindId
()))
sessionEvent = ClientUtility.getResourceValue(IResourceNames.EVENT);
else if (IConstants.KIND_SYMPOSIA.equals(selectedSessionEventItem.getSessi
onKindId()))
sessionEvent = ClientUtility.getResourceValue(IResourceNames.SYMPOSIA);

MessageBox.confirm("Confirm",
"Changing the duration will remove the " + sessionEvent + " from the P
rogram. Are you sure?",
new Listener<MessageBoxEvent>()
{
public void handleEvent(MessageBoxEvent event)
{
Button btn = event.getButtonClicked();
if (IConstants.MESSAGE_BOX_YES_STR.equals(btn.getText()))
{
if (DisplayUtility.isCanScheduleSession(
selectedSessionEventItem, S1AMain.userId, IConstants.Y.equal
s(S1AMain.sessionAdminPermissionFl)))
{
Map<String, Object> params = ClientUtility.getParamsForService
();
sessionInfoTab.saveFields(params);
service.saveSession(params, selectedSessionEventItem, sessionE
ditSaveCallback);
}
else
{
String sessionEvent = ClientUtility.getResourceValue(IResource
Names.SESSION);
if (IConstants.KIND_EVENT.equals(selectedSessionEventItem.getS
essionKindId()))
sessionEvent = ClientUtility.getResourceValue(IResourceNames
.EVENT);
else if (IConstants.KIND_SYMPOSIA.equals(selectedSessionEventI
tem.getSessionKindId()))
sessionEvent = ClientUtility.getResourceValue(IResourceNames
.SYMPOSIA);

MessageBox.alert("Error", "You are not able to remove the " +
sessionEvent + ".", null);
onCancelSaveSession();
}
}
else
{
onCancelSaveSession();
}
}
});
}
else
{
Map<String, Object> params = ClientUtility.getParamsForService();
// SF-13925 s. do not save incorrect duration. show warning message instea
d
if (sessionInfoTab.isDurationEditable())
{
ProgramItem currentProgramItem = S1AMain.programSchedulerRenderer.getSch
edulerGrid().getCurrentProgramItem();
int programInterval = (currentProgramItem.getInterval() != null && curre
ntProgramItem.getInterval() > 0)
? currentProgramItem.getInterval() : 1;
if (newDuration % programInterval != 0)
{
MessageBox.alert("Warning", "The session Duration could not be saved.
The Program Time Interval "
+ "is currently set to " + programInterval + " minutes and the
Duration must be divisible by this value. "
+ "For example, if your Time Interval is 30 minutes, you canno
t save a Session Duration of 35 minutes.", null);
return;
}
params.put(IParameterNames.GRID_SCHEDULER_FL, true);
}
// SF-13925 e
sessionInfoTab.saveFields(params);
// US-000053 s
if (isDurationChanged == true && selectedSessionEventItem.getSessionLocati
onId() != null
&& sessionInfoTab.isDurationEditable() == true) // if the flag is set
then do not save duration to base
// because it ca
n has a conflict.
{
selectedSessionEventItem.setSessionDuration(prevDuration);
}
// US-000053 e
service.saveSession(params, selectedSessionEventItem, sessionEditSaveCallb
ack);
selectedSessionEventItem.setSessionDuration(newDuration); // US-000053
}
}
/**
* Get window heading text
* SCRPSE-003.0, SCRPSE-004.0
*
* @return
*/
private String getWindowHeading()
{
String createOrEditStr = "Edit";

if (DisplayUtility.getIsSessionEventPopupReadOnly())
{
createOrEditStr = "View";
}
else if (selectedSessionEventItem.getSessionId() == null || selectedSessionE
ventItem.getSessionId().intValue() == 0)
{
createOrEditStr = "Create";
}
if (selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_SESSI
ON))
{
createOrEditStr = createOrEditStr + " " + ClientUtility.getResourceValue(I
ResourceNames.SESSION);
}
else if (selectedSessionEventItem.getSessionKindId().equals(IConstants.KIND_
EVENT))
{
createOrEditStr = createOrEditStr + " " + ClientUtility.getResourceValue(I
ResourceNames.EVENT);
}
else
{
createOrEditStr = createOrEditStr + " " + ClientUtility.getResourceValue(I
ResourceNames.SYMPOSIA);
}
boolean isHeadingFieldsEmpty = true;
if (selectedSessionEventItem.getSessionClientId() != null)
{
createOrEditStr = createOrEditStr + ": " + selectedSessionEventItem.getSes
sionClientId();
isHeadingFieldsEmpty = false;
}

if (selectedSessionEventItem.getSessionAbbrv() != null && selectedSessionEve
ntItem.getSessionAbbrv().length() > 0)
{
if (!isHeadingFieldsEmpty)
{
createOrEditStr = createOrEditStr + " - ";
}
else
{
createOrEditStr = createOrEditStr + ": ";
}
createOrEditStr = createOrEditStr + selectedSessionEventItem.getSessionAbb
rv();
isHeadingFieldsEmpty = false;
}
if (selectedSessionEventItem.getSessionName() != null && selectedSessionEven
tItem.getSessionName().length() > 0)
{
if (!isHeadingFieldsEmpty)
{
createOrEditStr = createOrEditStr + " - ";
}
else
{
createOrEditStr = createOrEditStr + ": ";
}

createOrEditStr = createOrEditStr + selectedSessionEventItem.getSessionNam
e();
}

createOrEditStr = ClientUtility.encodeHtmlSpecialCharsAllowPalette(ClientUti
lity.limitString(createOrEditStr, 80)); //SF_10616, SF-14191

return createOrEditStr;
}

/**
* This method is called when a saving of session is canceled.
* */
protected void onCancelSaveSession()
{
performActionAfterSave = 0;
}

/**
* Return error message if host roles are not set.
* *
* @return
*/
private Boolean validateHostRolesOnSwitch()
{
for (ModelData model : sessionHostsTab.getCurrentlyAssignedHostsGrid().getSt
ore().getModels())
{
SessionHostItem host = (SessionHostItem) model;
if (host.getSessionHostRoleId() == null)
{
return true;
}
}
return false;
}
}

Potrebbero piacerti anche