List of usage examples for com.google.gwt.user.client.ui FormPanel setMethod
public void setMethod(String method)
From source file:org.pentaho.pat.client.ui.panels.PropertiesPanel.java
License:Open Source License
/** * PropertiesPanel Constructor.// w w w . j a v a 2 s . com * * @param dPanel * */ public PropertiesPanel(final DataPanel dPanel, PanelUtil.PanelType pType) { super(); this.dataPanel = dPanel; this.queryId = Pat.getCurrQuery(); EventFactory.getQueryInstance().addQueryListener(this); final LayoutPanel rootPanel = getLayoutPanel(); final ScrollLayoutPanel mainPanel = new ScrollLayoutPanel(); mainPanel.addStyleName("pat-propertiesPanel"); //$NON-NLS-1$ mainPanel.setLayout(new BoxLayout(Orientation.HORIZONTAL)); final FormPanel formPanel = new FormPanel(); formPanel.setAction(FORM_ACTION); formPanel.setMethod(FORM_METHOD); //formPanel.setEncoding(FORM_ENCODING); Hidden curQuery = new Hidden(FORM_NAME_QUERY); curQuery.setName(FORM_NAME_QUERY); curQuery.setValue(queryId); formPanel.add(curQuery); executeButton = new Button(Pat.IMAGES.execute_no_ds().getHTML()); executeButton.setTitle(Pat.CONSTANTS.executeQuery()); executeButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { if (executemode == false) { Pat.executeQuery(PropertiesPanel.this, queryId); setExecuteButton(true); dPanel.swapWindows(); } else { setExecuteButton(false); dPanel.swapWindows(); } } }); exportButton = new ToolButton(Pat.CONSTANTS.export()); exportButton.setTitle(Pat.CONSTANTS.export()); exportButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { formPanel.submit(); } }); exportButton.setEnabled(false); exportCdaButton = new ToolButton("CDA"); exportCdaButton.setTitle(Pat.CONSTANTS.export() + " as CDA"); exportCdaButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { SaveWindow.displayCDA(); } }); exportCdaButton.setEnabled(false); mdxButton = new ToolButton(Pat.CONSTANTS.mdx()); mdxButton.setTitle(Pat.CONSTANTS.showMDX()); mdxButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { ServiceFactory.getQueryInstance().getMdxForQuery(Pat.getSessionID(), queryId, new AsyncCallback<String>() { public void onFailure(final Throwable arg0) { MessageBox.error(Pat.CONSTANTS.error(), arg0.getLocalizedMessage()); } public void onSuccess(final String mdx) { final WindowPanel winPanel = new WindowPanel(Pat.CONSTANTS.mdx()); final LayoutPanel wpLayoutPanel = new LayoutPanel( new BoxLayout(Orientation.VERTICAL)); wpLayoutPanel.setSize("450px", "200px"); //$NON-NLS-1$ //$NON-NLS-2$ final MDXRichTextArea mdxArea = new MDXRichTextArea(); mdxArea.setText(mdx); wpLayoutPanel.add(mdxArea, new BoxLayoutData(1, 0.9)); final ToolButton closeBtn = new ToolButton(Pat.CONSTANTS.close()); closeBtn.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { winPanel.hide(); } }); final ToolButton mdxBtn = new ToolButton(Pat.CONSTANTS.newMdxQuery()); mdxBtn.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { final Widget widget = MainTabPanel.getSelectedWidget(); if (widget instanceof OlapPanel) { ((OlapPanel) widget).getCubeItem(); final MdxPanel mdxpanel = new MdxPanel( ((OlapPanel) widget).getCubeItem(), Pat.getCurrConnection(), mdxArea.getText(), null); MainTabPanel.displayContentWidget(mdxpanel); } winPanel.hide(); } }); final LayoutPanel wpButtonPanel = new LayoutPanel( new BoxLayout(Orientation.HORIZONTAL)); wpButtonPanel.add(mdxBtn); wpButtonPanel.add(closeBtn); wpLayoutPanel.add(wpButtonPanel); wpLayoutPanel.layout(); winPanel.add(wpLayoutPanel); winPanel.layout(); winPanel.pack(); winPanel.setSize("500px", "320px"); //$NON-NLS-1$ //$NON-NLS-2$ winPanel.center(); } }); } }); hideBlanksButton = new ToolButton(Pat.IMAGES.zero().getHTML()); hideBlanksButton.setTitle(Pat.CONSTANTS.showBlankCells()); hideBlanksButton.setStyle(ToolButtonStyle.CHECKBOX); hideBlanksButton.setChecked(true); hideBlanksButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { EventFactory.getQueryInstance().getQueryListeners().fireQueryStartsExecution(PropertiesPanel.this, queryId); ServiceFactory.getQueryInstance().setNonEmpty(Pat.getSessionID(), queryId, hideBlanksButton.isChecked(), new AsyncCallback<CellDataSet>() { public void onFailure(final Throwable arg0) { EventFactory.getQueryInstance().getQueryListeners() .fireQueryFailedExecution(PropertiesPanel.this, queryId); MessageBox.error(Pat.CONSTANTS.error(), MessageFactory.getInstance().failedNonEmpty()); } public void onSuccess(final CellDataSet arg0) { if (hideBlanksButton.isChecked()) { hideBlanksButton.setTitle(Pat.CONSTANTS.showBlankCells()); } else { hideBlanksButton.setTitle(Pat.CONSTANTS.hideBlankCells()); } EventFactory.getQueryInstance().getQueryListeners() .fireQueryExecuted(PropertiesPanel.this, queryId, arg0); } }); } }); hideBlanksButton.setEnabled(false); final ToolButton createScenarioButton = new ToolButton("Create Scenario"); createScenarioButton.setStyle(ToolButtonStyle.CHECKBOX); createScenarioButton.setEnabled(false); createScenarioButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { ServiceFactory.getQueryInstance().alterCell(queryId, Pat.getSessionID(), Pat.getCurrScenario(), Pat.getCurrConnectionId(), "123", new AsyncCallback<CellDataSet>() { public void onFailure(Throwable arg0) { // TODO Auto-generated method stub } public void onSuccess(CellDataSet arg0) { Pat.executeQuery(PropertiesPanel.this, queryId); } }); /*ServiceFactory.getSessionInstance().createNewScenario(Pat.getSessionID(), Pat.getCurrConnection(), new AsyncCallback<String>(){ public void onFailure(final Throwable arg0){ MessageBox.error(Pat.CONSTANTS.error(), "Failed to set scenario"); } public void onSuccess(String scenario){ createScenarioButton.setText(scenario); Pat.setCurrScenario(scenario); } });*/ } }); pivotButton = new ToolButton(Pat.CONSTANTS.pivot()); pivotButton.setTitle(Pat.CONSTANTS.pivot()); pivotButton.setStyle(ToolButtonStyle.CHECKBOX); pivotButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { EventFactory.getQueryInstance().getQueryListeners().fireQueryStartsExecution(PropertiesPanel.this, queryId); ServiceFactory.getQueryInstance().swapAxis(Pat.getSessionID(), queryId, new AsyncCallback<CellDataSet>() { public void onFailure(final Throwable arg0) { EventFactory.getQueryInstance().getQueryListeners() .fireQueryFailedExecution(PropertiesPanel.this, queryId); MessageBox.error(Pat.CONSTANTS.error(), MessageFactory.getInstance().failedPivot(arg0.getLocalizedMessage())); } public void onSuccess(final CellDataSet arg0) { EventFactory.getQueryInstance().getQueryListeners() .fireQueryExecuted(PropertiesPanel.this, queryId, arg0); } }); } }); pivotButton.setEnabled(false); layoutMenuButton = new ToolButton(Pat.IMAGES.chart_pie().getHTML()); layoutMenuButton.setTitle(Pat.CONSTANTS.chart()); layoutMenuButton.setStyle(ToolButtonStyle.MENU); layoutMenuButton.setEnabled(false); final PopupMenu layoutMenuBtnMenu = new PopupMenu(); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.grid(), new LayoutCommand(null)); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.chart(), new LayoutCommand(Region.CENTER)); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.top(), new LayoutCommand(Region.NORTH)); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.bottom(), new LayoutCommand(Region.SOUTH)); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.left(), new LayoutCommand(Region.WEST)); layoutMenuBtnMenu.addItem(Pat.CONSTANTS.right(), new LayoutCommand(Region.EAST)); layoutMenuButton.setMenu(layoutMenuBtnMenu); drillPositionButton = new ToolButton( ButtonHelper.createButtonLabel(Pat.IMAGES.drill(), "", ButtonLabelType.NO_TEXT)); drillPositionButton.setTitle(Pat.CONSTANTS.drillPosition()); drillPositionButton.setStyle(ToolButtonStyle.RADIO); drillPositionButton.setEnabled(false); drillPositionButton.setChecked(true); drillPositionButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { drillReplaceButton.setChecked(false); drillUpButton.setChecked(false); drillNoneButton.setChecked(false); drillPositionButton.setChecked(true); (new DrillCommand(DrillType.POSITION)).execute(); EventFactory.getOperationInstance().getOperationListeners() .fireDrillStyleChanged(PropertiesPanel.this, queryId, DrillType.POSITION); } }); drillReplaceButton = new ToolButton( ButtonHelper.createButtonLabel(Pat.IMAGES.arrow_down(), "", ButtonLabelType.NO_TEXT)); drillReplaceButton.setTitle(Pat.CONSTANTS.drillReplace()); drillReplaceButton.setStyle(ToolButtonStyle.RADIO); drillReplaceButton.setEnabled(false); drillReplaceButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { drillPositionButton.setChecked(false); drillUpButton.setChecked(false); drillNoneButton.setChecked(false); drillReplaceButton.setChecked(true); (new DrillCommand(DrillType.REPLACE)).execute(); EventFactory.getOperationInstance().getOperationListeners() .fireDrillStyleChanged(PropertiesPanel.this, queryId, DrillType.REPLACE); } }); drillUpButton = new ToolButton( ButtonHelper.createButtonLabel(Pat.IMAGES.arrow_up(), "", ButtonLabelType.NO_TEXT)); drillUpButton.setTitle(Pat.CONSTANTS.drillUp()); drillUpButton.setStyle(ToolButtonStyle.RADIO); drillUpButton.setEnabled(false); drillUpButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { drillPositionButton.setChecked(false); drillReplaceButton.setChecked(false); drillNoneButton.setChecked(false); drillUpButton.setChecked(true); (new DrillCommand(DrillType.UP)).execute(); EventFactory.getOperationInstance().getOperationListeners() .fireDrillStyleChanged(PropertiesPanel.this, queryId, DrillType.UP); } }); drillNoneButton = new ToolButton(Pat.CONSTANTS.drillNone()); drillNoneButton.setStyle(ToolButtonStyle.RADIO); drillNoneButton.setEnabled(false); drillNoneButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { drillPositionButton.setChecked(false); drillReplaceButton.setChecked(false); drillUpButton.setChecked(false); drillNoneButton.setChecked(true); (new DrillCommand(DrillType.NONE)).execute(); EventFactory.getOperationInstance().getOperationListeners() .fireDrillStyleChanged(PropertiesPanel.this, queryId, DrillType.NONE); } }); drillThroughButton = new ToolButton(Pat.CONSTANTS.drillThrough()); drillThroughButton.setTitle(Pat.CONSTANTS.drillThrough()); drillThroughButton.setEnabled(false); drillThroughButton.setStyle(ToolButtonStyle.CHECKBOX); drillThroughButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { if (drillThroughButton.isChecked()) { EventFactory.getOperationInstance().getOperationListeners() .fireOperationExecuted(PropertiesPanel.this, queryId, Operation.ENABLE_DRILLTHROUGH); } else { EventFactory.getOperationInstance().getOperationListeners() .fireOperationExecuted(PropertiesPanel.this, queryId, Operation.DISABLE_DRILLTHROUGH); } } }); ToolButton syncButton = new ToolButton(Pat.IMAGES.arrow_refresh().getHTML()); syncButton.setTitle("Refresh Query"); syncButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { ServiceFactory.getQueryInstance().getSelections(Pat.getSessionID(), queryId, new AsyncCallback<Map<IAxis, PatQueryAxis>>() { public void onFailure(Throwable arg0) { MessageBox.alert("ERROR", "ERROR"); } public void onSuccess(Map<IAxis, PatQueryAxis> arg0) { Integer rows = arg0.get(IAxis.ROWS) != null ? arg0.get(IAxis.ROWS).getDimensions().size() : 0; Integer cols = arg0.get(IAxis.COLUMNS) != null ? arg0.get(IAxis.COLUMNS).getDimensions().size() : 0; Integer filter = arg0.get(IAxis.FILTER) != null ? arg0.get(IAxis.FILTER).getDimensions().size() : 0; MessageBox.alert("OK", "rows: " + rows + " cols:" + cols + " filter:" + filter); } }); } }); if (pType == PanelUtil.PanelType.MDX) { mainPanel.add(exportButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(layoutMenuButton, new BoxLayoutData(FillStyle.HORIZONTAL)); } if (pType == PanelUtil.PanelType.QM) { mainPanel.add(executeButton, new BoxLayoutData(FillStyle.HORIZONTAL)); // TODO enable sync button when implemented routines // mainPanel.add(syncButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(exportButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(layoutMenuButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(drillPositionButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(drillReplaceButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(drillUpButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(drillNoneButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(mdxButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(hideBlanksButton, new BoxLayoutData(FillStyle.HORIZONTAL)); mainPanel.add(pivotButton, new BoxLayoutData(FillStyle.HORIZONTAL)); // mainPanel.add(drillThroughButton, new BoxLayoutData(FillStyle.HORIZONTAL)); // mainPanel.add(createScenarioButton, new BoxLayoutData(FillStyle.HORIZONTAL)); } if (Pat.isPlugin()) { mainPanel.add(exportCdaButton, new BoxLayoutData(FillStyle.HORIZONTAL)); } mainPanel.add(formPanel, new BoxLayoutData(FillStyle.HORIZONTAL)); rootPanel.add(mainPanel); }
From source file:org.pentaho.pat.client.ui.panels.windows.ConnectMondrianPanel.java
License:Open Source License
/** * Run on panel initialize./* ww w. ja va 2 s . c o m*/ */ private void init() { final FormPanel formPanel = new FormPanel(); formPanel.setAction(FORM_ACTION); formPanel.setMethod(FORM_METHOD); formPanel.setEncoding(FORM_ENCODING); formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(final SubmitCompleteEvent arg0) { if (arg0 != null && arg0.getResults() != null && arg0.getResults().length() > 0) { if (arg0.getResults().contains(VALIDATION_START)) { final String tmp = arg0.getResults().substring( arg0.getResults().indexOf(VALIDATION_START) + VALIDATION_START.length(), arg0.getResults().indexOf(VALIDATION_END)); if (tmp != null && tmp.length() > 0) { if (schemaValCheckbox.getValue()) { MessageBox.info(Pat.CONSTANTS.warning(), MessageFactory.getInstance().schemaFileInvalid() + "<br>" + tmp); //$NON-NLS-1$ } } } if (arg0.getResults().contains(SCHEMA_START)) { final String tmp = arg0.getResults().substring( arg0.getResults().indexOf(SCHEMA_START) + SCHEMA_START.length(), arg0.getResults().indexOf(SCHEMA_END)); schemaData = decode(tmp); saveButton.setEnabled(true); viewSchemaButton.setEnabled(true); viewSchemaButton.setText(Pat.CONSTANTS.viewSchema()); // TODO remove this later Application.INSTANCE.showInfoPanel(Pat.CONSTANTS.fileUpload(), Pat.CONSTANTS.success()); } else { MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.fileUploadFailed()); } } else { MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.checkErrorLog()); } } }); final FormLayout layout = new FormLayout("right:[40dlu,pref], 3dlu, 70dlu, 7dlu, " //$NON-NLS-1$ + "right:[40dlu,pref], 3dlu, 70dlu", //$NON-NLS-1$ "p, 3dlu, p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p, 3dlu,p"); //$NON-NLS-1$ final PanelBuilder builder = new PanelBuilder(layout); builder.addLabel(Pat.CONSTANTS.name() + LABEL_SUFFIX, CellConstraints.xy(1, 1)); builder.add(nameTextBox, CellConstraints.xyw(3, 1, 5)); builder.addLabel(Pat.CONSTANTS.jdbcDriver() + LABEL_SUFFIX, CellConstraints.xy(1, 3)); builder.add(driverListBox, CellConstraints.xyw(3, 3, 5)); builder.addLabel(Pat.CONSTANTS.jdbcUrl() + LABEL_SUFFIX, CellConstraints.xy(1, 5)); builder.add(urlTextBox, CellConstraints.xyw(3, 5, 5)); builder.addLabel(Pat.CONSTANTS.username() + LABEL_SUFFIX, CellConstraints.xy(1, 7)); builder.add(userTextBox, CellConstraints.xy(3, 7)); builder.addLabel(Pat.CONSTANTS.password() + LABEL_SUFFIX, CellConstraints.xy(5, 7)); builder.add(passwordTextBox, CellConstraints.xy(7, 7)); builder.addLabel(Pat.CONSTANTS.schemaFile() + LABEL_SUFFIX, CellConstraints.xy(1, 9)); fileUpload.setName(FORM_NAME_FILE); builder.add(fileUpload, CellConstraints.xyw(3, 9, 5)); builder.add(schemaValCheckbox, CellConstraints.xyw(3, 11, 5)); uploadButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { final String filename = fileUpload.getFilename(); if (filename == null || filename.length() == 0) { MessageBox.error(Pat.CONSTANTS.error(), Pat.CONSTANTS.fileUploadNoFile()); } else { formPanel.submit(); } } }); builder.add(uploadButton, CellConstraints.xy(3, 13)); viewSchemaButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent arg0) { final WindowPanel winPanel = new WindowPanel(Pat.CONSTANTS.schemaFile()); final LayoutPanel wpLayoutPanel = new LayoutPanel(new BoxLayout(Orientation.VERTICAL)); wpLayoutPanel.setSize("450px", "200px"); //$NON-NLS-1$ //$NON-NLS-2$ final RichTextArea schemaArea = new RichTextArea(); String newStr = schemaData + ""; newStr = newStr.replaceAll("\\<", "<").replaceAll("\\>", ">").replaceAll(" ", " "); newStr = newStr.replaceAll("\t", " "); newStr = newStr.replaceAll("(\r\n)", "<br>"); //$NON-NLS-1$ //$NON-NLS-2$ // newStr = newStr.replaceAll("[\r\n\t\f]", "<br>"); //$NON-NLS-1$ //$NON-NLS-2$ schemaArea.setHTML(newStr + ""); wpLayoutPanel.add(schemaArea, new BoxLayoutData(1, 0.9)); final ToolButton saveBtn = new ToolButton(Pat.CONSTANTS.save()); saveBtn.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { String newStr = schemaArea.getHTML(); newStr = newStr.replaceAll("<", "\\<").replaceAll(">", "\\>").replaceAll(" ", " "); newStr = newStr.replaceAll(" ", "\t"); newStr = newStr.replaceAll("<br>", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ schemaData = newStr; winPanel.hide(); ConnectionManagerWindow.display(false); } }); final ToolButton closeBtn = new ToolButton(Pat.CONSTANTS.close()); closeBtn.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent arg0) { winPanel.hide(); ConnectionManagerWindow.display(false); } }); final LayoutPanel wpButtonPanel = new LayoutPanel(new BoxLayout(Orientation.HORIZONTAL)); wpButtonPanel.add(saveBtn); wpButtonPanel.add(closeBtn); wpLayoutPanel.add(wpButtonPanel); wpLayoutPanel.layout(); winPanel.add(wpLayoutPanel); winPanel.layout(); winPanel.pack(); winPanel.setSize("700px", "520px"); //$NON-NLS-1$ //$NON-NLS-2$ ConnectionManagerWindow.close(); winPanel.center(); } }); viewSchemaButton.setEnabled(false); viewSchemaButton.setText(Pat.CONSTANTS.noSchema()); builder.add(viewSchemaButton, CellConstraints.xy(7, 13)); builder.addLabel(Pat.CONSTANTS.role() + LABEL_SUFFIX, CellConstraints.xy(1, 15)); builder.add(roleTextBox, CellConstraints.xyw(3, 15, 5)); builder.add(startupCheckbox, CellConstraints.xy(3, 17)); saveButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { final CubeConnection cc = getCubeConnection(); if (validateConnection(cc)) { saveButton.setEnabled(false); ServiceFactory.getSessionInstance().saveConnection(Pat.getSessionID(), cc, new AsyncCallback<String>() { public void onFailure(final Throwable arg0) { MessageBox.error(Pat.CONSTANTS.error(), MessageFactory.getInstance() .failedLoadConnection(arg0.getLocalizedMessage())); saveButton.setEnabled(true); } public void onSuccess(final String id) { if (cc.isConnectOnStartup()) { ConnectionManagerPanel.connectEvent(id, cc.isConnected(), true); } ConnectionManagerWindow.closeTabs(); } }); } } }); saveButton.setEnabled(false); builder.add(saveButton, CellConstraints.xy(3, 19)); cancelButton.addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { ConnectionManagerWindow.closeTabs(); } }); builder.add(cancelButton, CellConstraints.xy(7, 19)); final LayoutPanel layoutPanel = builder.getPanel(); layoutPanel.setPadding(15); formPanel.add(layoutPanel); this.getLayoutPanel().add(formPanel); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.UploadFile.java
License:Open Source License
public void onModuleLoad() { // Create a FormPanel and point it at a service. final FormPanel uploadForm = new FormPanel(); uploadForm.setAction(GWT.getModuleBaseURL() + "/UploadService"); // 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. uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); uploadForm.setWidget(panel);/*w w w . ja v a 2s . c o m*/ // Create a TextBox, giving it a name so that it will be submitted. final TextBox tb = new TextBox(); tb.setName("textBoxFormElement"); panel.add(tb); // Create a FileUpload widget. FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); // Add a 'Upload' button. Button uploadSubmitButton = new Button("Upload"); panel.add(uploadSubmitButton); uploadSubmitButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { uploadForm.submit(); } }); uploadForm.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { } public void onSubmitComplete(FormSubmitCompleteEvent event) { Window.alert(event.getResults()); } }); RootPanel.get().add(uploadForm); }
From source file:org.roda.wui.common.client.tools.RestUtils.java
public static <T extends IsIndexed> void requestCSVExport(Class<T> classToReturn, Filter filter, Sorter sorter, Sublist sublist, Facets facets, boolean onlyActive, boolean exportFacets, String filename) { // api/v1/index/findFORM?type=csv String url = RodaConstants.API_REST_V1_INDEX + "findFORM"; FindRequest request = new FindRequest(classToReturn.getName(), filter, sorter, sublist, facets, onlyActive, exportFacets, filename);/* www. j av a 2 s . c om*/ final FormPanel form = new FormPanel(); form.setAction(URL.encode(url)); form.setMethod(FormPanel.METHOD_POST); form.setEncoding(FormPanel.ENCODING_URLENCODED); FlowPanel layout = new FlowPanel(); form.setWidget(layout); layout.add(new Hidden("findRequest", FIND_REQUEST_MAPPER.write(request))); layout.add(new Hidden("type", "csv")); form.setVisible(false); RootPanel.get().add(form); // using submit instead of submit completed because Chrome doesn't created // the other event form.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { Timer timer = new Timer() { @Override public void run() { RootPanel.get().remove(form); } }; // remove form 10 seconds in the future timer.schedule(10000); } }); form.submit(); }
From source file:org.rstudio.core.client.widget.HtmlFormModalDialog.java
License:Open Source License
protected void setFormPanelEncodingAndMethod(FormPanel formPanel) { formPanel.setEncoding(FormPanel.ENCODING_URLENCODED); formPanel.setMethod(FormPanel.METHOD_POST); }
From source file:org.rstudio.studio.client.server.remote.RemoteServerAuth.java
License:Open Source License
public void updateCredentials(final ServerRequestCallback<Integer> requestCallback) { // safely cleanup any previously active update credentials forms safeCleanupPreviousUpdateCredentials(); // create a hidden form panel to submit the update credentials to // (we do this so GWT manages the trickiness associated with // managing and reading the contents of a hidden iframe) final FormPanel updateCredentialsForm = new FormPanel(); updateCredentialsForm.setMethod(FormPanel.METHOD_GET); updateCredentialsForm.setEncoding(FormPanel.ENCODING_URLENCODED); // form url// ww w .ja va2s.co m String url = remoteServer_.getApplicationURL("auth-update-credentials"); updateCredentialsForm.setAction(url); // request log entry (fake up a json rpc method call to conform // to the data format expected by RequestLog String requestId = Integer.toString(Random.nextInt()); String requestData = createRequestData(); final RequestLogEntry logEntry = RequestLog.log(requestId, requestData); // form submit complete handler updateCredentialsForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent event) { // parse the results String results = event.getResults(); RpcResponse response = RpcResponse.parse(event.getResults()); if (response != null) { logEntry.logResponse(ResponseType.Normal, results); // check for error RpcError rpcError = response.getError(); if (rpcError != null) { if (rpcError.getCode() == RpcError.METHOD_NOT_FOUND) { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_UNSUPPORTED)); } else { requestCallback.onError(new RemoteServerError(rpcError)); } } else // must be a valid response { Bool authenticated = response.getResult(); if (authenticated.getValue()) { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_SUCCESS)); } else { requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_FAILURE)); } } } else // error parsing results { logEntry.logResponse(ResponseType.Error, results); // form message String msg = "Error parsing results: " + (results != null ? results : "(null)"); // we don't expect this so debug log to flag our attention Debug.log("UPDATE CREDENTIALS: " + msg); // return the error RpcError rpcError = RpcError.create(RpcError.PARSE_ERROR, msg); requestCallback.onError(new RemoteServerError(rpcError)); } // remove the hidden form (from both last-ditch list and DOM) previousUpdateCredentialsForms_.remove(updateCredentialsForm); Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { RootPanel.get().remove(updateCredentialsForm); } }); } }); // add the (hidden) form panel to the document and last ditch list RootPanel.get().add(updateCredentialsForm, -1000, -1000); previousUpdateCredentialsForms_.add(updateCredentialsForm); // submit the form updateCredentialsForm.submit(); }
From source file:org.rstudio.studio.client.workbench.views.files.ui.FileUploadDialog.java
License:Open Source License
@Override protected void setFormPanelEncodingAndMethod(FormPanel formPanel) { formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); }
From source file:org.utgenome.gwt.utgb.client.track.lib.NavigatorTrack.java
License:Apache License
public NavigatorTrack() { super("NavigatorTrack"); panel.setStyleName("toolbox"); panel.setWidth("100%"); speciesBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.SPECIES, speciesBox)); revisionBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.REVISION, revisionBox)); regionBox.addKeyUpHandler(new SequenceRangeChangeListner()); targetBox.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent e) { int keyCode = e.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ENTER || keyCode == KeyCodes.KEY_TAB) { getTrackGroup().getPropertyWriter().setProperty(UTGBProperty.TARGET, targetBox.getText()); }//from ww w . j av a2 s . c om } }); targetBox.setWidth("100px"); // value selectors hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp.add(new FormLabel("Species")); hp.add(speciesBox); hp.add(new FormLabel("Ref.")); hp.add(revisionBox); hp.add(new FormLabel("Chr.")); hp.add(targetBox); // window locator regionBox.setWidth("160px"); hp2.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp2.add(new FormLabel("Region")); hp2.add(regionBox); Button strandSwitch = new Button("reverse"); Style.margin(strandSwitch, Style.LEFT, 2); Style.border(strandSwitch, 2, Style.BORDER_OUTSET, "white"); strandSwitch.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { isPlusStrand = !isPlusStrand; TrackWindow window = getTrackGroup().getTrackWindow(); if (isPlusStrand) { getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome()); } else { getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome()); } } }); // TODO reverse button //hp2.add(strandSwitch); hp2.add(new ScrollButtonSet()); // save view final FormPanel saveViewForm = new FormPanel(); saveViewForm.setAction(GWT.getModuleBaseURL() + "utgb-core/EchoBackView"); saveViewForm.setEncoding(FormPanel.ENCODING_URLENCODED); saveViewForm.setMethod(FormPanel.METHOD_POST); final Hidden viewData = new Hidden("view"); final Hidden time = new Hidden("time"); final Button saveButton = new Button("save view"); HorizontalPanel formLayout = new HorizontalPanel(); formLayout.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); viewData.setVisible(false); formLayout.add(viewData); formLayout.add(time); formLayout.add(saveButton); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { XMLWriter xmlWriter = new XMLWriter(); getTrackGroup().toXML(xmlWriter); String view = xmlWriter.toString(); viewData.setValue(view); // send the time stamp Date today = new Date(); time.setValue(Long.toString(today.getTime())); saveViewForm.submit(); } }); saveViewForm.add(formLayout); DOM.setStyleAttribute(saveViewForm.getElement(), "margin", "0"); hp.add(saveViewForm); Button loadButton = new Button("load view"); loadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { getTrackGroup().insertTrack(new ViewLoaderTrack(), getTrackGroup().getTrackIndex(_self) + 1); } }); hp.add(loadButton); }
From source file:org.utgenome.gwt.utgb.client.track.lib.ViewLoaderTrack.java
License:Apache License
public ViewLoaderTrack() { super("View Loader"); // load view via HTTP HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp.add(new FormLabel("View Silk URL: ")); urlBox.setWidth("400px"); urlBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent e) { if (e.getCharCode() == KeyCodes.KEY_ENTER) { downloadView(urlBox.getText()); }/*from w ww . j a v a 2s . c o m*/ } }); Button loadButton = new Button("load"); loadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { downloadView(urlBox.getText()); } }); hp.add(urlBox); hp.add(loadButton); // load view from a file final FormPanel fileUploadForm = new FormPanel(); fileUploadForm.setAction(GWT.getModuleBaseURL() + "utgb-core/loadview"); fileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); fileUploadForm.setMethod(FormPanel.METHOD_POST); HorizontalPanel formButtonPanel = new HorizontalPanel(); FileUpload fileBox = new FileUpload(); fileBox.setName("file"); fileBox.setWidth("300px"); Button uploadButton = new Button("submit"); uploadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { fileUploadForm.submit(); } }); formButtonPanel.add(new FormLabel("View Silk File:")); formButtonPanel.add(fileBox); formButtonPanel.add(uploadButton); fileUploadForm.add(formButtonPanel); DOM.setStyleAttribute(fileUploadForm.getElement(), "margin", "0"); fileUploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent e) { getFrame().setNowLoading(); String viewXML = extractEmbeddedSilkInComment(e.getResults()); setViewSilk(viewXML); } }); // set panes panel.setStyleName("toolbox"); panel.add(hp); panel.add(fileUploadForm); }
From source file:org.vectomatic.client.rep.controller.ExportController.java
License:Open Source License
public ExportController(RepApplication app, FormPanel form) { super(app);//from www . ja v a 2 s . co m _form = form; form.setMethod(FormPanel.METHOD_POST); Element svgexport = DOM.getElementById("svgexport"); String uri = ""; if (svgexport != null) { uri = svgexport.getAttribute("content"); } form.setAction(uri); _hidden = new Hidden(); _hidden.setName("data"); form.add(_hidden); _exportSVG11MenuItem = new ControllerMenuItem(app.getView(), app.getConstants().exportSVG11Command(), new ControllerBase(_app) { @Override public void activate(DrawingView view) { export(new SVG11Visitor()); } }); _exportSVG12MenuItem = new ControllerMenuItem(app.getView(), app.getConstants().exportSVG12Command(), new ControllerBase(_app) { @Override public void activate(DrawingView view) { export(new SVG12Visitor()); } }); }