List of usage examples for com.google.gwt.user.client.ui FileUpload setName
public void setName(String name)
From source file:com.GTDF.client.GWT_Transxchange2GoogleTransit.java
License:Apache License
public void onModuleLoad() { String wikiUserName = readUsername(); //Service Start final TextBox textBoxServiceStartGz = new TextBox(); TabPanel tabs = new TabPanel(); tabs.setStyleName(".gwt-TabBar"); tabs.setWidth("100%"); tabs.setHeight("100%"); //-------------------------EDJ ---------------- DockPanel dock = new DockPanel(); dock.setSize("663px", "220px"); dock.setStyleName("gwt-TabBar"); VerticalPanel TransformWindow = new VerticalPanel(); TransformWindow.setStyleName("weather-input-panel"); //Agency URL//from w ww .j a v a2s.c om HorizontalPanel AgencyURL = new HorizontalPanel(); Label url_lbl = new Label("Agency URL:"); url_lbl.setWidth("90"); final TextBox textBoxUrl = new TextBox(); textBoxUrl.setText("http://www.agency.org"); textBoxUrl.setVisibleLength(40); AgencyURL.add(url_lbl); AgencyURL.add(textBoxUrl); //----------- //Route Type HorizontalPanel RType = new HorizontalPanel(); Label rt_lbl = new Label("Route Type:"); rt_lbl.setWidth("90"); final ListBox listBoxDefaultRouteType = new ListBox(); listBoxDefaultRouteType.setVisibleItemCount(1); listBoxDefaultRouteType.addItem("Tram"); listBoxDefaultRouteType.addItem("Subway"); listBoxDefaultRouteType.addItem("Rail"); listBoxDefaultRouteType.addItem("Bus"); listBoxDefaultRouteType.addItem("Ferry"); listBoxDefaultRouteType.addItem("Cable car"); listBoxDefaultRouteType.addItem("Gondola"); listBoxDefaultRouteType.addItem("Funicular"); listBoxDefaultRouteType.setSelectedIndex(0); RType.add(rt_lbl); RType.add(listBoxDefaultRouteType); //----------- //Time Zone VerticalPanel TZ = new VerticalPanel(); Label tz_lbl = new Label("Time Zone:"); tz_lbl.setWidth("90"); HorizontalPanel Continent = new HorizontalPanel(); Label continent_lbl = new Label("Continent:"); continent_lbl.setWidth("90"); final ListBox listBoxTimezoneP = new ListBox(); listBoxTimezoneP.addItem("Africa"); listBoxTimezoneP.addItem("America"); listBoxTimezoneP.addItem("Antarctica"); listBoxTimezoneP.addItem("Artic"); listBoxTimezoneP.addItem("Asia"); listBoxTimezoneP.addItem("Atlantic"); listBoxTimezoneP.addItem("Australia"); listBoxTimezoneP.addItem("Europe"); listBoxTimezoneP.addItem("Indian"); listBoxTimezoneP.addItem("Pacific"); listBoxTimezoneP.setVisibleItemCount(1); listBoxTimezoneP.setSelectedIndex(0); Continent.add(continent_lbl); Continent.add(listBoxTimezoneP); HorizontalPanel Region = new HorizontalPanel(); Label region_lbl = new Label("Region:"); region_lbl.setWidth("90"); final ListBox listBoxTimezoneS = new ListBox(); switchTimezone(listBoxTimezoneS, 0); Region.add(region_lbl); Region.add(listBoxTimezoneS); TZ.add(tz_lbl); TZ.add(Continent); TZ.add(Region); //----------- Button dialogButton = new Button("Show Dialog", new ClickListener() { public void onClick(Widget sender) { //EDJ DialogBox dlg = new MyDialog(); int left = 120; int top = 300; dlg.setPopupPosition(left, top); dlg.show(); } }); final Label labelOutdir = new Label(); // Displays wikiuser final Label labelResultGz = new Label(); final Label labelResult = new Label(); final Label labelResultUser = new Label(); final FormPanel uploadFormGz = new FormPanel(); uploadFormGz.setAction(GWT.getModuleBaseURL() + "upload"); uploadFormGz.setEncoding(FormPanel.ENCODING_MULTIPART); uploadFormGz.setMethod(FormPanel.METHOD_POST); //Upload final HorizontalPanel uploadPanelGz = new HorizontalPanel(); Label upload_lbl = new Label("Upload File:"); upload_lbl.setWidth("90"); uploadPanelGz.add(upload_lbl); //uploadPanelGz.add(upload_tb); //uploadPanelGz.add(upload_btn); //-------------- // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table final Hidden hwGz = new Hidden("username", wikiUserName); uploadPanelGz.add(hwGz); // Add hidden widget to pass service start to FileUploadServlet final Hidden ssGz = new Hidden("prefix"); uploadPanelGz.add(ssGz); final FileUpload uploadGz = new FileUpload(); uploadGz.setName("uploadFormElement"); uploadPanelGz.add(uploadGz); //final VerticalPanel uploadPanelGz = new VerticalPanel(); uploadFormGz.setWidget(uploadPanelGz); /* * Add Transxchange2GoogleTransit file upload */ final FormPanel uploadForm = new FormPanel(); uploadForm.setAction(GWT.getModuleBaseURL() + "upload"); uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); final VerticalPanel uploadPanel = new VerticalPanel(); uploadForm.setWidget(uploadPanel); // Add hidden widget to pass user name to FileUploadServlet for verification against wiki user table final Hidden hw = new Hidden("username", wikiUserName); uploadPanel.add(hw); final FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); uploadPanel.add(upload); /* * Verify user and enable action buttons if user exists */ WikiUserServiceAsync wikiUserService = (WikiUserServiceAsync) GWT.create(WikiUserService.class); ServiceDefTarget endpoint = (ServiceDefTarget) wikiUserService; String moduleRelativeURL = GWT.getModuleBaseURL() + "WikiUser"; endpoint.setServiceEntryPoint(moduleRelativeURL); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { Button buttonGz = new Button("Upload", new ClickListener() { public void onClick(Widget sender) { // Extract service start and pass as prefix String serviceStart = textBoxServiceStartGz.getText(); ssGz.setValue(serviceStart); // Upload selected infile to server uploadFormGz.submit(); //EDJ DialogBox dlg = new MyDialog(); int left = 120; int top = 300; dlg.setPopupPosition(left, top); dlg.show(); } }); Button button = new Button("Transform", new ClickListener() { public void onClick(Widget sender) { // Upload selected infile to server uploadForm.submit(); } }); if (result != "LOGGED") { button.setEnabled(false); buttonGz.setEnabled(false); labelResultUser.setText((String) result); } uploadPanel.add(button); uploadPanelGz.add(buttonGz); } public void onFailure(Throwable caught) { try { throw caught; } catch (InvocationException e) { labelResult.setText("InvocationException: " + e.getMessage()); } catch (Throwable e) { labelResult.setText("callback failed: " + e.getMessage()); } } }; wikiUserService.wikiUserVerify(wikiUserName, callback); /* * Upload google_transit.zip file */ uploadFormGz.addFormHandler(new FormHandler() { public void onSubmitComplete(FormSubmitCompleteEvent event) { labelResultGz.setText((String) event.getResults()); } public void onSubmit(FormSubmitEvent event) { // Upload infile to server String inFilename = uploadGz.getFilename(); if (inFilename.length() == 0) { Window.alert("Infile required"); return; } } }); /* * Upload TransXChange file and call Transxchange2GoogleTransit servlet when "transform" button is pushed */ uploadForm.addFormHandler(new FormHandler() { public void onSubmitComplete(FormSubmitCompleteEvent event) { labelResult.setText((String) event.getResults()); // Start transformation String parseArgs = upload.getFilename(); parseArgs = parseArgs + " " + textBoxUrl.getText(); parseArgs = parseArgs + " " + listBoxTimezoneP.getItemText(listBoxTimezoneP.getSelectedIndex()); String helpString = listBoxTimezoneS.getItemText(listBoxTimezoneS.getSelectedIndex()); parseArgs = parseArgs + "/" + helpString.substring(0, helpString.indexOf(' ')); parseArgs = parseArgs + " " + listBoxDefaultRouteType.getSelectedIndex(); parseArgs = parseArgs + " " + labelOutdir.getText(); // call server through GWT asynchronous RPC Transxchange2GoogleTransitServiceAsync transxchange2GoogleTransitService = (Transxchange2GoogleTransitServiceAsync) GWT .create(Transxchange2GoogleTransitService.class); ServiceDefTarget endpoint = (ServiceDefTarget) transxchange2GoogleTransitService; String moduleRelativeURL = GWT.getModuleBaseURL() + "GTDF"; endpoint.setServiceEntryPoint(moduleRelativeURL); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { labelResult.setText((String) result); } public void onFailure(Throwable caught) { try { throw caught; } catch (InvocationException e) { labelResult.setText("InvocationException: " + e.getMessage()); } catch (Throwable e) { labelResult.setText("callback failed: " + e.getMessage()); } } }; transxchange2GoogleTransitService.transxchange2GoogleTransit_transform(parseArgs, callback); } public void onSubmit(FormSubmitEvent event) { // Upload infile to server String inFilename = upload.getFilename(); if (inFilename.length() == 0) { Window.alert("Infile required"); return; } } }); /* * Add UI elements * Better practice (for future reference): use CSS */ TransformWindow.add(AgencyURL); TransformWindow.add(RType); TransformWindow.add(TZ); TransformWindow.add(uploadPanelGz); TransformWindow.add(uploadPanel); TransformWindow.add(dialogButton); tabs.add(TransformWindow, "TransXChange"); //tabs.add(TZ, "Transformation2"); tabs.selectTab(0); dock.add(tabs, DockPanel.CENTER); RootPanel.get("tab_area").add(dock); /* RootPanel.get("gz_servicestart").add(textBoxServiceStartGz); RootPanel.get("gz_infile").add(uploadFormGz); RootPanel.get("url").add(textBoxUrl); RootPanel.get("timezoneP").add(listBoxTimezoneP); RootPanel.get("timezoneS").add(listBoxTimezoneS); RootPanel.get("defaultroutetype").add(listBoxDefaultRouteType); RootPanel.get("outdir").add(labelOutdir); labelOutdir.setText(wikiUserName); RootPanel.get("user_result").add(labelResultUser); RootPanel.get("gz_result").add(labelResultGz); RootPanel.get("result").add(labelResult); RootPanel.get("infile").add(uploadForm); */ // Primary time zone (Africa, Europe, ...) selected listBoxTimezoneP.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { switchTimezone(listBoxTimezoneS, listBoxTimezoneP.getSelectedIndex()); } }); //---------------------------------------------------------------------------------------------- //----------------------------------------EDJ--------------------------------------------------- }
From source file:com.ikon.frontend.client.widget.upload.FileUploadForm.java
License:Open Source License
/** * FileUploadForm//from w ww . j a v a 2 s .c o m */ public FileUploadForm(FileUpload fileUpload, String size) { this.fileUpload = fileUpload; fileUpload.setStyleName("okm-Input"); fileUpload.getElement().setAttribute("size", size); // Set the name of the upload file form element fileUpload.setName("uploadFormElement"); uploadForm = new FormPanel(); vPanel = new VerticalPanel(); inputPath = new TextBox(); inputAction = new TextBox(); inputRenameDocument = new TextBox(); notifyToUser = new CheckBox(); importZip = new CheckBox(); versionComment = new TextArea(); users = new TextBox(); roles = new TextBox(); message = new TextArea(); // Set Form details // Set the action to call on submit uploadForm.setAction(RPCService.FileUploadService); // Set the form encoding to multipart to indicate a file upload uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); // Set the method to Post uploadForm.setMethod(FormPanel.METHOD_POST); inputPath.setName("path"); inputPath.setVisible(false); vPanel.add(inputPath); inputAction.setName("action"); inputAction.setVisible(false); vPanel.add(inputAction); inputRenameDocument.setName("rename"); inputRenameDocument.setVisible(false); vPanel.add(inputRenameDocument); notifyToUser.setName("notify"); notifyToUser.setVisible(false); vPanel.add(notifyToUser); importZip.setName("importZip"); importZip.setVisible(false); vPanel.add(importZip); versionComment.setName("comment"); versionComment.setVisible(false); vPanel.add(versionComment); users.setName("users"); users.setVisible(false); vPanel.add(users); roles.setName("roles"); roles.setVisible(false); vPanel.add(roles); message.setName("message"); message.setVisible(false); vPanel.add(message); vPanel.add(fileUpload); uploadForm.setWidget(vPanel); initWidget(uploadForm); }
From source file:com.openkm.frontend.client.widget.upload.FileUploadForm.java
License:Open Source License
/** * FileUploadForm//w w w. j ava2 s . c o m */ public FileUploadForm(FileUpload fileUpload, String size) { this.fileUpload = fileUpload; fileUpload.setStyleName("okm-Input"); fileUpload.getElement().setAttribute("size", size); // Set the name of the upload file form element fileUpload.setName("uploadFormElement"); uploadForm = new FormPanel(); vPanel = new VerticalPanel(); inputPath = new TextBox(); inputAction = new TextBox(); inputRenameDocument = new TextBox(); notifyToUser = new CheckBox(); importZip = new CheckBox(); versionComment = new TextArea(); mails = new TextBox(); users = new TextBox(); roles = new TextBox(); message = new TextArea(); increaseVersion = new TextBox(); // Set Form details // Set the action to call on submit uploadForm.setAction(RPCService.FileUploadService); // Set the form encoding to multipart to indicate a file upload uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); // Set the method to Post uploadForm.setMethod(FormPanel.METHOD_POST); inputPath.setName("path"); inputPath.setVisible(false); vPanel.add(inputPath); inputAction.setName("action"); inputAction.setVisible(false); vPanel.add(inputAction); inputRenameDocument.setName("rename"); inputRenameDocument.setVisible(false); vPanel.add(inputRenameDocument); notifyToUser.setName("notify"); notifyToUser.setVisible(false); vPanel.add(notifyToUser); importZip.setName("importZip"); importZip.setVisible(false); vPanel.add(importZip); versionComment.setName("comment"); versionComment.setVisible(false); vPanel.add(versionComment); mails.setName("mails"); mails.setVisible(false); vPanel.add(mails); users.setName("users"); users.setVisible(false); vPanel.add(users); roles.setName("roles"); roles.setVisible(false); vPanel.add(roles); message.setName("message"); message.setVisible(false); vPanel.add(message); increaseVersion.setName("increaseVersion"); increaseVersion.setText("0"); increaseVersion.setVisible(false); vPanel.add(increaseVersion); vPanel.add(fileUpload); uploadForm.setWidget(vPanel); initWidget(uploadForm); }
From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTableOperation.java
License:Apache License
/** * Constructor.//from ww w . j a v a2s .co m * * @param table * the table being affected * @param images * the images to use */ // CHECKSTYLE.OFF: CyclomaticComplexity public QPagingScrollTableOperation(final QPagingScrollTable table, ScrollTableOperationImages images) { this.table = table; if (this.table instanceof QPagingScrollTable) { ((QPagingScrollTable) this.table).setScrollTableOperations(this); } // Create the main widget HorizontalPanel hPanel = new HorizontalPanel(); initWidget(hPanel); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); setStyleName(DEFAULT_STYLENAME); // Create the paging image buttons createPageButtons(images); // Create the error label errorLabel = new HTML(); errorLabel.setStylePrimaryName("errorMessage"); // Add the widgets to the panel hPanel.add(createSpacer()); if (hasAddControl(table)) { hPanel.add(addImage); hPanel.add(createSpacer()); } if (hasDeleteControl(table)) { hPanel.add(deleteImage); hPanel.add(createSpacer()); } if (isEditableDatagrid(table) || hasDeleteControl(table) || hasAddControl(table)) { if (saveDatagrid(table)) { hPanel.add(saveImage); hPanel.add(createSpacer()); } if (refreshDatagrid(table)) { hPanel.add(refreshImage); hPanel.add(createSpacer()); } if (cancelDatagrid(table)) { hPanel.add(cancelImage); hPanel.add(createSpacer()); } } hPanel.add(errorLabel); if (table.getSource().getImportEnabled() != null && table.getSource().getImportEnabled().booleanValue()) { final DisclosurePanel importPanel = new DisclosurePanel("Upload data"); hPanel.add(importPanel); final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.datagridupload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); CheckBox isFirstLineHeader = new CheckBox("Is first row header ?"); isFirstLineHeader.setName("isFirstLineHeader"); isFirstLineHeader.setTitle( "Check wheter or not the first line of the uploaded file is a header/column definition"); HorizontalPanel hp = new HorizontalPanel(); Label label = new Label("Delimeter"); final TextBox delimiter = new TextBox(); delimiter.setValue(","); delimiter.setTitle("Insert the delimeter (can be any value, as long it's length 1)"); delimiter.setName("delimiter"); delimiter.setWidth("15px"); hp.setSpacing(10); hp.add(label); hp.add(delimiter); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(1, 0, isFirstLineHeader); gridPanel.setWidget(1, 1, hp); formPanel.add(gridPanel); formPanel.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { // This event is fired just before the form is submitted. We can // take // this opportunity to perform validation. if (delimiter.getText().length() == 0 || delimiter.getText().length() > 1) { ClientApplicationContext.getInstance().log("Ooops...Delimeter invalid", "Make sure there is valid delimeter value.One character only (current value ='" + delimiter.getText() + "'", true); event.cancel(); } } }); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); processData(uuId); importPanel.setOpen(false); } else { ClientApplicationContext.getInstance().log("Upload failed", event.getResults(), true); } } }); importPanel.add(formPanel); } if (table.getSource() != null && table.getSource().getExport() != null && table.getSource().getExport().booleanValue()) { createExportLabelsAndImages(); final DisclosurePanel exportPanel = new DisclosurePanel("Export"); String[] labels = getExportLabels(table.getSource().getExportFormats()); Image[] exportImages = getExportImages(labels); FlexTable gridExportPanel = new FlexTable(); hPanel.add(exportPanel); exportPanel.add(gridExportPanel); final Frame frame = new Frame(); frame.setHeight("0"); frame.setWidth("0"); frame.setVisible(false); final String moduleRelativeURL = GWT.getModuleBaseURL() + "/rpc.export"; gridExportPanel.setWidget(0, 0, frame); final CheckBox generateColumnHeaderBox = new CheckBox("Generate Column Header"); gridExportPanel.getFlexCellFormatter().setColSpan(1, 1, 7); gridExportPanel.setWidget(2, 1, generateColumnHeaderBox); gridExportPanel.getFlexCellFormatter().setColSpan(2, 1, 6); for (int i = 0; i < labels.length; i++) { exportImages[i].setStylePrimaryName("datagridexportlabel"); exportImages[i].setTitle(labels[i]); gridExportPanel.setWidget(0, i + 1, exportImages[i]); exportImages[i].addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (event.getSource() instanceof Image) { Image image = (Image) (event.getSource()); final String exportCode = image.getTitle(); RPCServiceAsync service = MainFactoryActions.createService(); AsyncCallback<?> callback = new AsyncCallback<Object>() { public void onSuccess(Object result) { String uuid = (String) result; // set frame frame.setUrl(moduleRelativeURL + "?uuid=" + uuid); ClientApplicationContext.getInstance().setBusy(false); } public void onFailure(Throwable caught) { ClientApplicationContext.getInstance().log("Export failed", "Export failed for " + exportCode + " ", true, true, caught); ClientApplicationContext.getInstance().setBusy(false); FunctionsExecutor.setProcessedBuiltIn(true); } }; List<DataContainerGVO> dList = new ArrayList<DataContainerGVO>(); // following loop is to maintain the order of rows while exporting. for (int i = 0; i < (table.getAbsoluteLastRowIndex() + 1); i++) { dList.add(table.getRowValue(i)); } service.prepareForExport(dList, exportCode, null, generateColumnHeaderBox.getValue().booleanValue(), callback); } } }); } } }
From source file:com.qualogy.qafe.gwt.client.factory.MainFactory.java
License:Apache License
public static void createTryMeWindow(String subwindow) { final WindowPanel w = new WindowPanel("Try me!"); w.setResizable(true);// w ww.j a v a2 s . co m w.setAnimationEnabled(true); w.setSize("800px", "500px"); VerticalPanel verticalPanel = new VerticalPanel(); final ScrollLayoutPanel vp = new ScrollLayoutPanel(); vp.setAlwaysShowScrollBars(false); vp.setWidth("800px"); vp.setHeight("500px"); w.setWidget(verticalPanel); // vp.setSpacing(5); // vp.setWidth("100%"); final TabPanel tabPanel = new TabPanel(); tabPanel.setAnimationEnabled(true); tabPanel.setWidth("580px"); tabPanel.setHeight("500px"); DockPanel dockPanel = new DockPanel(); dockPanel.setWidth("580px"); dockPanel.setHeight("500px"); tabPanel.add(dockPanel, "Insert code!"); final TextArea textArea = new TextArea(); textArea.setVisibleLines(30); textArea.setHeight("auto"); textArea.setWidth("580px"); DOM.setElementAttribute(textArea.getElement(), "font-size", "10pt"); dockPanel.add(textArea, DockPanel.CENTER); final MenuBar menu = new MenuBar(); MenuBar renderMenu = new MenuBar(true); w.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { int height = event.getHeight(); int width = event.getWidth(); if (w.getWidget() != null) { w.setHeight((height) + "px"); w.setWidth((width) + "px"); vp.setHeight((height - 20) + "px"); vp.setWidth((width - 20) + "px"); tabPanel.setHeight((height - 20) + "px"); tabPanel.setWidth((width - 20) + "px"); menu.setWidth((width) + "px"); textArea.setWidth((width - 20) + "px"); } } }); MenuItem gwtMenuItem = new MenuItem("GWT output", new Command() { public void execute() { String xml = textArea.getText(); if (xml == null || xml.length() == 0) { MessageBox.error("Try me:Error", "There is no input"); } else { MainFactoryActions.processUIXml(xml); } } }); MenuItem flexMenuItem = new MenuItem("Flex output", new Command() { public void execute() { String xml = textArea.getText(); if (xml == null || xml.length() == 0) { MessageBox.error("Try me:Error", "There is no input"); } else { MainFactoryActions.processUIXmlFlex(xml); } } }); renderMenu.addItem(gwtMenuItem); renderMenu.addItem(flexMenuItem); MenuBar codeMenu = new MenuBar(true); MenuItem clearXmlInput = new MenuItem("Clear", new Command() { public void execute() { textArea.setText(""); } }); MenuItem createHeaderButton = new MenuItem("Create Header", new Command() { public void execute() { final String headerText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n" + " <!-- PLEASE ENTER YOUR CODE HERE --> \n" + "</application-mapping> \n"; textArea.setText(headerText); } }); MenuItem createSampleAppButton = new MenuItem("Create Sample Application", new Command() { public void execute() { final String sampleText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n" + "<presentation-tier>\n" + " <view>\n" + " <window id=\"window1\" displayname=\"Hello World\" width=\"200\" height=\"200\">\n" + " <rootpanel id=\"myRootPanel\"> \n" + " <verticallayout>\n\n" + " <!-- PLEASE ENTER HERE YOUR CODE -->\n\n" + " <label id=\"mylabel\" displayname=\"Hello World\" />\n\n" + " </verticallayout>\n" + " </rootpanel>\n" + " </window>\n" + " </view>\n" + "</presentation-tier>\n" + "</application-mapping> \n"; textArea.setText(sampleText); } }); codeMenu.addItem(clearXmlInput); codeMenu.addItem(createHeaderButton); codeMenu.addItem(createSampleAppButton); menu.addItem("Render", renderMenu); menu.addItem("Code", codeMenu); if (menu != null) { verticalPanel.add(menu); } verticalPanel.add(vp); // w.setWidget(tabPanel); /* * FMB Upload */ final FormPanel fmbForm = new FormPanel(); fmbForm.setAction(GWT.getModuleBaseURL() + "/rpc.fmbupload"); // Because we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. fmbForm.setEncoding(FormPanel.ENCODING_MULTIPART); fmbForm.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panelFmbUpload = new VerticalPanel(); panelFmbUpload.setWidth("580px"); panelFmbUpload.setHeight("500px"); // panelFmbUpload.setHeight("100%"); final FileUpload fmbFile = new FileUpload(); final TextBox emailBox = new TextBox(); final TextBox phoneBox = new TextBox(); fmbFile.setName("fmbUploadElement"); // Add an event handler to the form. fmbForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { if (event.getResults() != null) { if (event.getResults().startsWith("Conversion failed")) { ClientApplicationContext.getInstance().log("Conversion failed", "The file doesn't seem to be a valid Oracle Forms file. If you still want it to be converted for demo purpose, you can also send it to info@qafe.com", true); } else if (event.getResults().startsWith("UUID")) { String[] split = event.getResults().split("="); if (split.length == 2) { String uuid = split[1]; MainFactoryActions.processUIByUUID(uuid, textArea); MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]", "The message was sent by " + emailBox.getText() + " with optional phonenr: " + phoneBox.getText()); tabPanel.selectTab(0); } } else { // firefox workaround String[] split = event.getResults().split("="); if (split.length == 2) { String uuid = split[1]; uuid = uuid.replaceAll("</pre>", ""); MainFactoryActions.processUIByUUID(uuid, textArea); MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]", "The message was sent by " + emailBox.getText() + " with optional phonenr: " + phoneBox.getText()); tabPanel.selectTab(0); } else { ClientApplicationContext.getInstance().log(event.getResults()); } } } else { ClientApplicationContext.getInstance().log( "The Forms Conversion process could not handle this file. Please check the file.", "Check whether or not this file is an FMB (not an FMX)", true); } } }); FlexTable tempFmbPanel = new FlexTable(); tempFmbPanel.setWidget(0, 1, fmbFile); tempFmbPanel.setWidget(0, 0, new Label("Input for FMB")); tempFmbPanel.setWidget(1, 0, new HTML( "<p>Note: the FMB you are uploading is only for <span style=\"color:red;\">demo</span> purpose.</p>" + "<p>FMB's can have external dependencies like <span style=\"color:red;\">PLL, OLB's, images</span>,etc. Since they are <span style=\"color:red;\">not</span> included in the upload, the output might not appear correct.</p>" + "<p>For a more detailed conversion of your FMB's please contact us at <span style=\"color:red;\">info@qafe.com </span></p> <p/>" + "<p>Please fill in the information below, so that we can contact you for more information</p> ")); tempFmbPanel.getFlexCellFormatter().setColSpan(1, 0, 2); tempFmbPanel.setWidget(2, 0, new Label("E-mail: (required)")); emailBox.setName("fmbEmail"); emailBox.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { String textValue = ((TextBoxBase) event.getSource()).getText(); if (textValue != null) { if (textValue.replaceFirst(TextFieldGVO.REGEXP_TYPE_EMAIL_VALUE, "").length() > 0) { ClientApplicationContext.getInstance().log("Email validation error", TextFieldGVO.TYPE_EMAIL_DEFAULT_MESSAGE, true); } } } }); tempFmbPanel.setWidget(2, 1, emailBox); tempFmbPanel.setWidget(3, 0, new Label("Phonenr:")); phoneBox.setName("fmbPhone"); phoneBox.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { } }); tempFmbPanel.setWidget(3, 1, phoneBox); fmbForm.add(tempFmbPanel); panelFmbUpload.add(fmbForm); // Add a 'submit' button. panelFmbUpload.add(new Button("Generate", new ClickHandler() { public void onClick(ClickEvent event) { fmbForm.submit(); } })); // Add an event handler to the form. fmbForm.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { // This event is fired just before the form is submitted. We can take // this opportunity to perform validation. if (emailBox.getText().length() == 0) { ClientApplicationContext.getInstance().log("Email validation error", "Please fill in your email address", true); event.cancel(); } else if (fmbFile.getFilename() == null || fmbFile.getFilename().length() == 0) { ClientApplicationContext.getInstance().log("Uploaded file validation error", "There is no file selected. Please select one to continue", true); event.cancel(); } } }); tabPanel.add(panelFmbUpload, "Forms Conversion"); vp.add(tabPanel); w.center(); if (QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME_FORMS.equals(subwindow)) { tabPanel.selectTab(1); } else { tabPanel.selectTab(0); } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { HorizontalPanel uiObject = null;//w w w . j a v a 2 s .com final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); final Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); final FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); fileUploadComponent.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { String filename = fileUploadComponent.getFilename(); boolean enabled = (filename != null) && (filename.length() > 0); uploadButtonComponent.setEnabled(enabled); } }); Hidden appId = new Hidden(); final String appID = ClientApplicationContext.getInstance().getWindowSession(); appId.setName("APPUUID=" + appID); Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label clearLabel = new Label("Clear"); clearLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(clearLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(clearLabel.getElement(), "cursor", "hand"); clearLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); clearLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); init(fileUpload, uploadButton); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, clearLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); init(fileUploadComponent, uploadButtonComponent); } } return uiObject; }
From source file:com.qualogy.qafe.mgwt.client.ui.renderer.FileUploadRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String owner, String uuid, String parent, String context, AbstractActivity activity) {//from www.j av a 2 s .co m HorizontalPanel uiObject = null; final String finalParent = parent; if (component != null) { if (component instanceof FileUploadGVO) { if (component.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; uiObject = new HorizontalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new HorizontalPanel(); } final FormPanel formPanel = new FormPanel(); formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.upload"); formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); FileUpload fileUploadComponent = new FileUpload(); fileUploadComponent.setName("uploadElement"); Button uploadButtonComponent = new Button("Upload"); uploadButtonComponent.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { formPanel.submit(); } }); Hidden appId = new Hidden(); appId.setName("APPUUID=" + uuid); final String appID = uuid; Hidden windowId = new Hidden(); windowId.setName("WINDOWID=" + parent); Grid gridPanel = new Grid(2, 4); gridPanel.setWidget(0, 0, fileUploadComponent); gridPanel.setWidget(0, 1, uploadButtonComponent); gridPanel.setWidget(0, 2, appId); gridPanel.setWidget(0, 3, windowId); formPanel.add(gridPanel); RendererHelper.fillIn(component, formPanel, uuid, parent, context); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { String uuId = event.getResults(); boolean success = false; if (uuId != null && uuId.indexOf("=") > 0) { uuId = uuId.substring(uuId.indexOf("=") + 1); success = true; } if (formPanel instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) formPanel; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof Grid) { Grid gridPanel = (Grid) widget; final FileUpload fileUpload = (FileUpload) gridPanel.getWidget(0, 0); final Button uploadButton = (Button) gridPanel.getWidget(0, 1); if (success) { fileUpload.setVisible(false); uploadButton.setVisible(false); String fileName = event.getResults().substring(0, event.getResults().indexOf("#")); final String viewUrl = GWT.getModuleBaseURL() + "/rpc.view?APPUUID=" + appID + "&WINDOWID=" + finalParent + "&VIEW=" + uuId; final Label fileNameLabel = new Label(fileName); DOM.setStyleAttribute(fileNameLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(fileNameLabel.getElement(), "cursor", "hand"); fileNameLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(viewUrl, "UploadedFile", null); } }); fileNameLabel.setVisible(true); final Label removeLabel = new Label("Remove"); removeLabel.setVisible(true); final String finalUuId = uuId; DOM.setStyleAttribute(removeLabel.getElement(), "textDecoration", "underline"); DOM.setStyleAttribute(removeLabel.getElement(), "cursor", "hand"); removeLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { MainFactoryActions.removeUploadedFile(appID, finalParent, finalUuId); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", ""); fileNameLabel.setVisible(false); removeLabel.setVisible(false); fileUpload.setVisible(true); uploadButton.setVisible(true); } }); gridPanel.setWidget(1, 0, fileNameLabel); gridPanel.setWidget(1, 1, removeLabel); DOM.setElementAttribute(fileUpload.getElement(), "fu-uuid", uuId); CallbackHandler.createCallBack(formPanel, "onfinish", null, null); } else { Hyperlink fileNameLabel = (Hyperlink) gridPanel.getWidget(1, 0); fileNameLabel.setText("Uploading unsuccessfull."); fileNameLabel.setVisible(true); } } } } } }); uiObject.add(formPanel); } } return uiObject; }
From source file:com.siderakis.demo.client.FullFormDemo.java
License:Apache License
public FullFormDemo() { // Create a UploadFormPanel and point it at a service. final UploadFormPanel form = new UploadFormPanel(); form.setAction(UPLOAD_ACTION_URL); form.setWidget(panel);// ww w. j ava2 s . com // Create a standard FileUpload. panel.add(new Label("Single File:")); final FileUpload upload = new FileUpload(); upload.setName("singleUploadFormElement"); panel.add(upload); // Create a TextBox, giving it a name so that it will be submitted. panel.add(new Label("Textbox:")); final TextBox tb = new TextBox(); tb.setName("textBoxFormElement"); panel.add(tb); // Create a ListBox, giving it a name and some values to be associated // with its options. panel.add(new Label("Listbox:")); final ListBox lb = new ListBox(); lb.setName("listBoxFormElement"); lb.addItem("foo", "fooValue"); lb.addItem("bar", "barValue"); lb.addItem("baz", "bazValue"); panel.add(lb); // Add a 'submit' button. panel.add(new Button("Submit", new ClickHandler() { @Override public void onClick(final ClickEvent event) { form.submit(); } })); // Create a SimpleProgressBar, add it to the panel. Also set it as the // status display for the form. final SimpleProgressBar simpleProgressBar = new SimpleProgressBar(); panel.add(simpleProgressBar); form.setStatusDisplay(simpleProgressBar); form.addSubmitCompleteHandler(new SubmitCompleteHandler() { @Override public void onSubmitComplete(final SubmitCompleteEvent event) { // TODO reset the form. } }); outer.add(form); addSourceCodeLink("FullFormDemo"); }
From source file:com.siderakis.demo.client.StyledInputDemo.java
License:Apache License
private void addCSSStyledInput() { final FileUpload upload = new StyledFileUpload(); final FlowPanel outer = new FlowPanel(); outer.setStyleName("style"); final FlowPanel flowPanel = new FlowPanel(); flowPanel.setStyleName("fileinputs"); upload.setStyleName("file"); upload.setName("styledUploadFormElement"); flowPanel.add(upload);//from w w w .j ava 2 s . c o m panel.add(new Label("Image Styled File Input:")); outer.add(flowPanel); panel.add(outer); }
From source file:edu.iastate.airl.semtus.client.SEMTUSWEBAPP.java
License:Open Source License
public FormPanel upload() { final FormPanel form = new FormPanel(); form.setAction(GWT.getModuleBaseURL() + "upload"); // Because we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. HorizontalPanel panel = new HorizontalPanel(); form.setWidget(panel);/*from w ww. ja v a2s.co m*/ // Create a FileUpload widget. final FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); panel.add(new HTML(" ")); // Add a 'submit' button. panel.add(new Button("Upload", new ClickHandler() { public void onClick(ClickEvent event) { String filename = upload.getFilename(); if (filename.length() == 0) { Window.alert("No File Specified"); } else { form.submit(); } } })); panel.add(new HTML(" ")); // Add a 'Done' button. panel.add(new Button("Done", new ClickHandler() { public void onClick(ClickEvent event) { uploadBox.hide(); tabPanel.selectTab(0); } })); // Add an event handler to the form. form.addSubmitHandler(new FormPanel.SubmitHandler() { public void onSubmit(SubmitEvent event) { } }); form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // Check if there's been an error in upload if (event.getResults() == null) { Window.alert( "Ontology Upload Failed. Please give us feedback [sushain.pandit@gmail.com] explaining the parameters of upload (filesize, format, etc) and we'll try to get it resolved asap."); } else if (event.getResults().toLowerCase().contains("file already exists")) { // if it's already present on // server, then we're just // fine. Window.alert( "You just uploaded this ontology. Please proceed to the workspace for text input. Thanks !"); } else if (event.getResults().toLowerCase().contains("error") || event.getResults().toLowerCase().contains("not available")) { // o'wise flag an error Window.alert( "Ontology Upload Failed. Please give us feedback [sushain.pandit@gmail.com] explaining the parameters of upload (filesize, format, etc) and we'll try to get it resolved asap."); } else { Window.alert(event.getResults()); Window.alert("Ontology Upload Successful"); } } }); return form; }