blob: 76f5803d45b0e44edaaa8e251a5cc18dc0db7aec [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.library.edit.validation.internal;
import java.io.File;
import org.eclipse.epf.library.edit.util.TngUtil;
import org.eclipse.epf.library.edit.validation.AbstractStringValidator;
import org.eclipse.epf.library.edit.validation.IValidator;
import org.eclipse.epf.services.IFileBasedLibraryPersister;
import org.eclipse.epf.services.Services;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodLibrary;
/**
* Name validator for MethodConfiguration.
*
* @author Phong Nguyen Le - May 12, 2006
* @since 1.0
*/
public class MethodConfigurationNameValidator extends AbstractStringValidator {
private MethodLibrary library;
private MethodConfiguration config;
public MethodConfigurationNameValidator(MethodLibrary lib, MethodConfiguration config) {
library = lib;
this.config = config;
}
/* (non-Javadoc)
* @see org.eclipse.epf.library.edit.validation.IValidator#isValid(java.lang.String)
*/
public String isValid(String newText) {
String configFolder = ((IFileBasedLibraryPersister)Services.getLibraryPersister(Services.XMI_PERSISTENCE_TYPE))
.getFolderRelativePath(config);
File dir = new File(new File(library.eResource().getURI().toFileString())
.getParent(), configFolder);
return TngUtil.checkName(dir, library.getPredefinedConfigurations(), config,
newText, TngUtil.getTypeText(config), false);
}
}