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); }
FlashUploadComponentImpl(final UploadComponentOptions options) { filesGrid.setHeight(100); filesGrid.setWidth100(); if (options.isAllowMultiple()) { filesGrid.setEmptyMessage("No files selected."); } else { filesGrid.setEmptyMessage("File not selected."); } final ListGridField nameField = new ListGridField("name", "File Name"); nameField.setType(ListGridFieldType.TEXT); nameField.setWidth("*"); filesGrid.setFields(nameField); final UploadBuilder builder = new UploadBuilder(); // Configure which file types may be selected if (options.getTypes() != null) { builder.setFileTypes(options.getTypes()); } if (options.getTypesDescription() != null) { builder.setFileTypesDescription(options.getTypesDescription()); } if (options.getTypesDescription() != null) { builder.setFileTypesDescription(options.getTypesDescription()); } clientId = getUniqueId(); final HTMLPane pane = new HTMLPane(); pane.setHeight(22); builder.setButtonPlaceholderID(clientId); builder.setButtonHeight(22); builder.setButtonWidth(100); pane.setWidth(100); if (options.isAllowMultiple()) { builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageAddFiles.jpg"); } else { builder.setButtonImageURL(GWT.getHostPageBaseURL() + "images/uploadImageChooseFile.jpg"); } // Use ButtonAction.SELECT_FILE to only allow selection of a single file builder.setButtonAction( options.isAllowMultiple() ? ButtonAction.SELECT_FILES : ButtonAction.SELECT_FILE); builder.setFileQueuedHandler( new FileQueuedHandler() { public void onFileQueued(final FileQueuedEvent queuedEvent) { if (!options.isAllowMultiple()) { SmartUtils.removeAllRecords(filesGrid); } final ListGridRecord record = new ListGridRecord(); record.setAttribute("id", queuedEvent.getFile().getId()); record.setAttribute("name", queuedEvent.getFile().getName()); filesGrid.addData(record); } }); builder.setUploadSuccessHandler( new UploadSuccessHandler() { public void onUploadSuccess(final UploadSuccessEvent uploadEvent) { try { filesUploaded++; bytesUploaded += uploadEvent.getFile().getSize(); final String serverResponse = uploadEvent.getServerData(); fileSources.addAll(toFileSources(serverResponse)); updateUrl(); if (upload.getStats().getFilesQueued() > 0) { upload.startUpload(); } else { options.getCompletionCallback().onSuccess(fileSources); } } catch (final Exception e) { options.getCompletionCallback().onFailure(e); } } }); builder.setUploadErrorHandler( new UploadErrorHandler() { public void onUploadError(final UploadErrorEvent e) { options .getCompletionCallback() .onFailure(new Exception("Upload failed " + e.getMessage())); } }); // The button to start the transfer final Layout parent = getParentCanvas(options); setWidget(parent); // pane.setMargin(5); pane.setContents("<span id=\"" + clientId + "\" />"); reg = get() .addDrawHandler( new DrawHandler() { public void onDraw(final DrawEvent event) { upload = builder.build(); reg.removeHandler(); } }); final Button removeButton = SmartUtils.getButton("Remove File", Resources.CROSS); removeButton.addClickHandler( new ClickHandler() { public void onClick(final ClickEvent event) { final ListGridRecord record = filesGrid.getSelectedRecord(); final String id = record.getAttribute("id"); filesGrid.removeData(record); upload.cancelUpload(id, false); } }); SmartUtils.enabledWhenHasSelection(removeButton, filesGrid); removeButton.setDisabled(true); if (!options.isAllowMultiple()) { removeButton.hide(); } final CanvasWithOpsLayout<ClientListGrid> layout = new CanvasWithOpsLayout<ClientListGrid>(filesGrid, pane, removeButton); if (debug) { layout.setBorder("1px solid red"); parent.setBorder("1px solid orange"); } parent.addMember(layout); }