Search in sources :

Example 36 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class PerunSearchParametersWidget method addParameter.

/**
 * Adds a parameter
 */
protected void addParameter() {
    TextBox tb = new TextBox();
    final ListBoxWithObjects<AttributeDefinition> lb = new ListBoxWithObjects<AttributeDefinition>();
    inputs.put(lb, tb);
    lb.addAllItems(availableAttrDefs);
    rebuild();
}
Also used : AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) TextBox(com.google.gwt.user.client.ui.TextBox)

Example 37 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class PerunSearchParametersWidget method rebuild.

/**
 * Method which rebuild whole searcher widget when number of params changes
 */
protected void rebuild() {
    ft.clear();
    // ft.setHTML(0, 0, "<h3>" + "Search by parameters:" + "</h3>");
    // ft.getFlexCellFormatter().setColSpan(0, 0, 4);
    int row = 1;
    for (Map.Entry<ListBoxWithObjects<AttributeDefinition>, TextBox> entry : inputs.entrySet()) {
        final ListBoxWithObjects<AttributeDefinition> lb = entry.getKey();
        int selectedItem = lb.getSelectedIndex();
        lb.clear();
        lb.addAllItems(availableAttrDefs);
        lb.setSelectedIndex(selectedItem);
        CustomButton rb = new CustomButton("", SmallIcons.INSTANCE.deleteIcon());
        ft.setWidget(row, 0, lb);
        ft.setText(row, 1, "=");
        ft.setWidget(row, 2, entry.getValue());
        ft.setWidget(row, 3, rb);
        if (inputs.entrySet().size() <= 1) {
            // allow remove if more than 1
            rb.setEnabled(false);
            rb.setTitle("Enabled only when more than 1 parameter is used.");
        }
        rb.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent clickEvent) {
                inputs.keySet().remove(lb);
                rebuild();
            }
        });
        row++;
    }
    ft.setWidget(row, 0, addParameterButton);
    ft.setHTML(row, 1, "");
    ft.setWidget(row, 2, searchButton);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) TextBox(com.google.gwt.user.client.ui.TextBox) HashMap(java.util.HashMap) Map(java.util.Map)

Example 38 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class GetApplicationForm method createWidget.

/**
 * Create approval style change widget
 *
 * @param form
 */
private void createWidget(final ApplicationForm form) {
    final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
    if (form != null) {
        boolean groupForm = form.getGroup() != null;
        // create click handler
        ClickHandler ch = new ClickHandler() {

            public void onClick(ClickEvent event) {
                // layout
                FlexTable ft = new FlexTable();
                ft.setCellSpacing(10);
                ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
                ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
                if (groupForm && voHasEmbeddedGroupApplication) {
                    ft.setHTML(2, 0, "<strong>EMBEDDED: </strong>");
                    ft.setHTML(3, 0, "<strong>Module name: </strong>");
                } else {
                    ft.setHTML(2, 0, "<strong>Module name: </strong>");
                }
                // widgets
                final ListBox lbInit = new ListBox();
                final ListBox lbExt = new ListBox();
                final ListBox lbEmbed = new ListBox();
                final TextBox className = new TextBox();
                lbInit.addItem("Automatic", "true");
                lbInit.addItem("Manual", "false");
                lbExt.addItem("Automatic", "true");
                lbExt.addItem("Manual", "false");
                if (form.getAutomaticApproval() == true) {
                    lbInit.setSelectedIndex(0);
                } else {
                    lbInit.setSelectedIndex(1);
                }
                if (form.getAutomaticApprovalExtension() == true) {
                    lbExt.setSelectedIndex(0);
                } else {
                    lbExt.setSelectedIndex(1);
                }
                className.setText(form.getModuleClassName());
                ft.setWidget(0, 1, lbInit);
                ft.setWidget(1, 1, lbExt);
                if (groupForm && voHasEmbeddedGroupApplication) {
                    lbEmbed.addItem("Automatic", "true");
                    lbEmbed.addItem("Manual", "false");
                    if (form.getAutomaticApprovalEmbedded() == true) {
                        lbEmbed.setSelectedIndex(0);
                    } else {
                        lbEmbed.setSelectedIndex(1);
                    }
                    ft.setWidget(2, 1, lbEmbed);
                    ft.setWidget(3, 1, className);
                } else {
                    ft.setWidget(2, 1, className);
                }
                // click on save
                ClickHandler click = new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        // switch and send request
                        UpdateForm request = new UpdateForm(new JsonCallbackEvents() {

                            public void onFinished(JavaScriptObject jso) {
                                // recreate same widget
                                content.clear();
                                ApplicationForm newForm = jso.cast();
                                createWidget(newForm);
                            }
                        });
                        form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
                        form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
                        if (groupForm && voHasEmbeddedGroupApplication) {
                            form.setAutomaticApprovalEmbedded(Boolean.parseBoolean(lbEmbed.getValue(lbEmbed.getSelectedIndex())));
                        }
                        form.setModuleClassName(className.getText().trim());
                        request.updateForm(form);
                    }
                };
                Confirm c = new Confirm("Change application form settings", ft, click, true);
                c.show();
            }
        };
        button.addClickHandler(ch);
        String appStyle = "<strong>Approval style: </strong>";
        String module = "</br><strong>Module name: </strong>" + SafeHtmlUtils.fromString(form.getModuleClassName()).asString();
        if (form.getAutomaticApproval() == true) {
            appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
        } else {
            appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
        }
        if (form.getAutomaticApprovalExtension() == true) {
            appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
        } else {
            appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
        }
        if (groupForm && voHasEmbeddedGroupApplication) {
            if (form.getAutomaticApprovalEmbedded() == true) {
                appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EMBEDDED)";
            } else {
                appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EMBEDDED)";
            }
        }
        if (!groupForm && !session.isVoAdmin(form.getVo().getId()))
            button.setEnabled(false);
        if (groupForm && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
            button.setEnabled(false);
        content.setHTML(0, 0, appStyle + module);
        if (groupForm && voHasEmbeddedGroupApplication) {
            CheckBox checkBox = new CheckBox("Allowed for embedded applications");
            checkBox.setValue(autoRegistrationEnabled);
            if (!session.isGroupAdmin(form.getGroup().getId()))
                checkBox.setEnabled(false);
            ClickHandler clickCHB = new ClickHandler() {

                public void onClick(ClickEvent event) {
                    ArrayList<Group> list = new ArrayList<>();
                    list.add(group);
                    if (((CheckBox) event.getSource()).getValue()) {
                        AddAutoRegGroups request = new AddAutoRegGroups(JsonCallbackEvents.disableCheckboxEvents(checkBox));
                        request.setAutoRegGroups(list);
                    } else {
                        RemoveGroupsFromAutoRegistration request = new RemoveGroupsFromAutoRegistration(JsonCallbackEvents.disableCheckboxEvents(checkBox));
                        request.deleteGroups(list);
                    }
                }
            };
            checkBox.addClickHandler(clickCHB);
            content.setWidget(1, 0, checkBox);
        }
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().setRowSpan(0, 1, 2);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    } else {
        button.setEnabled(false);
        String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
        String module = "</br><strong>Module name: </strong> Form doesn't exists.";
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationForm(cz.metacentrum.perun.webgui.model.ApplicationForm) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) TextBox(com.google.gwt.user.client.ui.TextBox) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CheckBox(com.google.gwt.user.client.ui.CheckBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 39 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project pentaho-platform by pentaho.

the class OpenURLCommand method performOperation.

protected void performOperation(boolean feedback) {
    final TextBox textBox = new TextBox();
    // $NON-NLS-1$
    textBox.setText("http://");
    // $NON-NLS-1$
    textBox.setWidth("500px");
    textBox.setVisibleLength(72);
    IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
        }

        public void okPressed() {
            SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(textBox.getText(), textBox.getText(), textBox.getText(), false);
        }
    };
    IDialogValidatorCallback validatorCallback = new IDialogValidatorCallback() {

        public boolean validate() {
            // $NON-NLS-1$
            boolean isValid = !"".equals(textBox.getText()) && textBox.getText() != null;
            if (!isValid) {
                MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("urlNotSpecified"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                true);
                dialogBox.center();
            }
            return isValid;
        }
    };
    PromptDialogBox promptDialog = new PromptDialogBox(Messages.getString("enterURL"), Messages.getString("ok"), Messages.getString("cancel"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    textBox);
    promptDialog.setValidatorCallback(validatorCallback);
    promptDialog.setCallback(callback);
    // $NON-NLS-1$
    promptDialog.setWidth("500px");
    promptDialog.center();
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) TextBox(com.google.gwt.user.client.ui.TextBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) IDialogValidatorCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogValidatorCallback)

Example 40 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project pentaho-platform by pentaho.

the class ContentCleanerPanel method activate.

public void activate() {
    clear();
    String moduleBaseURL = GWT.getModuleBaseURL();
    String moduleName = GWT.getModuleName();
    String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL + "api/scheduler/getContentCleanerJob?cb=" + System.currentTimeMillis());
    scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("accept", "application/json");
    try {
        scheduleFileRequestBuilder.sendRequest("", new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            }

            public void onResponseReceived(Request request, Response response) {
                final TextBox nowTextBox = new TextBox();
                nowTextBox.setWidth("24px");
                nowTextBox.getElement().getStyle().setPadding(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginLeft(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginRight(5, Unit.PX);
                final TextBox scheduleTextBox = new TextBox();
                scheduleTextBox.setVisibleLength(4);
                JsJob tmpJsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
                boolean fakeJob = false;
                if (tmpJsJob == null) {
                    tmpJsJob = createJsJob();
                    fakeJob = true;
                }
                final JsJob jsJob = tmpJsJob;
                if (jsJob != null) {
                    scheduleTextBox.setValue("" + (Long.parseLong(jsJob.getJobParamValue("age")) / DAY_IN_MILLIS));
                } else {
                    scheduleTextBox.setText("180");
                }
                scheduleTextBox.addChangeHandler(new ChangeHandler() {

                    public void onChange(ChangeEvent event) {
                        if (jsJob != null) {
                            JsArray<JsJobParam> params = jsJob.getJobParams();
                            for (int i = 0; i < params.length(); i++) {
                                if (params.get(i).getName().equals("age")) {
                                    params.get(i).setValue("" + (Long.parseLong(scheduleTextBox.getText()) * DAY_IN_MILLIS));
                                    break;
                                }
                            }
                        }
                    }
                });
                Label settingsLabel = new Label(Messages.getString("settings"));
                settingsLabel.setStyleName("pentaho-fieldgroup-major");
                add(settingsLabel, DockPanel.NORTH);
                VerticalPanel nowPanelWrapper = new VerticalPanel();
                Label deleteNowLabel = new Label(Messages.getString("deleteGeneratedFilesNow"));
                deleteNowLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                deleteNowLabel.setStyleName("pentaho-fieldgroup-minor");
                nowPanelWrapper.add(deleteNowLabel);
                HorizontalPanel nowLabelPanel = new HorizontalPanel();
                nowLabelPanel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                nowLabelPanel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Label deleteGeneratedFilesOlderThan = new Label(Messages.getString("deleteGeneratedFilesOlderThan"));
                deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(deleteGeneratedFilesOlderThan);
                nowLabelPanel.add(nowTextBox);
                nowTextBox.setText("180");
                Label days = new Label(Messages.getString("daysDot"));
                days.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(days);
                Button deleteNowButton = new Button(Messages.getString("deleteNow"));
                deleteNowButton.setStylePrimaryName("pentaho-button");
                deleteNowButton.addStyleName("first");
                deleteNowButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        MessageDialogBox warning = new MessageDialogBox(Messages.getString("deleteNow"), Messages.getString("confirmDeleteGeneratedContentNow"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
                        warning.setCallback(new IDialogCallback() {

                            @Override
                            public void okPressed() {
                                deleteContentNow(Long.parseLong(nowTextBox.getValue()) * DAY_IN_MILLIS);
                            }

                            @Override
                            public void cancelPressed() {
                            }
                        });
                        warning.center();
                    }
                });
                nowPanelWrapper.add(nowLabelPanel);
                nowPanelWrapper.add(deleteNowButton);
                add(nowPanelWrapper, DockPanel.NORTH);
                // scheduled
                VerticalPanel scheduledPanel = new VerticalPanel();
                Label deleteScheduleLabel = new Label(Messages.getString("scheduleDeletionOfGeneratedFiles"));
                deleteScheduleLabel.setStyleName("pentaho-fieldgroup-minor");
                deleteScheduleLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                scheduledPanel.add(deleteScheduleLabel);
                Label descLabel;
                if (!fakeJob) {
                    String desc = jsJob.getJobTrigger().getDescription();
                    descLabel = new Label(desc);
                    scheduledPanel.add(descLabel);
                } else {
                    descLabel = new Label(Messages.getString("generatedFilesAreNotScheduledToBeDeleted"));
                    scheduledPanel.add(descLabel);
                }
                descLabel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                descLabel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Button editScheduleButton = new Button(Messages.getString("edit"));
                if (fakeJob) {
                    editScheduleButton.setText(Messages.getString("scheduleDeletion"));
                }
                Button deleteScheduleButton = new Button(Messages.getString("cancelSchedule"));
                deleteScheduleButton.setStylePrimaryName("pentaho-button");
                deleteScheduleButton.addStyleName("last");
                deleteScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        deleteContentCleaner(jsJob);
                    }
                });
                editScheduleButton.setStylePrimaryName("pentaho-button");
                editScheduleButton.addStyleName("first");
                editScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        IDialogCallback callback = new IDialogCallback() {

                            public void okPressed() {
                                deleteContentCleaner(jsJob);
                            }

                            public void cancelPressed() {
                            }
                        };
                        HorizontalPanel scheduleLabelPanel = new HorizontalPanel();
                        scheduleLabelPanel.add(new Label(Messages.getString("deleteGeneratedFilesOlderThan"), false));
                        scheduleLabelPanel.add(scheduleTextBox);
                        scheduleLabelPanel.add(new Label(Messages.getString("daysUsingTheFollowingRules"), false));
                        ScheduleRecurrenceDialog editSchedule = new ScheduleRecurrenceDialog(null, jsJob, callback, false, false, AbstractWizardDialog.ScheduleDialogType.SCHEDULER);
                        editSchedule.setShowSuccessDialog(false);
                        editSchedule.addCustomPanel(scheduleLabelPanel, DockPanel.NORTH);
                        editSchedule.center();
                    }
                });
                HorizontalPanel scheduleButtonPanel = new HorizontalPanel();
                scheduleButtonPanel.add(editScheduleButton);
                if (!fakeJob) {
                    scheduleButtonPanel.add(deleteScheduleButton);
                }
                scheduledPanel.add(scheduleButtonPanel);
                add(scheduledPanel, DockPanel.NORTH);
                VerticalPanel fillPanel = new VerticalPanel();
                add(fillPanel, DockPanel.NORTH);
                fillPanel.getElement().getParentElement().getStyle().setHeight(100, Unit.PCT);
            }
        });
    } catch (RequestException re) {
    // ignored
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Request(com.google.gwt.http.client.Request) Label(com.google.gwt.user.client.ui.Label) JsJobParam(org.pentaho.mantle.client.workspace.JsJobParam) JSONString(com.google.gwt.json.client.JSONString) TextBox(com.google.gwt.user.client.ui.TextBox) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RequestCallback(com.google.gwt.http.client.RequestCallback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(com.google.gwt.user.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) JsJob(org.pentaho.mantle.client.workspace.JsJob) ScheduleRecurrenceDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog)

Aggregations

TextBox (com.google.gwt.user.client.ui.TextBox)41 Label (com.google.gwt.user.client.ui.Label)13 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)13 Test (org.junit.Test)10 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)8 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 CheckBox (com.google.gwt.user.client.ui.CheckBox)5 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 Grid (com.google.gwt.user.client.ui.Grid)4 PasswordTextBox (com.google.gwt.user.client.ui.PasswordTextBox)3 HashMap (java.util.HashMap)3 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)2 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)2 JSONString (com.google.gwt.json.client.JSONString)2 Button (com.google.gwt.user.client.ui.Button)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 HTML (com.google.gwt.user.client.ui.HTML)2 ListBox (com.google.gwt.user.client.ui.ListBox)2