diff options
30 files changed, 246 insertions, 143 deletions
diff --git a/builders/.classpath b/builders/.classpath new file mode 100644 index 0000000..fb50116 --- /dev/null +++ b/builders/.classpath @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/builders/.gitignore b/builders/.gitignore new file mode 100644 index 0000000..c5e82d7 --- /dev/null +++ b/builders/.gitignore @@ -0,0 +1 @@ +bin
\ No newline at end of file diff --git a/builders/.project b/builders/.project new file mode 100644 index 0000000..713c9a2 --- /dev/null +++ b/builders/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>builders</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/builders/Android.mk b/builders/Android.mk new file mode 100644 index 0000000..7e69334 --- /dev/null +++ b/builders/Android.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +BUILDERS_LOCAL_DIR := $(call my-dir) +include $(BUILDERS_LOCAL_DIR)/src/Android.mk diff --git a/builders/src/Android.mk b/builders/src/Android.mk new file mode 100644 index 0000000..aaa6864 --- /dev/null +++ b/builders/src/Android.mk @@ -0,0 +1,24 @@ +# +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_JAVA_LIBRARIES := \ + +LOCAL_MODULE := builders + +include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/FileWrapper.java b/builders/src/com/android/builders/FileWrapper.java index 9de5290..a564cae 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/FileWrapper.java +++ b/builders/src/com/android/builders/FileWrapper.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.eclipse.org/org/documents/epl-v10.php + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.resources.manager.files; +package com.android.builders; -import org.eclipse.core.resources.IFile; import java.io.File; import java.io.FileInputStream; @@ -29,33 +28,27 @@ import java.io.InputStream; * */ public class FileWrapper implements IAbstractFile { - - private File mFile; + + private final File mFile; /** * Constructs a {@link FileWrapper} object. If {@link File#isFile()} returns <code>false</code> - * then an {@link IOException} is thrown. + * then an {@link IOException} is thrown. */ public FileWrapper(File file) throws IOException { if (file.isFile() == false) { throw new IOException("FileWrapper must wrap a File object representing an existing file!"); //$NON-NLS-1$ } - + mFile = file; } - public InputStream getContents() { + public InputStream getContents() throws StreamException { try { return new FileInputStream(mFile); } catch (FileNotFoundException e) { - // we'll return null below. + throw new StreamException(e); } - - return null; - } - - public IFile getIFile() { - return null; } public String getOsLocation() { @@ -65,20 +58,20 @@ public class FileWrapper implements IAbstractFile { public String getName() { return mFile.getName(); } - + @Override public boolean equals(Object obj) { if (obj instanceof FileWrapper) { return mFile.equals(((FileWrapper)obj).mFile); } - + if (obj instanceof File) { return mFile.equals(obj); } return super.equals(obj); } - + @Override public int hashCode() { return mFile.hashCode(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/FolderWrapper.java b/builders/src/com/android/builders/FolderWrapper.java index 1e96164..6d092c7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/FolderWrapper.java +++ b/builders/src/com/android/builders/FolderWrapper.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.eclipse.org/org/documents/epl-v10.php + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.resources.manager.files; +package com.android.builders; -import org.eclipse.core.resources.IFolder; import java.io.File; import java.io.IOException; @@ -26,20 +25,20 @@ import java.io.IOException; */ public class FolderWrapper implements IAbstractFolder { - private File mFolder; + private final File mFolder; /** * Constructs a {@link FileWrapper} object. If {@link File#isDirectory()} returns - * <code>false</code> then an {@link IOException} is thrown. + * <code>false</code> then an {@link IOException} is thrown. */ public FolderWrapper(File folder) throws IOException { if (folder.isDirectory() == false) { throw new IOException("FileWrapper must wrap a File object representing an existing folder!"); //$NON-NLS-1$ } - + mFolder = folder; } - + public boolean hasFile(String name) { return false; } @@ -48,23 +47,19 @@ public class FolderWrapper implements IAbstractFolder { return mFolder.getName(); } - public IFolder getIFolder() { - return null; - } - @Override public boolean equals(Object obj) { if (obj instanceof FolderWrapper) { return mFolder.equals(((FolderWrapper)obj).mFolder); } - + if (obj instanceof File) { return mFolder.equals(obj); } return super.equals(obj); } - + @Override public int hashCode() { return mFolder.hashCode(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractFile.java b/builders/src/com/android/builders/IAbstractFile.java index db1de5a..008d4b1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractFile.java +++ b/builders/src/com/android/builders/IAbstractFile.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.eclipse.org/org/documents/epl-v10.php + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.resources.manager.files; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; +package com.android.builders; import java.io.InputStream; @@ -30,15 +27,10 @@ public interface IAbstractFile extends IAbstractResource { * Returns an {@link InputStream} object on the file content. * @throws CoreException */ - InputStream getContents() throws CoreException; + InputStream getContents() throws StreamException; /** * Returns the OS path of the file location. */ String getOsLocation(); - - /** - * Returns the {@link IFile} object that the receiver could represent. Can be <code>null</code> - */ - IFile getIFile(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractFolder.java b/builders/src/com/android/builders/IAbstractFolder.java index 8557ae2..92407ae 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractFolder.java +++ b/builders/src/com/android/builders/IAbstractFolder.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.eclipse.org/org/documents/epl-v10.php + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.resources.manager.files; +package com.android.builders; -import org.eclipse.core.resources.IFolder; /** * A folder. @@ -24,15 +23,9 @@ import org.eclipse.core.resources.IFolder; public interface IAbstractFolder extends IAbstractResource { /** - * Returns true if the receiver contains a file with a given name + * Returns true if the receiver contains a file with a given name * @param name the name of the file. This is the name without the path leading to the * parent folder. */ boolean hasFile(String name); - - /** - * Returns the {@link IFolder} object that the receiver could represent. - * Can be <code>null</code> - */ - IFolder getIFolder(); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractResource.java b/builders/src/com/android/builders/IAbstractResource.java index 76f338a..e573f84 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IAbstractResource.java +++ b/builders/src/com/android/builders/IAbstractResource.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.eclipse.org/org/documents/epl-v10.php + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,16 +14,12 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.resources.manager.files; - -import org.eclipse.core.resources.IFile; - -import java.io.File; +package com.android.builders; /** * Base representation of a file system resource.<p/> * This somewhat limited interface is designed to let classes use file-system resources, without - * having the manually handle {@link IFile} and/or {@link File} manually. + * having the manually handle either the standard Java file or the Eclipse file API.. */ public interface IAbstractResource { diff --git a/builders/src/com/android/builders/StreamException.java b/builders/src/com/android/builders/StreamException.java new file mode 100644 index 0000000..4db2df3 --- /dev/null +++ b/builders/src/com/android/builders/StreamException.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.builders; + +/** + * Exception thrown when {@link IAbstractFile#getContents()} fails. + */ +public class StreamException extends Exception { + private static final long serialVersionUID = 1L; + + public StreamException(Exception e) { + super(e); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath index 2fd96a4..91dbcbb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath @@ -14,5 +14,6 @@ <classpathentry kind="lib" path="sdkuilib.jar" sourcepath="/SdkUiLib"/> <classpathentry kind="lib" path="commons-compress-1.0.jar"/> <classpathentry kind="lib" path="groovy-all-1.7.0.jar" sourcepath="/GroovySrc/groovy-src-1.7.0.zip"/> + <classpathentry kind="lib" path="builders.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF index e508125..dc22511 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Bundle-ClassPath: ., sdkuilib.jar, commons-compress-1.0.jar, groovy-all-1.7.0.jar + builders.jar Bundle-Activator: com.android.ide.eclipse.adt.AdtPlugin Bundle-Vendor: The Android Open Source Project Require-Bundle: com.android.ide.eclipse.ddms, @@ -48,7 +49,8 @@ Require-Bundle: com.android.ide.eclipse.ddms, org.eclipse.ltk.ui.refactoring, org.eclipse.core.expressions Eclipse-LazyStart: true -Export-Package: com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.tests", +Export-Package: com.android.builders;x-friends:="com.android.ide.eclipse.tests", + com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.tests", com.android.ide.eclipse.adt.internal;x-friends:="com.android.ide.eclipse.tests", com.android.ide.eclipse.adt.internal.actions;x-friends:="com.android.ide.eclipse.tests", com.android.ide.eclipse.adt.internal.build;x-friends:="com.android.ide.eclipse.tests", diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties index 47f6611..ed2a914 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties +++ b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties @@ -15,6 +15,7 @@ bin.includes = plugin.xml,\ sdkuilib.jar,\ commons-compress-1.0.jar,\ groovy-all-1.7.0.jar,\ - gscripts/ + gscripts/,\ + builders.jar source.. = src/ output.. = bin/ diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle1/GraphicalLayoutEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle1/GraphicalLayoutEditor.java index edb5f87..5a1f0e6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle1/GraphicalLayoutEditor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle1/GraphicalLayoutEditor.java @@ -46,6 +46,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFile; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolderType; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; +import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; import com.android.ide.eclipse.adt.internal.sdk.LoadStatus; import com.android.ide.eclipse.adt.internal.sdk.Sdk; @@ -823,15 +824,16 @@ public class GraphicalLayoutEditor extends GraphicalEditorWithPalette } if (match != null) { - if (match.getFile().equals(mEditedFile) == false) { + // since this is coming from Eclipse, this is always an instance of IFileWrapper + IFileWrapper iFileWrapper = (IFileWrapper) match.getFile(); + IFile iFile = iFileWrapper.getIFile(); + if (iFile.equals(mEditedFile) == false) { try { // tell the editor that the next replacement file is due to a config change. mLayoutEditor.setNewFileOnConfigChange(true); // ask the IDE to open the replacement file. - IDE.openEditor( - getSite().getWorkbenchWindow().getActivePage(), - match.getFile().getIFile()); + IDE.openEditor(getSite().getWorkbenchWindow().getActivePage(), iFile); // we're done! return; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java index ef6c59d..9d2ae69 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java @@ -38,6 +38,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFile; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolderType; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; +import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; import com.android.ide.eclipse.adt.internal.sdk.LoadStatus; import com.android.ide.eclipse.adt.internal.sdk.Sdk; @@ -366,16 +367,17 @@ public class GraphicalEditorPart extends EditorPart implements IGraphicalLayoutE } if (match != null) { - if (match.getFile().equals(mEditedFile) == false) { + // since this is coming from Eclipse, this is always an instance of IFileWrapper + IFileWrapper iFileWrapper = (IFileWrapper) match.getFile(); + IFile iFile = iFileWrapper.getIFile(); + if (iFile.equals(mEditedFile) == false) { try { // tell the editor that the next replacement file is due to a config // change. mLayoutEditor.setNewFileOnConfigChange(true); // ask the IDE to open the replacement file. - IDE.openEditor( - getSite().getWorkbenchWindow().getActivePage(), - match.getFile().getIFile()); + IDE.openEditor(getSite().getWorkbenchWindow().getActivePage(), iFile); // we're done! return; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/MultiResourceFile.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/MultiResourceFile.java index 2d2749d..3386e17 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/MultiResourceFile.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/MultiResourceFile.java @@ -16,14 +16,14 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.IAbstractFile; +import com.android.builders.StreamException; import com.android.ide.eclipse.adt.internal.resources.ResourceType; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile; import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.utils.ResourceValue; import com.android.layoutlib.utils.ValueResourceParser; import com.android.layoutlib.utils.ValueResourceParser.IValueResourceRepository; -import org.eclipse.core.runtime.CoreException; import org.xml.sax.SAXException; import java.io.IOException; @@ -125,7 +125,7 @@ public final class MultiResourceFile extends ResourceFile implements IValueResou } catch (ParserConfigurationException e) { } catch (SAXException e) { } catch (IOException e) { - } catch (CoreException e) { + } catch (StreamException e) { } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java index d2cc529..e91ebe5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ProjectResources.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.IAbstractFolder; import com.android.ide.eclipse.adt.internal.resources.IResourceRepository; import com.android.ide.eclipse.adt.internal.resources.ResourceItem; import com.android.ide.eclipse.adt.internal.resources.ResourceType; @@ -23,7 +24,7 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfi import com.android.ide.eclipse.adt.internal.resources.configurations.LanguageQualifier; import com.android.ide.eclipse.adt.internal.resources.configurations.RegionQualifier; import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFolder; +import com.android.ide.eclipse.adt.internal.resources.manager.files.IFolderWrapper; import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.utils.ResourceValue; @@ -136,7 +137,9 @@ public class ProjectResources implements IResourceRepository { int count = list.size(); for (int i = 0 ; i < count ; i++) { ResourceFolder resFolder = list.get(i); - if (resFolder.getFolder().getIFolder().equals(folder)) { + // this is only used for Eclipse stuff so we know it's an IFolderWrapper + IFolderWrapper wrapper = (IFolderWrapper) resFolder.getFolder(); + if (wrapper.getIFolder().equals(folder)) { // we found the matching ResourceFolder. we need to remove it. list.remove(i); @@ -294,7 +297,9 @@ public class ProjectResources implements IResourceRepository { public ResourceFolder getResourceFolder(IFolder folder) { for (List<ResourceFolder> list : mFolderMap.values()) { for (ResourceFolder resFolder : list) { - if (resFolder.getFolder().getIFolder().equals(folder)) { + // this is only used for Eclipse stuff so we know it's an IFolderWrapper + IFolderWrapper wrapper = (IFolderWrapper) resFolder.getFolder(); + if (wrapper.getIFolder().equals(folder)) { return resFolder; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFile.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFile.java index f7fb93f..75f002b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFile.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFile.java @@ -16,9 +16,9 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.IAbstractFile; import com.android.ide.eclipse.adt.internal.resources.ResourceType; import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile; import com.android.layoutlib.api.IResourceValue; import java.util.Collection; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java index 582e0a6..ae32300 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceFolder.java @@ -16,11 +16,12 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.IAbstractFile; +import com.android.builders.IAbstractFolder; import com.android.ide.eclipse.adt.internal.resources.ResourceItem; import com.android.ide.eclipse.adt.internal.resources.ResourceType; import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFolder; +import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -77,11 +78,14 @@ public final class ResourceFolder extends Resource { for (int i = 0 ; i < count ; i++) { ResourceFile resFile = mFiles.get(i); if (resFile != null) { - IFile iFile = resFile.getFile().getIFile(); - if (iFile != null && iFile.equals(file)) { - mFiles.remove(i); - touch(); - return resFile; + IAbstractFile abstractFile = resFile.getFile(); + if (abstractFile instanceof IFileWrapper) { + IFile iFile = ((IFileWrapper)resFile.getFile()).getIFile(); + if (iFile != null && iFile.equals(file)) { + mFiles.remove(i); + touch(); + return resFile; + } } } } @@ -177,9 +181,12 @@ public final class ResourceFolder extends Resource { public ResourceFile getFile(IFile file) { if (mFiles != null) { for (ResourceFile f : mFiles) { - IFile iFile = f.getFile().getIFile(); - if (iFile != null && iFile.equals(file)) { - return f; + IAbstractFile abstractFile = f.getFile(); + if (abstractFile instanceof IFileWrapper) { + IFile iFile = ((IFileWrapper)f.getFile()).getIFile(); + if (iFile != null && iFile.equals(file)) { + return f; + } } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java index 143b644..162e163 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/ResourceManager.java @@ -16,6 +16,10 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.FileWrapper; +import com.android.builders.FolderWrapper; +import com.android.builders.IAbstractFile; +import com.android.builders.IAbstractFolder; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; import com.android.ide.eclipse.adt.internal.resources.ResourceType; @@ -24,10 +28,6 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQua import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IFileListener; import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IFolderListener; import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IProjectListener; -import com.android.ide.eclipse.adt.internal.resources.manager.files.FileWrapper; -import com.android.ide.eclipse.adt.internal.resources.manager.files.FolderWrapper; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFolder; import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import com.android.ide.eclipse.adt.internal.resources.manager.files.IFolderWrapper; import com.android.sdklib.IAndroidTarget; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java index 8900500..8e688f6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java @@ -16,9 +16,9 @@ package com.android.ide.eclipse.adt.internal.resources.manager; +import com.android.builders.IAbstractFile; import com.android.ide.eclipse.adt.internal.resources.ResourceType; import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFile; import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.utils.DensityBasedResourceValue; import com.android.layoutlib.utils.ResourceValue; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFileWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFileWrapper.java index a85d36b..27084c0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFileWrapper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFileWrapper.java @@ -16,6 +16,9 @@ package com.android.ide.eclipse.adt.internal.resources.manager.files; +import com.android.builders.IAbstractFile; +import com.android.builders.StreamException; + import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; @@ -26,14 +29,18 @@ import java.io.InputStream; */ public class IFileWrapper implements IAbstractFile { - private IFile mFile; + private final IFile mFile; public IFileWrapper(IFile file) { mFile = file; } - - public InputStream getContents() throws CoreException { - return mFile.getContents(); + + public InputStream getContents() throws StreamException { + try { + return mFile.getContents(); + } catch (CoreException e) { + throw new StreamException(e); + } } public String getOsLocation() { @@ -44,23 +51,26 @@ public class IFileWrapper implements IAbstractFile { return mFile.getName(); } + /** + * Returns the {@link IFile} object that the receiver could represent. Can be <code>null</code> + */ public IFile getIFile() { return mFile; } - + @Override public boolean equals(Object obj) { if (obj instanceof IFileWrapper) { return mFile.equals(((IFileWrapper)obj).mFile); } - + if (obj instanceof IFile) { return mFile.equals(obj); } return super.equals(obj); } - + @Override public int hashCode() { return mFile.hashCode(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFolderWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFolderWrapper.java index a92fecd..4df4ccb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFolderWrapper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/files/IFolderWrapper.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.resources.manager.files; +import com.android.builders.IAbstractFolder; + import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -24,8 +26,8 @@ import org.eclipse.core.runtime.CoreException; * An implementation of {@link IAbstractFolder} on top of an {@link IFolder} object. */ public class IFolderWrapper implements IAbstractFolder { - - private IFolder mFolder; + + private final IFolder mFolder; public IFolderWrapper(IFolder folder) { mFolder = folder; @@ -49,24 +51,28 @@ public class IFolderWrapper implements IAbstractFolder { return false; } - + + /** + * Returns the {@link IFolder} object that the receiver could represent. + * Can be <code>null</code> + */ public IFolder getIFolder() { return mFolder; } - + @Override public boolean equals(Object obj) { if (obj instanceof IFolderWrapper) { return mFolder.equals(((IFolderWrapper)obj).mFolder); } - + if (obj instanceof IFolder) { return mFolder.equals(obj); } return super.equals(obj); } - + @Override public int hashCode() { return mFolder.hashCode(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceExplorerView.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceExplorerView.java index 5aaa847..77c67ef 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceExplorerView.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ResourceExplorerView.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.ui; +import com.android.builders.IAbstractFile; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidConstants; import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResourceItem; @@ -23,6 +24,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFile; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; import com.android.ide.eclipse.adt.internal.resources.manager.GlobalProjectMonitor.IResourceEventListener; +import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -65,12 +67,12 @@ import java.util.Iterator; * The view listener to change in selection in the workbench, and update to show the resource * of the project of the current selected item (either item in the package explorer, or of the * current editor). - * + * * @see ResourceContentProvider */ public class ResourceExplorerView extends ViewPart implements ISelectionListener, IResourceEventListener { - + // Note: keep using the obsolete AndroidConstants.EDITORS_NAMESPACE (which used // to be the Editors Plugin ID) to keep existing preferences functional. private final static String PREFS_COLUMN_RES = @@ -80,7 +82,7 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener private Tree mTree; private TreeViewer mTreeViewer; - + private IProject mCurrentProject; public ResourceExplorerView() { @@ -103,18 +105,18 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener // create the jface wrapper mTreeViewer = new TreeViewer(mTree); - + mTreeViewer.setContentProvider(new ResourceContentProvider(true /* fullLevels */)); mTreeViewer.setLabelProvider(new ResourceLabelProvider()); - + // listen to selection change in the workbench. IWorkbenchPage page = getSite().getPage(); - + page.addSelectionListener(this); - + // init with current selection selectionChanged(getSite().getPart(), page.getSelection()); - + // add support for double click. mTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { @@ -125,26 +127,32 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener if (selection.size() == 1) { Object element = selection.getFirstElement(); - + // if it's a resourceFile, we directly open it. if (element instanceof ResourceFile) { try { - IDE.openEditor(getSite().getWorkbenchWindow().getActivePage(), - ((ResourceFile)element).getFile().getIFile()); + IAbstractFile iAbstractFile = ((ResourceFile)element).getFile(); + if (iAbstractFile instanceof IFileWrapper) { + IDE.openEditor(getSite().getWorkbenchWindow().getActivePage(), + ((IFileWrapper)iAbstractFile).getIFile()); + } } catch (PartInitException e) { } } else if (element instanceof ProjectResourceItem) { // if it's a ResourceItem, we open the first file, but only if // there's no alternate files. ProjectResourceItem item = (ProjectResourceItem)element; - + if (item.isEditableDirectly()) { ResourceFile[] files = item.getSourceFileArray(); if (files[0] != null) { try { - IDE.openEditor( - getSite().getWorkbenchWindow().getActivePage(), - files[0].getFile().getIFile()); + IAbstractFile iAbstractFile = files[0].getFile(); + if (iAbstractFile instanceof IFileWrapper) { + IDE.openEditor( + getSite().getWorkbenchWindow().getActivePage(), + ((IFileWrapper)iAbstractFile).getIFile()); + } } catch (PartInitException e) { } } @@ -154,11 +162,11 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener } } }); - + // set up the resource manager to send us resource change notification AdtPlugin.getDefault().getResourceMonitor().addResourceEventListener(this); } - + @Override public void dispose() { AdtPlugin.getDefault().getResourceMonitor().removeResourceEventListener(this); @@ -179,14 +187,14 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener if (part instanceof IEditorPart) { // if it is, we check if it's a file editor. IEditorInput input = ((IEditorPart)part).getEditorInput(); - + if (input instanceof IFileEditorInput) { // from the file editor we can get the IFile object, and from it, the IProject. IFile file = ((IFileEditorInput)input).getFile(); - + // get the file project IProject project = file.getProject(); - + handleProjectSelection(project); } } else if (selection instanceof IStructuredSelection) { @@ -195,7 +203,7 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener it.hasNext();) { Object element = it.next(); IProject project = null; - + // if we are in the navigator or package explorer, the selection could contain a // IResource object. if (element instanceof IResource) { @@ -245,10 +253,10 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener } } catch (CoreException e) { } - + return false; } - + /** * Create a TreeColumn with the specified parameters. If a * <code>PreferenceStore</code> object and a preference entry name String @@ -270,7 +278,7 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener // create the column TreeColumn col = new TreeColumn(parent, style); - + if (fixedSize != -1) { col.setWidth(fixedSize); col.setResizable(false); @@ -281,7 +289,7 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener if (prefs == null || prefs.contains(pref_name) == false) { col.setText(sample_text); col.pack(); - + // init the prefs store with the current value if (prefs != null) { prefs.setValue(pref_name, col.getWidth()); @@ -289,18 +297,18 @@ public class ResourceExplorerView extends ViewPart implements ISelectionListener } else { col.setWidth(prefs.getInt(pref_name)); } - + // if there is a pref store and a pref entry name, then we setup a // listener to catch column resize to put the new width value into the store. if (prefs != null && pref_name != null) { col.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { } - + public void controlResized(ControlEvent e) { // get the new width int w = ((TreeColumn)e.widget).getWidth(); - + // store in pref store prefs.setValue(pref_name, w); } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath index 660adf3..17d578d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath @@ -11,5 +11,6 @@ <classpathentry kind="lib" path="layoutlib.jar"/> <classpathentry kind="lib" path="kxml2-2.3.0.jar"/> <classpathentry kind="lib" path="groovy-all-1.7.0.jar"/> + <classpathentry kind="lib" path="/adt/builders.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF index 21e4d1f..5af8623 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF @@ -17,7 +17,5 @@ Bundle-ActivationPolicy: lazy Bundle-Vendor: The Android Open Source Project Bundle-ClassPath: kxml2-2.3.0.jar, ., - layoutlib_api.jar, - sdklib.jar, layoutlib.jar, groovy-all-1.7.0.jar diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties index 9b92645..7be75ed 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties +++ b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties @@ -7,8 +7,6 @@ bin.includes = META-INF/,\ prefs.template,\ unittest.xml,\ kxml2-2.3.0.jar,\ - sdklib.jar,\ - layoutlib_api.jar,\ layoutlib.jar,\ unittests/com/android/sdklib/testdata/,\ unittests/com/android/layoutlib/testdata/,\ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java index c0533ed..e81e70e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.manager; +import com.android.builders.IAbstractFolder; import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration; import com.android.ide.eclipse.adt.internal.resources.configurations.ResourceQualifier; import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier.KeyboardState; @@ -29,7 +30,6 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolder; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolderType; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; import com.android.ide.eclipse.adt.internal.resources.manager.SingleResourceFile; -import com.android.ide.eclipse.adt.internal.resources.manager.files.IAbstractFolder; import com.android.ide.eclipse.adt.internal.resources.manager.files.IFileWrapper; import com.android.ide.eclipse.adt.internal.resources.manager.files.IFolderWrapper; import com.android.ide.eclipse.mock.FileMock; diff --git a/eclipse/scripts/create_adt_symlinks.sh b/eclipse/scripts/create_adt_symlinks.sh index 46d0d33..95f0325 100755 --- a/eclipse/scripts/create_adt_symlinks.sh +++ b/eclipse/scripts/create_adt_symlinks.sh @@ -14,7 +14,7 @@ DEST="sdk/eclipse/plugins/com.android.ide.eclipse.adt" # computes "../.." from DEST to here (in /android) BACK=`echo $DEST | sed 's@[^/]*@..@g'` -LIBS="sdkstats jarutils androidprefs layoutlib_api layoutlib_utils ninepatch sdklib sdkuilib" +LIBS="sdkstats jarutils androidprefs layoutlib_api layoutlib_utils ninepatch sdklib sdkuilib builders" echo "make java libs ..." make -j3 showcommands $LIBS || die "ADT: Fail to build one of $LIBS." |