org.glassmaker.eclipse/org.glassmaker.ui.editor/src/main/java/org/glassmaker/ui/editor/wizards/NewCardFileWizardPage.java
protected boolean validatePage() {
		setMessage(null);
		setErrorMessage(null);

		if (!super.validatePage()) {
			return false;
		}

		String fileName = getFileName();
		IPath fullPath = getContainerFullPath();
		if ((fullPath != null) && (fullPath.isEmpty() == false) && (fileName != null)) {
			// check that filename does not contain invalid extension
			if (!extensionValidForContentType(fileName)) {
				setErrorMessage("Filename must end with .card");
				return false;
			}
			// no file extension specified so check adding default
			// extension doesn't equal a file that already exists
			if (fileName.lastIndexOf('.') == -1) {
				String newFileName = addDefaultExtension(fileName);
				IPath resourcePath = fullPath.append(newFileName);

				IWorkspace workspace = ResourcesPlugin.getWorkspace();
				IStatus result = workspace.validatePath(resourcePath.toString(), IResource.FOLDER);
				if (!result.isOK()) {
					// path invalid
					setErrorMessage(result.getMessage());
					return false;
				}

				if ((workspace.getRoot().getFolder(resourcePath).exists() || workspace.getRoot().getFile(resourcePath).exists())) {
					setErrorMessage("There is a card with that name");
					return false;
				}
			}

			// get the IProject for the selection path
			IProject project = getProjectFromPath(fullPath);
			// if inside web project, check if inside webContent folder
			if (project != null && isWebProject(project)) {
				// check that the path is inside the webContent folder
				IPath[] webContentPaths = ProjectUtils.getAcceptableRootPaths(project);
				boolean isPrefix = false;
				for (int i = 0; !isPrefix && i < webContentPaths.length; i++) {
					isPrefix |= webContentPaths[i].isPrefixOf(fullPath);
				}
				if (!isPrefix) {
					setMessage("Cards must be inside the web contents", WARNING);
				}
			}
		}

		return true;
	}
protected boolean validatePage() {
		setMessage(null);
		setErrorMessage(null);

		if (!super.validatePage()) {
			return false;
		}

		String fileName = getFileName();
		IPath fullPath = getContainerFullPath();
		if ((fullPath != null) && (fullPath.isEmpty() == false) && (fileName != null)) {
			// check that filename does not contain invalid extension
			if (!extensionValidForContentType(fileName)) {
				setErrorMessage("Filename must end with .card");
				return false;
			}
			// no file extension specified so check adding default
			// extension doesn't equal a file that already exists
			if (fileName.lastIndexOf('.') == -1) {
				String newFileName = addDefaultExtension(fileName);
				IPath resourcePath = fullPath.append(newFileName);

				IWorkspace workspace = ResourcesPlugin.getWorkspace();
				IStatus result = workspace.validatePath(resourcePath.toString(), IResource.FOLDER);
				if (!result.isOK()) {
					// path invalid
					setErrorMessage(result.getMessage());
					return false;
				}

				if ((workspace.getRoot().getFolder(resourcePath).exists() || workspace.getRoot().getFile(resourcePath).exists())) {
					setErrorMessage("There is a card with that name");
					return false;
				}
			}

			// get the IProject for the selection path
			IProject project = getProjectFromPath(fullPath);
			// if inside web project, check if inside webContent folder
			if (project != null && isWebProject(project)) {
				// check that the path is inside the webContent folder
				IPath[] webContentPaths = ProjectUtils.getAcceptableRootPaths(project);
				boolean isPrefix = false;
				for (int i = 0; !isPrefix && i < webContentPaths.length; i++) {
					isPrefix |= webContentPaths[i].isPrefixOf(fullPath);
				}
				if (!isPrefix) {
					setMessage("Cards must be inside the web contents", WARNING);
				}
			}
		}

		return true;
	}
protected boolean validatePage ( ) { setMessage ( null ) ; setErrorMessage ( null ) ; if ( ! super . validatePage ( ) ) { return false ; } String fileName = getFileName ( ) ; IPath fullPath = getContainerFullPath ( ) ; if ( ( fullPath != null ) && ( fullPath . isEmpty ( ) == false ) && ( fileName != null ) ) { // check that filename does not contain invalid extension if ( ! extensionValidForContentType ( fileName ) ) { setErrorMessage ( "Filename must end with .card" ) ; return false ; } // no file extension specified so check adding default // extension doesn't equal a file that already exists if ( fileName . lastIndexOf ( ' ' ) == - 1 ) { String newFileName = addDefaultExtension ( fileName ) ; IPath resourcePath = fullPath . append ( newFileName ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; IStatus result = workspace . validatePath ( resourcePath . toString ( ) , IResource . FOLDER ) ; if ( ! result . isOK ( ) ) { // path invalid setErrorMessage ( result . getMessage ( ) ) ; return false ; } if ( ( workspace . getRoot ( ) . getFolder ( resourcePath ) . exists ( ) || workspace . getRoot ( ) . getFile ( resourcePath ) . exists ( ) ) ) { setErrorMessage ( "There is a card with that name" ) ; return false ; } } // get the IProject for the selection path IProject project = getProjectFromPath ( fullPath ) ; // if inside web project, check if inside webContent folder if ( project != null && isWebProject ( project ) ) { // check that the path is inside the webContent folder IPath [ ] webContentPaths = ProjectUtils . getAcceptableRootPaths ( project ) ; boolean isPrefix = false ; for ( int i = 0 ; ! isPrefix && i < webContentPaths . length ; i ++ ) { isPrefix |= webContentPaths [ i ] . isPrefixOf ( fullPath ) ; } if ( ! isPrefix ) { setMessage ( "Cards must be inside the web contents" , WARNING ) ; } } } return true ; }
This method is overridden to set additional validation specific to html
files.
This method is overridden to set additional validation specific to html files .