public static ModelProblemManager problemManager(ArchitectureModel model) { synchronized (instances) { ModelProblemManager instance = instances.get(model.getResource()); if (instance == null) { instance = new ModelProblemManager(model); instances.put(model.getResource(), instance); } return instance; } }
@Override public void connectorXReferenceAdded(final Connector connector, final IXReference xref) { // Thread thread = new Thread(new Runnable() { // // @Override // public void run() { if (connector.isEnvisaged() || ignoreViolations() || !isAttachedToProject(xref.getSource().getResource().getProject())) return; IResource resource = xref.getSource().getResource(); try { IMarker marker = resource.createMarker(defaults.MARKER_TYPE); marker.setAttribute(IMarker.SEVERITY, getViolationSeverity()); marker.setAttribute( IMarker.MESSAGE, "Element " + xref.getTarget().getName() + " should not be accessed in this context " + "(" + connector.getSource().getName() + "->" + connector.getTarget().getName() + ")"); marker.setAttribute(IMarker.CHAR_START, xref.getOffset()); marker.setAttribute(IMarker.CHAR_END, xref.getOffset() + xref.getLength()); marker.setAttribute(IMarker.LINE_NUMBER, xref.getLine()); marker.setAttribute(defaults.MODEL, model.getResource().getFullPath()); marker.setAttribute(defaults.CONNECTOR_ID, connector.toString()); violations.put(ArchitectureModel.xrefStringFactory.toString(xref), marker.getId()); } catch (CoreException ex) { // TODO: Do something better here; ex.printStackTrace(); } // } // });thread.start(); }
public void setViolationSeverity(int severity) { validateSeverity(severity); int oldSeverity = getViolationSeverity(); if (severity != oldSeverity) { getModelProperties().setViolationSeverity(severity); for (IProject project : projects) { try { if (oldSeverity == -1) { model.accept(new ModelProblemCollector(this, project)); } else if (severity != -1) { for (IMarker marker : project.findMarkers(defaults.MARKER_TYPE, true, IResource.DEPTH_INFINITE)) marker.setAttribute(IMarker.SEVERITY, severity); } else project.deleteMarkers(defaults.MARKER_TYPE, true, IResource.DEPTH_INFINITE); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
private ModelProperties getModelProperties() { return model.getModelProperties(); }
protected void attachToProject(IProject project) { if (!projects.add(project)) return; // This will add the errors originating from this project. model.accept(new ModelProblemCollector(this, project)); }