IpCameraを自分のページに集約
詳細
public class RobotPage extends Page {
private final static String CSS_ROBOT_PAGE = "robot-page";
private final static String LOCALHOST = "127.0.0.1";
private final static String HTMLTEMPLATE_VIDEO = ""; //the video source for html
private final static String HTMLTEMPLATE_CONTROL = ""; //the ip-camera-control:direction source for html
private final static String XML_FILE_INSTRUCTION = "robot-instruction.xml";
private final static String XML_FILE_KIOSKINFO = "kiosk-information.xml";
private final static String CSS_RENTAL_LEFT_BUTTON = "robot-left-navibutton";
private final static String CSS_RENTAL_RIGHT_BUTTON = "robot-right-navibutton";
private final static String CSS_INSTRUCTION_GRID = "robot-instruction-grid";
private final static String CSS_LOG_SCROLL_PANEL = "robot-log-scroll-panel";
private final static String CSS_ROBOT_NAVI_PANEL = "robot-navi-buttons-panel";
private final static String CSS_GROUP_BUTTONS_GRIDS = "robot-group-buttons-grid";
private final static String CSS_IPCAMERA_DIRECTION = "ipcamera-direction-grid";
private final static String CSS_IPCAMERA_BRIGHTNESS = "ipcamera-brightness-grid";
private final static String CSS_WINDOW_CLOSE = "window-close-button";
private final static String CSS_MSG = "json-error-msg";
private final static String ROOT_NAME = "all";
private static final int PAGESIZE = 6; //will hold the number of instruction(each inst is a button).
private static final int MAXCOL_SIZE = InstPanel.MAX_INSTTUCTION_NUM; //in one row, there's 3 instruction button.
private static final int MAXROW_SIZE = PAGESIZE / MAXCOL_SIZE ; // each page will hold those rows.
private static int _currentPage = 0; //the state of current page number.
private static int _totalPage = 0; //the total of page number.
// protected HashMap _dataNames = new HashMap();
// protected ArrayList _valueListenersNames = new ArrayList();
// protected ArrayList _valueListeners = new ArrayList();
// protected ArrayList _errorListenersNames = new ArrayList();
// protected ArrayList _errorListeners = new ArrayList();
private static ArrayList _instList = new ArrayList(); //store Instruction
private static ArrayList _instPanelList = new ArrayList(); //store InstPanel;
private static ParseKioskInfo _parseKioskInfo = null; //it's global
protected String _group = ROOT_NAME; //story current group name
private CommandPushButton _cmdPrevPage; // navi button <<
private CommandPushButton _cmdNextPage; // navi button >>
private Grid _instGrid; // to arrage instruction panel...
private VerticalPanel _pageContentPanel; // the container of this page
private Label _errorMsg;
private HTML _logHtml;
private CustomScrollPanel _logContainer;
private KioskSelectionPopup _kioskPopup;
private DataLabel _entryField;
private HTML _ipCameraVideo;
private HTML _ipCameraControl;
public static PageInfo init(final Screen parent, final ScreenData data) {
return new PageInfo("robot-test", parent) {
public Page createInstance() {
return new RobotPage("robot-test", parent, data);
}
};
}
public RobotPage(String token, final Screen parent, ScreenData data) {
super(token, parent, data);
// KioskConstants constants = Main.getConstants();
// A vertical layout. this widget ready to prepare for xmlPanel...
_pageContentPanel = new VerticalPanel();
_pageContentPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
initWidget(_pageContentPanel);
setStyleName(CSS_ROBOT_PAGE);
}
public void preShowPageExecute() {
// KioskConstants constants = Main.getConstants();
// // Page title
// _pageTitle = PageTitle.getInstance();
// _pageTitle.setVisible(true);
// _pageTitle.setTitle("robot-instruction-test");
// final NavigationMenu naviMenu = NavigationMenu.getInstance();
// naviMenu.resetButtons();
// reset movie language selection
// _data.setValue( Rental.DATA_RENTAL_MOVIELANGUAGESELECTION_MOVIELANGUAGEID, "", null );
// super.preShowPageExecute();
_isBlocking = false;
_visible = true;
_hasBeenShown = true;
GetXML robotXml = new GetXML(XML_FILE_INSTRUCTION,_data,this,_pageContentPanel);
robotXml.call();
new CancelIdleTimer().scheduleRepeating( 1000);
//if there's no any password setting, don't show me.
if (Security.getPassword().length() > 0){
Security security = new Security(_data,this);
security.showSessionDialog();
}
// enableChangeListeners();
}
public void postHidePageExecute() {
_isBlocking = false;
_visible = false;
// disableChangeListeners();
}
protected class GetXML {
private ScreenData _screenData;
private Page _currPage;
private String _xmlFile;
private VerticalPanel _pageContentPanel;
protected GetXML(String xmlFile,ScreenData data,Page currentPage,VerticalPanel pageContentPanel){
_xmlFile = xmlFile;
_screenData = data;
_currPage = currentPage;
_pageContentPanel = pageContentPanel;
}
protected void call(){
HTTPRequest.asyncGet(_xmlFile, new ResponseTextHandler() {
public void onCompletion(String responseText) {
// In the real world, this text would come as a RPC response. This
// technique is great for testing and samples though!
renderXML(responseText);
}
public void dealWithRobotInstList(String xmlText,final VerticalPanel pageContentPanel) {
// --------------------------------begin xmlParse-------------------------------- //
Document robotInstDom = XMLParser.parse(xmlText);
Element topMostElement = robotInstDom.getDocumentElement();
// Must do this if you ever use a raw node list that you expect to be
// all elements.
XMLParser.removeWhitespace(topMostElement);
_instList.clear();
NodeList insts = topMostElement.getElementsByTagName("inst");
for (int i = 0; i < insts.getLength(); i++) {
Element inst = (Element) insts.item(i);
Instruction robotInst = new Instruction();
String desc = inst.getAttribute("desc") == null ? "" : inst.getAttribute("desc");
robotInst.setDesc(desc);
String urlMap = inst.getAttribute("urlMap") == null ? "" : inst.getAttribute("urlMap");
robotInst.setUrlMap(urlMap);
String group = inst.getAttribute("group") == null ? "others" : inst.getAttribute("group");
robotInst.setGroup(group);
NodeList params = inst.getChildNodes();
if(params == null){
_instList.add(robotInst);
continue;
}
Param[] robotInstParams = new Param[params.getLength()];
for(int j = 0; j < params.getLength(); j++) {
Element param = (Element) params.item(j);
robotInstParams[j] = new Param();
String name = param.getAttribute("name") == null ? "" : param.getAttribute("name");
robotInstParams[j].setName(name);
String paramDesc = param.getAttribute("desc") == null ? "" : param.getAttribute("desc");
robotInstParams[j].setDesc(paramDesc);
String reg = param.getAttribute("regularExpression") == null ? "" : param.getAttribute("regularExpression");
robotInstParams[j].setRegularExpression(reg.trim());
String defaultValue = param.getAttribute("defaultValue") == null ? "" : param.getAttribute("defaultValue");
robotInstParams[j].setValue(defaultValue.trim());
String min = param.getAttribute("min") == null ? "" : param.getAttribute("min");
robotInstParams[j].setMin(min.trim());
String max = param.getAttribute("max") == null ? "" : param.getAttribute("max");
robotInstParams[j].setMax(max.trim());
// _data.addDataItem(robotInst.getUrlMap().trim()+name.trim(), ScreenData.STRING_TYPE, 55);
//// if(!defaultValue.trim().equals("")){
// _data.setValue(robotInst.getUrlMap().trim()+name.trim(), defaultValue, null);
//// }
}
robotInst.setParams(robotInstParams);
_instList.add(robotInst);
}
// --------------------------------end xmlParse--------------------------------
// --------------------------------begin construct widget-------------------------------- //
_totalPage = _instList.size() / PAGESIZE;
if( _totalPage * PAGESIZE < _instList.size() ){
_totalPage += 1;
}
final HorizontalPanel cmdPanel = new HorizontalPanel();
cmdPanel.setStyleName(CSS_ROBOT_NAVI_PANEL);
cmdPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
{
_cmdPrevPage = new CommandPushButton(/*"<>" */"");
_cmdNextPage.setStyleName(CSS_RENTAL_RIGHT_BUTTON);
_currentPage = _instList.size() > 0 ? 1 : 0;
_cmdNextPage.setVisible( _currentPage < _totalPage );
cmdPanel.add( _cmdPrevPage );
cmdPanel.setCellVerticalAlignment( _cmdPrevPage, HorizontalPanel.ALIGN_TOP);
cmdPanel.add( _cmdNextPage );
cmdPanel.setCellVerticalAlignment( _cmdNextPage, HorizontalPanel.ALIGN_TOP);
}
// cmdPanel.add(setTreeView());
setGroupButtons(cmdPanel,_currPage);
// Edit popup
// _entryField = new DataLabel( _currPage, _data, RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID,
// DataLabel.LABEL_ELLIPSES | DataLabel.LABEL_POPUP );
// AllKiosks.getInstanceAndAddCompletionCommand(new Command(){
// public void execute(){
//// Kiosk popup
// _kioskPopup = new KioskSelectionPopupExt( _currPage,
// _data,
// RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID,
// CssDefn.CSS_DATAENTRYPOPUP_CELLNUMBER,
// new HTML("select the kiosk you want to test."),_entryField);
// //HB,2008/04/01, Step 4: add change listern,the third param is a widget have implements ChangeListener.
// _data.addValueChangeListener( RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID, _entryField );
//
// _entryField.setMap(AllKiosks.getInstance().getKioskMap());
//
// // Edit button
// CommandPushButton kioskButton = new CommandPushButton( "select
kiosk" );
// kioskButton.setCommand( new SelectKioskCommand( _kioskPopup ));
//
// cmdPanel.add(kioskButton);
// }
// });
pageContentPanel.add(cmdPanel);
HorizontalPanel instPanel = new HorizontalPanel();
instPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
//log: record the json value
// RichTextArea log = new RichTextArea();
// log.setStyleName(NOTES_STYLE);
{
_errorMsg = new Label();
_errorMsg.setWordWrap(true);
_errorMsg.setStyleName(CSS_MSG);
}
_logHtml = new HTML();
_logContainer = new CustomScrollPanel( _logHtml );
_logContainer.setStyleName( CSS_LOG_SCROLL_PANEL );
// instPanel.add(setTreeView());
{
{
_instGrid = new Grid(MAXROW_SIZE,MAXCOL_SIZE);
_instGrid.setStyleName(CSS_INSTRUCTION_GRID);
instPanel.add( _instGrid );
instPanel.setCellVerticalAlignment( _instGrid, HorizontalPanel.ALIGN_TOP);
{
_instPanelList.clear();
int currentRow = 0;
int currentCol = 0;
for(Iterator iter = _instList.iterator(); iter.hasNext(); ){
Instruction currentInst = (Instruction)iter.next();
InstPanel tmpPanel = new InstPanel(currentInst,_logContainer,_logHtml,_errorMsg,_screenData,_currPage);
_instPanelList.add(tmpPanel);
if( currentRow <= MAXROW_SIZE - 1 ){
_instGrid.setWidget(currentRow, currentCol,tmpPanel);
_instGrid.getCellFormatter().setHorizontalAlignment( currentRow,
currentCol,
VerticalPanel.ALIGN_LEFT);
_instGrid.getCellFormatter().setVerticalAlignment( currentRow,
currentCol,
VerticalPanel.ALIGN_TOP);
}
else {
continue;
}
if( currentCol < MAXCOL_SIZE - 1 ){
currentCol++;
}
else {
currentRow++;
currentCol = 0;
}
}
}
}
VerticalPanel ipCameraVerticalPanel = new VerticalPanel(); //for adding ipcamera
{
_ipCameraVideo = new HTML("");
_ipCameraControl = new HTML("");
ipCameraVerticalPanel.add(_ipCameraVideo);
ipCameraVerticalPanel.add(_ipCameraControl);
Grid directionGrid = new Grid(3,3); //for controling the direction
directionGrid.setStyleName(CSS_IPCAMERA_DIRECTION);
{
Button up = new Button("↑", new ClickListener(){
public void onClick(Widget sender){
String ipcameraHost = "127.0.0.1";
if (_parseKioskInfo != null){
if (_parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID) != null){
ipcameraHost = _parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID).toString();
}
}
directionPost(ipcameraHost,"TiltUp");
}
}); //for up direction
directionGrid.setWidget(0, 1, up);
Button left = new Button("←", new ClickListener(){
public void onClick(Widget sender){
String ipcameraHost = "127.0.0.1";
if (_parseKioskInfo != null){
if (_parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID) != null){
ipcameraHost = _parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID).toString();
}
}
directionPost(ipcameraHost,"PanLeft");
}
}); //for left direction
directionGrid.setWidget(1, 0, left);
Button original = new Button("o", new ClickListener(){
public void onClick(Widget sender){
String ipcameraHost = "127.0.0.1";
if (_parseKioskInfo != null){
if (_parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID) != null){
ipcameraHost = _parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID).toString();
}
}
homePositionPost(ipcameraHost);
}
}); //return to original
directionGrid.setWidget(1, 1, original);
Button right = new Button("→", new ClickListener(){
public void onClick(Widget sender){
String ipcameraHost = "127.0.0.1";
if (_parseKioskInfo != null){
if (_parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID) != null){
ipcameraHost = _parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID).toString();
}
}
directionPost(ipcameraHost,"PanRight");
}
}); //for right direction
directionGrid.setWidget(1, 2, right);
Button down = new Button("↓", new ClickListener(){
public void onClick(Widget sender){
String ipcameraHost = "127.0.0.1";
if (_parseKioskInfo != null){
if (_parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID) != null){
ipcameraHost = _parseKioskInfo.getCameraIpList().get(RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID).toString();
}
}
directionPost(ipcameraHost,"TiltDown");
}
}); //for down direction
directionGrid.setWidget(2, 1, down);
}
ipCameraVerticalPanel.add(directionGrid);
//for Brightness
{
ipCameraVerticalPanel.add(new HTML("Brightness"));
Grid brightnessGrid = new Grid(1,3);
brightnessGrid.setStyleName(CSS_IPCAMERA_BRIGHTNESS);
Button darker = new Button("-", new ClickListener(){
public void onClick(Widget sender){
directionPost(_data.getValue(RobotScreen.DATA_ROBOTSCREEN_KIOSK_IP),"Darker");
}
}); //become darker
brightnessGrid.setWidget(0, 0, darker);
Button defaultBrightness = new Button("o", new ClickListener(){
public void onClick(Widget sender){
directionPost(_data.getValue(RobotScreen.DATA_ROBOTSCREEN_KIOSK_IP),"DefaultBrightness");
}
}); //keep intact
brightnessGrid.setWidget(0, 1, defaultBrightness);
Button brighter = new Button("+", new ClickListener(){
public void onClick(Widget sender){
directionPost(_data.getValue(RobotScreen.DATA_ROBOTSCREEN_KIOSK_IP),"Brighter");
}
}); //become brighter
brightnessGrid.setWidget(0, 2, brighter);
ipCameraVerticalPanel.add(brightnessGrid);
}
Button closeWindow = new Button("Leave Robot-test", new ClickListener(){
public void onClick(Widget sender){
closeWindow();
}
}); //hit to close the gwt-window
closeWindow.setStyleName(CSS_WINDOW_CLOSE);
ipCameraVerticalPanel.add(new HTML(" "));
ipCameraVerticalPanel.add(closeWindow);
}
instPanel.add(ipCameraVerticalPanel);
pageContentPanel.add(instPanel);
pageContentPanel.setCellHorizontalAlignment(instPanel, VerticalPanel.ALIGN_LEFT);
pageContentPanel.setCellVerticalAlignment(instPanel, VerticalPanel.ALIGN_TOP);
pageContentPanel.add(_errorMsg);
pageContentPanel.add(_logContainer);
pageContentPanel.setCellVerticalAlignment(_logContainer, VerticalPanel.ALIGN_TOP);
CellPanelHelper.setParentCellStyleName( _logContainer, CssDefn.CSS_SIGNUP_AGREEMENT_TERMS_CONTENT_CELL );
}
// --------------------------------end construct widget-------------------------------- //
// -------------set navi menu command-------------
_cmdPrevPage.setCommand(new PrevPageCommand());
_cmdNextPage.setCommand(new NextPageCommand());
// -------------set navi menu command-------------
}
//add two FlowPanel to this page.
private void renderXML(String xmlText) {
// final TabPanel tab = new TabPanel();
// final FlowPanel xmlSource = new FlowPanel();
//// final FlowPanel xmlParsed = new FlowPanel();
// final FlowPanel xmlrobot = new FlowPanel();
//// tab.add(xmlParsed, "Customer Pane");
// tab.add(xmlSource, "XML Source");
// tab.add(xmlrobot,"Robot Test");
//
// tab.selectTab(1);
// _pageContentPanel.add(tab);
// xmlPane(xmlText, xmlSource);
dealWithRobotInstList(xmlText, _pageContentPanel);
}
/**
* Show the raw XML.
*
* @param xmlText
* @param xmlSource
*/
// private void xmlPane(String xmlText, final FlowPanel xmlSource) {
// xmlText = xmlText.replaceAll("", ">");
// Label xml = new HTML("" + xmlText + "
", false);
// xml.setStyleName(XML_LABEL_STYLE);
// xmlSource.add(xml);
// }
});
}
}
//hit next button to do this command
protected class NextPageCommand implements Command {
public void execute(){
_currentPage++;
_instGrid.clear();
_cmdNextPage.setVisible( _currentPage < _totalPage);
_cmdPrevPage.setVisible(true);
int currentRow = 0;
int currentCol = 0;
ArrayList relatedPanelList = filteredInstPanel(_group);
for(int i = (_currentPage -1) * PAGESIZE; i >= 0 && i < _currentPage * PAGESIZE && i < relatedPanelList.size(); i++){
_instGrid.setWidget(currentRow, currentCol,(InstPanel)relatedPanelList.get(i));
if(currentCol < MAXCOL_SIZE - 1){
currentCol++;
}
else {
currentRow++;
currentCol = 0;
}
}
}
}
//hit prev button to do this command
protected class PrevPageCommand implements Command {
public void execute(){
_currentPage--;
_instGrid.clear();
_cmdNextPage.setVisible(_currentPage < _totalPage);
_cmdPrevPage.setVisible(_currentPage > 1);
int currentRow = 0;
int currentCol = 0;
ArrayList relatedPanelList = filteredInstPanel(_group);
for(int i = (_currentPage -1 ) * PAGESIZE; i >= 0 && i < _currentPage * PAGESIZE && i < relatedPanelList.size(); i++){
_instGrid.setWidget(currentRow, currentCol,(InstPanel)relatedPanelList.get(i));
if(currentCol < MAXCOL_SIZE -1 ){
currentCol++;
}
else {
currentRow++;
currentCol = 0;
}
}
}
}
/**
*
* add treeView,it has been expanded.
*/
// private Tree setTreeView() {
// TreeItem root = new TreeItem(new Button(ROOT_NAME, new ClickListener(){
// public void onClick(Widget sender){
// setGroup(ROOT_NAME);
// _currentPage = 2;
// new PrevPageCommand().execute();
// }
// }));
// Set hashSet = new HashSet();
//
// //-----get all distinct group-----
// for(Iterator insts = _instList.iterator(); insts.hasNext(); ) {
// Instruction inst = (Instruction) insts.next();
// String group = inst.getGroup();
// hashSet.add(group);
//
// }
// //-----get all distinct group-----
//
// for(Iterator groups = hashSet.iterator(); groups.hasNext(); ) {
// String group = groups.next().toString();
// root.addItem(new Button(group, new ClickListener(){
// public void onClick(Widget sender){
// setGroup(((Button)sender).getText());
// _currentPage = 2;
// new PrevPageCommand().execute();
// }
// }));
// }
//
// Tree t = new Tree();
// t.addItem(root);
//
// //----it's the only way to expand all nodes
// t.setSelectedItem(root.getChild(0));
// t.ensureSelectedItemVisible();
// //----it's the only way to expand all nodes
//
//
// return t;
// }
private void setGroupButtons( HorizontalPanel container,final Page curentPage) {
final int MAX_COL = 6;
final Grid grid = new Grid();
grid.setCellPadding(30);
grid.setCellSpacing(30);
grid.setStyleName(CSS_GROUP_BUTTONS_GRIDS);
Button all = new Button(ROOT_NAME, new ClickListener(){
public void onClick(Widget sender){
setGroup(ROOT_NAME);
_currentPage = 2;
new PrevPageCommand().execute();
}
});
ArrayList instGroups = new ArrayList();
//-----get all distinct group-----
for(Iterator insts = _instList.iterator(); insts.hasNext(); ) {
Instruction inst = (Instruction) insts.next();
String group = inst.getGroup();
if(!instGroups.contains(group)){
instGroups.add(group);
}
}
//-----get all distinct group-----
int rows = (instGroups.size() + 2)/MAX_COL;
rows = (instGroups.size() + 2) % MAX_COL == 0 ? rows : rows + 2;
grid.resize(rows, MAX_COL);
int row = 0;
int col = 0;
grid.setWidget(row, col, all);
for(Iterator groups = instGroups.iterator(); groups.hasNext(); ) {
String group = groups.next().toString();
Button groupItem = new Button(group, new ClickListener(){
public void onClick(Widget sender){
setGroup(((Button)sender).getText());
_currentPage = 2;
new PrevPageCommand().execute();
}
});
col++;
if (col==MAX_COL) {
col = 0;
row++;
}
grid.setWidget(row, col, groupItem);
}
// Edit popup
_entryField = new DataLabel( curentPage, _data, RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID,
DataLabel.LABEL_ELLIPSES | DataLabel.LABEL_POPUP );
//ParseKioskInfo.getInstance(xmlFile, nextCommand);
// AllKiosks.getInstanceAndAddCompletionCommand(new Command(){
AllKiosks.getInstanceAndAddCompletionCommand(new Command(){
public void execute(){
_parseKioskInfo = ParseKioskInfo.getInstance(XML_FILE_KIOSKINFO, new Command(){
public void execute(){
// Kiosk popup
_kioskPopup = new KioskSelectionPopupExt(curentPage,
_data,
RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID,
CssDefn.CSS_DATAENTRYPOPUP_CELLNUMBER,
new HTML("
select the kiosk you want to test."),_entryField);
//HB,2008/04/01, Step 4: add change listern,the third param is a widget have implements ChangeListener.
_data.addValueChangeListener( RobotScreen.DATA_RENTAL_CONFIRMRENTAL_KIOSKID, _entryField );
_entryField.setMap(_parseKioskInfo.getKioskDescList());
// Edit button
// CommandPushButton kioskButton = new CommandPushButton( "select kiosk" );
// kioskButton.setCommand( new SelectKioskCommand( _kioskPopup ));
Button edit = new Button("select kiosk", new ClickListener(){
public void onClick(Widget sender){
new SelectKioskCommand( _kioskPopup ).execute();
}
});
edit.setHTML(" select kiosk ");
grid.setWidget(grid.getRowCount()-2, grid.getColumnCount()-1, edit);
}
});
}
});
container.add(grid);
}
/**
* reset all related member of this page,excepting _instList and _instPanelList.
*/
private void filterGroup(String group) {
if(group.equals(ROOT_NAME)){
_currentPage = _instList.size() > 0 ? 1 : 0;
_totalPage = _instList.size() / PAGESIZE;
if( _totalPage * PAGESIZE < _instList.size() ){
_totalPage += 1;
}
}
else {
int counter = 0; //a counter of group
for(Iterator insts = _instList.iterator(); insts.hasNext(); ) {
Instruction inst = (Instruction)insts.next();
if (inst.getGroup().equals(group)){
counter++;
}
}
_currentPage = counter > 0 ? 1 : 0;
_totalPage = counter / PAGESIZE;
if( _totalPage * PAGESIZE < counter ){
_totalPage += 1;
}
}
}
/**
*
* @param group
* @return : get all related panels
*/
private ArrayList filteredInstPanel(String group){
if(group.equals(ROOT_NAME)) {
return _instPanelList;
}
ArrayList result = new ArrayList();
for(Iterator panels = _instPanelList.iterator(); panels.hasNext(); ) {
InstPanel panel = (InstPanel)panels.next();
if(panel.getInstruction().getGroup().equals(group)) {
result.add(panel);
}
}
return result;
}
protected void setGroup(String group) {
_group = group;
filterGroup(group);
}
private class CancelIdleTimer extends Timer {
public void run(){
MainPanel.getInstance().haltIdleTimer();
}
}
private class KioskSelectionPopupExt extends KioskSelectionPopup {
public KioskSelectionPopupExt(HasDataListeners listenerController,
ScreenData data,
String dataName,
String cssName,
HTML title,
DataLabel field){
super(listenerController,data,dataName,cssName,title,field);
_listenerController.addValueListener(dataName, field);
}
public void onHide() {
//get selected kiosk ip.
String kioskId = _data.getValue(_dataName);
// String kioskIp = (String)Security.getKioskIpList().get(kioskId);
//for kiosk
String kioskIp = (String)_parseKioskInfo.getKioskIpList().get(kioskId);
if( kioskIp == null) {
kioskIp = LOCALHOST;
}
//for camera
String cameraIp = (String)_parseKioskInfo.getCameraIpList().get(kioskId);
if( cameraIp == null) {
cameraIp = LOCALHOST;
}
_data.setValue(RobotScreen.DATA_ROBOTSCREEN_KIOSK_IP, kioskIp, null);
//reset html source for ip-camera:video
String htmlSource1 = HTMLTEMPLATE_VIDEO.replaceFirst("%h", cameraIp);
htmlSource1 = htmlSource1.replaceFirst("%u", _parseKioskInfo.getUser());
htmlSource1 = htmlSource1.replaceFirst("%p", _parseKioskInfo.getPassword());
// if( kioskIp != LOCALHOST){
_ipCameraVideo.setHTML(htmlSource1); //it's no use for localhost????
// }
// //reset html source for ip-camera:control
// String htmlSource2 = HTMLTEMPLATE_CONTROL.replaceFirst("%h", kioskIp);
// htmlSource2 = htmlSource2.replaceFirst("%u", _parseKioskInfo.getUser());
// htmlSource2 = htmlSource2.replaceFirst("%p", _parseKioskInfo.getPassword());
// if( kioskIp != LOCALHOST){
// _ipCameraControl.setHTML(htmlSource2); //it's no use for localhost????
// }
}
}
/*
* send the direction control instruction to ip-camera host or
* send the change brightness instruction to ip-camera host
*/
private void directionPost(String host,String direction){
String htmlDirection = null;
htmlDirection = HTMLTEMPLATE_CONTROL.replaceFirst("%h", host);
htmlDirection = htmlDirection.replaceFirst("%u", _parseKioskInfo.getUser());
htmlDirection = htmlDirection.replaceFirst("%p", _parseKioskInfo.getPassword());
htmlDirection = htmlDirection.replaceFirst("%d", direction);
_ipCameraControl.setHTML(htmlDirection);
}
/*
* send the home position instruction to ip-camera host
*/
private void homePositionPost(String host){
String htmlDirection = ""; //for reset homePosition
htmlDirection = htmlDirection.replaceFirst("%h", host);
htmlDirection = htmlDirection.replaceFirst("%u", _parseKioskInfo.getUser());
htmlDirection = htmlDirection.replaceFirst("%p", _parseKioskInfo.getPassword());
_ipCameraControl.setHTML(htmlDirection);
}
//close current window....
public static native void closeWindow() /*-{
answer = confirm("Leave robot-test?")
if (answer){
$wnd.close();
}
else {
}
}-*/;
}