Author: b00__1
Date: 2007-07-15 08:21:46-0700
New Revision: 13077
Added:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/RootContainerAdapter.java (contents, props changed)
Modified:
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java
branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java
Log:
Implemented an Adapter that listens notifications from the UML elements contained in a root container.
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java?view=diff&rev=13077&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java&r1=13076&r2=13077
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/EUMLModelImplementation.java 2007-07-15 08:21:46-0700
@@ -165,7 +165,7 @@
private MetaTypes theMetaTypes;
- private ModelEventPump theModelEventPump;
+ private ModelEventPumpEUMLImpl theModelEventPump;
private ModelManagementFactory theModelManagementFactory;
@@ -440,7 +440,7 @@
return theMetaTypes;
}
- public ModelEventPump getModelEventPump() {
+ public ModelEventPumpEUMLImpl getModelEventPump() {
if (theModelEventPump == null) {
theModelEventPump = new ModelEventPumpEUMLImpl(this);
}
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java?view=diff&rev=13077&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java&r1=13076&r2=13077
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelEventPumpEUMLImpl.java 2007-07-15 08:21:46-0700
@@ -29,6 +29,7 @@
import java.beans.PropertyChangeListener;
import org.argouml.model.ModelEventPump;
+import org.eclipse.emf.common.notify.Notifier;
/**
* The implementation of the ModelEventPump for EUML2.
@@ -39,6 +40,10 @@
* The model implementation.
*/
private EUMLModelImplementation modelImpl;
+
+ private Notifier rootContainer;
+
+ private RootContainerAdapter rootContainerAdapter;
/**
* Constructor.
@@ -49,6 +54,13 @@
public ModelEventPumpEUMLImpl(EUMLModelImplementation implementation) {
modelImpl = implementation;
}
+
+ public void setRootContainer(Notifier container) {
+ if (rootContainerAdapter == null) {
+ rootContainerAdapter = new RootContainerAdapter();
+ }
+ rootContainerAdapter.setRootContainer(container);
+ }
public void addClassModelEventListener(PropertyChangeListener listener,
Object modelClass, String[] propertyNames) {
Modified: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java?view=diff&rev=13077&p1=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java&p2=branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java&r1=13076&r2=13077
==============================================================================
--- branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java (original)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/ModelManagementFactoryEUMLImpl.java 2007-07-15 08:21:46-0700
@@ -113,6 +113,7 @@
+ rootModel.getClass().getName());
}
theRootModel = (org.eclipse.uml2.uml.Package) rootModel;
+ modelImpl.getModelEventPump().setRootContainer(theRootModel);
}
public org.eclipse.uml2.uml.Package getRootModel() {
Added: branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/RootContainerAdapter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/RootContainerAdapter.java?view=auto&rev=13077
==============================================================================
--- (empty file)
+++ branches/gsoc2007/b00__1/model-euml/src/org/argouml/model/euml/RootContainerAdapter.java 2007-07-15 08:21:46-0700
@@ -0,0 +1,95 @@
+// $Id$
+// Copyright (c) 2007, The ArgoUML Project
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the ArgoUML Project nor the
+// names of its contributors may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE ArgoUML PROJECT ``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE ArgoUML PROJECT BE LIABLE FOR ANY
+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package org.argouml.model.euml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+
+/**
+ * Maintains a list of notifiers descendants of the root container that are
+ * firing events to this adapter.
+ *
+ * @author Bogdan Pistol
+ */
+public class RootContainerAdapter extends EContentAdapter {
+
+ private List<Notifier> notifiers = new ArrayList<Notifier>();
+
+ private Notifier rootContainer;
+
+ /**
+ * Setter for the root container
+ * @param n the new root container
+ */
+ public void setRootContainer(Notifier n) {
+ if (n == rootContainer) {
+ return;
+ }
+
+ removeAllAdapters();
+ if (n != null) {
+ rootContainer = n;
+ rootContainer.eAdapters().add(this);
+ }
+ }
+
+ @Override
+ protected void addAdapter(Notifier notifier) {
+ notifiers.add(notifier);
+ super.addAdapter(notifier);
+ }
+
+ @Override
+ protected void removeAdapter(Notifier notifier) {
+ notifiers.remove(notifier);
+ super.removeAdapter(notifier);
+ }
+
+ /**
+ * Removes this listener from all the notifiers' eAdapters list.
+ */
+ public void removeAllAdapters() {
+ for (Notifier n : notifiers) {
+ super.removeAdapter(n);
+ }
+ if (rootContainer != null) {
+ super.removeAdapter(rootContainer);
+ rootContainer = null;
+ }
+ notifiers.clear();
+ }
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ super.notifyChanged(notification);
+ }
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.