blob: 5cdb842d01428cbd2c04a694c2182a8b6294f166 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 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.util;
import java.util.Iterator;
import org.eclipse.epf.uma.MethodElement;
import org.eclipse.epf.uma.MethodElementProperty;
import org.eclipse.epf.uma.UmaFactory;
/**
* @author Phong Nguyen Le
*
* @since 1.2
*/
public class MethodElementPropertyHelper {
public static final String WORK_ORDER__PREDECESSOR_PROCESS_PATH = "pred_process_path"; //$NON-NLS-1$
public static final String CONFIG_PROPBLEM_HIDE_ERRORS = "hide_errors"; //$NON-NLS-1$
public static final String CONFIG_PROPBLEM_HIDE_WARNINGS = "hide_warnings"; //$NON-NLS-1$
public static final String CONFIG_PROPBLEM_HIDE_INFOS = "hide_infos"; //$NON-NLS-1$
public static final String CUSTOM_CATEGORY__INCLUDED_ELEMENTS = "include"; //$NON-NLS-1$
public static final MethodElementProperty getProperty(MethodElement e, String propertyName) {
if (e != null) {
for (Iterator iter = e.getMethodElementProperty().iterator(); iter.hasNext();) {
MethodElementProperty prop = (MethodElementProperty) iter.next();
if(prop.getName().equals(propertyName)) {
return prop;
}
}
}
return null;
}
public static final void setProperty(MethodElement e, String propName, String propValue) {
MethodElementProperty prop = getProperty(e, propName);
if (prop == null) {
prop = UmaFactory.eINSTANCE.createMethodElementProperty();
prop.setName(propName);
e.getMethodElementProperty().add(prop);
}
if (propValue != null && propValue.equals(prop.getValue())) return;
if (propValue == null && prop.getValue() == null) return;
prop.setValue(propValue);
}
public static final void setProperty(MethodElement e, String propName, boolean b) {
setProperty(e, propName, String.valueOf(b));
}
public static final void removeProperty(MethodElement e, String propName) {
MethodElementProperty property = getProperty(e, propName);
if (property != null) {
e.getMethodElementProperty().remove(property);
}
}
}