blob: 66b2c42eb92ed6482735d88cc2e3129c74bcaef6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*****************************************************************************
* Copyright (c) 2020 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alexandra Buzila (EclipseSource) - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.plugin.builder.quickfix;
import java.util.Optional;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.papyrus.infra.emf.utils.ResourceUtils;
import org.eclipse.papyrus.toolsmiths.plugin.builder.Activator;
import org.eclipse.papyrus.toolsmiths.plugin.builder.Messages;
import org.eclipse.uml2.uml.Profile;
/**
* Resolution for markers created for missing genModel attributes in the extension point.
*
*/
public class NoLocationUMLGenPackageMarkerResolution
extends AbstractMissingAttributeMarkerResolution {
NoLocationUMLGenPackageMarkerResolution() {
super("location"); //$NON-NLS-1$
}
@Override
public String getLabel() {
return Messages.NoLocationUMLGenPackageMarkerResolution_label;
}
@Override
public String getDescription() {
return Messages.NoLocationUMLGenPackageMarkerResolution_description;
}
@Override
protected String getAttributeValue() {
Optional<Profile> profileOptional = MarkerResolutionUtils.getProfile(getMarker());
if (profileOptional.isEmpty()) {
return null;
}
Profile profile = profileOptional.get();
Resource resource = profile.eResource();
String uriFragment = resource.getURIFragment(profile);
try {
IFile umlModelFile = MarkerResolutionUtils.getUMLModelFile(getMarker());
if (umlModelFile == null) {
return null;
}
return ResourceUtils.mapAndEncodePath(umlModelFile) + "#" + uriFragment; //$NON-NLS-1$
} catch (CoreException e) {
Activator.log.error(e);
}
return null;
}
}
|