Author: bobtarling
Date: 2010-03-25 11:46:25-0700
New Revision: 18168

Added:
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigateNextAction.java
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigatePreviousAction.java

Log:
Reinstate buttons to traverse siblings

Added: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigateNextAction.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigateNextAction.java?view=markup&pathrev=18168
==============================================================================
--- (empty file)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigateNextAction.java
     2010-03-25 11:46:25-0700
@@ -0,0 +1,65 @@
+/* $Id$
+ 
*******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * 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
+ *
+ * Contributors:
+ *    Bob Tarling
+ 
*******************************************************************************
+ */
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+
+/**
+ * This action changes the target to the owning model element
+ * of the given element.
+ *
+ * @author Bob Tarling
+ */
+class NavigateNextAction extends AbstractAction {
+
+    final Object modelElement;
+    
+    public NavigateNextAction(Object modelElement) {
+        super(Translator.localize("action.navigate-forward"),
+                ResourceLoaderWrapper.lookupIcon("action.navigate-forward"));
+        
+        this.modelElement = modelElement;
+    }
+    public void actionPerformed(ActionEvent arg0) {
+        final Object owner =
+            Model.getFacade().getModelElementContainer(modelElement);
+        Object newTarget = null;
+        List list = null;
+        if (Model.getFacade().isAAttribute(modelElement)) {
+            list = Model.getFacade().getAttributes(owner);
+        }
+        if (Model.getFacade().isAOperation(modelElement)
+                || Model.getFacade().isAReception(modelElement)) {
+            list = Model.getFacade().getOperationsAndReceptions(owner);
+        }
+        if (Model.getFacade().isAParameter(modelElement)) {
+            list = Model.getFacade().getParametersList(owner);
+        }
+        if (list != null) {
+            final int posn = list.indexOf(modelElement);
+            if (posn >= 0 && posn < list.size() - 1) {
+                newTarget = list.get(posn + 1);
+                TargetManager.getInstance().setTarget(newTarget);
+            }
+        }
+    }
+}

Added: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigatePreviousAction.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigatePreviousAction.java?view=markup&pathrev=18168
==============================================================================
--- (empty file)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/NavigatePreviousAction.java
 2010-03-25 11:46:25-0700
@@ -0,0 +1,66 @@
+/* $Id$
+ 
*******************************************************************************
+ * Copyright (c) 2010 Contributors - see below
+ * 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
+ *
+ * Contributors:
+ *    Bob Tarling
+ 
*******************************************************************************
+ */
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+
+/**
+ * This action changes the target to the owning model element
+ * of the given element.
+ *
+ * @author Bob Tarling
+ */
+class NavigatePreviousAction extends AbstractAction {
+
+    final Object modelElement;
+    
+    public NavigatePreviousAction(Object modelElement) {
+        super(Translator.localize("action.navigate-forward"),
+                ResourceLoaderWrapper.lookupIcon("action.navigate-back"));
+        
+        this.modelElement = modelElement;
+    }
+    public void actionPerformed(ActionEvent arg0) {
+        final Object owner =
+            Model.getFacade().getModelElementContainer(modelElement);
+        Object newTarget = null;
+        List list = null;
+        if (Model.getFacade().isAAttribute(modelElement)) {
+            list = Model.getFacade().getAttributes(owner);
+        }
+        if (Model.getFacade().isAOperation(modelElement)
+                || Model.getFacade().isAReception(modelElement)) {
+            list = Model.getFacade().getOperationsAndReceptions(owner);
+        }
+        if (Model.getFacade().isAParameter(modelElement)) {
+            list = Model.getFacade().getParametersList(owner);
+        }
+        if (list != null) {
+            final int posn = list.indexOf(modelElement);
+            if (posn > 0) {
+                newTarget = list.get(posn - 1);
+                TargetManager.getInstance().setTarget(newTarget);
+            }
+        }
+    }
+
+}

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2465074

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to