Example usage for com.google.gwt.user.client.ui DialogBox hide

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

Introduction

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

Prototype

@Override
    public void hide() 

Source Link

Usage

From source file:org.rest.client.activity.RequestActivity.java

License:Apache License

private void getFileMetadataFromDrive(final String fileId, final DialogBox loader) {

    DriveApi.getFileMetadata(fileId, new DriveApi.FileMetadataHandler() {

        @Override//from  www. ja va 2s .c  o m
        public void onLoad(DriveFileItem response) {
            if (response == null) {
                loader.hide();
                StatusNotification.notify("Unable read from gdrive. ", StatusNotification.TYPE_ERROR,
                        StatusNotification.TIME_SHORT);
                return;
            }

            downloadFileFromDrive(fileId, response, loader);
        }

        @Override
        public void onError(JavaScriptException exc) {
            loader.hide();
            if (RestClient.isDebug()) {
                Log.error("Unable read from gdrive.", exc);
            }
            StatusNotification.notify("Unable read from gdrive. " + exc.getMessage(),
                    StatusNotification.TYPE_ERROR, StatusNotification.TIME_SHORT);
        }
    });
}

From source file:org.rest.client.activity.RequestActivity.java

License:Apache License

private void downloadFileFromDrive(final String fileId, final DriveFileItem response, final DialogBox loader) {

    final String fileUrl = response.getDownloadUrl();
    final String fileTitle = response.getTitle();
    final String fileEtag = response.getEtag();

    if (currentRequestEtag != null && fileEtag != null && fileEtag.equals(currentRequestEtag)) {
        //nothing has changed.
        loader.hide();
        requestView.setGDriveConstrols();
        return;/*www.ja  v a  2 s. com*/
    }

    currentRequestEtag = fileEtag;

    DriveApi.downloadFile(fileUrl, new DriveApi.FileDownloadHandler() {
        @Override
        public void onError(JavaScriptException exc) {
            loader.hide();
            if (RestClient.isDebug()) {
                Log.error("Unable download from gdrive.", exc);
            }
            StatusNotification.notify("Unable download from gdrive. " + exc.getMessage(),
                    StatusNotification.TYPE_ERROR, StatusNotification.TIME_SHORT);
        }

        @Override
        public void onDownload(String content) {
            if (content == null) {
                loader.hide();
                //request error
                StatusNotification.notify("Unable download from gdrive. ", StatusNotification.TYPE_ERROR,
                        StatusNotification.TIME_SHORT);
                return;
            }
            RequestObject values = null;
            try {
                values = RequestObject.fromString(content);
            } catch (Exception e) {
                loader.hide();
                if (RestClient.isDebug()) {
                    Log.error("Invalid ARC file.", e);
                }
                StatusNotification.notify("Invalid ARC file.", StatusNotification.TYPE_ERROR,
                        StatusNotification.TIME_SHORT);
                return;
            }

            if (values == null) {
                StatusNotification.notify("Invalid ARC file.", StatusNotification.TYPE_ERROR,
                        StatusNotification.TIME_SHORT);
            } else {
                Storage store = Storage.getSessionStorageIfSupported();
                store.setItem(LocalStore.CURRENT_GOOGLE_DRIVE_ITEM, fileId);
            }

            values.setGDriveId(fileId);
            values.setName(fileTitle);

            setViewParameters(values);
            loader.hide();
        }
    });
}

From source file:org.rest.client.ui.desktop.RequestViewImpl.java

License:Apache License

@UiHandler("deleteEndpoint")
void onDeleteEndpoint(ClickEvent e) {
    e.preventDefault();/*ww  w  .j a  va 2  s . co m*/
    final DialogBox dialog = new DialogBox(true);
    dialog.setAnimationEnabled(true);
    dialog.setGlassEnabled(true);
    dialog.setModal(true);

    HTMLPanel wrapper = new HTMLPanel("");
    Label message = new Label("Delete selected endpoint?");
    HTMLPanel buttons = new HTMLPanel("");
    buttons.setStyleName("dialogButtons");
    Button confirm = new Button("Confirm");
    confirm.setStyleName("button");
    Button cancel = new Button("Cancel");
    cancel.setStyleName("button");
    buttons.add(confirm);
    buttons.add(cancel);
    wrapper.add(message);
    wrapper.add(buttons);
    dialog.add(wrapper);
    dialog.show();
    dialog.center();
    cancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialog.hide();
        }
    });
    confirm.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialog.hide();
            listener.deleteCurrentEndpoint();
        }
    });
}

From source file:org.roda.wui.client.common.dialogs.Dialogs.java

public static void showInformationDialog(String title, String message, String continueButtonText,
        final AsyncCallback<Void> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);//from w ww . ja va  2  s . c  om

    FlowPanel layout = new FlowPanel();
    HTML messageLabel = new HTML(message);
    Button continueButton = new Button(continueButtonText);

    layout.add(messageLabel);
    layout.add(continueButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    continueButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(null);
        }
    });

    dialogBox.addStyleName("wui-dialog-information");
    layout.addStyleName("wui-dialog-layout");
    messageLabel.addStyleName("wui-dialog-message");
    continueButton.addStyleName("btn btn-play");

    dialogBox.center();
    dialogBox.show();
}

From source file:org.roda.wui.client.common.dialogs.Dialogs.java

public static void showPromptDialog(String title, String message, String value, String placeHolder,
        final RegExp validator, String cancelButtonText, String confirmButtonText, boolean mandatory,
        final AsyncCallback<String> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);/*from w  w  w . j av  a  2  s .  c  o  m*/

    final FlowPanel layout = new FlowPanel();

    if (message != null) {
        final Label messageLabel = new Label(message);
        layout.add(messageLabel);
        messageLabel.addStyleName("wui-dialog-message");
    }

    final TextBox inputBox = new TextBox();
    inputBox.setTitle("input box");

    if (value != null) {
        inputBox.setText(value);
    }

    if (placeHolder != null) {
        inputBox.getElement().setPropertyString("placeholder", placeHolder);
    }

    final Button cancelButton = new Button(cancelButtonText);
    final Button confirmButton = new Button(confirmButtonText);
    confirmButton.setEnabled(!mandatory);

    layout.add(inputBox);
    layout.add(cancelButton);
    layout.add(confirmButton);

    dialogBox.setWidget(layout);
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onFailure(null);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (validator.test(inputBox.getText())) {
                dialogBox.hide();
                callback.onSuccess(inputBox.getText());
            }
        }
    });

    inputBox.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            boolean isValid = validator.test(event.getValue());
            confirmButton.setEnabled(isValid);
            if (isValid) {
                inputBox.removeStyleName("error");
            } else {
                inputBox.addStyleName("error");
            }
        }
    });

    inputBox.addKeyPressHandler(new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            TextBox box = (TextBox) event.getSource();
            confirmButton.setEnabled(validator.test(box.getText()));
        }
    });

    inputBox.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            TextBox box = (TextBox) event.getSource();
            confirmButton.setEnabled(validator.test(box.getText()));
        }
    });

    inputBox.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (validator.test(inputBox.getText())) {
                    dialogBox.hide();
                    callback.onSuccess(inputBox.getText());
                }
            } else {
                TextBox box = (TextBox) event.getSource();
                confirmButton.setEnabled(validator.test(box.getText()));
            }
        }
    });

    dialogBox.addStyleName("wui-dialog-prompt");
    layout.addStyleName("wui-dialog-layout");
    inputBox.addStyleName("form-textbox wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("pull-right btn btn-play");

    dialogBox.center();
    dialogBox.show();
    inputBox.setFocus(true);
}

From source file:org.roda.wui.client.common.dialogs.Dialogs.java

public static void showPromptDialogSuggest(String title, String message, String placeHolder,
        String cancelButtonText, String confirmButtonText, SearchSuggestBox<?> suggestBox,
        final AsyncCallback<String> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);//from   w ww  .  jav a  2 s  .c o  m

    final FlowPanel layout = new FlowPanel();

    if (message != null) {
        final Label messageLabel = new Label(message);
        layout.add(messageLabel);
        messageLabel.addStyleName("wui-dialog-message");
    }

    final SearchSuggestBox<?> inputBox = suggestBox;

    if (placeHolder != null) {
        inputBox.getElement().setPropertyString("placeholder", placeHolder);
    }

    final Button cancelButton = new Button(cancelButtonText);
    final Button confirmButton = new Button(confirmButtonText);

    layout.add(inputBox);
    layout.add(cancelButton);
    layout.add(confirmButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onFailure(null);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(inputBox.getValue());
        }
    });

    dialogBox.addStyleName("wui-dialog-prompt");
    layout.addStyleName("wui-dialog-layout");
    inputBox.addStyleName("form-textbox wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("pull-right btn btn-play");

    dialogBox.center();
    dialogBox.show();
    inputBox.setFocus(true);
}

From source file:org.unitime.timetable.gwt.client.curricula.CurriculaTable.java

License:Apache License

private void openCurriculumProjectionRules() {
    final DialogBox dialog = new UniTimeDialogBox(true, true);
    final CurriculumProjectionRulesPage rules = new CurriculumProjectionRulesPage();
    rules.setAllowClose(true);/*from w ww .  jav a2 s .  c o m*/
    rules.getElement().getStyle().setMarginRight(ToolBox.getScrollBarWidth(), Unit.PX);
    rules.getElement().getStyle().setPaddingLeft(10, Unit.PX);
    rules.getElement().getStyle().setPaddingRight(10, Unit.PX);
    final ScrollPanel panel = new ScrollPanel(rules);
    panel.setHeight(Math.round(0.9 * Window.getClientHeight()) + "px");
    panel.setStyleName("unitime-ScrollPanel");
    dialog.setWidget(panel);
    dialog.setText(MESSAGES.dialogCurriculumProjectionRules());
    rules.addProjectionRulesHandler(new CurriculumProjectionRulesPage.ProjectionRulesHandler() {
        @Override
        public void onRulesSaved(ProjectionRulesEvent evt) {
            dialog.hide();
            query(iLastQuery, null);
        }

        @Override
        public void onRulesLoaded(ProjectionRulesEvent evt) {
            dialog.center();
            //panel.setWidth((ToolBox.getScrollBarWidth() + rules.getOffsetWidth()) + "px");
        }

        @Override
        public void onRulesClosed(ProjectionRulesEvent evt) {
            dialog.hide();
        }

        @Override
        public void onException(Throwable caught) {
            setError(MESSAGES.failedToOpenCurriculumProjectionRules(caught.getMessage()));
            UniTimeNotifications.error(MESSAGES.failedToOpenCurriculumProjectionRules(caught.getMessage()),
                    caught);
        }
    });
}

From source file:piramide.interaction.reasoner.web.client.ReasonerManagementWeb.java

License:Apache License

@Override
public void showError(String message) {

    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Error");

    final VerticalPanel dialogContents = new VerticalPanel();
    final Label label = new Label(message);
    label.setStyleName(Styles.error);//from  ww  w .  j av a 2 s.  c  o  m
    dialogContents.add(label);
    final Button closeButton = new Button("Close");
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogContents.add(closeButton);

    dialogBox.setWidget(dialogContents);
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);

    dialogBox.center();
    dialogBox.show();
}

From source file:piramide.interaction.reasoner.web.client.ui.fuzzy.AddEditLinguisticTermPanel.java

License:Apache License

@UiHandler("addLinguisticTermButton")
void onAddLinguisticTermButtonClicked(ClickEvent event) {
    final DialogBox addDialogBox = new DialogBox();
    addDialogBox.setGlassEnabled(true);/*from   ww w .jav a2s  .c  o m*/

    addDialogBox.setText(messages.add());

    final VerticalPanel vpanel = new VerticalPanel();
    vpanel.add(new Label(messages.addLinguisticTerm()));
    final TextBox textbox = new TextBox();
    textbox.setVisibleLength(10);
    vpanel.add(textbox);

    final HorizontalPanel hpanel = new HorizontalPanel();
    final Button cancelButton = new Button(messages.cancel());
    final Button addButton = new Button(messages.add());

    hpanel.add(addButton);
    hpanel.add(cancelButton);
    vpanel.add(hpanel);

    addDialogBox.setWidget(vpanel);

    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addDialogBox.hide();
        }
    });

    final ClickHandler handler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addDialogBox.hide();
            AddEditLinguisticTermPanel.this.linguisticTermsListBox.addItem(textbox.getText());
            AddEditLinguisticTermPanel.this.addLinguisticTermButton.setFocus(true);
        }
    };

    final KeyPressHandler keyboardHandler = new KeyPressHandler() {
        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER)
                handler.onClick(null);
        }
    };

    textbox.addKeyPressHandler(keyboardHandler);
    addButton.addClickHandler(handler);

    addDialogBox.center();
    addDialogBox.show();

    textbox.setFocus(true);
}

From source file:piramide.interaction.reasoner.web.client.ui.fuzzy.VariableItem.java

License:Apache License

@UiHandler("viewButton")
void onViewButtonClicked(ClickEvent event) {
    final String variableName = this.nameLabel.getText();
    final String variableType = this.typeLabel.getText();
    final String variableScope = this.userDeviceTypeLabel.getText();

    String[] terms = new String[] {};
    final boolean devices;
    final boolean input;
    if (variableType.equals(messages.input()) && variableScope.equals(messages.device())) {
        final List<Variable> deviceVariables = this.mainWindow.getFuzzyConfiguration().getInput()
                .getDeviceVariables();/*from  w ww .j  a v a 2 s .c o  m*/
        terms = findVariableTerms(variableName, deviceVariables);
        devices = true;
        input = true;
    } else if (variableType.equals(messages.input())) {
        final List<Variable> userVariables = this.mainWindow.getFuzzyConfiguration().getInput()
                .getUserVariables();
        terms = findVariableTerms(variableName, userVariables);
        devices = false;
        input = true;
    } else {
        final List<Variable> outputVariables = this.mainWindow.getFuzzyConfiguration().getOutput()
                .getVariables();
        terms = findVariableTerms(variableName, outputVariables);
        devices = false;
        input = false;
    }

    final ImageUrlBuilder builder = new ImageUrlBuilder(variableName, null, devices, input, terms);

    final DialogBox dialogBox = new DialogBox();
    VerticalPanel variableImagePanel = new VerticalPanel();
    final Label loadingMessage = new Label(messages.loading());
    variableImagePanel.add(loadingMessage);
    final Image image = new Image(builder.toString());
    image.setVisible(false);
    variableImagePanel.add(image);
    image.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            image.setVisible(true);
            loadingMessage.setVisible(false);
        }
    });

    Button closeButton = new Button(messages.cancel());
    closeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();

        }
    });

    variableImagePanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    variableImagePanel.add(closeButton);

    dialogBox.setWidget(variableImagePanel);

    dialogBox.setWidth("500px");
    dialogBox.setText(this.getName());

    dialogBox.setGlassEnabled(true);
    dialogBox.center();
    dialogBox.show();

}