auto import from //branches/cupcake/...@137197
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := eng development tests
|
LOCAL_MODULE_TAGS := eng
|
||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
LOCAL_JAVA_LIBRARIES := android.test.runner
|
||||||
LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client
|
LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := user development
|
LOCAL_MODULE_TAGS := user
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := user
|
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := SdkSetup
|
LOCAL_PACKAGE_NAME := SdkSetup
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := eng development
|
LOCAL_MODULE_TAGS := eng
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||||
|
|
||||||
|
|||||||
@@ -57,10 +57,6 @@
|
|||||||
<string name="summary_end_button">Select End (red) button action</string>
|
<string name="summary_end_button">Select End (red) button action</string>
|
||||||
<string name="dialog_title_end_button">Select End button</string>
|
<string name="dialog_title_end_button">Select End button</string>
|
||||||
|
|
||||||
<string name="title_accelerometer">Display rotation</string>
|
|
||||||
<string name="summary_on_accelerometer">Display rotates from orientation</string>
|
|
||||||
<string name="summary_off_accelerometer">Display rotates from orientation</string>
|
|
||||||
|
|
||||||
<string name="applications_title">Applications</string>
|
<string name="applications_title">Applications</string>
|
||||||
|
|
||||||
<string name="title_maps_compass">Show compass in Maps</string>
|
<string name="title_maps_compass">Show compass in Maps</string>
|
||||||
|
|||||||
@@ -88,12 +88,6 @@
|
|||||||
android:entryValues="@array/entryvalues_end_button"
|
android:entryValues="@array/entryvalues_end_button"
|
||||||
android:dialogTitle="@string/dialog_title_end_button" />
|
android:dialogTitle="@string/dialog_title_end_button" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="accelerometer"
|
|
||||||
android:title="@string/title_accelerometer"
|
|
||||||
android:summaryOn="@string/summary_on_accelerometer"
|
|
||||||
android:summaryOff="@string/summary_off_accelerometer"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="haptic_feedback"
|
android:key="haptic_feedback"
|
||||||
android:title="@string/title_haptic_feedback"
|
android:title="@string/title_haptic_feedback"
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ public class SpareParts extends PreferenceActivity
|
|||||||
private static final String HAPTIC_FEEDBACK_PREF = "haptic_feedback";
|
private static final String HAPTIC_FEEDBACK_PREF = "haptic_feedback";
|
||||||
private static final String FONT_SIZE_PREF = "font_size";
|
private static final String FONT_SIZE_PREF = "font_size";
|
||||||
private static final String END_BUTTON_PREF = "end_button";
|
private static final String END_BUTTON_PREF = "end_button";
|
||||||
private static final String ACCELEROMETER_PREF = "accelerometer";
|
|
||||||
private static final String MAPS_COMPASS_PREF = "maps_compass";
|
private static final String MAPS_COMPASS_PREF = "maps_compass";
|
||||||
|
|
||||||
private final Configuration mCurConfig = new Configuration();
|
private final Configuration mCurConfig = new Configuration();
|
||||||
@@ -68,7 +67,6 @@ public class SpareParts extends PreferenceActivity
|
|||||||
private CheckBoxPreference mHapticFeedbackPref;
|
private CheckBoxPreference mHapticFeedbackPref;
|
||||||
private ListPreference mFontSizePref;
|
private ListPreference mFontSizePref;
|
||||||
private ListPreference mEndButtonPref;
|
private ListPreference mEndButtonPref;
|
||||||
private CheckBoxPreference mAccelerometerPref;
|
|
||||||
private CheckBoxPreference mShowMapsCompassPref;
|
private CheckBoxPreference mShowMapsCompassPref;
|
||||||
|
|
||||||
private IWindowManager mWindowManager;
|
private IWindowManager mWindowManager;
|
||||||
@@ -125,7 +123,6 @@ public class SpareParts extends PreferenceActivity
|
|||||||
mFontSizePref.setOnPreferenceChangeListener(this);
|
mFontSizePref.setOnPreferenceChangeListener(this);
|
||||||
mEndButtonPref = (ListPreference) prefSet.findPreference(END_BUTTON_PREF);
|
mEndButtonPref = (ListPreference) prefSet.findPreference(END_BUTTON_PREF);
|
||||||
mEndButtonPref.setOnPreferenceChangeListener(this);
|
mEndButtonPref.setOnPreferenceChangeListener(this);
|
||||||
mAccelerometerPref = (CheckBoxPreference) prefSet.findPreference(ACCELEROMETER_PREF);
|
|
||||||
mShowMapsCompassPref = (CheckBoxPreference) prefSet.findPreference(MAPS_COMPASS_PREF);
|
mShowMapsCompassPref = (CheckBoxPreference) prefSet.findPreference(MAPS_COMPASS_PREF);
|
||||||
|
|
||||||
mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
|
mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
|
||||||
@@ -149,9 +146,6 @@ public class SpareParts extends PreferenceActivity
|
|||||||
mHapticFeedbackPref.setChecked(Settings.System.getInt(
|
mHapticFeedbackPref.setChecked(Settings.System.getInt(
|
||||||
getContentResolver(),
|
getContentResolver(),
|
||||||
Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0);
|
Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0);
|
||||||
mAccelerometerPref.setChecked(Settings.System.getInt(
|
|
||||||
getContentResolver(),
|
|
||||||
Settings.System.ACCELEROMETER_ROTATION, 0) != 0);
|
|
||||||
Context c = createPackageContext("com.google.android.apps.maps", 0);
|
Context c = createPackageContext("com.google.android.apps.maps", 0);
|
||||||
mShowMapsCompassPref.setChecked(c.getSharedPreferences("extra-features", MODE_WORLD_READABLE)
|
mShowMapsCompassPref.setChecked(c.getSharedPreferences("extra-features", MODE_WORLD_READABLE)
|
||||||
.getBoolean("compass", false));
|
.getBoolean("compass", false));
|
||||||
@@ -243,11 +237,7 @@ public class SpareParts extends PreferenceActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||||
if (ACCELEROMETER_PREF.equals(key)) {
|
if (FANCY_IME_ANIMATIONS_PREF.equals(key)) {
|
||||||
Settings.System.putInt(getContentResolver(),
|
|
||||||
Settings.System.ACCELEROMETER_ROTATION,
|
|
||||||
mAccelerometerPref.isChecked() ? 1 : 0);
|
|
||||||
} else if (FANCY_IME_ANIMATIONS_PREF.equals(key)) {
|
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.FANCY_IME_ANIMATIONS,
|
Settings.System.FANCY_IME_ANIMATIONS,
|
||||||
mFancyImeAnimationsPref.isChecked() ? 1 : 0);
|
mFancyImeAnimationsPref.isChecked() ? 1 : 0);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := samples development
|
LOCAL_MODULE_TAGS := samples
|
||||||
|
|
||||||
# Only compile source java files in this apk.
|
# Only compile source java files in this apk.
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
|||||||
@@ -253,6 +253,8 @@ public class SoftKeyboard extends InputMethodService
|
|||||||
@Override public void onUpdateSelection(int oldSelStart, int oldSelEnd,
|
@Override public void onUpdateSelection(int oldSelStart, int oldSelEnd,
|
||||||
int newSelStart, int newSelEnd,
|
int newSelStart, int newSelEnd,
|
||||||
int candidatesStart, int candidatesEnd) {
|
int candidatesStart, int candidatesEnd) {
|
||||||
|
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd,
|
||||||
|
candidatesStart, candidatesEnd);
|
||||||
|
|
||||||
// If the current selection in the text view changes, we should
|
// If the current selection in the text view changes, we should
|
||||||
// clear whatever candidate text we have.
|
// clear whatever candidate text we have.
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ void PropertyServer::SetDefaultProperties(void)
|
|||||||
{ "ro.SECONDARY_SERVER_MEM", "4096" },
|
{ "ro.SECONDARY_SERVER_MEM", "4096" },
|
||||||
{ "ro.HIDDEN_APP_MEM", "8192" },
|
{ "ro.HIDDEN_APP_MEM", "8192" },
|
||||||
{ "ro.EMPTY_APP_MEM", "16384" },
|
{ "ro.EMPTY_APP_MEM", "16384" },
|
||||||
|
{ "ro.HOME_APP_ADJ", "4" },
|
||||||
|
{ "ro.HOME_APP_MEM", "4096" },
|
||||||
//{ "init.svc.adbd", "running" }, // causes ADB-JDWP
|
//{ "init.svc.adbd", "running" }, // causes ADB-JDWP
|
||||||
{ "init.svc.usbd", "running" },
|
{ "init.svc.usbd", "running" },
|
||||||
{ "init.svc.debuggerd", "running" },
|
{ "init.svc.debuggerd", "running" },
|
||||||
|
|||||||
@@ -478,6 +478,14 @@ class ImageEditorPanel extends JPanel {
|
|||||||
start = rect.x;
|
start = rect.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int start = -1;
|
||||||
|
for (Rectangle rect : patches) {
|
||||||
|
if (rect.x > start) {
|
||||||
|
horizontalPatchesSum += rect.width;
|
||||||
|
start = rect.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalPatchesSum = 0;
|
verticalPatchesSum = 0;
|
||||||
@@ -489,6 +497,14 @@ class ImageEditorPanel extends JPanel {
|
|||||||
start = rect.y;
|
start = rect.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int start = -1;
|
||||||
|
for (Rectangle rect : patches) {
|
||||||
|
if (rect.y > start) {
|
||||||
|
verticalPatchesSum += rect.height;
|
||||||
|
start = rect.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSize(size);
|
setSize(size);
|
||||||
@@ -528,8 +544,7 @@ class ImageEditorPanel extends JPanel {
|
|||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
if (patches.size() == 0 || horizontalPatches.size() == 0 ||
|
if (patches.size() == 0) {
|
||||||
verticalPatches.size() == 0) {
|
|
||||||
g.drawImage(image, 0, 0, scaledWidth, scaledHeight, null);
|
g.drawImage(image, 0, 0, scaledWidth, scaledHeight, null);
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
return;
|
return;
|
||||||
@@ -1028,7 +1043,15 @@ class ImageEditorPanel extends JPanel {
|
|||||||
horizontalPatches = getRectangles(left.first, top.second);
|
horizontalPatches = getRectangles(left.first, top.second);
|
||||||
verticalPatches = getRectangles(left.second, top.first);
|
verticalPatches = getRectangles(left.second, top.first);
|
||||||
} else {
|
} else {
|
||||||
horizontalPatches = verticalPatches = new ArrayList<Rectangle>(0);
|
if (top.first.size() > 0) {
|
||||||
|
horizontalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
verticalPatches = getVerticalRectangles(top.first);
|
||||||
|
} else if (left.first.size() > 0) {
|
||||||
|
horizontalPatches = getHorizontalRectangles(left.first);
|
||||||
|
verticalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
} else {
|
||||||
|
horizontalPatches = verticalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row = GraphicsUtilities.getPixels(image, 0, height - 1, width, 1, row);
|
row = GraphicsUtilities.getPixels(image, 0, height - 1, width, 1, row);
|
||||||
@@ -1041,6 +1064,28 @@ class ImageEditorPanel extends JPanel {
|
|||||||
verticalPadding = getPadding(left.first);
|
verticalPadding = getPadding(left.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Rectangle> getVerticalRectangles(List<Pair<Integer>> topPairs) {
|
||||||
|
List<Rectangle> rectangles = new ArrayList<Rectangle>();
|
||||||
|
for (Pair<Integer> top : topPairs) {
|
||||||
|
int x = top.first;
|
||||||
|
int width = top.second - top.first;
|
||||||
|
|
||||||
|
rectangles.add(new Rectangle(x, 1, width, image.getHeight() - 2));
|
||||||
|
}
|
||||||
|
return rectangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Rectangle> getHorizontalRectangles(List<Pair<Integer>> leftPairs) {
|
||||||
|
List<Rectangle> rectangles = new ArrayList<Rectangle>();
|
||||||
|
for (Pair<Integer> left : leftPairs) {
|
||||||
|
int y = left.first;
|
||||||
|
int height = left.second - left.first;
|
||||||
|
|
||||||
|
rectangles.add(new Rectangle(1, y, image.getWidth() - 2, height));
|
||||||
|
}
|
||||||
|
return rectangles;
|
||||||
|
}
|
||||||
|
|
||||||
private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
|
private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
|
||||||
if (pairs.size() == 0) {
|
if (pairs.size() == 0) {
|
||||||
return new Pair<Integer>(0, 0);
|
return new Pair<Integer>(0, 0);
|
||||||
@@ -1063,7 +1108,7 @@ class ImageEditorPanel extends JPanel {
|
|||||||
for (Pair<Integer> left : leftPairs) {
|
for (Pair<Integer> left : leftPairs) {
|
||||||
int y = left.first;
|
int y = left.first;
|
||||||
int height = left.second - left.first;
|
int height = left.second - left.first;
|
||||||
for (Pair<Integer> top: topPairs) {
|
for (Pair<Integer> top : topPairs) {
|
||||||
int x = top.first;
|
int x = top.first;
|
||||||
int width = top.second - top.first;
|
int width = top.second - top.first;
|
||||||
|
|
||||||
@@ -1108,6 +1153,7 @@ class ImageEditorPanel extends JPanel {
|
|||||||
startWithPatch[0] = true;
|
startWithPatch[0] = true;
|
||||||
fixed.clear();
|
fixed.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<List<Pair<Integer>>>(fixed, patches);
|
return new Pair<List<Pair<Integer>>>(fixed, patches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,25 +36,48 @@ class ImageTransferHandler extends TransferHandler {
|
|||||||
@Override
|
@Override
|
||||||
public boolean importData(JComponent component, Transferable transferable) {
|
public boolean importData(JComponent component, Transferable transferable) {
|
||||||
try {
|
try {
|
||||||
Object data = transferable.getTransferData(DataFlavor.javaFileListFlavor);
|
for (DataFlavor flavor : transferable.getTransferDataFlavors()) {
|
||||||
//noinspection unchecked
|
if (flavor.isFlavorJavaFileListType()) {
|
||||||
final File file = ((List<File>) data).get(0);
|
Object data = transferable.getTransferData(DataFlavor.javaFileListFlavor);
|
||||||
mainFrame.open(file).execute();
|
//noinspection unchecked
|
||||||
|
final File file = ((List<File>) data).get(0);
|
||||||
|
mainFrame.open(file).execute();
|
||||||
|
return true;
|
||||||
|
} else if (flavor.isFlavorTextType()) {
|
||||||
|
if (flavor.getRepresentationClass() == String.class) {
|
||||||
|
String mime = flavor.getMimeType();
|
||||||
|
DataFlavor flave = new DataFlavor(mime);
|
||||||
|
Object data = transferable.getTransferData(flave);
|
||||||
|
final String path = convertPath(data.toString());
|
||||||
|
mainFrame.open(new File(path)).execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (UnsupportedFlavorException e) {
|
} catch (UnsupportedFlavorException e) {
|
||||||
return false;
|
// Ignore
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String convertPath(String path) {
|
||||||
|
if (path.startsWith("file://")) path = path.substring("file://".length());
|
||||||
|
if (path.indexOf('\n') != -1) path = path.substring(0, path.indexOf('\n'));
|
||||||
|
if (path.indexOf('\r') != -1) path = path.substring(0, path.indexOf('\r'));
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canImport(JComponent component, DataFlavor[] dataFlavors) {
|
public boolean canImport(JComponent component, DataFlavor[] dataFlavors) {
|
||||||
for (DataFlavor flavor : dataFlavors) {
|
for (DataFlavor flavor : dataFlavors) {
|
||||||
if (flavor.isFlavorJavaFileListType()) {
|
if (flavor.isFlavorJavaFileListType() || flavor.isFlavorTextType()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ This Agreement is governed by the laws of the State of New York and the intellec
|
|||||||
<import plugin="org.eclipse.wst.sse.ui"/>
|
<import plugin="org.eclipse.wst.sse.ui"/>
|
||||||
<import plugin="org.eclipse.wst.xml.core"/>
|
<import plugin="org.eclipse.wst.xml.core"/>
|
||||||
<import plugin="org.eclipse.wst.xml.ui"/>
|
<import plugin="org.eclipse.wst.xml.ui"/>
|
||||||
|
<import plugin="org.eclipse.jdt.junit"/>
|
||||||
</requires>
|
</requires>
|
||||||
|
|
||||||
<plugin
|
<plugin
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<classpathentry kind="lib" path="layoutlib_api.jar"/>
|
<classpathentry kind="lib" path="layoutlib_api.jar"/>
|
||||||
<classpathentry kind="lib" path="layoutlib_utils.jar"/>
|
<classpathentry kind="lib" path="layoutlib_utils.jar"/>
|
||||||
<classpathentry kind="lib" path="ninepatch.jar"/>
|
<classpathentry kind="lib" path="ninepatch.jar"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
|
<classpathentry kind="lib" path="sdklib.jar" sourcepath="/SdkLib"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkUiLib"/>
|
<classpathentry kind="lib" path="sdkuilib.jar" sourcepath="/SdkUiLib"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ Require-Bundle: com.android.ide.eclipse.ddms,
|
|||||||
org.eclipse.wst.sse.core,
|
org.eclipse.wst.sse.core,
|
||||||
org.eclipse.wst.sse.ui,
|
org.eclipse.wst.sse.ui,
|
||||||
org.eclipse.wst.xml.core,
|
org.eclipse.wst.xml.core,
|
||||||
org.eclipse.wst.xml.ui
|
org.eclipse.wst.xml.ui,
|
||||||
|
org.eclipse.jdt.junit
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: com.android.ide.eclipse.adt,
|
Export-Package: com.android.ide.eclipse.adt,
|
||||||
com.android.ide.eclipse.adt.build;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.build;x-friends:="com.android.ide.eclipse.tests",
|
||||||
|
com.android.ide.eclipse.adt.launch;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.project;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.project;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.project.internal;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.project.internal;x-friends:="com.android.ide.eclipse.tests",
|
||||||
com.android.ide.eclipse.adt.sdk;x-friends:="com.android.ide.eclipse.tests",
|
com.android.ide.eclipse.adt.sdk;x-friends:="com.android.ide.eclipse.tests",
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.core.launchConfigurationTypes">
|
point="org.eclipse.debug.core.launchConfigurationTypes">
|
||||||
<launchConfigurationType
|
<launchConfigurationType
|
||||||
delegate="com.android.ide.eclipse.adt.debug.launching.LaunchConfigDelegate"
|
delegate="com.android.ide.eclipse.adt.launch.LaunchConfigDelegate"
|
||||||
delegateDescription="The Android Application Launcher supports running and debugging remote Android applications on devices or emulators."
|
delegateDescription="The Android Application Launcher supports running and debugging remote Android applications on devices or emulators."
|
||||||
delegateName="Android Launcher"
|
delegateName="Android Launcher"
|
||||||
id="com.android.ide.eclipse.adt.debug.LaunchConfigType"
|
id="com.android.ide.eclipse.adt.debug.LaunchConfigType"
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||||
<launchConfigurationTabGroup
|
<launchConfigurationTabGroup
|
||||||
class="com.android.ide.eclipse.adt.debug.ui.LaunchConfigTabGroup"
|
class="com.android.ide.eclipse.adt.launch.LaunchConfigTabGroup"
|
||||||
description="Android Application"
|
description="Android Application"
|
||||||
id="com.android.ide.eclipse.adt.debug.LaunchConfigTabGroup"
|
id="com.android.ide.eclipse.adt.debug.LaunchConfigTabGroup"
|
||||||
type="com.android.ide.eclipse.adt.debug.LaunchConfigType"/>
|
type="com.android.ide.eclipse.adt.debug.LaunchConfigType"/>
|
||||||
@@ -140,8 +140,8 @@
|
|||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.ui.launchShortcuts">
|
point="org.eclipse.debug.ui.launchShortcuts">
|
||||||
<shortcut
|
<shortcut
|
||||||
category="com.android.ide.eclipse.adt.debug.LaunchConfigType"
|
category="com.android.ide.eclipse.adt.launch.LaunchConfigType"
|
||||||
class="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut"
|
class="com.android.ide.eclipse.adt.launch.LaunchShortcut"
|
||||||
icon="icons/android.png"
|
icon="icons/android.png"
|
||||||
id="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut"
|
id="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut"
|
||||||
label="Android Application"
|
label="Android Application"
|
||||||
@@ -219,12 +219,6 @@
|
|||||||
name="projectNature"
|
name="projectNature"
|
||||||
value="com.android.ide.eclipse.adt.AndroidNature">
|
value="com.android.ide.eclipse.adt.AndroidNature">
|
||||||
</filter>
|
</filter>
|
||||||
<action
|
|
||||||
class="com.android.ide.eclipse.adt.project.CreateAidlImportAction"
|
|
||||||
enablesFor="1"
|
|
||||||
id="com.android.ide.eclipse.adt.project.CreateAidlImportAction"
|
|
||||||
label="Create Aidl preprocess file for Parcelable classes"
|
|
||||||
menubarPath="com.android.ide.eclipse.adt.AndroidTools/group1"/>
|
|
||||||
<action
|
<action
|
||||||
class="com.android.ide.eclipse.adt.project.NewXmlFileWizardAction"
|
class="com.android.ide.eclipse.adt.project.NewXmlFileWizardAction"
|
||||||
enablesFor="1"
|
enablesFor="1"
|
||||||
@@ -345,24 +339,24 @@
|
|||||||
name="Debug Android Application"
|
name="Debug Android Application"
|
||||||
description="Debug Android Application"
|
description="Debug Android Application"
|
||||||
categoryId="org.eclipse.debug.ui.category.run"
|
categoryId="org.eclipse.debug.ui.category.run"
|
||||||
id="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut.debug">
|
id="com.android.ide.eclipse.adt.launch.LaunchShortcut.debug">
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
name="Run Android Application"
|
name="Run Android Application"
|
||||||
description="Run Android Application"
|
description="Run Android Application"
|
||||||
categoryId="org.eclipse.debug.ui.category.run"
|
categoryId="org.eclipse.debug.ui.category.run"
|
||||||
id="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut.run">
|
id="com.android.ide.eclipse.adt.launch.LaunchShortcut.run">
|
||||||
</command>
|
</command>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
keySequence="M3+M2+A D"
|
keySequence="M3+M2+A D"
|
||||||
contextId="org.eclipse.ui.globalScope"
|
contextId="org.eclipse.ui.globalScope"
|
||||||
commandId="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut.debug"
|
commandId="com.android.ide.eclipse.adt.launch.LaunchShortcut.debug"
|
||||||
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
|
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
keySequence="M3+M2+A R"
|
keySequence="M3+M2+A R"
|
||||||
contextId="org.eclipse.ui.globalScope"
|
contextId="org.eclipse.ui.globalScope"
|
||||||
commandId="com.android.ide.eclipse.adt.debug.launching.LaunchShortcut.run"
|
commandId="com.android.ide.eclipse.adt.launch.LaunchShortcut.run"
|
||||||
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
|
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
</extension>
|
</extension>
|
||||||
@@ -499,4 +493,15 @@
|
|||||||
</action>
|
</action>
|
||||||
</actionSet>
|
</actionSet>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.debug.core.launchDelegates">
|
||||||
|
<launchDelegate
|
||||||
|
delegate="com.android.ide.eclipse.adt.launch.JUnitLaunchConfigDelegate"
|
||||||
|
delegateDescription="Removes the Android JAR from the Bootstrap Classpath"
|
||||||
|
id="com.android.ide.eclipse.adt.launch.JUnitLaunchConfigDelegate.launchAndroidJunit"
|
||||||
|
modes="run,debug"
|
||||||
|
name="Android JUnit"
|
||||||
|
type="org.eclipse.jdt.junit.launchconfig">
|
||||||
|
</launchDelegate>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.android.ddmuilib.StackTracePanel;
|
|||||||
import com.android.ddmuilib.StackTracePanel.ISourceRevealer;
|
import com.android.ddmuilib.StackTracePanel.ISourceRevealer;
|
||||||
import com.android.ddmuilib.console.DdmConsole;
|
import com.android.ddmuilib.console.DdmConsole;
|
||||||
import com.android.ddmuilib.console.IDdmConsole;
|
import com.android.ddmuilib.console.IDdmConsole;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.AndroidLaunchController;
|
import com.android.ide.eclipse.adt.launch.AndroidLaunchController;
|
||||||
import com.android.ide.eclipse.adt.preferences.BuildPreferencePage;
|
import com.android.ide.eclipse.adt.preferences.BuildPreferencePage;
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||||
import com.android.ide.eclipse.adt.project.export.ExportWizard;
|
import com.android.ide.eclipse.adt.project.export.ExportWizard;
|
||||||
|
|||||||
@@ -20,15 +20,14 @@ import com.android.ide.eclipse.adt.AdtConstants;
|
|||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||||
import com.android.ide.eclipse.adt.sdk.LoadStatus;
|
import com.android.ide.eclipse.adt.sdk.LoadStatus;
|
||||||
import com.android.ide.eclipse.adt.sdk.Sdk;
|
|
||||||
import com.android.ide.eclipse.common.AndroidConstants;
|
import com.android.ide.eclipse.common.AndroidConstants;
|
||||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||||
import com.android.ide.eclipse.common.project.XmlErrorHandler;
|
import com.android.ide.eclipse.common.project.XmlErrorHandler;
|
||||||
import com.android.ide.eclipse.common.project.XmlErrorHandler.XmlErrorListener;
|
import com.android.ide.eclipse.common.project.XmlErrorHandler.XmlErrorListener;
|
||||||
import com.android.sdklib.IAndroidTarget;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
@@ -37,8 +36,10 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
|
|||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.jdt.core.IClasspathEntry;
|
import org.eclipse.jdt.core.IClasspathEntry;
|
||||||
import org.eclipse.jdt.core.IJavaProject;
|
import org.eclipse.jdt.core.IJavaProject;
|
||||||
import org.eclipse.jdt.core.JavaCore;
|
import org.eclipse.jdt.core.JavaCore;
|
||||||
@@ -892,25 +893,19 @@ abstract class BaseBuilder extends IncrementalProjectBuilder {
|
|||||||
stopBuild("SDK is not loaded yet");
|
stopBuild("SDK is not loaded yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the compiler compliance level.
|
// abort if there are TARGET or ADT type markers
|
||||||
if (ProjectHelper.checkCompilerCompliance(project) !=
|
IMarker[] markers = project.findMarkers(AdtConstants.MARKER_TARGET,
|
||||||
ProjectHelper.COMPILER_COMPLIANCE_OK) {
|
false /*includeSubtypes*/, IResource.DEPTH_ZERO);
|
||||||
// we exit silently
|
|
||||||
stopBuild(Messages.Compiler_Compliance_Error);
|
if (markers.length > 0) {
|
||||||
|
stopBuild("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the SDK directory has been setup.
|
markers = project.findMarkers(AdtConstants.MARKER_ADT, false /*includeSubtypes*/,
|
||||||
String osSdkFolder = AdtPlugin.getOsSdkFolder();
|
IResource.DEPTH_ZERO);
|
||||||
|
|
||||||
if (osSdkFolder == null || osSdkFolder.length() == 0) {
|
if (markers.length > 0) {
|
||||||
stopBuild(Messages.No_SDK_Setup_Error);
|
stopBuild("");
|
||||||
}
|
|
||||||
|
|
||||||
IAndroidTarget projectTarget = Sdk.getCurrent().getTarget(project);
|
|
||||||
if (projectTarget == null) {
|
|
||||||
// no target. error has been output by the container initializer:
|
|
||||||
// exit silently.
|
|
||||||
stopBuild("Project has no target");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,4 +921,21 @@ abstract class BaseBuilder extends IncrementalProjectBuilder {
|
|||||||
String.format(error, args)));
|
String.format(error, args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively delete all the derived resources.
|
||||||
|
*/
|
||||||
|
protected void removeDerivedResources(IResource resource, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
|
if (resource.exists()) {
|
||||||
|
if (resource.isDerived()) {
|
||||||
|
resource.delete(true, new SubProgressMonitor(monitor, 10));
|
||||||
|
} else if (resource.getType() == IResource.FOLDER) {
|
||||||
|
IFolder folder = (IFolder)resource;
|
||||||
|
IResource[] members = folder.members();
|
||||||
|
for (IResource member : members) {
|
||||||
|
removeDerivedResources(member, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ package com.android.ide.eclipse.adt.build;
|
|||||||
import com.android.ide.eclipse.adt.AdtConstants;
|
import com.android.ide.eclipse.adt.AdtConstants;
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.build.BaseBuilder.BaseDeltaVisitor;
|
import com.android.ide.eclipse.adt.build.BaseBuilder.BaseDeltaVisitor;
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.build.PreCompilerBuilder.AidlData;
|
||||||
import com.android.ide.eclipse.common.AndroidConstants;
|
import com.android.ide.eclipse.common.AndroidConstants;
|
||||||
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
||||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||||
@@ -31,14 +31,25 @@ import org.eclipse.core.resources.IFolder;
|
|||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resource Delta visitor for the pre-compiler.
|
* Resource Delta visitor for the pre-compiler.
|
||||||
|
* <p/>This delta visitor only cares about files that are the source or the result of actions of the
|
||||||
|
* {@link PreCompilerBuilder}:
|
||||||
|
* <ul><li>R.java/Manifest.java generated by compiling the resources</li>
|
||||||
|
* <li>Any Java files generated by <code>aidl</code></li></ul>.
|
||||||
|
*
|
||||||
|
* Therefore it looks for the following:
|
||||||
|
* <ul><li>Any modification in the resource folder</li>
|
||||||
|
* <li>Removed files from the source folder receiving generated Java files</li>
|
||||||
|
* <li>Any modification to aidl files.</li>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
||||||
IResourceDeltaVisitor {
|
IResourceDeltaVisitor {
|
||||||
@@ -53,13 +64,10 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
private boolean mCompileResources = false;
|
private boolean mCompileResources = false;
|
||||||
|
|
||||||
/** List of .aidl files found that are modified or new. */
|
/** List of .aidl files found that are modified or new. */
|
||||||
private final ArrayList<IFile> mAidlToCompile = new ArrayList<IFile>();
|
private final ArrayList<AidlData> mAidlToCompile = new ArrayList<AidlData>();
|
||||||
|
|
||||||
/** List of .aidl files that have been removed. */
|
/** List of .aidl files that have been removed. */
|
||||||
private final ArrayList<IFile> mAidlToRemove = new ArrayList<IFile>();
|
private final ArrayList<AidlData> mAidlToRemove = new ArrayList<AidlData>();
|
||||||
|
|
||||||
/** Aidl forced recompilation flag. This is set to true if project.aidl is modified. */
|
|
||||||
private boolean mFullAidlCompilation = false;
|
|
||||||
|
|
||||||
/** Manifest check/parsing flag. */
|
/** Manifest check/parsing flag. */
|
||||||
private boolean mCheckedManifestXml = false;
|
private boolean mCheckedManifestXml = false;
|
||||||
@@ -75,36 +83,36 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
private boolean mInRes = false;
|
private boolean mInRes = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In Source folder flag. This allows us to know if we're in a source
|
* Current Source folder. This allows us to know if we're in a source
|
||||||
* folder.
|
* folder, and which folder.
|
||||||
*/
|
*/
|
||||||
private boolean mInSrc = false;
|
private IFolder mSourceFolder = null;
|
||||||
|
|
||||||
/** List of source folders. */
|
/** List of source folders. */
|
||||||
private ArrayList<IPath> mSourceFolders;
|
private ArrayList<IPath> mSourceFolders;
|
||||||
|
private boolean mIsGenSourceFolder = false;
|
||||||
|
|
||||||
|
private IWorkspaceRoot mRoot;
|
||||||
|
|
||||||
|
|
||||||
public PreCompilerDeltaVisitor(BaseBuilder builder, ArrayList<IPath> sourceFolders) {
|
public PreCompilerDeltaVisitor(BaseBuilder builder, ArrayList<IPath> sourceFolders) {
|
||||||
super(builder);
|
super(builder);
|
||||||
mSourceFolders = sourceFolders;
|
mSourceFolders = sourceFolders;
|
||||||
|
mRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getCompileResources() {
|
public boolean getCompileResources() {
|
||||||
return mCompileResources;
|
return mCompileResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<IFile> getAidlToCompile() {
|
public ArrayList<AidlData> getAidlToCompile() {
|
||||||
return mAidlToCompile;
|
return mAidlToCompile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<IFile> getAidlToRemove() {
|
public ArrayList<AidlData> getAidlToRemove() {
|
||||||
return mAidlToRemove;
|
return mAidlToRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getFullAidlRecompilation() {
|
|
||||||
return mFullAidlCompilation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the manifest file was parsed/checked for error during the resource delta
|
* Returns whether the manifest file was parsed/checked for error during the resource delta
|
||||||
* visiting.
|
* visiting.
|
||||||
@@ -149,11 +157,13 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
// since the delta visitor also visits the root we return true if
|
// since the delta visitor also visits the root we return true if
|
||||||
// segments.length = 1
|
// segments.length = 1
|
||||||
if (segments.length == 1) {
|
if (segments.length == 1) {
|
||||||
|
// FIXME: check this is an Android project.
|
||||||
return true;
|
return true;
|
||||||
} else if (segments.length == 2) {
|
} else if (segments.length == 2) {
|
||||||
// if we are at an item directly under the root directory,
|
// if we are at an item directly under the root directory,
|
||||||
// then we are not yet in a source or resource folder
|
// then we are not yet in a source or resource folder
|
||||||
mInRes = mInSrc = false;
|
mInRes = false;
|
||||||
|
mSourceFolder = null;
|
||||||
|
|
||||||
if (SdkConstants.FD_RESOURCES.equalsIgnoreCase(segments[1])) {
|
if (SdkConstants.FD_RESOURCES.equalsIgnoreCase(segments[1])) {
|
||||||
// this is the resource folder that was modified. we want to
|
// this is the resource folder that was modified. we want to
|
||||||
@@ -162,7 +172,7 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
// since we're going to visit its children next, we set the
|
// since we're going to visit its children next, we set the
|
||||||
// flag
|
// flag
|
||||||
mInRes = true;
|
mInRes = true;
|
||||||
mInSrc = false;
|
mSourceFolder = null;
|
||||||
return true;
|
return true;
|
||||||
} else if (AndroidConstants.FN_ANDROID_MANIFEST.equalsIgnoreCase(segments[1])) {
|
} else if (AndroidConstants.FN_ANDROID_MANIFEST.equalsIgnoreCase(segments[1])) {
|
||||||
// any change in the manifest could trigger a new R.java
|
// any change in the manifest could trigger a new R.java
|
||||||
@@ -183,9 +193,6 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
// we don't want to go to the children, not like they are
|
// we don't want to go to the children, not like they are
|
||||||
// any for this resource anyway.
|
// any for this resource anyway.
|
||||||
return false;
|
return false;
|
||||||
} else if (AndroidConstants.FN_PROJECT_AIDL.equalsIgnoreCase(segments[1])) {
|
|
||||||
// need to force recompilation of all the aidl files
|
|
||||||
mFullAidlCompilation = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +205,7 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
// so first we test if we already know we are in a source or
|
// so first we test if we already know we are in a source or
|
||||||
// resource folder.
|
// resource folder.
|
||||||
|
|
||||||
if (mInSrc) {
|
if (mSourceFolder != null) {
|
||||||
// if we are in the res folder, we are looking for the following changes:
|
// if we are in the res folder, we are looking for the following changes:
|
||||||
// - added/removed/modified aidl files.
|
// - added/removed/modified aidl files.
|
||||||
// - missing R.java file
|
// - missing R.java file
|
||||||
@@ -216,127 +223,81 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
// get the modification kind
|
// get the modification kind
|
||||||
int kind = delta.getKind();
|
int kind = delta.getKind();
|
||||||
|
|
||||||
if (kind == IResourceDelta.ADDED) {
|
// we process normal source folder and the 'gen' source folder differently.
|
||||||
// we only care about added files (inside the source folders), if they
|
if (mIsGenSourceFolder) {
|
||||||
// are aidl files.
|
// this is the generated java file source folder.
|
||||||
|
// - if R.java/Manifest.java are removed/modified, we recompile the resources
|
||||||
|
// - if aidl files are removed/modified, we recompile them.
|
||||||
|
|
||||||
// get the extension of the resource
|
boolean outputWarning = false;
|
||||||
String ext = resource.getFileExtension();
|
|
||||||
|
|
||||||
if (AndroidConstants.EXT_AIDL.equalsIgnoreCase(ext)) {
|
String fileName = resource.getName();
|
||||||
// look for an already existing matching java file
|
|
||||||
String javaName = resource.getName().replaceAll(
|
|
||||||
AndroidConstants.RE_AIDL_EXT,
|
|
||||||
AndroidConstants.DOT_JAVA);
|
|
||||||
|
|
||||||
// get the parent container
|
// Special case of R.java/Manifest.java.
|
||||||
IContainer ic = resource.getParent();
|
if (AndroidConstants.FN_RESOURCE_CLASS.equals(fileName) ||
|
||||||
|
AndroidConstants.FN_MANIFEST_CLASS.equals(fileName)) {
|
||||||
|
// if it was removed, there's a possibility that it was removed due to a
|
||||||
|
// package change, or an aidl that was removed, but the only thing
|
||||||
|
// that will happen is that we'll have an extra build. Not much of a problem.
|
||||||
|
mCompileResources = true;
|
||||||
|
|
||||||
IFile javaFile = ic.getFile(new Path(javaName));
|
// we want a warning
|
||||||
if (javaFile != null && javaFile.exists()) {
|
outputWarning = true;
|
||||||
// check if that file was generated by the plugin. Normally those files are
|
} else {
|
||||||
// deleted automatically, but it's better to check.
|
// this has to be a Java file created from an aidl file.
|
||||||
String aidlPath = ProjectHelper.loadStringProperty(javaFile,
|
// Look for the source aidl file in all the source folders.
|
||||||
PreCompilerBuilder.PROPERTY_ANDROID_GENERATED);
|
String aidlFileName = fileName.replaceAll(AndroidConstants.RE_JAVA_EXT,
|
||||||
if (aidlPath == null) {
|
AndroidConstants.DOT_AIDL);
|
||||||
// mark the aidl file that it cannot be compile just yet
|
|
||||||
ProjectHelper.saveBooleanProperty(file,
|
for (IPath sourceFolderPath : mSourceFolders) {
|
||||||
PreCompilerBuilder.PROPERTY_ANDROID_CONFLICT, true);
|
// do not search in the current source folder as it is the 'gen' folder.
|
||||||
|
if (sourceFolderPath.equals(mSourceFolder.getFullPath())) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we add it anyway so that we can try to compile it at every compilation
|
IFolder sourceFolder = getFolder(sourceFolderPath);
|
||||||
// until the conflict is fixed.
|
if (sourceFolder != null) {
|
||||||
mAidlToCompile.add(file);
|
// go recursively, segment by segment.
|
||||||
|
// index starts at 2 (0 is project, 1 is 'gen'
|
||||||
|
IFile sourceFile = findFile(sourceFolder, segments, 2, aidlFileName);
|
||||||
|
|
||||||
} else {
|
if (sourceFile != null) {
|
||||||
// the java file doesn't exist, we can safely add the file to the list
|
// found the source. add it to the list of files to compile
|
||||||
// of files to compile.
|
mAidlToCompile.add(new AidlData(sourceFolder, sourceFile));
|
||||||
mAidlToCompile.add(file);
|
outputWarning = true;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the filename
|
|
||||||
String fileName = segments[segments.length - 1];
|
|
||||||
|
|
||||||
boolean outputMessage = false;
|
|
||||||
|
|
||||||
// Special case of R.java/Manifest.java.
|
|
||||||
// FIXME: This does not check the package. Any modification of R.java/Manifest.java in another project will trigger a new recompilation of the resources.
|
|
||||||
if (AndroidConstants.FN_RESOURCE_CLASS.equals(fileName) ||
|
|
||||||
AndroidConstants.FN_MANIFEST_CLASS.equals(fileName)) {
|
|
||||||
// if it was removed, there's a possibility that it was removed due to a
|
|
||||||
// package change, or an aidl that was removed, but the only thing
|
|
||||||
// that will happen is that we'll have an extra build. Not much of a problem.
|
|
||||||
mCompileResources = true;
|
|
||||||
|
|
||||||
// we want a warning
|
|
||||||
outputMessage = true;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// get the extension of the resource
|
|
||||||
String ext = resource.getFileExtension();
|
|
||||||
|
|
||||||
if (AndroidConstants.EXT_AIDL.equalsIgnoreCase(ext)) {
|
|
||||||
if (kind == IResourceDelta.REMOVED) {
|
|
||||||
mAidlToRemove.add(file);
|
|
||||||
} else {
|
|
||||||
mAidlToCompile.add(file);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (kind == IResourceDelta.REMOVED) {
|
|
||||||
// the file has been removed. we need to check it's a java file and that
|
|
||||||
// there's a matching aidl file. We can't check its persistent storage
|
|
||||||
// anymore.
|
|
||||||
if (AndroidConstants.EXT_JAVA.equalsIgnoreCase(ext)) {
|
|
||||||
String aidlFile = resource.getName().replaceAll(
|
|
||||||
AndroidConstants.RE_JAVA_EXT,
|
|
||||||
AndroidConstants.DOT_AIDL);
|
|
||||||
|
|
||||||
// get the parent container
|
|
||||||
IContainer ic = resource.getParent();
|
|
||||||
|
|
||||||
IFile f = ic.getFile(new Path(aidlFile));
|
|
||||||
if (f != null && f.exists() ) {
|
|
||||||
// make sure that the aidl file is not in conflict anymore, in
|
|
||||||
// case the java file was not generated by us.
|
|
||||||
if (ProjectHelper.loadBooleanProperty(f,
|
|
||||||
PreCompilerBuilder.PROPERTY_ANDROID_CONFLICT, false)) {
|
|
||||||
ProjectHelper.saveBooleanProperty(f,
|
|
||||||
PreCompilerBuilder.PROPERTY_ANDROID_CONFLICT, false);
|
|
||||||
} else {
|
|
||||||
outputMessage = true;
|
|
||||||
}
|
|
||||||
mAidlToCompile.add(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// check if it's an android generated java file.
|
|
||||||
IResource aidlSource = ProjectHelper.loadResourceProperty(
|
|
||||||
file, PreCompilerBuilder.PROPERTY_ANDROID_GENERATED);
|
|
||||||
|
|
||||||
if (aidlSource != null && aidlSource.exists() &&
|
|
||||||
aidlSource.getType() == IResource.FILE) {
|
|
||||||
// it looks like this was a java file created from an aidl file.
|
|
||||||
// we need to add the aidl file to the list of aidl file to compile
|
|
||||||
mAidlToCompile.add((IFile)aidlSource);
|
|
||||||
outputMessage = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (outputMessage) {
|
if (outputWarning) {
|
||||||
if (kind == IResourceDelta.REMOVED) {
|
if (kind == IResourceDelta.REMOVED) {
|
||||||
// We pring an error just so that it's red, but it's just a warning really.
|
// We pring an error just so that it's red, but it's just a warning really.
|
||||||
String msg = String.format(Messages.s_Removed_Recreating_s, fileName);
|
String msg = String.format(Messages.s_Removed_Recreating_s, fileName);
|
||||||
AdtPlugin.printErrorToConsole(mBuilder.getProject(), msg);
|
AdtPlugin.printErrorToConsole(mBuilder.getProject(), msg);
|
||||||
} else if (kind == IResourceDelta.CHANGED) {
|
} else if (kind == IResourceDelta.CHANGED) {
|
||||||
// the file was modified manually! we can't allow it.
|
// the file was modified manually! we can't allow it.
|
||||||
String msg = String.format(Messages.s_Modified_Manually_Recreating_s, fileName);
|
String msg = String.format(Messages.s_Modified_Manually_Recreating_s,
|
||||||
AdtPlugin.printErrorToConsole(mBuilder.getProject(), msg);
|
fileName);
|
||||||
|
AdtPlugin.printErrorToConsole(mBuilder.getProject(), msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// this is another source folder.
|
||||||
|
// We only care about aidl files being added/modified/removed.
|
||||||
|
|
||||||
|
// get the extension of the resource
|
||||||
|
String ext = resource.getFileExtension();
|
||||||
|
if (AndroidConstants.EXT_AIDL.equalsIgnoreCase(ext)) {
|
||||||
|
if (kind == IResourceDelta.REMOVED) {
|
||||||
|
// we'll have to remove the generated file.
|
||||||
|
mAidlToRemove.add(new AidlData(mSourceFolder, file));
|
||||||
|
} else {
|
||||||
|
// add the aidl file to the list of file to (re)compile
|
||||||
|
mAidlToCompile.add(new AidlData(mSourceFolder, file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,19 +364,25 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
}
|
}
|
||||||
} else if (resource instanceof IFolder) {
|
} else if (resource instanceof IFolder) {
|
||||||
// in this case we may be inside a folder that contains a source
|
// in this case we may be inside a folder that contains a source
|
||||||
// folder.
|
// folder, go through the list of known source folders
|
||||||
String[] sourceFolderSegments = findMatchingSourceFolder(mSourceFolders, segments);
|
|
||||||
if (sourceFolderSegments != null) {
|
|
||||||
// we have a match!
|
|
||||||
mInRes = false;
|
|
||||||
|
|
||||||
// Check if the current folder is actually a source folder
|
for (IPath sourceFolderPath : mSourceFolders) {
|
||||||
if (sourceFolderSegments.length == segments.length) {
|
// first check if they match exactly.
|
||||||
mInSrc = true;
|
if (sourceFolderPath.equals(path)) {
|
||||||
|
// this is a source folder!
|
||||||
|
mInRes = false;
|
||||||
|
mSourceFolder = getFolder(sourceFolderPath); // all non null due to test above
|
||||||
|
mIsGenSourceFolder = path.segmentCount() == 2 &&
|
||||||
|
path.segment(1).equals(SdkConstants.FD_GEN_SOURCES);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and return true to visit the content, no matter what
|
// check if we are on the way to a source folder.
|
||||||
return true;
|
int count = sourceFolderPath.matchingFirstSegments(path);
|
||||||
|
if (count == path.segmentCount()) {
|
||||||
|
mInRes = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're here, we are visiting another folder
|
// if we're here, we are visiting another folder
|
||||||
@@ -429,4 +396,46 @@ class PreCompilerDeltaVisitor extends BaseDeltaVisitor implements
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for and return a file in a folder. The file is defined by its segments, and a new
|
||||||
|
* name (replacing the last segment).
|
||||||
|
* @param folder the folder we are searching
|
||||||
|
* @param segments the segments of the file to search.
|
||||||
|
* @param index the index of the current segment we are looking for
|
||||||
|
* @param filename the new name to replace the last segment.
|
||||||
|
* @return the {@link IFile} representing the searched file, or null if not found
|
||||||
|
*/
|
||||||
|
private IFile findFile(IFolder folder, String[] segments, int index, String filename) {
|
||||||
|
boolean lastSegment = index == segments.length - 1;
|
||||||
|
IResource resource = folder.findMember(lastSegment ? filename : segments[index]);
|
||||||
|
if (resource != null && resource.exists()) {
|
||||||
|
if (lastSegment) {
|
||||||
|
if (resource.getType() == IResource.FILE) {
|
||||||
|
return (IFile)resource;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (resource.getType() == IResource.FOLDER) {
|
||||||
|
return findFile((IFolder)resource, segments, index+1, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a handle to the folder identified by the given path in this container.
|
||||||
|
* <p/>The different with {@link IContainer#getFolder(IPath)} is that this returns a non
|
||||||
|
* null object only if the resource actually exists and is a folder (and not a file)
|
||||||
|
* @param path the path of the folder to return.
|
||||||
|
* @return a handle to the folder if it exists, or null otherwise.
|
||||||
|
*/
|
||||||
|
private IFolder getFolder(IPath path) {
|
||||||
|
IResource resource = mRoot.findMember(path);
|
||||||
|
if (resource != null && resource.exists() && resource.getType() == IResource.FOLDER) {
|
||||||
|
return (IFolder)resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,19 +19,27 @@ package com.android.ide.eclipse.adt.build;
|
|||||||
import com.android.ide.eclipse.adt.AdtConstants;
|
import com.android.ide.eclipse.adt.AdtConstants;
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||||
import com.android.ide.eclipse.adt.sdk.LoadStatus;
|
|
||||||
import com.android.ide.eclipse.adt.sdk.Sdk;
|
import com.android.ide.eclipse.adt.sdk.Sdk;
|
||||||
import com.android.ide.eclipse.common.AndroidConstants;
|
import com.android.ide.eclipse.common.AndroidConstants;
|
||||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||||
import com.android.sdklib.IAndroidTarget;
|
import com.android.sdklib.IAndroidTarget;
|
||||||
|
import com.android.sdklib.SdkConstants;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
import org.eclipse.jdt.core.IClasspathEntry;
|
||||||
|
import org.eclipse.jdt.core.IJavaProject;
|
||||||
|
import org.eclipse.jdt.core.JavaCore;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +65,10 @@ public class ResourceManagerBuilder extends BaseBuilder {
|
|||||||
// Clear the project of the generic markers
|
// Clear the project of the generic markers
|
||||||
BaseBuilder.removeMarkersFromProject(project, AdtConstants.MARKER_ADT);
|
BaseBuilder.removeMarkersFromProject(project, AdtConstants.MARKER_ADT);
|
||||||
|
|
||||||
|
// check for existing target marker, in which case we abort.
|
||||||
|
// (this means: no SDK, no target, or unresolvable target.)
|
||||||
|
abortOnBadSetup(project);
|
||||||
|
|
||||||
// Check the compiler compliance level, displaying the error message
|
// Check the compiler compliance level, displaying the error message
|
||||||
// since this is the first builder.
|
// since this is the first builder.
|
||||||
int res = ProjectHelper.checkCompilerCompliance(project);
|
int res = ProjectHelper.checkCompilerCompliance(project);
|
||||||
@@ -83,8 +95,7 @@ public class ResourceManagerBuilder extends BaseBuilder {
|
|||||||
String osSdkFolder = AdtPlugin.getOsSdkFolder();
|
String osSdkFolder = AdtPlugin.getOsSdkFolder();
|
||||||
|
|
||||||
if (osSdkFolder == null || osSdkFolder.length() == 0) {
|
if (osSdkFolder == null || osSdkFolder.length() == 0) {
|
||||||
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, project,
|
AdtPlugin.printErrorToConsole(project, Messages.No_SDK_Setup_Error);
|
||||||
Messages.No_SDK_Setup_Error);
|
|
||||||
markProject(AdtConstants.MARKER_ADT, Messages.No_SDK_Setup_Error,
|
markProject(AdtConstants.MARKER_ADT, Messages.No_SDK_Setup_Error,
|
||||||
IMarker.SEVERITY_ERROR);
|
IMarker.SEVERITY_ERROR);
|
||||||
|
|
||||||
@@ -92,13 +103,6 @@ public class ResourceManagerBuilder extends BaseBuilder {
|
|||||||
stopBuild(Messages.No_SDK_Setup_Error);
|
stopBuild(Messages.No_SDK_Setup_Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we have finished loading the SDK.
|
|
||||||
if (AdtPlugin.getDefault().getSdkLoadStatus() != LoadStatus.LOADED) {
|
|
||||||
// we exit silently
|
|
||||||
// This interrupts the build. The next builders will not run.
|
|
||||||
stopBuild("SDK is not loaded yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check the project has a target
|
// check the project has a target
|
||||||
IAndroidTarget projectTarget = Sdk.getCurrent().getTarget(project);
|
IAndroidTarget projectTarget = Sdk.getCurrent().getTarget(project);
|
||||||
if (projectTarget == null) {
|
if (projectTarget == null) {
|
||||||
@@ -107,6 +111,85 @@ public class ResourceManagerBuilder extends BaseBuilder {
|
|||||||
stopBuild("Project has no target");
|
stopBuild("Project has no target");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check the 'gen' source folder is present
|
||||||
|
boolean hasGenSrcFolder = false; // whether the project has a 'gen' source folder setup
|
||||||
|
IJavaProject javaProject = JavaCore.create(project);
|
||||||
|
|
||||||
|
IClasspathEntry[] classpaths = javaProject.readRawClasspath();
|
||||||
|
if (classpaths != null) {
|
||||||
|
for (IClasspathEntry e : classpaths) {
|
||||||
|
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
|
||||||
|
IPath path = e.getPath();
|
||||||
|
if (path.segmentCount() == 2 &&
|
||||||
|
path.segment(1).equals(SdkConstants.FD_GEN_SOURCES)) {
|
||||||
|
hasGenSrcFolder = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean genFolderPresent = false; // whether the gen folder actually exists
|
||||||
|
IResource resource = project.findMember(SdkConstants.FD_GEN_SOURCES);
|
||||||
|
genFolderPresent = resource != null && resource.exists();
|
||||||
|
|
||||||
|
if (hasGenSrcFolder == false && genFolderPresent) {
|
||||||
|
// No source folder setup for 'gen' in the project, but there's already a
|
||||||
|
// 'gen' resource (file or folder).
|
||||||
|
String message;
|
||||||
|
if (resource.getType() == IResource.FOLDER) {
|
||||||
|
// folder exists already! This is an error. If the folder had been created
|
||||||
|
// by the NewProjectWizard, it'd be a source folder.
|
||||||
|
message = String.format("%1$s already exists but is not a source folder. Convert to a source folder or rename it.",
|
||||||
|
resource.getFullPath().toString());
|
||||||
|
} else {
|
||||||
|
// resource exists but is not a folder.
|
||||||
|
message = String.format(
|
||||||
|
"Resource %1$s is in the way. ADT needs a source folder called 'gen' to work. Rename or delete resource.",
|
||||||
|
resource.getFullPath().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
AdtPlugin.printErrorToConsole(project, message);
|
||||||
|
markProject(AdtConstants.MARKER_ADT, message, IMarker.SEVERITY_ERROR);
|
||||||
|
|
||||||
|
// This interrupts the build. The next builders will not run.
|
||||||
|
stopBuild(message);
|
||||||
|
} else if (hasGenSrcFolder == false || genFolderPresent == false) {
|
||||||
|
// either there is no 'gen' source folder in the project (older SDK),
|
||||||
|
// or the folder does not exist (was deleted, or was a fresh svn checkout maybe.)
|
||||||
|
|
||||||
|
// In case we are migrating from an older SDK, we go through the current source
|
||||||
|
// folders and delete the generated Java files.
|
||||||
|
ArrayList<IPath> sourceFolders = BaseProjectHelper.getSourceClasspaths(javaProject);
|
||||||
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
for (IPath path : sourceFolders) {
|
||||||
|
IResource member = root.findMember(path);
|
||||||
|
if (member != null) {
|
||||||
|
removeDerivedResources(member, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the new source folder, if needed
|
||||||
|
IFolder genFolder = project.getFolder(SdkConstants.FD_GEN_SOURCES);
|
||||||
|
if (genFolderPresent == false) {
|
||||||
|
AdtPlugin.printBuildToConsole(AdtConstants.BUILD_VERBOSE, project,
|
||||||
|
"Creating 'gen' source folder for generated Java files");
|
||||||
|
genFolder.create(true /* force */, true /* local */,
|
||||||
|
new SubProgressMonitor(monitor, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add it to the source folder list, if needed only (or it will throw)
|
||||||
|
if (hasGenSrcFolder == false) {
|
||||||
|
IClasspathEntry[] entries = javaProject.getRawClasspath();
|
||||||
|
entries = ProjectHelper.addEntryToClasspath(entries,
|
||||||
|
JavaCore.newSourceEntry(genFolder.getFullPath()));
|
||||||
|
javaProject.setRawClasspath(entries, new SubProgressMonitor(monitor, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
// refresh the whole project
|
||||||
|
project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 10));
|
||||||
|
}
|
||||||
|
|
||||||
// Check the preference to be sure we are supposed to refresh
|
// Check the preference to be sure we are supposed to refresh
|
||||||
// the folders.
|
// the folders.
|
||||||
if (AdtPlugin.getAutoResRefresh()) {
|
if (AdtPlugin.getAutoResRefresh()) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.launching;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.launching;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
@@ -28,8 +28,7 @@ import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
|
|||||||
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
|
||||||
import com.android.ddmlib.SyncService.SyncResult;
|
import com.android.ddmlib.SyncService.SyncResult;
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.DeviceChooserDialog.DeviceChooserResponse;
|
import com.android.ide.eclipse.adt.launch.DeviceChooserDialog.DeviceChooserResponse;
|
||||||
import com.android.ide.eclipse.adt.debug.ui.EmulatorConfigTab;
|
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||||
import com.android.ide.eclipse.adt.sdk.Sdk;
|
import com.android.ide.eclipse.adt.sdk.Sdk;
|
||||||
import com.android.ide.eclipse.common.project.AndroidManifestHelper;
|
import com.android.ide.eclipse.common.project.AndroidManifestHelper;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.launching;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ddmlib.Client;
|
import com.android.ddmlib.Client;
|
||||||
@@ -14,10 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.ui;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.LaunchConfigDelegate;
|
|
||||||
import com.android.ide.eclipse.adt.sdk.Sdk;
|
import com.android.ide.eclipse.adt.sdk.Sdk;
|
||||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||||
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
import com.android.ide.eclipse.ddms.DdmsPlugin;
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Eclipse Public License, Version 1.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
|
||||||
|
*
|
||||||
|
* 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.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
|
import com.android.ide.eclipse.common.AndroidConstants;
|
||||||
|
import com.android.sdklib.SdkConstants;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.FileLocator;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* For Android projects, android.jar gets added to the launch configuration of
|
||||||
|
* JUnit tests as a bootstrap entry. This breaks JUnit tests as android.jar
|
||||||
|
* contains a skeleton version of JUnit classes and the JVM will stop with an error similar
|
||||||
|
* to: <blockquote> Error occurred during initialization of VM
|
||||||
|
* java/lang/NoClassDefFoundError: java/lang/ref/FinalReference </blockquote>
|
||||||
|
* <p>
|
||||||
|
* At compile time, Eclipse does not know that there is no valid junit.jar in
|
||||||
|
* the classpath since it can find a correct reference to all the necessary
|
||||||
|
* org.junit.* classes in the android.jar so it does not prompt the user to add
|
||||||
|
* the JUnit3 or JUnit4 jar.
|
||||||
|
* <p>
|
||||||
|
* This delegates removes the android.jar from the bootstrap path and if
|
||||||
|
* necessary also puts back the junit.jar in the user classpath.
|
||||||
|
* <p>
|
||||||
|
* This delegate will be present for both Java and Android projects (delegates
|
||||||
|
* setting instead of only the current project) but the behavior for Java
|
||||||
|
* projects should be neutral since:
|
||||||
|
* <ol>
|
||||||
|
* <li>Java tests can only compile (and then run) when a valid junit.jar is
|
||||||
|
* present
|
||||||
|
* <li>There is no android.jar in Java projects
|
||||||
|
* </ol>
|
||||||
|
*/
|
||||||
|
public class JUnitLaunchConfigDelegate extends JUnitLaunchConfigurationDelegate {
|
||||||
|
|
||||||
|
private static final String JUNIT_JAR = "junit.jar"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[][] getBootpathExt(ILaunchConfiguration configuration) throws CoreException {
|
||||||
|
String[][] bootpath = super.getBootpathExt(configuration);
|
||||||
|
return fixBootpathExt(bootpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
|
||||||
|
String[] classpath = super.getClasspath(configuration);
|
||||||
|
return fixClasspath(classpath, getJavaProjectName(configuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the android.jar from the bootstrap path if present.
|
||||||
|
*
|
||||||
|
* @param bootpath Array of Arrays of bootstrap class paths
|
||||||
|
* @return a new modified (if applicable) bootpath
|
||||||
|
*/
|
||||||
|
public static String[][] fixBootpathExt(String[][] bootpath) {
|
||||||
|
for (int i = 0; i < bootpath.length; i++) {
|
||||||
|
if (bootpath[i] != null) {
|
||||||
|
// we assume that the android.jar can only be present in the
|
||||||
|
// bootstrap path of android tests
|
||||||
|
if (bootpath[i][0].endsWith(SdkConstants.FN_FRAMEWORK_LIBRARY)) {
|
||||||
|
bootpath[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bootpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the junit.jar to the user classpath; since Eclipse was relying on
|
||||||
|
* android.jar to provide the appropriate org.junit classes, it does not
|
||||||
|
* know it actually needs the junit.jar.
|
||||||
|
*
|
||||||
|
* @param classpath Array containing classpath
|
||||||
|
* @param projectName The name of the project (for logging purposes)
|
||||||
|
*
|
||||||
|
* @return a new modified (if applicable) classpath
|
||||||
|
*/
|
||||||
|
public static String[] fixClasspath(String[] classpath, String projectName) {
|
||||||
|
// search for junit.jar; if any are found return immediately
|
||||||
|
for (int i = 0; i < classpath.length; i++) {
|
||||||
|
if (classpath[i].endsWith(JUNIT_JAR)) {
|
||||||
|
return classpath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This delegate being called without a junit.jar present is only
|
||||||
|
// possible for Android projects. In a non-Android project, the test
|
||||||
|
// would not compile and would be unable to run.
|
||||||
|
try {
|
||||||
|
// junit4 is backward compatible with junit3 and they uses the
|
||||||
|
// same junit.jar from bundle org.junit:
|
||||||
|
// When a project has mixed JUnit3 and JUnit4 tests, if JUnit3 jar
|
||||||
|
// is added first it is then replaced by the JUnit4 jar when user is
|
||||||
|
// prompted to fix the JUnit4 test failure
|
||||||
|
String jarLocation = getJunitJarLocation();
|
||||||
|
// we extend the classpath by one element and append junit.jar
|
||||||
|
String[] newClasspath = new String[classpath.length + 1];
|
||||||
|
System.arraycopy(classpath, 0, newClasspath, 0, classpath.length);
|
||||||
|
newClasspath[newClasspath.length - 1] = jarLocation;
|
||||||
|
classpath = newClasspath;
|
||||||
|
} catch (IOException e) {
|
||||||
|
// This should not happen as we depend on the org.junit
|
||||||
|
// plugin explicitly; the error is logged here so that the user can
|
||||||
|
// trace back the cause when the test fails to run
|
||||||
|
AdtPlugin.log(e, "Could not find a valid junit.jar");
|
||||||
|
AdtPlugin.printErrorToConsole(projectName,
|
||||||
|
"Could not find a valid junit.jar");
|
||||||
|
// Return the classpath as-is (with no junit.jar) anyway because we
|
||||||
|
// will let the actual launch config fails.
|
||||||
|
}
|
||||||
|
|
||||||
|
return classpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path of the junit jar in the highest version bundle.
|
||||||
|
*
|
||||||
|
* (This is public only so that the test can call it)
|
||||||
|
*
|
||||||
|
* @return the path as a string
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static String getJunitJarLocation() throws IOException {
|
||||||
|
Bundle bundle = Platform.getBundle("org.junit"); //$NON-NLS-1$
|
||||||
|
if (bundle == null) {
|
||||||
|
throw new IOException("Cannot find org.junit bundle");
|
||||||
|
}
|
||||||
|
URL jarUrl = bundle.getEntry(AndroidConstants.WS_SEP + JUNIT_JAR);
|
||||||
|
return FileLocator.resolve(jarUrl).getFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.launching;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import com.android.ddmlib.AndroidDebugBridge;
|
import com.android.ddmlib.AndroidDebugBridge;
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.AndroidLaunchController.AndroidLaunchConfiguration;
|
import com.android.ide.eclipse.adt.launch.AndroidLaunchController.AndroidLaunchConfiguration;
|
||||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||||
import com.android.ide.eclipse.common.AndroidConstants;
|
import com.android.ide.eclipse.common.AndroidConstants;
|
||||||
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.ui;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||||
import org.eclipse.debug.ui.CommonTab;
|
import org.eclipse.debug.ui.CommonTab;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.launching;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
@@ -14,11 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.ide.eclipse.adt.debug.ui;
|
package com.android.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.AndroidLaunchController;
|
|
||||||
import com.android.ide.eclipse.adt.debug.launching.LaunchConfigDelegate;
|
|
||||||
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
import com.android.ide.eclipse.common.project.AndroidManifestParser;
|
||||||
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
import com.android.ide.eclipse.common.project.BaseProjectHelper;
|
||||||
import com.android.ide.eclipse.common.project.ProjectChooserHelper;
|
import com.android.ide.eclipse.common.project.ProjectChooserHelper;
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Eclipse Public License, Version 1.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
|
|
||||||
*
|
|
||||||
* 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.ide.eclipse.adt.project;
|
|
||||||
|
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
|
||||||
import com.android.ide.eclipse.common.AndroidConstants;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
|
||||||
import org.eclipse.jdt.core.ICompilationUnit;
|
|
||||||
import org.eclipse.jdt.core.IJavaElement;
|
|
||||||
import org.eclipse.jdt.core.IJavaProject;
|
|
||||||
import org.eclipse.jdt.core.IPackageFragment;
|
|
||||||
import org.eclipse.jdt.core.IPackageFragmentRoot;
|
|
||||||
import org.eclipse.jdt.core.IType;
|
|
||||||
import org.eclipse.jdt.core.ITypeHierarchy;
|
|
||||||
import org.eclipse.jdt.core.JavaCore;
|
|
||||||
import org.eclipse.jdt.core.JavaModelException;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action going through all the source of a project and creating a pre-processed aidl file
|
|
||||||
* with all the custom parcelable classes.
|
|
||||||
*/
|
|
||||||
public class CreateAidlImportAction implements IObjectActionDelegate {
|
|
||||||
|
|
||||||
private ISelection mSelection;
|
|
||||||
|
|
||||||
public CreateAidlImportAction() {
|
|
||||||
// pass
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
|
||||||
// pass
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
|
||||||
public void run(IAction action) {
|
|
||||||
if (mSelection instanceof IStructuredSelection) {
|
|
||||||
for (Iterator<?> it = ((IStructuredSelection)mSelection).iterator(); it.hasNext();) {
|
|
||||||
Object element = it.next();
|
|
||||||
IProject project = null;
|
|
||||||
if (element instanceof IProject) {
|
|
||||||
project = (IProject)element;
|
|
||||||
} else if (element instanceof IAdaptable) {
|
|
||||||
project = (IProject)((IAdaptable)element).getAdapter(IProject.class);
|
|
||||||
}
|
|
||||||
if (project != null) {
|
|
||||||
final IProject fproject = project;
|
|
||||||
new Job("Aidl preprocess") {
|
|
||||||
@Override
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
return createImportFile(fproject, monitor);
|
|
||||||
}
|
|
||||||
}.schedule();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
mSelection = selection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IStatus createImportFile(IProject project, IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
if (monitor != null) {
|
|
||||||
monitor.beginTask(String.format(
|
|
||||||
"Creating aid preprocess file for %1$s", project.getName()), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> parcelables = new ArrayList<String>();
|
|
||||||
|
|
||||||
IJavaProject javaProject = JavaCore.create(project);
|
|
||||||
|
|
||||||
IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
|
|
||||||
|
|
||||||
for (IPackageFragmentRoot root : roots) {
|
|
||||||
if (root.isArchive() == false && root.isExternal() == false) {
|
|
||||||
parsePackageFragmentRoot(root, parcelables, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the file with the parcelables
|
|
||||||
if (parcelables.size() > 0) {
|
|
||||||
IPath path = project.getLocation();
|
|
||||||
path = path.append(AndroidConstants.FN_PROJECT_AIDL);
|
|
||||||
|
|
||||||
File f = new File(path.toOSString());
|
|
||||||
if (f.exists() == false) {
|
|
||||||
if (f.createNewFile() == false) {
|
|
||||||
return new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
|
|
||||||
"Failed to create /project.aidl");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileWriter fw = new FileWriter(f);
|
|
||||||
|
|
||||||
fw.write("// This file is auto-generated by the\n");
|
|
||||||
fw.write("// 'Create Aidl preprocess file for Parcelable classes'\n");
|
|
||||||
fw.write("// action. Do not modify!\n\n");
|
|
||||||
|
|
||||||
for (String parcelable : parcelables) {
|
|
||||||
fw.write("parcelable "); //$NON-NLS-1$
|
|
||||||
fw.write(parcelable);
|
|
||||||
fw.append(";\n"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
fw.close();
|
|
||||||
|
|
||||||
// need to refresh the level just below the project to make sure it's being picked
|
|
||||||
// up by eclipse.
|
|
||||||
project.refreshLocal(IResource.DEPTH_ONE, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitor != null) {
|
|
||||||
monitor.worked(1);
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (JavaModelException e) {
|
|
||||||
return e.getJavaModelStatus();
|
|
||||||
} catch (IOException e) {
|
|
||||||
return new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
|
|
||||||
"Failed to create /project.aidl", e);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
} finally {
|
|
||||||
if (monitor != null) {
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parsePackageFragmentRoot(IPackageFragmentRoot root,
|
|
||||||
ArrayList<String> parcelables, IProgressMonitor monitor) throws JavaModelException {
|
|
||||||
|
|
||||||
IJavaElement[] elements = root.getChildren();
|
|
||||||
|
|
||||||
for (IJavaElement element : elements) {
|
|
||||||
if (element instanceof IPackageFragment) {
|
|
||||||
ICompilationUnit[] compilationUnits =
|
|
||||||
((IPackageFragment)element).getCompilationUnits();
|
|
||||||
|
|
||||||
for (ICompilationUnit unit : compilationUnits) {
|
|
||||||
IType[] types = unit.getTypes();
|
|
||||||
|
|
||||||
for (IType type : types) {
|
|
||||||
parseType(type, parcelables, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseType(IType type, ArrayList<String> parcelables, IProgressMonitor monitor)
|
|
||||||
throws JavaModelException {
|
|
||||||
// first look in this type if it somehow extends parcelable.
|
|
||||||
ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(monitor);
|
|
||||||
|
|
||||||
IType[] superInterfaces = typeHierarchy.getAllSuperInterfaces(type);
|
|
||||||
for (IType superInterface : superInterfaces) {
|
|
||||||
if (AndroidConstants.CLASS_PARCELABLE.equals(superInterface.getFullyQualifiedName())) {
|
|
||||||
parcelables.add(type.getFullyQualifiedName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// then look in inner types.
|
|
||||||
IType[] innerTypes = type.getTypes();
|
|
||||||
|
|
||||||
for (IType innerType : innerTypes) {
|
|
||||||
parseType(innerType, parcelables, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
package com.android.ide.eclipse.adt.project;
|
package com.android.ide.eclipse.adt.project;
|
||||||
|
|
||||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||||
import com.android.ide.eclipse.adt.debug.launching.LaunchConfigDelegate;
|
import com.android.ide.eclipse.adt.launch.LaunchConfigDelegate;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class FolderDecorator implements ILightweightLabelDecorator {
|
|||||||
private ImageDescriptor mDescriptor;
|
private ImageDescriptor mDescriptor;
|
||||||
|
|
||||||
public FolderDecorator() {
|
public FolderDecorator() {
|
||||||
mDescriptor = AdtPlugin.getImageDescriptor("/icons/android_project.png");
|
mDescriptor = AdtPlugin.getImageDescriptor("/icons/android_project.png"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decorate(Object element, IDecoration decoration) {
|
public void decorate(Object element, IDecoration decoration) {
|
||||||
@@ -55,13 +55,13 @@ public class FolderDecorator implements ILightweightLabelDecorator {
|
|||||||
if (folder.getParent().getType() == IResource.PROJECT) {
|
if (folder.getParent().getType() == IResource.PROJECT) {
|
||||||
String name = folder.getName();
|
String name = folder.getName();
|
||||||
if (name.equals(SdkConstants.FD_ASSETS)) {
|
if (name.equals(SdkConstants.FD_ASSETS)) {
|
||||||
decorate(decoration, " [Android assets]");
|
doDecoration(decoration, null);
|
||||||
decoration.addOverlay(mDescriptor, IDecoration.TOP_RIGHT);
|
|
||||||
} else if (name.equals(SdkConstants.FD_RESOURCES)) {
|
} else if (name.equals(SdkConstants.FD_RESOURCES)) {
|
||||||
decorate(decoration, " [Android resources]");
|
doDecoration(decoration, null);
|
||||||
decoration.addOverlay(mDescriptor, IDecoration.TOP_RIGHT);
|
} else if (name.equals(SdkConstants.FD_GEN_SOURCES)) {
|
||||||
} else if (name.equals(SdkConstants.FD_NATIVE_LIBS)) {
|
doDecoration(decoration, " [Generated Java Files]");
|
||||||
decorate(decoration, " [Native Libraries]");
|
} else if (name.equals(SdkConstants.FD_NATIVE_LIBS)) {
|
||||||
|
doDecoration(decoration, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,20 +72,24 @@ public class FolderDecorator implements ILightweightLabelDecorator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decorate(IDecoration decoration, String suffix) {
|
public void doDecoration(IDecoration decoration, String suffix) {
|
||||||
decoration.addOverlay(mDescriptor, IDecoration.TOP_RIGHT);
|
decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT);
|
||||||
|
|
||||||
// this is broken as it changes the color of the whole text, not only of the decoration.
|
if (suffix != null) {
|
||||||
// TODO: figure out how to change the color of the decoration only.
|
decoration.addSuffix(suffix);
|
||||||
// decoration.addSuffix(suffix);
|
|
||||||
// ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
|
// this is broken as it changes the color of the whole text, not only of the decoration.
|
||||||
// ColorRegistry registry = theme.getColorRegistry();
|
// TODO: figure out how to change the color of the decoration only.
|
||||||
// decoration.setForegroundColor(registry.get("org.eclipse.jdt.ui.ColoredLabels.decorations"));
|
// ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
|
||||||
|
// ColorRegistry registry = theme.getColorRegistry();
|
||||||
|
// decoration.setForegroundColor(
|
||||||
|
// registry.get("org.eclipse.jdt.ui.ColoredLabels.decorations")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLabelProperty(Object element, String property) {
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
// at this time return false.
|
// Property change do not affect the label
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,13 +97,11 @@ public class FolderDecorator implements ILightweightLabelDecorator {
|
|||||||
// No state change will affect the rendering.
|
// No state change will affect the rendering.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void removeListener(ILabelProviderListener listener) {
|
public void removeListener(ILabelProviderListener listener) {
|
||||||
// No state change will affect the rendering.
|
// No state change will affect the rendering.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
// nothind to dispose
|
// nothing to dispose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ public class AndroidConstants {
|
|||||||
|
|
||||||
/** Name of the manifest file, i.e. "AndroidManifest.xml". */
|
/** Name of the manifest file, i.e. "AndroidManifest.xml". */
|
||||||
public static final String FN_ANDROID_MANIFEST = "AndroidManifest.xml"; //$NON-NLS-1$
|
public static final String FN_ANDROID_MANIFEST = "AndroidManifest.xml"; //$NON-NLS-1$
|
||||||
public static final String FN_PROJECT_AIDL = "project.aidl"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/** Name of the android sources directory */
|
/** Name of the android sources directory */
|
||||||
public static final String FD_ANDROID_SOURCES = "sources"; //$NON-NLS-1$
|
public static final String FD_ANDROID_SOURCES = "sources"; //$NON-NLS-1$
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui,
|
|||||||
org.eclipse.jdt.launching,
|
org.eclipse.jdt.launching,
|
||||||
org.eclipse.ui.views,
|
org.eclipse.ui.views,
|
||||||
com.android.ide.eclipse.ddms
|
com.android.ide.eclipse.ddms
|
||||||
Eclipse-LazyStart: true
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-Vendor: The Android Open Source Project
|
Bundle-Vendor: The Android Open Source Project
|
||||||
Bundle-ClassPath: kxml2-2.3.0.jar,
|
Bundle-ClassPath: kxml2-2.3.0.jar,
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Eclipse Public License, Version 1.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
|
||||||
|
*
|
||||||
|
* 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.ide.eclipse.adt.launch;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class JUnitLaunchConfigDelegateTest extends TestCase {
|
||||||
|
|
||||||
|
public void testAbleToFetchJunitJar() throws IOException {
|
||||||
|
assertTrue(JUnitLaunchConfigDelegate.getJunitJarLocation().endsWith("junit.jar"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFixBootpathExtWithAndroidJar() {
|
||||||
|
String[][] testArray = {
|
||||||
|
null,
|
||||||
|
{ "android.jar"},
|
||||||
|
null,
|
||||||
|
{ "some_other_jar.jar" },
|
||||||
|
};
|
||||||
|
|
||||||
|
String[][] expectedArray = {
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ "some_other_jar.jar" },
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFixBootpathExtWithNoAndroidJar() {
|
||||||
|
String[][] testArray = {
|
||||||
|
null,
|
||||||
|
{ "somejar.jar"},
|
||||||
|
null,
|
||||||
|
};
|
||||||
|
|
||||||
|
String[][] expectedArray = {
|
||||||
|
null,
|
||||||
|
{ "somejar.jar"},
|
||||||
|
null,
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFixClasspathWithJunitJar() throws IOException {
|
||||||
|
String[] testArray = {
|
||||||
|
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] expectedArray = {
|
||||||
|
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEqualsArrays(expectedArray,
|
||||||
|
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFixClasspathWithoutJunitJar() throws IOException {
|
||||||
|
String[] testArray = {
|
||||||
|
"random.jar",
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] expectedArray = {
|
||||||
|
"random.jar",
|
||||||
|
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEqualsArrays(expectedArray,
|
||||||
|
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testFixClasspathWithNoJars() throws IOException {
|
||||||
|
String[] testArray = {
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] expectedArray = {
|
||||||
|
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||||
|
};
|
||||||
|
|
||||||
|
assertEqualsArrays(expectedArray,
|
||||||
|
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertEqualsArrays(String[][] a1, String[][] a2) {
|
||||||
|
assertTrue(Arrays.deepEquals(a1, a2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertEqualsArrays(String[] a1, String[] a2) {
|
||||||
|
assertTrue(Arrays.deepEquals(a1, a2));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,15 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.ide.eclipse.tests;
|
package com.android.ide.eclipse.tests;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for collecting all test cases in an eclipse plugin
|
* Class for collecting all test cases in an eclipse plugin
|
||||||
@@ -31,8 +30,6 @@ import java.util.logging.Logger;
|
|||||||
*/
|
*/
|
||||||
public class EclipseTestCollector {
|
public class EclipseTestCollector {
|
||||||
|
|
||||||
private static final Logger sLogger = Logger.getLogger(EclipseTestCollector.class.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -49,13 +46,13 @@ public class EclipseTestCollector {
|
|||||||
*/
|
*/
|
||||||
public void addTestCases(TestSuite suite, Plugin plugin, String expectedPackage) {
|
public void addTestCases(TestSuite suite, Plugin plugin, String expectedPackage) {
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
Enumeration entries = plugin.getBundle().findEntries("/", "*.class", true);
|
Enumeration<?> entries = plugin.getBundle().findEntries("/", "*.class", true);
|
||||||
|
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
URL entry = (URL)entries.nextElement();
|
URL entry = (URL)entries.nextElement();
|
||||||
String filePath = entry.getPath().replace(".class", "");
|
String filePath = entry.getPath().replace(".class", "");
|
||||||
try {
|
try {
|
||||||
Class testClass = getClass(filePath, expectedPackage);
|
Class<?> testClass = getClass(filePath, expectedPackage);
|
||||||
if (isTestClass(testClass)) {
|
if (isTestClass(testClass)) {
|
||||||
suite.addTestSuite(testClass);
|
suite.addTestSuite(testClass);
|
||||||
}
|
}
|
||||||
@@ -69,11 +66,11 @@ public class EclipseTestCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if given class shouk\ld be added to suite
|
* Returns true if given class should be added to suite
|
||||||
* @param testClass
|
* @param testClass
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected boolean isTestClass(Class testClass) {
|
protected boolean isTestClass(Class<?> testClass) {
|
||||||
return TestCase.class.isAssignableFrom(testClass) &&
|
return TestCase.class.isAssignableFrom(testClass) &&
|
||||||
Modifier.isPublic(testClass.getModifiers()) &&
|
Modifier.isPublic(testClass.getModifiers()) &&
|
||||||
hasPublicConstructor(testClass);
|
hasPublicConstructor(testClass);
|
||||||
@@ -84,7 +81,7 @@ public class EclipseTestCollector {
|
|||||||
* @param testClass
|
* @param testClass
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected boolean hasPublicConstructor(Class testClass) {
|
protected boolean hasPublicConstructor(Class<?> testClass) {
|
||||||
try {
|
try {
|
||||||
TestSuite.getTestConstructor(testClass);
|
TestSuite.getTestConstructor(testClass);
|
||||||
} catch(NoSuchMethodException e) {
|
} catch(NoSuchMethodException e) {
|
||||||
@@ -100,7 +97,7 @@ public class EclipseTestCollector {
|
|||||||
* @return
|
* @return
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
protected Class getClass(String filePath, String expectedPackage) throws ClassNotFoundException {
|
protected Class<?> getClass(String filePath, String expectedPackage) throws ClassNotFoundException {
|
||||||
String dotPath = filePath.replace('/', '.');
|
String dotPath = filePath.replace('/', '.');
|
||||||
// remove the output folders, by finding where package name starts
|
// remove the output folders, by finding where package name starts
|
||||||
int index = dotPath.indexOf(expectedPackage);
|
int index = dotPath.indexOf(expectedPackage);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class UnitTests {
|
|||||||
* Override parent class to exclude functional tests
|
* Override parent class to exclude functional tests
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean isTestClass(Class testClass) {
|
protected boolean isTestClass(Class<?> testClass) {
|
||||||
return super.isTestClass(testClass) &&
|
return super.isTestClass(testClass) &&
|
||||||
!testClass.getPackage().getName().startsWith(FuncTests.FUNC_TEST_PACKAGE);
|
!testClass.getPackage().getName().startsWith(FuncTests.FUNC_TEST_PACKAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.android.ide.eclipse.mock.FolderMock;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@@ -47,7 +46,6 @@ public class ConfigMatchTest extends TestCase {
|
|||||||
private FolderConfiguration config2;
|
private FolderConfiguration config2;
|
||||||
private FolderConfiguration config1;
|
private FolderConfiguration config1;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.android.ide.eclipse.editors.resources.configurations.FolderConfigurat
|
|||||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ public class QualifierListTest extends TestCase {
|
|||||||
mManager = null;
|
mManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void testQualifierList() {
|
public void testQualifierList() {
|
||||||
try {
|
try {
|
||||||
// get the list of qualifier in the resource manager
|
// get the list of qualifier in the resource manager
|
||||||
|
|||||||
@@ -424,11 +424,13 @@ public class FileMock implements IFile {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getPersistentProperties() throws CoreException {
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map getPersistentProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getSessionProperties() throws CoreException {
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map getSessionProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -428,11 +428,11 @@ public final class FolderMock implements IFolder {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getPersistentProperties() throws CoreException {
|
public Map<?,?> getPersistentProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getSessionProperties() throws CoreException {
|
public Map<?,?> getSessionProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class ProjectMock implements IProject {
|
public class ProjectMock implements IProject {
|
||||||
|
|
||||||
public void build(int kind, IProgressMonitor monitor) throws CoreException {
|
public void build(int kind, IProgressMonitor monitor) throws CoreException {
|
||||||
@@ -95,7 +96,6 @@ public class ProjectMock implements IProject {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public IPath getPluginWorkingLocation(IPluginDescriptor plugin) {
|
public IPath getPluginWorkingLocation(IPluginDescriptor plugin) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -459,6 +459,8 @@ public class ProjectMock implements IProject {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -476,11 +478,11 @@ public class ProjectMock implements IProject {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getPersistentProperties() throws CoreException {
|
public Map<?,?> getPersistentProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getSessionProperties() throws CoreException {
|
public Map<?,?> getSessionProperties() throws CoreException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,8 +127,7 @@ public class NinePatch {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mPatches.size() == 0 || mHorizontalPatches.size() == 0 ||
|
if (mPatches.size() == 0) {
|
||||||
mVerticalPatches.size() == 0) {
|
|
||||||
g.drawImage(mImage, x, y, scaledWidth, scaledHeight, null);
|
g.drawImage(mImage, x, y, scaledWidth, scaledHeight, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -254,6 +253,14 @@ public class NinePatch {
|
|||||||
start = rect.x;
|
start = rect.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int start = -1;
|
||||||
|
for (Rectangle rect : mPatches) {
|
||||||
|
if (rect.x > start) {
|
||||||
|
mHorizontalPatchesSum += rect.width;
|
||||||
|
start = rect.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mVerticalPatchesSum = 0;
|
mVerticalPatchesSum = 0;
|
||||||
@@ -265,6 +272,14 @@ public class NinePatch {
|
|||||||
start = rect.y;
|
start = rect.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int start = -1;
|
||||||
|
for (Rectangle rect : mPatches) {
|
||||||
|
if (rect.y > start) {
|
||||||
|
mVerticalPatchesSum += rect.height;
|
||||||
|
start = rect.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,27 +302,10 @@ public class NinePatch {
|
|||||||
Pair<List<Pair<Integer>>> left = getPatches(column, result);
|
Pair<List<Pair<Integer>>> left = getPatches(column, result);
|
||||||
mVerticalStartWithPatch = result[0];
|
mVerticalStartWithPatch = result[0];
|
||||||
|
|
||||||
// compute the min size, based on the list of fixed sections, which is stored in
|
|
||||||
// Pair.mFirst
|
|
||||||
mMinHeight = 0;
|
|
||||||
List<Pair<Integer>> fixedSections = left.mFirst;
|
|
||||||
for (Pair<Integer> section : fixedSections) {
|
|
||||||
mMinHeight += section.mSecond - section.mFirst;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = new boolean[1];
|
result = new boolean[1];
|
||||||
Pair<List<Pair<Integer>>> top = getPatches(row, result);
|
Pair<List<Pair<Integer>>> top = getPatches(row, result);
|
||||||
mHorizontalStartWithPatch = result[0];
|
mHorizontalStartWithPatch = result[0];
|
||||||
|
|
||||||
// compute the min size, based on the list of fixed sections, which is stored in
|
|
||||||
// Pair.mFirst
|
|
||||||
|
|
||||||
mMinWidth = 0;
|
|
||||||
fixedSections = top.mFirst;
|
|
||||||
for (Pair<Integer> section : fixedSections) {
|
|
||||||
mMinWidth += section.mSecond - section.mFirst;
|
|
||||||
}
|
|
||||||
|
|
||||||
mFixed = getRectangles(left.mFirst, top.mFirst);
|
mFixed = getRectangles(left.mFirst, top.mFirst);
|
||||||
mPatches = getRectangles(left.mSecond, top.mSecond);
|
mPatches = getRectangles(left.mSecond, top.mSecond);
|
||||||
|
|
||||||
@@ -315,7 +313,15 @@ public class NinePatch {
|
|||||||
mHorizontalPatches = getRectangles(left.mFirst, top.mSecond);
|
mHorizontalPatches = getRectangles(left.mFirst, top.mSecond);
|
||||||
mVerticalPatches = getRectangles(left.mSecond, top.mFirst);
|
mVerticalPatches = getRectangles(left.mSecond, top.mFirst);
|
||||||
} else {
|
} else {
|
||||||
mHorizontalPatches = mVerticalPatches = new ArrayList<Rectangle>(0);
|
if (top.mFirst.size() > 0) {
|
||||||
|
mHorizontalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
mVerticalPatches = getVerticalRectangles(top.mFirst);
|
||||||
|
} else if (left.mFirst.size() > 0) {
|
||||||
|
mHorizontalPatches = getHorizontalRectangles(left.mFirst);
|
||||||
|
mVerticalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
} else {
|
||||||
|
mHorizontalPatches = mVerticalPatches = new ArrayList<Rectangle>(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row = GraphicsUtilities.getPixels(mImage, 0, height - 1, width, 1, row);
|
row = GraphicsUtilities.getPixels(mImage, 0, height - 1, width, 1, row);
|
||||||
@@ -326,29 +332,28 @@ public class NinePatch {
|
|||||||
|
|
||||||
left = getPatches(column, result);
|
left = getPatches(column, result);
|
||||||
mVerticalPadding = getPadding(left.mFirst);
|
mVerticalPadding = getPadding(left.mFirst);
|
||||||
|
}
|
||||||
|
|
||||||
mHorizontalPatchesSum = 0;
|
private List<Rectangle> getVerticalRectangles(List<Pair<Integer>> topPairs) {
|
||||||
if (mHorizontalPatches.size() > 0) {
|
List<Rectangle> rectangles = new ArrayList<Rectangle>();
|
||||||
int start = -1;
|
for (Pair<Integer> top : topPairs) {
|
||||||
for (Rectangle rect : mHorizontalPatches) {
|
int x = top.mFirst;
|
||||||
if (rect.x > start) {
|
int width = top.mSecond - top.mFirst;
|
||||||
mHorizontalPatchesSum += rect.width;
|
|
||||||
start = rect.x;
|
rectangles.add(new Rectangle(x, 1, width, mImage.getHeight() - 2));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return rectangles;
|
||||||
|
}
|
||||||
|
|
||||||
mVerticalPatchesSum = 0;
|
private List<Rectangle> getHorizontalRectangles(List<Pair<Integer>> leftPairs) {
|
||||||
if (mVerticalPatches.size() > 0) {
|
List<Rectangle> rectangles = new ArrayList<Rectangle>();
|
||||||
int start = -1;
|
for (Pair<Integer> left : leftPairs) {
|
||||||
for (Rectangle rect : mVerticalPatches) {
|
int y = left.mFirst;
|
||||||
if (rect.y > start) {
|
int height = left.mSecond - left.mFirst;
|
||||||
mVerticalPatchesSum += rect.height;
|
|
||||||
start = rect.y;
|
rectangles.add(new Rectangle(1, y, mImage.getWidth() - 2, height));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return rectangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
|
private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
|
||||||
@@ -373,7 +378,7 @@ public class NinePatch {
|
|||||||
for (Pair<Integer> left : leftPairs) {
|
for (Pair<Integer> left : leftPairs) {
|
||||||
int y = left.mFirst;
|
int y = left.mFirst;
|
||||||
int height = left.mSecond - left.mFirst;
|
int height = left.mSecond - left.mFirst;
|
||||||
for (Pair<Integer> top: topPairs) {
|
for (Pair<Integer> top : topPairs) {
|
||||||
int x = top.mFirst;
|
int x = top.mFirst;
|
||||||
int width = top.mSecond - top.mFirst;
|
int width = top.mSecond - top.mFirst;
|
||||||
|
|
||||||
@@ -418,6 +423,7 @@ public class NinePatch {
|
|||||||
startWithPatch[0] = true;
|
startWithPatch[0] = true;
|
||||||
fixed.clear();
|
fixed.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<List<Pair<Integer>>>(fixed, patches);
|
return new Pair<List<Pair<Integer>>>(fixed, patches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user