/** Prepares the SMTP form */ private Tab setupSmtp(final ValuesManager vm) { // Prepare the SMTP connection tab Tab smtpTab = new Tab(); smtpTab.setTitle(I18N.message("smtpserver")); final DynamicForm smtpForm = new DynamicForm(); smtpForm.setDisabled(true); smtpForm.setID("smtpForm"); smtpForm.setTitleOrientation(TitleOrientation.TOP); smtpForm.setValuesManager(vm); smtpTab.setPane(smtpForm); TextItem smtpHost = ItemFactory.newTextItem(SMTP_HOST, "host", null); smtpHost.setValue("localhost"); smtpHost.setWrapTitle(false); IntegerItem smtpPort = ItemFactory.newIntegerItem(SMTP_PORT, "port", null); smtpPort.setValue(25); smtpPort.setWrapTitle(false); TextItem smtpUsername = ItemFactory.newTextItem(SMTP_USERNAME, "username", null); smtpUsername.setWrapTitle(false); PasswordItem smtpPassword = new PasswordItem(); smtpPassword.setTitle(I18N.message("password")); smtpPassword.setName(SMTP_PASSWORD); smtpPassword.setWrapTitle(false); BooleanItem smtpSecureAuth = new BooleanItem(); smtpSecureAuth.setTitle(I18N.message("secureauth")); smtpSecureAuth.setName(SMTP_SECURE_AUTH); smtpSecureAuth.setWrapTitle(false); smtpSecureAuth.setDefaultValue(false); SelectItem smtpConnectionSecurity = new SelectItem(); smtpConnectionSecurity.setTitle(I18N.message("connectionsecurity")); smtpConnectionSecurity.setName("smtpConnectionSecurity"); smtpConnectionSecurity.setDefaultValue(Constants.SMTP_SECURITY_NONE); smtpConnectionSecurity.setWrapTitle(false); LinkedHashMap<String, String> valueMap = new LinkedHashMap<String, String>(); valueMap.put(Constants.SMTP_SECURITY_NONE, I18N.message("none")); valueMap.put(Constants.SMTP_SECURITY_SSL, I18N.message("ssl")); valueMap.put(Constants.SMTP_SECURITY_TLS, I18N.message("tls")); valueMap.put(Constants.SMTP_SECURITY_TLS_IF_AVAILABLE, I18N.message("tlsavailable")); smtpConnectionSecurity.setValueMap(valueMap); TextItem smtpSender = ItemFactory.newEmailItem(SMTP_SENDER, "sender", false); smtpSender.setWrapTitle(false); smtpSender.setValue("*****@*****.**"); smtpForm.setFields( smtpHost, smtpPort, smtpUsername, smtpPassword, smtpSender, smtpConnectionSecurity, smtpSecureAuth); return smtpTab; }
/** Prepares the registration form */ private Tab setupRegistration(final ValuesManager vm) { Tab registrationTab = new Tab(); registrationTab.setTitle(I18N.message("registration")); TextItem regName = ItemFactory.newTextItem(REG_NAME, "name", null); regName.setWrapTitle(false); TextItem regOrganization = ItemFactory.newTextItem(REG_ORGANIZATION, "organization", null); regOrganization.setWrapTitle(false); TextItem regWebsite = ItemFactory.newTextItem(REG_WEBSITE, "website", null); regWebsite.setWrapTitle(false); TextItem regEmail = ItemFactory.newEmailItem(REG_EMAIL, "email", false); regEmail.setWrapTitle(false); final DynamicForm regForm = new DynamicForm(); regForm.setID("regForm"); regForm.setValuesManager(vm); regForm.setFields(regName, regEmail, regOrganization, regWebsite); registrationTab.setPane(regForm); return registrationTab; }
/** Prepares the repository form */ private Tab setupRepository(final ValuesManager vm) { // Prepare the tab used to configure the repository where documents and // other data will be stored Tab repositoryTab = new Tab(); repositoryTab.setTitle(I18N.message("repository")); final DynamicForm repositoryForm = new DynamicForm(); repositoryForm.setID("repositoryForm"); repositoryForm.setValuesManager(vm); TextItem repositoryItem = ItemFactory.newTextItem(REPOSITORY_FOLDER, "repofolder", null); repositoryItem.setWidth(200); repositoryItem.setRequired(true); repositoryItem.setWrapTitle(false); repositoryItem.setDefaultValue(getDefaultFolder()); repositoryForm.setFields(repositoryItem); repositoryForm.setDisabled(true); repositoryTab.setPane(repositoryForm); return repositoryTab; }
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); }
private DynamicForm buildEditForm() { editForm = new LocatableDynamicForm(extendLocatorId("Editor")); editForm.setMargin(5); editForm.setAutoWidth(); editForm.setNumCols(canEditName() ? 12 : 10); TextItem nameItem = null; if (dashboardContainer.supportsDashboardNameEdit()) { nameItem = new TextItem("name", MSG.common_title_dashboard_name()); nameItem.setValue(storedDashboard.getName()); nameItem.setLength(200); nameItem.setWrapTitle(false); nameItem.addBlurHandler( new BlurHandler() { public void onBlur(BlurEvent blurEvent) { FormItem nameItem = blurEvent.getItem(); String name = (String) nameItem.getValue(); String trimmedName = (name == null) ? "" : name.trim(); if (dashboardContainer.isValidDashboardName(trimmedName)) { storedDashboard.setName(trimmedName); save(); dashboardContainer.updateDashboardNames(); } else { // TODO: i18n Message message = new Message( "There is already a dashboard named '" + trimmedName + "'. Please specify a name that is not already in use.", Message.Severity.Error, EnumSet.of(Message.Option.Transient)); CoreGUI.getMessageCenter().notify(message); nameItem.setValue(storedDashboard.getName()); } } }); } final StaticTextItem numColItem = new StaticTextItem(); numColItem.setTitle(MSG.common_title_columns()); numColItem.setValue(storedDashboard.getColumns()); ButtonItem addColumn = new ButtonItem("addColumn", MSG.common_title_add_column()); addColumn.setAutoFit(true); addColumn.setStartRow(false); addColumn.setEndRow(false); final ButtonItem removeColumn = new ButtonItem("removeColumn", MSG.common_title_remove_column()); removeColumn.setAutoFit(true); removeColumn.setStartRow(false); removeColumn.setEndRow(false); removeColumn.setDisabled(storedDashboard.getColumns() == 1); addColumn.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { portalLayout.addMember(new PortalColumn()); numColItem.setValue(storedDashboard.getColumns() + 1); storedDashboard.setColumns(storedDashboard.getColumns() + 1); removeColumn.setDisabled(storedDashboard.getColumns() == 1); save(); } }); removeColumn.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler() { public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) { Canvas[] columns = portalLayout.getMembers(); int numColumns = columns.length; if (numColumns > 0) { PortalColumn lastColumn = (PortalColumn) columns[numColumns - 1]; for (Canvas portletWindow : lastColumn.getMembers()) { storedDashboard.removePortlet(((PortletWindow) portletWindow).getStoredPortlet()); } portalLayout.removeMember(lastColumn); numColItem.setValue(numColumns - 1); storedDashboard.setColumns(storedDashboard.getColumns() - 1); removeColumn.setDisabled(storedDashboard.getColumns() == 1); save(); } } }); // build the menu of valid portlets for this context, sorted by portlet name final Menu addPortletMenu = new LocatableMenu(editForm.extendLocatorId("PortletMenu")); LinkedHashMap<String, String> valueMap; switch (context.getType()) { case SubsystemView: valueMap = PortletFactory.getGlobalPortletMenuMap(); break; case ResourceGroup: valueMap = processPortletNameMapForGroup(this.groupComposite); // In addition to the group-specific portlets, make the global portlets available valueMap.putAll(PortletFactory.getGlobalPortletMenuMap()); break; case Resource: valueMap = processPortletNameMapForResource(this.resourceComposite); // In addition to the resource-specific portlets, make the global portlets available valueMap.putAll(PortletFactory.getGlobalPortletMenuMap()); break; default: throw new IllegalStateException("Unsupported context [" + context + "]"); } for (Iterator<String> i = valueMap.keySet().iterator(); i.hasNext(); ) { String portletKey = i.next(); String portletName = valueMap.get(portletKey); MenuItem menuItem = new MenuItem(portletName); menuItem.setAttribute("portletKey", portletKey); addPortletMenu.addItem(menuItem); } addPortlet = new LocatableIMenuButton( editForm.extendLocatorId("AddPortlet"), MSG.common_title_add_portlet(), addPortletMenu); addPortlet.setIcon("[skin]/images/actions/add.png"); addPortlet.setAutoFit(true); addPortletMenu.addItemClickHandler( new ItemClickHandler() { public void onItemClick(ItemClickEvent itemClickEvent) { String key = itemClickEvent.getItem().getAttribute("portletKey"); String name = itemClickEvent.getItem().getTitle(); addPortlet(key, name); } }); CanvasItem addCanvas = new CanvasItem(); addCanvas.setShowTitle(false); addCanvas.setCanvas(addPortlet); addCanvas.setStartRow(false); addCanvas.setEndRow(false); ColorButtonItem picker = new ColorButtonItem("colorButton", MSG.common_title_background()); picker.setStartRow(false); picker.setEndRow(false); picker.setCurrentColor( storedDashboard.getConfiguration().getSimpleValue(Dashboard.CFG_BACKGROUND, "white")); picker.setColorSelectedHandler( new ColorSelectedHandler() { @Override public void onColorSelected(ColorSelectedEvent event) { String selectedColor = event.getColor(); if (selectedColor != null) { setBackgroundColor(selectedColor); storedDashboard .getConfiguration() .put(new PropertySimple(Dashboard.CFG_BACKGROUND, selectedColor)); save(); } } }); // refresh interval LocatableMenu refreshMenu = new LocatableMenu("AutoRefreshMenu"); refreshMenu.setShowShadow(true); refreshMenu.setShadowDepth(10); refreshMenu.setAutoWidth(); refreshMenu.setHeight(15); ClickHandler menuClick = new ClickHandler() { @Override public void onClick(MenuItemClickEvent event) { String selection = event.getItem().getTitle(); refreshInterval = 0; if (selection != null) { if (selection.equals(STOP)) { refreshInterval = STOP_VALUE; } else if (selection.equals(REFRESH1)) { refreshInterval = REFRESH1_VALUE; } else if (selection.equals(REFRESH5)) { refreshInterval = REFRESH5_VALUE; } else if (selection.equals(REFRESH10)) { refreshInterval = REFRESH10_VALUE; } else { // unable to locate value disable refresh refreshInterval = STOP_VALUE; // } UserSessionManager.getUserPreferences() .setPageRefreshInterval(refreshInterval, new UpdatePortletRefreshCallback()); } } }; String[] refreshIntervals = {STOP, REFRESH1, REFRESH5, REFRESH10}; Integer[] refreshValues = {STOP_VALUE, REFRESH1_VALUE, REFRESH5_VALUE, REFRESH10_VALUE}; refreshMenuMappings = new HashMap<Integer, String>(); refreshMenuItems = new MenuItem[refreshIntervals.length]; int retrievedRefreshInterval = REFRESH1_VALUE; if (null != UserSessionManager.getUserPreferences()) { retrievedRefreshInterval = UserSessionManager.getUserPreferences().getPageRefreshInterval(); } for (int i = 0; i < refreshIntervals.length; i++) { MenuItem item = new MenuItem(refreshIntervals[i], ""); item.addClickHandler(menuClick); refreshMenuMappings.put(refreshValues[i], refreshIntervals[i]); if (retrievedRefreshInterval == refreshValues[i]) { item.setIcon(ImageManager.getAvailabilityIcon(true)); } refreshMenuItems[i] = item; } refreshMenu.setItems(refreshMenuItems); refreshMenuButton = new LocatableIMenuButton( "AutoRefreshButton", MSG.common_title_change_refresh_time(), refreshMenu); refreshMenu.setAutoHeight(); refreshMenuButton.getMenu().setItems(refreshMenuItems); refreshMenuButton.setWidth(140); refreshMenuButton.setShowTitle(true); refreshMenuButton.setTop(0); refreshMenuButton.setIconOrientation("left"); CanvasItem refreshCanvas = new CanvasItem(); refreshCanvas.setShowTitle(false); refreshCanvas.setCanvas(refreshMenuButton); refreshCanvas.setStartRow(false); refreshCanvas.setEndRow(false); if (null != nameItem) { editForm.setItems( nameItem, addCanvas, numColItem, addColumn, removeColumn, picker, refreshCanvas); } else { editForm.setItems(addCanvas, numColItem, addColumn, removeColumn, picker, refreshCanvas); } updateRefreshMenu(); this.refreshMenuButton.markForRedraw(); markForRedraw(); // attempt to initialize editForm.markForRedraw(); markForRedraw(); return editForm; }
/** 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 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); }
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; }