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:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleAttributeWidget.java

License:Apache License

private Image getRemoveMetaIcon(final int idx) {
    Image remove = new Image(DroolsGuvnorImageResources.INSTANCE.itemImages().deleteItemSmall());
    remove.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisRuleOption())) {
                model.removeMetadata(idx);
                parent.refreshWidget();//from  w w  w. j a v  a 2s . co m
            }
        }
    });
    return remove;
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModeller.java

License:Apache License

/**
 * Do all the widgets for the RHS./*  w w w.ja v a 2s  .c  o  m*/
 */
private void renderRhs(final RuleModel model) {

    for (int i = 0; i < model.rhs.length; i++) {
        DirtyableVerticalPane widget = new DirtyableVerticalPane();
        widget.setWidth("100%");
        IAction action = model.rhs[i];

        //if lockRHS() set the widget RO, otherwise let them decide.
        Boolean readOnly = this.lockRHS() ? true : null;

        RuleModellerWidget w = getWidgetFactory().getWidget(this, eventBus, action, readOnly);
        w.addOnModifiedCommand(this.onWidgetModifiedCommand);

        w.setWidth("100%");
        widget.add(spacerWidget());

        DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
        horiz.setWidth("100%");
        //horiz.setBorderWidth(2);

        Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
        remove.setTitle(Constants.INSTANCE.RemoveThisAction());
        final int idx = i;
        remove.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) {
                    model.removeRhsItem(idx);
                    refreshWidget();

                    //Signal possible change in Template variables
                    TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(model);
                    eventBus.fireEventFromSource(tvce, model);
                }
            }
        });
        horiz.add(w);
        if (!(w instanceof ActionRetractFactWidget)) {
            w.setWidth("100%"); //NON-NLS
            horiz.setWidth("100%");
        }

        if (!(this.lockRHS() || w.isReadOnly())) {
            horiz.add(remove);
        }

        widget.add(horiz);

        layout.setHTML(currentLayoutRow, 0, "<div class='form-field'>" + (i + 1) + ".</div>");
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 0,
                HasHorizontalAlignment.ALIGN_CENTER);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 0,
                HasVerticalAlignment.ALIGN_MIDDLE);

        layout.setWidget(currentLayoutRow, 1, widget);
        layout.getFlexCellFormatter().setHorizontalAlignment(currentLayoutRow, 1,
                HasHorizontalAlignment.ALIGN_LEFT);
        layout.getFlexCellFormatter().setVerticalAlignment(currentLayoutRow, 1, HasVerticalAlignment.ALIGN_TOP);
        layout.getFlexCellFormatter().setWidth(currentLayoutRow, 1, "100%");

        final int index = i;
        if (!(this.lockRHS() || w.isReadOnly())) {
            this.addActionsButtonsToLayout(Constants.INSTANCE.AddAnActionBelow(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    showActionSelector((Widget) event.getSource(), index + 1);
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveRhsItemDown(index);
                    refreshWidget();
                }
            }, new ClickHandler() {

                public void onClick(ClickEvent event) {
                    model.moveRhsItemUp(index);
                    refreshWidget();
                }
            });
        }

        this.rhsWidgets.add(w);
        currentLayoutRow++;

    }

}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModeller.java

License:Apache License

/**
 * This adds the widget to the UI, also adding the remove icon.
 *///from   ww w.j a  v a 2  s . c o m
private Widget wrapLHSWidget(final RuleModel model, int i, RuleModellerWidget w) {
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();

    final Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
    remove.setTitle(Constants.INSTANCE.RemoveThisENTIREConditionAndAllTheFieldConstraintsThatBelongToIt());
    final int idx = i;
    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (Window.confirm(Constants.INSTANCE.RemoveThisEntireConditionQ())) {
                if (model.removeLhsItem(idx)) {
                    refreshWidget();

                    //Signal possible change in Template variables
                    TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(model);
                    eventBus.fireEventFromSource(tvce, model);
                } else {
                    ErrorPopup.showMessage(
                            Constants.INSTANCE.CanTRemoveThatItemAsItIsUsedInTheActionPartOfTheRule());
                }
            }
        }
    });

    horiz.setWidth("100%");
    w.setWidth("100%");

    horiz.add(w);
    if (!(this.lockLHS() || w.isReadOnly())) {
        horiz.add(remove);
    }

    return horiz;
}

From source file:org.drools.guvnor.client.asseteditor.drools.PackagesNewAssetMenuViewImpl.java

License:Apache License

public void confirmRebuild() {
    if (Window.confirm(Constants.INSTANCE.RebuildConfirmWarning())) {
        presenter.onRebuildConfirmed();
    }
}

From source file:org.drools.guvnor.client.asseteditor.drools.serviceconfig.ServiceConfigEditor.java

License:Apache License

private void addKBasePainel(final ServiceKBaseConfig kbase, final ClientFactory clientFactory) {

    final ClosableLabel closableLabel = new ClosableLabel(kbase.getName());

    final UpdateTabEvent updateTabEvent = new UpdateTabEvent() {
        public void onUpdate(String newName) {
            closableLabel.updateTitle(newName);
        }//  ww w. ja v a  2s  . c  o  m
    };

    tabPanel.add(new KBaseConfigPanel(config, kbase, updateTabEvent, asset.getMetaData().getModuleUUID(),
            asset.getMetaData().getModuleName(), clientFactory), closableLabel);

    closableLabel.addCloseHandler(new CloseHandler<ClosableLabel>() {
        public void onClose(CloseEvent<ClosableLabel> closableLabelCloseEvent) {
            if (tabPanel.getWidgetCount() <= 2) {
                Window.alert(Constants.INSTANCE.CantDeleteKBase());
                return;
            }
            if (!Window.confirm(Constants.INSTANCE.ConfirmDeleteKBase())) {
                return;
            }
            for (int i = 0; i < tabPanel.getWidgetCount(); i++) {
                if (tabPanel.getWidget(i) instanceof KBaseConfigPanel) {
                    final KBaseConfigPanel editor = (KBaseConfigPanel) tabPanel.getWidget(i);
                    if (editor.getKBase().getName().equals(kbase.getName())) {
                        config.removeKBase(kbase.getName());
                        tabPanel.remove(i);
                        break;
                    }
                }
            }
        }
    });
}

From source file:org.drools.guvnor.client.examples.NewRepositoryDialog.java

License:Apache License

public NewRepositoryDialog() {
    setTitle(((ConstantsCore) GWT.create(ConstantsCore.class)).WelcomeToGuvnor());

    constants = ((ConstantsCore) GWT.create(ConstantsCore.class));
    addAttribute("", new HTML("<div class='highlight'>" + constants.BrandNewRepositoryNote() + "</div>")); //NON-NLS

    HorizontalPanel hp = new HorizontalPanel();

    Button ins = new Button(constants.YesPleaseInstallSamples());
    hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hp.add(ins);/*from  w  w w  . j av  a2 s.  c o m*/
    Button no = new Button(constants.NoThanks());
    hp.add(no);

    addAttribute("", hp);
    ins.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (!Window.confirm(constants.AboutToInstallSampleRepositoryAreYouSure()))
                return;
            LoadingPopup.showMessage(constants.ImportingAndProcessing());
            ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
            moduleService.installSampleRepository(new GenericCallback<java.lang.Void>() {
                public void onSuccess(Void v) {
                    Window.alert(constants.RepositoryInstalledSuccessfully());
                    hide();
                    Window.Location.reload();
                }
            });
        }
    });
    no.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            hide();
        }
    });

}

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

License:Apache License

public ArchivedAssetManager(ClientFactory clientFactory, EventBus eventBus) {

    this.eventBus = eventBus;

    PrettyFormLayout pf = new PrettyFormLayout();

    VerticalPanel header = new VerticalPanel();
    header.add(new HTML(constants.ArchivedItems()));

    pf.addHeader(GuvnorImages.INSTANCE.Backup(), header);

    loadPackages();/*w w  w. jav  a 2  s.  com*/

    Command restoreSelectedAssetCommand = new Command() {

        public void execute() {
            if (table.getSelectedRowUUIDs() == null) {
                Window.alert(constants.PleaseSelectAnItemToRestore());
                return;
            }
            assetService.archiveAssets(table.getSelectedRowUUIDs(), false,
                    new GenericCallback<java.lang.Void>() {
                        public void onSuccess(Void arg0) {
                            Window.alert(constants.ItemRestored());
                            table.refresh();
                        }
                    });
        }

    };

    Command deleteSelectedAssetCommand = new Command() {

        public void execute() {
            if (table.getSelectedRowUUIDs() == null) {
                Window.alert(constants.PleaseSelectAnItemToPermanentlyDelete());
                return;
            }
            if (!Window.confirm(constants.AreYouSureDeletingAsset())) {
                return;
            }
            assetService.removeAssets(table.getSelectedRowUUIDs(), new GenericCallback<java.lang.Void>() {
                public void onSuccess(Void arg0) {
                    Window.alert(constants.ItemDeleted());
                    table.refresh();
                }
            });
        }

    };

    table = new AdminArchivedPagedTable(restoreSelectedAssetCommand, deleteSelectedAssetCommand, clientFactory);
    HorizontalPanel packagesToolbar = new HorizontalPanel();
    btnRestorePackage = new Button(constants.RestoreSelectedPackage());
    btnRestorePackage.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (packages.getSelectedIndex() == -1) {
                Window.alert(constants.PleaseSelectAnItemToRestore());
                return;
            }
            restorePackage(packages.getValue(packages.getSelectedIndex()));
        }

    });
    packagesToolbar.add(btnRestorePackage);

    btnDeletePackage = new Button(constants.PermanentlyDeletePackage());
    btnDeletePackage.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (packages.getSelectedIndex() == -1) {
                Window.alert(constants.PleaseSelectAnItemToPermanentlyDelete());
                return;
            }
            if (Window.confirm(constants.AreYouSurePackageDelete())) {
                deletePackage(packages.getValue(packages.getSelectedIndex()));
            }
        }

    });
    packagesToolbar.add(btnDeletePackage);

    pf.startSection(constants.ArchivedPackagesList());
    pf.addRow(packagesToolbar);
    pf.addRow(packages);
    pf.endSection();

    pf.startSection(constants.ArchivedAssets());
    pf.addRow(table);
    pf.endSection();

    initWidget(pf);
}

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

License:Apache License

private Widget newImportWidget() {

    final FormPanel uploadFormPanel = new FormPanel();
    uploadFormPanel.setAction(GWT.getModuleBaseURL() + "backup");
    uploadFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadFormPanel.setMethod(FormPanel.METHOD_POST);

    HorizontalPanel panel = new HorizontalPanel();
    uploadFormPanel.setWidget(panel);//from  w w w.  j a va2 s  . co  m

    final FileUpload upload = new FileUpload();
    upload.setName(HTMLFileManagerFields.FILE_UPLOAD_FIELD_NAME_IMPORT);
    upload.setHeight("30px");
    panel.add(upload);

    panel.add(new HTML("&nbsp;&nbsp;&nbsp;"));

    Button ok = new Button(constants.Import());
    ok.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent sender) {
            doImportFile(uploadFormPanel);
        }

        private void doImportFile(final FormPanel uploadFormPanel) {
            if (Window.confirm(constants.ImportConfirm())) {
                LoadingPopup.showMessage(constants.ImportingInProgress());
                uploadFormPanel.submit();
            }
        }
    });

    panel.add(ok);

    uploadFormPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            if (event.getResults().indexOf("OK") > -1) {
                Window.alert(constants.ImportDone());
                History.newItem(" ");
                Window.Location.reload();
            } else {
                ErrorPopup.showMessage(constants.ImportFailed());
            }
            LoadingPopup.close();
        }
    });

    uploadFormPanel.addSubmitHandler(new SubmitHandler() {

        public void onSubmit(SubmitEvent event) {
            String fileName = upload.getFilename();
            if (fileName.length() == 0) {
                Window.alert(constants.NoExportFilename());
                event.cancel();
            } else {
                String lowerCaseFileName = fileName.toLowerCase();
                if (!lowerCaseFileName.endsWith(".xml") && !lowerCaseFileName.endsWith(".zip")) {
                    Window.alert(constants.PleaseSpecifyAValidRepositoryXmlFile());
                    event.cancel();
                }
            }
        }
    });

    return uploadFormPanel;
}

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

License:Apache License

private void exportRepository() {

    if (Window.confirm(constants.ExportRepoWarning())) {
        LoadingPopup.showMessage(constants.ExportRepoWait());

        Window.open(GWT.getModuleBaseURL() + "backup?" + HTMLFileManagerFields.FORM_FIELD_REPOSITORY + "=true",
                "downloading", "resizable=no,scrollbars=yes,status=no");

        LoadingPopup.close();/*from w  w  w  .j  a va 2 s.  c om*/
    }
}

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

License:Apache License

private void deleteSelected() {
    if (Window.confirm(constants.AreYouSureYouWantToDeleteCategory() + explorer.getSelectedPath())) {
        CategoryServiceAsync categoryService = GWT.create(CategoryService.class);
        categoryService.removeCategory(explorer.getSelectedPath(), new GenericCallback<java.lang.Void>() {

            public void onSuccess(Void v) {
                explorer.refresh();/* www  .  ja v  a2 s .  c om*/
            }

        });
    }
}