Skip to content

Commit

Permalink
[2178] Use quick fix to solve the issue Error log with "The id xxx has
Browse files Browse the repository at this point in the history
not been found in the id cache map

In this commit:
- we change the status of severity  log on rule DWF_D_48
- we add two new quick fix : Delete the constraint and Clean the
dangling reference element
- i change the label quickfix of delete constraint, and
add description of this quickfix, we had the copyright on the
different file and put  the clean dangling element reference in body in
one command, and add require bundle in manifest.mf

Bug: 2178
Change-Id: I96e2d5fba9da117ea1feaf8e65acb11d4dd98102
Signed-off-by: Joacquim Esabe <joacquim.esabe@laposte.net>
  • Loading branch information
Joacquim Esabe committed Sep 12, 2018
1 parent a9098c3 commit 495b742
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 8 deletions.
Expand Up @@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.ui,
org.polarsys.capella.core.platform.sirius.ui.navigator,
org.polarsys.capella.core.model.helpers,
org.polarsys.capella.core.ui.semantic.browser.sirius,
org.polarsys.capella.core.ui.properties
org.polarsys.capella.core.ui.properties,
org.polarsys.capella.common.linkedtext.ui,
org.polarsys.capella.core.linkedtext.ui
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -4,6 +4,7 @@ These followings icons are made available under the terms of the Eclipse Public

<icon file path> - <original eclipse plug-in> - <original file path>

/icons/clear.gif - org.eclipse.jdt.ui - org.eclipse.jdt.ui/icons/full/elcl16/clear_co.gif
/icons/delete_element.gif - org.eclipse.debug.ui - org.eclipse.debug.ui/icons/full/elcl16/delete_config.gif
/icons/goto_16.png - org.eclipse.jdt.doc.user - org.eclipse.jdt.doc.user/images/org.eclipse.jdt.ui/elcl16/goto_input.png
/icons/move.gif - org.eclipse.ui.cheatsheets - org.eclipse.ui.cheatsheets/icons/elcl16/restart_task.gif
Expand Down
@@ -1,5 +1,5 @@
# ====================================================================
# Copyright (c) 2006, 2015 THALES GLOBAL SERVICES.
# Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
# 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
Expand Down Expand Up @@ -49,8 +49,7 @@ quickFix.DWF_D_40.label = Open Editor to assign type
quickFix.DWF_D_40.desc = Open Editor to assign type
# Rules DWF_D_41
quickFix.DWF_D_41.label = Set this class abstract
quickFix.DWF_D_41.desc = Set a selected class abstract

quickFix.DWF_D_41.desc = Set a selected class abstract
# Rules DWF_D_43
quickFix.DWF_D_43.label = Set/Unset the Parameter Direction
quickFix.DWF_D_43.desc = Set/Unset the Parameter Direction and Exchange Item Element kind according to Exchange Item exchange mechanism
Expand All @@ -62,7 +61,10 @@ quickFix.DWF_D_45_Del.desc = Delete Association
# Rules DWF_D_46
quickFix.DWF_D_46.label = Move association
quickFix.DWF_D_46.desc = Move association to its correct container


# Rules DWF_D_48
quickFix.DWF_D_48_delconstraint.label = Delete Constraint linked to the dangling element
quickFix.DWF_D_48_delconstraint.desc = Delete the constraint link to the Opaque expression when the dangling element reference hyperlink is deleted
quickFix.DWF_D_48_cleanDanglingReference.label = Clean dangling element reference
quickFix.DWF_D_48_cleanDanglingReference.desc = Clean the deleted reference hyperlink
providerName = Eclipse.org
pluginName = Quickfix for information cat.
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
Copyright (c) 2006, 2014 THALES GLOBAL SERVICES.
Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
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
Expand Down Expand Up @@ -197,6 +197,24 @@
ruleId="DWF_D_46">
</rules>
</resolver>
<resolver
class="org.polarsys.capella.core.data.information.ui.quickfix.resolver.DeleteConstraintResolver"
desc="%quickFix.DWF_D_48_delconstraint.desc"
icon="icons/delete_element.gif"
label="%quickFix.DWF_D_48_delconstraint.label">
<rules
ruleId="DWF_D_48">
</rules>
</resolver>
<resolver
class="org.polarsys.capella.core.data.information.ui.quickfix.resolver.CleanReferenceElementResolver"
desc="%quickFix.DWF_D_48_cleanDanglingReference.desc "
icon="icons/clear.gif"
label="%quickFix.DWF_D_48_cleanDanglingReference.label">
<rules
ruleId="DWF_D_48">
</rules>
</resolver>
</extension>

</plugin>
@@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* 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:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.information.ui.quickfix.resolver;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.text.BadLocationException;
import org.polarsys.capella.common.linkedtext.ui.LinkedTextDocument;
import org.polarsys.capella.common.linkedtext.ui.LinkedTextHyperlink;
import org.polarsys.capella.core.data.information.datavalue.OpaqueExpression;
import org.polarsys.capella.core.linkedtext.ui.CapellaEmbeddedLinkedTextEditorInput;
import org.polarsys.capella.core.validation.ui.ide.quickfix.AbstractCapellaMarkerResolution;

public class CleanReferenceElementResolver extends AbstractCapellaMarkerResolution {

@Override
public void run(IMarker marker) {

final EObject value = getModelElements(marker).get(0);
if (value instanceof OpaqueExpression) {
OpaqueExpression opExpression = (OpaqueExpression) value;
cleanDeletedHyperLink(opExpression);
try {
marker.delete();
} catch (CoreException e) {
e.printStackTrace();
}
}
}

public void cleanDeletedHyperLink(OpaqueExpression opExpression) {

TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(opExpression);
domain.getCommandStack().execute(new RecordingCommand(domain) {

@Override
protected void doExecute() {
EList<String> listBody = opExpression.getBodies();
for (int i = 0; i < listBody.size(); i++) {
String body = listBody.get(i);
// Get all the content of text editor in the body of opaque Expression
CapellaEmbeddedLinkedTextEditorInput input = new CapellaEmbeddedLinkedTextEditorInput.Readonly(opExpression,
body);
try {
// Load the linked text of text editor
LinkedTextDocument doc = LinkedTextDocument.load(input);
for (LinkedTextHyperlink hl : doc.getHyperlinks()) {
Object o = hl.getTarget();
if (o == null) {
try {
// Delete the text corresponding at the link to delete
doc.replace(hl.offset, hl.length, "");
// Delete the physical link with model
hl.delete();
} catch (BadLocationException e) {
e.printStackTrace();
}
}
}
// Save the new content of body text editor
String content = doc.saveToRaw();
int position = i;
// Implement write operations on opaqueExpression,
opExpression.getBodies().set(position, content);
} finally {
input.dispose();
}
}
}
});

}
}
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* 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:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.information.ui.quickfix.resolver;

import org.polarsys.capella.core.data.capellacore.Constraint;
import org.polarsys.capella.core.data.information.datavalue.OpaqueExpression;
import org.polarsys.capella.core.validation.ui.ide.quickfix.AbstractDeleteCommandResolver;

public class DeleteConstraintResolver extends AbstractDeleteCommandResolver {

@Override
public Object getElementToDelete(Object obj) {
if (obj instanceof OpaqueExpression) {
OpaqueExpression opExpression = (OpaqueExpression) obj;
Object cstObj = opExpression.eContainer();
if (cstObj instanceof Constraint) {
return cstObj;
}
}
return null;
}

}
Expand Up @@ -17,7 +17,7 @@
lang="Java"
mode="Batch"
name="DWF_D_48 - Dangling LinkedText hyperlinks in OpaqueExpressions"
severity="WARNING"
severity="ERROR"
statusCode="1">
<message>
OpaqueExpression {0} contains one or more dangling element references
Expand Down

0 comments on commit 495b742

Please sign in to comment.