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

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

Introduction

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

Prototype

public static boolean confirm(String msg) 

Source Link

Usage

From source file:gov.nist.spectrumbrowser.admin.SessionManagement.java

License:Open Source License

@Override
public void draw() {
    try {//from  ww  w . ja v  a 2s  .  c o  m
        verticalPanel.clear();
        HTML title = new HTML("<h2>Active Sessions </h2>");
        verticalPanel.add(title);
        if (frozen) {
            HTML subtitle = new HTML("<h3>New session creation is temporarily suspended by " + freezeRequester
                    + ". Users cannot use the system.</h3>");
            verticalPanel.add(subtitle);
        }

        int nrows = userSessions.size() + adminSessions.size();
        Grid grid = new Grid(nrows + 1, 5);
        for (int i = 0; i < grid.getRowCount(); i++) {
            for (int j = 0; j < grid.getColumnCount(); j++) {
                grid.getCellFormatter().setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER);
                grid.getCellFormatter().setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE);
            }
        }

        for (int i = 0; i < grid.getColumnCount(); i++) {
            grid.getCellFormatter().setStyleName(0, i, "textLabelStyle");
        }
        grid.setBorderWidth(2);
        grid.setCellSpacing(2);
        grid.setCellPadding(2);
        grid.setText(0, 0, "Email Address");
        grid.setText(0, 1, "Remote IP Address");
        grid.setText(0, 2, "Session Start Time");
        grid.setText(0, 3, "Session End Time");
        grid.setText(0, 4, "User Privilege");

        for (int i = 0; i < userSessions.size(); i++) {
            JSONObject jsonObj = userSessions.get(i).isObject();
            String userName = jsonObj.get(Defines.USER_NAME).isString().stringValue();
            int row = i + 1;
            grid.setText(row, 0, userName);
            String ipAddr = jsonObj.get(Defines.REMOTE_ADDRESS).isString().stringValue();
            grid.setText(row, 1, ipAddr);
            String startTime = jsonObj.get(Defines.SESSION_LOGIN_TIME).isString().stringValue();
            grid.setText(row, 2, startTime);
            String expiryTime = jsonObj.get(Defines.EXPIRE_TIME).isString().stringValue();
            grid.setText(row, 3, expiryTime);
            grid.setText(row, 4, "user");

        }
        for (int i = 0; i < adminSessions.size(); i++) {
            JSONObject jsonObj = adminSessions.get(i).isObject();
            int row = i + userSessions.size() + 1;
            String userName = jsonObj.get(Defines.USER_NAME).isString().stringValue();
            grid.setText(row, 0, userName);
            String ipAddr = jsonObj.get(Defines.REMOTE_ADDRESS).isString().stringValue();
            grid.setText(row, 1, ipAddr);
            String startTime = jsonObj.get(Defines.SESSION_LOGIN_TIME).isString().stringValue();
            grid.setText(row, 2, startTime);
            String expiryTime = jsonObj.get(Defines.EXPIRE_TIME).isString().stringValue();
            grid.setText(row, 3, expiryTime);
            grid.setText(row, 4, "admin");
        }
        verticalPanel.add(grid);

        HorizontalPanel hpanel = new HorizontalPanel();

        Button freezeButton = new Button("Freeze Sessions");
        hpanel.add(freezeButton);
        freezeButton.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                boolean yesno = Window.confirm("Warning! No new sessions will be allowed.\n "
                        + "Email will be sent to the administrator when all active sessions are terminated.\n Proceed?");
                if (yesno) {
                    SessionManagement.this.redraw = true;
                    Admin.getAdminService().freezeSessions(SessionManagement.this);
                }
            }
        });

        Button unfreezeButton = new Button("Cancel Freeze");

        hpanel.add(unfreezeButton);
        unfreezeButton.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                SessionManagement.this.redraw = true;
                Admin.getAdminService().unfreezeSessions(SessionManagement.this);

            }
        });

        Button logoffButton = new Button("Log Off");
        hpanel.add(logoffButton);
        logoffButton.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                timer.cancel();
                admin.logoff();
            }
        });
        verticalPanel.add(hpanel);
        timer = new Timer() {
            @Override
            public void run() {
                if (Admin.getSessionToken() != null) {
                    SessionManagement.this.redraw = true;
                    Admin.getAdminService().getSessions(SessionManagement.this);
                }
            }

        };

        timer.schedule(5 * 1000);
    } catch (Throwable th) {
        logger.log(Level.SEVERE, "Error drawing", th);
        admin.logoff();
    }

}

From source file:gov.nist.spectrumbrowser.admin.SweptFrequencySensorBands.java

License:Open Source License

public void draw() {

    verticalPanel.clear();/*  w  w w .ja  va  2s .co  m*/
    HTML html = new HTML("<H2>Bands for sensor : " + sensor.getSensorId() + "</H2>");
    verticalPanel.add(html);
    JSONObject sensorThresholds = sensor.getThresholds();

    Grid grid = new Grid(sensorThresholds.keySet().size() + 1, 8);
    grid.setBorderWidth(2);
    grid.setCellPadding(2);
    grid.setCellSpacing(2);
    grid.setText(0, 0, "System To Detect");
    grid.setText(0, 1, "Min Freq (Hz)");
    grid.setText(0, 2, "Max Freq (Hz)");
    grid.setText(0, 3, "Channel Count");
    grid.setText(0, 4, "Occupancy Threshold (dBm/Hz)");
    grid.setText(0, 5, "Occupancy Threshold (dBm)");
    grid.setText(0, 6, "Enabled?");
    grid.setText(0, 7, "Delete Band");
    grid.setBorderWidth(2);
    grid.setCellPadding(2);
    grid.setCellSpacing(2);
    CellFormatter formatter = grid.getCellFormatter();

    for (int i = 0; i < grid.getRowCount(); i++) {
        for (int j = 0; j < grid.getColumnCount(); j++) {
            formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER);
            formatter.setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE);
        }
    }
    for (int i = 0; i < grid.getColumnCount(); i++) {
        grid.getCellFormatter().setStyleName(0, i, "textLabelStyle");
    }

    int row = 1;
    for (String key : sensorThresholds.keySet()) {
        final SweptFrequencyBand threshold = new SweptFrequencyBand(sensorThresholds.get(key).isObject());
        grid.setText(row, 0, threshold.getSystemToDetect());
        grid.setText(row, 1, Long.toString(threshold.getMinFreqHz()));
        grid.setText(row, 2, Long.toString(threshold.getMaxFreqHz()));
        final TextBox channelCountTextBox = new TextBox();
        channelCountTextBox.setText(Long.toString(threshold.getChannelCount()));
        channelCountTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                Long oldValue = Long.parseLong(channelCountTextBox.getValue());
                try {
                    long newValue = Long.parseLong(event.getValue());
                    threshold.setChannelCount((long) newValue);
                } catch (Exception ex) {
                    Window.alert(ex.getMessage());
                    channelCountTextBox.setValue(Double.toString(oldValue));
                }
            }

        });
        grid.setWidget(row, 3, channelCountTextBox);

        final Label thresholdLabel = new Label();

        final TextBox thresholdTextBox = new TextBox();
        thresholdTextBox.setText(Double.toString(threshold.getThresholdDbmPerHz()));
        thresholdTextBox.addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                Double oldThreshold = Double.parseDouble(thresholdTextBox.getValue());
                try {
                    double newThreshold = Double.parseDouble(event.getValue());
                    threshold.setThresholdDbmPerHz(newThreshold);
                    thresholdLabel.setText(Float.toString(threshold.getThresholdDbm()));
                } catch (Exception ex) {
                    Window.alert(ex.getMessage());
                    thresholdTextBox.setValue(Double.toString(oldThreshold));
                }
            }

        });
        grid.setWidget(row, 4, thresholdTextBox);
        thresholdLabel.setText(Float.toString(threshold.getThresholdDbm()));
        grid.setWidget(row, 5, thresholdLabel);
        CheckBox activeCheckBox = new CheckBox();
        grid.setWidget(row, 6, activeCheckBox);
        activeCheckBox.setValue(threshold.isActive());
        activeCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {

                if (event.getValue()) {
                    for (String key : sensor.getThresholds().keySet()) {
                        SweptFrequencyBand th = new SweptFrequencyBand(sensor.getThreshold(key));
                        th.setActive(false);
                    }
                }
                threshold.setActive(event.getValue());
                draw();

            }
        });

        Button deleteButton = new Button("Delete Band");
        deleteButton.addClickHandler(new DeleteThresholdClickHandler(threshold));
        grid.setWidget(row, 7, deleteButton);
        row++;

    }
    verticalPanel.add(grid);
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    Button addButton = new Button("Add Band");
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            new AddSweptFrequencySensorBand(admin, SweptFrequencySensorBands.this, sensorConfig, sensor,
                    verticalPanel).draw();

        }
    });
    horizontalPanel.add(addButton);

    Button recomputeButton = new Button("Recompute Occupancies");
    recomputeButton.setTitle("Recomputes per message summary occupancies.");
    recomputeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            boolean yes = Window.confirm(
                    "Ensure no users are using the system. Update sensor before proceeding. This can take a long time. Proceed?");
            if (yes) {

                final HTML html = new HTML(
                        "<h3>Recomputing thresholds - this can take a while. Please wait. </h3>");
                verticalPanel.add(html);

                Admin.getAdminService().recomputeOccupancies(sensor.getSensorId(),
                        new SpectrumBrowserCallback<String>() {

                            @Override
                            public void onSuccess(String result) {
                                verticalPanel.remove(html);

                            }

                            @Override
                            public void onFailure(Throwable throwable) {
                                Window.alert("Error communicating with server");
                                admin.logoff();

                            }
                        });
            }
        }
    });
    horizontalPanel.add(recomputeButton);

    Button doneButton = new Button("Done");
    doneButton.setTitle("Return to sensors screen");
    doneButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            sensorConfig.redraw();
        }
    });

    horizontalPanel.add(doneButton);

    Button updateButton = new Button("Update");
    updateButton.setTitle("Update sensor on server");
    updateButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Admin.getAdminService().updateSensor(sensor.toString(), sensorConfig);
        }
    });

    horizontalPanel.add(updateButton);

    Button logoffButton = new Button("Log Off");
    logoffButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            admin.logoff();
        }
    });

    horizontalPanel.add(logoffButton);

    verticalPanel.add(horizontalPanel);

}

From source file:hudson.gwtmarketplace.client.pages.product.EditProductPage.java

License:Open Source License

public void onCancel() {
    if (Window.confirm("Are you sure you want to cancel?")) {
        pages.goTo(product.getAlias()).execute();
    }
}

From source file:hudson.gwtmarketplace.client.pages.product.NewProductPage.java

License:Open Source License

@Override
public void onCancel() {
    if (Window.confirm("Are you sure you want to cancel?")) {
        pages.showStartPage(false);
    }
}

From source file:ilarkesto.gwt.client.Gwt.java

License:Open Source License

public static boolean confirm(String message) {
    return Window.confirm(message);
}

From source file:io.apiman.manager.ui.client.local.pages.app.AppContractList.java

License:Apache License

/**
 * Creates the action column for the single contract row.
 * @param bean/*from w  w  w.  j a  v  a2 s .c  o m*/
 * @param row
 */
protected void createActionColumn(final ContractSummaryBean bean, FlowPanel row) {
    FlowPanel col = new FlowPanel();
    row.add(col);
    col.setStyleName("col-md-2"); //$NON-NLS-1$
    col.addStyleName("col-no-padding"); //$NON-NLS-1$

    SpanPanel sp = new SpanPanel();
    col.add(sp);
    sp.getElement().setClassName("actions"); //$NON-NLS-1$
    final AsyncActionButton aab = new AsyncActionButton();
    aab.getElement().setClassName("btn"); //$NON-NLS-1$
    aab.getElement().addClassName("btn-default"); //$NON-NLS-1$
    aab.setHTML(i18n.format(AppMessages.BREAK_CONTRACT));
    aab.setActionText(i18n.format(AppMessages.BREAKING));
    aab.setIcon("fa-cog"); //$NON-NLS-1$
    aab.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (Window.confirm(i18n.format(AppMessages.CONFIRM_BREAK_CONTRACT, bean.getServiceId()))) {
                aab.onActionStarted();
                BreakContractEvent.fire(AppContractList.this, bean);
            }
        }
    });
    sp.add(aab);
}

From source file:io.apiman.manager.ui.client.local.pages.common.PolicyList.java

License:Apache License

/**
 * Creates the action column for the single policy row.
 * @param bean//from ww  w.  j ava2s  . c  om
 * @param row
 */
protected void createActionColumn(final PolicyBean bean, FlowPanel row) {
    FlowPanel col = new FlowPanel();
    row.add(col);
    col.setStyleName("col"); //$NON-NLS-1$
    col.addStyleName("pull-right"); //$NON-NLS-1$

    SpanPanel sp = new SpanPanel();
    col.add(sp);
    sp.getElement().setClassName("actions"); //$NON-NLS-1$
    final AsyncActionButton aab = new AsyncActionButton();
    aab.getElement().setClassName("btn"); //$NON-NLS-1$
    aab.getElement().addClassName("btn-default"); //$NON-NLS-1$
    aab.setHTML(i18n.format(AppMessages.REMOVE));
    aab.setActionText(i18n.format(AppMessages.REMOVING));
    aab.setIcon("fa-cog"); //$NON-NLS-1$
    aab.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (Window.confirm(i18n.format(AppMessages.CONFIRM_REMOVE_POLICY, bean.getName()))) {
                aab.onActionStarted();
                RemovePolicyEvent.fire(PolicyList.this, bean);
            }
        }
    });
    sp.add(aab);
}

From source file:io.apiman.manager.ui.client.local.pages.EditGatewayPage.java

License:Apache License

/**
 * Called when the user clicks the Delete Gateway button.
 * @param event/*  ww  w . j a v  a  2s.c  o  m*/
 */
@EventHandler("deleteButton")
public void onDelete(ClickEvent event) {
    deleteButton.onActionStarted();
    updateButton.setEnabled(false);
    if (Window.confirm(i18n.format(AppMessages.CONFIRM_GATEWAY_DELETE, gatewayBean.getName()))) {
        GatewayBean gateway = new GatewayBean();
        gateway.setId(id);
        rest.deleteGateway(gateway, new IRestInvokerCallback<Void>() {
            @Override
            public void onSuccess(Void response) {
                toGateways.go();
            }

            @Override
            public void onError(Throwable error) {
                dataPacketError(error);
            }
        });
    } else {
        deleteButton.reset();
        updateButton.reset();
    }

}

From source file:io.apiman.manager.ui.client.local.pages.EditRolePage.java

License:Apache License

/**
 * Called when the user clicks the Delete Role button.
 * @param event//from  w  w  w  .j a  v a 2  s . co m
 */
@EventHandler("deleteButton")
public void onDelete(ClickEvent event) {
    deleteButton.onActionStarted();
    updateButton.setEnabled(false);
    if (Window.confirm(i18n.format(AppMessages.CONFIRM_ROLE_DELETE, roleBean.getName()))) {
        RoleBean role = new RoleBean();
        role.setId(id);
        rest.deleteRole(role, new IRestInvokerCallback<Void>() {
            @Override
            public void onSuccess(Void response) {
                toRoles.go();
            }

            @Override
            public void onError(Throwable error) {
                dataPacketError(error);
            }
        });
    } else {
        deleteButton.reset();
        updateButton.reset();
    }

}

From source file:io.apiman.manager.ui.client.local.pages.org.MemberCard.java

License:Apache License

/**
 * Called when the user clicks the "Revoke All" button.
 * @param event//from  w  w w  .  jav  a2 s  .  co m
 */
@EventHandler("revokeButton")
public void onRevoke(ClickEvent event) {
    applyButton.setEnabled(false);
    cancelButton.setEnabled(false);
    revokeButton.onActionStarted();

    // TODO replace this with a bootstrap modal yes/no dialog!
    if (Window.confirm("This will remove the user from all roles in the Organization.  Really do this?")) { //$NON-NLS-1$
        // Firing with a null value is a signal to the page that the user wants to delete the card.
        ValueChangeEvent.fire(this, null);
    }
}