diff options
-rw-r--r-- | org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java b/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java index 06107443e..f1cc7b488 100644 --- a/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java +++ b/org.tizen.common/src/org/tizen/common/ui/page/properties/PackageConfigUtil.java @@ -28,11 +28,13 @@ package org.tizen.common.ui.page.properties; import java.util.List; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.tizen.common.core.application.PackageResourceInfo; import org.tizen.common.core.application.TizenPackageInfoStore; +import org.tizen.common.util.FilenameUtil; /** * This class is utilities for {@link PackageConfiguration}. @@ -95,18 +97,14 @@ public class PackageConfigUtil { if ( parentSegments.length > childSegments.length ) { return false; - } - else if ( parentSegments.length == childSegments.length ) { + } else if ( parentSegments.length == childSegments.length ) { if ( !child.isSupportedType(parent.getType()) ) { return false; } - } - else { - if ( parent.getType() != IResource.FOLDER ) { + } else if ( parent.getType() != IResource.FOLDER ) { return false; - } } - + for ( int i = 0 ; i < childSegments.length ; i++ ) { if ( i >= parentSegments.length ) { break; @@ -116,7 +114,7 @@ public class PackageConfigUtil { return false; } } - + return true; } @@ -124,33 +122,44 @@ public class PackageConfigUtil { * Checks whether the given {@code child} contains the given {@code parent}. */ public static boolean contains(PackageResourceInfo parent, IResource child) { - String[] childSegments = child.getFullPath().segments(); - String[] parentSegments = new Path(child.getProject().getName() + "/" + parent.getName()).segments(); - - if ( parentSegments.length > childSegments.length ) { - return false; - } - else if ( parentSegments.length == childSegments.length ) { - if ( !parent.isSupportedType(child.getType()) ) { + return contains(parent, child.getFullPath().toString(), child.getType(), child.getProject()); + } + + /** + * Checks whether the given {@code child} contains the given {@code parent}. + */ + public static boolean contains(PackageResourceInfo parent, String childResourcePath, int childResourceType, IProject project) { + switch(parent.getElementType()) { + case PackageResourceInfo.REGEX: + if (childResourcePath.matches(parent.getName())) { + return true; + } else { return false; } - } - else { - if ( !parent.isSupportedType(IResource.FOLDER) ) { + default: + String[] childSegments = FilenameUtil.getCanonicalFragments(childResourcePath); + String[] parentSegments = new Path(project.getName() + "/" + parent.getName()).segments(); + + if ( parentSegments.length > childSegments.length ) { return false; - } - } - - for ( int i = 0 ; i < childSegments.length ; i++ ) { - if ( i >= parentSegments.length ) { - break; - } - - if ( !parentSegments[i].equals(childSegments[i]) ) { + } else if ( parentSegments.length == childSegments.length ) { + if ( !parent.isSupportedType(childResourceType) ) { + return false; + } + } else if ( !parent.isSupportedType(IResource.FOLDER) ) { return false; } + + for ( int i = 0 ; i < childSegments.length ; i++ ) { + if ( i >= parentSegments.length ) { + break; + } + + if ( !parentSegments[i].equals(childSegments[i]) ) { + return false; + } + } + return true; } - - return true; } } |