Skip to content
Snippets Groups Projects
Commit a785ce71 authored by Luca Cristoforetti's avatar Luca Cristoforetti Committed by Alberto Debiasi
Browse files

Add an utility to post on Problems view

Also add a couple on simple methods in EntityView
parent 39e332b3
No related branches found
No related tags found
No related merge requests found
......@@ -1836,6 +1836,14 @@ public class EntityUtil {
return transitions;
}
public EList<Transition> getOutgoingTransitions(Vertex state) {
return state.getOutgoings();
}
public EList<Transition> getIncomingTransitions(Vertex state) {
return state.getIncomings();
}
public String getSignalEventName(Trigger trigger) {
if (trigger.getEvent() instanceof SignalEvent) {
......
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* 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:
* Luca Cristoforetti - initial API and implementation
******************************************************************************/
package org.polarsys.chess.service.gui.utils;
import java.util.HashMap;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
/**
* An utility class to post messages to the Problems tab.
*
* @author cristofo
*
*/
public class ReportProblemsUtil {
/**
* Deletes all markers on this resource.
* @param resource the resource
* @throws CoreException
*/
public static void cleanResource(IResource resource) throws CoreException {
resource.deleteMarkers(null, true, IResource.DEPTH_INFINITE);
}
/**
* Reports a warning in the Problems tab.
* @param resource the resource
* @param msg the message to display
* @param lineNumber the line to select (or 0)
* @param charStart the start of selection (or 0)
* @param charEnd the end of seletion (or 0)
* @return the created IMarker
* @throws CoreException
* @throws NullPointerException
*/
public static IMarker reportWarning(IResource resource, String msg, int lineNumber,
int charStart, int charEnd) throws CoreException, NullPointerException {
return reportMessage(resource, msg, lineNumber, charStart, charEnd,
IMarker.PROBLEM, IMarker.SEVERITY_WARNING);
}
/**
* Reports an error in the Problems tab.
* @param resource the resource
* @param msg the message to display
* @param lineNumber the line to select (or 0)
* @param charStart the start of selection (or 0)
* @param charEnd the end of seletion (or 0)
* @return the created IMarker
* @throws CoreException
* @throws NullPointerException
*/
public static IMarker reportError(IResource resource, String msg, int lineNumber,
int charStart, int charEnd) throws CoreException, NullPointerException {
return reportMessage(resource, msg, lineNumber, charStart, charEnd,
IMarker.PROBLEM, IMarker.SEVERITY_ERROR);
}
/**
* Reports an info in the Problems tab.
* @param resource the resource
* @param msg the message to display
* @param lineNumber the line to select (or 0)
* @param charStart the start of selection (or 0)
* @param charEnd the end of seletion (or 0)
* @return the created IMarker
* @throws CoreException
* @throws NullPointerException
*/
public static IMarker reportInfo(IResource resource, String msg, int lineNumber,
int charStart, int charEnd) throws CoreException, NullPointerException {
return reportMessage(resource, msg, lineNumber, charStart, charEnd,
IMarker.PROBLEM, IMarker.SEVERITY_INFO);
}
private static IMarker reportMessage(IResource resource, String msg, int lineNumber, int charStart,
int charEnd, String type, int severity) throws CoreException, NullPointerException {
if (resource == null) {
throw new NullPointerException("Resource is null");
}
IMarker m = resource.createMarker(type);
HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH));
attributes.put(IMarker.SEVERITY, new Integer(severity));
if (lineNumber > 0) attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
attributes.put(IMarker.MESSAGE, msg);
if (charStart > 0) attributes.put(IMarker.CHAR_START, new Integer(charStart)); // Note: this value is from the beginning of the document
if (charEnd > 0) attributes.put(IMarker.CHAR_END, new Integer(charEnd)); // Note: this value is from the beginning of the document
// m.setAttribute(IMarker.LOCATION, "whole file"); // This is a generic info about location
m.setAttributes(attributes);
return m;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment