]> source.dussan.org Git - aspectj.git/commitdiff
298704
authoraclement <aclement>
Mon, 25 Jan 2010 20:45:34 +0000 (20:45 +0000)
committeraclement <aclement>
Mon, 25 Jan 2010 20:45:34 +0000 (20:45 +0000)
tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/annotation/View.java [new file with mode: 0644]
tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/AbstractViewEnhancerAspect.aj [new file with mode: 0644]
tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IManagedView.java [new file with mode: 0644]
tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IPresenter.java [new file with mode: 0644]
tests/multiIncremental/pr298704_testaspects/base/src/test/ViewEnhancerIntegrationTest.java [new file with mode: 0644]

diff --git a/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/annotation/View.java b/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/annotation/View.java
new file mode 100644 (file)
index 0000000..c69ae71
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2009 Collaborative Development Group, C.S. Dept., University of Bari
+ *
+ * All rights reserved. This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package it.uniba.di.cdg.penelope.ui.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marks views to be injected.
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Inherited
+public @interface View {
+}
diff --git a/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/AbstractViewEnhancerAspect.aj b/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/AbstractViewEnhancerAspect.aj
new file mode 100644 (file)
index 0000000..80dd465
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
+ *
+ * All rights reserved. This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package it.uniba.di.cdg.penelope.ui.mvp;
+
+import it.uniba.di.cdg.penelope.ui.annotation.View;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Augments views with support for View events.
+ */
+public abstract aspect AbstractViewEnhancerAspect {
+       pointcut scope(); 
+       
+       declare parents: (@View *) implements IManagedView;
+
+       private final List<IPresenter> IManagedView.presenters = new ArrayList<IPresenter>(); 
+       
+       public void IManagedView.fire( Object event ) {
+               for (IPresenter presenter : presenters) {
+                       presenter.dispatchEvent( event );
+               }
+       }
+       
+       public void IManagedView.registerPresenter( IPresenter presenter ) {
+               presenters.add( presenter );
+       }
+       
+       public void IManagedView.unregisterPresenter( IPresenter presenter ) {
+               presenters.remove( presenter );
+       }       
+}
diff --git a/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IManagedView.java b/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IManagedView.java
new file mode 100644 (file)
index 0000000..7be1568
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
+ *
+ * All rights reserved. This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package it.uniba.di.cdg.penelope.ui.mvp;
+
+/**
+ * 
+ */
+public interface IManagedView {
+       void fire( Object event );
+       
+       void registerPresenter( IPresenter presenter );
+       
+       void unregisterPresenter( IPresenter presenter );
+}
diff --git a/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IPresenter.java b/tests/multiIncremental/pr298704_baseaspects/base/src/it/uniba/di/cdg/penelope/ui/mvp/IPresenter.java
new file mode 100644 (file)
index 0000000..6cdb46d
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
+ *
+ * All rights reserved. This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package it.uniba.di.cdg.penelope.ui.mvp;
+
+import java.beans.PropertyChangeListener;
+
+/**
+ * Basic interface for <strong>Presenter</strong> implementations. Within Penelope, a Presenter is a supervising controller 
+ * which reacts to view events (see the View Events mechanism): the view just displays the session state stored within
+ * the <strong>Presentation Model</strong>.
+ */
+public interface IPresenter extends PropertyChangeListener {
+       /**
+        * View has been created.
+        */
+       void onViewCreated(); 
+
+       /**
+        * View has been destroyed.
+        */
+       void onViewDisposed();
+
+       /**
+        * @param event
+        */
+       void dispatchEvent( Object event );
+}
diff --git a/tests/multiIncremental/pr298704_testaspects/base/src/test/ViewEnhancerIntegrationTest.java b/tests/multiIncremental/pr298704_testaspects/base/src/test/ViewEnhancerIntegrationTest.java
new file mode 100644 (file)
index 0000000..a10ddd0
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2009  Collaborative Development Group, C.S. Dept., University of Bari
+ *
+ * All rights reserved. This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package test;
+
+import it.uniba.di.cdg.penelope.ui.annotation.View;
+import it.uniba.di.cdg.penelope.ui.mvp.IManagedView;
+import it.uniba.di.cdg.penelope.ui.mvp.AbstractViewEnhancerAspect;
+
+/**
+ * 
+ */
+public class ViewEnhancerIntegrationTest {
+
+@View
+       public static class MockView {
+               
+       }
+       
+       static aspect ViewEnhancerAspect extends AbstractViewEnhancerAspect {
+               pointcut scope() : within( test.ViewEnhancerIntegrationTest );
+       }
+       
+       public void simulateViewCreation() {
+       }
+       
+       public void shouldAugmentView() {
+               //given @View class has been augmented
+
+               //when
+               MockView view = new MockView(); 
+               
+               //then
+       //      assertTrue( view instanceof IManagedView );
+       }
+}