List of usage examples for com.google.gwt.user.client Window confirm
public static boolean confirm(String msg)
From source file:org.drools.guvnor.client.admin.BackupManager.java
License:Apache License
private void exportRepository() { if (Window.confirm("Export the repository? This may take some time.")) { LoadingPopup.showMessage("Exporting repository, please wait, as this could take some time..."); Window.open(GWT.getModuleBaseURL() + "backup?" + HTMLFileManagerFields.FORM_FIELD_REPOSITORY + "=true", "downloading", "resizable=no,scrollbars=yes,status=no"); LoadingPopup.close();/* www. j av a 2 s . com*/ } }
From source file:org.drools.guvnor.client.admin.BackupManager.java
License:Apache License
private void exportPackageFromRepository(String packageName) { if (Window.confirm("Export the package?")) { LoadingPopup.showMessage("Exporting package, please wait, as this could take some time..."); Window.open(//from w ww. j av a 2 s .c om GWT.getModuleBaseURL() + "backup?" + HTMLFileManagerFields.FORM_FIELD_REPOSITORY + "=true&packageName=" + packageName, "downloading", "resizable=no,scrollbars=yes,status=no"); LoadingPopup.close(); } }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.AnnotationEditorPopup.java
License:Apache License
public void show() { final FormStylePopup pop = new FormStylePopup(); VerticalPanel vp = new VerticalPanel(); Grid g = new Grid(2, 3); txtName.addKeyPressHandler(new NoSpaceKeyPressHandler()); txtKey.addKeyPressHandler(new NoSpaceKeyPressHandler()); g.setWidget(0, 0, new HTML("<b>Name</b>")); g.setWidget(1, 0, txtName);/* ww w .j a va 2 s . c o m*/ g.setWidget(0, 1, new HTML("<b>Key</b>")); g.setWidget(1, 1, txtKey); g.setWidget(0, 2, new HTML("<b>Value</b>")); g.setWidget(1, 2, txtValue); setControlValues(annotation); Button btnOK = new Button(Constants.INSTANCE.OK()); btnOK.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String name = txtName.getText(); if (!isNameValid(name)) { Window.alert(Constants.INSTANCE.InvalidModelName(name)); return; } if (doesTheNameExist(name)) { Window.alert(Constants.INSTANCE.NameTakenForModel(name)); return; } if (annotationAlreadyHasAName() && annotationNameHasChanged(name)) { if (isTheUserSureHeWantsToChangeTheName()) { setNameAndClose(); } } else { setNameAndClose(); } } private boolean isNameValid(String name) { if (name == null || "".equals(name)) { return false; } return VALID_NAME.test(name); } private boolean annotationAlreadyHasAName() { return annotation.name != null && annotation.name.length() > 0; } private boolean annotationNameHasChanged(String name) { return !name.equals(annotation.name); } private void setNameAndClose() { String name = txtName.getText(); String key = txtKey.getText(); if (key == null || key.length() == 0) { //This is the default annotation key constructed by AnnotationDescr when none is provided //e.g. @smurf( Pupa ) -> @smurf( value = Pupa ). We explicitly set it to keep the user //experience consistent between what they enter and what is parsed. key = "value"; } String value = txtValue.getText(); annotation.name = name; annotation.getValues().clear(); annotation.getValues().put(key, value); okCommand.execute(); pop.hide(); } private boolean isTheUserSureHeWantsToChangeTheName() { return Window.confirm(Constants.INSTANCE.ModelNameChangeWarning()); } private boolean doesTheNameExist(String name) { for (AnnotationMetaModel a : annotations) { if (a != annotation) { if (a.name.equals(name)) { return true; } } } return false; } }); vp.add(g); vp.add(btnOK); pop.addRow(vp); pop.show(); }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.FactEditorPopup.java
License:Apache License
public void show() { final FormStylePopup pop = new FormStylePopup(); pop.setTitle(Constants.INSTANCE.Name()); HorizontalPanel changeName = new HorizontalPanel(); final TextBox name = new TextBox(); name.setText(factModel.getName());/*w w w . ja v a 2 s . co m*/ changeName.add(name); int selectedIndex = 0; lstSuperTypes.addItem(Constants.INSTANCE.DoesNotExtend()); //Sort Super Types by name Collections.sort(superTypeFactModels, byNameAscendingComparator); //Populate listbox for (FactMetaModel fmm : superTypeFactModels) { if (!fmm.getName().equals(factModel.getName())) { lstSuperTypes.addItem(fmm.getName()); if (factModel.getSuperType() != null && factModel.getSuperType().equals(fmm.getName())) { selectedIndex = lstSuperTypes.getItemCount() - 1; } } } lstSuperTypes.setSelectedIndex(selectedIndex); if (lstSuperTypes.getItemCount() == 1) { lstSuperTypes.setEnabled(false); } lstSuperTypes.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { if (lstSuperTypes.getSelectedIndex() <= 0) { factModel.setSuperType(null); } else { String oldSuperType = factModel.getSuperType(); String newSuperType = lstSuperTypes.getItemText(lstSuperTypes.getSelectedIndex()); factModel.setSuperType(newSuperType); if (createsCircularDependency(newSuperType)) { Window.alert(Constants.INSTANCE.CreatesCircularDependency(name.getText())); factModel.setSuperType(oldSuperType); lstSuperTypes.setSelectedIndex(getSelectedIndex(oldSuperType)); return; } else { factModel.setSuperType(newSuperType); } } } }); Button nameButton = new Button(Constants.INSTANCE.OK()); nameButton.addKeyPressHandler(new NoSpaceKeyPressHandler()); nameButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String factName = name.getText(); if (!isNameValid(factName)) { Window.alert(Constants.INSTANCE.InvalidModelName(factName)); return; } if (doesTheNameExist(factName)) { Window.alert(Constants.INSTANCE.NameTakenForModel(factName)); return; } if (factModelAlreadyHasAName(factName)) { if (isTheUserSureHeWantsToChangeTheName()) { setNameAndClose(); } } else { setNameAndClose(); } } private boolean isNameValid(String name) { if (name == null || "".equals(name)) { return false; } return VALID_NAME.test(name); } private boolean factModelAlreadyHasAName(String name) { return factModel.getName() != null && !factModel.getName().equals(name); } private void setNameAndClose() { String oldName = factModel.getName(); String newName = name.getText(); modelNameHelper.changeNameInModelNameHelper(oldName, newName); factModel.setName(newName); okCommand.execute(); pop.hide(); } private boolean isTheUserSureHeWantsToChangeTheName() { return Window.confirm(Constants.INSTANCE.ModelNameChangeWarning()); } private boolean doesTheNameExist(String name) { //The name may not have changed if (factModel.getName() != null && factModel.getName().equals(name)) { return false; } return !modelNameHelper.isUniqueName(name); } }); pop.addAttribute(Constants.INSTANCE.Name(), changeName); pop.addAttribute(Constants.INSTANCE.TypeExtends(), lstSuperTypes); pop.addRow(nameButton); pop.show(); }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.FactFieldsEditor.java
License:Apache License
private void addFieldRow(final FieldMetaModel field) { final FactFieldEditor editor = new FactFieldEditor(field, fields, modelNameHelper); editor.setDeleteCommand(new Command() { public void execute() { if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveTheField0(field.name))) { fieldsPanel.remove(editor); fields.remove(field);//from w w w . ja v a 2 s. c o m } } }); fieldsPanel.add(editor); }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.FactFieldsEditor.java
License:Apache License
private void addAnnotationRow(final AnnotationMetaModel annotation) { final AnnotationEditor editor = new AnnotationEditor(annotation, annotations); editor.setDeleteCommand(new Command() { public void execute() { if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveTheAnnotation0(annotation.name))) { fieldsPanel.remove(editor); annotations.remove(annotation); }// ww w .j a va 2 s. co m } }); fieldsPanel.insert(editor, findPositionOfLastAnnotation()); }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.FactModelEditor.java
License:Apache License
@UiHandler("deleteIcon") void deleteClick(ClickEvent event) { //Check if the Fact is a super type of any other facts for (FactMetaModel fmm : superTypeFactModels) { if (fmm.hasSuperType()) { if (fmm.getSuperType().equals(factMetaModel.getName())) { Window.confirm(Constants.INSTANCE.CannotDeleteADeclarationThatIsASuperType()); return; }// w w w. j a v a 2 s . co m } } if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveThisFact())) { deleteEvent.execute(); } }
From source file:org.drools.guvnor.client.asseteditor.drools.factmodel.FieldEditorPopup.java
License:Apache License
public void show() { final FormStylePopup pop = new FormStylePopup(); final TextBox fieldName = new TextBox(); final TextBox fieldType = new TextBox(); fieldName.addKeyPressHandler(new NoSpaceKeyPressHandler()); fieldType.addKeyPressHandler(new NoSpaceKeyPressHandler()); if (field != null) { fieldName.setText(field.name);/*from ww w . ja v a 2s .c o m*/ fieldType.setText(field.type); } HorizontalPanel typeP = new HorizontalPanel(); typeP.add(fieldType); final ListBox typeChoice = new ListBox(); typeChoice.addItem(Constants.INSTANCE.chooseType()); for (Map.Entry<String, String> entry : modelNameHelper.getTypeDescriptions().entrySet()) { typeChoice.addItem(entry.getValue(), entry.getKey()); } typeChoice.setSelectedIndex(0); typeChoice.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fieldType.setText(typeChoice.getValue(typeChoice.getSelectedIndex())); } }); typeP.add(typeChoice); pop.addAttribute(Constants.INSTANCE.FieldNameAttribute(), fieldName); pop.addAttribute(Constants.INSTANCE.Type(), typeP); Button ok = new Button(Constants.INSTANCE.OK()); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String dataType = fieldType.getText(); if (!isDataTypeValid(dataType)) { Window.alert(Constants.INSTANCE.InvalidDataTypeName(dataType)); return; } String name = fieldName.getText(); if (!isNameValid(name)) { Window.alert(Constants.INSTANCE.InvalidModelName(name)); return; } if (doesTheNameExist(name)) { Window.alert(Constants.INSTANCE.NameTakenForModel(name)); return; } if (factModelAlreadyHasAName(name)) { if (isTheUserSureHeWantsToChangeTheName()) { setNameAndClose(); } } else { setNameAndClose(); } } private boolean isDataTypeValid(String dataType) { if (dataType == null || "".equals(dataType)) { return false; } return VALID_DATATYPE.test(dataType); } private boolean isNameValid(String name) { if (name == null || "".equals(name)) { return false; } return VALID_NAME.test(name); } private boolean factModelAlreadyHasAName(String name) { return field.name != null && !field.name.equals(name); } private void setNameAndClose() { field.name = fieldName.getText(); field.type = fieldType.getText(); okCommand.execute(); pop.hide(); } private boolean isTheUserSureHeWantsToChangeTheName() { return Window.confirm(Constants.INSTANCE.ModelNameChangeWarning()); } private boolean doesTheNameExist(String name) { //The name may not have changed if (field.name != null && field.name.equals(name)) { return false; } //Check for field name is unique amongst other fields on the fact for (FieldMetaModel f : fields) { if (f.name.equals(name)) { return true; } } return false; } }); pop.addAttribute("", ok); pop.show(); }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.ActionInsertFactWidget.java
License:Apache License
private void doLayout() { layout.clear();//from w w w.j av a2 s. com layout.setWidget(0, 0, getAssertLabel()); layout.setWidget(1, 0, new HTML(" ")); layout.getFlexCellFormatter().setColSpan(0, 0, 2); DirtyableFlexTable inner = new DirtyableFlexTable(); int col = 0; for (int i = 0; i < model.fieldValues.length; i++) { ActionFieldValue val = model.fieldValues[i]; inner.setWidget(i, 0 + col, fieldSelector(val)); inner.setWidget(i, 1 + col, valueEditor(val)); final int idx = i; Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); remove.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) { model.removeField(idx); setModified(true); getModeller().refreshWidget(); //Signal possible change in Template variables TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent( getModeller().getModel()); getEventBus().fireEventFromSource(tvce, getModeller().getModel()); } } }); if (!this.readOnly) { inner.setWidget(i, 2 + col, remove); } } layout.setWidget(1, 1, inner); }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.ActionSetFieldWidget.java
License:Apache License
private void doLayout() { layout.clear();/*from w w w. ja v a2s. c om*/ for (int i = 0; i < model.fieldValues.length; i++) { ActionFieldValue val = model.fieldValues[i]; layout.setWidget(i, 0, getSetterLabel()); layout.setWidget(i, 1, fieldSelector(val)); layout.setWidget(i, 2, valueEditor(val)); final int idx = i; Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall(); remove.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) { model.removeField(idx); setModified(true); getModeller().refreshWidget(); //Signal possible change in Template variables TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent( getModeller().getModel()); getEventBus().fireEventFromSource(tvce, getModeller().getModel()); } } }); if (!this.readOnly) { layout.setWidget(i, 3, remove); } } if (model.fieldValues.length == 0) { HorizontalPanel h = new HorizontalPanel(); h.add(getSetterLabel()); if (!this.readOnly) { Image image = GuvnorImages.INSTANCE.Edit(); image.setAltText(Constants.INSTANCE.AddFirstNewField()); image.setTitle(Constants.INSTANCE.AddFirstNewField()); image.addClickHandler(new ClickHandler() { public void onClick(ClickEvent sender) { showAddFieldPopup(sender); } }); h.add(image); } layout.setWidget(0, 0, h); } //layout.setWidget( 0, 1, inner ); }