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(); } }); }
public Canvas getViewPanel() { Label label = new Label( "Staging: <span style=\"color: green; font-weight: bold;\">Normal</span><br/>" + "Production: <span style=\"color: green; font-weight: bold;\">Normal</span><br/>" + "Development: <span style=\"color: green; font-weight: bold;\">Normal</span>"); label.setHeight100(); label.setPadding(5); label.setValign(VerticalAlignment.TOP); Window window = new Window(); window.setTitle("Minimizing a window"); window.setWidth(300); window.setHeight(85); window.setCanDragResize(true); window.addItem(label); Canvas canvasMain = new Canvas(); canvasMain.addChild(window); return canvasMain; }
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(); } }); }