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

Add headers in missing classes in contract folder.

Change-Id: I6e89c582f521a64a9381ec5ca0af6dbbb0955149
parent 44bc673f
No related branches found
No related tags found
No related merge requests found
Showing
with 257 additions and 187 deletions
package org.polarsys.chess.contracts.integration.preferences; /*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
import org.eclipse.jface.preference.DirectoryFieldEditor; * All rights reserved. This program and the accompanying materials
import org.eclipse.jface.preference.FieldEditorPreferencePage; * are made available under the terms of the Eclipse Public License v2.0
import org.eclipse.ui.IWorkbench; * which accompanies this distribution, and is available at
import org.eclipse.ui.IWorkbenchPreferencePage; * http://www.eclipse.org/legal/epl-v20.html
import org.polarsys.chess.contracts.integration.Activator; ******************************************************************************/
package org.polarsys.chess.contracts.integration.preferences;
public class XsapAnalysisPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage{ import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
public static final String XSAP_PATH = "XSAP_PATH"; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
public XsapAnalysisPreferencePage() { import org.polarsys.chess.contracts.integration.Activator;
super(GRID);
} public class XsapAnalysisPreferencePage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage{
@Override
protected void createFieldEditors() { public static final String XSAP_PATH = "XSAP_PATH";
DirectoryFieldEditor xsapPathDirEditor = new DirectoryFieldEditor(XSAP_PATH, "xSAP scripts directory:",
getFieldEditorParent()); public XsapAnalysisPreferencePage() {
addField(xsapPathDirEditor); super(GRID);
} }
@Override @Override
public void init(IWorkbench workbench) { protected void createFieldEditors() {
setPreferenceStore(Activator.getDefault().getPreferenceStore()); DirectoryFieldEditor xsapPathDirEditor = new DirectoryFieldEditor(XSAP_PATH, "xSAP scripts directory:",
setDescription("Preferences page for xSAP Analysis Tool"); getFieldEditorParent());
} addField(xsapPathDirEditor);
}
}
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("Preferences page for xSAP Analysis Tool");
}
}
package org.polarsys.chess.contracts.profile.chesscontract.util; /*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
public class Constants { * All rights reserved. This program and the accompanying materials
public static String ContractRefinementAnalysis = "CHESSContract::ContractRefinementAnalysisContext"; * are made available under the terms of the Eclipse Public License v2.0
public static final String CONTRACT = "CHESSContract::Contract"; * which accompanies this distribution, and is available at
public static final String CONTRACT_PROP = "CHESSContract::ContractProperty"; * http://www.eclipse.org/legal/epl-v20.html
public static final String DELEGATION_CONST = "CHESSContract::DelegationConstraint"; ******************************************************************************/
public static final String FORMAL_PROP = "CHESSContract::FormalProperty"; package org.polarsys.chess.contracts.profile.chesscontract.util;
}
public class Constants {
public static String ContractRefinementAnalysis = "CHESSContract::ContractRefinementAnalysisContext";
public static final String CONTRACT = "CHESSContract::Contract";
public static final String CONTRACT_PROP = "CHESSContract::ContractProperty";
public static final String DELEGATION_CONST = "CHESSContract::DelegationConstraint";
public static final String FORMAL_PROP = "CHESSContract::FormalProperty";
}
package org.polarsys.chess.contracts.transformations.commands; /*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
import java.io.File; * All rights reserved. This program and the accompanying materials
import java.io.IOException; * are made available under the terms of the Eclipse Public License v2.0
import java.util.ArrayList; * which accompanies this distribution, and is available at
import java.util.List; * http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
import org.eclipse.core.commands.AbstractHandler; package org.polarsys.chess.contracts.transformations.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import java.io.File;
import org.eclipse.core.runtime.IProgressMonitor; import java.io.IOException;
import org.eclipse.core.runtime.IStatus; import java.util.ArrayList;
import org.eclipse.core.runtime.Status; import java.util.List;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.EObject; import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.ITreeSelection; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT; import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Shell; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.ISelectionService; import org.eclipse.emf.ecore.EObject;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.uml2.uml.Class; import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
import org.eclipse.uml2.uml.Package; import org.eclipse.swt.SWT;
import org.polarsys.chess.chessmlprofile.ComponentModel.ComponentType; import org.eclipse.swt.widgets.FileDialog;
import org.polarsys.chess.contracts.transformations.main.GenerateErrorModel; import org.eclipse.swt.widgets.Shell;
import org.polarsys.chess.core.notifications.ResourceNotification; import org.eclipse.ui.ISelectionService;
import org.polarsys.chess.core.profiles.CHESSProfileManager; import org.eclipse.ui.IWorkbenchWindow;
import org.polarsys.chess.core.util.uml.UMLUtils; import org.eclipse.ui.handlers.HandlerUtil;
import org.polarsys.chess.core.views.ViewUtils; import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
public class ExportSmv extends AbstractHandler{ import org.polarsys.chess.chessmlprofile.ComponentModel.ComponentType;
import org.polarsys.chess.contracts.transformations.main.GenerateErrorModel;
public Object execute(ExecutionEvent event) throws ExecutionException { import org.polarsys.chess.core.notifications.ResourceNotification;
import org.polarsys.chess.core.profiles.CHESSProfileManager;
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); import org.polarsys.chess.core.util.uml.UMLUtils;
final Shell activeShell = window.getShell(); import org.polarsys.chess.core.views.ViewUtils;
final Class selected = getSelection(window); public class ExportSmv extends AbstractHandler{
if(selected != null){
public Object execute(ExecutionEvent event) throws ExecutionException {
FileDialog dialog = new FileDialog(activeShell,SWT.SAVE);
dialog.setFilterNames(new String[] { "SMV" }); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
dialog.setFilterExtensions(new String[] { "*.smv" }); final Shell activeShell = window.getShell();
String dir = dialog.open(); final Class selected = getSelection(window);
if(dir != null){ if(selected != null){
final File targetDir = (new File(dialog.getFilterPath()));
FileDialog dialog = new FileDialog(activeShell,SWT.SAVE);
String systemQN = selected.getQualifiedName(); dialog.setFilterNames(new String[] { "SMV" });
final List<String> args = new ArrayList<String>(); dialog.setFilterExtensions(new String[] { "*.smv" });
args.add(systemQN);
String systemName = systemQN.substring(systemQN.lastIndexOf("::")+2); String dir = dialog.open();
args.add(systemName); if(dir != null){
args.add(dialog.getFileName().replaceFirst(".smv", "")); final File targetDir = (new File(dialog.getFilterPath()));
Job job = new Job("Exporting to SMV"){ String systemQN = selected.getQualifiedName();
final List<String> args = new ArrayList<String>();
@Override args.add(systemQN);
protected IStatus run(IProgressMonitor monitor) { String systemName = systemQN.substring(systemQN.lastIndexOf("::")+2);
args.add(systemName);
monitor.beginTask("operation in progress ...", 3); args.add(dialog.getFileName().replaceFirst(".smv", ""));
try{
monitor.subTask("transforming..."); Job job = new Job("Exporting to SMV"){
GenerateErrorModel gen = new GenerateErrorModel(selected, targetDir, args); @Override
gen.doGenerate(null); protected IStatus run(IProgressMonitor monitor) {
monitor.worked(1);
monitor.beginTask("operation in progress ...", 3);
}catch (IOException e) { try{
e.printStackTrace(); monitor.subTask("transforming...");
}
monitor.done(); GenerateErrorModel gen = new GenerateErrorModel(selected, targetDir, args);
if (monitor.isCanceled()) gen.doGenerate(null);
return Status.CANCEL_STATUS; monitor.worked(1);
return Status.OK_STATUS;
} }catch (IOException e) {
}; e.printStackTrace();
}
job.setUser(true); monitor.done();
job.setPriority(Job.SHORT); if (monitor.isCanceled())
job.schedule(); return Status.CANCEL_STATUS;
}else{ return Status.OK_STATUS;
return null; }
} };
}
ResourceNotification.showOk("Element exported correctly"); job.setUser(true);
return null; job.setPriority(Job.SHORT);
job.schedule();
} }else{
return null;
private Class getSelection(IWorkbenchWindow window ) { }
ISelectionService selectionService = window.getSelectionService(); }
ISelection selectionX = selectionService.getSelection(); ResourceNotification.showOk("Element exported correctly");
if (!(selectionX instanceof ITreeSelection)){ return null;
ResourceNotification.showOk("Selection not valid: select a single resource on the ModelExplorer");
return null; }
}
ITreeSelection treesel = (ITreeSelection)selectionX; private Class getSelection(IWorkbenchWindow window ) {
if (treesel.getPaths().length == 0 || treesel.getPaths().length > 1){ ISelectionService selectionService = window.getSelectionService();
ResourceNotification.showError("Selection not valid: select a single resource on the ModelExplorer"); ISelection selectionX = selectionService.getSelection();
return null; if (!(selectionX instanceof ITreeSelection)){
} ResourceNotification.showOk("Selection not valid: select a single resource on the ModelExplorer");
return null;
Object obj = treesel.getFirstElement(); }
if (!(obj instanceof EObjectTreeElement)){ ITreeSelection treesel = (ITreeSelection)selectionX;
ResourceNotification.showError("Selection not valid: select a single resource on the ModelExplorer"); if (treesel.getPaths().length == 0 || treesel.getPaths().length > 1){
} ResourceNotification.showError("Selection not valid: select a single resource on the ModelExplorer");
EObject eobj = ((EObjectTreeElement) obj).getEObject(); return null;
final Package view = ViewUtils.getView(eobj); }
// final Model umlModel = view.getModel(); Object obj = treesel.getFirstElement();
final Class umlClass = (Class) eobj; if (!(obj instanceof EObjectTreeElement)){
ResourceNotification.showError("Selection not valid: select a single resource on the ModelExplorer");
if (!ViewUtils.isDesignView(view, CHESSProfileManager.SYSTEM_VIEW) && }
!ViewUtils.isDesignView(view, CHESSProfileManager.COMPONENT_VIEW)) { EObject eobj = ((EObjectTreeElement) obj).getEObject();
ResourceNotification.showError("Selection not valid: please select a resource of the SystemView or of the ComponentView"); final Package view = ViewUtils.getView(eobj);
return null;
} // final Model umlModel = view.getModel();
final Class umlClass = (Class) eobj;
if (ViewUtils.isDesignView(view, CHESSProfileManager.COMPONENT_VIEW)){
if (UMLUtils.getStereotypeApplication(umlClass, ComponentType.class)!= null){ if (!ViewUtils.isDesignView(view, CHESSProfileManager.SYSTEM_VIEW) &&
ResourceNotification.showError("Selection not valid: ComponentType"); !ViewUtils.isDesignView(view, CHESSProfileManager.COMPONENT_VIEW)) {
return null; ResourceNotification.showError("Selection not valid: please select a resource of the SystemView or of the ComponentView");
} return null;
} }
return umlClass; if (ViewUtils.isDesignView(view, CHESSProfileManager.COMPONENT_VIEW)){
} if (UMLUtils.getStereotypeApplication(umlClass, ComponentType.class)!= null){
ResourceNotification.showError("Selection not valid: ComponentType");
} return null;
}
}
return umlClass;
}
}
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; /*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
import org.junit.runner.RunWith; * are made available under the terms of the Eclipse Public License v2.0
import org.junit.runners.Suite; * which accompanies this distribution, and is available at
import org.junit.runners.Suite.SuiteClasses; * http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
@RunWith(Suite.class) package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
@SuiteClasses({
TestBasicOperations.class, TestBasicOperationsHeadless.class, TestSafetyAnalysisOperations.class, TestVAndVOperations.class
,TestVandVOperationsOSLC.class import org.junit.runner.RunWith;
}) import org.junit.runners.Suite;
public class AllTests { import org.junit.runners.Suite.SuiteClasses;
}
@RunWith(Suite.class)
@SuiteClasses({
TestBasicOperations.class, TestBasicOperationsHeadless.class, TestSafetyAnalysisOperations.class, TestVAndVOperations.class
,TestVandVOperationsOSLC.class
})
public class AllTests {
}
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
import java.io.File; import java.io.File;
......
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
import java.io.File; import java.io.File;
......
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
import java.io.File; import java.io.File;
......
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
import java.io.File; import java.io.File;
......
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.tests; package org.polarsys.chess.contracts.verificationService.test.runtime.tests;
import org.eclipse.lyo.client.oslc.OSLCConstants; import org.eclipse.lyo.client.oslc.OSLCConstants;
......
/*******************************************************************************
* 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 v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
******************************************************************************/
package org.polarsys.chess.contracts.verificationService.test.runtime.util; package org.polarsys.chess.contracts.verificationService.test.runtime.util;
import java.io.BufferedReader; import java.io.BufferedReader;
......
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