Java Code Examples for com.google.gwt.user.client.Window#confirm()

The following examples show how to use com.google.gwt.user.client.Window#confirm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MvpController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void goTo(final Place newPlace) {

	if (this.getWhere().equals(newPlace)) {
		return;
	}

	PlaceChangeRequestEvent willChange = new PlaceChangeRequestEvent(newPlace);
	EventBus.get().fireEvent(willChange);
	String warning = willChange.getWarning();
	if (warning == null || Window.confirm(warning)) {
		this.doGo(newPlace);
	} else {
		this.goTo(this.getWhere());
	}
}
 
Example 2
Source File: TemplateUploadWizard.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Removes a template repository.
 */
private void removeCurrentlySelectedRepository() {
  boolean ok = Window.confirm("Are you sure you want to remove this repository? " +
    "Click cancel to abort.");
  if (ok) {
    dynamicTemplateUrls.remove(templateHostUrl);
    templatesMap.remove(templateHostUrl);
    templatesMenu.removeItem(lastSelectedIndex);
    templatesMenu.setSelectedIndex(1);
    templatesMenu.setItemSelected(1, true);
    removeButton.setVisible(false);
    retrieveSelectedTemplates(templatesMenu.getValue(1));

    // Update the user settings
    UserSettings settings = Ode.getUserSettings();
    settings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS).
      changePropertyValue(SettingsConstants.USER_TEMPLATE_URLS,
        TemplateUploadWizard.getStoredTemplateUrls());
    settings.saveSettings(null);
  }
}
 
Example 3
Source File: DesignToolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() {
  Ode ode = Ode.getInstance();
  if (ode.screensLocked()) {
    return;                 // Don't permit this if we are locked out (saving files)
  }
  YoungAndroidSourceNode sourceNode = ode.getCurrentYoungAndroidSourceNode();
  if (sourceNode != null && !sourceNode.isScreen1()) {
    // DeleteFileCommand handles the whole operation, including displaying the confirmation
    // message dialog, closing the form editor and the blocks editor,
    // deleting the files in the server's storage, and deleting the
    // corresponding client-side nodes (which will ultimately trigger the
    // screen deletion in the DesignToolbar).
    final String deleteConfirmationMessage = MESSAGES.reallyDeleteForm(
        sourceNode.getFormName());
    ChainableCommand cmd = new DeleteFileCommand() {
      @Override
      protected boolean deleteConfirmation() {
        return Window.confirm(deleteConfirmationMessage);
      }
    };
    cmd.startExecuteChain(Tracking.PROJECT_ACTION_REMOVEFORM_YA, sourceNode);
  }
}
 
Example 4
Source File: ProjectToolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private boolean deleteConfirmation(List<Project> projects) {
  String message;
  GallerySettings gallerySettings = GalleryClient.getInstance().getGallerySettings();
  if (projects.size() == 1) {
    if (projects.get(0).isPublished()) {
      message = MESSAGES.confirmDeleteSinglePublishedProjectWarning(projects.get(0).getProjectName());
    } else {
      message = MESSAGES.confirmMoveToTrashSingleProject(projects.get(0).getProjectName());
    }
  } else {
    StringBuilder sb = new StringBuilder();
    String separator = "";
    for (Project project : projects) {
      sb.append(separator).append(project.getProjectName());
      separator = ", ";
    }
    String projectNames = sb.toString();
    if(!gallerySettings.galleryEnabled()){
      message = MESSAGES.confirmMoveToTrash(projectNames);
    } else {
      message = MESSAGES.confirmDeleteManyProjectsWithGalleryOn(projectNames);
    }
  }
  return Window.confirm(message);
}
 
Example 5
Source File: ProjectToolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private boolean deleteConfirmation(List<Project> projects) {
  String message;
  GallerySettings gallerySettings = GalleryClient.getInstance().getGallerySettings();
  if (projects.size() == 1) {
    if (projects.get(0).isPublished()) {
      message = MESSAGES.confirmDeleteSinglePublishedProject(projects.get(0).getProjectName());
    } else {
      message = MESSAGES.confirmDeleteSingleProject(projects.get(0).getProjectName());
    }
  } else {
    StringBuilder sb = new StringBuilder();
    String separator = "";
    for (Project project : projects) {
      sb.append(separator).append(project.getProjectName());
      separator = ", ";
    }
    String projectNames = sb.toString();
    if(!gallerySettings.galleryEnabled()){
      message = MESSAGES.confirmDeleteManyProjects(projectNames);
    } else {
      message = MESSAGES.confirmDeleteForeverManyProjectsWithGalleryOn(projectNames);
    }
  }
  return Window.confirm(message);
}
 
Example 6
Source File: TopToolbar.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private boolean deleteConfirmation(List<Project> projects) {
  String message;
  GallerySettings gallerySettings = GalleryClient.getInstance().getGallerySettings();
  if (projects.size() == 1) {
    if (projects.get(0).isPublished())
      message = MESSAGES.confirmDeleteSinglePublishedProjectWarning(projects.get(0).getProjectName());
    else
      message = MESSAGES.confirmMoveToTrashSingleProject(projects.get(0).getProjectName());
  } else {
    StringBuilder sb = new StringBuilder();
    String separator = "";
    for (Project project : projects) {
      sb.append(separator).append(project.getProjectName());
      separator = ", ";
    }
    String projectNames = sb.toString();
    if(!gallerySettings.galleryEnabled()){
      message = MESSAGES.confirmMoveToTrash(projectNames);
    } else {
      message = MESSAGES.confirmDeleteManyProjectsWithGalleryOn(projectNames);
    }
  }
  return Window.confirm(message);
}
 
Example 7
Source File: TopToolbar.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() {
  Tracking.trackEvent(Tracking.PROJECT_EVENT,
      Tracking.PROJECT_ACTION_DOWNLOAD_ALL_PROJECTS_SOURCE_YA);

  // Is there a way to disable the Download All button until this completes?
  if (Window.confirm(MESSAGES.downloadAllAlert())) {

    Downloader.getInstance().download(ServerLayout.DOWNLOAD_SERVLET_BASE +
        ServerLayout.DOWNLOAD_ALL_PROJECTS_SOURCE);
  }
}
 
Example 8
Source File: MenuController.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipMenuItemView item = panel.asBlipMenuItem(context);
  switch (item.getOption()) {
    case EDIT:
      actions.startEditing(item.getParent().getParent());
      break;
    case EDIT_DONE:
      actions.stopEditing();
      break;
    case REPLY:
      actions.reply(item.getParent().getParent());
      break;
    case DELETE:
      // We delete the blip without confirmation if shift key is pressed
      if (event.getNativeEvent().getShiftKey() || Window.confirm(messages.confirmDeletion())) {
        actions.delete(item.getParent().getParent());
      }
      break;
    case LINK:
      actions.popupLink(item.getParent().getParent());
      break;
    default:
      throw new AssertionError();
  }
  event.preventDefault();
  return true;
}
 
Example 9
Source File: MenuController.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipMenuItemView item = panel.asBlipMenuItem(context);
  switch (item.getOption()) {
    case EDIT:
      actions.startEditing(item.getParent().getParent());
      break;
    case EDIT_DONE:
      actions.stopEditing();
      break;
    case REPLY:
      actions.reply(item.getParent().getParent());
      break;
    case DELETE:
      // We delete the blip without confirmation if shift key is pressed
      if (event.getNativeEvent().getShiftKey() || Window.confirm(messages.confirmDeletion())) {
        actions.delete(item.getParent().getParent());
      }
      break;
    case LINK:
      actions.popupLink(item.getParent().getParent());
      break;
    default:
      throw new AssertionError();
  }
  event.preventDefault();
  return true;
}
 
Example 10
Source File: UniTimeConfirmationDialog.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static void confirm(boolean useDefault, String message, Command callback) {
	if (useDefault) {
		if (Window.confirm(message))
			callback.execute();
	} else {
		confirm(message, callback);
	}
}
 
Example 11
Source File: ComponentRemoveWidget.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleClick() {
  if (Window.confirm(MESSAGES.reallyRemoveComponent())) {
    long projectId = ode.getCurrentYoungAndroidProjectId();
    YaProjectEditor projectEditor = (YaProjectEditor) ode.getEditorManager().getOpenProjectEditor(projectId);
    SimpleComponentDatabase componentDatabase = SimpleComponentDatabase.getInstance();
    componentDatabase.addComponentDatabaseListener(projectEditor);
    componentDatabase.removeComponent(scd.getName());
  }
}
 
Example 12
Source File: NaluPluginGWT.java    From nalu with Apache License 2.0 5 votes vote down vote up
@Override
public void confirm(String message,
                    ConfirmHandler handler) {
  if (customConfirmPresenter == null) {
    if (Window.confirm(message)) {
      handler.onOk();
    } else {
      handler.onCancel();
    }
  } else {
    customConfirmPresenter.addConfirmHandler(handler);
    customConfirmPresenter.confirm(message);
  }
}
 
Example 13
Source File: FlowDemo.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(Control<StringBuffer> control)
{
    boolean shouldContinue = Window.confirm("Step " + name + ", continue?");
    control.getContext().append(",").append(name).append("-result");

    if (!shouldContinue)
    { control.abort(); }
    else
    { control.proceed(); }
}
 
Example 14
Source File: DatasetDeprecateMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final DatasetLeaf node) {
	Command command = new MenuItemCommand(node) {
		@Override
		public void execute() {
			String id = node.getModule().getId();
			boolean y = Window.confirm("Ready to deprecate " + node.getModule().getName() + "?");
			if (y) {
				DatasetServiceAsync svc = GWT.create(DatasetService.class);
				svc.deprecate(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}

				});
			}
			this.component.getContextMenu().hide();
		}
	};

	MenuItem item = new MenuItem("Deprecate", command);
	return item;
}
 
Example 15
Source File: JobDeleteMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final JobLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getJobId();
			boolean isExampleDir = node.getParentItem().getText().equals(Constants.studioUIMsg.examples());
			if(!isExampleDir && node.getModule().getAccount().equals(AppController.email) && node.getModule().getIsExample())
				Window.alert("The job is example job, please don't delete it in my task!");
			else
			{
				boolean y = Window.confirm("Are you sure you want to delete?");
				if (y) {
					JobServiceAsync srv = GWT.create(JobService.class);
					srv.deleteJob(id, new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							Window.alert(caught.getMessage());
						}

						@Override
						public void onSuccess(Void result) {
							node.delete();
						}
					});
				}
			}
			this.component.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Delete", command);
	return item;
}
 
Example 16
Source File: ProgramDeprecateMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {
	Command command = new MenuItemCommand(node) {
		@Override
		public void execute() {
			String id = node.getModule().getId();
			boolean y = Window.confirm("Are you ready to deprecate " + node.getModule().getName() + "?");
			if (y) {
				ProgramServiceAsync svc = GWT.create(ProgramService.class);
				svc.deprecate(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}

				});
			}
			this.component.getContextMenu().hide();
		}

	};

	MenuItem item = new MenuItem("deprecate", command);
	return item;
}
 
Example 17
Source File: JobAddExampleMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final JobLeaf node) {
	Command command = new MenuItemCommand(node) {

		@Override
		public void execute() {
			String id = node.getModule().getJobId();
			boolean y = Window.confirm("Are you sure you want to join the example task?");
			if (y) {
				JobServiceAsync srv = GWT.create(JobService.class);
				srv.setExampleJobs(id, new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						Window.alert(caught.getMessage());
					}

					@Override
					public void onSuccess(Void result) {
						node.delete();
					}
				});
			}
			this.component.getContextMenu().hide();
		}
	};
	MenuItem item = new MenuItem("Join example task", command);
	return item;
}
 
Example 18
Source File: ProgramDeleteMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final ProgramLeaf node) {

		Command command = new MenuItemCommand(node) {

			@Override
			public void execute() {
				String id = node.getModule().getId();
				boolean y = Window.confirm("Are you ready to delete " + node.getText() + "?");
				if (y) {
					ProgramServiceAsync svc = GWT.create(ProgramService.class);
					svc.delete(id, new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							Window.alert(caught.getMessage());
						}

						@Override
						public void onSuccess(Void result) {
							node.delete();
						}

					});
				}
				this.component.getContextMenu().hide();
			}
		};

		MenuItem item = new MenuItem("delete", command);
		return item;
	}
 
Example 19
Source File: DatasetDeleteMenu.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public static MenuItem create(final DatasetLeaf node) {

		Command command = new MenuItemCommand(node) {

			@Override
			public void execute() {
				String id = node.getModule().getId();
				boolean y = Window.confirm("Ready to delete " + node.getText() + "?");
				if (y) {
					DatasetServiceAsync svc = GWT.create(DatasetService.class);
					svc.delete(id, new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							Window.alert(caught.getMessage());
						}

						@Override
						public void onSuccess(Void result) {
							node.delete();
						}
					});
				}

				this.component.getContextMenu().hide();
			}
		};

		MenuItem item = new MenuItem("Delete", command);
		return item;
	}
 
Example 20
Source File: FileUploadWizard.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private boolean confirmOverwrite(FolderNode folderNode, String newFile, String existingFile) {
  return Window.confirm(MESSAGES.confirmOverwrite(newFile, existingFile));
}