/** * Get content for bookmark popup * * @return */ private HLayout getPopupContent() { HLayout hlayout = new HLayout(); hlayout.setWidth100(); hlayout.setHeight100(); DynamicForm form = new DynamicForm(); form.setHeight100(); form.setWidth(260); form.setTitleWidth(100); bookmarkTitle = new TextItem(); bookmarkTitle.setTitle("Title"); if (!view.getSettings().inSingleEndpointMode()) { includeEndpoint = new CheckboxItem(); includeEndpoint.setTitle("Include endpoint"); includeEndpoint.setLabelAsTitle(true); form.setItems(bookmarkTitle, includeEndpoint); } else { form.setItems(bookmarkTitle); } Button bookmarkButton = new Button("Bookmark"); bookmarkButton.setHeight100(); bookmarkButton.setWidth(60); bookmarkButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Bookmark bookmark = new Bookmark(); if (includeEndpoint != null && includeEndpoint.getValueAsBoolean()) { bookmark.setEndpoint(view.getSelectedTabSettings().getEndpoint()); } bookmark.setQuery(view.getSelectedTabSettings().getQueryString()); bookmark.setTitle(bookmarkTitle.getValueAsString()); window.clear(); setSrc(Imgs.get(Imgs.LOADING)); view.getRemoteService() .addBookmark( bookmark, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { setSrc(Imgs.get(Imgs.BOOKMARK_QUERY)); if (caught instanceof OpenIdException) { view.getElements().onError(caught.getMessage() + ". Logging out"); view.getOpenId().logOut(); } else { view.getElements().onError(caught); } } @Override public void onSuccess(Void result) { setSrc(Imgs.get(Imgs.BOOKMARK_QUERY)); } }); } }); hlayout.addMembers(form, Helper.getHSpacer(), bookmarkButton); return hlayout; }
@Inject public LoginPageView() { window = new Window(); window.setHeaderIcon(AppImages.SAVARA_ICON); window.setTitle("console"); window.setWidth(300); window.setHeight(150); window.setIsModal(true); window.setShowMinimizeButton(false); window.setShowCloseButton(false); window.centerInPage(); DynamicForm form = new DynamicForm(); form.setWidth(250); usernameItem = new TextItem(); usernameItem.setTitle("username"); passwordItem = new PasswordItem(); passwordItem.setTitle("password"); HLayout buttonLayout = new HLayout(); IButton loginBtn = new IButton("Login"); loginBtn.setWidth(60); loginBtn.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { String name = usernameItem.getValueAsString(); String password = passwordItem.getValueAsString(); presenter.login(name, password); } }); buttonLayout.addMember(loginBtn); buttonLayout.setAlign(Alignment.CENTER); form.setFields(new FormItem[] {usernameItem, passwordItem}); form.setPadding(10); window.addItem(form); window.addItem(buttonLayout); HLayout versionLayout = new HLayout(); Label versionNo = new Label(Build.VERSION); versionLayout.addMember(versionNo); versionLayout.setAlign(Alignment.RIGHT); window.addItem(versionLayout); }
public ListaVentas(final Sgc_capa_web mainWindow) { String PATH_IMG = "/sgc_capa_web/images/"; VLayout layout = new VLayout(10); layout.setBackgroundColor("#006633"); final ListGrid facturaGrid = new ListGrid(); facturaGrid.setWidth(500); facturaGrid.setHeight(224); facturaGrid.setShowAllRecords(true); facturaGrid.setAlternateRecordStyles(true); facturaGrid.setShowEdges(true); facturaGrid.setBorder("0px"); facturaGrid.setBodyStyleName("normal"); facturaGrid.setLeaveScrollbarGap(false); facturaGrid.setBackgroundColor("#99ffcc"); /*-Buscar ------------------------------*/ DynamicForm buscarFields = new DynamicForm(); // buscarFields.setBackgroundColor("#99ffcc"); buscarFields.setItemLayout(FormLayoutType.ABSOLUTE); final TextItem codigoText = new TextItem("codigo"); codigoText.setWrapTitle(false); codigoText.setLeft(10); codigoText.setWidth(43); codigoText.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if ("Enter".equals(event.getKeyName())) { /* buscar por el campo correspondiente */ if (codigoText.getValue() != null) { Factura factura = new Factura(); factura.setId(Integer.parseInt(codigoText.getValue().toString())); listar(facturaGrid, factura, "codigo"); } } } }); ButtonItem buscarButton = new ButtonItem("find", ""); buscarButton.setIcon("view.png"); buscarButton.setWidth(50); buscarButton.setLeft(443); buscarButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { /* buscar por el campo correspondiente */ Factura factura = new Factura(); if (codigoText.getValue() != null) factura.setId(Integer.parseInt(codigoText.getValue().toString())); /*if(nombreusuarioText.getValue() != null) cliente.setNombreusuario(nombreusuarioText.getValue().toString());*/ listar(facturaGrid, factura, "nombre"); } }); buscarFields.setFields(codigoText, buscarButton); /*--------------------------------------*/ ListGridField codigoField = new ListGridField("codigo", "Codigo"); ListGridField fechaField = new ListGridField("fecha", "Fecha"); ListGridField numeroField = new ListGridField("numero", "Numero"); ListGridField pendienteField = new ListGridField("pendiente", "Pendiente"); ListGridField saldoField = new ListGridField("saldo", "Saldo"); ListGridField editarField = new ListGridField("edit", "Editar"); ListGridField borrarField = new ListGridField("remove", "Borrar"); codigoField.setAlign(Alignment.CENTER); editarField.setAlign(Alignment.CENTER); borrarField.setAlign(Alignment.CENTER); editarField.setType(ListGridFieldType.IMAGE); borrarField.setType(ListGridFieldType.IMAGE); editarField.setImageURLPrefix(PATH_IMG); borrarField.setImageURLPrefix(PATH_IMG); editarField.setImageURLSuffix(".png"); borrarField.setImageURLSuffix(".png"); facturaGrid.addCellClickHandler( new CellClickHandler() { @Override public void onCellClick(CellClickEvent event) { ListGridRecord record = event.getRecord(); int col = event.getColNum(); if (col > 4) { Factura factura = new Factura(); factura.setId(record.getAttributeAsInt("codigo")); factura.setFecha(record.getAttributeAsDate("fecha")); factura.setNumero(Integer.parseInt(record.getAttribute("numero"))); factura.setPendiente(record.getAttribute("pendiente")); factura.setSaldo(Double.parseDouble(record.getAttribute("saldo"))); if (col == 5) { /* Editar */ new VentaDetalle(factura, mainWindow); } else { /* Borrar */ FacturaServiceAsync service = GWT.create(FacturaService.class); ServiceDefTarget serviceDef = (ServiceDefTarget) service; serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "facturaService"); try { service.eliminar( record.getAttributeAsInt("codigo"), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Window.alert( "Ocurrio un error y no se puedo eliminar (objeto referenciado)"); // " // + // caught.getClass().getName() + " " + caught.getMessage()) ; } @Override public void onSuccess(Void result) { new ListaVentas(mainWindow); } }); } catch (NumberFormatException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } } }); codigoField.setWidth(50); fechaField.setWidth(180); numeroField.setWidth(50); pendienteField.setWidth(50); saldoField.setWidth(50); facturaGrid.setFields( codigoField, fechaField, numeroField, pendienteField, saldoField, editarField, borrarField); facturaGrid.setCanResizeFields(true); ButtonItem button = new ButtonItem("add", "Agregar"); button.setStartRow(false); button.setWidth(80); button.setIcon("add.png"); button.setAlign(Alignment.CENTER); button.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { new VentaDetalle(mainWindow); } }); listar(facturaGrid, new Factura(), "nombre"); Label label = new Label(); label.setBackgroundColor("#99ffcc"); label.setHeight(30); label.setWidth(500); label.setPadding(10); label.setAlign(Alignment.CENTER); label.setValign(VerticalAlignment.CENTER); label.setWrap(false); label.setShowEdges(true); label.setContents("<div style='color:black;font-size:15'><b>Lista de Ventas</b></div>"); layout.addMember(label); layout.addMember(buscarFields); layout.addMember(facturaGrid); DynamicForm form = new DynamicForm(); // form.setBackgroundColor("#99ffcc"); form.setWidth(300); form.setItems(button); layout.addMember(form); mainWindow.showDialog(layout); }
private DynamicForm getConnectionForm() { connectionForm = new DynamicForm(); connectionForm.setNumCols(4); connectionForm.setWrapItemTitles(false); connectionForm.setColWidths("130", "450", "110"); connectionForm.setExtraSpace(15); connectionForm.setWidth(790); connectionForm.setPadding(5); connectionForm.setIsGroup(true); connectionForm.setGroupTitle(MSG.view_remoteAgentInstall_connInfo()); final int textFieldWidth = 440; TextItem host = new TextItem("host", MSG.common_title_host()); host.setRequired(true); host.setWidth(textFieldWidth); host.setPrompt(MSG.view_remoteAgentInstall_promptHost()); host.setHoverWidth(300); host.setEndRow(true); host.addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { hostAuthorized = false; // if the host changes, we need to make sure the user authorizes it if needed } }); TextItem port = new TextItem("port", MSG.common_title_port()); port.setRequired(false); port.setWidth(textFieldWidth); port.setPrompt(MSG.view_remoteAgentInstall_promptPort()); port.setHoverWidth(300); port.setEndRow(true); IntegerRangeValidator portValidator = new IntegerRangeValidator(); portValidator.setMin(1); portValidator.setMax(65535); port.setValidators(new IsIntegerValidator(), portValidator); TextItem username = new TextItem("username", MSG.common_title_user()); username.setRequired( false); // if not specified, the server will attempt to use the default ssh user defined in // system settings username.setWidth(textFieldWidth); username.setPrompt(MSG.view_remoteAgentInstall_promptUser()); username.setHoverWidth(300); username.setEndRow(true); PasswordItem password = new PasswordItem("password", MSG.common_title_password()); password.setRequired( false); // if not specified, the server will attempt to use the default ssh pw defined in // system settings password.setWidth(textFieldWidth); password.setPrompt(MSG.view_remoteAgentInstall_promptPassword()); password.setHoverWidth(300); password.setEndRow(true); password.setAttribute("autocomplete", "off"); rememberMeCheckbox = new CheckboxItem("rememberme", MSG.view_remoteAgentInstall_rememberMe()); rememberMeCheckbox.setRequired(false); rememberMeCheckbox.setPrompt(MSG.view_remoteAgentInstall_promptRememberMe()); rememberMeCheckbox.setHoverWidth(300); rememberMeCheckbox.setColSpan(2); rememberMeCheckbox.setEndRow(true); agentInstallPath = new TextItem("agentInstallPath", MSG.view_remoteAgentInstall_installPath()); agentInstallPath.setWidth(textFieldWidth); agentInstallPath.setPrompt(MSG.view_remoteAgentInstall_promptInstallPath()); agentInstallPath.setHoverWidth(300); agentInstallPath.setStartRow(true); agentInstallPath.setEndRow(false); agentInstallPath.setValidators( absPathValidator); // we will "turn this on" when needed - this is to ensure we create paths // properly and it doesn't go in places user isn't expecting findAgentInstallPathButton = new ButtonItem("findAgentInstallPathButton", MSG.view_remoteAgentInstall_buttonFindAgent()); findAgentInstallPathButton.setStartRow(false); findAgentInstallPathButton.setEndRow(true); if (findAgentInstallPathButton.getTitle().length() < 15) { // i18n may prolong the title findAgentInstallPathButton.setWidth(100); } findAgentInstallPathButton.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick( com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) { // we only want to validate host if (connectionForm.getValueAsString("host") == null || connectionForm.getValueAsString("host").trim().isEmpty()) { final HashMap<String, String> errors = new HashMap<String, String>(1); errors.put("host", CoreGUI.getSmartGwtMessages().validator_requiredField()); connectionForm.setErrors(errors, true); return; } new CheckSSHConnectionCallback() { @Override protected void doActualWork() { findAgentInstallPath(); } }.execute(); } }); createAgentStatusTextItem(); statusCheckButton = new ButtonItem("updateStatus", MSG.common_title_updateStatus()); statusCheckButton.setStartRow(false); statusCheckButton.setEndRow(true); if (findAgentInstallPathButton.getTitle().length() < 15) { // i18n may prolong the title statusCheckButton.setWidth(100); } statusCheckButton.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick( com.smartgwt.client.widgets.form.fields.events.ClickEvent clickEvent) { if (connectionForm.validate()) { new CheckSSHConnectionCallback() { @Override protected void doActualWork() { agentStatusCheck(); } }.execute(); } } }); if (initialAgentInstall != null) { host.setValue(initialAgentInstall.getSshHost()); if (initialAgentInstall.getSshPort() != null) { port.setValue(String.valueOf(initialAgentInstall.getSshPort())); } username.setValue(initialAgentInstall.getSshUsername()); password.setValue(initialAgentInstall.getSshPassword()); agentInstallPath.setValue(initialAgentInstall.getInstallLocation()); // if it was already saved, assume they want it to stay remembered // however, because the uninstall page is getting rid of the agent, we don't need or want to // remember the credentials anymore if (!this.showUninstallButton) { rememberMeCheckbox.setValue(initialAgentInstall.getSshPassword() != null); } } // disable some form elements if we don't want the user changing them - they should have been // filled in by who ever created this view if (this.showUninstallButton || this.showStartButton || this.showStopButton) { host.setDisabled(true); port.setDisabled(true); agentInstallPath.setDisabled(true); findAgentInstallPathButton.setDisabled(true); } if (this.showUninstallButton) { // don't show rememberMe checkbox - we're getting rid of this agent so there won't be a record // to store the creds connectionForm.setFields( host, port, username, password, agentInstallPath, findAgentInstallPathButton, agentStatusText, statusCheckButton); } else { connectionForm.setFields( host, port, username, password, rememberMeCheckbox, agentInstallPath, findAgentInstallPathButton, agentStatusText, statusCheckButton); } return connectionForm; }
/** * Creates this property editor. * * @param contents Contents view form. */ public MixinValueEditor(Contents contents) { super(TITLE); this.contents = contents; setWidth(WIDTH); setHeight(HEIGHT); Columns h1 = new Columns(Align.CENTER, Align.CENTER); h1.setHeight(15); Label l1 = new Label(); l1.setWidth(150); l1.setContents("Mixin Types"); Label l2 = new Label(); l2.setWidth(100); l2.setContents(""); Label l3 = new Label(); l3.setWidth(150); l3.setContents("Node's types"); h1.addMember(l1); h1.addMember(l2); h1.addMember(l3); addMember(h1); Columns layout = new Columns(Align.CENTER, Align.CENTER); layout.setWidth100(); mixTypes.setMultiple(true); mixTypes.setMultipleAppearance(MultipleAppearance.GRID); mixTypes.setWidth(150); mixTypes.setHeight(200); selectedTypes.setMultiple(true); selectedTypes.setMultipleAppearance(MultipleAppearance.GRID); selectedTypes.setWidth(150); selectedTypes.setHeight(200); DynamicForm f1 = new DynamicForm(); f1.setItems(mixTypes); f1.setWidth(150); f1.setHeight(200); DynamicForm f2 = new DynamicForm(); f2.setItems(selectedTypes); f2.setWidth(150); f2.setHeight(200); VLayout buttons = new VLayout(); buttons.setLayoutAlign(Alignment.CENTER); buttons.setDefaultLayoutAlign(Alignment.CENTER); buttons.setAlign(Alignment.CENTER); buttons.setLayoutAlign(VerticalAlignment.CENTER); buttons.setWidth(50); layout.addMember(f1); layout.addMember(buttons); layout.addMember(f2); Button b1 = new Button(">>"); b1.setWidth(30); b1.addClickHandler( new ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { allTypes = remove(allTypes, mixTypes.getValueAsString()); nodeTypes = add(nodeTypes, mixTypes.getValueAsString()); updateLists(); } }); Button b2 = new Button("<<"); b2.setWidth(30); b2.addClickHandler( new ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { nodeTypes = remove(nodeTypes, selectedTypes.getValueAsString()); allTypes = add(allTypes, selectedTypes.getValueAsString()); updateLists(); } }); buttons.addMember(b1); buttons.addMember(b2); addMember(layout); Columns h3 = new Columns(Align.RIGHT, Align.CENTER); h3.setHeight(50); Button okButton = new Button("OK"); okButton.addClickHandler( new ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { onConfirm(null); hide(); } }); Button cancelButton = new Button("Cancel"); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { hide(); } }); h3.addMember(okButton); h3.addMember(cancelButton); addMember(h3); }
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(); }
public UserDetailTabPane(DataSource userDS, final ItemListGrid userListGrid) { this.userListGrid = userListGrid; setStyleName("defaultBorder"); userViewer = new DetailViewer(); userViewer.setDataSource(userDS); userViewer.setWidth100(); userViewer.setMargin(25); userViewer.setEmptyMessage("Select an user to view its details"); editorLabel = new Label(); editorLabel.setWidth100(); editorLabel.setHeight100(); editorLabel.setAlign(Alignment.CENTER); editorLabel.setContents("Select an user to edit, or insert a new user into"); insertLabel = new Label(); insertLabel.setWidth100(); insertLabel.setHeight100(); insertLabel.setAlign(Alignment.CENTER); insertLabel.setContents("Insert a new user into"); // update form editorForm = new DynamicForm(); editorForm.setWidth(650); editorForm.setMargin(25); editorForm.setNumCols(4); editorForm.setCellPadding(5); editorForm.setAutoFocus(false); editorForm.setDataSource(userDS); editorForm.setUseAllDataSourceFields(true); userId = new StaticTextItem("userId", "User ID"); userName = new TextItem("userName", "User Name"); password = new PasswordItem("password", "Password"); enabled = new CheckboxItem("enabled", "Enabled"); userName.setRequired(true); password.setRequired(true); ButtonItem saveButton = new ButtonItem("saveUser", "Update user info."); saveButton.setAlign(Alignment.CENTER); saveButton.setWidth(100); saveButton.setColSpan(4); saveButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { // editorForm.saveData(); if (userId.getValue() == null) { return; } if (!editorForm.validate(false)) { return; } User user = new User(); user.setUserId((String) userId.getValue()); user.setUserName(userName.getValueAsString()); user.setPassword(password.getValueAsString()); user.setEnabled(enabled.getValueAsBoolean()); userService.updateUser( user, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { SC.say("Error", "Server side error occured. Contact your administrator."); } public void onSuccess(Void noAnswer) { SC.say("Updated", "User info. is updated."); userListGrid.invalidateCache(); } }); } }); editorForm.setFields(userId, userName, password, enabled, saveButton); editorForm.setColWidths(100, 200, 100, 200); // insert form insertForm = new DynamicForm(); insertForm.setWidth(650); insertForm.setMargin(25); insertForm.setNumCols(4); insertForm.setCellPadding(5); insertForm.setAutoFocus(false); insertForm.setDataSource(userDS); insertForm.setUseAllDataSourceFields(true); userId4add = new TextItem("userId", "User ID"); userName4add = new TextItem("userName", "User Name"); password4add = new PasswordItem("password", "Password"); enabled4add = new CheckboxItem("enabled", "Enabled"); enabled4add.setValue(true); userId4add.setRequired(true); userName4add.setRequired(true); password4add.setRequired(true); ButtonItem addButton = new ButtonItem("addUser", "Add user info."); addButton.setAlign(Alignment.CENTER); addButton.setWidth(100); addButton.setColSpan(4); addButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { if (!insertForm.validate(false)) { return; } User user = new User(); user.setUserId(userId4add.getValueAsString()); user.setUserName(userName4add.getValueAsString()); user.setPassword(password4add.getValueAsString()); user.setEnabled(enabled4add.getValueAsBoolean()); userService.addUser( user, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { SC.say("Error", "Server side error occured. Contact your administrator."); } public void onSuccess(Void noAnswer) { SC.say("Added", "User info. is added."); userListGrid.invalidateCache(); insertForm.clearValues(); } }); } }); insertForm.setFields(userId4add, userName4add, password4add, enabled4add, addButton); insertForm.setColWidths(100, 200, 100, 200); // tab Tab viewTab = new Tab("View"); viewTab.setIcon("silk/application_form.png"); viewTab.setWidth(70); viewTab.setPane(userViewer); Tab editTab = new Tab("Edit"); editTab.setIcon("demoApp/icon_edit.png"); editTab.setWidth(70); editTab.setPane(editorForm); Tab insertTab = new Tab("Add"); insertTab.setIcon("demoApp/icon_add.png"); insertTab.setWidth(70); insertTab.setPane(insertForm); setTabs(viewTab, editTab, insertTab); addTabSelectedHandler( new TabSelectedHandler() { public void onTabSelected(TabSelectedEvent event) { updateDetails(); } }); }
public void onModuleLoad() { topTabSet = new TabSet(); topTabSet.setTabBarPosition(Side.TOP); topTabSet.setWidth(1024); topTabSet.setHeight(768); topTabSet.setTabBarThickness(50); Tab tTab1 = new Tab("Menu", "assets/mainMenu.png"); Img tImg1 = new Img("pieces/48/pawn_blue.png", 96, 96); topTabSet.addTab(tTab1); Tab lTab1 = new Tab(); lTab1.setIcon("pieces/16/pawn_blue.png", 16); Img lImg1 = new Img("pieces/48/pawn_blue.png", 48, 48); lTab1.setPane(lImg1); HLayout buttons = new HLayout(); buttons.setMembersMargin(15); VLayout vLayout = new VLayout(); vLayout.setMembersMargin(15); vLayout.addMember(topTabSet); vLayout.addMember(buttons); // vLayout.addMember(leftTabSet); vLayout.setHeight("*"); vLayout.draw(); final HLayout hLayout = new HLayout(); hLayout.setWidth100(); hLayout.setHeight100(); hLayout.setLayoutMargin(20); // tree menu TreeGrid tree = new TreeGrid(); tree.setShowConnectors(true); tree.setShowResizeBar(true); Tree dataTree = new Tree(); dataTree.setModelType(TreeModelType.CHILDREN); dataTree.setRoot( new TreeNode( "root", new TreeNode("Aluno"), new TreeNode("Funcionario"), new TreeNode("Contato"), new TreeNode("Veiculo"), new TreeNode("Disciplina"))); tree.setData(dataTree); TreeGridField fieldTree = new TreeGridField("Navegacao"); fieldTree.setCellFormatter( new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { return record.getAttribute("name"); } }); tree.setFields(fieldTree); // layout esquerda SectionStack leftSideLayout = new SectionStack(); leftSideLayout.setWidth(200); leftSideLayout.setShowResizeBar(true); leftSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE); leftSideLayout.setAnimateSections(true); leftSideLayout.setMembers(tree); // UIs final AlunoUI alunoUI = new AlunoUI(); final FuncionarioUI funcionarioUI = new FuncionarioUI(); final ContatoUI contatoUI = new ContatoUI(); final VeiculoUI veiculoUI = new VeiculoUI(); final DisciplinaUI disciplinaUI = new DisciplinaUI(); // layout direita final SectionStack rightSideLayout = new SectionStack(); rightSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE); rightSideLayout.setAnimateSections(true); grid = alunoUI.getGrid(); formBotoes = alunoUI.getFormBotoes(); menuItens = new DynamicForm(); menuItens.setWidth(100); menuItens.setAlign(Alignment.RIGHT); ButtonItem aluno = new ButtonItem("Aluno"); aluno.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomAluno("Aluno"); } }); ButtonItem disc = new ButtonItem("Disciplina"); disc.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomDisciplina("Disciplina"); } }); ButtonItem curso = new ButtonItem("Curso"); curso.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomCurso("Curso"); } }); ButtonItem matric = new ButtonItem("Matricula"); matric.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { newTabCustomMatricula("Matricula"); } }); menuItens.setFields(aluno, disc, curso, matric); rightSideLayout.setMembers(menuItens); rightSideLayout.setWidth(200); // seleciona tree tree.addNodeClickHandler( new NodeClickHandler() { public void onNodeClick(NodeClickEvent event) { String node = event.getNode().getAttribute("name"); if (node.equals("Aluno")) { // rightSideLayout.removeMembers(formBotoes,grid); // Tab tab = new Tab(node); newTabCustomAluno(node); } else { if (node.equals("Disciplina")) { newTabCustomDisciplina(node); } else { if (node.equals("Curso")) { // newTabCustom(node); } else { if (node.equals("Matricula")) { // newTabCustom(node); } else { if (node.equals("Disciplina")) { rightSideLayout.removeMembers(formBotoes, grid); grid = disciplinaUI.getGrid(); formBotoes = disciplinaUI.getFormBotoes(); rightSideLayout.setMembers(formBotoes, grid); } } } } } } }); // hLayout hLayout.addMember(leftSideLayout); hLayout.addMember(rightSideLayout); hLayout.draw(); tTab1.setPane(hLayout); }
public TabBillingComps() { try { setTitle(CallCenterBK.constants.billingComps()); setCanClose(true); billingCompsDS = DataSource.get("BillingCompsDS"); mainLayout = new VLayout(5); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.setMargin(5); searchForm = new DynamicForm(); searchForm.setAutoFocus(true); searchForm.setWidth(830); searchForm.setTitleWidth(250); searchForm.setNumCols(4); mainLayout.addMember(searchForm); billingCompNameItem = new TextItem(); billingCompNameItem.setTitle(CallCenterBK.constants.companyName()); billingCompNameItem.setWidth(250); billingCompNameItem.setName("billingCompNameItem"); phoneIndexItem = new TextItem(); phoneIndexItem.setTitle(CallCenterBK.constants.index()); phoneIndexItem.setWidth(250); phoneIndexItem.setName("phoneIndexItem"); hasCalcItem = new SelectItem(); hasCalcItem.setTitle(CallCenterBK.constants.hasCalculation()); hasCalcItem.setWidth(250); hasCalcItem.setName("hasCalcItem"); hasCalcItem.setDefaultToFirstOption(true); hasCalcItem.setValueMap(ClientMapUtil.getInstance().getHasCalculations()); operatorItem = new SelectItem(); operatorItem.setTitle(CallCenterBK.constants.operator()); operatorItem.setWidth(200); operatorItem.setName("operator_src"); operatorItem.setDefaultToFirstOption(true); ClientUtils.fillCombo( operatorItem, "OperatorsDS", "searchOperators", "operator_src", "operator_src_descr"); searchForm.setFields(billingCompNameItem, phoneIndexItem, hasCalcItem, operatorItem); HLayout buttonLayout = new HLayout(5); buttonLayout.setWidth(830); buttonLayout.setHeight(30); buttonLayout.setAlign(Alignment.RIGHT); clearButton = new IButton(); clearButton.setTitle(CallCenterBK.constants.clear()); findButton = new IButton(); findButton.setTitle(CallCenterBK.constants.find()); buttonLayout.setMembers(findButton, clearButton); mainLayout.addMember(buttonLayout); ToolStrip toolStrip = new ToolStrip(); toolStrip.setWidth100(); toolStrip.setPadding(5); mainLayout.addMember(toolStrip); addBtn = new ToolStripButton(CallCenterBK.constants.add(), "addIcon.png"); addBtn.setLayoutAlign(Alignment.LEFT); addBtn.setWidth(50); toolStrip.addButton(addBtn); editBtn = new ToolStripButton(CallCenterBK.constants.modify(), "editIcon.png"); editBtn.setLayoutAlign(Alignment.LEFT); editBtn.setWidth(50); toolStrip.addButton(editBtn); deleteBtn = new ToolStripButton(CallCenterBK.constants.disable(), "deleteIcon.png"); deleteBtn.setLayoutAlign(Alignment.LEFT); deleteBtn.setWidth(50); toolStrip.addButton(deleteBtn); toolStrip.addSeparator(); billingCompBillByDayBtn = new ToolStripButton(CallCenterBK.constants.telCombBillByDay(), "billing.png"); billingCompBillByDayBtn.setLayoutAlign(Alignment.LEFT); billingCompBillByDayBtn.setWidth(50); toolStrip.addButton(billingCompBillByDayBtn); billingCompBillByMonthBtn = new ToolStripButton(CallCenterBK.constants.telCombBillByMonth(), "billing.png"); billingCompBillByMonthBtn.setLayoutAlign(Alignment.LEFT); billingCompBillByMonthBtn.setWidth(50); toolStrip.addButton(billingCompBillByMonthBtn); billingCompsGrid = new ListGrid(); billingCompsGrid.setWidth100(); billingCompsGrid.setHeight100(); billingCompsGrid.setAlternateRecordStyles(true); billingCompsGrid.setDataSource(billingCompsDS); billingCompsGrid.setAutoFetchData(false); billingCompsGrid.setShowFilterEditor(false); billingCompsGrid.setCanEdit(false); billingCompsGrid.setCanRemoveRecords(false); billingCompsGrid.setFetchOperation("searchAllBillingComps"); billingCompsGrid.setShowRowNumbers(true); billingCompsGrid.setCanHover(true); billingCompsGrid.setShowHover(true); billingCompsGrid.setShowHoverComponents(true); billingCompsGrid.setWrapCells(true); billingCompsGrid.setFixedRecordHeights(false); billingCompsGrid.setCanDragSelectText(true); ListGridField billing_company_name = new ListGridField("billing_company_name", CallCenterBK.constants.companyName()); ListGridField our_percent = new ListGridField("our_percent", CallCenterBK.constants.ourPercent(), 150); ListGridField has_calculation_descr = new ListGridField("has_calculation_descr", CallCenterBK.constants.hasCalculation(), 150); ListGridField call_price = new ListGridField("call_price", CallCenterBK.constants.callPrice(), 150); our_percent.setAlign(Alignment.CENTER); has_calculation_descr.setAlign(Alignment.CENTER); call_price.setAlign(Alignment.CENTER); billingCompsGrid.setFields( billing_company_name, our_percent, has_calculation_descr, call_price); mainLayout.addMember(billingCompsGrid); findButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { search(); } }); billingCompNameItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); phoneIndexItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); clearButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { billingCompNameItem.clearValue(); } }); addBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { DlgAddEditBillingComps dlgAddEditBillingComp = new DlgAddEditBillingComps(billingCompsGrid, null); dlgAddEditBillingComp.show(); } }); editBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenterBK.constants.pleaseSelrecord()); return; } DlgAddEditBillingComps dlgAddEditBillingComp = new DlgAddEditBillingComps(billingCompsGrid, listGridRecord); dlgAddEditBillingComp.show(); } }); deleteBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenterBK.constants.pleaseSelrecord()); return; } SC.ask( CallCenterBK.constants.askForDisable(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { delete(listGridRecord); } } }); } }); billingCompsGrid.addRecordDoubleClickHandler( new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord(); DlgAddEditBillingComps dlgAddEditBillingComp = new DlgAddEditBillingComps(billingCompsGrid, listGridRecord); dlgAddEditBillingComp.show(); } }); billingCompBillByDayBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenterBK.constants.pleaseSelrecord()); return; } Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id"); getBillingCompBillByDay(billing_company_id); } }); billingCompBillByMonthBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenterBK.constants.pleaseSelrecord()); return; } Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id"); getBillingCompBillByMonth(billing_company_id); } }); setPane(mainLayout); } catch (Exception e) { SC.say(e.toString()); } }
/** * Generate the form layout. * * @return */ private Layout createEditForm() { /** The layout panel we're generating */ Layout resPanel = new VLayout(); editForm = new DynamicForm(); editForm.setWidth(400); FormItem[] fieldList = new FormItem[] {}; /* * Generate a FormField for each field */ for (String field : getFieldOrder()) { UIFormFieldValue formField = dataMap.get(field); if (formField != null) { FormItem formFieldItem = createFormField(field, formField); if (formFieldItem != null) fieldList[fieldList.length] = formFieldItem; else log("!!formfield " + field + " creation gave back null!"); } else log("!!formfield definition for " + field + " was null!"); } editForm.setFields(fieldList); resPanel.addMember(editForm); final Button saveButton = new Button("Save " + getFormLabel()); saveButton.setAutoFit(true); saveButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { save( new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { switchToView(true); } @Override public void onFailure(Throwable caught) { SC.warn("Caught exception: " + caught.getMessage()); } }); } }); final Button cancelButton = new Button("cancel"); cancelButton.setAutoFit(true); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { switchToView(false); } }); HLayout buttons = new HLayout(); buttons.addMember(saveButton); buttons.addMember(cancelButton); buttons.setHeight("5em"); buttons.setMembersMargin(5); resPanel.addMember(buttons); return resPanel; }
public ReportReceiveLayout_2(final User currentUser) { setWidth(950); setHeight100(); HLayout searchLayout = new HLayout(); searchLayout.setHeight(20); final DynamicForm searchForm = new DynamicForm(); searchForm.setWidth(450); searchForm.setHeight(30); searchForm.setMargin(5); searchForm.setNumCols(4); searchForm.setCellPadding(2); searchForm.setAutoFocus(true); searchForm.setSelectOnFocus(true); searchForm.setIsGroup(true); searchForm.setDataSource(TransferDS.getInstance()); searchForm.setUseAllDataSourceFields(false); searchForm.setGroupTitle("ตัวกรอง"); final SelectItem statusSelected = new SelectItem("status", "สถานะ"); statusSelected.setWrapTitle(false); // statusSelected.setValueMap("รอแก้ไข", "รออนุมัติ", "อนุมัติแล้ว"); statusSelected.setValueMap(TransferStatus.getValueMap()); statusSelected.setAllowEmptyValue(true); statusSelected.setEmptyDisplayValue("ทั้งหมด"); statusSelected.setOperator(OperatorId.EQUALS); final TextItem jidText = new TextItem("plan_id", "รหัสแผนการผลิต"); jidText.setWrapTitle(false); jidText.setOperator(OperatorId.REGEXP); // final TextItem smidText = new TextItem("smid", "รหัสช่าง"); // smidText.setWrapTitle(false); // smidText.setOperator(OperatorId.REGEXP); // final DynamicForm dateForm = new DynamicForm(); // dateForm.setWidth(300); // dateForm.setHeight(30); // dateForm.setMargin(5); // dateForm.setNumCols(2); // dateForm.setCellPadding(2); // dateForm.setSelectOnFocus(true); // dateForm.setIsGroup(true); // dateForm.setGroupTitle("วันที่ขอโอนสินค้า"); DateRange dateRange = new DateRange(); dateRange.setRelativeStartDate(new RelativeDate("-1w")); dateRange.setRelativeEndDate(RelativeDate.TODAY); final DateItem from = new DateItem("create_from", "ตั้งแต่"); final DateItem to = new DateItem("create_to", "ถึง"); from.setDefaultChooserDate(dateRange.getStartDate()); from.setDefaultValue(dateRange.getStartDate()); from.setUseTextField(true); to.setDefaultChooserDate(dateRange.getEndDate()); to.setDefaultValue(dateRange.getEndDate()); to.setUseTextField(true); searchForm.setItems(jidText, statusSelected, from, to); // searchForm.setItems(planText, jidText); // dateForm.setItems(from, to); final ListGrid orderListGrid = new ListGrid(); orderListGrid.setAutoFetchData(true); orderListGrid.setCanMultiSort(true); orderListGrid.setShowRowNumbers(true); orderListGrid.setShowGridSummary(true); AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.AND, new Criterion[] { // new Criterion("status", OperatorId.NOT_EQUAL, "3_to_next_process"), // new Criterion("created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(), // to.getValueAsDate()) new Criterion( "created_date", OperatorId.BETWEEN_INCLUSIVE, dateRange.getStartDate(), dateRange.getEndDate()) }); orderListGrid.setCriteria(criteria); orderListGrid.setDataSource(TransferDS.getInstance()); orderListGrid.setInitialSort( new SortSpecifier[] { new SortSpecifier("status", SortDirection.DESCENDING), new SortSpecifier("created_date", SortDirection.DESCENDING) }); orderListGrid.setUseAllDataSourceFields(false); orderListGrid.setSelectionType(SelectionStyle.NONE); ListGridField transfer_id = new ListGridField("transfer_id", 100); transfer_id.setSummaryFunction( new SummaryFunction() { public Object getSummaryValue(Record[] records, ListGridField field) { return records.length + " รายการ"; } }); transfer_id.setShowGridSummary(true); ListGridField status = new ListGridField("status", 120); ListGridField plan_id = new ListGridField("plan_id", 100); ListGridField transfer_by = new ListGridField("transfer_by"); ListGridField transfer_date = new ListGridField("transfer_date", 150); ListGridField total_weight = new ListGridField("total_sent_weight", 120); total_weight.setCellFormatter(FieldFormatter.getNumberFormat()); total_weight.setAlign(Alignment.RIGHT); total_weight.setSummaryFunction(SummaryFunctionType.SUM); total_weight.setShowGridSummary(true); ListGridField total_amount = new ListGridField("total_sent_amount", 120); total_amount.setCellFormatter(FieldFormatter.getNumberFormat()); total_amount.setAlign(Alignment.RIGHT); total_amount.setSummaryFunction(SummaryFunctionType.SUM); total_amount.setShowGridSummary(true); orderListGrid.setFields( transfer_date, transfer_id, status, plan_id, transfer_by, total_weight, total_amount); // orderListGrid.hideField("status"); HLayout buttonLayout = new HLayout(); buttonLayout.setMargin(10); buttonLayout.setMembersMargin(5); buttonLayout.setHeight(30); IButton searchButton = new IButton("ค้นหาคำขอโอนสินค้า"); searchButton.setIcon("icons/16/reports-icon.png"); searchButton.setWidth(170); searchButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Criterion search = new Criterion(); search.addCriteria(searchForm.getValuesAsCriteria()); AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.AND, new Criterion[] { new Criterion( "created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(), to.getValueAsDate()), search }); reportDate.setContents( "ตั้งแต่วันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate()) + " ถึงวันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate())); orderListGrid.fetchData(criteria); orderListGrid.deselectAllRecords(); } }); IButton listAllButton = new IButton("ล้างรายการค้นหา"); listAllButton.setIcon("[SKIN]actions/refresh.png"); listAllButton.setWidth(150); listAllButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.AND, new Criterion[] { new Criterion( "created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(), to.getValueAsDate()) }); searchForm.reset(); reportDate.setContents( "ตั้งแต่วันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate()) + " ถึงวันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate())); orderListGrid.fetchData(criteria); orderListGrid.deselectAllRecords(); } }); IButton printButton = new IButton("พิมพ์รายงาน"); printButton.setIcon("icons/16/print.png"); printButton.setWidth(120); buttonLayout.addMembers(searchButton, listAllButton, printButton); searchLayout.addMembers(searchForm); // reviseLayout. addMember(searchLayout); // reviseLayout. addMember(buttonLayout); final VLayout gridLayout = new VLayout(); gridLayout.setWidth100(); gridLayout.setHeight(500); Label text = new Label(); text.setContents("รายงานการโอนสินค้าเข้าคลังสินค้า"); text.setAlign(Alignment.CENTER); text.setHeight(10); text.setStyleName("printTitle"); reportDate = new Label(); reportDate.setContents( "ตั้งแต่วันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(from.getValueAsDate()) + " ถึงวันที่ " + DateTimeFormat.getFormat("d-M-yyyy").format(to.getValueAsDate())); reportDate.setAlign(Alignment.CENTER); reportDate.setHeight(10); reportDate.setStyleName("printDetails"); gridLayout.addMember(text); gridLayout.addMember(reportDate); gridLayout.addMember(orderListGrid); addMember(gridLayout); printButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Canvas.showPrintPreview(gridLayout); } }); }
public DeliveryOrderLayout(final User currentUser) { // Tab reviseTab = new Tab("ข้อมูลใบแจ้งหนี้", "icons/16/search-good-icon.png"); // VLayout reviseLayout = new VLayout(); // reviseLayout. setWidth(750); // reviseLayout. setHeight100(); HLayout searchLayout = new HLayout(); searchLayout.setHeight(20); final DynamicForm searchForm = new DynamicForm(); searchForm.setWidth(450); searchForm.setHeight(30); searchForm.setMargin(5); searchForm.setNumCols(4); searchForm.setCellPadding(2); searchForm.setAutoFocus(true); searchForm.setSelectOnFocus(true); searchForm.setIsGroup(true); searchForm.setDataSource(DeliveryDS.getInstance()); searchForm.setUseAllDataSourceFields(false); searchForm.setGroupTitle("ค้นหารายการนำส่งสินค้า"); final TextItem deliveryText = new TextItem("delivery_id", "รหัสรายการนำส่งสินค้า"); deliveryText.setWrapTitle(false); deliveryText.setOperator(OperatorId.REGEXP); final TextItem saleText = new TextItem("sale_id", "รหัสรายการขาย"); saleText.setWrapTitle(false); saleText.setOperator(OperatorId.REGEXP); final SelectItem statusSelected = new SelectItem("issued_status", "สถานะ"); statusSelected.setWrapTitle(false); // statusSelected.setValueMap("กำลังนำส่ง", "นำส่งแล้ว"); statusSelected.setValueMap(DeliveryStatus.getIssueValueMap()); statusSelected.setAllowEmptyValue(true); statusSelected.setEmptyDisplayValue("ทั้งหมด"); statusSelected.setOperator(OperatorId.EQUALS); final TextItem cidText = new TextItem("cid", "รหัสลูกค้า"); cidText.setWrapTitle(false); cidText.setOperator(OperatorId.REGEXP); final DynamicForm dateForm = new DynamicForm(); dateForm.setWidth(300); dateForm.setHeight(30); dateForm.setMargin(5); dateForm.setNumCols(2); dateForm.setCellPadding(2); dateForm.setSelectOnFocus(true); dateForm.setIsGroup(true); // dateForm.setGroupTitle("วันที่นำส่งสินค้า"); dateForm.setGroupTitle("วันที่ออกใบนำส่งสินค้า"); DateRange dateRange = new DateRange(); dateRange.setRelativeStartDate(new RelativeDate("-7d")); dateRange.setRelativeEndDate(RelativeDate.TODAY); // final DateItem from = new DateItem("delivery_from" , "ตั้งแต่"); // final DateItem to = new DateItem("delivery_to" , "ถึง"); final DateItem from = new DateItem("created_from", "ตั้งแต่"); final DateItem to = new DateItem("created_to", "ถึง"); from.setDefaultChooserDate(dateRange.getStartDate()); from.setDefaultValue(dateRange.getStartDate()); from.setUseTextField(true); to.setDefaultChooserDate(dateRange.getEndDate()); to.setDefaultValue(dateRange.getEndDate()); to.setUseTextField(true); FromToValidate.addValidator(from, to); searchForm.setItems(deliveryText, statusSelected, saleText, cidText); // searchForm.setItems(Text, cidText, cnameText); dateForm.setItems(from, to); // final ListGrid deliveryListGrid = new EditorListGrid(new RequestViewWindow(), currentUser); final ListGrid deliveryListGrid = new ListGrid(); deliveryListGrid.setAutoFetchData(true); deliveryListGrid.setCanMultiSort(true); // deliveryListGrid.setCriteria(new Criterion("status", OperatorId.NOT_EQUAL, "ยกเลิก")); deliveryListGrid.setDataSource(DeliveryDS.getInstance()); deliveryListGrid.setInitialSort( new SortSpecifier[] { new SortSpecifier("issued_status", SortDirection.ASCENDING), new SortSpecifier("delivery", SortDirection.DESCENDING) }); deliveryListGrid.setUseAllDataSourceFields(false); deliveryListGrid.setGroupByField("issued_status"); deliveryListGrid.setGroupStartOpen(GroupStartOpen.ALL); ListGridField delivery_id = new ListGridField("delivery_id", 120); ListGridField sale_id = new ListGridField("sale_id", 100); // ListGridField quote_id = new ListGridField("quote_id" , 90); ListGridField cus_name = new ListGridField("cus_name", 180); ListGridField status = new ListGridField("issued_status"); // LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); // valueMap.put("3_approved", "approved"); // status.setValueMap(valueMap); ListGridField total_amount = new ListGridField("total_amount", 120); total_amount.setCellFormatter(FieldFormatter.getIntegerFormat()); total_amount.setAlign(Alignment.RIGHT); // ListGridField netInclusive = new ListGridField("netInclusive", 125); // netInclusive.setCellFormatter(FieldFormatter.getPriceFormat()); // netInclusive.setAlign(Alignment.RIGHT); ListGridField delivery_date = new ListGridField("delivery", 120); // created_date.setType(ListGridFieldType.DATE); // created_date.setCellFormatter(new CellFormatter() { // // @Override // public String format(Object arg0, ListGridRecord arg1, int arg2, int arg3) { // DateTimeFormat fmt = DateTimeFormat.getFormat("MM/dd/yyyy"); // return fmt.format(arg1.getAttributeAsDate("created_date")); // } // }); // ListGridField iconField = new ListGridField("viewDeliveryField", "เรียกดูรายการ", 80); deliveryListGrid.setFields(status, delivery_id, sale_id, cus_name, total_amount, delivery_date); searchLayout.addMembers(searchForm, dateForm); // reviseLayout. addMember(searchLayout); HLayout buttonLayout = new HLayout(); buttonLayout.setMargin(10); buttonLayout.setMembersMargin(5); buttonLayout.setHeight(30); IButton searchButton = new IButton("ค้นหารายการนำส่งสินค้า"); searchButton.setIcon("icons/16/icon_view.png"); searchButton.setWidth(150); searchButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { Criterion search = new Criterion(); search.addCriteria(searchForm.getValuesAsCriteria()); AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.AND, new Criterion[] { // new Criterion("delivery", OperatorId.BETWEEN_INCLUSIVE, // from.getValueAsDate(), to.getValueAsDate()), new Criterion( "created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(), to.getValueAsDate()), search }); deliveryListGrid.fetchData(criteria); deliveryListGrid.deselectAllRecords(); } }); IButton listAllButton = new IButton("แสดงรายการทั้งหมด"); listAllButton.setIcon("[SKIN]actions/refresh.png"); listAllButton.setWidth(150); listAllButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.AND, new Criterion[] { // new Criterion("delivery", OperatorId.BETWEEN_INCLUSIVE, // from.getValueAsDate(), to.getValueAsDate()) new Criterion( "created_date", OperatorId.BETWEEN_INCLUSIVE, from.getValueAsDate(), to.getValueAsDate()) }); searchForm.reset(); deliveryListGrid.fetchData(criteria); deliveryListGrid.deselectAllRecords(); } }); HLayout empty = new HLayout(); empty.setWidth("*"); IButton viewButton = new IButton("เรียกดูรายการ"); viewButton.setIcon("icons/16/icon_view.png"); viewButton.setWidth(150); viewButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { ListGridRecord selected = deliveryListGrid.getSelectedRecord(); if (selected == null) { SC.warn("กรุณาเลือกรายการเบิกสินค้า"); return; } RequestViewWindow deliveryWindow = new RequestViewWindow(); deliveryWindow.show(selected, false, currentUser, 1); } }); IButton receiveOrderButton = new IButton("เบิกจ่ายสินค้า"); receiveOrderButton.setIcon("icons/16/actions-receive-icon.png"); receiveOrderButton.setWidth(100); receiveOrderButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { ListGridRecord selected = deliveryListGrid.getSelectedRecord(); if (selected == null) { SC.warn("กรุณาเลือกรายการเบิกสินค้า"); return; } if (selected .getAttributeAsString("issued_status") .equalsIgnoreCase("0_product_request")) { RequestViewWindow deliveryWindow = new RequestViewWindow(); deliveryWindow.show(selected, true, currentUser, 2); } else { SC.warn("จ่ายสินค้าแล้ว"); } } }); buttonLayout.addMembers(searchButton, listAllButton, empty, viewButton, receiveOrderButton); // buttonLayout.addMembers(searchButton, listAllButton); // reviseLayout. addMember(buttonLayout); VLayout gridLayout = new VLayout(); gridLayout.setWidth100(); gridLayout.setHeight(355); gridLayout.addMember(deliveryListGrid); // reviseLayout. addMember(gridLayout); // reviseTab.setPane(reviseLayout); // return reviseTab; }
/** Instantiates a new home view. */ @Inject public HomeView(LangConstants lang) { this.lang = lang; layout = new VStack(); layout.setHeight100(); layout.setPadding(15); HTMLFlow html1 = new HTMLFlow(); html1.setContents(lang.introduction() + HtmlCode.title(lang.availCoopSys(), 2)); html1.setExtraSpace(15); status = new HTMLFlow(getStatusString()); status.setExtraSpace(35); checkButton = new IButton(lang.checkAvailability()); checkButton.setAutoFit(true); checkButton.setExtraSpace(60); HTMLFlow html2 = new HTMLFlow(); html2.setContents(HtmlCode.title(lang.openDigitalObject(), 2)); html2.setExtraSpace(30); DataSource dataSource = new DataSource(); dataSource.setID("regularExpression"); RegExpValidator regExpValidator = new RegExpValidator(); regExpValidator.setExpression( "^.*:([\\da-fA-F]){8}-([\\da-fA-F]){4}-([\\da-fA-F]){4}-([\\da-fA-F]){4}-([\\da-fA-F]){12}$"); uuidField = new TextItem(); uuidField.setTitle("PID"); uuidField.setWidth(255); uuidField.setHint(HtmlCode.nobr(lang.withoutPrefix())); uuidField.setValidators(regExpValidator); form = new DynamicForm(); form.setWidth(300); form.setFields(uuidField); open = new IButton(); open.setTitle(lang.open()); open.setDisabled(true); open.setAutoShowParent(false); HLayout hLayout = new HLayout(); hLayout.setMembersMargin(10); hLayout.addMember(form); hLayout.addMember(open); // HTMLFlow html3 = new HTMLFlow(); // html3.setHeight("*"); // html3.setLayoutAlign(VerticalAlignment.BOTTOM); // html3.setContents(lang.credits()); // html3.setHeight(20); layout.addMember(html1); layout.addMember(status); layout.addMember(checkButton); layout.addMember(html2); layout.addMember(hLayout); // layout.addMember(html3); }
private HLayout createSearchLayout() { HLayout searchLayout = new HLayout(); searchLayout.setWidth100(); searchLayout.setHeight(20); searchLayout.setMembersMargin(15); i_searchForm = new DynamicForm(); i_searchForm.setWidth(250); i_searchForm.setHeight100(); i_searchForm.setAlign(Alignment.LEFT); i_searchForm.setAutoFocus(true); i_searchTextItem = new TextItem(); i_searchTextItem.setTitle("Search"); i_searchTextItem.setWidth(200); i_searchTextItem.setHint(SEARCH_HINT); i_searchTextItem.setShowHintInField(true); i_searchTextItem.setCanFocus(true); i_searchTextItem.setSelectOnFocus(true); i_searchTextItem.addKeyUpHandler( new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { event.getKeyName(); // ignore the arrow keys if (isValidSearchText()) { i_searchListGrid.getData(i_searchTextItem.getValueAsString()); i_addButton.setDisabled(true); } } }); i_searchForm.setFields(i_searchTextItem); // add button to a Vlayout so we can position it correctly with the form // search text. VLayout buttonVlayout = new VLayout(); buttonVlayout.setWidth(40); buttonVlayout.setAlign(VerticalAlignment.CENTER); buttonVlayout.setMargin(2); i_clearButton = new IButton(CLEAR_BUTTON_TITLE); i_clearButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { i_searchTextItem.setValue(""); i_rowsRetrievedLabel.setContents(""); i_searchListGrid.clearData(); i_addButton.setDisabled(true); } }); buttonVlayout.addMember(i_clearButton); // add Label to a Vlayout so we can position it correctly with the form // search text. VLayout labelVlayout = new VLayout(); labelVlayout.setWidth(100); labelVlayout.setAlign(VerticalAlignment.BOTTOM); labelVlayout.setMargin(2); i_rowsRetrievedLabel = new Label(); i_rowsRetrievedLabel.setWrap(false); i_rowsRetrievedLabel.setWidth100(); i_rowsRetrievedLabel.setHeight(23); labelVlayout.addMember(i_rowsRetrievedLabel); searchLayout.addMember(i_searchForm); searchLayout.addMember(buttonVlayout); searchLayout.addMember(labelVlayout); return searchLayout; }
private RegistrationWindow() { super(); final DynamicForm form = new DynamicForm(); form.setWidth("100%"); uName = new TextItem(); uName.setName("Username"); uName.setTitle("Username"); uName.setWidth("100%"); password1 = new PasswordItem(); password1.setName("Password1"); password1.setTitle("Enter Password"); password1.setWidth("100%"); password2 = new PasswordItem(); password2.setName("Password2"); password2.setTitle("Confirm Password"); password2.setWidth("100%"); name = new TextItem(); name.setName("Name"); name.setTitle("Name"); name.setWidth("100%"); surName = new TextItem(); surName.setName("Surname"); surName.setTitle("Surname"); surName.setWidth("100%"); email = new TextItem(); email.setName("Email"); email.setTitle("Email"); email.setWidth("100%"); final IButton buttonItem = new IButton(); final IButton cancelItem = new IButton(); cancelItem.setTitle("Cancel"); cancelItem.setWidth("100%"); cancelItem.setAlign(Alignment.CENTER); cancelItem.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { RegistrationWindow.getInstance().hide(); } }); buttonItem.setTitle("Register"); buttonItem.setWidth("100%"); buttonItem.setAlign(Alignment.CENTER); buttonItem.addClickHandler(new MyHandler()); form.setFields(uName, password1, password2, name, surName, email); HLayout layout = new HLayout(); layout.addMember(buttonItem); layout.addMember(cancelItem); layout.setAlign(Alignment.CENTER); setWidth(360); setHeight(250); setTitle("Contact Details"); setShowMinimizeButton(false); setIsModal(true); setShowModalMask(true); centerInPage(); addCloseClickHandler( new CloseClickHandler() { @Override public void onCloseClick(CloseClientEvent event) { instance.hide(); } }); addItem(form); addItem(layout); draw(); }
/** Prepares the database tab */ private Tab setupDatabase(final ValuesManager vm) { // Prepare the map with all database engines engines.put( MYSQL, new String[] { "MySQL 5.x", "com.mysql.jdbc.Driver", "jdbc:mysql://<server>[,<failoverhost>][<:3306>]/<database>", "org.hibernate.dialect.MySQLDialect", "SELECT 1" }); engines.put( "PostgreSQL", new String[] { "PostgreSQL 9.x", "org.postgresql.Driver", "jdbc:postgresql:[<//server>[<:5432>/]]<database>", "org.hibernate.dialect.PostgreSQLDialect", "SELECT 1" }); engines.put( ORACLE, new String[] { "Oracle 10g/11g", "oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@<server>[<:1521>]:<sid>", "org.hibernate.dialect.Oracle10gDialect", "SELECT 1 FROM DUAL" }); engines.put( SQLSERVER, new String[] { "SQL Server 2005/2008", "net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://<server>[:<1433>]/<database>;instance=<instance>", "org.hibernate.dialect.SQLServerDialect", "SELECT 1" }); Tab databaseTab = new Tab(); databaseTab.setTitle(I18N.message("database")); final DynamicForm databaseForm = new DynamicForm(); databaseForm.setWidth(450); databaseForm.setID("database"); databaseForm.setValuesManager(vm); databaseForm.setDisabled(true); RadioGroupItem dbType = new RadioGroupItem(); dbType.setName(DB_TYPE); dbType.setWrapTitle(false); dbType.setRequired(true); dbType.setVertical(false); dbType.setValueMap(I18N.message(INTERNAL), I18N.message("external")); dbType.setValue(I18N.message(INTERNAL)); dbType.setRedrawOnChange(true); dbType.setTitle(I18N.message("dbtype")); // The database engine, if the External db was chosen SelectItem dbEngine = new SelectItem(); dbEngine.setTitle(I18N.message("dbengine")); dbEngine.setWrapTitle(false); dbEngine.setVisible(false); dbEngine.setName(DB_ENGINE); dbEngine.setDefaultValue(MYSQL); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); for (String engine : engines.keySet()) { valueMap.put(engine, engines.get(engine)[0]); } dbEngine.setValueMap(valueMap); dbEngine.setShowIfCondition( new FormItemIfFunction() { public boolean execute(FormItem item, Object value, DynamicForm form) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); RequiredIfValidator ifValidator = new RequiredIfValidator(); ifValidator.setExpression( new RequiredIfFunction() { public boolean execute(FormItem formItem, Object value) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); dbEngine.setValidators(ifValidator); dbEngine.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { String selectedItem = (String) event.getValue(); databaseForm.getField(DB_DRIVER).setValue(engines.get(selectedItem)[1]); databaseForm.getField(DB_URL).setValue(engines.get(selectedItem)[2]); } }); // The driver for the external DB TextItem dbDriver = ItemFactory.newTextItem(DB_DRIVER, "driverclass", null); dbDriver.setVisible(false); dbDriver.setDefaultValue(engines.get(MYSQL)[1]); dbDriver.setWrapTitle(false); dbDriver.setShowIfCondition( new FormItemIfFunction() { public boolean execute(FormItem item, Object value, DynamicForm form) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); dbDriver.setValidators(ifValidator); // The connection URL to external DB TextItem dbUrl = ItemFactory.newTextItem(DB_URL, "connectionurl", null); dbUrl.setWidth(200); dbUrl.setVisible(false); dbUrl.setDefaultValue(engines.get(MYSQL)[2]); dbUrl.setWrapTitle(false); dbUrl.setShowIfCondition( new FormItemIfFunction() { public boolean execute(FormItem item, Object value, DynamicForm form) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); dbUrl.setValidators(ifValidator); // The username to access the external DB TextItem dbUsername = ItemFactory.newTextItem(DB_USERNAME, "username", null); dbUsername.setVisible(false); dbUsername.setWrapTitle(false); dbUsername.setShowIfCondition( new FormItemIfFunction() { public boolean execute(FormItem item, Object value, DynamicForm form) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); // The password to access the external DB PasswordItem dbPassword = new PasswordItem(); dbPassword.setVisible(false); dbPassword.setTitle(I18N.message("password")); dbPassword.setName(DB_PASSWORD); dbPassword.setWrapTitle(false); dbPassword.setShowIfCondition( new FormItemIfFunction() { public boolean execute(FormItem item, Object value, DynamicForm form) { return !I18N.message(INTERNAL).equals(databaseForm.getValue(DB_TYPE)); } }); databaseForm.setFields(dbType, dbEngine, dbDriver, dbUrl, dbUsername, dbPassword); databaseTab.setPane(databaseForm); return databaseTab; }
public ProxyPanel(GUIParameter[] parameters) { setWidth100(); setMembersMargin(10); setMargin(30); setHeight(400); TabSet tabs = new TabSet(); tabs.setWidth(380); tabs.setHeight(250); Tab tab = new Tab(); tab.setTitle(I18N.message("proxy")); tabs.setTabs(tab); DynamicForm proxySettingsForm = new DynamicForm(); proxySettingsForm.setWidth(300); proxySettingsForm.setColWidths(1, "*"); proxySettingsForm.setValuesManager(vm); proxySettingsForm.setTitleOrientation(TitleOrientation.LEFT); List<FormItem> items = new ArrayList<FormItem>(); for (GUIParameter f : parameters) { if (f.getName().equals("password")) { PasswordItem item = ItemFactory.newPasswordItem(f.getName(), f.getName(), f.getValue()); item.setRequired(true); item.setWidth(250); items.add(item); } else if (f.getName().equals("port")) { IntegerItem item = ItemFactory.newValidateIntegerItem( f.getName(), f.getName(), Integer.parseInt(f.getValue()), 1, null); item.setRequired(true); item.setWidth(250); items.add(item); } else { TextItem item = ItemFactory.newTextItem(f.getName(), f.getName(), f.getValue()); item.setRequired(true); item.setWidth(250); items.add(item); } } proxySettingsForm.setItems(items.toArray(new FormItem[0])); IButton save = new IButton(); save.setTitle(I18N.message("save")); save.addClickHandler( new ClickHandler() { @SuppressWarnings("unchecked") public void onClick(ClickEvent event) { Map<String, Object> values = (Map<String, Object>) vm.getValues(); if (vm.validate()) { List<GUIParameter> proxySettings = new ArrayList<GUIParameter>(); for (String name : values.keySet()) { GUIParameter proxyParam = new GUIParameter(name, values.get(name).toString()); proxySettings.add(proxyParam); } service.saveProxySettings( Session.get().getSid(), proxySettings.toArray(new GUIParameter[0]), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Log.serverError(caught); } @Override public void onSuccess(Void result) { Log.info(I18N.message("settingssaved"), null); } }); } } }); tab.setPane(proxySettingsForm); setMembers(tabs, save); }
public CargaProductoCompra(CompraDetalle compradetalle, final Sgc_capa_web mainWindow) { VLayout layout = new VLayout(10); final DynamicForm form = new DynamicForm(); form.setBackgroundColor("#006633"); form.setBorder("2px"); form.setAutoFocus(true); form.setNumCols(3); form.setWidth(500); Label label = new Label(); label.setBackgroundColor("#99ffcc"); label.setHeight(30); label.setWidth(500); label.setPadding(10); label.setAlign(Alignment.CENTER); label.setValign(VerticalAlignment.CENTER); label.setWrap(false); label.setShowEdges(true); label.setContents( "<div style='color:black;font-size:15'><b>Carga de Productos de la Compra</b></div>"); TextItem codigoText = new TextItem("codigo"); codigoText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}"); codigoText.setTitle("Codigo"); codigoText.setDisabled(true); codigoText.setWrapTitle(false); final TextItem productoText = new TextItem("producto"); productoText.setTitle("Producto"); productoText.setDefaultValue(new Date()); productoText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}"); productoText.setWrapTitle(false); final TextItem cantidadText = new TextItem("cantidad"); cantidadText.setTitle("Cantidad"); cantidadText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}"); cantidadText.setWrapTitle(false); final TextItem preciocompraText = new TextItem("preciocompra"); preciocompraText.setTitle("Precio"); preciocompraText.setTitleStyle("{font-color:white;font-weigh:bold;font-size:14}"); preciocompraText.setWrapTitle(false); ButtonItem button = new ButtonItem("save", "Aceptar"); button.setStartRow(false); button.setWidth(80); button.setIcon("approve.png"); button.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { CompraDetalleServiceAsync service = GWT.create(CompraDetalleService.class); ServiceDefTarget serviceDef = (ServiceDefTarget) service; serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "compradetalleService"); CompraDetalle compradetalle = new CompraDetalle(); compradetalle.setId_producto(Integer.parseInt(form.getValueAsString("producto"))); compradetalle.setCantidad(Integer.parseInt(form.getValueAsString("cantidad"))); compradetalle.setPrecioCompra( Double.parseDouble(form.getValueAsString("preciocompra"))); // compra.setTotalCompra(Integer.parseInt("15000")); if (form.getValueAsString("codigo") != null) { compradetalle.setIdCompDet(Integer.valueOf(form.getValueAsString("codigo"))); } try { service.guardar( compradetalle, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { Window.alert( "Ocurrio un error: " + caught.getClass().getName() + " " + caught.getMessage()); } @Override public void onSuccess(Void result) { new CargaProductoCompra(mainWindow); } }); } catch (Exception e) { e.printStackTrace(); } } }); if (compradetalle != null) { codigoText.setDefaultValue(String.valueOf(compradetalle.getIdCompDet())); productoText.setDefaultValue(compradetalle.getId_producto()); cantidadText.setDefaultValue(compradetalle.getCantidad()); preciocompraText.setDefaultValue(((Object) compradetalle.getPrecioCompra()).toString()); } form.setFields(codigoText, productoText, cantidadText, preciocompraText, button); layout.addMember(label); layout.addMember(form); mainWindow.showDialog(layout); }
public TabFindAbonent() { setTitle(CallCenter.constants.findAbonent()); setCanClose(true); datasource = DataSource.get("AbonentsDS"); mainLayout = new VLayout(5); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.setMargin(5); searchForm = new DynamicForm(); searchForm.setAutoFocus(true); searchForm.setWidth(750); searchForm.setNumCols(3); searchForm.setTitleOrientation(TitleOrientation.TOP); mainLayout.addMember(searchForm); firstNameItem = new TextItem(); firstNameItem.setTitle(CallCenter.constants.name()); firstNameItem.setWidth(250); firstNameItem.setName("firstNameItem"); lastNameItem = new TextItem(); lastNameItem.setTitle(CallCenter.constants.lastName()); lastNameItem.setWidth(250); lastNameItem.setName("lastNameItem"); phoneItem = new TextItem(); phoneItem.setTitle(CallCenter.constants.phone()); phoneItem.setWidth(250); phoneItem.setName("phone"); streetItem = new TextItem(); streetItem.setTitle(CallCenter.constants.street()); streetItem.setName("street_name_geo"); streetItem.setWidth(250); citiesItem = new ComboBoxItem(); citiesItem.setTitle(CallCenter.constants.city()); citiesItem.setName("city_name_geo"); citiesItem.setWidth(250); citiesItem.setFetchMissingValues(true); citiesItem.setFilterLocally(false); citiesItem.setAddUnknownValues(false); DataSource cityDS = DataSource.get("CityDS"); citiesItem.setOptionOperationId("searchCitiesFromDBForCombos"); citiesItem.setOptionDataSource(cityDS); citiesItem.setValueField("city_id"); citiesItem.setDisplayField("city_name_geo"); citiesItem.setOptionCriteria(new Criteria()); citiesItem.setAutoFetchData(false); citiesItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { Criteria criteria = citiesItem.getOptionCriteria(); if (criteria != null) { String oldAttr = criteria.getAttribute("city_id"); if (oldAttr != null) { Object nullO = null; criteria.setAttribute("city_id", nullO); } } } }); regionItem = new ComboBoxItem(); regionItem.setTitle(CallCenter.constants.cityRegion()); regionItem.setName("city_region_name_geo"); regionItem.setWidth(250); regionItem.setFetchMissingValues(true); regionItem.setFilterLocally(false); regionItem.setAddUnknownValues(false); DataSource streetsDS = DataSource.get("CityRegionDS"); regionItem.setOptionOperationId("searchCityRegsFromDBForCombos"); regionItem.setOptionDataSource(streetsDS); regionItem.setValueField("city_region_id"); regionItem.setDisplayField("city_region_name_geo"); Criteria criteria = new Criterion(); regionItem.setOptionCriteria(criteria); regionItem.setAutoFetchData(false); regionItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { Criteria criteria = regionItem.getOptionCriteria(); if (criteria != null) { String oldAttr = criteria.getAttribute("city_region_id"); if (oldAttr != null) { Object nullO = null; criteria.setAttribute("city_region_id", nullO); } } } }); searchForm.setFields( lastNameItem, firstNameItem, phoneItem, streetItem, citiesItem, regionItem); HLayout buttonLayout = new HLayout(5); buttonLayout.setWidth(750); buttonLayout.setHeight(30); buttonLayout.setAlign(Alignment.RIGHT); clearButton = new IButton(); clearButton.setTitle(CallCenter.constants.clear()); findButton = new IButton(); findButton.setTitle(CallCenter.constants.find()); buttonLayout.setMembers(findButton, clearButton); mainLayout.addMember(buttonLayout); listGrid = new ListGrid() { protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) { ListGridRecord countryRecord = (ListGridRecord) record; if (countryRecord == null) { return super.getCellCSSText(record, rowNum, colNum); } Integer deleted = countryRecord.getAttributeAsInt("deleted"); if (deleted != null && !deleted.equals(0)) { return "color:red;"; } else { return super.getCellCSSText(record, rowNum, colNum); } }; }; listGrid.setWidth(1000); listGrid.setHeight100(); listGrid.setAlternateRecordStyles(true); listGrid.setDataSource(datasource); listGrid.setAutoFetchData(false); listGrid.setShowFilterEditor(false); listGrid.setCanEdit(false); listGrid.setCanRemoveRecords(false); listGrid.setFetchOperation("customSearchForCC"); listGrid.setCanSort(false); listGrid.setCanResizeFields(false); listGrid.setCanSelectText(true); listGrid.setCanDragSelectText(true); listGrid.setShowFilterEditor(true); listGrid.setFilterOnKeypress(true); ListGridField firstname = new ListGridField("firstname", CallCenter.constants.name(), 120); firstname.setCanFilter(true); ListGridField lastname = new ListGridField("lastname", CallCenter.constants.lastName(), 150); lastname.setCanFilter(true); ListGridField city = new ListGridField("city", CallCenter.constants.city(), 140); city.setCanFilter(false); ListGridField address = new ListGridField("address", CallCenter.constants.address()); address.setCanFilter(true); ListGridField phone = new ListGridField("phone", CallCenter.constants.phone(), 100); phone.setCanFilter(true); firstname.setAlign(Alignment.LEFT); lastname.setAlign(Alignment.LEFT); city.setAlign(Alignment.LEFT); address.setAlign(Alignment.LEFT); phone.setAlign(Alignment.CENTER); listGrid.setFields(lastname, firstname, city, address, phone); mainLayout.addMember(listGrid); clearButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { firstNameItem.clearValue(); lastNameItem.clearValue(); phoneItem.clearValue(); streetItem.clearValue(); citiesItem.clearValue(); regionItem.clearValue(); } }); findButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { search(); } }); citiesItem.addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { String value = citiesItem.getValueAsString(); if (value == null) { return; } regionItem.clearValue(); fillCityRegionCombo(new Integer(value)); } }); firstNameItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); lastNameItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); phoneItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); streetItem.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { search(); } } }); listGrid.addRecordDoubleClickHandler( new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { DlgViewAbonent dlgViewAbonent = new DlgViewAbonent(listGrid, datasource, listGrid.getSelectedRecord()); dlgViewAbonent.show(); } }); setPane(mainLayout); }
public TabCalendar() { try { setTitle(CallCenter.constants.menuCalendar()); setCanClose(true); datasource = DataSource.get("CalSecDS"); mainLayout = new VLayout(5); mainLayout.setWidth100(); mainLayout.setHeight100(); mainLayout.setMargin(5); searchForm = new DynamicForm(); searchForm.setAutoFocus(true); searchForm.setWidth(780); searchForm.setTitleWidth(300); searchForm.setNumCols(4); mainLayout.addMember(searchForm); calendarStateItem = new ComboBoxItem(); calendarStateItem.setTitle(CallCenter.constants.type()); calendarStateItem.setWidth(300); calendarStateItem.setName("calendar_state_id"); calendarStateItem.setValueMap(ClientMapUtil.getInstance().getCalendarStates()); calendarStateItem.setAddUnknownValues(false); secCalendarTypeItem = new ComboBoxItem(); secCalendarTypeItem.setTitle(CallCenter.constants.moonPhase()); secCalendarTypeItem.setWidth(300); secCalendarTypeItem.setName("calendar_event_id"); secCalendarTypeItem.setValueMap(ClientMapUtil.getInstance().getSecCalendarTypes()); secCalendarTypeItem.setAddUnknownValues(false); calendarDayItem = new DateItem(); calendarDayItem.setTitle(CallCenter.constants.date()); calendarDayItem.setWidth(300); calendarDayItem.setValue(new Date()); calendarDayItem.setName("calendar_day"); calendarDayItem.setHint(CallCenter.constants.choose()); descriptionItem = new TextItem(); descriptionItem.setTitle(CallCenter.constants.description()); descriptionItem.setName("calendar_description"); descriptionItem.setWidth(300); commentItem = new TextItem(); commentItem.setTitle(CallCenter.constants.comment()); commentItem.setName("calendar_comment"); commentItem.setWidth(300); byCalendarDayItem = new CheckboxItem(); byCalendarDayItem.setTitle(CallCenter.constants.searchByDate()); byCalendarDayItem.setWidth(300); byCalendarDayItem.setName("buCalDaySearch"); byCalendarDayItem.setValue(false); searchForm.setFields( calendarStateItem, secCalendarTypeItem, descriptionItem, commentItem, byCalendarDayItem, calendarDayItem); HLayout buttonLayout = new HLayout(5); buttonLayout.setWidth(780); buttonLayout.setHeight(30); buttonLayout.setAlign(Alignment.RIGHT); clearButton = new IButton(); clearButton.setTitle(CallCenter.constants.clear()); findButton = new IButton(); findButton.setTitle(CallCenter.constants.find()); buttonLayout.setMembers(findButton, clearButton); mainLayout.addMember(buttonLayout); ToolStrip toolStrip = new ToolStrip(); toolStrip.setWidth(780); toolStrip.setPadding(5); mainLayout.addMember(toolStrip); addBtn = new ToolStripButton(CallCenter.constants.add(), "addIcon.png"); addBtn.setLayoutAlign(Alignment.LEFT); addBtn.setWidth(50); toolStrip.addButton(addBtn); editBtn = new ToolStripButton(CallCenter.constants.modify(), "editIcon.png"); editBtn.setLayoutAlign(Alignment.LEFT); editBtn.setWidth(50); toolStrip.addButton(editBtn); disableBtn = new ToolStripButton(CallCenter.constants.disable(), "deleteIcon.png"); disableBtn.setLayoutAlign(Alignment.LEFT); disableBtn.setWidth(50); toolStrip.addButton(disableBtn); activateBtn = new ToolStripButton(CallCenter.constants.enable(), "restoreIcon.gif"); activateBtn.setLayoutAlign(Alignment.LEFT); activateBtn.setWidth(50); toolStrip.addButton(activateBtn); toolStrip.addSeparator(); copyBtn = new ToolStripButton(CallCenter.constants.copy(), "copy.png"); copyBtn.setLayoutAlign(Alignment.LEFT); copyBtn.setWidth(50); toolStrip.addButton(copyBtn); listGrid = new ListGrid() { protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) { ListGridRecord countryRecord = (ListGridRecord) record; if (countryRecord == null) { return super.getCellCSSText(record, rowNum, colNum); } Integer deleted = countryRecord.getAttributeAsInt("deleted"); if (deleted != null && !deleted.equals(0)) { return "color:red;"; } else { return super.getCellCSSText(record, rowNum, colNum); } }; }; listGrid.setWidth(780); listGrid.setHeight(260); listGrid.setAlternateRecordStyles(true); listGrid.setDataSource(datasource); listGrid.setAutoFetchData(false); listGrid.setShowFilterEditor(false); listGrid.setCanEdit(false); listGrid.setCanRemoveRecords(false); listGrid.setFetchOperation("searchAllSecularCalendars"); listGrid.setShowRowNumbers(true); listGrid.setCanHover(true); listGrid.setShowHover(true); listGrid.setShowHoverComponents(true); datasource.getField("calendar_day").setTitle(CallCenter.constants.date()); datasource.getField("event").setTitle(CallCenter.constants.moonPhase()); datasource.getField("state").setTitle(CallCenter.constants.type()); datasource.getField("sun_rise").setTitle(CallCenter.constants.order()); datasource.getField("calendar_description").setTitle(CallCenter.constants.description()); datasource.getField("calendar_comment").setTitle(CallCenter.constants.comment()); datasource.getField("rec_date").setTitle(CallCenter.constants.recDate()); datasource.getField("rec_user").setTitle(CallCenter.constants.recUser()); datasource.getField("upd_date").setTitle(CallCenter.constants.updDate()); datasource.getField("upd_user").setTitle(CallCenter.constants.updUser()); ListGridField calendar_day = new ListGridField("calendar_day", CallCenter.constants.date(), 150); ListGridField event = new ListGridField("event", CallCenter.constants.moonPhase(), 150); ListGridField state = new ListGridField("state", CallCenter.constants.type(), 80); ListGridField sun_rise = new ListGridField("sun_rise", CallCenter.constants.sunRise(), 100); ListGridField calendar_description = new ListGridField("calendar_description", CallCenter.constants.description(), 250); calendar_day.setAlign(Alignment.LEFT); event.setAlign(Alignment.LEFT); state.setAlign(Alignment.CENTER); sun_rise.setAlign(Alignment.CENTER); listGrid.setFields(calendar_day, event, state, sun_rise, calendar_description); mainLayout.addMember(listGrid); findButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { search(); } }); clearButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { calendarStateItem.clearValue(); secCalendarTypeItem.clearValue(); calendarDayItem.clearValue(); descriptionItem.clearValue(); commentItem.clearValue(); } }); addBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { DlgAddEditSecCalendar dlgEditSecCalendar = new DlgAddEditSecCalendar(listGrid, null, false); dlgEditSecCalendar.show(); } }); editBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ListGridRecord listGridRecord = listGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenter.constants.pleaseSelrecord()); return; } DlgAddEditSecCalendar dlgEditSecCalendar = new DlgAddEditSecCalendar(listGrid, listGridRecord, false); dlgEditSecCalendar.show(); } }); copyBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ListGridRecord listGridRecord = listGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenter.constants.pleaseSelrecord()); return; } DlgAddEditSecCalendar dlgEditSecCalendar = new DlgAddEditSecCalendar(listGrid, listGridRecord, true); dlgEditSecCalendar.show(); } }); disableBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ListGridRecord listGridRecord = listGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenter.constants.pleaseSelrecord()); return; } Integer deleted = listGridRecord.getAttributeAsInt("deleted"); if (!deleted.equals(0)) { SC.say(CallCenter.constants.recordAlrDisabled()); return; } final Integer calendar_id = listGridRecord.getAttributeAsInt("calendar_id"); SC.ask( CallCenter.constants.askForDisable(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { changeStatus(calendar_id, 1); } } }); } }); activateBtn.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { ListGridRecord listGridRecord = listGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenter.constants.pleaseSelrecord()); return; } Integer deleted = listGridRecord.getAttributeAsInt("deleted"); if (deleted.equals(0)) { SC.say(CallCenter.constants.recordAlrEnabled()); return; } final Integer calendar_id = listGridRecord.getAttributeAsInt("calendar_id"); SC.ask( CallCenter.constants.askForEnable(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { changeStatus(calendar_id, 0); } } }); } }); TabSet tabSet = new TabSet(); tabSet.setWidth(780); Tab tabDetViewer = new Tab(CallCenter.constants.view()); final DetailViewer detailViewer = new DetailViewer(); detailViewer.setDataSource(datasource); detailViewer.setWidth(750); tabDetViewer.setPane(detailViewer); listGrid.addRecordClickHandler( new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { detailViewer.viewSelectedData(listGrid); } }); listGrid.addRecordDoubleClickHandler( new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { ListGridRecord listGridRecord = listGrid.getSelectedRecord(); if (listGridRecord == null) { SC.say(CallCenter.constants.pleaseSelrecord()); return; } DlgAddEditSecCalendar dlgEditSecCalendar = new DlgAddEditSecCalendar(listGrid, listGridRecord, false); dlgEditSecCalendar.show(); } }); tabSet.setTabs(tabDetViewer); mainLayout.addMember(tabSet); setPane(mainLayout); } catch (Exception e) { e.printStackTrace(); SC.say(e.getMessage().toString()); } }
public CurrencyViewImpl() { Element eBasePrefix = DOM.getElementById("baseCurrencyPrefix"); if (eBasePrefix == null) { throw new IllegalStateException("Base Currency Prefix div not found in hosted page"); } baseCurrencyPrefix = eBasePrefix.getInnerText(); Element eDocPrefix = DOM.getElementById("docCurrencyPrefix"); if (eDocPrefix == null) { throw new IllegalStateException("Doc Currency Prefix div not found in hosted page"); } docCurrencyPrefix = eDocPrefix.getInnerText(); currencyGrid = new ListGrid(); currencyGrid.setShowAllColumns(true); currencyGrid.setCanEdit(true); currencyGrid.setAutoFetchData(true); currencyGrid.setWidth100(); currencyGrid.setHeight100(); currencyGrid.setShowAllColumns(true); currencyGrid.setSelectionType(SelectionStyle.SINGLE); currencyGrid.setDataSource(CurrencyDataSource.getInstance()); currencyGrid.setSortDirection(SortDirection.DESCENDING); currencyGrid.setSortField("dt"); currencyGrid.setShowHeaderContextMenu(false); currencyGrid.setCanAutoFitFields(false); addRowButton = new IButton(constants.add()); addRowButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // Boolean isWindowInput = (Boolean)isWindowInputItem.getValue(); // currencyGrid.startEditingNew(); // currencyGrid.endEditing(); Record firstRecord = currencyGrid.getRecordList().first(); Record lastRecord = currencyGrid.getRecordList().last(); Date firstDate = firstRecord.getAttributeAsDate("dt"); Date lastDate = lastRecord.getAttributeAsDate("dt"); Date nowDate = new Date(); DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd.MM.yyyy"); String firstDateStr = dateFormatter.format(firstDate); String lastDateStr = dateFormatter.format(lastDate); String nowDateStr = dateFormatter.format(nowDate); if (nowDateStr.equals(firstDateStr) || nowDateStr.equals(lastDateStr)) { SC.say(constants.warningCurrencyAlreadySet()); } else { CurrencyRecord currencyRecord = new CurrencyRecord(); currencyRecord.setDt(new Date()); currencyRecord.setAttribute( CurrencyRecord.IDENTITY_CURRENCY + baseCurrencyPrefix, 1.0); currencyRecord.setAttribute( CurrencyRecord.IDENTITY_CURRENCY + docCurrencyPrefix, 1.0); currencyGrid.startEditingNew(currencyRecord); } } }); editRowButton = new IButton(constants.editCurrency()); editRowButton.setAutoFit(true); editRowButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.goTo(new CurrencyTypePlace("")); } }); currencyGrid.addCellDoubleClickHandler( new CellDoubleClickHandler() { @Override public void onCellDoubleClick(CellDoubleClickEvent event) { if (currencyGrid.getFieldNum("remove") == event.getColNum()) { final ListGridRecord record = currencyGrid.getRecord(event.getRowNum()); if (record != null) { SC.ask( constants.askRemoveRecord(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { currencyGrid.removeData(record); } } }); } } else { Boolean isWindowInput = (Boolean) isWindowInputItem.getValue(); if (isWindowInput) { String fieldName = currencyGrid.getFieldName(event.getColNum()); Double exchange = null; try { exchange = Double.parseDouble(event.getRecord().getAttribute(fieldName)); } catch (Exception ex) { } if (fieldName != null && exchange != null && fieldName.startsWith(CurrencyRecord.IDENTITY_CURRENCY)) { String name = fieldName.substring(1); Currency currency = new Currency(name, exchange); showCurrencyForm(event.getRowNum(), event.getColNum(), currency); } } } } }); currencyGrid.addCellClickHandler( new CellClickHandler() { @Override public void onCellClick(CellClickEvent event) { if (currencyGrid.getFieldNum("remove") == event.getColNum()) { final ListGridRecord record = currencyGrid.getRecord(event.getRowNum()); if (record != null) { SC.ask( constants.askRemoveRecord(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value) { currencyGrid.removeData(record); } } }); } } else { Boolean isWindowInput = (Boolean) isWindowInputItem.getValue(); if (isWindowInput) event.cancel(); } } }); DynamicForm form = new DynamicForm(); isWindowInputItem = new CheckboxItem("output", constants.windowsInput()); isWindowInputItem.setDefaultValue(false); isWindowInputItem.setAlign(Alignment.RIGHT); form.setItems(isWindowInputItem); form.setWidth("*"); HLayout controlLayout = new HLayout(); controlLayout.setMembers(addRowButton, editRowButton, form); addMember(currencyGrid); addMember(controlLayout); }
/** Instantiates a new digital object menu view. */ @Inject public DigitalObjectMenuView(final LangConstants lang, final EventBus eventBus) { this.lang = lang; this.eventBus = eventBus; layout = new VLayout(); layout.setHeight100(); layout.setWidth100(); layout.setOverflow(Overflow.AUTO); relatedGrid = new ListGrid(); relatedGrid.setWidth100(); relatedGrid.setHeight100(); relatedGrid.setShowSortArrow(SortArrow.CORNER); relatedGrid.setShowAllRecords(true); relatedGrid.setAutoFetchData(false); relatedGrid.setCanHover(true); relatedGrid.setCanSort(false); ListGridField field1 = new ListGridField("relation", lang.relation()); field1.setWidth("40%"); ListGridField field2 = new ListGridField("uuid", "PID"); field2.setWidth("*"); relatedGrid.setFields(field1, field2); sectionRelated = new SectionStackSection(); sectionRelated.setID(SECTION_RELATED_ID); sectionRelated.setTitle(lang.referencedBy()); sectionRelated.setResizeable(true); sectionRelated.setItems(relatedGrid); sectionRelated.setExpanded(false); sideNavGrid = new ListGrid() { @Override protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) { final ListGridRecord rollOverRecord = this.getRecord(rowNum); if (rollOverCanvas == null) { rollOverCanvas = new HLayout(); rollOverCanvas.setSnapTo("TR"); rollOverCanvas.setWidth(50); rollOverCanvas.setHeight(22); } if (rollOverCanvas.getChildren().length > 0) { rollOverCanvas.removeChild(rollOverCanvas.getChildren()[0]); } final String lockOwner = rollOverRecord.getAttributeAsString(Constants.ATTR_LOCK_OWNER); if (lockOwner != null) { ImgButton lockImg = new ImgButton(); lockImg.setShowDown(false); lockImg.setShowRollOver(false); lockImg.setLayoutAlign(Alignment.CENTER); if ("".equals(lockOwner)) { lockImg.setSrc("icons/16/lock_lock_all.png"); } else if (lockOwner.length() > 0) { lockImg.setSrc("icons/16/lock_lock_all_red.png"); } lockImg.setPrompt(lang.lockInfoButton()); lockImg.setHeight(16); lockImg.setWidth(16); lockImg.addClickHandler( new com.smartgwt.client.widgets.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { EditorSC.objectIsLock( lang, new LockInfo( lockOwner, rollOverRecord.getAttributeAsString(Constants.ATTR_LOCK_DESCRIPTION), rollOverRecord.getAttributeAsStringArray( Constants.ATTR_TIME_TO_EXP_LOCK))); } }); rollOverCanvas.addChild(lockImg); } return rollOverCanvas; } }; sideNavGrid.setShowSelectionCanvas(false); sideNavGrid.setWidth100(); sideNavGrid.setHeight100(); sideNavGrid.setShowSortArrow(SortArrow.CORNER); sideNavGrid.setShowAllRecords(true); sideNavGrid.setAutoFetchData(true); sideNavGrid.setCanHover(true); sideNavGrid.setHoverOpacity(75); sideNavGrid.setHoverStyle("interactImageHover"); sideNavGrid.setShowRollOverCanvas(true); final DynamicForm form = new DynamicForm(); form.setHeight(1); form.setWidth(60); form.setNumCols(1); selectItem.setWidth(60); selectItem.setShowTitle(false); selectItem.setValueMap(lang.me(), lang.all()); selectItem.setDefaultValue(lang.me()); selectItem.setHoverOpacity(75); selectItem.setHoverStyle("interactImageHover"); selectItem.addItemHoverHandler( new ItemHoverHandler() { @Override public void onItemHover(ItemHoverEvent event) { selectItem.setPrompt( DigitalObjectMenuView.this.lang.showModifiedHint() + selectItem.getValue()); } }); selectItem.addChangedHandler( new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { getUiHandlers().refreshRecentlyModified(); } }); form.setFields(selectItem); form.setTitle("by:"); sectionRecentlyModified = new SectionStackSection(); sectionRecentlyModified.setTitle(lang.recentlyModified()); sectionRecentlyModified.setResizeable(true); sectionRecentlyModified.setItems(sideNavGrid); sectionRecentlyModified.setControls(form); sectionRecentlyModified.setExpanded(true); sectionStack = new SectionStack(); sectionStack.addSection(sectionRelated); sectionStack.addSection(sectionRecentlyModified); sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE); sectionStack.setAnimateSections(true); sectionStack.setWidth100(); sectionStack.setHeight100(); sectionStack.setOverflow(Overflow.HIDDEN); layout.addMember(sectionStack); }
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(); }