private void initEditWindow() { String strBookName = theBook.getBookName(); this.setAutoSize(true); this.setTitle("《" + strBookName + "》" + "修改信息"); this.setCanDragReposition(true); this.setCanDragResize(false); this.setAutoCenter(true); this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); VLayout vLayout; HLayout hLayout; HLayout buttonLayout; vLayout = new VLayout(); vLayout.setWidth(WINDOW_WIDTH); vLayout.setHeight(WINDOW_HEIGHT); vLayout.setBorder("2px solid #7598C7"); vLayout.setMargin(12); vLayout.setPadding(14); hLayout = new HLayout(); hLayout.setWidth(WINDOW_WIDTH); // HLayout // --------------------------------------------------------------------------------------- strBookPicUrl = theBook.getBookPicUrl(); imgVLayout = new VLayout(); imgVLayout.setWidth(IMG_WIDTH); bookPicUrlItem = new Img(strBookPicUrl, IMG_WIDTH, IMG_HEIGHT); // bookPicUrlItem = new Img(strBookPicUrl, IMG_WIDTH, IMG_HEIGHT); // bookPicUrlItem.setPrefix("/images/upload/"); uploadPicButton = new IButton("上传封面"); uploadPicButton.setIcon("actions/plus.png"); uploadPicButton.setWidth(IMG_WIDTH); imgVLayout.setMembers(bookPicUrlItem, uploadPicButton); imgVLayout.setMembersMargin(10); // Form // 1----------------------------------------------------------------------------------------- SLBookDS theDataSource = new SLBookDS(); Record theRecord = theBook.toRecord(); theDataSource.addData(theRecord); bookForm1 = new DynamicForm(); bookForm1.setDataSource(theDataSource); bookForm1.setNumCols(4); bookForm1.setWidth("*"); bookForm1.setColWidths(100, "*", 100, "*"); bookForm1.setCellPadding(5); TextItem bookNameItem = new TextItem("bookName", "书名"); bookNameItem.setColSpan(4); bookNameItem.setWidth("100%"); bookNameItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookNameItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookAuthorItem = new TextItem("bookAuthor", "作者"); bookAuthorItem.setColSpan(4); bookAuthorItem.setWidth("100%"); bookAuthorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookAuthorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookISBNItem = new TextItem("bookISBN", "ISBN"); bookISBNItem.setColSpan(4); bookISBNItem.setWidth("100%"); bookISBNItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookISBNItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookISBNItem.setDisabled(true); TextItem bookPublisherItem = new TextItem("bookPublisher", "出版社"); bookPublisherItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPublisherItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); DateItem bookPublishDateItem = new DateItem("bookPublishDate", "出版日期"); bookPublishDateItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPublishDateItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookPublishDateItem.setUseTextField(true); SelectItem bookClassItem = new SelectItem("bookClass", "类别"); bookClassItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookClassItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookClassItem.setValueMap( "计算机/网络", "小说/文学", "哲学/文化", "经济/管理", "政治/军事", "励志/成长", "儿童/育儿", "心理", "法律", "历史", "其他"); bookClassItem.setDefaultToFirstOption(true); SelectItem bookLanguageItem = new SelectItem("bookLanguage", "语言"); bookLanguageItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookLanguageItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookLanguageItem.setValueMap("中文", "英语", "法语", "德语", "日语", "俄语", "韩语"); bookLanguageItem.setDefaultToFirstOption(true); TextItem bookContributorItem = new TextItem("bookContributor", "贡献者"); bookContributorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookContributorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookPriceItem = new TextItem("bookPrice", "价格"); bookPriceItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPriceItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookForm1.setFields( bookNameItem, bookAuthorItem, bookISBNItem, bookPublisherItem, bookPublishDateItem, bookClassItem, bookLanguageItem, bookContributorItem, bookPriceItem); bookForm1.selectRecord(theRecord); bookForm1.fetchData(); // Form // 2----------------------------------------------------------------------------------------- bookForm2 = new DynamicForm(); bookForm2.setDataSource(theDataSource); bookForm2.setNumCols(3); bookForm2.setWidth(WINDOW_WIDTH); bookForm2.setColWidths("*", "*", "*"); bookForm2.setCellPadding(3); bookForm2.setCellBorder(1); bookForm2.setTitleOrientation(TitleOrientation.TOP); StaticTextItem bookTotalQuantityItemTitle = new StaticTextItem("bookTotalQuantityTitle", ""); bookTotalQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookTotalQuantityItemTitle.setShowTitle(false); StaticTextItem bookInStoreQuantityitemTitle = new StaticTextItem("bookInStoreQuantityTitle", ""); bookInStoreQuantityitemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookInStoreQuantityitemTitle.setShowTitle(false); StaticTextItem bookAvailableQuantityItemTitle = new StaticTextItem("bookAvailableQuantityTitle", ""); bookAvailableQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookAvailableQuantityItemTitle.setShowTitle(false); TextItem bookTotalQuantityItem = new TextItem("bookTotalQuantity", ""); bookTotalQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookTotalQuantityItem.setShowTitle(false); TextItem bookInStoreQuantityitem = new TextItem("bookInStoreQuantity", ""); bookInStoreQuantityitem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookInStoreQuantityitem.setShowTitle(false); TextItem bookAvailableQuantityItem = new TextItem("bookAvailableQuantity", ""); bookAvailableQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookAvailableQuantityItem.setShowTitle(false); bookForm2.setFields( bookTotalQuantityItemTitle, bookInStoreQuantityitemTitle, bookAvailableQuantityItemTitle, bookTotalQuantityItem, bookInStoreQuantityitem, bookAvailableQuantityItem); bookForm2.selectRecord(theRecord); bookForm2.fetchData(); // Form // 3----------------------------------------------------------------------------------------- bookForm3 = new DynamicForm(); bookForm3.setDataSource(theDataSource); bookForm3.setWidth(WINDOW_WIDTH); bookForm3.setCellPadding(3); // bookForm2.setNumCols(2); bookForm3.setTitleOrientation(TitleOrientation.TOP); StaticTextItem bookIntroItemTitle = new StaticTextItem("bookIntroTitle", ""); bookIntroItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_text_title"); bookIntroItemTitle.setShowTitle(false); TextAreaItem bookIntroItem = new TextAreaItem("bookIntro", ""); bookIntroItem.setTextBoxStyle("alex_bookdisplaywindow_form_intro_content"); bookIntroItem.setShowTitle(false); bookIntroItem.setColSpan(2); bookIntroItem.setWidth("100%"); bookForm3.setFields(bookIntroItemTitle, bookIntroItem); bookForm3.selectRecord(theRecord); bookForm3.fetchData(); // buttonLayout // -------------------------------------------------------------------------------------- buttonLayout = new HLayout(); submitButton = new IButton("提交修改"); submitButton.setIcon("actions/approve.png"); buttonLayout.setMembers(submitButton); buttonLayout.setAlign(Alignment.RIGHT); hLayout.setMembers(imgVLayout, bookForm1); vLayout.setMembers(hLayout, bookForm2, bookForm3, buttonLayout); vLayout.setMembersMargin(20); this.addItem(vLayout); bind(); }
private void initNewWindow() { this.setAutoSize(true); this.setTitle("新书入库"); this.setCanDragReposition(true); this.setCanDragResize(false); this.setAutoCenter(true); this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); VLayout vLayout; HLayout hLayout; HLayout buttonLayout; vLayout = new VLayout(); vLayout.setWidth(WINDOW_WIDTH); vLayout.setHeight(WINDOW_HEIGHT); vLayout.setBorder("2px solid #7598C7"); vLayout.setMargin(12); vLayout.setPadding(14); hLayout = new HLayout(); hLayout.setWidth(WINDOW_WIDTH); // HLayout // --------------------------------------------------------------------------------------- imgVLayout = new VLayout(); imgVLayout.setWidth(IMG_WIDTH); bookPicUrlItem = new Img("/images/upload/" + strBookPicUrl, IMG_WIDTH, IMG_HEIGHT); // bookPicUrlItem = new Img(strBookPicUrl, IMG_WIDTH, IMG_HEIGHT); // bookPicUrlItem.setPrefix("/images/upload/"); uploadPicButton = new IButton("上传封面"); uploadPicButton.setIcon("actions/plus.png"); uploadPicButton.setWidth(IMG_WIDTH); imgVLayout.setMembers(bookPicUrlItem, uploadPicButton); imgVLayout.setMembersMargin(10); // Form // 1----------------------------------------------------------------------------------------- bookForm1 = new DynamicForm(); bookForm1.setNumCols(4); bookForm1.setWidth("*"); bookForm1.setColWidths(100, "*", 100, "*"); bookForm1.setCellPadding(5); TextItem bookNameItem = new TextItem("bookName", "书名"); bookNameItem.setColSpan(4); bookNameItem.setWidth("100%"); bookNameItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookNameItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookAuthorItem = new TextItem("bookAuthor", "作者"); bookAuthorItem.setColSpan(4); bookAuthorItem.setWidth("100%"); bookAuthorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookAuthorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookISBNItem = new TextItem("bookISBN", "ISBN"); bookISBNItem.setColSpan(4); bookISBNItem.setWidth("100%"); bookISBNItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookISBNItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookISBNItem.setShowIcons(true); FormItemIcon fetchBookInfoBut = new FormItemIcon(); fetchBookInfoBut.setSrc("/images/actions/approve.png"); bookISBNItem.setIcons(fetchBookInfoBut); bookISBNItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { fetchDataFromDouban(); } } }); fetchBookInfoBut.addFormItemClickHandler( new FormItemClickHandler() { @Override public void onFormItemClick(FormItemIconClickEvent event) { fetchDataFromDouban(); } }); bookISBNItem.setIconPrompt("从豆瓣获取书籍信息"); TextItem bookPublisherItem = new TextItem("bookPublisher", "出版社"); bookPublisherItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPublisherItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); DateItem bookPublishDateItem = new DateItem("bookPublishDate", "出版日期"); bookPublishDateItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPublishDateItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookPublishDateItem.setUseTextField(true); bookPublishDateItem.setDefaultChooserDate(new Date()); SelectItem bookClassItem = new SelectItem("bookClass", "类别"); bookClassItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookClassItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookClassItem.setValueMap( "计算机/网络", "小说/文学", "哲学/文化", "经济/管理", "政治/军事", "励志/成长", "儿童/育儿", "心理", "法律", "历史", "其他"); bookClassItem.setDefaultToFirstOption(true); SelectItem bookLanguageItem = new SelectItem("bookLanguage", "语言"); bookLanguageItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookLanguageItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookLanguageItem.setValueMap("中文", "英语", "法语", "德语", "日语", "俄语", "韩语"); bookLanguageItem.setDefaultToFirstOption(true); TextItem bookContributorItem = new TextItem("bookContributor", "贡献者"); bookContributorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookContributorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); TextItem bookPriceItem = new TextItem("bookPrice", "价格"); bookPriceItem.setTitleStyle("alex_bookdisplaywindow_form_text_title"); bookPriceItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookForm1.setFields( bookNameItem, bookAuthorItem, bookISBNItem, bookPublisherItem, bookPublishDateItem, bookClassItem, bookLanguageItem, bookContributorItem, bookPriceItem); // Form // 2----------------------------------------------------------------------------------------- bookForm2 = new DynamicForm(); bookForm2.setNumCols(3); bookForm2.setWidth(WINDOW_WIDTH); bookForm2.setColWidths("*", "*", "*"); bookForm2.setCellPadding(3); bookForm2.setCellBorder(1); bookForm2.setTitleOrientation(TitleOrientation.TOP); StaticTextItem bookTotalQuantityItemTitle = new StaticTextItem("bookTotalQuantityTitle", ""); bookTotalQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookTotalQuantityItemTitle.setShowTitle(false); StaticTextItem bookInStoreQuantityitemTitle = new StaticTextItem("bookInStoreQuantityTitle", ""); bookInStoreQuantityitemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookInStoreQuantityitemTitle.setShowTitle(false); StaticTextItem bookAvailableQuantityItemTitle = new StaticTextItem("bookAvailableQuantityTitle", ""); bookAvailableQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header"); bookAvailableQuantityItemTitle.setShowTitle(false); TextItem bookTotalQuantityItem = new TextItem("bookTotalQuantity", ""); bookTotalQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookTotalQuantityItem.setShowTitle(false); TextItem bookInStoreQuantityitem = new TextItem("bookInStoreQuantity", ""); bookInStoreQuantityitem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookInStoreQuantityitem.setShowTitle(false); TextItem bookAvailableQuantityItem = new TextItem("bookAvailableQuantity", ""); bookAvailableQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content"); bookAvailableQuantityItem.setShowTitle(false); bookForm2.setFields( bookTotalQuantityItemTitle, bookInStoreQuantityitemTitle, bookAvailableQuantityItemTitle, bookTotalQuantityItem, bookInStoreQuantityitem, bookAvailableQuantityItem); // Form // 3----------------------------------------------------------------------------------------- bookForm3 = new DynamicForm(); bookForm3.setWidth(WINDOW_WIDTH); bookForm3.setCellPadding(3); // bookForm2.setNumCols(2); bookForm3.setTitleOrientation(TitleOrientation.TOP); StaticTextItem bookIntroItemTitle = new StaticTextItem("bookIntroTitle", ""); bookIntroItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_text_title"); bookIntroItemTitle.setShowTitle(false); TextAreaItem bookIntroItem = new TextAreaItem("bookIntro", ""); bookIntroItem.setTextBoxStyle("alex_bookdisplaywindow_form_intro_content"); bookIntroItem.setShowTitle(false); bookIntroItem.setColSpan(2); bookIntroItem.setWidth("100%"); bookForm3.setFields(bookIntroItemTitle, bookIntroItem); // buttonLayout // -------------------------------------------------------------------------------------- buttonLayout = new HLayout(); newButton = new IButton("添加图书"); newButton.setIcon("actions/approve.png"); buttonLayout.setMembers(newButton); buttonLayout.setAlign(Alignment.RIGHT); hLayout.setMembers(imgVLayout, bookForm1); vLayout.setMembers(hLayout, bookForm2, bookForm3, buttonLayout); vLayout.setMembersMargin(20); bookForm1.setValue("bookPublishDate", new Date()); bookForm1.setValue("bookClass", "计算机/网络"); bookForm1.setValue("bookLanguage", "中文"); bookForm1.setValue("bookPrice", "0.00"); bookForm1.setValue("bookContributor", "公司采购"); bookForm2.setValue("bookTotalQuantity", "1"); bookForm2.setValue("bookInStoreQuantity", "1"); bookForm2.setValue("bookAvailableQuantity", "1"); bookForm2.setValue("bookTotalQuantityTitle", "总数"); bookForm2.setValue("bookInStoreQuantityTitle", "库中数量"); bookForm2.setValue("bookAvailableQuantityTitle", "可借数量"); bookForm3.setValue("bookIntroTitle", "简介:"); this.addItem(vLayout); bind(); }