--- /dev/null
+/**
+ * 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 {
+}
--- /dev/null
+/**
+ * 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 );
+ }
+}
--- /dev/null
+/**
+ * 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 );
+}
--- /dev/null
+/**
+ * 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 );
+}
--- /dev/null
+/**
+ * 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 );
+ }
+}