import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
-import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.SdkConstants;
import org.eclipse.core.filesystem.EFS;
IPath workspacePath = workspace.getLocation();
IEditorSite editorSite = graphicalEditor.getEditorSite();
if (workspacePath.isPrefixOf(filePath)) {
- IPath relativePath = Sdk.makeRelativeTo(filePath, workspacePath);
+ IPath relativePath = filePath.makeRelativeTo(workspacePath);
IResource xmlFile = workspace.findMember(relativePath);
if (xmlFile != null) {
IFile leavingFile = graphicalEditor.getEditedFile();
"Please select a library project");
if (javaProject != null) {
IProject iProject = javaProject.getProject();
- IPath relativePath = Sdk.makeRelativeTo(
- iProject.getLocation(), mState.getProject().getLocation());
+ IPath relativePath = iProject.getLocation().makeRelativeTo(
+ mState.getProject().getLocation());
addItem(relativePath.toString(), iProject, -1);
resetEnabled();
/**
* Saves the state of the UI into the {@link ProjectProperties} object that was returned by
- * {@link #setContent(ProjectState)}.
+ * {@link #setContent}.
* <p/>This does not update the {@link ProjectState} object that was provided, nor does it save
* the new properties on disk. Saving the properties on disk, via
- * {@link ProjectProperties#save()}, and updating the {@link ProjectState} instance, via
- * {@link ProjectState#reloadProperties()} must be done by the caller.
+ * {@link ProjectPropertiesWorkingCopy#save()}, and updating the {@link ProjectState} instance,
+ * via {@link ProjectState#reloadProperties()} must be done by the caller.
* @return <code>true</code> if there was actually new data saved in the project state, false
* otherwise.
*/
synchronized (sLock) {
for (ProjectState projectState : sProjectStateMap.values()) {
if (projectState != renamedState && projectState.isMissingLibraries()) {
- IPath oldRelativePath = makeRelativeTo(from,
+ IPath oldRelativePath = from.makeRelativeTo(
projectState.getProject().getFullPath());
- IPath newRelativePath = makeRelativeTo(project.getFullPath(),
+ IPath newRelativePath = project.getFullPath().makeRelativeTo(
projectState.getProject().getFullPath());
// get the current libraries
// for this libraries, to update the project there were depending on.
updateProjectsWithNewLibraries(updatedLibraries);
}
-
- /**
- * Computes a new IPath targeting a given target, but relative to a given base.
- * <p/>{@link IPath#makeRelativeTo(IPath)} is only available in 3.5 and later.
- * <p/>This is based on the implementation {@link Path#makeRelativeTo(IPath)}.
- * @param target the target of the IPath
- * @param base the IPath to base the relative path on.
- * @return the relative IPath
- */
- public static IPath makeRelativeTo(IPath target, IPath base) {
- //can't make relative if devices are not equal
- if (target.getDevice() != base.getDevice() && (target.getDevice() == null ||
- !target.getDevice().equalsIgnoreCase(base.getDevice())))
- return target;
- int commonLength = target.matchingFirstSegments(base);
- final int differenceLength = base.segmentCount() - commonLength;
- final int newSegmentLength = differenceLength + target.segmentCount() - commonLength;
- if (newSegmentLength == 0)
- return Path.EMPTY;
- String[] newSegments = new String[newSegmentLength];
- //add parent references for each segment different from the base
- Arrays.fill(newSegments, 0, differenceLength, ".."); //$NON-NLS-1$
- //append the segments of this path not in common with the base
- System.arraycopy(target.segments(), commonLength, newSegments,
- differenceLength, newSegmentLength - differenceLength);
-
- StringBuilder sb = new StringBuilder();
- for (String s : newSegments) {
- sb.append(s).append('/');
- }
-
- return new Path(null, sb.toString());
- }
}