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

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

Introduction

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

Prototype

public static String prompt(String msg, String initialValue) 

Source Link

Usage

From source file:org.drools.guvnor.client.admin.CategoryManager.java

License:Apache License

private void renameSelected() {

    String name = Window.prompt("Please enter the name you would like to change this category to", "");
    if (name != null) {
        RepositoryServiceFactory.getService().renameCategory(explorer.getSelectedPath(), name,
                new GenericCallback() {
                    public void onSuccess(Object data) {
                        Window.alert("Category renamed");
                        explorer.refresh();
                    }/*from w w  w  .j av a 2  s .com*/
                });
    }
}

From source file:org.drools.guvnor.client.admin.StateManager.java

License:Apache License

private void renameSelected() {

    String newName = Window.prompt("Please enter the name you would like to change this status to", "");

    String oldName = currentStatuses.getItemText(currentStatuses.getSelectedIndex());

    if (newName != null) {
        RepositoryServiceFactory.getService().renameState(oldName, newName, new GenericCallback() {
            public void onSuccess(Object data) {
                Window.alert("Status renamed.");
                refreshList();//from  w  ww  .j a v  a  2 s . c o m
            }
        });
    }
}

From source file:org.drools.guvnor.client.explorer.navigation.admin.widget.CategoryManager.java

License:Apache License

private void renameSelected() {

    String name = Window.prompt(constants.CategoryNewNamePleaseEnter(), "");
    if (name != null) {
        CategoryServiceAsync categoryService = GWT.create(CategoryService.class);
        categoryService.renameCategory(explorer.getSelectedPath(), name, new GenericCallback<java.lang.Void>() {
            public void onSuccess(Void v) {
                Window.alert(constants.CategoryRenamed());
                explorer.refresh();/*from  w w  w.j a  v a2 s .c  om*/
            }
        });
    }
}

From source file:org.drools.guvnor.client.explorer.navigation.admin.widget.StateManager.java

License:Apache License

private void renameSelected() {

    String newName = Window.prompt(constants.PleaseEnterTheNameYouWouldLikeToChangeThisStatusTo(), "");

    String oldName = currentStatuses.getItemText(currentStatuses.getSelectedIndex());

    if (newName != null) {
        repositoryService.renameState(oldName, newName, new GenericCallback<Void>() {
            public void onSuccess(Void data) {
                Window.alert(constants.StatusRenamed());
                refreshList();/*from w  w w . j a v  a  2s . co m*/
            }
        });
    }
}

From source file:org.drools.workbench.screens.categories.client.CategoriesEditorViewImpl.java

License:Apache License

@PostConstruct
public void init() {
    explorer = new CategoryTreeEditorWidget();
    form = new PrettyFormLayout();

    form.addHeader(Images.INSTANCE.EditCategories(), new HTML(Constants.INSTANCE.EditCategories()));
    form.startSection(Constants.INSTANCE.CategoriesPurposeTip());

    final SimplePanel editable = new SimplePanel();
    editable.add(explorer);//www .j  ava 2 s. c o m

    form.addAttribute(Constants.INSTANCE.CurrentCategories(), editable);

    final HorizontalPanel actions = new HorizontalPanel();

    form.addAttribute("", actions);

    final Button newCat = new Button(Constants.INSTANCE.NewCategory());
    newCat.setTitle(Constants.INSTANCE.CreateANewCategory());
    newCat.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            final CategoryEditor newCat;
            if (explorer.getSelectedCategory() == null) {
                newCat = new CategoryEditor(explorer.getCategories());
            } else {
                newCat = new CategoryEditor(explorer.getSelectedCategory());
            }

            newCat.show();
        }
    });

    actions.add(newCat);

    final Button rename = new Button(Constants.INSTANCE.RenameSelected());
    rename.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            if (!explorer.isSelected()) {
                Window.alert(Constants.INSTANCE.PleaseSelectACategoryToRename());
                return;
            }
            final String name = Window.prompt(Constants.INSTANCE.CategoryNewNamePleaseEnter(), "");
            if (name != null) {
                explorer.renameSelected(name);
            }
        }
    });

    actions.add(rename);

    final Button delete = new Button(Constants.INSTANCE.DeleteSelected());
    delete.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent w) {
            if (!explorer.isSelected()) {
                Window.alert(Constants.INSTANCE.PleaseSelectACategoryToDelete());
                return;
            }
            if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToDeleteCategory()
                    + explorer.getSelectedCategory().getName())) {
                explorer.removeSelected();
            }
        }
    });
    delete.setTitle(Constants.INSTANCE.DeleteSelectedCat());

    actions.add(delete);

    form.endSection();

    initWidget(form);
}

From source file:org.eobjects.datacleaner.monitor.scheduling.widgets.CustomizeJobClickHandler.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    final JobIdentifier job = _schedulePanel.getSchedule().getJob();
    final MenuBar menuBar = new MenuBar(true);
    menuBar.addItem("Rename job", new Command() {
        @Override/*w w  w .j  a  va  2  s  . co  m*/
        public void execute() {
            final String newName = Window.prompt("Enter job name", job.getName());
            if (newName == null || newName.trim().length() == 0 || newName.equals(job.getName())) {
                return;
            }

            final DCPopupPanel popup = new DCPopupPanel("Renaming...");
            popup.setWidget(new LoadingIndicator());
            popup.center();
            popup.show();

            final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".modify");

            final JSONObject payload = new JSONObject();
            payload.put("name", new JSONString(newName));

            final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
            requestBuilder.setHeader("Content-Type", "application/json");
            requestBuilder.send(payload.toString(), new DCRequestCallback() {
                @Override
                protected void onSuccess(Request request, Response response) {
                    Window.Location.reload();
                }

                @Override
                public void onNonSuccesfullStatusCode(Request request, Response response, int statusCode,
                        String statusText) {
                    popup.hide();
                    ErrorHandler.showErrorDialog(response.getText());
                }
            });
        }
    });
    menuBar.addItem("Copy job", new Command() {
        @Override
        public void execute() {
            final String newJobName = Window.prompt("Enter new job name", job.getName() + " (Copy)");

            if (newJobName == null || newJobName.trim().length() == 0 || newJobName.equals(job.getName())) {
                return;
            }

            final DCPopupPanel popup = new DCPopupPanel("Copying...");
            popup.setWidget(new LoadingIndicator());
            popup.center();
            popup.show();

            final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".copy");

            final JSONObject payload = new JSONObject();
            payload.put("name", new JSONString(newJobName));

            final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
            requestBuilder.setHeader("Content-Type", "application/json");
            requestBuilder.send(payload.toString(), new DCRequestCallback() {
                @Override
                protected void onSuccess(Request request, Response response) {
                    Window.Location.reload();
                }
            });
        }
    });

    menuBar.addItem("Delete job", new Command() {
        @Override
        public void execute() {
            boolean delete = Window.confirm("Are you sure you want to delete the job '" + job.getName()
                    + "' and related schedule, results and timelines.");
            if (delete) {
                final String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".delete");
                final DCRequestBuilder requestBuilder = new DCRequestBuilder(RequestBuilder.POST, url);
                requestBuilder.setHeader("Content-Type", "application/json");
                requestBuilder.send("", new DCRequestCallback() {
                    @Override
                    protected void onSuccess(Request request, Response response) {
                        Window.Location.reload();
                    }
                });
            }
        }
    });

    final boolean analysisJob = JobIdentifier.JOB_TYPE_ANALYSIS_JOB.equals(job.getType());

    if (analysisJob) {
        menuBar.addSeparator();

        menuBar.addItem("Job definition (xml)", new Command() {
            @Override
            public void execute() {
                String url = Urls.createRepositoryUrl(_tenant, "jobs/" + job.getName() + ".analysis.xml");
                Window.open(url, "datacleaner_job_details", null);
                _popup.hide();
            }
        });
        menuBar.addItem("Show latest result", new Command() {
            @Override
            public void execute() {
                String url = Urls.createRepositoryUrl(_tenant,
                        "results/" + job.getName() + "-latest.analysis.result.dat");
                Window.open(url, "datacleaner_job_details", null);
                _popup.hide();
            }
        });
    }

    _popup.setWidget(menuBar);
    _popup.showRelativeTo((UIObject) event.getSource());
}

From source file:org.fao.fenix.web.modules.text.client.control.TextEditorToolbarController.java

License:Open Source License

public static ClickListener onClick(final TextEditorToolbar toolbar) {
    return new ClickListener() {
        public void onClick(Widget sender) {
            if (sender == toolbar.bold) {
                toolbar.basic.toggleBold();
            } else if (sender == toolbar.italic) {
                toolbar.basic.toggleItalic();
            } else if (sender == toolbar.underline) {
                toolbar.basic.toggleUnderline();
            } else if (sender == toolbar.subscript) {
                toolbar.basic.toggleSubscript();
            } else if (sender == toolbar.superscript) {
                toolbar.basic.toggleSuperscript();
            } else if (sender == toolbar.strikethrough) {
                toolbar.extended.toggleStrikethrough();
            } else if (sender == toolbar.indent) {
                toolbar.extended.rightIndent();
            } else if (sender == toolbar.outdent) {
                toolbar.extended.leftIndent();
            } else if (sender == toolbar.justifyLeft) {
                toolbar.basic.setJustification(RichTextArea.Justification.LEFT);
            } else if (sender == toolbar.justifyCenter) {
                toolbar.basic.setJustification(RichTextArea.Justification.CENTER);
            } else if (sender == toolbar.justifyRight) {
                toolbar.basic.setJustification(RichTextArea.Justification.RIGHT);
            } else if (sender == toolbar.insertImage) {

                ImageFenixView imageFenixView = new ImageFenixView(toolbar);

                //               String url = Window.prompt("Enter an image URL:", "http://");
                //               if (url != null) {
                //                  toolbar.extended.insertImage(url);
                //               }
            } else if (sender == toolbar.createLink) {
                String url = Window.prompt("Enter a link URL:", "http://");
                if (url != null) {
                    toolbar.extended.createLink(url);
                }/*from   w ww .j  a  va 2  s .  c om*/
            } else if (sender == toolbar.removeLink) {
                toolbar.extended.removeLink();
            } else if (sender == toolbar.hr) {
                toolbar.extended.insertHorizontalRule();
            } else if (sender == toolbar.ol) {
                toolbar.extended.insertOrderedList();
            } else if (sender == toolbar.ul) {
                toolbar.extended.insertUnorderedList();
            } else if (sender == toolbar.removeFormat) {
                toolbar.extended.removeFormat();
            }
            // else if (sender == toolbar.backColors) {
            // new ColorPicker(toolbar.setBackColor, 0, 0,
            // toolbar.basic).build(ColorPickerCaller.TEXT_EDITOR_BG);
            // }
            // else if (sender == toolbar.foreColors) {
            // new ColorPicker(toolbar.setForeColor, 0, 0,
            // toolbar.basic).build(ColorPickerCaller.TEXT_EDITOR_FG);
            // }
            else if (sender == toolbar.richText) {
                // RichTextArea's onKeyUp event to update the toolbar
                // status.
                // This will catch any cases where the user moves the cursur
                // using the
                // keyboard, or uses one of the browser's built-in keyboard
                // shortcuts.
                updateStatus(toolbar);
            }
        }
    };
}

From source file:org.gwtportlets.portlet.client.edit.DefaultWidgetEditor.java

License:Open Source License

/**
 * Create a menu item to prompt for a style for a widget and change it.
 *//*from  w  ww  . ja  v  a  2 s  . c om*/
protected MenuItem createEnterStyleMenuItem(final PageEditor manager, final Widget widget) {
    MenuItem mi = new MenuItem("Enter Style Name", new Command() {
        public void execute() {
            String s = Window.prompt("Enter style name:", widget.getStylePrimaryName());
            if (s != null) {
                changeStyleName(manager, widget, s);
            }
        }
    });
    mi.setTitle("Capture new style name");
    return mi;
}

From source file:org.gwtportlets.portlet.client.ui.WebAppContentPortlet.java

License:Open Source License

public void configure() {
    String s = Window.prompt("Enter path to web content to display:", path == null ? "" : path);
    if (s != null) {
        path = s;//from   www.  j  ava2 s .com
        refresh();
    }
}

From source file:org.jahia.ajax.gwt.client.util.content.actions.ContentActions.java

License:Open Source License

/**
 * Create a folder//from w w  w .jav a 2  s  .c  o m
 *
 * @param linker
 */
public static void createFolder(final Linker linker) {
    GWTJahiaNode parent = linker.getSelectionContext().getSingleSelection();
    if (parent != null) {
        String newFolder = Window.prompt(Messages.get("newDirName.label"), "untitled");
        if (newFolder != null && FileUploader.filenameHasInvalidCharacters(newFolder)) {
            MessageBox.alert(Messages.get("label.error"),
                    Messages.getWithArgs("failure.upload.invalid.filename", "", new String[] { newFolder }),
                    null);
        } else if (newFolder != null && newFolder.length() > 0) {
            linker.loading(Messages.get("statusbar.newfoldering.label"));
            JahiaContentManagementService.App.getInstance().createFolder(parent.getPath(), newFolder,
                    new BaseAsyncCallback<GWTJahiaNode>() {
                        public void onApplicationFailure(Throwable throwable) {
                            Window.alert(Messages.get("failure.newDir.label") + "\n"
                                    + throwable.getLocalizedMessage());
                            linker.loaded();
                        }

                        public void onSuccess(GWTJahiaNode node) {
                            linker.setSelectPathAfterDataUpdate(Arrays.asList(node.getPath()));
                            linker.loaded();
                            Map<String, Object> data = new HashMap<String, Object>();
                            data.put("node", node);
                            if (linker instanceof ManagerLinker) {
                                data.put(Linker.REFRESH_MAIN, "true");
                            }
                            linker.refresh(data);
                        }
                    });
        }
    }
}