Commit d8e416e6 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Tree-wide: Update ratings to mirror the rating state of the svn repo.



* Since the tooling helpers used in the svn installation and the git
  version, a re-rating of all files was required (less work than fixing
  the tooling code that would be only used once).
* Updates the hashes of the classes in the .rating files.
* Removes empty .rating files from directories without ratable files.
Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 7104abc7
ActionConstraintChecker.java d1b016ee750f187142b278d996bd5ecd06ebfb96 GREEN
ActionConstraintCheckerBase.java 8b984491a33bbb49d2b3d7f5776e18b9d568492b GREEN
ChannelConstraintChecker.java e227c08751fd7d50f111e15d2089fa6017e1883c GREEN
CodeSpecificationConstraintChecker.java 687b77d1e820bb239f7f0232413b9ff51f46a977 GREEN
ComponentConstraintChecker.java af07c2a98a4db8ca95996d6814a4ba6da7a53fe7 GREEN
ComponentConstraintGroup.java 5a025e2e3c643de56a19907c6c38f54688aa9943 GREEN
ConstraintMessage.java 57a469e85e93b4c96e5de3d6dcab6d2c024b1323 GREEN
DataStateVariableConstraintChecker.java 35f9a182c59c66563b7ed26954554a309e1257b7 GREEN
DataStateVariableConstraintCheckerBase.java 0c462285d7f9d548730b26176f2e55a57407f34d GREEN
GuardConstraintChecker.java 94da9818cd9640a944108ca7730f0b2907573b41 GREEN
GuardConstraintCheckerBase.java f78af2876fea8431de54ce52ee2a7355caeb91e3 GREEN
RetargetTypeCheckConstraintCheckerBase.java ce725cc9a7211d913b4eb8722d7bc7bcdcff10e7 GREEN
TypeCheckConstraintCheckerBase.java be60878fb424416abce80217c7bae3e3e11e487b GREEN
WeakCausalityCycleConstraintChecker.java ef344881f2d16425d1aa78ffd1c7ff33be116a76 GREEN
ActionConstraintChecker.java 800d9239d371d064a9f636c1eba0943f30c01446 GREEN
ActionConstraintCheckerBase.java 3de1ac918ca1e597b008f9616558efb12ff9ed3e GREEN
ChannelConstraintChecker.java 08d15f13a4e5dfb66eb646821c254e915990b142 GREEN
CodeSpecificationConstraintChecker.java 8d7b31f86295225b44210b7fae1524ce3594af86 GREEN
ComponentConstraintChecker.java 7be19204cc316bdc0f008ea664a905afefb906e5 GREEN
ComponentConstraintGroup.java a01c05c57a7280ed6ef9dff5f5eda15ad641a4e6 GREEN
ConstraintMessage.java 5c6a3ab97bdd603e35b1daa69fb600c35aba24c1 GREEN
DataStateVariableConstraintChecker.java 4a561c6c18138a2cef241a5d08a5f2525131e25f GREEN
DataStateVariableConstraintCheckerBase.java 640f62f4e5ff077266880bc04c9e23deb4eb452b GREEN
GuardConstraintChecker.java 0d998f9d2bae2925194ab34f25861147e2dbb9ef GREEN
GuardConstraintCheckerBase.java bb13955b134b969ad9612fa0bd8c4a5c6eddb616 GREEN
RetargetTypeCheckConstraintCheckerBase.java 193a77a22e75e3159bb9fda73e0f41098d0b1b3f GREEN
TypeCheckConstraintCheckerBase.java 0ac543da85da3e5ae08af0be54df506e028771fc GREEN
WeakCausalityCycleConstraintChecker.java b0d304983a5797636267b281f75b3cabae0ae173 GREEN
CPortReplacement.java f744963ba37652abbb265c849a3d01497984f0ef GREEN
ComponentArchitectureToCSourcePackageTransformation.java 9b3c460626f4c7ee6c58bcb6f7974ae82094753c GREEN
ComponentArchitectureToFMUArchivePackageTransformation.java c48801ad1abdbc477f579d35025a4540fbb1fb6c GREEN
ComponentProgramToCSourcePackageTransformation.java f32609f55fc2bfd81d07c2ce5d40968e1dad97d9 GREEN
CPortReplacement.java a88d71295e33d1f2a5d35483ebfc742b850d8792 GREEN
ComponentArchitectureToCSourcePackageTransformation.java 562a09729ac2a6b032fabbdfc191144d2d2b8f32 GREEN
ComponentArchitectureToFMUArchivePackageTransformation.java 3209172e17190a293d1bac3169924d23bc9bb74a GREEN
ComponentProgramToCSourcePackageTransformation.java f1517c952327a323f02253446c4e219aeaa44967 GREEN
CodeSpecificationToComponentProgramTransformation.java 043ada89c7297af79b805d80558bc73609fac3e6 GREEN
ComponentFunctionIdentifierUtils.java 4a05646661f1609c9fdd1cc662f8d05ff74f1847 GREEN
ComponentProgramTransformationBase.java 00ce4f5949558855ec16187c904105a2b2c810aa GREEN
CompositeComponentToComponentProgramTransformation.java 91274b336f373430d51d1229e5fa89781ced216a GREEN
PortVariableUtils.java 35e7744dabb0a3b0f81feedfd37d8def8b43d6a6 GREEN
TermReplacement.java 70c07af86b57acd63ab522f65f937463fc548248 GREEN
CodeSpecificationToComponentProgramTransformation.java eb0f4ca27989efce299bc2aba3c07a96e29b0fad GREEN
ComponentFunctionIdentifierUtils.java 57ff40789fb157c20bde150f3bbf813dd8bcd187 GREEN
ComponentProgramTransformationBase.java c2032bb8f886dd644c27b76d991144ccb039cacc GREEN
CompositeComponentToComponentProgramTransformation.java beb359b95bc01aa34cfc1422debd09016db40a69 GREEN
PortVariableUtils.java 8e7d895cf561eea093a2319290ddf7f991f98507 GREEN
TermReplacement.java 1c587eb3ee61d3b72ff78efad6c514d54aebedf9 GREEN
ComponentArchitectureToJavaSourcePackageTransformation.java 618a2401e77b838b0beca9b283f61551ec0739be GREEN
ComponentProgramToJavaSourcePackageTransformation.java 5d41aa9a27cd8e14ca461ec236982a9cf0a12c97 GREEN
JavaReplacement.java 713c046ecfa313c4874527894ec3cba2ed2d02b3 GREEN
ComponentArchitectureToJavaSourcePackageTransformation.java 6db3a88630f16c78137eb2ec9659717829ee93b5 GREEN
ComponentProgramToJavaSourcePackageTransformation.java 2b0f7540ed5e4ab678e7feaeb0159a6ac760aa28 GREEN
JavaReplacement.java 83c19dd144682e5e603b127a73b2a35525e459f3 GREEN
AF3ToNuSMVConsts.java 5778ae07a01b235df7b43f4a7d27d069efd36b2e GREEN
ArrayToStructVariableDefinition.java 9fe1c7cb090d9e6a20c8f242d5f6453fd691c584 GREEN
CodeSpecPrepareAddReturnStatement.java 345452b4f08d0e41c5f8a9650310c9add2bad414 GREEN
CodeSpecPrepareRemoveMultipleAssignments.java 34b36ea5e8116289160a244c5ae7d254900c619e GREEN
CodeSpecPrepareToIfElseBlock.java bd01d2bdfadf0b4642c9ed3d889fc23c19435616 GREEN
CodeSpecPrepareToIfSequence.java 7c6aa9a8e09600c28a35d6be97bb20d0aa546f91 GREEN
CopyProject.java cda5c16613ab88c2430960ebac4b3fd0d086bc13 GREEN
FlattenVariableDefs.java 30a49d3876655b637f51e381e946979239ed59aa GREEN
MultiValuedMap.java a48091f2a40ae06984f43a50a86cbc8e9bd8c5ba GREEN
NamesTransformation.java 278bdc970d5e14ee2b9035e4ca542c6122eb55a7 GREEN
ResolveNoVal.java 2d7727f4afaef58a54314f5a4d900e47bff9caa0 GREEN
StandaloneBooleanVarToFunctionCall.java 7d5c7458131b6c3bc82042bdbeec6973c2cece7d GREEN
ToNuSMVComponent.java 52f75f473a12019e81054da0eb17c0ba2aeb9351 GREEN
ToNuSMVDataDictionary.java 3b44b3b3230cdf44d2b167996a7d8eb871f0ed07 GREEN
ToNuSMVExpression.java d97e5860451ac72abf829a482f159a42e6c0d047 GREEN
AF3ToNuSMVConsts.java 873d75fa85215be06915a97ddcd760883dca56db GREEN
ArrayToStructVariableDefinition.java 796523020c2b817032bb989f56094404adf84946 GREEN
CodeSpecPrepareAddReturnStatement.java 48c2d69fa9736e437c1ffe8335f0097a53cca022 GREEN
CodeSpecPrepareRemoveMultipleAssignments.java efc9876dad06e8759fa697122d0f80a680c7050a GREEN
CodeSpecPrepareToIfElseBlock.java 0e8200ae771a525aff3205654df24528640c3e8c GREEN
CodeSpecPrepareToIfSequence.java be83903eafb935c85ed40c0389b60331687c405a GREEN
CopyProject.java eb81b8ad0c46dbdbb82251637cc837754793d8e4 GREEN
FlattenVariableDefs.java 71fb9ee878387343436e33c34e77fd406bffa4c5 GREEN
MultiValuedMap.java 9a92088a5d39dab3e64dfbb05db0507cb6e89b9a GREEN
NamesTransformation.java c4988d68fc86a43faa562f2155941fc2f5626d83 GREEN
ResolveNoVal.java 7a2001b6397182f44f341602fc9fefc3c6cecfd9 GREEN
StandaloneBooleanVarToFunctionCall.java aee7121ff24e8a4171ce5448c96c62e1c16c109f GREEN
ToNuSMVComponent.java 3f0d9b8360b7397bd1500c0057e2003b81bb4bab GREEN
ToNuSMVDataDictionary.java e415ae007deea8c55f0141142946f170fdfefa11 GREEN
ToNuSMVExpression.java 6dd47d4ada462506f7dc97f3138d74f78442b3a3 GREEN
ComponentLibraryHandler.java 0d065425a2d085fe486ff8808ece3e695a18f9a1 GREEN
ComponentLibraryHandler.java 0fd595de1cad0e81b752aa67571d88da3f7d8a9c GREEN
ComponentLibraryPrototype.java 67d51bb033f64f038840ac168b7747a6a369837f GREEN
ComponentLibraryPrototypeProvider.java 067403c78fdcfabf768570caf6e80a0a38881d1d GREEN
ComponentLibraryPrototype.java 94c808c249fa231e1e15b173a5243c092bf7e2e3 GREEN
ComponentLibraryPrototypeProvider.java 6d2cd4f7c0fd35b13fbe070977de622e90ce556b GREEN
CodeSpecificationStaticImpl.java 77c43f3842c57eb78ac44a49439f94a0e1297d0b GREEN
CodeSpecificationStaticImpl.java 52b59dde1f21792bc1ac119b1a55f498abfdf87b GREEN
ActionStaticImpl.java 47de617d654ee004dab5e4dc75107adddab9e276 GREEN
DataStateVariableStaticImpl.java cb2cb3a1b7bc6d84934937815d11d318cafd8ac2 GREEN
GuardStaticImpl.java 8e20d4b34ecf64a64b559e983d23b36165decd9b GREEN
ActionStaticImpl.java 8d0948c654c65396ae46ef9c1a47c7e46254d011 GREEN
DataStateVariableStaticImpl.java e3b04ed90f380a2c7c33b01e3164ebcc08afea32 GREEN
GuardStaticImpl.java 6e7c38f6c35af8cccf18a3ec7feede840b09474c GREEN
ReadPortVariableExpressionStaticImpl.java 3b39629e0728697bf9422ccac7e7a6d5be556e73 GREEN
TestPortVariableExpressionStaticImpl.java f0ebc492ea5fc72e739913838f92a15561f5e434 GREEN
WritePortVariableStatementStaticImpl.java bd4e7ea648435ad2300d2a9f1407c379f7660196 GREEN
ReadPortVariableExpressionStaticImpl.java 01b24c25895b425ec5007594b9da606357a4274f GREEN
TestPortVariableExpressionStaticImpl.java b6f8466729b3359f061ac23f9d0f198e6d9c9f2f GREEN
WritePortVariableStatementStaticImpl.java a05e7f6b9a5cb9c42ab1fa9b725d7496de96f8fb GREEN
ChannelStaticImpl.java 8d5173e1793d2c9970ef2a137b1e85de138cd8fd GREEN
ComponentArchitectureStaticImpl.java 439e13723dd400539a9446bb5b73ac3a1f443036 GREEN
ComponentRefStaticImpl.java 477de737e1a6252edab8f78787d3369502361105 GREEN
ComponentStaticImpl.java 7f660d95485602c6ee7976d203f89d8b5f488c44 GREEN
LibraryComponentPackageStaticImpl.java 066fa7a1dfcfe15f0d7e126089417f67cfd7f213 GREEN
LibraryComponentStaticImpl.java f850b1b1711c1f2092a9947b559966a6e83f08c3 GREEN
PortSpecificationStaticImpl.java 075fbc3427db8a94b78f398a7dca49e20ebf0360 GREEN
PortStaticImpl.java c3c6301aec61b08056ceae611453902f83035cf5 GREEN
ChannelStaticImpl.java a7ed787738b1be77ea8e5f624e3aeb7fad8aff65 GREEN
ComponentArchitectureStaticImpl.java 8c5acf769a980f2b0a8139aa3484d3f5f704b4a6 GREEN
ComponentRefStaticImpl.java 41689aa04c15ab3c66ad23c4d5a7f45b16cad844 GREEN
ComponentStaticImpl.java 8ac1cc3509d4dad8be01cfe9d336bfca57db7fc6 GREEN
LibraryComponentPackageStaticImpl.java 4939fb91b2c8a0cac4a4bed4431ad089f33ed14c GREEN
LibraryComponentStaticImpl.java 3e00f70f12e14e961f6fd41606176c144ef947ae GREEN
PortSpecificationStaticImpl.java 12806cc91a671460d2c67f72773d850f9ca39cc6 GREEN
PortStaticImpl.java 2fe2b113156c7618a16626a8a0d708369e9fe7bf GREEN
MigrationProvider.java 555f074c2c99cadab5ce72b30c8dddd049bcee11 GREEN
MigrationProvider.java 64b07790d9ae972bb09694affd35d389a4a47b99 GREEN
GloballyCategorizedPrototypeProviderBase.java 18a42f9171bb69cfb8977e1fa6b24349b7a1a957 GREEN
GloballyCategorizedPrototypeProviderBase.java ea2549b47889edceea4a26933359860f5d08bd39 GREEN
ExecutableAtomicComponentBase.java 069fb4523fd444c49393436115ea75189796dd48 GREEN
ExecutableBlackBox.java 62cfd61d9cfc2025e76177aec70fa42117b249a1 GREEN
ExecutableCodeSpecification.java 47841e5a0cff6fa46bee253bdc79a5b65cd52788 GREEN
ExecutableComponent.java f27213395fc7ef470f6214896e3bbe13c0081f3b GREEN
ExecutableCompositeComponent.java 967698ec141f8ccdfc3c2cfec84520a813997d52 GREEN
ExecutionException.java fe7b4915962c43d9f729d10da859bf142d3d8f15 GREEN
ITraceListener.java 3479190257171eb360671967af83c41eb4dcf74b GREEN
SignalSource.java 4b78dcf981c8e4938c0230e5f63075b945660c23 GREEN
ExecutableAtomicComponentBase.java 00c4ad01eadeb399db4f925a316bebc9843b1182 GREEN
ExecutableBlackBox.java 34b1c7ee39074c9642aef35ee171bb6488601b15 GREEN
ExecutableCodeSpecification.java 40bf7133f376c46e9f2fb51c9d3aded46e2fe4fe GREEN
ExecutableComponent.java 31d64ed396b013f3e7f25266e9aaa76bc17e701d GREEN
ExecutableCompositeComponent.java 373ab25da9b55db3ab5e0b35553d5c5e21f5c3aa GREEN
ExecutionException.java 5fffab2b29c7794e2feeb7041c1991701e9a4100 GREEN
ITraceListener.java b1bd97885b88987acb32bedd66b9f066fe0e2a28 GREEN
SignalSource.java 95725553597612f3f5fdfd4970934e1332148de5 GREEN
ExecutableCodeSpecificationTransformation.java 6b2278d9df0e1d74843e54af592f27541f10b2d6 GREEN
ExecutableComponentTransformationBase.java dd4ce115d9c9b29c1558a7b24364faa7b023c2b6 GREEN
ExecutableCompositeComponentTransformation.java d7dbc48a9384e7dee47293a2fb4cb1fa624f8c78 GREEN
MissingComponentBehaviorTransformation.java e47e9f710ff20389554b25ce0ab89bda4b89f267 GREEN
ExecutableCodeSpecificationTransformation.java 50e3e9334b2922a1902a82a57308e41700a2a66d GREEN
ExecutableComponentTransformationBase.java 2e2c43819a9bf6deddef25542b746069dfa62c1e GREEN
ExecutableCompositeComponentTransformation.java beffe5d6ebd1da59d8f2a3ada788b1b7b4b733f3 GREEN
MissingComponentBehaviorTransformation.java e855f014e871b2e3cf286037a44d98686fa015db GREEN
BehaviorModelElementFactory.java 7e4e9de4fcac3790eb0664963dd2b403db1659d0 GREEN
ComponentArchitectureTransformationBase.java 8feabb8dc141d4e2c4d2f56526bffac06c6734ce GREEN
ComponentArchitectureUtils.java 80fcfc03ad4f9f383af463ad703a91211546dd79 GREEN
ComponentLibraryModelElementFactory.java 186b2e27e184cac8149ac28a28343ecd76ddf157 GREEN
ComponentLibraryUtils.java 69bb291f7c5c9fb037fcc6b938793df2b1281b26 GREEN
ComponentModelElementFactory.java 2f3e136e37f56f3675121fa9c3515cc083f10d12 GREEN
ComponentProgramUtils.java ece02e69081cfdf558af7511927cd80294d2c018 GREEN
ComponentUtils.java 2cb3855a360ef58c2a49d7485d40841bc3070aa9 GREEN
FormalAnalysisTransformationUtils.java 72ea815b08d1a4ff8a0fa086902300bb3796de86 GREEN
GeneratorModelElementFactory.java e493ab2408fd1cd154960eca5cd09c1647321a7c GREEN
IComponentArchitectureTransformation.java d4dbb9895aa4dcb23486013c0ea1db7e8411b02e GREEN
SimulationUtils.java 009faa681a95baf35e3d9552ef5300effaeb9fb5 GREEN
BehaviorModelElementFactory.java 5be68f9a2ae4fad663d6fb20f6c5c7b12c0647ab GREEN
ComponentArchitectureTransformationBase.java 762c9311377f0bee7ff0aff70344601ff8f832c7 GREEN
ComponentArchitectureUtils.java 69af57a2bf19473f4202dc7fb95d64c4e93a7bd7 GREEN
ComponentLibraryModelElementFactory.java b6c854e91d431fa3bc42fafdcf618a2040d23ab4 GREEN
ComponentLibraryUtils.java eacae09896dab81355565ae295c2c3400ab007b0 GREEN
ComponentModelElementFactory.java 520d0d3d3763dee16990d4d30792fbf315d10a8a GREEN
ComponentProgramUtils.java 71faad6256159ee2d59843fcde83ac6995dff0fe GREEN
ComponentUtils.java 91918ddde8db6ca4fb148dbb82d7e0c5d07dae9f GREEN
FormalAnalysisTransformationUtils.java f1d2125284bcbc9c3ab45bdb23e483317dc0c351 GREEN
GeneratorModelElementFactory.java 7fdb75341336fe579d4338a53c99df2f091c2b09 GREEN
IComponentArchitectureTransformation.java 146974a2abefb74f51dd8045990ffd6a3ed62866 GREEN
SimulationUtils.java 4a77edd9c52efab678ba422beb34817497d0886b GREEN
documentation.html c5e0c8d7e1d3bfe8e9420e374cc2ce816e6a9418 GREEN
documentation.html a333de07b53abdd7823928a13cbd5e825d4dae0c GREEN
AF3CosimulationUIActivator.java 7313561f5b1d8e100c879857e163f649a3cd009a GREEN
AF3CosimulationUIActivator.java c949492fd0b08f341baa09ec8bad0fe613c5c650 GREEN
ExternalSpecificationEditor.java be774141c43db45a4b56bd71e8b7495e2fc7a488 GREEN
ExternalSpecificationEditorBinding.java 85da9425c5b8a45869aeb58f04edd053458cd4ca GREEN
ExternalSpecificationEditor.java eae484e685abfac8124a8875d6dbef21a663dae3 GREEN
ExternalSpecificationEditorBinding.java c5ede1e02867805e28e6c95c52ec3557466db47a GREEN
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.cosimulation.ui.editor;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.deleteExtraPorts;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.extractXMLFile;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.fileDialog;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.parseXMLAndCreateOrModifyPorts;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import static org.fortiss.tooling.kernel.ui.util.WidgetsFactory.createTextWithUndo;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.IReadOnlyBehaviorSpecification;
import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.cosimulation.model.AF3CosimulationPackage;
import org.fortiss.af3.cosimulation.model.FMUSpecification;
import org.fortiss.af3.cosimulation.model.IExternalBehaviorSpecification;
import org.fortiss.af3.cosimulation.model.SimulinkSpecification;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.xml.sax.helpers.DefaultHandler;
/**
* Editor for {@link FMUSpecification} and {@link SimulinkSpecification}
*
* @author aziz
*/
public class ExternalSpecificationEditor extends FormsEditorBase<IExternalBehaviorSpecification> {
/** Cached form object. */
private ScrolledForm specForm;
/** {@inheritDoc} */
@Override
protected void createSections() {
String specName;
if(!(editedObject instanceof FMUSpecification || editedObject instanceof SimulinkSpecification)) {
return;
}
specName = editedObject instanceof FMUSpecification ? "FMU" : "Simulink";
pathSection(specName);
specForm.reflow(true);
}
/** Section to define the parameter FMUPath/SimPath of the FMU/Simulink. */
private void pathSection(String specName) {
boolean isFMU = editedObject instanceof FMUSpecification;
GridDataFactory layout = GridDataFactory.fillDefaults().grab(true, false);
Composite composeExternalSection =
createNewSection(specName + " Specification", "Provide the path for " + specName +
":");
composeExternalSection.setLayout(new GridLayout(3, false));
toolkit.createLabel(composeExternalSection, specName + " Path:");
Text hostText = createTextWithUndo(toolkit, composeExternalSection, "");
hostText.setEditable(false);
layout.applyTo(hostText);
if(isFMU) {
bind(dbc, hostText, getEditedObject(),
AF3CosimulationPackage.Literals.FMU_SPECIFICATION__FMU_PATH);
} else {
bind(dbc, hostText, getEditedObject(),
AF3CosimulationPackage.Literals.SIMULINK_SPECIFICATION__SIM_PATH);
}
Button browse = new Button(composeExternalSection, SWT.NONE);
browse.setText("Browse");
browse.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
switch(e.type) {
case SWT.Selection:
try {
executeFileExtractionAndCreateIOPorts(editedObject, true, isFMU);
} catch(IOException e1) {
throw new RuntimeException("[Directory Deletion] error: " +
e1.getMessage());
}
break;
}
}
});
toolkit.createLabel(composeExternalSection, "Press to update the component:");
Button update = new Button(composeExternalSection, SWT.NONE);
update.setText("Update");
update.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
switch(e.type) {
case SWT.Selection:
try {
executeFileExtractionAndCreateIOPorts(editedObject, false, isFMU);
} catch(IOException e1) {
throw new RuntimeException("[Directory create] error: " +
e1.getMessage());
}
break;
}
}
});
}
/** {@inheritDoc} */
@Override
protected void setupScrolledForm(final ScrolledForm form) {
this.specForm = form;
}
/**
* Unzip the .fmu/.slx and extract the XML file in the temporary build directory. Then, read the
* extracted file to generate the I/O ports for component.
*/
public void executeFileExtractionAndCreateIOPorts(IReadOnlyBehaviorSpecification elt,
boolean takeInput, boolean isFMU) throws IOException {
ArrayList<Port> newOutputPorts = new ArrayList<>();
ArrayList<Port> newInputPorts = new ArrayList<>();
ITopLevelElement modelContext =
IPersistencyService.getInstance().getTopLevelElementFor(elt);
String tempBuildDirectoryPath =
Files.createTempDirectory("temporaryXMLFileDirectory").toString();
modelContext
.runAsCommand(() -> {
String filePath;
Component container = null;
String xmlName = null;
String fileType = null;
if(isFMU) {
fileType = "*.fmu";
filePath =
takeInput ? fileDialog(fileType) : ((FMUSpecification)elt)
.getFMUPath();
((FMUSpecification)elt).setFMUPath(filePath);
xmlName = "modelDescription.xml";
container = ((FMUSpecification)elt).getComponent();
} else {
fileType = "*.slx";
filePath =
takeInput ? fileDialog(fileType) : ((SimulinkSpecification)elt)
.getSimPath();
((SimulinkSpecification)elt).setSimPath(filePath);
xmlName = "graphicalInterface.xml";
container = ((SimulinkSpecification)elt).getComponent();
}
Shell currentShell = getWorkbench().getActiveWorkbenchWindow().getShell();
boolean fileExist = true;
try {
extractXMLFile(tempBuildDirectoryPath, filePath, xmlName);
} catch(IOException e) {
MessageDialog.openInformation(currentShell, "[" + fileType +
" import] File not found: ", fileType +
" file does not exist at the selected path");
fileExist = false;
} catch(NullPointerException e) {
if(!takeInput) {
MessageDialog
.openInformation(currentShell, "[" + fileType +
" import] File not found: ", fileType +
" file is not selected");
}
fileExist = false;
}
if(fileExist) {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser;
try {
saxParser = factory.newSAXParser();
DefaultHandler handler =
parseXMLAndCreateOrModifyPorts(container, newOutputPorts,
newInputPorts);
saxParser.parse(tempBuildDirectoryPath + File.separator + xmlName,
handler);
deleteExtraPorts(newInputPorts, newOutputPorts, container);
} catch(Exception e) {
MessageDialog.openInformation(currentShell, "[XML import] " + fileType +
" File Error: ", "Required XML file is not found in the " +
fileType +
" or its format is not in accordance with the standard");
}
}
try {
deleteDirectory(new File(tempBuildDirectoryPath));
} catch(Exception e) {
throw new RuntimeException("[Directory Deletion] error: " + e.getMessage());
}
});
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.cosimulation.ui.editor;
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.deleteExtraPorts;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.extractXMLFile;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.fileDialog;
import static org.fortiss.af3.cosimulation.ui.utils.EditorUtils.parseXMLAndCreateOrModifyPorts;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import static org.fortiss.tooling.kernel.ui.util.WidgetsFactory.createTextWithUndo;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.IReadOnlyBehaviorSpecification;
import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.cosimulation.model.AF3CosimulationPackage;
import org.fortiss.af3.cosimulation.model.FMUSpecification;
import org.fortiss.af3.cosimulation.model.IExternalBehaviorSpecification;
import org.fortiss.af3.cosimulation.model.SimulinkSpecification;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.xml.sax.helpers.DefaultHandler;
/**
* Editor for {@link FMUSpecification} and {@link SimulinkSpecification}
*
* @author aziz
*/
public class ExternalSpecificationEditor extends FormsEditorBase<IExternalBehaviorSpecification> {
/** Cached form object. */
private ScrolledForm specForm;
/** {@inheritDoc} */
@Override
protected void createSections() {
String specName;
if(!(editedObject instanceof FMUSpecification || editedObject instanceof SimulinkSpecification)) {
return;
}
specName = editedObject instanceof FMUSpecification ? "FMU" : "Simulink";
pathSection(specName);
specForm.reflow(true);
}
/** Section to define the parameter FMUPath/SimPath of the FMU/Simulink. */
private void pathSection(String specName) {
boolean isFMU = editedObject instanceof FMUSpecification;
GridDataFactory layout = GridDataFactory.fillDefaults().grab(true, false);
Composite composeExternalSection =
createNewSection(specName + " Specification", "Provide the path for " + specName +
":");
composeExternalSection.setLayout(new GridLayout(3, false));
toolkit.createLabel(composeExternalSection, specName + " Path:");
Text hostText = createTextWithUndo(toolkit, composeExternalSection, "");
hostText.setEditable(false);
layout.applyTo(hostText);
if(isFMU) {
bind(dbc, hostText, getEditedObject(),
AF3CosimulationPackage.Literals.FMU_SPECIFICATION__FMU_PATH);
} else {
bind(dbc, hostText, getEditedObject(),
AF3CosimulationPackage.Literals.SIMULINK_SPECIFICATION__SIM_PATH);
}
<