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

The following examples show how to use com.google.gwt.user.client.Window#alert() . 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: CommonProgramWidget.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Create Program Conf
 * @return program conf
 */
@Override
protected ProgramConf createProgramConf() {
	Commander cmd = null;
	try {
		cmd = CommandParser.parse(program.getCommandline());
	} catch (CommandParseException e) {
		Window.alert( e.getMessage() );
	}
    CommonProgramConf conf = null;
    
    if(program.isTensorflow())
         conf = new CommonProgramConf(cmd, true);
    else
         conf = new CommonProgramConf(cmd, program.isStandalone());

	return conf;
}
 
Example 2
Source File: YoungAndroidFormUpgrader.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Upgrades the given sourceProperties if necessary.
 *
 * @param sourceProperties the properties from the source file
 * @return true if the sourceProperties was upgraded, false otherwise
 */
public static boolean upgradeSourceProperties(Map<String, JSONValue> sourceProperties) {
  StringBuilder upgradeDetails = new StringBuilder();
  try {
    int srcYaVersion = getSrcYaVersion(sourceProperties);
    if (needToUpgrade(srcYaVersion)) {
      Map<String, JSONValue> formProperties =
          sourceProperties.get("Properties").asObject().getProperties();
      upgradeComponent(srcYaVersion, formProperties, upgradeDetails);
      // The sourceProperties were upgraded. Update the version number.
      setSrcYaVersion(sourceProperties);
      if (upgradeDetails.length() > 0) {
        Window.alert(MESSAGES.projectWasUpgraded(upgradeDetails.toString()));
      }
      return true;
    }
  } catch (LoadException e) {
    // This shouldn't happen. If it does it's our fault, not the user's fault.
    Window.alert(MESSAGES.unexpectedProblem(e.getMessage()));
    OdeLog.xlog(e);
  }
  return false;
}
 
Example 3
Source File: ToolBarButtonExample.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
public ToolBarButtonExample() {
	button = new ToolBarButton(new Image(OKMExtensionBundleExampleResources.INSTANCE.box()), title, new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			Window.alert("make some operation");
		}
	});
}
 
Example 4
Source File: TextValidators.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether the given project name is valid, displaying an alert
 * if it is not.  In order to be valid, the project name must satisfy
 * {@link #isValidIdentifier(String)} and not be a duplicate of an existing
 * project name for the same user.
 *
 * @param projectName the project name to validate
 * @return {@code true} if the project name is valid, {@code false} otherwise
 */
public static boolean checkNewProjectName(String projectName) {

  // Check the format of the project name
  if (!isValidIdentifier(projectName)) {
    Window.alert(MESSAGES.malformedProjectNameError());
    return false;
  }

  // Check for names that reserved words
  if (isReservedName(projectName)) {
    Window.alert(MESSAGES.reservedNameError());
    return false;
  }

  // Check that project does not already exist
  if (Ode.getInstance().getProjectManager().getProject(projectName) != null) {
    Window.alert(MESSAGES.duplicateProjectNameError(projectName));
    return false;
  }

  // Check that project name may already exist in Trash Projects
  if (Ode.getInstance().getProjectManager().getTrashProject(projectName) != null) {
    Window.alert(MESSAGES.duplicateTrashProjectNameError(projectName));
    return false;
  }

  return true;
}
 
Example 5
Source File: SubsetJSONPropertyEditor.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void loadJSONfile(FileUpload filePath, Boolean doUpdate) {
  String uploadFilename = filePath.getFilename();
  if (!uploadFilename.isEmpty()) {
    final String filename = makeValidFilename(uploadFilename);
    if (!TextValidators.isValidCharFilename(filename)) {
      Window.alert(MESSAGES.malformedFilename());
    } else if (!TextValidators.isValidLengthFilename(filename)) {
      Window.alert(MESSAGES.malformedFilename());
    } else if (!filename.endsWith(".json")){
      Window.alert(MESSAGES.malformedFilenameTitle());
    } else {
      loadJSONfileNative(filePath.getElement(), doUpdate);
    }
  }
}
 
Example 6
Source File: ExceptionHandler.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Process exception.
 * 
 * @param e
 *            the e
 */
private static void logInToaster(MetaException e) {
    Toaster toaster = Toaster.getToasterInstance();
    if (toaster == null) {
        Window.alert("Initialization error: no message toaster present!");
        if (!GWT.isProdMode()) {
            GWT.log("INIT ERROR: No message toaster present!");
            GWT.log(e.getMessage(), e);
        }
        return;
    }

    StringBuilder sb = new StringBuilder();
    switch (e.getWeight()) {
    case mild:
        sb.append("MILD: ");
        break;
    case severe:
        sb.append("SEVERE: ");
        break;
    }
    sb.append(e.getMessage());
    sb.append("\ncaused by: ");
    sb.append(e.getCause());
    toaster.addErrorMessage(sb.toString());
    if (!GWT.isProdMode()) GWT.log(e.getMessage(), e);
}
 
Example 7
Source File: ColorHelper.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Show popup with a color picker and set/clear the color on the range.
 *
 * @param editor the editor
 * @param button the button
 * @param suffix the key suffix
 * @param allowNone the allow none color (in background color)
 */
private static void showPopup(final EditorContext editor, ToolbarClickButton button,
    final String suffix, boolean allowNone) {
  FocusedRange focusedRange = editor.getSelectionHelper().getSelectionRange();
  if (focusedRange == null) {
    // Lets try to focus
    editor.focus(false);
  }
  focusedRange = editor.getSelectionHelper().getSelectionRange();
  if (focusedRange == null) {
    Window.alert(ComplexColorPicker.messages.selectSomeText());
    return;
  }
  final Range range = focusedRange.asRange();
  final ColorPopup popup = new ColorPopup(button.getButton().hackGetWidget().getElement(), allowNone);
  popup.show(new OnColorChooseListener() {
    @Override
    public void onColorChoose(String color) {
      EditorAnnotationUtil.
          setAnnotationOverRange(editor.getDocument(), editor.getCaretAnnotations(),
              StyleAnnotationHandler.key(suffix), color, range.getStart(), range.getEnd());
      popup.hide();
      editor.focus(false);
    }

    @Override
    public void onNoneColorChoose() {
      EditorAnnotationUtil.
      clearAnnotationsOverRange(editor.getDocument(), editor.getCaretAnnotations(),
          new String[] {StyleAnnotationHandler.key(suffix)}, range.getStart(), range.getEnd());
      popup.hide();
      editor.focus(false);
    }});
}
 
Example 8
Source File: DBController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Submit the uploaded dataSet  information to the database.
 * 
 * @param fileUploader
 * @param grid
 * @return  If submit is success
 * @throws CommandParseException
 */
public boolean submitUploadDataset2DB(final Presenter presenter,final View view, final UploadFileModule fileUploader
		,Dataset dataset, DescribeGrid grid)
				throws CommandParseException {
	String name = grid.getText("Name");
	if (name == null || "".equals(name)) {
		Window.alert("Name could not be empty!");
		return false;
	}
	String category = grid.getText("Category");
	if(category == null || "".equals(category) || category.equals("Choose Category")){
		Window.alert("Category could not be empty!");
		return false;
	}
	datasetBinder.sync(grid, dataset);
	fileUploader.setUpLoadDataset(dataset);
	datasetSrv.upload(grid.asDataset(dataset), fileUploader.getNewFileUUID(),
			new AsyncCallback<Dataset>() {
		@Override
		public void onFailure(Throwable caught) {
			Window.alert(caught.getMessage());
		}
		@Override
		public void onSuccess(Dataset result) {
			fileUploader.setUpLoadDataset(result);
			DatasetLeaf node = new DatasetLeaf(result);
			DatasetTreeLoader.addContextMenu( view.getDatasetTree()
					,node);
			DatasetTreeLoader.addDatasetLeaf( view.getDatasetTree(),
					node,AppController.email);
			logger.info("Dataset insert to DB:"+result.getCategory());
		}
	});
	return true;
}
 
Example 9
Source File: FrontendMain.java    From mvn-golang with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPushSystemError(final Throwable thr) {
    this.timerLabel.setText("Can't get time from server");
    Window.alert("Detected error in push event system : "+thr.getMessage());
    return false;
}
 
Example 10
Source File: ToolBarButtonExample.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onChange(ToolBarEventConstant event) {
	if (event.equals(HasToolBarEvent.EXECUTE_ADD_DOCUMENT)) {
		Window.alert("executed add document - " + event.getType());
	}
}
 
Example 11
Source File: ComponentImportWizard.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void onSuccess(ComponentImportResponse response) {
  if (response.getStatus() == ComponentImportResponse.Status.FAILED){
    Window.alert(MESSAGES.componentImportError() + "\n" + response.getMessage());
    return;
  }
  else if (response.getStatus() != ComponentImportResponse.Status.IMPORTED &&
      response.getStatus() != ComponentImportResponse.Status.UPGRADED) {
    Window.alert(MESSAGES.componentImportError());
    return;
  }
  else if (response.getStatus() == ComponentImportResponse.Status.UNKNOWN_URL) {
    Window.alert(MESSAGES.componentImportUnknownURLError());
  }
  else if (response.getStatus() == ComponentImportResponse.Status.UPGRADED) {
    StringBuilder sb = new StringBuilder(MESSAGES.componentUpgradedAlert());
    for (String name : response.getComponentTypes().values()) {
      sb.append("\n");
      sb.append(name);
    }
    Window.alert(sb.toString());
  }

  List<ProjectNode> compNodes = response.getNodes();
  long destinationProjectId = response.getProjectId();
  long currentProjectId = ode.getCurrentYoungAndroidProjectId();
  if (currentProjectId != destinationProjectId) {
    return; // User switched project early!
  }
  Project project = ode.getProjectManager().getProject(destinationProjectId);
  if (project == null) {
    return; // Project does not exist!
  }
  if (response.getStatus() == ComponentImportResponse.Status.UPGRADED ||
      response.getStatus() == ComponentImportResponse.Status.IMPORTED) {
    YoungAndroidComponentsFolder componentsFolder = ((YoungAndroidProjectNode) project.getRootNode()).getComponentsFolder();
    YaProjectEditor projectEditor = (YaProjectEditor) ode.getEditorManager().getOpenProjectEditor(destinationProjectId);
    if (projectEditor == null) {
      return; // Project is not open!
    }
    for (ProjectNode node : compNodes) {
      project.addNode(componentsFolder, node);
      if ((node.getName().equals("component.json") || node.getName().equals("components.json"))
          && StringUtils.countMatches(node.getFileId(), "/") == 3) {
        projectEditor.addComponent(node, null);
      }
    }
  }
}
 
Example 12
Source File: TableDisplayerView.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
@Override
public void exportNoData() {
    Window.alert(TableConstants.INSTANCE.tableDisplayer_export_no_data());
}
 
Example 13
Source File: BaseWidget.java    From EasyML with Apache License 2.0 4 votes vote down vote up
public BaseWidget clone(String Id){
	Window.alert("clone");
	return this;
}
 
Example 14
Source File: ToolBarButtonExample.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onChange(LanguageEventConstant event) {
	if (event.equals(HasLanguageEvent.LANGUAGE_CHANGED)) {
		Window.alert("language changed");
	}
}
 
Example 15
Source File: MainMenuExample.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void execute() {
	Window.alert("option2 action");
}
 
Example 16
Source File: Ode.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public void openPreviousProject() {
  if (userSettings == null) {
    OdeLog.wlog("Ignoring openPreviousProject() since userSettings is null");
    return;
  }
  OdeLog.log("Ode.openPreviousProject called");
  final String value = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS).
    getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID);

  // Retrieve the userTemplates
  String userTemplates = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS).
    getPropertyValue(SettingsConstants.USER_TEMPLATE_URLS);
  TemplateUploadWizard.setStoredTemplateUrls(userTemplates);

  if (templateLoadingFlag) {  // We are loading a template, open it instead
                              // of the last project
    NewProjectCommand callbackCommand = new NewProjectCommand() {
        @Override
        public void execute(Project project) {
          templateLoadingFlag = false;
          Ode.getInstance().openYoungAndroidProjectInDesigner(project);
        }
      };
    TemplateUploadWizard.openProjectFromTemplate(templatePath, callbackCommand);
  } else if(galleryIdLoadingFlag){
    try {
      long galleryId_Long = Long.valueOf(galleryId);
      final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>(
          // failure message
          MESSAGES.galleryError()) {
            @Override
            public void onSuccess(GalleryApp app) {
              if(app == null){
                openProject(value);
                Window.alert(MESSAGES.galleryIdNotExist());
              }else{
                Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
              }
            }
          };
      Ode.getInstance().getGalleryService().getApp(galleryId_Long, callback);
    } catch (NumberFormatException e) {
      openProject(value);
      Window.alert(MESSAGES.galleryIdNotExist());
    }
  } else {
    openProject(value);
  }
}
 
Example 17
Source File: PropertiesStrategy.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void launchNewPropertyDialoge(String reference) {
    Window.alert("Not yet implemented");
}
 
Example 18
Source File: HelloWorld.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onChange(LanguageEventConstant event) {
	if (event.equals(HasLanguageEvent.LANGUAGE_CHANGED)) {
		Window.alert("language changed");
	}
}
 
Example 19
Source File: DBController.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * Submit the uploaded program information to the database.
 * 
 * @param presenter
 * @param fileUploader
 * @param program
 * @param grid
 * @return  If submit is success
 * @throws CommandParseException
 */
public boolean submitUploadProgram2DB(final Presenter presenter,  final View view, final UploadFileModule fileUploader,
		Program program, final DescribeGrid grid)
				throws CommandParseException {
	String name = grid.getText("Name");
	if (name == null || "".equals(name)) {
		Window.alert("Name could not be empty!");
		return false;
	}
	String category = grid.getText("Category");
	if(category == null || "".equals(category) || category.equals("Choose Category")){
		Window.alert("Category could not be empty!");
		return false;
	}
	String cmdline = grid.getText("CommandLine");
	if (cmdline == null || "".equals(cmdline)) {
		Window.alert("CommandLine could not be empty!");
		return false;
	} else {
		String programable = grid.getText("Programable");
		if( !Constants.studioUIMsg.yes().equals( programable ) )
			CommandParser.parse(cmdline);
	}
	logger.info("grid"+grid.ProgramToString());
	programBinder.sync(grid, program);
	fileUploader.setUpLoadProgram(program);
	logger.info("programm"+grid.asProgram(program).toString());
	programSrv.upload(grid.asProgram(program), fileUploader.getNewFileUUID(),
			new AsyncCallback<Program>() {
		@Override
		public void onFailure(Throwable caught) {
			logger.info(caught.getMessage());
		}

		@Override
		public void onSuccess(Program result) {
			fileUploader.setUpLoadProgram(result);
			ProgramLeaf node = new ProgramLeaf(result);
			ProgramTreeLoader.addContextMenu( view.getProgramTree(),
					node);
			ProgramTreeLoader.addProgramLeaf( view.getProgramTree(),
					node,AppController.email);
			logger.info("Program insert to DB:"+result.getCategory());
		}
	});
	return true;
}
 
Example 20
Source File: Tomato.java    From gwt-boot-samples with Apache License 2.0 4 votes vote down vote up
public void click() {
	Window.alert("Hello, I'm GWT JsInterop!\nThanks for clicking: " + name);
}