From 2b5c73d2fb943122724ab81c4d2cba0e909dd8da Mon Sep 17 00:00:00 2001 From: Ryan Mcilnay Date: Thu, 30 Apr 2020 09:29:44 -0500 Subject: [PATCH 1/4] ge aadl properties of refined elements fix --- .../ChangeSubcomponentTypePropertySection.java | 17 +++++++---------- ...tchDirectionOfConnectionPropertySection.java | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java index 33ddcab09ec..7a805d575f7 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -49,6 +49,7 @@ import org.osate.aadl2.Subcomponent; import org.osate.ge.BusinessObjectSelection; import org.osate.ge.internal.ui.util.InternalPropertySectionUtil; +import org.osate.ge.internal.util.AadlHelper; import org.osate.ge.internal.util.AgeEmfUtil; import org.osate.ge.internal.util.StringUtil; import org.osate.ge.internal.util.SubcomponentUtil; @@ -140,11 +141,7 @@ public void refresh() { } private static boolean isCompatibleSupcomponentType(final NamedElement ne, final EClass subcomponentType) { - Subcomponent sc = (Subcomponent) ne; - if (sc.getRefined() != null) { - sc = sc.getRefined(); - } - + final Subcomponent sc = (Subcomponent) AadlHelper.getRootRefinedElement(ne); final ComponentImplementation ci = (ComponentImplementation) sc.getContainingClassifier(); return SubcomponentUtil.canContainSubcomponentType(ci, subcomponentType) && (sc.getRefined() == null || sc.getRefined() instanceof AbstractSubcomponent); diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/SwitchDirectionOfConnectionPropertySection.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/SwitchDirectionOfConnectionPropertySection.java index 9bd0b0c0934..572ebbf9f91 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/SwitchDirectionOfConnectionPropertySection.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/SwitchDirectionOfConnectionPropertySection.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -48,6 +48,7 @@ import org.osate.aadl2.ParameterConnection; import org.osate.ge.BusinessObjectSelection; import org.osate.ge.internal.ui.util.InternalPropertySectionUtil; +import org.osate.ge.internal.util.AadlHelper; import org.osate.ge.ui.properties.PropertySectionUtil; public class SwitchDirectionOfConnectionPropertySection extends AbstractPropertySection { @@ -102,11 +103,7 @@ public void widgetSelected(final SelectionEvent e) { }; private static Connection getEditConnection(final Connection connection) { - if (connection.getRefined() != null) { - return connection.getRefined(); - } - - return connection; + return (Connection) AadlHelper.getRootRefinedElement(connection); } @Override From 998732127227dd358113f84aa84bd61e14a63f59 Mon Sep 17 00:00:00 2001 From: Ryan Mcilnay Date: Tue, 5 May 2020 10:22:00 -0500 Subject: [PATCH 2/4] fix properties view for refined elements --- .../properties/ChangeSubcomponentTypePropertySection.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java index 7a805d575f7..423a31ea555 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java @@ -95,7 +95,7 @@ public void widgetSelected(final SelectionEvent e) { AgeEmfUtil.transferStructuralFeatureValues(sc, SubcomponentUtil.createSubcomponent(ci, scTypeElement.getType())); -// Remove the old object + // Remove the old object EcoreUtil.remove(sc); }); } @@ -125,13 +125,13 @@ public void refresh() { final Consumer addSubcomponentTypeElement = (type) -> subcomponentTypeOptions .add(new SubcomponentTypeElement(type)); -// Get comboviewer selected value and populate available type options for comboviewer + // Get comboviewer selected value and populate available type options for comboviewer selectedScType = InternalPropertySectionUtil.getTypeOptionsInformation(selectedSubcomponenents, SubcomponentUtil.getSubcomponentTypes(), (sc, type) -> isCompatibleSupcomponentType(sc, type), addSubcomponentTypeElement); comboViewer.setInput(subcomponentTypeOptions); -// Set comboviewer selection + // Set comboviewer selection if (selectedScType != null) { subcomponentTypeOptions.stream().filter(scTypeElement -> selectedScType == scTypeElement.getType()) .findAny().ifPresent(scTypeElement -> { From 59768fbc2c9ddce837f28c3b4f88eda14e22e187 Mon Sep 17 00:00:00 2001 From: Ryan Mcilnay Date: Tue, 5 May 2020 10:49:06 -0500 Subject: [PATCH 3/4] ge fix properties view for refined elements --- .../ui/properties/ChangeSubcomponentTypePropertySection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java index 423a31ea555..b71b01efa8d 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java @@ -127,7 +127,7 @@ public void refresh() { // Get comboviewer selected value and populate available type options for comboviewer selectedScType = InternalPropertySectionUtil.getTypeOptionsInformation(selectedSubcomponenents, - SubcomponentUtil.getSubcomponentTypes(), (sc, type) -> isCompatibleSupcomponentType(sc, type), + SubcomponentUtil.getSubcomponentTypes(), (sc, type) -> isCompatibleSubcomponentType(sc, type), addSubcomponentTypeElement); comboViewer.setInput(subcomponentTypeOptions); @@ -140,7 +140,7 @@ public void refresh() { } } - private static boolean isCompatibleSupcomponentType(final NamedElement ne, final EClass subcomponentType) { + private static boolean isCompatibleSubcomponentType(final NamedElement ne, final EClass subcomponentType) { final Subcomponent sc = (Subcomponent) AadlHelper.getRootRefinedElement(ne); final ComponentImplementation ci = (ComponentImplementation) sc.getContainingClassifier(); return SubcomponentUtil.canContainSubcomponentType(ci, subcomponentType) From 2f8e0afd7ce2fc1ae91094a34fa83cf3210f4955 Mon Sep 17 00:00:00 2001 From: Ryan Mcilnay Date: Fri, 8 May 2020 08:59:38 -0500 Subject: [PATCH 4/4] ge fixed refined subcomponent properties --- ...ChangeSubcomponentTypePropertySection.java | 14 ++++++-------- .../ui/util/InternalPropertySectionUtil.java | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java index b71b01efa8d..52f458bc02d 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/properties/ChangeSubcomponentTypePropertySection.java @@ -45,11 +45,9 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.osate.aadl2.AbstractSubcomponent; import org.osate.aadl2.ComponentImplementation; -import org.osate.aadl2.NamedElement; import org.osate.aadl2.Subcomponent; import org.osate.ge.BusinessObjectSelection; import org.osate.ge.internal.ui.util.InternalPropertySectionUtil; -import org.osate.ge.internal.util.AadlHelper; import org.osate.ge.internal.util.AgeEmfUtil; import org.osate.ge.internal.util.StringUtil; import org.osate.ge.internal.util.SubcomponentUtil; @@ -118,7 +116,7 @@ public void setInput(final IWorkbenchPart part, final ISelection selection) { @Override public void refresh() { - final Set selectedSubcomponenents = selectedBos.boStream(NamedElement.class) + final Set selectedSubcomponenents = selectedBos.boStream(Subcomponent.class) .collect(Collectors.toSet()); final Set subcomponentTypeOptions = new HashSet<>(); // Add to options @@ -140,11 +138,11 @@ public void refresh() { } } - private static boolean isCompatibleSubcomponentType(final NamedElement ne, final EClass subcomponentType) { - final Subcomponent sc = (Subcomponent) AadlHelper.getRootRefinedElement(ne); - final ComponentImplementation ci = (ComponentImplementation) sc.getContainingClassifier(); - return SubcomponentUtil.canContainSubcomponentType(ci, subcomponentType) - && (sc.getRefined() == null || sc.getRefined() instanceof AbstractSubcomponent); + private static boolean isCompatibleSubcomponentType(final Subcomponent sc, final EClass subcomponentType) { + final ComponentImplementation ci = sc.getContainingComponentImpl(); + return (SubcomponentUtil.canContainSubcomponentType(ci, subcomponentType) + && (sc.getRefined() == null || sc.getRefined() instanceof AbstractSubcomponent)) + || subcomponentType == sc.eClass(); } private class SubcomponentTypeElement { diff --git a/ge/org.osate.ge/src/org/osate/ge/internal/ui/util/InternalPropertySectionUtil.java b/ge/org.osate.ge/src/org/osate/ge/internal/ui/util/InternalPropertySectionUtil.java index 0f9e6c61314..c724aecf46d 100644 --- a/ge/org.osate.ge/src/org/osate/ge/internal/ui/util/InternalPropertySectionUtil.java +++ b/ge/org.osate.ge/src/org/osate/ge/internal/ui/util/InternalPropertySectionUtil.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -122,14 +122,15 @@ public static TableViewerColumn createTableColumnViewer(final TableViewer tableV return tableViewerColumn; } + // Returns initial value for type options and populates type options - public static EClass getTypeOptionsInformation(final Set selectedElements, - final Collection allTypes, final BiFunction isValidTypeOption, + public static EClass getTypeOptionsInformation(final Set selectedElements, + final Collection allTypes, final BiFunction isValidTypeOption, final Consumer addTypeOption) { EClass selectedType = null; for (final EClass type : allTypes) { - final Iterator it = selectedElements.iterator(); - NamedElement ne = it.next(); + final Iterator it = selectedElements.iterator(); + T ne = it.next(); // Initial combo selected value selectedType = ne.eClass();