From 47d60dbb856dcfbf36ce24f99d3213ac95032dce Mon Sep 17 00:00:00 2001 From: Illia Bershadskyi Date: Thu, 1 Nov 2012 13:24:45 +0200 Subject: [PATCH 1/7] basic functional for CustomTitle annotation --- .../annotations/CustomTitle.java | 19 ++++++++++ .../processing/CustomTitleProcessor.java | 28 ++++++++++++++ .../validation/CustomTitleValidator.java | 38 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java create mode 100644 AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java create mode 100644 AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java new file mode 100644 index 0000000000..68d161cd88 --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java @@ -0,0 +1,19 @@ +package com.googlecode.androidannotations.annotations; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Should be used on Activity classes that must have custom title layout. + * + * The activity must be annotated with {@link EActivity}. + * + */ +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface CustomTitle { + int value() default ResId.DEFAULT_VALUE; +} diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java new file mode 100644 index 0000000000..3e487154ba --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java @@ -0,0 +1,28 @@ +package com.googlecode.androidannotations.processing; + +import com.googlecode.androidannotations.annotations.CustomTitle; +import com.googlecode.androidannotations.annotations.Extra; +import com.googlecode.androidannotations.annotations.NoTitle; +import com.sun.codemodel.*; + +import javax.lang.model.element.Element; +import java.lang.annotation.Annotation; + + +public class CustomTitleProcessor implements DecoratingElementProcessor { + + @Override + public Class getTarget() { + return CustomTitle.class; + } + + @Override + public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { + CustomTitle annotation = element.getAnnotation(CustomTitle.class); + JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE"); + + holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature); + holder.init.body().invoke("setFeatureInt").arg(customTitleFeature).arg(JExpr.lit(annotation.value())); + } + +} \ No newline at end of file diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java new file mode 100644 index 0000000000..613c7cdeab --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java @@ -0,0 +1,38 @@ +package com.googlecode.androidannotations.validation; + +import com.googlecode.androidannotations.annotations.CustomTitle; +import com.googlecode.androidannotations.helper.IdAnnotationHelper; +import com.googlecode.androidannotations.helper.IdValidatorHelper; +import com.googlecode.androidannotations.model.AnnotationElements; +import com.googlecode.androidannotations.rclass.IRClass; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import java.lang.annotation.Annotation; + +public class CustomTitleValidator implements ElementValidator { + + private IdValidatorHelper validatorHelper; + + public CustomTitleValidator(ProcessingEnvironment processingEnv, IRClass rClass) { + IdAnnotationHelper annotationHelper = new IdAnnotationHelper(processingEnv, getTarget(), rClass); + validatorHelper = new IdValidatorHelper(annotationHelper); + } + + @Override + public Class getTarget() { + return CustomTitle.class; + } + + @Override + public boolean validate(Element element, AnnotationElements validatedElements) { + + IsValid valid = new IsValid(); + + validatorHelper.hasEActivity(element, validatedElements, valid); + validatorHelper.resIdsExist(element, IRClass.Res.ID, IdValidatorHelper.FallbackStrategy.NEED_RES_ID, valid); + validatorHelper.isNotFinal(element, valid); + + return valid.isValid(); + } +} From c74c8a8e924ba1b5a0daf1b656fbb06569d77fbc Mon Sep 17 00:00:00 2001 From: Illia Bershadskyi Date: Fri, 2 Nov 2012 14:52:09 +0200 Subject: [PATCH 2/7] almost working :-) --- .../androidannotations/processing/CustomTitleProcessor.java | 2 +- .../androidannotations/validation/CustomTitleValidator.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java index 3e487154ba..566f4cf97e 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java @@ -22,7 +22,7 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE"); holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature); - holder.init.body().invoke("setFeatureInt").arg(customTitleFeature).arg(JExpr.lit(annotation.value())); + holder.init.body().directStatement("getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, " + annotation.value() + ");"); } } \ No newline at end of file diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java index 613c7cdeab..a686cc1dfa 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java @@ -26,13 +26,13 @@ public Class getTarget() { @Override public boolean validate(Element element, AnnotationElements validatedElements) { - - IsValid valid = new IsValid(); +/* IsValid valid = new IsValid(); validatorHelper.hasEActivity(element, validatedElements, valid); validatorHelper.resIdsExist(element, IRClass.Res.ID, IdValidatorHelper.FallbackStrategy.NEED_RES_ID, valid); validatorHelper.isNotFinal(element, valid); - return valid.isValid(); + return valid.isValid();*/ + return true; } } From 6e69048a699d472b9ddc5710c2f478a94d6e181e Mon Sep 17 00:00:00 2001 From: Iliya Bershadskiy Date: Sun, 4 Nov 2012 12:11:53 +0200 Subject: [PATCH 3/7] Complete! --- .../processing/CustomTitleProcessor.java | 7 +++---- .../validation/CustomTitleValidator.java | 9 ++++----- .../test15/CustomTitleActivity.java | 11 +++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java index 566f4cf97e..9b361473bd 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java @@ -1,9 +1,8 @@ package com.googlecode.androidannotations.processing; import com.googlecode.androidannotations.annotations.CustomTitle; -import com.googlecode.androidannotations.annotations.Extra; -import com.googlecode.androidannotations.annotations.NoTitle; -import com.sun.codemodel.*; +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JFieldRef; import javax.lang.model.element.Element; import java.lang.annotation.Annotation; @@ -22,7 +21,7 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE"); holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature); - holder.init.body().directStatement("getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, " + annotation.value() + ");"); + holder.afterSetContentView.body().directStatement("getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, " + annotation.value() + ");"); } } \ No newline at end of file diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java index a686cc1dfa..531dd1840e 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java @@ -26,13 +26,12 @@ public Class getTarget() { @Override public boolean validate(Element element, AnnotationElements validatedElements) { -/* IsValid valid = new IsValid(); + IsValid valid = new IsValid(); validatorHelper.hasEActivity(element, validatedElements, valid); - validatorHelper.resIdsExist(element, IRClass.Res.ID, IdValidatorHelper.FallbackStrategy.NEED_RES_ID, valid); - validatorHelper.isNotFinal(element, valid); - return valid.isValid();*/ - return true; + validatorHelper.resIdsExist(element, IRClass.Res.LAYOUT, IdValidatorHelper.FallbackStrategy.NEED_RES_ID, valid); + + return valid.isValid(); } } diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java new file mode 100644 index 0000000000..b30d91b791 --- /dev/null +++ b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java @@ -0,0 +1,11 @@ +package com.googlecode.androidannotations.test15; + +import android.app.Activity; + +import com.googlecode.androidannotations.annotations.EActivity; +import com.googlecode.androidannotations.annotations.CustomTitle; + +@EActivity +@CustomTitle(R.layout.component) +public class CustomTitleActivity extends Activity { +} From 65b7fb4fb6a1d6090999ef17de6ec0b80a3c05de Mon Sep 17 00:00:00 2001 From: Iliya Bershadskiy Date: Sun, 4 Nov 2012 13:13:59 +0200 Subject: [PATCH 4/7] license information added --- .../annotations/CustomTitle.java | 15 +++++++++++++++ .../processing/CustomTitleProcessor.java | 15 +++++++++++++++ .../validation/CustomTitleValidator.java | 15 +++++++++++++++ .../test15/CustomTitleActivity.java | 15 +++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java index 68d161cd88..80981e6dda 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.androidannotations.annotations; diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java index 9b361473bd..45e391d785 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.androidannotations.processing; import com.googlecode.androidannotations.annotations.CustomTitle; diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java index 531dd1840e..e4d22bca8a 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java +++ b/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.androidannotations.validation; import com.googlecode.androidannotations.annotations.CustomTitle; diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java index b30d91b791..7009d0946e 100644 --- a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java +++ b/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.androidannotations.test15; import android.app.Activity; From 17937a0bdf55ea1b85922f59a961bb0c9138978f Mon Sep 17 00:00:00 2001 From: Illia Bershadskyi Date: Mon, 19 Nov 2012 14:01:39 +0200 Subject: [PATCH 5/7] CustomTitile fix --- ...droidannotations to org.androidannotations | 65 +++++++++++++++++++ .../annotations/CustomTitle.java | 4 +- ...droidannotations to org.androidannotations | 64 ++++++++++++++++++ .../AndroidAnnotationProcessor.java | 6 ++ .../processing/CustomTitleProcessor.java | 9 +-- .../validation/CustomTitleValidator.java | 12 ++-- ...droidannotations to org.androidannotations | 8 +++ ...droidannotations to org.androidannotations | 5 ++ .../test15/CustomTitleActivity.java | 6 +- 9 files changed, 164 insertions(+), 15 deletions(-) create mode 100644 AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations rename AndroidAnnotations/{androidannotations/src/main/java/com/googlecode => androidannotations-api/src/main/java/org}/androidannotations/annotations/CustomTitle.java (88%) create mode 100644 AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations rename AndroidAnnotations/androidannotations/src/main/java/{com/googlecode => org}/androidannotations/processing/CustomTitleProcessor.java (79%) rename AndroidAnnotations/androidannotations/src/main/java/{com/googlecode => org}/androidannotations/validation/CustomTitleValidator.java (79%) create mode 100644 AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations create mode 100644 AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations rename AndroidAnnotations/functional-test-1-5/src/main/java/{com/googlecode => org}/androidannotations/test15/CustomTitleActivity.java (78%) diff --git a/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations new file mode 100644 index 0000000000..439220027d --- /dev/null +++ b/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations @@ -0,0 +1,65 @@ +package com.googlecode.androidannotations.api; +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.googlecode.androidannotations-api"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java similarity index 88% rename from AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java rename to AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java index 80981e6dda..802d8dae48 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/annotations/CustomTitle.java +++ b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.googlecode.androidannotations.annotations; +package org.androidannotations.annotations; import java.lang.annotation.ElementType; @@ -30,5 +30,5 @@ @Retention(RetentionPolicy.CLASS) @Target(ElementType.TYPE) public @interface CustomTitle { - int value() default ResId.DEFAULT_VALUE; + int value(); } diff --git a/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations new file mode 100644 index 0000000000..0e44ab39d0 --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2010-2012 eBusiness Information, Excilys Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed To in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.androidannotations; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.googlecode.androidannotations"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java index 8019d074f3..c236220adb 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java @@ -62,6 +62,7 @@ import org.androidannotations.annotations.ItemSelect; import org.androidannotations.annotations.LongClick; import org.androidannotations.annotations.NoTitle; +import org.androidannotations.annotations.CustomTitle; import org.androidannotations.annotations.NonConfigurationInstance; import org.androidannotations.annotations.OnActivityResult; import org.androidannotations.annotations.OptionsItem; @@ -148,6 +149,7 @@ import org.androidannotations.processing.ModelProcessor; import org.androidannotations.processing.ModelProcessor.ProcessResult; import org.androidannotations.processing.NoTitleProcessor; +import org.androidannotations.processing.CustomTitleProcessor; import org.androidannotations.processing.NonConfigurationInstanceProcessor; import org.androidannotations.processing.OnActivityResultProcessor; import org.androidannotations.processing.OptionsItemProcessor; @@ -211,6 +213,7 @@ import org.androidannotations.validation.LongClickValidator; import org.androidannotations.validation.ModelValidator; import org.androidannotations.validation.NoTitleValidator; +import org.androidannotations.validation.CustomTitleValidator; import org.androidannotations.validation.NonConfigurationInstanceValidator; import org.androidannotations.validation.OnActivityResultValidator; import org.androidannotations.validation.OptionsItemValidator; @@ -290,6 +293,7 @@ OptionsItem.class, // HtmlRes.class, // NoTitle.class, // + CustomTitle.class, // Fullscreen.class, // RestService.class, // EBean.class, // @@ -462,6 +466,7 @@ private ModelValidator buildModelValidator(IRClass rClass, AndroidSystemServices modelValidator.register(new OptionsMenuValidator(processingEnv, rClass)); modelValidator.register(new OptionsItemValidator(processingEnv, rClass)); modelValidator.register(new NoTitleValidator(processingEnv)); + modelValidator.register(new CustomTitleValidator(processingEnv, rClass)); modelValidator.register(new FullscreenValidator(processingEnv)); modelValidator.register(new RestServiceValidator(processingEnv)); modelValidator.register(new RootContextValidator(processingEnv)); @@ -550,6 +555,7 @@ private ModelProcessor buildModelProcessor(IRClass rClass, AndroidSystemServices modelProcessor.register(new OptionsMenuProcessor(processingEnv, rClass)); modelProcessor.register(new OptionsItemProcessor(processingEnv, rClass)); modelProcessor.register(new NoTitleProcessor()); + modelProcessor.register(new CustomTitleProcessor()); modelProcessor.register(new FullscreenProcessor()); modelProcessor.register(new RestServiceProcessor()); modelProcessor.register(new OrmLiteDaoProcessor(processingEnv)); diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java similarity index 79% rename from AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java rename to AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java index 45e391d785..db24c6f399 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/processing/CustomTitleProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java @@ -13,15 +13,17 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.googlecode.androidannotations.processing; +package org.androidannotations.processing; -import com.googlecode.androidannotations.annotations.CustomTitle; +import org.androidannotations.annotations.CustomTitle; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JFieldRef; import javax.lang.model.element.Element; import java.lang.annotation.Annotation; +import static com.sun.codemodel.JExpr.lit; + public class CustomTitleProcessor implements DecoratingElementProcessor { @@ -36,7 +38,6 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE"); holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature); - holder.afterSetContentView.body().directStatement("getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, " + annotation.value() + ");"); + holder.afterSetContentView.body().add(holder.contextRef.invoke("getWindow").invoke("setFeatureInt").arg(customTitleFeature).arg(lit(annotation.value()))); } - } \ No newline at end of file diff --git a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/CustomTitleValidator.java similarity index 79% rename from AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java rename to AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/CustomTitleValidator.java index e4d22bca8a..bda05c191c 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/validation/CustomTitleValidator.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/validation/CustomTitleValidator.java @@ -13,13 +13,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.googlecode.androidannotations.validation; +package org.androidannotations.validation; -import com.googlecode.androidannotations.annotations.CustomTitle; -import com.googlecode.androidannotations.helper.IdAnnotationHelper; -import com.googlecode.androidannotations.helper.IdValidatorHelper; -import com.googlecode.androidannotations.model.AnnotationElements; -import com.googlecode.androidannotations.rclass.IRClass; +import org.androidannotations.annotations.CustomTitle; +import org.androidannotations.helper.IdAnnotationHelper; +import org.androidannotations.helper.IdValidatorHelper; +import org.androidannotations.model.AnnotationElements; +import org.androidannotations.rclass.IRClass; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; diff --git a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations new file mode 100644 index 0000000000..cda38a6ad3 --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations @@ -0,0 +1,8 @@ +package com.googlecode.androidannotations.ebean; + +import com.googlecode.androidannotations.annotations.EBean; + +@EBean +public class SomeImplementation implements SomeInterface { + +} diff --git a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations new file mode 100644 index 0000000000..f68a014414 --- /dev/null +++ b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations @@ -0,0 +1,5 @@ +package com.googlecode.androidannotations.ebean; + +public interface SomeInterface { + +} diff --git a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java similarity index 78% rename from AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java rename to AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java index 7009d0946e..6abca565a7 100644 --- a/AndroidAnnotations/functional-test-1-5/src/main/java/com/googlecode/androidannotations/test15/CustomTitleActivity.java +++ b/AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/CustomTitleActivity.java @@ -13,12 +13,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.googlecode.androidannotations.test15; +package org.androidannotations.test15; import android.app.Activity; -import com.googlecode.androidannotations.annotations.EActivity; -import com.googlecode.androidannotations.annotations.CustomTitle; +import org.androidannotations.annotations.EActivity; +import org.androidannotations.annotations.CustomTitle; @EActivity @CustomTitle(R.layout.component) From 35b94f4824f66e22afae8554e645678f0844baaa Mon Sep 17 00:00:00 2001 From: Illia Bershadskyi Date: Mon, 19 Nov 2012 14:04:42 +0200 Subject: [PATCH 6/7] Removed unnecessary files --- ...droidannotations to org.androidannotations | 65 ------------------- ...droidannotations to org.androidannotations | 64 ------------------ ...droidannotations to org.androidannotations | 8 --- ...droidannotations to org.androidannotations | 5 -- 4 files changed, 142 deletions(-) delete mode 100644 AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations delete mode 100644 AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations delete mode 100644 AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations delete mode 100644 AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations diff --git a/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations deleted file mode 100644 index 439220027d..0000000000 --- a/AndroidAnnotations/androidannotations-api/src/main/eclipse/org/androidannotations/api/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations +++ /dev/null @@ -1,65 +0,0 @@ -package com.googlecode.androidannotations.api; -/** - * Copyright (C) 2010-2012 eBusiness Information, Excilys Group - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed To in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends Plugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.googlecode.androidannotations-api"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } -} diff --git a/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations deleted file mode 100644 index 0e44ab39d0..0000000000 --- a/AndroidAnnotations/androidannotations/src/main/eclipse/org/androidannotations/Activator.java~Moved files from com.googlecode.androidannotations to org.androidannotations +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2010-2012 eBusiness Information, Excilys Group - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed To in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.googlecode.androidannotations; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends Plugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.googlecode.androidannotations"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } -} diff --git a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations deleted file mode 100644 index cda38a6ad3..0000000000 --- a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeImplementation.java~Moved files from com.googlecode.androidannotations to org.androidannotations +++ /dev/null @@ -1,8 +0,0 @@ -package com.googlecode.androidannotations.ebean; - -import com.googlecode.androidannotations.annotations.EBean; - -@EBean -public class SomeImplementation implements SomeInterface { - -} diff --git a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations b/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations deleted file mode 100644 index f68a014414..0000000000 --- a/AndroidAnnotations/androidannotations/src/test/java/org/androidannotations/ebean/SomeInterface.java~Moved files from com.googlecode.androidannotations to org.androidannotations +++ /dev/null @@ -1,5 +0,0 @@ -package com.googlecode.androidannotations.ebean; - -public interface SomeInterface { - -} From f61c956ee0a71c27bd0dd8b24a27d5436453d230 Mon Sep 17 00:00:00 2001 From: Illia Bershadskyi Date: Fri, 23 Nov 2012 17:44:36 +0200 Subject: [PATCH 7/7] Updated JavaDoc; Added output of R field in processor --- .../annotations/CustomTitle.java | 2 +- .../AndroidAnnotationProcessor.java | 2 +- .../processing/CustomTitleProcessor.java | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java index 802d8dae48..6b436ced50 100644 --- a/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java +++ b/AndroidAnnotations/androidannotations-api/src/main/java/org/androidannotations/annotations/CustomTitle.java @@ -22,7 +22,7 @@ import java.lang.annotation.Target; /** - * Should be used on Activity classes that must have custom title layout. + * Use it on activities to set a custom title layout. * * The activity must be annotated with {@link EActivity}. * diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java index c236220adb..cc0342435e 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/AndroidAnnotationProcessor.java @@ -555,7 +555,7 @@ private ModelProcessor buildModelProcessor(IRClass rClass, AndroidSystemServices modelProcessor.register(new OptionsMenuProcessor(processingEnv, rClass)); modelProcessor.register(new OptionsItemProcessor(processingEnv, rClass)); modelProcessor.register(new NoTitleProcessor()); - modelProcessor.register(new CustomTitleProcessor()); + modelProcessor.register(new CustomTitleProcessor(processingEnv, rClass)); modelProcessor.register(new FullscreenProcessor()); modelProcessor.register(new RestServiceProcessor()); modelProcessor.register(new OrmLiteDaoProcessor(processingEnv)); diff --git a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java index db24c6f399..88d621a363 100644 --- a/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java +++ b/AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/CustomTitleProcessor.java @@ -18,14 +18,22 @@ import org.androidannotations.annotations.CustomTitle; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JFieldRef; +import org.androidannotations.helper.AnnotationHelper; +import org.androidannotations.rclass.IRClass; +import org.androidannotations.rclass.IRClass.Res; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import java.lang.annotation.Annotation; -import static com.sun.codemodel.JExpr.lit; - - public class CustomTitleProcessor implements DecoratingElementProcessor { + private final AnnotationHelper annotationHelper; + private final IRClass rClass; + + public CustomTitleProcessor(ProcessingEnvironment processingEnv, IRClass rClass) { + annotationHelper = new AnnotationHelper(processingEnv); + this.rClass = rClass; + } @Override public Class getTarget() { @@ -34,10 +42,10 @@ public Class getTarget() { @Override public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { - CustomTitle annotation = element.getAnnotation(CustomTitle.class); JFieldRef customTitleFeature = holder.classes().WINDOW.staticRef("FEATURE_CUSTOM_TITLE"); holder.init.body().invoke("requestWindowFeature").arg(customTitleFeature); - holder.afterSetContentView.body().add(holder.contextRef.invoke("getWindow").invoke("setFeatureInt").arg(customTitleFeature).arg(lit(annotation.value()))); + JFieldRef contentViewId = annotationHelper.extractAnnotationFieldRefs(holder, element, CustomTitle.class, rClass.get(Res.LAYOUT), false).get(0); + holder.afterSetContentView.body().add(holder.contextRef.invoke("getWindow").invoke("setFeatureInt").arg(customTitleFeature).arg(contentViewId)); } } \ No newline at end of file