Example usage for com.google.gwt.user.client.ui Hidden Hidden

List of usage examples for com.google.gwt.user.client.ui Hidden Hidden

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Hidden Hidden.

Prototype

protected Hidden(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:org.ow2.proactive_grid_cloud_portal.common.client.LoginPage.java

License:Open Source License

/**
 * @return the forms and widgets for plain login/password authentication
 *///from  w ww.j  a v  a 2 s  . co  m
private Layout getPlainAuth() {

    /* smartGWT forms don't allow simple multipart file upload,
     * so we use a smartGWT form for login/password/checkbox,
     * a pure GWT form for file upload, and upon submission,
     * put the fields from the first form as hidden fields of the
     * pure GWT form. It's a bit convoluted but like this we get
     * the pretty widgets and the nice features       */

    TextItem loginField = new TextItem("login", "User");
    loginField.setRequired(true);

    PasswordItem passwordField = new PasswordItem("password", "Password");
    passwordField.setRequired(true);

    final CheckboxItem moreField = new CheckboxItem("useSSH", "Use SSH private key");
    moreField.setValue(false);

    // smartGWT form: only used to input the data before filling the hidden fields
    // in the other form with it
    final DynamicForm form = new DynamicForm();
    form.setFields(loginField, passwordField, moreField);
    form.hideItem("useSSH");

    // pure GWT form for uploading, will be used to contact the servlet
    // even if no ssh key is used
    final FileUpload fileUpload = new FileUpload();
    fileUpload.setName("sshkey");
    final Hidden hiddenUser = new Hidden("username");
    final Hidden hiddenPass = new Hidden("password");
    final FormPanel formPanel = new FormPanel();
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_POST);
    formPanel.setAction(GWT.getModuleBaseURL() + "login");
    final VerticalPanel vpan = new VerticalPanel();
    vpan.add(hiddenUser);
    vpan.add(hiddenPass);
    vpan.add(fileUpload);
    formPanel.setWidget(vpan);
    formPanel.setWidth("100%");
    formPanel.setHeight("30px");
    final HLayout formWrapper = new HLayout();
    formWrapper.setAlign(Alignment.CENTER);
    formWrapper.addChild(formPanel);
    formWrapper.setWidth100();
    formWrapper.addDrawHandler(new DrawHandler() {
        public void onDraw(DrawEvent event) {
            // took me half a day to find this hack:
            // if the form is added to the page in a hidden element,
            // it is never created and submission fails without callback.
            // it needs to be visible so that it is created once, then
            // we can safely hide it and still use it
            if (disableFormWrapper) {
                disableFormWrapper = false;
                formWrapper.setVisible(false);
            }
        }
    });

    // hide/show the ssh key upload input
    moreField.addChangedHandler(new ChangedHandler() {
        public void onChanged(ChangedEvent event) {
            if (moreField.getValueAsBoolean()) {
                //formWrapper.setVisible(true);
                formWrapper.animateShow(AnimationEffect.FLY);
            } else {
                //formWrapper.setVisible(false);
                formWrapper.animateHide(AnimationEffect.FLY);
                formPanel.reset();
            }
        }
    });
    // prevent form validation if no ssh key is selected
    Validator moreVal = new CustomValidator() {
        @Override
        protected boolean condition(Object value) {
            if (moreField.getValueAsBoolean()) {
                String file = fileUpload.getFilename();
                return (file != null && file.length() > 0);
            } else {
                return true;
            }
        }
    };
    moreVal.setErrorMessage("No file selected");
    moreField.setValidators(moreVal);

    final Runnable advancedVisibilityChanged = new Runnable() {
        @Override
        public void run() {
            if (!moreField.getVisible()) {
                authSelLayout.setVisible(true);
                form.showItem("useSSH");
                optsLabel.setIcon(Images.instance.close_16().getSafeUri().asString());
                optsLabel.setContents(
                        "<nobr style='color:#003168;font-size: 1.2em;" + "cursor:pointer'>less options</nobr>");
            } else {
                authTypeSelectForm.setValue("Mode", "Basic");
                switchPlainCredForm.run();
                authSelLayout.setVisible(false);
                form.hideItem("useSSH");
                formWrapper.animateHide(AnimationEffect.FLY);
                moreField.setValue(false);
                formPanel.reset();
                optsLabel.setIcon(Images.instance.expand_16().getSafeUri().asString());
                optsLabel.setContents(
                        "<nobr style='color:#003168;font-size: 1.2em;" + "cursor:pointer'>more options</nobr>");
            }
        }
    };
    optsLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            advancedVisibilityChanged.run();
        }
    });

    String cacheLogin = Settings.get().getSetting(controller.getLoginSettingKey());
    if (cacheLogin != null) {
        form.setValue("login", cacheLogin);
    }

    final IButton okButton = new IButton();
    okButton.setShowDisabled(false);
    okButton.setIcon(Images.instance.connect_16().getSafeUri().asString());
    okButton.setTitle("Connect");
    okButton.setWidth(120);
    okButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (!form.validate())
                return;

            String login = form.getValueAsString("login");
            String pw = form.getValueAsString("password");
            hiddenUser.setValue(login);
            hiddenPass.setValue(pw);

            okButton.setIcon("loading.gif");
            okButton.setTitle("Connecting...");
            form.disable();
            formWrapper.disable();

            authTypeSelectForm.disable();
            okButton.disable();

            // only submit once the the error message is hidden so we don't try to show it (on form response)
            // while the effect is played resulting in the message hidden staying hidden
            if (errorLabel.isDrawn() && errorLabel.isVisible()) {
                errorLabel.animateHide(AnimationEffect.FLY, new AnimationCallback() {
                    @Override
                    public void execute(boolean earlyFinish) {
                        formPanel.submit();
                    }
                });
            } else {
                formPanel.submit();
            }
        }
    });

    formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            String res = new HTML(event.getResults()).getText();
            boolean fail = false;
            try {
                JSONValue val = controller.parseJSON(res);
                JSONObject obj = val.isObject();
                if (obj != null && obj.containsKey("sessionId")) {
                    String sess = obj.isObject().get("sessionId").isString().stringValue();
                    controller.login(sess, form.getValueAsString("login"));
                } else {
                    fail = true;
                }
            } catch (Throwable t) {
                fail = true;
            }

            if (fail) {
                String err = JSONUtils.getJsonErrorMessage(res);
                int sta = JSONUtils.getJsonErrorCode(res);
                if (sta != -1)
                    err += " (" + sta + ")";
                errorLabel.setContents("<span style='color:red;'>Could not login: " + err + "</span>");
                errorLabel.animateShow(AnimationEffect.FLY);

                okButton.setIcon(Images.instance.connect_16().getSafeUri().asString());
                okButton.setTitle("Connect");
                formWrapper.enable();
                form.enable();
                authTypeSelectForm.enable();
                okButton.enable();
            }
        }
    });

    form.addItemKeyPressHandler(new ItemKeyPressHandler() {
        public void onItemKeyPress(ItemKeyPressEvent event) {
            if ("Enter".equals(event.getKeyName())) {
                okButton.fireEvent(new ClickEvent(null));
            }
        }
    });

    Layout formLayout = new VLayout();
    formLayout.setWidth100();
    formLayout.setMembersMargin(10);
    formLayout.addMember(form);
    formLayout.addMember(formWrapper);

    HLayout buttonBar = new HLayout();
    buttonBar.setWidth100();
    buttonBar.setAlign(Alignment.CENTER);
    buttonBar.addMember(okButton);
    formLayout.addMember(buttonBar);

    return formLayout;
}

From source file:org.ow2.proactive_grid_cloud_portal.rm.client.nodesource.serialization.export.file.ExportToFileHandler.java

License:Open Source License

private void createSubmitWindow() {
    this.exportToFileWindow = new Window();
    this.exportToFileFormPanel = new FormPanel();
    configureFormPanel(this.exportToFileFormPanel);
    VerticalPanel panel = new VerticalPanel();

    this.fileContentItem = new Hidden(FILE_CONTENT_PARAM);
    this.fileSuffixItem = new Hidden(FILE_SUFFIX_PARAM);
    this.nodeSourceNameItem = new Hidden(NODE_SOURCE_NAME_PARAM);

    panel.add(this.fileContentItem);
    panel.add(this.fileSuffixItem);
    panel.add(this.nodeSourceNameItem);
    this.exportToFileFormPanel.setWidget(panel);
    this.exportToFileWindow.addChild(this.exportToFileFormPanel);
    this.exportToFileWindow.show();
}

From source file:org.pentaho.mantle.client.dialogs.ImportDialog.java

License:Open Source License

/**
 * @param repositoryFile//  ww w. jav  a  2s.co  m
 */
public ImportDialog(RepositoryFile repositoryFile, boolean allowAdvancedDialog) {
    super(Messages.getString("import"), Messages.getString("ok"), Messages.getString("cancel"), false, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    form = new FormPanel();
    form.addSubmitHandler(new SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent se) {
            // if no file is selected then do not proceed
            okButton.setEnabled(false);
            cancelButton.setEnabled(false);
            MantleApplication.showBusyIndicator(Messages.getString("pleaseWait"),
                    Messages.getString("importInProgress"));
        }
    });
    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(SubmitCompleteEvent sce) {
            MantleApplication.hideBusyIndicator();
            okButton.setEnabled(false);
            cancelButton.setEnabled(true);
            ImportDialog.this.hide();
            String result = sce.getResults();
            if (result.length() > 5) {
                HTML messageTextBox = null;
                if (result.contains("INVALID_MIME_TYPE") == true) {
                    messageTextBox = new HTML(Messages.getString("uploadInvalidFileTypeQuestion", result));
                } else {
                    logWindow(result, Messages.getString("importLogWindowTitle"));
                }

                if (messageTextBox != null) {
                    PromptDialogBox dialogBox = new PromptDialogBox(Messages.getString("uploadUnsuccessful"),
                            Messages.getString("close"), null, true, true);
                    dialogBox.setContent(messageTextBox);
                    dialogBox.center();
                }
            }

            // if mantle_isBrowseRepoDirty=true: do getChildren call
            // if mantle_isBrowseRepoDirty=false: use stored fileBrowserModel in myself.get("cachedData")
            setBrowseRepoDirty(Boolean.TRUE);

            // BISERVER-9319 Refresh browse perspective after import
            final GenericEvent event = new GenericEvent();
            event.setEventSubType("ImportDialogEvent");
            EventBusUtil.EVENT_BUS.fireEvent(event);
        }
    });

    VerticalPanel rootPanel = new VerticalPanel();

    VerticalPanel spacer = new VerticalPanel();
    spacer.setHeight("10px");
    rootPanel.add(spacer);

    Label fileLabel = new Label(Messages.getString("file") + ":");
    final TextBox importDir = new TextBox();
    rootPanel.add(fileLabel);

    okButton.setEnabled(false);

    final TextBox fileTextBox = new TextBox();
    fileTextBox.setEnabled(false);

    //We use an fileNameOverride because FileUpload can only handle US character set reliably.
    final Hidden fileNameOverride = new Hidden("fileNameOverride");

    final FileUpload upload = new FileUpload();
    upload.setName("fileUpload");
    ChangeHandler fileUploadHandler = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            fileTextBox.setText(upload.getFilename());
            if (!"".equals(importDir.getValue())) {
                //Set the fileNameOverride because the fileUpload object can only reliably transmit US-ASCII
                //character set.  See RFC283 section 2.3 for details
                String fileNameValue = upload.getFilename().replaceAll("\\\\", "/");
                fileNameValue = fileNameValue.substring(fileNameValue.lastIndexOf("/") + 1);
                fileNameOverride.setValue(fileNameValue);
                okButton.setEnabled(true);
            } else {
                okButton.setEnabled(false);
            }
        }
    };
    upload.addChangeHandler(fileUploadHandler);
    upload.setVisible(false);

    HorizontalPanel fileUploadPanel = new HorizontalPanel();
    fileUploadPanel.add(fileTextBox);
    fileUploadPanel.add(new HTML("&nbsp;"));

    Button browseButton = new Button(Messages.getString("browse") + "...");
    browseButton.setStyleName("pentaho-button");
    fileUploadPanel.add(browseButton);
    browseButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            setRetainOwnershipState();
            jsClickUpload(upload.getElement());
        }
    });

    rootPanel.add(fileUploadPanel);
    rootPanel.add(upload);

    applyAclPermissions.setName("applyAclPermissions");
    applyAclPermissions.setValue(Boolean.FALSE);
    applyAclPermissions.setFormValue("false");
    applyAclPermissions.setEnabled(true);
    applyAclPermissions.setVisible(false);

    final CheckBox overwriteAclPermissions = new CheckBox(Messages.getString("overwriteAclPermissions"), true);
    overwriteAclPermissions.setName("overwriteAclPermissions");
    applyAclPermissions.setValue(Boolean.FALSE);
    applyAclPermissions.setFormValue("false");
    overwriteAclPermissions.setEnabled(true);
    overwriteAclPermissions.setVisible(false);

    final Hidden overwriteFile = new Hidden("overwriteFile");
    overwriteFile.setValue("true");

    final Hidden logLevel = new Hidden("logLevel");
    logLevel.setValue("ERROR");

    final Hidden retainOwnership = new Hidden("retainOwnership");
    retainOwnership.setValue("true");

    rootPanel.add(applyAclPermissions);
    rootPanel.add(overwriteAclPermissions);
    rootPanel.add(overwriteFile);
    rootPanel.add(logLevel);
    rootPanel.add(retainOwnership);
    rootPanel.add(fileNameOverride);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    rootPanel.add(spacer);

    DisclosurePanel disclosurePanel = new DisclosurePanel(Messages.getString("advancedOptions"));
    disclosurePanel.getHeader().setStyleName("gwt-Label");
    disclosurePanel.setVisible(allowAdvancedDialog);
    HorizontalPanel mainPanel = new HorizontalPanel();
    mainPanel.add(new HTML("&nbsp;"));
    VerticalPanel disclosureContent = new VerticalPanel();

    HTML replaceLabel = new HTML(Messages.getString("fileExists"));
    replaceLabel.setStyleName("gwt-Label");
    disclosureContent.add(replaceLabel);

    final CustomListBox overwriteFileDropDown = new CustomListBox();
    final CustomListBox filePermissionsDropDown = new CustomListBox();

    DefaultListItem replaceListItem = new DefaultListItem(Messages.getString("replaceFile"));
    replaceListItem.setValue("true");
    overwriteFileDropDown.addItem(replaceListItem);
    DefaultListItem doNotImportListItem = new DefaultListItem(Messages.getString("doNotImport"));
    doNotImportListItem.setValue("false");
    overwriteFileDropDown.addItem(doNotImportListItem);
    overwriteFileDropDown.setVisibleRowCount(1);
    disclosureContent.add(overwriteFileDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    HTML filePermissionsLabel = new HTML(Messages.getString("filePermissions"));
    filePermissionsLabel.setStyleName("gwt-Label");
    disclosureContent.add(filePermissionsLabel);

    DefaultListItem usePermissionsListItem = new DefaultListItem(Messages.getString("usePermissions"));
    usePermissionsListItem.setValue("false");
    filePermissionsDropDown.addItem(usePermissionsListItem); // If selected set "overwriteAclPermissions" to
    // false.
    DefaultListItem retainPermissionsListItem = new DefaultListItem(Messages.getString("retainPermissions"));
    retainPermissionsListItem.setValue("true");
    filePermissionsDropDown.addItem(retainPermissionsListItem); // If selected set "overwriteAclPermissions" to
    // true.

    final ChangeListener filePermissionsHandler = new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = filePermissionsDropDown.getSelectedItem().getValue().toString();

            applyAclPermissions.setValue(Boolean.valueOf(value));
            applyAclPermissions.setFormValue(value);
            overwriteAclPermissions.setFormValue(value);
            overwriteAclPermissions.setValue(Boolean.valueOf(value));
            setRetainOwnershipState();
        }
    };
    filePermissionsDropDown.addChangeListener(filePermissionsHandler);
    filePermissionsDropDown.setVisibleRowCount(1);
    disclosureContent.add(filePermissionsDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    HTML fileOwnershipLabel = new HTML(Messages.getString("fileOwnership"));
    fileOwnershipLabel.setStyleName("gwt-Label");
    disclosureContent.add(fileOwnershipLabel);

    retainOwnershipDropDown.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = retainOwnershipDropDown.getSelectedItem().getValue().toString();
            retainOwnership.setValue(value);
        }
    });
    DefaultListItem keepOwnershipListItem = new DefaultListItem(Messages.getString("keepOwnership"));
    keepOwnershipListItem.setValue("true");
    retainOwnershipDropDown.addItem(keepOwnershipListItem);
    DefaultListItem assignOwnershipListItem = new DefaultListItem(Messages.getString("assignOwnership"));
    assignOwnershipListItem.setValue("false");
    retainOwnershipDropDown.addItem(assignOwnershipListItem);

    retainOwnershipDropDown.setVisibleRowCount(1);
    disclosureContent.add(retainOwnershipDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    ChangeListener overwriteFileHandler = new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = overwriteFileDropDown.getSelectedItem().getValue().toString();
            overwriteFile.setValue(value);
        }
    };
    overwriteFileDropDown.addChangeListener(overwriteFileHandler);

    HTML loggingLabel = new HTML(Messages.getString("logging"));
    loggingLabel.setStyleName("gwt-Label");
    disclosureContent.add(loggingLabel);

    final CustomListBox loggingDropDown = new CustomListBox();
    loggingDropDown.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            String value = loggingDropDown.getSelectedItem().getValue().toString();
            logLevel.setValue(value);
        }
    });
    DefaultListItem noneListItem = new DefaultListItem(Messages.getString("none"));
    noneListItem.setValue("ERROR");
    loggingDropDown.addItem(noneListItem);
    DefaultListItem shortListItem = new DefaultListItem(Messages.getString("short"));
    shortListItem.setValue("WARN");
    loggingDropDown.addItem(shortListItem);
    DefaultListItem debugListItem = new DefaultListItem(Messages.getString("verbose"));
    debugListItem.setValue("TRACE");
    loggingDropDown.addItem(debugListItem);
    loggingDropDown.setVisibleRowCount(1);
    disclosureContent.add(loggingDropDown);

    mainPanel.add(disclosureContent);
    disclosurePanel.setContent(mainPanel);
    rootPanel.add(disclosurePanel);

    importDir.setName("importDir");
    importDir.setText(repositoryFile.getPath());
    importDir.setVisible(false);

    rootPanel.add(importDir);

    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    setFormAction();

    form.add(rootPanel);

    setContent(form);
}

From source file:org.pentaho.pat.client.ui.panels.PropertiesPanel.java

License:Open Source License

/**
 * PropertiesPanel Constructor.//  w  ww.  java 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.rebioma.client.CsvDownloadWidget.java

License:Apache License

public CsvDownloadWidget() {
    super(true);/*www.ja v a2  s .  com*/
    AppConstants constants = ApplicationView.getConstants();
    myDownload = false;
    form = new FormPanel();
    downloadButton = new Button(constants.AcceptAndDownload());
    form.setAction(GWT.getModuleBaseURL() + "downloadFile");

    form.setEncoding(Encoding.MULTIPART);
    form.setMethod(Method.POST);
    //    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    //    form.setMethod(FormPanel.METHOD_POST);
    hiddenSessionId = new Hidden("sessionId");
    hiddenQuery = new Hidden("query");
    extraInfo = new Hidden("extra");
    userEmail = new Hidden("useremail");
    HorizontalPanel delimiterPanel = new HorizontalPanel();
    ListBox delimiterBox = new ListBox();
    delimiterBox.setName("delimiter");
    delimiterBox.addItem(constants.Comma(), ",");
    delimiterBox.addItem(constants.Semicolon(), ";");
    delimiterPanel.setSpacing(2);
    delimiterPanel.add(delimiterBox);
    delimiterPanel.add(new HTML(constants.CSVDelimiter()));

    HorizontalPanel downloadPanel = new HorizontalPanel();
    downloadPanel.setSpacing(2);
    cancelButton = new Button(constants.Close());
    downloadPanel.add(downloadButton);
    downloadPanel.add(cancelButton);
    mainVp.setWidth("380px");
    mainVp.add(hiddenSessionId);
    mainVp.add(hiddenQuery);
    mainVp.add(extraInfo);
    mainVp.add(userEmail);
    RTextField title = new RTextField(false);
    title.setName("title");
    title.setEmptyText("Mr, Mme, Pr, Dr, ...");
    RTextField firstN = new RTextField(false);
    firstN.setName("firstN");
    RTextField lastN = new RTextField(true);
    lastN.setName("lastN");
    RTextField activity = new RTextField(false);
    activity.setName("activity");
    RTextField email = new RTextField(false);
    email.setName("email");
    RTextField institution = new RTextField(true);
    institution.setName("institution");
    TextArea dataUE = new TextArea();
    dataUE.setWidth(270);
    dataUE.setAllowBlank(false);
    dataUE.setName("dataue");
    info = new Label("* required fields");
    infoP = new Label(
            "These informations will be sent to the related data owners and the REBIOMA portal administrator. "
                    + "Please fill correctly the form and give more explanations as possible!");
    infoP.setStyleName("infop");
    fieldTitle = new FieldLabel(title, "Title*");
    fieldFirstN = new FieldLabel(firstN, "First name*");
    fieldLastN = new FieldLabel(lastN, "Last name");
    fieldActivity = new FieldLabel(activity, "Activities*/ Profession");
    fieldEmail = new FieldLabel(email, "Email*");
    fieldInstitution = new FieldLabel(institution, "Institution");
    fieldDataUE = new FieldLabel(dataUE, "Data use explanation*");

    mainVp.add(fieldTitle);
    mainVp.add(fieldFirstN);
    mainVp.add(fieldLastN);
    mainVp.add(fieldActivity);
    mainVp.add(fieldEmail);
    mainVp.add(fieldInstitution);
    mainVp.add(fieldDataUE);
    mainVp.add(info);
    mainVp.add(infoP);
    mainVp.add(new FieldLabel(delimiterBox, constants.CSVDelimiter()));
    //    mainVp.add(delimiterPanel);
    mainVp.add(termsOfUseLabel);
    mainVp.add(downloadPanel);
    form.setWidget(mainVp);
    setWidget(form);
    mainVp.setSpacing(5);
    downloadButton.addClickHandler(this);
    cancelButton.addClickHandler(this);
    // FormPanel only works if attached to something.
    // RootPanel.get().add(this);

}

From source file:org.rebioma.client.CsvDownloadWidget.java

License:Apache License

public CsvDownloadWidget(String downloadModel) {
    super(true);/*from   w w  w .  ja v  a 2  s.  c  om*/
    AppConstants constants = ApplicationView.getConstants();
    form = new FormPanel();
    downloadModelButton = new Button(constants.Download());
    userEmail = new Hidden("useremail");
    HorizontalPanel downloadPanel = new HorizontalPanel();
    downloadPanel.setSpacing(2);
    cancelButton = new Button(constants.Close());
    downloadPanel.add(downloadModelButton);
    downloadPanel.add(cancelButton);
    mainVp.setWidth("380px");
    mainVp.add(userEmail);
    RTextField title = new RTextField(false);
    title.setName("title");
    title.setEmptyText("Mr, Mme, Pr, Dr, ...");
    RTextField firstN = new RTextField(false);
    firstN.setName("firstN");
    RTextField lastN = new RTextField(true);
    lastN.setName("lastN");
    RTextField activity = new RTextField(false);
    activity.setName("activity");
    RTextField email = new RTextField(false);
    email.setName("email");
    RTextField institution = new RTextField(true);
    institution.setName("institution");
    TextArea dataUE = new TextArea();
    dataUE.setWidth(270);
    dataUE.setAllowBlank(false);
    dataUE.setName("dataue");
    info = new Label("* required fields");
    infoP = new Label("These informations will be sent to the REBIOMA portal administrator. "
            + "Please fill correctly the form and give more explanations as possible!");
    infoP.setStyleName("infop");
    fieldTitle = new FieldLabel(title, "Title*");
    fieldFirstN = new FieldLabel(firstN, "First name*");
    fieldLastN = new FieldLabel(lastN, "Last name");
    fieldActivity = new FieldLabel(activity, "Activities*/ Profession");
    fieldEmail = new FieldLabel(email, "Email*");
    fieldInstitution = new FieldLabel(institution, "Institution");
    fieldDataUE = new FieldLabel(dataUE, "Data use explanation*");

    mainVp.add(fieldTitle);
    mainVp.add(fieldFirstN);
    mainVp.add(fieldLastN);
    mainVp.add(fieldActivity);
    mainVp.add(fieldEmail);
    mainVp.add(fieldInstitution);
    mainVp.add(fieldDataUE);
    mainVp.add(info);
    mainVp.add(infoP);
    mainVp.add(downloadPanel);
    form.setWidget(mainVp);
    setWidget(form);
    mainVp.setSpacing(5);
    downloadModelButton.addClickHandler(this);
    cancelButton.addClickHandler(this);

}

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());
            }// w w w .  j av  a2  s . c  o m
        }
    });
    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);

}