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() . These examples are extracted from open source projects. 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
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 2
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 3
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 4
@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 5
/**
 * 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 6
@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 7
Source Project: nalu   File: NaluPluginGWT.java    License: 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 8
Source Project: EasyML   File: DatasetDeleteMenu.java    License: 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 9
Source Project: EasyML   File: ProgramDeleteMenu.java    License: 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 10
Source Project: EasyML   File: JobAddExampleMenu.java    License: 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 11
Source Project: EasyML   File: ProgramDeprecateMenu.java    License: 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 12
Source Project: EasyML   File: JobDeleteMenu.java    License: 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 13
Source Project: EasyML   File: DatasetDeprecateMenu.java    License: 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 14
@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 15
@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 16
@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 17
public static void confirm(boolean useDefault, String message, Command callback) {
	if (useDefault) {
		if (Window.confirm(message))
			callback.execute();
	} else {
		confirm(message, callback);
	}
}
 
Example 18
Source Project: swellrt   File: MenuController.java    License: 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 19
@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 20
private boolean confirmOverwrite(FolderNode folderNode, String newFile, String existingFile) {
  return Window.confirm(MESSAGES.confirmOverwrite(newFile, existingFile));
}