-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2178] Use quick fix to solve the issue Error log with "The id xxx has
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
Showing
8 changed files
with
148 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+595 Bytes
.../plugins/org.polarsys.capella.core.data.information.ui.quickfix/icons/clear.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...sys/capella/core/data/information/ui/quickfix/resolver/CleanReferenceElementResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...polarsys/capella/core/data/information/ui/quickfix/resolver/DeleteConstraintResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters