Search in sources :

Example 6 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project rstudio by rstudio.

the class NewPackagePage method onAddTopPanelWidgets.

@Override
protected void onAddTopPanelWidgets(HorizontalPanel panel) {
    dirNameLabel_.setText("Package name:");
    String[] labels = { "Package" };
    String[] values = { "package" };
    listProjectType_ = new SelectWidget("Type:", labels, values, false);
    listProjectType_.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            txtProjectName_.setFocus(true);
        }
    });
    panel.add(listProjectType_);
}
Also used : SelectWidget(org.rstudio.core.client.widget.SelectWidget) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 7 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project gwt-test-utils by gwt-test-utils.

the class MyBeautifulApp method onModuleLoad.

public void onModuleLoad() {
    FlowPanel panel = new FlowPanel();
    b1 = new Button("Button1's HTML");
    b1.getElement().setId("button-1");
    panel.add(b1);
    b2 = new Button("Button2's HTML");
    b2.getElement().setId("button-2");
    panel.add(b2);
    l = new Label();
    l.setText("init");
    panel.add(l);
    t = new TextBox();
    panel.add(t);
    historyLabel = new Label();
    panel.add(historyLabel);
    invisibleTB = new TextBox();
    invisibleTB.setVisible(false);
    panel.add(invisibleTB);
    lb = new ListBox();
    lb.addItem("lbText0");
    lb.addItem("lbText1");
    lb.addItem("lbText2");
    panel.add(lb);
    RootPanel.get().add(panel);
    b1.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b1");
        }
    });
    b2.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            l.setText("click on b2");
        }
    });
    b3 = new Button("Button3's HTML");
    panel.add(b3);
    b3.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod(l.getText(), new AsyncCallback<String>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(String arg0) {
                    l.setText(arg0);
                }
            });
        }
    });
    b4 = new Button("Button4's HTML");
    panel.add(b4);
    b4.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod2(new MyCustomObject("toto"), new AsyncCallback<MyCustomObject>() {

                public void onFailure(Throwable t) {
                    throw new RuntimeException(t);
                }

                public void onSuccess(MyCustomObject object) {
                    l.setText(object.myField + " " + object.myTransientField);
                }
            });
        }
    });
    b5 = new Button("Button5's HTML");
    panel.add(b5);
    b5.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent arg0) {
            MyRemoteServiceAsync remoteServiceAsync = GWT.create(MyRemoteService.class);
            remoteServiceAsync.myMethod3(new AsyncCallback<Void>() {

                public void onFailure(Throwable arg0) {
                    l.setText("error");
                }

                public void onSuccess(Void arg0) {
                    l.setText("success");
                }
            });
        }
    });
    t.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("t was filled with value \"" + t.getText() + "\"");
        }
    });
    invisibleTB.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            historyLabel.setText("invisibleTB was filled with value \"" + invisibleTB.getText() + "\"");
        }
    });
    myComposite = new MyComposite("myComposite Label", "MyComposite Button");
    panel.add(myComposite);
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 8 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.

the class JsonErrorHandler method reportBox.

/**
	 * Creates and display a report box used for reporting errors
	 *
	 * @param error Error object returned from RPC
	 */
public static void reportBox(final PerunError error) {
    // clear password fields if present
    final JSONObject postObject = new JSONObject(JsonUtils.parseJson(error.getPostData()));
    if (postObject.getJavaScriptObject() != null) {
        clearPasswords(postObject);
    }
    String s = "unknown";
    if (PerunWebSession.getInstance().getTabManager() != null) {
        s = PerunWebSession.getInstance().getTabManager().getCurrentUrl(true);
    }
    final String status = s;
    final TextBox boxSubject = new TextBox();
    boxSubject.setValue("Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")");
    boxSubject.setWidth("100%");
    final TextArea messageTextBox = new TextArea();
    messageTextBox.setSize("335px", "100px");
    // ok click - report
    ClickHandler sendReportHandler = new ClickHandler() {

        public void onClick(ClickEvent event) {
            String text = getErrorFullMessage(messageTextBox, error, postObject, status);
            final String finalText = text;
            // request itself
            SendMessageToRt msg = new SendMessageToRt(new JsonCallbackEvents() {

                @Override
                public void onError(PerunError error) {
                    FlexTable layout = new FlexTable();
                    TextArea scrollPanel = new TextArea();
                    scrollPanel.setText(finalText);
                    layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.errorIcon())));
                    layout.setHTML(0, 1, "<p>Reporting errors is not working at the moment. We are sorry for inconvenience. <p>Please send following text to <strong>perun@cesnet.cz</strong>.");
                    layout.getFlexCellFormatter().setColSpan(1, 0, 2);
                    layout.setWidget(1, 0, scrollPanel);
                    scrollPanel.setSize("350px", "150px");
                    layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
                    Confirm c = new Confirm("Error report is not working", layout, true);
                    c.setNonScrollable(true);
                    c.setAutoHide(false);
                    c.show();
                }
            });
            if (boxSubject.getValue().isEmpty()) {
                msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, "Reported error: " + error.getRequest().getManager() + "/" + error.getRequest().getMethod() + " (" + error.getErrorId() + ")", text);
            } else {
                msg.sendMessage(SendMessageToRt.DEFAULT_QUEUE, boxSubject.getValue(), text);
            }
        }
    };
    FlexTable baseLayout = new FlexTable();
    baseLayout.setStyleName("alert-box-table");
    baseLayout.setWidth("350px");
    baseLayout.setHTML(0, 0, "<p>You can provide any message for this error report (e.g. describing what you tried to do). When you are done, click on send button.");
    baseLayout.setHTML(1, 0, "<strong>Subject:</strong>");
    baseLayout.setWidget(2, 0, boxSubject);
    baseLayout.setHTML(3, 0, "<strong>Message:</strong>");
    baseLayout.setWidget(4, 0, messageTextBox);
    final Anchor showDetails = new Anchor("Show message preview");
    final TextArea fullMessage = new TextArea();
    fullMessage.setReadOnly(true);
    fullMessage.setVisible(false);
    fullMessage.setSize("335px", "100px");
    showDetails.addClickHandler(new ClickHandler() {

        boolean pressed = false;

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (pressed) {
                showDetails.setText("Show message preview");
                fullMessage.setVisible(false);
            } else {
                showDetails.setText("Hide preview");
                fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
                fullMessage.setVisible(true);
            }
            pressed = !pressed;
        }
    });
    messageTextBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            if (fullMessage.isVisible()) {
                fullMessage.setText(getErrorFullMessage(messageTextBox, error, postObject, status));
            }
        }
    });
    baseLayout.setWidget(5, 0, showDetails);
    baseLayout.setWidget(6, 0, fullMessage);
    // box definition
    final Confirm conf = new Confirm(WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), baseLayout, sendReportHandler, WidgetTranslation.INSTANCE.jsonClientSendErrorButton(), true);
    conf.setOkIcon(SmallIcons.INSTANCE.emailIcon());
    conf.setNonScrollable(true);
    conf.setAutoHide(false);
    conf.setFocusOkButton(true);
    conf.show();
    messageTextBox.setFocus(true);
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SendMessageToRt(cz.metacentrum.perun.webgui.json.rtMessagesManager.SendMessageToRt) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) JSONString(com.google.gwt.json.client.JSONString) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JSONObject(com.google.gwt.json.client.JSONObject) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 9 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.

the class UsersApplicationsPage method refresh.

/**
	 * Refresh the page
	 */
private void refresh() {
    bodyContents.clear();
    String user = "";
    if (session.getUser() != null) {
        user = this.session.getUser().getFullNameWithTitles().trim();
    } else {
        PerunPrincipal pp = session.getPerunPrincipal();
        if (!pp.getAdditionInformations("displayName").equals("")) {
            user = pp.getAdditionInformations("displayName");
        } else if (!pp.getAdditionInformations("cn").equals("")) {
            user = pp.getAdditionInformations("cn");
        } else {
            if (pp.getExtSourceType().equals("cz.metacentrum.perun.core.impl.ExtSourceX509")) {
                user = Utils.convertCertCN(pp.getActor());
            } else {
                user = pp.getActor();
            }
        }
    }
    bodyContents.add(new HTML("<h1>" + ApplicationMessages.INSTANCE.applicationsForUser(user) + "</h1>"));
    // callback
    int userId = 0;
    if (session.getUser() != null) {
        userId = session.getUser().getId();
    }
    final GetApplicationsForUserForAppFormGui req = new GetApplicationsForUserForAppFormGui(userId);
    final ListBox listBox = new ListBox();
    req.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<Application> appls = JsonUtils.jsoAsList(jso);
            ArrayList<String> vos = new ArrayList<String>();
            for (Application app : appls) {
                if (!vos.contains(app.getVo().getName())) {
                    vos.add(app.getVo().getName());
                }
            }
            Collections.sort(vos);
            for (String s : vos) {
                listBox.addItem(s);
            }
            if (listBox.getItemCount() > 0) {
                listBox.insertItem(WidgetTranslation.INSTANCE.listboxAll(), 0);
            }
            for (int i = 0; i < listBox.getItemCount(); i++) {
                if (listBox.getItemText(i).equals(ApplicationFormGui.getVo().getName())) {
                    listBox.setSelectedIndex(i);
                    req.filterTable(ApplicationFormGui.getVo().getName());
                    break;
                }
            }
        }

        @Override
        public void onError(PerunError error) {
        }

        @Override
        public void onLoadingStart() {
            listBox.clear();
        }
    });
    req.setCheckable(false);
    listBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            if (listBox.getSelectedIndex() > 0) {
                req.filterTable(listBox.getItemText(listBox.getSelectedIndex()));
            } else {
                // show all
                req.filterTable("");
            }
        }
    });
    final TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.filterByVo() + ":</strong>"));
    tabMenu.addWidget(listBox);
    tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.clickOnApplicationToSee() + "</strong>"));
    tabMenu.addStyleName("tabMenu");
    final VerticalPanel applicationsWrapper = new VerticalPanel();
    applicationsWrapper.setSize("100%", "100%");
    applicationsWrapper.add(tabMenu);
    final CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            applicationsWrapper.clear();
            applicationsWrapper.add(backButton);
            applicationsWrapper.add(getApplicationDetailWidget(object));
        }
    });
    appsTable.addStyleName("perun-table");
    applicationsWrapper.add(appsTable);
    backButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            applicationsWrapper.clear();
            applicationsWrapper.add(tabMenu);
            applicationsWrapper.add(appsTable);
        }
    });
    bodyContents.add(applicationsWrapper);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) PerunPrincipal(cz.metacentrum.perun.webgui.model.PerunPrincipal) GetApplicationsForUserForAppFormGui(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUserForAppFormGui) PerunError(cz.metacentrum.perun.webgui.model.PerunError) Application(cz.metacentrum.perun.webgui.model.Application)

Example 10 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.

the class CreateMailTabItem method basicInformationTab.

/**
	 * Returns flex table with basic information
	 *
	 * @return
	 */
private Widget basicInformationTab() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("500px", "350px");
    vp.setSpacing(10);
    // layout
    FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    vp.add(ft);
    vp.add(new HTML("&nbsp;"));
    // inputs - filling
    mailTypeListbox.clear();
    for (ApplicationMail.MailType type : ApplicationMail.MailType.values()) {
        mailTypeListbox.addItem(ApplicationMail.getTranslatedMailType(type.toString()), type.toString());
    }
    int initialIndex = 0;
    applicationTypeListbox.clear();
    for (Application.ApplicationType type : Application.ApplicationType.values()) {
        applicationTypeListbox.addItem(Application.getTranslatedType(type.toString()), type.toString());
        if (type.equals(Application.ApplicationType.INITIAL)) {
            initialIndex = applicationTypeListbox.getItemCount() - 1;
        }
    }
    final int initIndex = initialIndex;
    mailTypeListbox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            if (mailTypeListbox.getValue(mailTypeListbox.getSelectedIndex()).equals("USER_INVITE")) {
                applicationTypeListbox.setEnabled(false);
                applicationTypeListbox.setSelectedIndex(initIndex);
            } else {
                applicationTypeListbox.setEnabled(true);
            }
        }
    });
    // basic info
    int row = 0;
    ft.setHTML(row, 0, "E-mail type:");
    ft.setWidget(row, 1, mailTypeListbox);
    ftf.setStyleName(row, 0, "itemName");
    row++;
    ft.setHTML(row, 1, "Selected type of notification (action which trigger sending and who is notified).");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    row++;
    ft.setHTML(row, 0, "Application type: ");
    ft.setWidget(row, 1, applicationTypeListbox);
    ftf.setStyleName(row, 0, "itemName");
    ftf.setWidth(row, 0, "120px");
    row++;
    ft.setHTML(row, 1, "Select which application type will trigger sending.");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    row++;
    sendingEnabledCheckBox.setValue(true);
    ft.setHTML(row, 0, "Sending enabled:");
    ft.setWidget(row, 1, sendingEnabledCheckBox);
    ftf.setStyleName(row, 0, "itemName");
    row++;
    ft.setHTML(row, 1, "If checked, notification will be sent. Un-check it to temporary disable sending.");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    return vp;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)58 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)58 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)31 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)31 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)31 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)28 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ArrayList (java.util.ArrayList)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)20 PerunError (cz.metacentrum.perun.webgui.model.PerunError)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 HashMap (java.util.HashMap)10 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)8 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)8 Map (java.util.Map)7 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)6 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)6 SetNewAttributeTabItem (cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem)6 ListBox (com.google.gwt.user.client.ui.ListBox)5