Skip to content
Snippets Groups Projects
Commit 4001616a authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Merge branch '231-implement-checkermanager' into 'master'

Resolve "Implement CheckerManager"

Closes #231

See merge request CPS_Design/CHESS!53
parents eccfa453 fa6e37f4
No related branches found
No related tags found
No related merge requests found
Showing
with 781 additions and 16 deletions
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
<module>../../plugins/sba/org.polarsys.chess.statebased</module> <module>../../plugins/sba/org.polarsys.chess.statebased</module>
<module>../../plugins/org.polarsys.chess.xtext.global</module> <module>../../plugins/org.polarsys.chess.xtext.global</module>
<module>../../plugins/org.polarsys.chess.tradeoffAnalysis</module> <module>../../plugins/org.polarsys.chess.tradeoffAnalysis</module>
<module>../../plugins/org.polarsys.chess.checkers</module>
<!-- module>../../plugins/org.polarsys.chess.tabbedproperties</module> <!-- module>../../plugins/org.polarsys.chess.tabbedproperties</module>
<module>../../plugins/fla/org.polarsys.chess.xtext.fladsl</module> <module>../../plugins/fla/org.polarsys.chess.xtext.fladsl</module>
......
...@@ -4169,34 +4169,38 @@ public class EntityUtil { ...@@ -4169,34 +4169,38 @@ public class EntityUtil {
return null; return null;
} }
public Object getParameterType(String paramName, Operation operation) {
public List<String> getMethodArgumentNames(String methodName, Class retrieveBlockType) {
List<String> args = new ArrayList<String>();
Operation operation = getOperation(methodName, retrieveBlockType);
if ((operation != null)) { if ((operation != null)) {
if (operation.inputParameters() != null) { if (operation.inputParameters() != null) {
Parameter par = operation.getOwnedParameter(paramName, null); for(Parameter par : operation.inputParameters()){
if (par != null) { args.add(par.getName());
// logger.debug("getParameterType par: " + par); }
return par.getType();
}
} }
} }
return null; return args;
} }
@SuppressWarnings("unchecked")
public Collection<Enumeration> getAllEnumeratives(Package packageElement) throws Exception { public Collection<Enumeration> getAllEnumeratives(Package packageElement) throws Exception {
return (Collection<Enumeration>) EObjectUtil.getAllElements(UMLPackage.eINSTANCE.getEnumeration(), return (Collection<Enumeration>) EObjectUtil.getAllElements(UMLPackage.eINSTANCE.getEnumeration(),
packageElement); packageElement);
} }
public Collection<Operation> getAllOperations(Package packageElement) throws Exception {
if (packageElement != null) {
TreeIterator<EObject> allElements = packageElement.eResource().getAllContents();
Collection<org.eclipse.uml2.uml.Operation> operations = EcoreUtil
.getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getOperation());
return operations;
}
throw new Exception("Element does not exist.");
}
/**
* Returns all the classes in the model.
* <p> BEWARE: all the classes, not only the classes in the given package
* @param packageElement
* @return
* @throws Exception
*/
public Collection<Class> getAllClasses(Package packageElement) throws Exception { public Collection<Class> getAllClasses(Package packageElement) throws Exception {
Collection<Class> classElements = null; Collection<Class> classElements = null;
if (packageElement != null) { if (packageElement != null) {
...@@ -4209,6 +4213,58 @@ public class EntityUtil { ...@@ -4209,6 +4213,58 @@ public class EntityUtil {
throw new Exception("Element does not exist."); throw new Exception("Element does not exist.");
} }
/**
* Returns the Class elements directly contained in a package.
* @param pkg the Package
* @return the Class children
*/
public Collection<Class> getPackageClasses(Package pkg) throws Exception {
Collection<Class> classElements = null;
if (pkg != null) {
Collection<Element> ownedElements = pkg.getOwnedElements();
if (ownedElements != null) {
classElements = getClasses(ownedElements);
}
return classElements;
}
throw new Exception("Package does not exist.");
}
private Collection<Class> getClasses(Collection<Element> elements) {
Collection<Class> result = new ArrayList<Class>();
for (Element element : elements) {
if (isBlock(element)) result.add((Class) element);
}
return result;
}
public Object getParameterType(String paramName, Operation operation) {
if ((operation != null)) {
if (operation.inputParameters() != null) {
Parameter par = operation.getOwnedParameter(paramName, null);
if (par != null) {
// logger.debug("getParameterType par: " + par);
return par.getType();
}
}
}
return null;
}
public Collection<Operation> getAllOperations(Package packageElement) throws Exception {
if (packageElement != null) {
TreeIterator<EObject> allElements = packageElement.eResource().getAllContents();
Collection<org.eclipse.uml2.uml.Operation> operations = EcoreUtil
.getObjectsByType(iterator2Collection(allElements), UMLPackage.eINSTANCE.getOperation());
return operations;
}
throw new Exception("Element does not exist.");
}
public static <T> Collection<T> getClassObjects(Collection<EObject> objects) { public static <T> Collection<T> getClassObjects(Collection<EObject> objects) {
Collection<T> result = new ArrayList<T>(); Collection<T> result = new ArrayList<T>();
for (EObject object : objects) { for (EObject object : objects) {
...@@ -4220,4 +4276,6 @@ public class EntityUtil { ...@@ -4220,4 +4276,6 @@ public class EntityUtil {
} }
return result; return result;
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/bin/
/target/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.polarsys.chess.checkers</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.directory=xtend-gen
//outlet.DEFAULT_OUTPUT.sourceFolder.src/test/java.directory=xtend-gen
BuilderConfiguration.is_project_specific=true
eclipse.preferences.version=1
outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CheckerManager
Bundle-SymbolicName: org.polarsys.chess.checkers;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.google.guava;bundle-version="15.0.0",
org.eclipse.uml2.uml,
org.eclipse.papyrus.sysml,
org.eclipse.ui.workbench,
org.eclipse.osgi,
org.eclipse.core.runtime;bundle-version="3.12.0",
org.polarsys.chess.service,
org.eclipse.papyrus.uml.tools,
org.eclipse.core.resources,
org.eclipse.papyrus.uml.tools.utils,
org.apache.log4j;bundle-version="1.2.15",
eu.fbk.eclipse.standardtools.utils,
org.eclipse.core.jobs,
org.eclipse.ui.workbench.texteditor,
org.eclipse.emf.common.ui,
org.eclipse.uml2.uml.resources,
org.eclipse.gmf.runtime.common.ui.services,
org.eclipse.papyrus.views.modelexplorer,
org.polarsys.chess.contracts.profile,
org.eclipse.emf.common,
org.eclipse.xtext
Export-Package: org.polarsys.chess.checkers,
org.polarsys.chess.checkers.core.checkerManager,
org.polarsys.chess.checkers.core.impl
Bundle-Activator: org.polarsys.chess.checkers.Activator
Bundle-ActivationPolicy: lazy
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/
plugins/org.polarsys.chess.checkers/icons/checker.png

557 B

plugins/org.polarsys.chess.checkers/icons/checker_old.png

765 B

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="RunCheckers"
label="Run Checkers">
<command
commandId="org.polarsys.chess.checkers.ui.commands.runCheckers"
icon="icons/checker.png"
label="Run Checkers"
style="push">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="org.polarsys.chess.checkers.ui.commands.RunCheckers"
id="org.polarsys.chess.checkers.ui.commands.runCheckers"
name="Run Checkers">
</command>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.polarsys.chess.checkers.ui.preferences.ModelCheckingPreferencePage"
id="org.polarsys.chess.checkers.ui.preferences.ModelCheckingPreferencePage"
name="Checkers">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.polarsys.chess.checkers.ui.preferences.ModelCheckingPreferenceInitializer">
</initializer>
</extension>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.polarsys.chess</groupId>
<artifactId>org.polarsys.chess.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../org.polarsys.chess.parent</relativePath>
</parent>
<artifactId>org.polarsys.chess.checkers</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
/*******************************************************************************
* Copyright (C) 2019 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
*******************************************************************************/
package org.polarsys.chess.checkers;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.polarsys.chess.checkers.core.checkerManager.CheckerManager;
import org.polarsys.chess.checkers.core.checkerManager.CheckersContainer;
import org.polarsys.chess.checkers.core.impl.NameDistance;
import org.polarsys.chess.checkers.core.impl.StateStatus;
import org.polarsys.chess.checkers.core.impl.TestChecker1;
import org.polarsys.chess.checkers.core.impl.TestChecker2;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.polarsys.chess.checkers";
// The system property that contains the log level to use
public static final String LOG4J_LOG_LEVEL = "Log4jLogLevel";
// The shared instance
private static Activator plugin;
private static CheckerManager checkerManager;
boolean started;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
* BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
System.out.println("Activator: " + this);
checkerManager = getCheckerManager();
/*
Set<String> tags1 = new HashSet<String>();
tags1.add("fast");
tags1.add("errors");
tags1.add("sysml");
new TestChecker2("SysMLChecker1", tags1);
Set<String> tags2 = new HashSet<String>();
tags2.add("slow");
tags2.add("warnings");
tags2.add("state machine");
tags2.add("sysml");
new TestChecker1("StateMachineChecker2", tags2, 4);
new TestChecker1("StateMachineChecker2", tags2, 1);
new TestChecker1("StateMachineChecker2", tags2, 10);
new TestChecker1("StateMachineChecker2", tags2, 2);*/
new NameDistance(1, 1);
new StateStatus();
started = true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
* BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
started = false;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given plug-in
* relative path
*
* @param path
* the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
public static CheckerManager getCheckerManager() {
if (checkerManager == null) {
checkerManager = new CheckerManager();
}
return checkerManager;
}
public Set<String> getTags() {
Set<String> selectedTags = new HashSet<String>();
for (String tag : checkerManager.getTags()) {
if (getPreferenceStore().getBoolean(tag)) {
selectedTags.add(tag);
}
}
return selectedTags;
}
}
package org.polarsys.chess.checkers.core.checkerManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
public abstract class Checker {
private static final Logger logger = Logger.getLogger(Checker.class);
private static String pluginID = "org.polarsys.chess.checkers";
public final String unifiedName;
protected final Set<String> checkerTags;
protected final int registerPriority;
private ArrayList<Exception> errors = new ArrayList<Exception>();
protected Checker(String unifiedName, Set<String> checkerTags) {
this(unifiedName, checkerTags, 0);
}
public Checker(String unifiedName, Set<String> checkerTags, int registerPriority) {
this.unifiedName = unifiedName;
this.checkerTags = checkerTags;
this.registerPriority = registerPriority;
CheckerManager checkerManager = org.polarsys.chess.checkers.Activator.getCheckerManager();
logger.debug("register " + unifiedName);
checkerManager.getCheckersContainter().register(this);
}
public abstract List<CheckerMessage> check(IProgressMonitor monitor) throws Exception;
public abstract void init() throws Exception;
public void asyncCheck(boolean isFirstChecker) throws Exception {
Display defaultDisplay = Display.getDefault();
Shell activeShell = defaultDisplay.getActiveShell();
CheckerManager checkerManager = org.polarsys.chess.checkers.Activator.getCheckerManager();
org.eclipse.uml2.uml.Package pack = EntityUtil.getInstance().getCurrentSystemView();
if(pack==null){
IFile file = EntityUtil.getInstance().getCurrentIFile();
System.out.println("file: "+file);
EntityUtil.getInstance().openCurrentModelIntoEditor(file);
}
IFile iFile = WorkspaceSynchronizer.getFile(EntityUtil.getInstance().getCurrentSystemView().eResource());
init();
logger.debug("running checker: "+unifiedName);
Job job = new Job("Checker Manager: " + unifiedName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
errors = new ArrayList<Exception>();
List<CheckerMessage> messages = check(monitor);
if (messages != null) {
checkerManager.deleteMarkers(iFile, unifiedName);
checkerManager.addMessages(unifiedName, messages);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("Checker '"+unifiedName+"' exception: "+e.getMessage());
return Status.CANCEL_STATUS;
}
if (monitor.isCanceled()) {
logger.warn("checker '" + unifiedName + "' isCanceled");
return Status.CANCEL_STATUS;
}
// use this to open a Shell in the UI thread
return Status.OK_STATUS;
}
};
job.setUser(isFirstChecker);
job.schedule();
}
/*
* private void syncWithUI(Shell shell) { Display.getDefault().asyncExec(new
* Runnable() { public void run() { MessageDialog.openInformation(shell,
* "message", "completed!"); } }); }
*/
public boolean belongsTo(Set<String> checkersTags) {
for (String tag : checkersTags) {
if (checkerTags.contains(tag))
return true;
}
return false;
}
public String getUnifiedName() {
return unifiedName;
}
public Set<String> getCheckerTags() {
return checkerTags;
}
public void addError(Exception e){
errors.add(e);
}
}
\ No newline at end of file
package org.polarsys.chess.checkers.core.checkerManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPage;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
import org.eclipse.papyrus.views.modelexplorer.ModelExplorerView;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.IPage;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.xtext.nodemodel.INode;
import org.polarsys.chess.service.gui.utils.ReportProblemsUtil;
public class CheckerManager {
private static final Logger logger = Logger.getLogger(CheckerManager.class);
private static final String CHECKER_NAME = "checkerName";
List<CheckersContainer> checkersContainers;
List<CheckerMessage> messages;
HashMap<String, Boolean> checkerStatus;
// ModelExplorerPageBookView modelExplorerPageBookView;
// ModelExplorerView modelExplorerView ;
// test test;
public CheckerManager() {
logger.debug("Instantiate CheckerManager");
this.checkersContainers = new ArrayList<CheckersContainer>();
new CheckersContainer(this);
// checkersContainers.add(checkersContainer);
}
public void run(Set<String> selectedCheckersTags) throws Exception {
logger.debug("run");
checkerStatus = new HashMap<String, Boolean>();
messages = new ArrayList<CheckerMessage>();
// modelExplorerPageBookView = getModelExplorerPageBookView();
// modelExplorerView = getModelExplorerView();
// test = new test(modelExplorerView);
for (CheckersContainer checkersContainer : checkersContainers) {
logger.debug("run checkersContainer");
checkersContainer.run(selectedCheckersTags);
}
}
public void register(CheckersContainer checkersContainer) {
logger.debug("register CheckersContainer");
this.checkersContainers.add(checkersContainer);
}
public Set<String> getTags() {
Set<String> tags = new HashSet<String>();
for (CheckersContainer containter : checkersContainers) {
tags.addAll(containter.getTags());
}
return tags;
}
public CheckersContainer getCheckersContainter() {
return checkersContainers.get(0);
}
public void addMessages(String unifiedName, List<CheckerMessage> newMessages) throws Exception {
// this.messages.addAll(newMessages);
checkerStatus.put(unifiedName, true);
// logger.debug("addMessages '" + unifiedName + "' : " +
// newMessages.size());
/*
* for (Boolean value : checkerStatus.values()) { if
* (value.booleanValue() == false) return; }
*/
// IViewPart modelexplorer =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
// .showView(ModelExplorerPageBookView.VIEW_ID);
// modelExplorerView = getModelExplorerPageBookView();
// System.out.println("modelexplorer: "+modelExplorerView);
// Set<IFile> iFiles = extractIFiles(newMessages);
// for (IFile iFile : iFiles) {
// deleteMarkers(iFile, unifiedName);
// }
for (CheckerMessage msn : newMessages) {
if (msn.object != null && msn.object instanceof EObject) {
IMarker marker = msn.file.createMarker(EValidator.MARKER);
marker.setAttribute(CHECKER_NAME, msn.checkerName);
marker.setAttribute(IMarker.MESSAGE, msn.message);
String location = EcoreUtil.getURI((EObject) msn.object).toString();
if (msn.object instanceof NamedElement) {
location = ((NamedElement) msn.object).getQualifiedName();
}
marker.setAttribute(IMarker.LOCATION, location);
marker.setAttribute(IMarker.SEVERITY, msn.severity);
marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI((EObject) msn.object).toString());
} else if (msn.object != null && msn.object instanceof INode) {
try {
final INode node = (INode) msn.object;
if (msn.severity == 0) {
ReportProblemsUtil.reportInfo(msn.file, msn.message, node.getStartLine(),
node.getOffset(), node.getEndOffset());
} else if (msn.severity == 1) {
ReportProblemsUtil.reportWarning(msn.file, msn.message, node.getStartLine(),
node.getOffset(), node.getEndOffset());
} else if (msn.severity == 2) {
ReportProblemsUtil.reportError(msn.file, msn.message, node.getStartLine(),
node.getOffset(), node.getEndOffset());
}
} catch (NullPointerException | CoreException e) {
e.printStackTrace();
}
}
}
}
private Set<IFile> extractIFiles(List<CheckerMessage> checkerMessages) {
Set<IFile> iFiles = new HashSet<IFile>();
if (checkerMessages != null) {
for (CheckerMessage checkerMessage : checkerMessages) {
if (checkerMessage.file != null) {
iFiles.add(checkerMessage.file);
}
}
}
return iFiles;
}
void deleteMarkers(IFile file, String checkerName) throws CoreException {
IMarker[] markers = file.findMarkers(EValidator.MARKER, false, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
if (marker != null && marker.exists() && marker.getAttribute(CHECKER_NAME, "").equals(checkerName)) {
marker.delete();
}
}
}
private ModelExplorerPageBookView getModelExplorerPageBookView() {
IWorkbench workbench = PlatformUI.getWorkbench();
System.out.println("workbench: " + workbench);
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
System.out.println("window: " + window);
IWorkbenchPage workbenchPage = window.getActivePage();
System.out.println("workbenchPage: " + workbenchPage);
IViewPart modelExplorerViewPart = null;
for (IViewPart view : workbenchPage.getViews()) {
System.out.println("view: " + view.getTitle());
}
try {
modelExplorerViewPart = window.getActivePage().showView(ModelExplorerPageBookView.VIEW_ID);
} catch (PartInitException ex) {
ex.printStackTrace(System.out);
}
ModelExplorerPageBookView view = (ModelExplorerPageBookView) modelExplorerViewPart;
return view;
}
private ModelExplorerView getModelExplorerView() {
ModelExplorerPageBookView view = getModelExplorerPageBookView();
IPage currentPage = view.getCurrentPage();
ModelExplorerPage page = (ModelExplorerPage) currentPage;
IViewPart viewer = page.getViewer();
ModelExplorerView modelExplorerView = (ModelExplorerView) viewer;
return modelExplorerView;
}
public void updateCheckerStatus(String unifiedName, boolean b) {
checkerStatus.put(unifiedName, b);
}
}
package org.polarsys.chess.checkers.core.checkerManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
public class CheckerMessage {
protected IFile file;
protected int severity;
protected String message;
protected Object object;
protected String checkerName;
public CheckerMessage(String message, int severity ,Object object, String checkerName ) {
this((object instanceof EObject) ? WorkspaceSynchronizer.getFile(((EObject) object).eResource()) : null,
severity, message, object, checkerName);
}
public CheckerMessage(IFile file, int severity, String message, Object object, String checkerName) {
super();
this.file = file;
this.severity = severity;
this.message = message;
this.object = object;
this.checkerName = checkerName;
}
public String getMessage() {
return message;
}
}
\ No newline at end of file
package org.polarsys.chess.checkers.core.checkerManager;
import java.util.List;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
public class CheckerTriggerManager {
Table<String, String, Integer> targetIdHashMap = HashBasedTable.create();
public void loadCheckersRegistry() {
// TODO Auto-generated method stub
}
public void saveCheckersRegistry() {
// TODO Auto-generated method stub
}
public boolean isTriggered(String checkerUnifiedName, String targetId, int targetCurrentHashCode) {
Integer lastTargetHashCode = targetIdHashMap.get(checkerUnifiedName, targetId);
if ((lastTargetHashCode != null) && (!lastTargetHashCode.equals(targetCurrentHashCode))) {
return true;
}
return false;
}
public void updateCheckersRegistryEntry(String checkerUnifiedName, String targetId, int targetCurrentHashCode) {
targetIdHashMap.put(checkerUnifiedName, targetId, targetCurrentHashCode);
}
public void updateCheckersRegistry(List<?> targets) {
// TODO Auto-generated method stub
}
}
\ No newline at end of file
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