Skip to content

Commit

Permalink
#2743 Fix dialog label in DWF_DC_27 resolver
Browse files Browse the repository at this point in the history
Fix class cast exception that prevented DWF_DC_12 to be resolved

Change-Id: I86e8955fb2b0488dcf9a1b3dee24cfdab99f6069
Signed-off-by: Erwann Traisnel <erwann.traisnel@obeo.fr>
  • Loading branch information
etraisnel2 authored and pdulth committed Nov 8, 2023
1 parent 6a56f65 commit d0cdda2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.statushandlers.StatusManager;
import org.polarsys.capella.common.helpers.TransactionHelper;
import org.polarsys.capella.core.data.fa.ComponentExchange;
import org.polarsys.capella.core.platform.sirius.ui.commands.CapellaDeleteCommand;
import org.polarsys.capella.core.validation.ui.ide.PluginActivator;
import org.polarsys.capella.core.validation.ui.ide.quickfix.AbstractCapellaMarkerResolution;
Expand All @@ -41,7 +40,7 @@ public void run(IMarker marker) {

if (!modelElements.isEmpty()) {
if (isAvailableFor(modelElements.get(0))) {
openSelectionDialog((ComponentExchange) modelElements.get(0), marker);
openSelectionDialog(modelElements.get(0), marker);
}
}
}
Expand Down
Expand Up @@ -16,14 +16,10 @@
import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.statushandlers.StatusManager;
import org.polarsys.capella.common.data.modellingcore.AbstractTrace;
import org.polarsys.capella.common.ef.command.AbstractReadWriteCommand;
import org.polarsys.capella.common.helpers.TransactionHelper;
Expand All @@ -32,7 +28,6 @@
import org.polarsys.capella.core.data.fa.ComponentExchangeFunctionalExchangeAllocation;
import org.polarsys.capella.core.data.fa.FunctionalExchange;
import org.polarsys.capella.core.platform.sirius.ui.commands.CapellaDeleteCommand;
import org.polarsys.capella.core.validation.ui.ide.PluginActivator;

/**
* DWF_DC_27 - SequenceLink with no associated FunctionalChainInvolvementLinks
Expand All @@ -41,20 +36,6 @@ public class DWF_DC_27_Resolver extends AbstractSelectOneResolver {
public DWF_DC_27_Resolver() {
}

/**
* {@inheritDoc}
*/
@Override
public void run(IMarker marker) {
final List<EObject> modelElements = getModelElements(marker);

if (!modelElements.isEmpty()) {
if (modelElements.get(0) instanceof FunctionalExchange) {
openSelectionDialog((FunctionalExchange) modelElements.get(0), marker);
}
}
}

protected void openSelectionDialog(EObject semanticElement, IMarker marker) {
List<ComponentExchange> allocatingCEs = new ArrayList<ComponentExchange>(
((FunctionalExchange) semanticElement).getAllocatingComponentExchanges());
Expand All @@ -64,7 +45,7 @@ protected void openSelectionDialog(EObject semanticElement, IMarker marker) {
public void run() {
Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
SelectElementsDialog dialog = new SelectElementsDialog(activeShell, "Component Exchange Allocation",
"Please select a single Physical Link to allocate\nOthers will be deallocated", allocatingCEs);
"Please select a single ComponentExchange to allocate\nOthers will be deallocated", allocatingCEs);
if (dialog.open() == Dialog.OK) {
ComponentExchange result = (ComponentExchange) dialog.getResult().get(0);
allocatingCEs.remove(result);
Expand Down Expand Up @@ -96,17 +77,6 @@ public void run() {
TransactionHelper.getExecutionManager(semanticElement).execute(command);
}

@Override
protected void deleteMarker(IMarker marker) {
// delete marker
try {
marker.delete();
} catch (CoreException exception) {
StatusManager.getManager().handle(
new Status(IStatus.ERROR, PluginActivator.getDefault().getPluginId(), exception.getMessage(), exception));
}
}

@Override
protected boolean isAvailableFor(EObject obj) {
return obj != null && obj instanceof FunctionalExchange;
Expand Down

0 comments on commit d0cdda2

Please sign in to comment.