Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make association source and target reliable in CDB #2914

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
/*******************************************************************************
* Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/

package org.polarsys.capella.common.ef.command;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;

import org.eclipse.core.runtime.Assert;

Expand Down Expand Up @@ -54,9 +55,21 @@ public void append(ICommand command) {
_commands.add(command);
}

/**
* Append specified optional command to this compound command's list of commands if this optional command is present.
*
* @param command
* the added command.
*/
public void appendIfPresent(Optional<? extends ICommand> optCommand) {
optCommand.ifPresent(command -> _commands.add(command));
}

/**
* Prepend specified command to this compound command's list of commands.
* @param command the added command.
*
* @param command
* the added command.
*/
public void prepend(ICommand command) {
_commands.add(0, command);
Expand Down Expand Up @@ -91,6 +104,7 @@ public List<ICommand> getContainedCommands() {
/**
* @see org.polarsys.capella.common.ef.command.ICommand#isReadOnly()
*/
@Override
public boolean isReadOnly() {
boolean isReadOnly = true;
// Iterate over contained commands to search one that is not a read only one.
Expand All @@ -105,6 +119,7 @@ public boolean isReadOnly() {
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
// Iterate over contained commands to run each contained command.
for (ICommand command : _commands) {
Expand Down
scosta-obeo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.polarsys.capella.common.data.modellingcore.ModellingcorePackage;
import org.polarsys.capella.common.ef.command.AbstractCompoundCommand;
import org.polarsys.capella.common.helpers.EObjectExt;
import org.polarsys.capella.core.data.capellacore.CapellacorePackage;
import org.polarsys.capella.core.data.capellacore.Classifier;
Expand Down Expand Up @@ -82,8 +83,12 @@ public void widgetSelected(SelectionEvent event) {
if (oppositeMember != null) {
EObject oppositeTypeElement = (EObject) oppositeMember.eGet(ModellingcorePackage.Literals.ABSTRACT_TYPED_ELEMENT__ABSTRACT_TYPE);
if (oppositeTypeElement != null) {
moveDataValue(semanticElement, oppositeTypeElement, CapellacorePackage.Literals.CLASSIFIER__OWNED_FEATURES);
addDataValue(ownerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement);
AbstractCompoundCommand command = new AbstractCompoundCommand() {};
command.appendIfPresent(createMoveDataValueCommand(semanticElement, oppositeTypeElement,
CapellacorePackage.Literals.CLASSIFIER__OWNED_FEATURES));
command.appendIfPresent(createAddDataValueCommand(ownerElement,
InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement));
executeCommand(command);
}
}
}
Expand All @@ -96,8 +101,12 @@ public void widgetSelected(SelectionEvent event) {
}

if ((typeElement instanceof Classifier) && (referencerElement instanceof Association)) {
moveDataValue(semanticElement, referencerElement, InformationPackage.Literals.ASSOCIATION__OWNED_MEMBERS);
removeDataValue(referencerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement);
AbstractCompoundCommand command = new AbstractCompoundCommand() {};
command.appendIfPresent(createMoveDataValueCommand(semanticElement, referencerElement,
InformationPackage.Literals.ASSOCIATION__OWNED_MEMBERS));
command.appendIfPresent(createRemoveDataValueCommand(referencerElement,
InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement));
executeCommand(command);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
<migrationContributor
class="org.polarsys.capella.core.data.migration.aird.AutoSizeSquareStyleMigrationContributor">
</migrationContributor>
<migrationContributor
class="org.polarsys.capella.core.data.migration.aird.AssociationCDBMigrationContributor">
</migrationContributor>

</extension>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public class MigrationConstants {
public static final String MIGRATION_KIND__VIEWPOINT = "MIGRATION_KIND__VIEWPOINT";
public static final String MIGRATION_KIND__IMAGE_DEPENDENCIES = "MIGRATION_KIND__IMAGE_DEPENDENCIES";
public static final String MIGRATION_KIND__AUTOSIZE_SQUARE_STYLE = "MIGRATION_KIND__AUTOSIZE_SQUARE_STYLE";
public static final String MIGRATION_KIND__ASSOCIATION_CDB = "MIGRATION_KIND__ASSOCIATION_CDB";

public static final String[] DEFAULT_KIND_ORDER = { MIGRATION_KIND__CHECK_MISSING_VP, MIGRATION_KIND__PATTERN,
MIGRATION_KIND__SEMANTIC, MIGRATION_KIND__DIAGRAM, MIGRATION_KIND__FCDDIAGRAM, MIGRATION_KIND__AFM,
MIGRATION_KIND__VIEWPOINT, MIGRATION_KIND__SCF, MIGRATION_KIND__IMAGE_DEPENDENCIES, MIGRATION_KIND__AUTOSIZE_SQUARE_STYLE };
MIGRATION_KIND__VIEWPOINT, MIGRATION_KIND__SCF, MIGRATION_KIND__IMAGE_DEPENDENCIES, MIGRATION_KIND__AUTOSIZE_SQUARE_STYLE, MIGRATION_KIND__ASSOCIATION_CDB };
}
Loading