public Bottom() { setWidth100(); setHeight(20); Label about = new Label("Information Center 08. Copyright 2010 - 2011. "); about.setWidth100(); about.setHeight100(); about.setAlign(Alignment.RIGHT); about.setStyleName("abouttext"); setMembers(about); addShowContextMenuHandler( new ShowContextMenuHandler() { @Override public void onShowContextMenu(ShowContextMenuEvent event) { event.cancel(); } }); }
private Label buildSecondaryMenuOption(final String title, boolean selected) { Label tmp = new Label(title); tmp.setTitle(title); tmp.setWrap(false); tmp.setValign(VerticalAlignment.BOTTOM); tmp.setAlign(Alignment.CENTER); tmp.setPadding(10); tmp.setShowRollOver(true); tmp.setCursor(Cursor.POINTER); String style; if (selected) { style = "secondaryMenuText-selected"; selectedSecondaryMenuOption = tmp; } else { style = "secondaryMenuText"; } tmp.setBaseStyle(style); tmp.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { Object o = event.getSource(); if (o instanceof Label) { Label lbl = (Label) o; if (!lbl.getTitle().equals(selectedSecondaryMenuOption.getTitle())) { selectedSecondaryMenuOption.setBaseStyle("secondaryMenuText"); lbl.setBaseStyle("secondaryMenuText-selected"); selectedSecondaryMenuOption = lbl; BLCMain.setCurrentPageKey(lbl.getTitle()); buildHistoryNewItem( lbl.getTitle(), BLCLaunch.getSelectedModule(History.getToken()), null); } } } }); return tmp; }
public UpgradeLevelLayout(int x, int y) { this.setWidth(500); this.setHeight(300); this.setMembersMargin(5); this.setPadding(5); this.setBackgroundColor("#FFFFFF"); this.setBorder("1px solid #CCCCCC"); this.setOpacity(85); this.moveTo(x, y + 20); Label titleLabel = new Label("<b>User Levels:</b>"); titleLabel.setIcon(CoreConstants.ICON_USER_INFO); titleLabel.setHeight(30); this.addMember(titleLabel); HTMLPane pane = new HTMLPane(); pane.setWidth100(); pane.setHeight100(); pane.setOverflow(Overflow.AUTO); pane.setContentsURL("./documentation/user/user_levels.html"); pane.setContentsType(ContentsType.PAGE); this.addMember(pane); Label closeLabel = new Label("Close"); closeLabel.setIcon(CoreConstants.ICON_CLOSE); closeLabel.setHeight(25); closeLabel.setWidth100(); closeLabel.setAlign(Alignment.RIGHT); closeLabel.setCursor(Cursor.HAND); closeLabel.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { destroy(); } }); this.addMember(closeLabel); }
private Label buildPrimaryMenuOption(final Module module, boolean selected) { Label tmp = new Label(module.getModuleTitle()); tmp.setValign(VerticalAlignment.CENTER); tmp.setHeight(30); tmp.setAlign(Alignment.CENTER); tmp.setWrap(false); tmp.setPadding(0); tmp.setShowRollOver(true); tmp.setCursor(Cursor.POINTER); final String style; if (selected) { style = "primaryMenuText-selected"; } else { style = "primaryMenuText"; } tmp.setBaseStyle(style); tmp.addClickHandler( new ClickHandler() { @Override public void onClick(final ClickEvent event) { Object o = event.getSource(); if (o instanceof Label) { final Label lbl = (Label) o; if (!"primaryMenuText-selected".equals(lbl.getBaseStyle())) { selectPrimaryMenu(module.getModuleKey()); lbl.setBaseStyle("primaryMenuText-selected"); BLCMain.setCurrentModuleKey(module.getModuleKey()); buildSecondaryMenu(null, module.getModuleKey()); AppController.getInstance() .go(canvas, module.getPages(), null, module.getModuleKey(), false); } } } }); return tmp; }
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 Canvas getViewPanel() { HStack hStack = new HStack(); hStack.setWidth(300); hStack.setHeight(100); hStack.setShowEdges(true); hStack.setCanAcceptDrop(true); hStack.setAnimateMembers(true); hStack.setDropLineThickness(4); final Label focusLabel = new Label(); focusLabel.setID("focusLabel"); focusLabel.setAlign(Alignment.CENTER); focusLabel.setTop(150); focusLabel.setWidth(300); focusLabel.setHeight(50); final Img bluePawn = new Img(); bluePawn.setID("bluePawn"); bluePawn.setLayoutAlign(Alignment.CENTER); bluePawn.setWidth(48); bluePawn.setHeight(48); bluePawn.setCanFocus(true); bluePawn.setSrc("pieces/48/pawn_blue.png"); bluePawn.setCanDragReposition(true); bluePawn.setCanDrop(true); bluePawn.setDragAppearance(DragAppearance.TARGET); bluePawn.addDrawHandler( new DrawHandler() { public void onDraw(DrawEvent event) { bluePawn.focus(); } }); bluePawn.addFocusChangedHandler( new FocusChangedHandler() { public void onFocusChanged(FocusChangedEvent event) { changeLabel(focusLabel, bluePawn.getID(), event.getHasFocus()); } }); ComboBoxItem field1 = new ComboBoxItem(); field1.setName("field1"); field1.setValueMap("Option 1", "Option 2"); DateItem field2 = new DateItem(); field2.setName("field2"); final DynamicForm simpleForm = new DynamicForm(); simpleForm.setID("simpleForm"); simpleForm.setLayoutAlign(Alignment.CENTER); simpleForm.setHeight(48); simpleForm.setFields(field1, field2); simpleForm.addFocusChangedHandler( new FocusChangedHandler() { public void onFocusChanged(FocusChangedEvent event) { changeLabel(focusLabel, simpleForm.getID(), event.getHasFocus()); } }); final Img greenPawn = new Img(); greenPawn.setID("greenPawn"); greenPawn.setLayoutAlign(Alignment.CENTER); greenPawn.setWidth(48); greenPawn.setHeight(48); greenPawn.setCanFocus(true); greenPawn.setSrc("pieces/48/pawn_green.png"); greenPawn.setCanDragReposition(true); greenPawn.setCanDrop(true); greenPawn.setDragAppearance(DragAppearance.TARGET); greenPawn.addFocusChangedHandler( new FocusChangedHandler() { public void onFocusChanged(FocusChangedEvent event) { changeLabel(focusLabel, greenPawn.getID(), event.getHasFocus()); } }); hStack.addMember(bluePawn); hStack.addMember(simpleForm); hStack.addMember(greenPawn); VLayout vLayout = new VLayout(); vLayout.setMembersMargin(10); vLayout.addMember(hStack); vLayout.addMember(focusLabel); return vLayout; }
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 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 void build() { final VLayout layout = new VLayout(); layout.setMargin(5); final VStack infraLayout = new VStack(); infraLayout.setHeight(26); final Label infraLabel = new Label("Updating available Infrastructures and Policies"); infraLabel.setIcon("loading.gif"); infraLabel.setHeight(26); infraLabel.setAlign(Alignment.CENTER); infraLayout.addMember(infraLabel); final DynamicForm infraForm = new DynamicForm(); infraForm.setEncoding(Encoding.MULTIPART); infraForm.setMethod(FormMethod.POST); infraForm.setAction(GWT.getModuleBaseURL() + "createnodesource"); infraForm.setTarget("__hiddenFrame"); infraLayout.addMember(infraForm); final Label label = new Label( "A Node Source is a combination of an Infrastructure, which defines how resources" + " will be acquired, and a Policy, that dictates when resources can be acquired."); label.setHeight(40); final HashMap<String, List<FormItem>> allForms = new HashMap<String, List<FormItem>>(); controller.fetchSupportedInfrastructuresAndPolicies( new Runnable() { public void run() { infraSelect = new SelectItem("infra", "Infrastructure"); infraSelect.setRequired(true); policySelect = new SelectItem("policy", "Policy"); policySelect.setRequired(true); infraSelect.setWidth(300); policySelect.setWidth(300); HiddenItem name = new HiddenItem("nsName"); HiddenItem callback = new HiddenItem("nsCallback"); HiddenItem session = new HiddenItem("sessionId"); ArrayList<FormItem> tmpAll = new ArrayList<FormItem>(); tmpAll.add(name); tmpAll.add(callback); tmpAll.add(session); tmpAll.add(infraSelect); LinkedHashMap<String, String> values = new LinkedHashMap<String, String>(); for (PluginDescriptor inf : controller.getModel().getSupportedInfrastructures().values()) { String shortName = inf.getPluginName().substring(inf.getPluginName().lastIndexOf('.') + 1); values.put(inf.getPluginName(), shortName); List<Field> configurableFields = inf.getConfigurableFields(); ArrayList<FormItem> forms = new ArrayList<FormItem>(configurableFields.size()); for (Field f : configurableFields) { FormItem infra = null; if (f.isPassword()) { infra = new PasswordItem(inf.getPluginName() + f.getName(), f.getName()); } else if (f.isFile() || f.isCredential()) { infra = new UploadItem(inf.getPluginName() + f.getName(), f.getName()); if (f.isCredential()) { PickerIcon cred = new PickerIcon( new Picker(Images.instance.key_16().getSafeUri().asString()), new FormItemClickHandler() { @Override public void onFormItemClick(FormItemIconClickEvent event) { CredentialsWindow win = new CredentialsWindow(); win.show(); } }); cred.setPrompt("Create a Credential file"); cred.setWidth(16); cred.setHeight(16); cred.setAttribute("hspace", 6); infra.setIcons(cred); } } else { infra = new TextItem(inf.getPluginName() + f.getName(), f.getName()); } infra.setValue(f.getValue()); infra.setWidth(250); infra.setHint("<nobr>" + f.getDescription() + "</nobr>"); forms.add(infra); tmpAll.add(infra); } allForms.put(inf.getPluginName(), forms); } infraSelect.setValueMap(values); tmpAll.add(new SpacerItem()); values.clear(); tmpAll.add(policySelect); for (PluginDescriptor inf : controller.getModel().getSupportedPolicies().values()) { String shortName = inf.getPluginName().substring(inf.getPluginName().lastIndexOf('.') + 1); values.put(inf.getPluginName(), shortName); List<Field> configurableFields = inf.getConfigurableFields(); ArrayList<FormItem> forms = new ArrayList<FormItem>(configurableFields.size()); for (Field f : configurableFields) { FormItem pol = null; if (f.isPassword()) { pol = new PasswordItem(inf.getPluginName() + f.getName(), f.getName()); } else if (f.isFile() || f.isCredential()) { pol = new UploadItem(inf.getPluginName() + f.getName(), f.getName()); if (f.isCredential()) { PickerIcon cred = new PickerIcon( new Picker(Images.instance.key_16().getSafeUri().asString()), new FormItemClickHandler() { @Override public void onFormItemClick(FormItemIconClickEvent event) { CredentialsWindow win = new CredentialsWindow(); win.show(); } }); cred.setPrompt("Create a Credential file"); cred.setWidth(16); cred.setHeight(16); cred.setAttribute("hspace", 6); pol.setIcons(cred); } } else { pol = new TextItem(inf.getPluginName() + f.getName(), f.getName()); } pol.setValue(f.getValue()); pol.setWidth(250); pol.setHint("<nobr>" + f.getDescription() + "</nobr>"); forms.add(pol); tmpAll.add(pol); } allForms.put(inf.getPluginName(), forms); } policySelect.setValueMap(values); infraSelectChanged = new Runnable() { @Override public void run() { if (policySelect.getValueAsString() == null) { return; } String nsName = infraSelect.getValueAsString(); if (oldInfra != null) { for (FormItem f : allForms.get(oldInfra)) { f.hide(); } } for (FormItem f : allForms.get(nsName)) { f.show(); } if (oldInfra == null) { oldInfra = nsName; policySelectChanged.run(); } else { oldInfra = nsName; } } }; policySelectChanged = new Runnable() { @Override public void run() { if (infraSelect.getValueAsString() == null) { return; } String policy = policySelect.getValueAsString(); if (oldPolicy != null) { for (FormItem f : allForms.get(oldPolicy)) { f.hide(); } } for (FormItem f : allForms.get(policy)) { f.show(); } if (oldPolicy == null) { oldPolicy = policy; infraSelectChanged.run(); } else { oldPolicy = policy; } } }; infraSelect.addChangedHandler( new ChangedHandler() { public void onChanged(ChangedEvent event) { infraSelectChanged.run(); } }); policySelect.addChangedHandler( new ChangedHandler() { public void onChanged(ChangedEvent event) { policySelectChanged.run(); } }); infraForm.setFields(tmpAll.toArray(new FormItem[tmpAll.size()])); infraLabel.hide(); infraForm.show(); for (List<FormItem> li : allForms.values()) { for (FormItem it : li) { it.hide(); } } } }, new Runnable() { @Override public void run() { window.hide(); } }); final TextItem nameItem = new TextItem("nsName", "Name"); DynamicForm nameForm = new DynamicForm(); nameForm.setFields(nameItem); HLayout buttons = new HLayout(); buttons.setWidth100(); buttons.setHeight(22); buttons.setMargin(5); buttons.setAlign(Alignment.RIGHT); buttons.setMembersMargin(5); final IButton okButton = new IButton("Ok"); okButton.setIcon(Images.instance.ok_16().getSafeUri().asString()); okButton.setShowDisabledIcon(false); final IButton cancelButton = new IButton("Cancel"); cancelButton.setIcon(Images.instance.cancel_16().getSafeUri().asString()); cancelButton.setShowDisabledIcon(false); okButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { infraForm.setValue("infra", infraSelect.getValueAsString()); infraForm.setValue("nsName", nameItem.getValueAsString()); infraForm.setValue("policy", policySelect.getValueAsString()); infraForm.setValue("sessionId", LoginModel.getInstance().getSessionId()); infraForm.setCanSubmit(true); /* this smartGWT form looks nice but cannot do callbacks ; * we register a native JS function to the document, send it to * the servlet so that it writes it back when returning * when the browser reads the return value and interprets it as JS, * the callback is called */ infraForm.setValue( "nsCallback", JSUtil.register( new JSUtil.JSCallback() { public void execute(JavaScriptObject obj) { JSONObject js = new JSONObject(obj); if (js.containsKey("result") && js.get("result").isBoolean().booleanValue()) { window.hide(); LogModel.getInstance() .logMessage( "Successfully created nodesource: " + nameItem.getValueAsString()); } else { String msg; if (js.get("errorMessage").isString() != null) { msg = js.get("errorMessage").isString().stringValue(); } else { msg = js.toString(); } label.setContents( "<span style='color:red'>Failed to create Node Source :<br>" + msg + "</span>"); LogModel.getInstance() .logImportantMessage( "Failed to create nodesource " + nameItem.getValueAsString() + ": " + msg); layout.scrollToTop(); } infraLabel.hide(); infraForm.show(); okButton.setDisabled(false); cancelButton.setDisabled(false); } })); infraForm.submitForm(); cancelButton.setDisabled(true); okButton.setDisabled(true); infraLabel.setContents("Node Source creation requested..."); infraLabel.show(); infraForm.hide(); } }); cancelButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { window.hide(); } }); buttons.setMembers(okButton, cancelButton); VLayout scroll = new VLayout(); scroll.setHeight100(); scroll.setWidth100(); scroll.setMembers(infraLayout); scroll.setOverflow(Overflow.AUTO); scroll.setBorder("1px solid #ddd"); scroll.setBackgroundColor("#fafafa"); layout.addMember(label); layout.addMember(nameForm); layout.addMember(scroll); layout.addMember(buttons); int winWidth = com.google.gwt.user.client.Window.getClientWidth() * 80 / 100; int winHeight = com.google.gwt.user.client.Window.getClientHeight() * 80 / 100; winWidth = Math.min(1000, winWidth); winHeight = Math.min(1000, winHeight); this.window = new Window(); this.window.setTitle("Create Node Source"); this.window.setShowMinimizeButton(false); this.window.setIsModal(true); this.window.setShowModalMask(true); this.window.addItem(layout); this.window.setWidth(winWidth); this.window.setHeight(winHeight); this.window.setCanDragResize(true); this.window.setCanDragReposition(true); this.window.centerInPage(); }
public RepositoryNameView(final Console console) { super(); setStyleName("repository"); setLayoutAlign(Alignment.CENTER); setLayoutAlign(VerticalAlignment.CENTER); setDefaultLayoutAlign(Alignment.CENTER); setDefaultLayoutAlign(VerticalAlignment.CENTER); setHeight(55); setWidth100(); Img logo = new Img(); logo.setSrc("icons/attach.png"); logo.setHeight(55); logo.setWidth(45); logo.setValign(VerticalAlignment.CENTER); HLayout panel0 = new HLayout(); HLayout panel1 = new HLayout(); panel1.setLayoutAlign(Alignment.RIGHT); panel1.setDefaultLayoutAlign(Alignment.RIGHT); panel1.setAlign(Alignment.RIGHT); HLayout panel = new HLayout(); // panel.setAlign(Alignment.LEFT); panel.setLayoutAlign(VerticalAlignment.CENTER); panel.setDefaultLayoutAlign(VerticalAlignment.CENTER); label.setStyleName("repository-caption"); label.setWidth("100%"); label.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { console.showRepositories(); } }); label.setBorder("1 px solid black"); label.setValign(VerticalAlignment.CENTER); Label explore = new Label("<b>Explore</b>"); explore.setAlign(Alignment.RIGHT); explore.setBorder("1ps solid green"); explore.setAutoFit(true); explore.setStyleName("tab-label"); explore.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { console.showContent(); } }); Label nodeTypes = new Label("<b>NodeTypes</b>"); nodeTypes.setAlign(Alignment.RIGHT); nodeTypes.setAutoFit(true); nodeTypes.setStyleName("tab-label"); nodeTypes.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { console.showNodeTypes(); } }); Label descriptor = new Label("<b>Descriptor</b>"); descriptor.setAlign(Alignment.RIGHT); descriptor.setAutoFit(true); descriptor.setStyleName("tab-label"); descriptor.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { console.showRepositoryInfo(); } }); Label query = new Label("<b>Query</b>"); query.setAlign(Alignment.RIGHT); query.setAutoFit(true); query.setStyleName("tab-label"); query.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { console.showQuery(); } }); panel.addMember(logo); panel.addMember(label); panel1.addMember(explore); panel1.addMember(new Spacer(10)); panel1.addMember(nodeTypes); panel1.addMember(new Spacer(10)); panel1.addMember(descriptor); panel1.addMember(new Spacer(10)); panel1.addMember(query); panel1.setHeight(55); panel0.setWidth("70%"); panel0.setHeight(55); panel0.addMember(panel); panel0.addMember(panel1); addMember(new Strut(10)); addMember(panel0); addMember(new Strut(10)); setVisible(false); }
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); } }); }
// private final MapServiceInfoAsync mapServiceInfo = GWT.create(MapServiceInfo.class); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public Authorization(final AsyncCallback<String> callback) { super(WINDOW_TITLE, WIDTH, HEIGHT, callback); this.setShowMinimizeButton(false); VLayout layout = new VLayout(); layout.layoutChildren(null); accountForm = new DynamicForm(); accountForm.setWidth100(); accountForm.setPadding(5); // backGround.setBorder("1px solid #ff0"); TextItem login = new TextItem(CONTROL_LOGIN); login.setTitle(CAPTION_LOGIN); PasswordItem password = new PasswordItem(CONTROL_PASSWORD); password.setTitle(CAPTION_PASSWORD); password.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(KeyPressEvent keyPressEvent) { // com.google.gwt.user.client.Window.alert("" + // keyPressEvent.getKeyName()); if (keyPressEvent.getKeyName().equalsIgnoreCase("ENTER")) onOkClick(); } }); accountForm.setFields(login, password); Label linkRegistration = null; if (GWTViewer.config.withRegistration()) { linkRegistration = new Label(); linkRegistration.setAlign(Alignment.RIGHT); linkRegistration.setStyleName(CSS_LABEL_LINK); linkRegistration.setHeight(20); linkRegistration.setWidth(265); linkRegistration.setContents(REGISTRATION); linkRegistration.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { callback.onSuccess(CMD_REGISTRATION); closeForm(); } }); } labelException = new Label(); labelException.setAlign(Alignment.CENTER); labelException.setStyleName(CSS_LABEL_ERROR); labelException.setHeight(35); labelException.setWidth100(); labelException.setMargin(5); // labelException.setBorder("1px solid #0aa"); labelException.setContents(""); HLayout controlPanel = new HLayout(); controlPanel.setHeight("30px"); controlPanel.setLayoutLeftMargin(55); Button btnOk = null; btnOk = new Button("Ok"); btnOk.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { onOkClick(); } }); Button btnClose = new Button(CAPTION_CLOSE); btnClose.setTop(10); btnClose.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { closeForm(); } }); controlPanel.addMember(btnOk); controlPanel.addMember(btnClose); layout.addMember(accountForm); if (linkRegistration != null) layout.addMember(linkRegistration); layout.addMember(labelException); layout.addMember(controlPanel); addItem(layout); }