Example usage for com.google.gwt.user.client Window alert

List of usage examples for com.google.gwt.user.client Window alert

Introduction

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

Prototype

public static void alert(String msg) 

Source Link

Usage

From source file:com.codenvy.ide.client.UITestProject.java

License:Open Source License

public void onModuleLoad() {

    // Defines debug IDs
    button.ensureDebugId(GWTIDConstants.BUTTON_DEBUG_ID);
    newProxyOption.ensureDebugId(GWTIDConstants.NEW_PROXY_DEBUG_ID);
    importProxyOption.ensureDebugId(GWTIDConstants.IMPORT_PROXY_DEBUG_ID);
    proxyNameBox.ensureDebugId(GWTIDConstants.PROXY_NAME_DEBUG_ID);
    proxyTypeBox.ensureDebugId(GWTIDConstants.PROXY_TYPE_DEBUG_ID);
    proxySaveBox.ensureDebugId(GWTIDConstants.PROXY_LOCATION_DEBUG_ID);
    proxyFileBox.ensureDebugId(GWTIDConstants.PROXY_FILE_DEBUG_ID);
    proxyEndpointBox.ensureDebugId(GWTIDConstants.PROXY_ENDPOINT_DEBUG_ID);

    // Adds items to the list
    proxyTypeBox.addItem(Constants.CUSTOM_PROXY);
    proxyTypeBox.addItem(Constants.PASS_THROUGH_PROXY);
    proxyTypeBox.addItem(Constants.TRANSFORMER_PROXY);
    proxyTypeBox.addItem(Constants.LOG_FORWARD_PROXY);
    proxyTypeBox.addItem(Constants.WSDL_BASED_PROXY);
    proxyTypeBox.addItem(Constants.SECURE_PROXY);

    grid.setWidget(0, 0, newProxyOption);
    grid.setWidget(0, 1, importProxyOption);
    root.add(grid);//from ww  w  .j  ava  2 s  . c om

    /*Allows relevant fields to be visible when selecting the new proxy
    option*/
    //TODO use for hadler for deprecated methods
    newProxyOption.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {

            grid.setWidget(1, 0, proxyNameLabel);
            grid.setWidget(1, 1, proxyNameBox);
            grid.setWidget(2, 0, proxyTypeLabel);
            grid.setWidget(2, 1, proxyTypeBox);
            grid.setWidget(3, 0, proxySaveLocation);
            grid.setWidget(3, 1, proxySaveBox);
            grid.setWidget(5, 1, button);
            root.add(grid);
        }
    });

    /*Allows relevant fields to be visible when selecting the import proxy
    option*/
    importProxyOption.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {

            grid.setWidget(1, 0, proxyFileLabel);
            grid.setWidget(1, 1, proxyFileBox);
            grid.setWidget(2, 0, proxySaveLocation);
            grid.setWidget(2, 1, proxySaveBox);
            grid.setWidget(5, 1, button);
            root.add(grid);
        }
    });

    // Allows relevant fields to be visible when selecting the list item
    proxyTypeBox.addChangeListener(new ChangeListener() {

        @Override
        public void onChange(Widget sender) {
            // Get the index of the selected item
            int itemSelected = proxyTypeBox.getSelectedIndex();

            // Get the string value of the item that has been selected
            String itemStringSelected = proxyTypeBox.getValue(itemSelected);
            if (itemStringSelected.equals(Constants.TRANSFORMER_PROXY)) {
                grid.setWidget(4, 0, proxyEndpointLabel);
                grid.setWidget(4, 1, proxyEndpointBox);
                root.add(grid);
            } else {
                grid.remove(proxyEndpointLabel);
                grid.remove(proxyEndpointBox);
                root.add(grid);
            }
        }
    });

    // Handles the button action when creating and importing proxies
    button.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {

            if (!proxyNameBox.getValue().isEmpty() && !proxySaveBox.getValue().isEmpty()) {
                grid.setVisible(false);
                root.add(new Label("Proxy Created Successfully...."));

            } else if (!proxyFileBox.getValue().isEmpty() && !proxySaveBox.getValue().isEmpty()) {
                grid.setVisible(false);
                root.add(new Label("Proxy Imported Successfully...."));
            } else {
                Window.alert("Please insert Data...");
            }
        }
    });
}

From source file:com.cognitivemedicine.metricsdashboard.client.adminconsole.MetricsTab.java

License:Apache License

public MetricsTab(DashboardController dashController) {
    this.controller = dashController;

    // METRIC GROUPS
    allMetricGroupsListBox = new ListBox();
    allMetricGroupsListBox.setWidth("200px");
    // allMetricGroupsListBox.setWidth("30%");
    allMetricGroupsListBox.setVisibleItemCount(15);
    allMetricGroupsListBox.addChangeHandler(new ChangeHandler() {
        @Override/*from  w w w . j  a v  a  2s. c om*/
        public void onChange(ChangeEvent event) {
            String id = allMetricGroupsListBox.getValue(allMetricGroupsListBox.getSelectedIndex());
            // controller.getMetricsGroups().get(id).getMetricList();
            List<Metric> metrics = controller.getMetricsInGroup(id);
            assignedMetricsListBox.clear();
            for (Metric m : metrics) {
                if (m != null) {
                    System.err.println("Name: " + m.getName() + " ID: " + m.getName());
                    assignedMetricsListBox.addItem(m.getName(), m.get_id());
                }
            }
        }
    });
    Collection<MetricGroup> allMetricGroups = controller.getMetricsGroups().values();
    for (MetricGroup g : allMetricGroups) {
        allMetricGroupsListBox.addItem(g.getName(), g.get_id());
    }

    // METRICS
    allMetricsListBox = new ListBox(true);
    allMetricsListBox.setWidth("200px");
    // allMetricsListBox.setWidth("30%");
    allMetricsListBox.setVisibleItemCount(15);
    Collection<Metric> allMetrics = controller.getAvailableMetrics().values();
    for (Metric m : allMetrics) {
        allMetricsListBox.addItem(m.getName(), m.get_id());
    }

    // ASSIGNED
    assignedMetricsListBox = new ListBox(true);
    assignedMetricsListBox.setWidth("200px");
    // assignedMetricsListBox.setWidth("30%");
    assignedMetricsListBox.setVisibleItemCount(15);

    VerticalPanel buttonPanel = new VerticalPanel();
    buttonPanel.setSpacing(2);
    Image image = new Image(MdConstants.IMG_LEFT_ARROW);
    image.setSize("24px", "24px");
    PushButton addButton = new PushButton(image);
    addButton.getElement().setId("addDefinitionButton");
    addButton.setSize("24px", "24px");
    addButton.setTitle("Add");
    // addButton = new Button("<-- Add");
    addButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addButtonClicked();
        }
    });

    image = new Image(MdConstants.IMG_RIGHT_ARROW);
    image.setSize("24px", "24px");
    PushButton removeButton = new PushButton(image);
    removeButton.getElement().setId("removeDefinitionButton");
    removeButton.setSize("24px", "24px");
    removeButton.setTitle("Add");
    // removeButton = new Button("Remove -->");
    removeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            removeButtonClicked();
        }
    });

    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    // buttonPanel.setBorderWidth(2);

    // this.setBorderWidth(3);
    // this.setSpacing(2);
    this.setWidth("100%");

    createGroupTextBox = new TextBox();
    // createGroupTextBox.setWidth("*");

    createGroupButton = new Button("Create Group");
    createGroupButton.getElement().setId("createGroupButton");
    createGroupButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (!(createGroupTextBox.getValue().equals(""))) {
                MetricGroup group = new MetricGroup();
                group.setName(createGroupTextBox.getValue());
                group.setDescription("");
                group.setMetricList(new ArrayList<String>());
                controller.createMetricGroup(group);
            } else {
                Window.alert("You must enter a name to create a group");
            }
        }
    });

    VerticalPanel allMetricsPanel = createLabeledList("Metrics Groups", allMetricGroupsListBox);
    HorizontalPanel createPanel = new HorizontalPanel();
    createPanel.add(createGroupTextBox);
    createPanel.add(createGroupButton);
    allMetricsPanel.add(createPanel);
    this.add(allMetricsPanel);
    // this.add(createLabeledList("Metrics Groups", allMetricGroupsListBox));
    this.add(createLabeledList("Assigned Metrics", assignedMetricsListBox));
    this.add(buttonPanel);
    this.add(createLabeledList("All Metrics", allMetricsListBox));

    setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    setCellVerticalAlignment(buttonPanel, HasVerticalAlignment.ALIGN_MIDDLE);
}

From source file:com.cognitivemedicine.metricsdashboard.client.charts.ChartWidget.java

License:Apache License

/**
 * When the ok button is clicked by the user (or programmatically), build a grain matrix from configuration settings to store the results, and query for data.
 *///from  ww  w.j av  a  2s.c o m
public void clickOkButton() {
    ChartSettings settings = chartEditorPanel.getChartSettings();

    this.setText(settings.getTitle());
    Period period = settings.getPeriod();
    Granularity granularity = settings.getGranularity();

    if (granularity != null && period.getMilliseconds() < granularity.getMilliseconds()) {
        Window.alert("Period must be a greater than or equal to granularity.");
        return;
    }

    grainMatrix = new GrainMatrix(settings, this);
    for (MetaDefinition meta : grainMatrix.getMetaDefinitions()) {
        controller.getMetrics(meta, grainMatrix);
    }
}

From source file:com.cognitivemedicine.metricsdashboard.client.dashboard.DashboardMainPanel.java

License:Apache License

public void finishLoadingMetricDefinitions(List<Metric> metricDefinitions) {
    if (metricDefinitions == null || metricDefinitions.size() == 0) {
        Window.alert(
                "FATAL ERROR: Metrics data could not be found.  This system may be incorrectly configured. Please contact your system administrator.");
    }//from  www .j av  a 2  s  . com
}

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.CreateDashboardDialog.java

License:Apache License

protected void createButtonClicked() {
    String name = nameBox.getText();
    if (name == null || name.trim().length() == 0) {
        Window.alert("You must enter a name");
        return;//from w w w  . ja  va 2s .co m
    }
    for (Dashboard d : parent.getController().getDashboards().values()) {
        if (d.getName().equalsIgnoreCase(name)) {
            Window.alert("A dashboard with this name already exists");
            return;
        }
    }

    Dashboard dashboard = new Dashboard();
    dashboard.setName(name);
    dashboard.setDescription(notesArea.getText());
    // TODO grab from authenticated user
    dashboard.setUserId("testuser");
    dashboard.setDashboardSettings(new DashboardSettings());
    parent.getController().createDashboard(dashboard);
    CreateDashboardDialog.this.hide();
}

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.SaveAsDashboardDialog.java

License:Apache License

private void createButtonClicked() {
    String name = nameBox.getText();
    if (name == null || name.trim().length() == 0) {
        Window.alert("You must enter a name");
        return;//w w  w  . j  a va  2s .c  o  m
    }
    for (Dashboard d : parent.getController().getDashboards().values()) {
        if (d.getName().equalsIgnoreCase(name)) {
            Window.alert("A dashboard with this name already exists");
            return;
        }
    }

    Dashboard dashboard = new Dashboard();
    dashboard.setName(nameBox.getText());
    dashboard.setDescription(parent.getNotes());
    dashboard.setCharts(parent.getDashboardCharts());
    dashboard.setDashboardSettings(parent.getSettingsPanel().getDashboardSettings());
    dashboard.setUserId("testuser");
    // currentDashboard.setUserId("USERID"); //TODO
    // currentDashboard.setCategory(category);
    // dashboardListBox.getValue(dashboardListBox.getSelectedIndex());
    parent.getController().createDashboard(dashboard);
    SaveAsDashboardDialog.this.hide();
}

From source file:com.cognitivemedicine.metricsdashboard.client.Md_sandbox.java

License:Apache License

public void siteListLoadFailed() {
    Window.alert(
            "FATAL ERROR: Site list data could not be found.  This system may be incorrectly configured. Please contact your system administrator.");
}

From source file:com.cognitivemedicine.metricsdashboard.client.Md_sandbox.java

License:Apache License

/**
 * The user couldn't log in so display an error message, and allow them to try again
 *//*from  w w w .jav  a  2  s.c  o  m*/
public void loginFailed(String message) {
    if (message != null) {
        Window.alert("Could not log in.  Please check your credentials and try again");
    }
}

From source file:com.colinalworth.xmlview.client.ElementCell.java

License:Apache License

/**
 * @param context//from ww  w . ja  v a  2 s.c o m
 * @param value
 */
private void finishEdit(Node value, com.google.gwt.dom.client.Element target) {
    ElementCell.ViewState state = updateViewState(lastKey, value, target);
    String newValue = target.<InputElement>cast().getValue();
    boolean valid = true;
    Element parent = (Element) value.getParentNode();
    switch (state.section) {
    case AttributeName:
        Attr attr = (Attr) value;
        //TODO this might lose namespace data
        parent.removeAttribute(attr.getName());
        parent.setAttribute(newValue, attr.getValue());

        valid = validator.isAttributeNameValid(parent.getAttributeNode(attr.getName()), parent);
        break;
    case AttributeValue:
        value.setNodeValue(newValue);
        valid = validator.isAttributeValueValid((Attr) value, parent);
        break;
    case Content:
        ((CharacterData) value).setData(newValue);
        valid = validator.isContentsValid((CharacterData) value);
        break;
    case TagName:
        Element elt = (Element) value;
        Element replacement = elt.getOwnerDocument().createElement(newValue);
        while (elt.getChildNodes().getLength() != 0) {
            replacement.appendChild(elt.getChildNodes().item(0));
        }
        //TODO this might lose namespace data
        for (int i = 0; i < elt.getAttributes().getLength(); i++) {
            Attr a = (Attr) elt.getAttributes().item(i);
            replacement.setAttribute(a.getName(), a.getValue());
        }

        parent.replaceChild(replacement, elt);

        valid = validator.isElementNameValid(replacement);
    }
    if (!valid) {
        Window.alert("Seems to be invalid: " + newValue + " in " + parent.getNodeName());
        //TODO mark invalid
    }
    this.lastKey = null;
    target.blur();
}

From source file:com.colinalworth.xmlview.client.XmlViewerEntryPoint.java

License:Apache License

@UiHandler("validate")
public void validate(ClickEvent evt) {
    Document d = (Document) tree.getRootTreeNode().getValue();

    //pass to server
    Window.alert(d.toString());

}