private void update() { if (currentCanvas != null) { currentCanvas.hide(); } currentComponent = components.get(currentType); currentCanvas = currentComponent.get(); currentCanvas.show(); }
private void reset(final UploadComponentOptions options) { resetComponents(options); clear(); final Set<String> types = components.keySet(); currentType = types.iterator().next(); parentCanvas = new Canvas(); layout = new VLayout(); final SelectItem typeItem = new SelectItem("uploadType", "Upload Type"); typeItem.setValueMap(types.toArray(new String[types.size()])); typeItem.setValue(currentType); typeItem.setWidth(250); typeItem.addChangedHandler( new ChangedHandler() { public void onChanged(final ChangedEvent event) { currentType = typeItem.getValue().toString(); update(); } }); final Form form = new Form( DomConstants.buildConstant(DomConstants.UPLOAD_COMPONENT_TYPE, uploadComponentNumber), typeItem); form.setPadding(0); form.setMargin(0); form.setCellSpacing(0); form.setCellPadding(0); form.setAlign(Alignment.RIGHT); form.setWidth(350); form.setHeight(20); final HLayout header = new HLayout(); header.setAlign(Alignment.RIGHT); header.addMember(form); header.setHeight(20); layout.setAlign(Alignment.RIGHT); layout.addMember(header); layout.addMember(parentCanvas); layout.setGroupTitle("File Chooser"); layout.setIsGroup(true); layout.setHeight("185px"); layout.setPadding(2); layout.setLayoutAlign(Alignment.CENTER); layout.setAlign(Alignment.CENTER); for (final UploadComponent uploadComponent : components.values()) { final Canvas childCanvas = uploadComponent.get(); childCanvas.hide(); parentCanvas.addChild(childCanvas); } update(); wrapperLayout.addMember(layout); }