001 /** 002 * Copyright 2010 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015 016 package org.kuali.student.common.ui.client.widgets.search; 017 018 import java.util.List; 019 020 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; 021 import org.kuali.student.common.ui.client.mvc.Callback; 022 import org.kuali.student.common.ui.client.widgets.KSLightBox; 023 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations; 024 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; 025 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup; 026 import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup; 027 import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; 028 import org.kuali.student.r2.core.search.dto.SearchRequestInfo; 029 030 public class AdvancedSearchWindow { 031 032 private VerticalFlowPanel layout = new VerticalFlowPanel(); 033 private KSLightBox dialog; 034 private SearchPanel searchPanel; 035 036 private ActionCancelGroup actionCancelButtons = new ActionCancelGroup(ButtonEnumerations.SearchCancelEnum.SEARCH, ButtonEnumerations.SearchCancelEnum.CANCEL); 037 038 public List<SelectedResults> getSelectedValues() { 039 return searchPanel.getSelectedValues(); 040 } 041 042 public SearchRequestInfo getSearchRequest() { 043 return searchPanel.getSearchRequest(); 044 } 045 046 public String getSelectedLookupName() { 047 return searchPanel.getSelectedLookupName(); 048 } 049 050 public AdvancedSearchWindow(String title, SearchPanel panel){ 051 052 actionCancelButtons.addStyleName("KS-Advanced-Search-Buttons"); 053 addCancelCompleteCallback(null); 054 searchPanel = panel; 055 searchPanel.setActionCancelButtonGroup(actionCancelButtons); 056 searchPanel.setupButtons(); 057 058 //dialog = new KSLightBox(title); 059 dialog = new KSLightBox(); 060 layout.addStyleName("KS-Advanced-Search-Window"); 061 SectionTitle sectionTitle = SectionTitle.generateH2Title(title); 062 dialog.setNonCaptionHeader(sectionTitle); 063 layout.add(panel); 064 layout.add(actionCancelButtons); 065 dialog.setMaxHeight(620); 066 ButtonGroup buttons = panel.getButtons(); 067 buttons.removeFromParent(); 068 dialog.addButtonGroup(buttons); 069 } 070 071 public void show(){ 072 searchPanel.setupSearch(); 073 dialog.setWidget(layout); 074 dialog.setMaxHeight(600); 075 dialog.show(); 076 } 077 078 public void hide(){ 079 dialog.hide(); 080 } 081 082 public void addCancelCompleteCallback(final Callback<Boolean> callback){ 083 //actionCompletedCallbacks.add(callback); 084 actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){ 085 @Override 086 public void exec(ButtonEnum result) { 087 if (result == ButtonEnumerations.SearchCancelEnum.CANCEL) { 088 if (callback != null) { 089 callback.exec(true); 090 } 091 dialog.hide(); 092 } 093 } 094 }); 095 } 096 097 public void addActionCompleteCallback(Callback<Boolean> callback){ 098 searchPanel.addActionCompleteCallback(callback); 099 } 100 }