diff --git a/.classpath b/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..e801ebfb4680123285c15553dc70584276fe0057 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ +<?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-11"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/.gitignore b/.gitignore index 763bc5ded238b70af005ecfed5fca311895d1e0a..13b78907b4c6c421f59c109df7d4acd8170bfb22 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.rej .DS_Store ._.DS_Store +/bin/ diff --git a/.gitmodules b/.gitmodules index 45fe7c2da10d5c1e0b2959d1583dbd5bb6db0555..243cfd15e91066976e25414558514dacf3a95f82 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "org.fortiss.tooling.ext.quality/.settings"] path = org.fortiss.tooling.ext.quality/.settings url = https://git.fortiss.org/af3/plugin-settings.git +[submodule "org.fortiss.tooling.ext.quality.ui/.settings"] + path = org.fortiss.tooling.ext.quality.ui/.settings + url = https://git.fortiss.org/af3/plugin-settings.git diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..72f463be037bd4771a7edc320e7893e9681a6a57 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.fortiss.tooling.ext.quality.ui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <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> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..c9545f06a4120d5b4a1228fb19f67a1171bc0f5b --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..0085736d8e68cacb77e63364024ab1fc4fef0e9e --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ui +Bundle-SymbolicName: org.fortiss.tooling.ext.quality.ui +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: org.fortiss.tooling.ext.quality.ui +Automatic-Module-Name: org.fortiss.tooling.ext.quality.ui +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Import-Package: org.eclipse.emf.ecore, + org.eclipse.jface.action, + org.eclipse.jface.resource, + org.eclipse.ui.plugin, + org.fortiss.tooling.ext.quality, + org.fortiss.tooling.kernel.ui.extension, + org.fortiss.tooling.kernel.ui.extension.data, + org.osgi.framework;version="1.9.0" diff --git a/build.properties b/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..34d2e4d2dad529ceaeb953bfcdb63c51d69ffed2 --- /dev/null +++ b/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.fortiss.tooling.ext.quality.ui/.settings b/org.fortiss.tooling.ext.quality.ui/.settings new file mode 160000 index 0000000000000000000000000000000000000000..310d1c04f28f6252d5a02dd8fde1b76ae4a4da51 --- /dev/null +++ b/org.fortiss.tooling.ext.quality.ui/.settings @@ -0,0 +1 @@ +Subproject commit 310d1c04f28f6252d5a02dd8fde1b76ae4a4da51 diff --git a/org.fortiss.tooling.ext.quality.ui/META-INF/MANIFEST.MF b/org.fortiss.tooling.ext.quality.ui/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..863d5c1e6d6695be9b29eeb7437c1ec4efc71c57 --- /dev/null +++ b/org.fortiss.tooling.ext.quality.ui/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.fortiss.tooling.ext.quality.ui +Bundle-SymbolicName: org.fortiss.tooling.ext.quality.ui;singleton:=true +Bundle-Version: 1.0.0 +Automatic-Module-Name: org.fortiss.tooling.ext.quality.ui +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Require-Bundle: org.eclipse.ui.ide;visibility:=reexport, + org.fortiss.tooling.base.ui;visibility:=reexport, + org.fortiss.tooling.kernel, + org.fortiss.tooling.kernel.ui, + org.fortiss.tooling.ext.reuse, + org.eclipse.emf.ecore diff --git a/org.fortiss.tooling.ext.quality.ui/plugin.xml b/org.fortiss.tooling.ext.quality.ui/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..99b8f591c261e36578c0f28348f3ae0019814fcd --- /dev/null +++ b/org.fortiss.tooling.ext.quality.ui/plugin.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<!-- (c) 2021 fortiss GmbH --> + +<plugin> + <extension point="org.fortiss.tooling.kernel.ui.contextMenuContribution"> + <contextMenuContribution + contributor="org.fortiss.tooling.ext.quality.ui.MetricExtractionMenu"> + </contextMenuContribution> + </extension> +</plugin> \ No newline at end of file diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/MetricExtractionMenu.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/MetricExtractionMenu.java new file mode 100644 index 0000000000000000000000000000000000000000..a268a43bf4639f8966f71b30ad8144a6ad00f59c --- /dev/null +++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/MetricExtractionMenu.java @@ -0,0 +1,75 @@ +package org.fortiss.tooling.ext.quality.ui; + +/*-------------------------------------------------------------------------+ +| Copyright 2019 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. | ++--------------------------------------------------------------------------*/ +import static java.util.Arrays.asList; +import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID; + + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor; +import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; + +/** + * Crates a context menu entry to generate the for the selected + * + * @author munaro + */ +public class MetricExtractionMenu implements IContextMenuContributor { + + /** String appearing in the context menu. */ + private static final String MENU_NAME = "Extract metrics"; + + /** {@inheritDoc} */ + @Override + public List<IContributionItem> getContributedItems(EObject selection, + ContextMenuContextProvider contextProvider) { + return asList(new IContributionItem[] { + new ActionContributionItem(new MetricExtractionAction())}); + } + + /** {@inheritDoc} */ + @Override + public String getMenuSectionID() { + return BOTTOM_MOST_MENU_SECTION_ID; + } + + /** Returns the icon that is visible in the context menu for this entry. */ + protected ImageDescriptor getActionIcon() { + return QualityUIActivator.getImageDescriptor("icons/componentarchitecture.gif"); + } + + /** Action for generating the set of . */ + protected class MetricExtractionAction extends Action { + + /** Constructor. */ + public MetricExtractionAction() { + super(MENU_NAME, getActionIcon()); + } + + /** {@inheritDoc} */ + @Override + public void run() { + System.out.println("We print something"); + } + } +} diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/QualityUIActivator.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/QualityUIActivator.java new file mode 100644 index 0000000000000000000000000000000000000000..ecf17f2329ec9811f2bd5795874f913fa189a281 --- /dev/null +++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/QualityUIActivator.java @@ -0,0 +1,53 @@ +package org.fortiss.tooling.ext.quality.ui; + +import static org.eclipse.jface.resource.ResourceLocator.imageDescriptorFromBundle; + +import org.eclipse.core.runtime.Plugin; +import org.eclipse.jface.resource.ImageDescriptor; +import org.osgi.framework.BundleContext; + +/** + * @author blaschke + * + */ +public class QualityUIActivator extends Plugin { + + /** The plug-in ID. */ + public static final String PLUGIN_ID = QualityUIActivator.class.getPackage().getName(); // $NON-NLS-1$ + + /** The shared instance. */ + private static QualityUIActivator plugin; + + /** {@inheritDoc} */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /** {@inheritDoc} */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance. + * + * @return The shared instance of ToolingReuseActivator + */ + public static QualityUIActivator getDefault() { + return plugin; + } + + /** + * Returns the image descriptor for the given icon file. + * + * @param path The path to the icon file of the image descriptor + * @return The image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromBundle(PLUGIN_ID, path).orElse(null); + } +} diff --git a/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF b/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF index 4db8cb70af2dc664684e1c99e81c1954373993e1..e2351f8911be3349d2ca653ceedf337b2205a971 100644 --- a/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF +++ b/org.fortiss.tooling.ext.quality/META-INF/MANIFEST.MF @@ -11,8 +11,6 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.emf.ecore;visibility:=reexport, org.fortiss.tooling.base;visibility:=reexport, org.fortiss.tooling.kernel;visibility:=reexport -Export-Package: org.fortiss.tooling.ext.quality.service -Import-Package: org.fortiss.af3.component.model, - org.fortiss.af3.component.utils, - org.fortiss.af3.project.model, - org.fortiss.af3.project.utils +Export-Package: org.fortiss.tooling.ext.quality, + org.fortiss.tooling.ext.quality.service + diff --git a/org.fortiss.tooling.ext.quality/plugin.xml b/org.fortiss.tooling.ext.quality/plugin.xml index dd83c26918967eac1e57c04d1b0300c8bc7efc7a..5535690d3778e11156a22397241826e5d5766009 100644 --- a/org.fortiss.tooling.ext.quality/plugin.xml +++ b/org.fortiss.tooling.ext.quality/plugin.xml @@ -1,21 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> - <extension - point="org.eclipse.emf.ecore.generated_package"> - <package - class="org.fortiss.tooling.ext.quality.EPackage1" - uri="org.fortiss.tooling.ext.quality.package1"> - </package> - </extension> - <extension - point="org.fortiss.tooling.kernel.modelElementCompositor"> - <modelElementCompositor - compositor="org.fortiss.tooling.ext.quality.ElementCompositor1"> - <modelElementClass - modelElementClass="org.fortiss.tooling.ext.quality.EObject1"> - </modelElementClass> - </modelElementCompositor> - </extension> </plugin> diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java index 1e669b9101c4962995e788572a918d7d960eff15..f2813520a1c4420b902907d67d323077a58b76db 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IMetricService.java @@ -28,4 +28,7 @@ public interface IMetricService { /** Registers the metric provider with the service. */ void registerMetricProvider(IMetricProvider<?> provider, Class<?> modelElementClass); + + /** trigger extraction to csv document */ + void metricExtractionToCSV(); } diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java index b9c2144af7fbbe06c6947200b1f3d175e361dec7..3e5fe0a62a0331f6abff935ddd68414b3d07d670 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricCommentProvider.java @@ -15,19 +15,27 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.ext.quality.service; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; -import org.fortiss.af3.component.model.InputPort; -import org.fortiss.af3.component.model.PortSpecification; +//import org.fortiss.af3.component.model.InputPort; +//import org.fortiss.af3.component.model.PortSpecification; import org.fortiss.tooling.base.model.base.HierarchicElementBase; import org.fortiss.tooling.base.model.element.IConnector; import org.fortiss.tooling.base.model.element.IHierarchicElement; +import org.fortiss.tooling.base.model.element.IModelElementSpecification; +import org.fortiss.tooling.ext.quality.service.IMetricProvider; import org.fortiss.tooling.kernel.model.INamedCommentedElement; /** @@ -51,14 +59,15 @@ public class MetricCommentProvider implements IMetricProvider<IHierarchicElement return strings; } + /** */ public void startRecursion(IHierarchicElement topElement) { - + Set<IElementConsumer> consumers = new HashSet<MetricCommentProvider.IElementConsumer>(); consumers.add(new PortCounter()); consumers.add(new ConnectionCounter()); consumers.add(new ElementCounter()); consumers.add(new CommentCompleteness()); - consumers.add(new CloneDetection()); + // consumers.add(new CloneDetection()); traverse(topElement, consumers); @@ -85,6 +94,41 @@ public class MetricCommentProvider implements IMetricProvider<IHierarchicElement public void printResult(); } + public static class MetricCSVWriter { + private static final String FILE_PATH = "data_ultra_cool.csv"; + private static final String CSV_SEPARATOR = ","; + + private BufferedWriter writer; + + public void openFile() throws IOException { + writer = new BufferedWriter(new FileWriter(FILE_PATH, true)); + } + + public void writeData(int value1, int value2) { + try { + String timestamp = getCurrentTimestamp(); + String dataLine = timestamp + CSV_SEPARATOR + value1 + CSV_SEPARATOR + value2; + writer.write(dataLine); + writer.newLine(); + writer.flush(); + } catch(IOException e) { + e.printStackTrace(); + } + } + + public void closeFile() throws IOException { + if(writer != null) { + writer.close(); + } + } + + private String getCurrentTimestamp() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + return dateFormat.format(now); + } + } + public abstract class MultiMethodDemo implements IElementConsumer { @Override @@ -102,91 +146,91 @@ public class MetricCommentProvider implements IMetricProvider<IHierarchicElement } - public class CloneDetection implements IElementConsumer { - - private Map<Integer, List<IHierarchicElement>> map = new HashMap<>(); - - @Override - public void printResult() { - System.out.println("Stuff"); - } - - @Override - public void apply(IHierarchicElement element) { - if(!((INamedCommentedElement)element).getName().equals("DtB")) { - // return; - } - - int hash = 1; - for(IConnector connector : element.getConnectors()) { - PortSpecification port = (PortSpecification)connector.getSpecifications().get(0); - hash = 31 * hash + (connector instanceof InputPort ? 1 : 2) * - port.getType().getClass().hashCode(); - } - map.putIfAbsent(hash, new ArrayList<>()); - - List<IHierarchicElement> elements = map.get(hash); - - for(IHierarchicElement element_b : elements) { - - List<String> element_a_input = new ArrayList<String>(); - List<String> element_b_input = new ArrayList<String>(); - List<String> element_a_output = new ArrayList<String>(); - List<String> element_b_output = new ArrayList<String>(); - - for(IConnector connector : element.getConnectors()) { - PortSpecification port = - (PortSpecification)connector.getSpecifications().get(0); - String type = port.getType().getClass().getSimpleName(); - if(connector instanceof InputPort) { - element_a_input.add(type); - } else { - element_a_output.add(type); - } - } - - for(IConnector connector : element_b.getConnectors()) { - PortSpecification port = - (PortSpecification)connector.getSpecifications().get(0); - String type = port.getType().getClass().getSimpleName(); - if(connector instanceof InputPort) { - element_b_input.add(type); - } else { - element_b_output.add(type); - } - } - - boolean equals = true; - - for(String type_a_input : element_a_input) { - if(!element_b_input.remove(type_a_input)) { - equals = false; - break; - } - - } - - for(String type_a_output : element_a_output) { - if(!element_b_output.remove(type_a_output)) { - equals = false; - break; - } - - } - - if(equals) { - System.out.println( - "Found duplicate: " + ((INamedCommentedElement)element).getName() + - ", " + ((INamedCommentedElement)element_b).getName()); - break; - } else { - System.out.println("Same but not duplicate"); - } - } - elements.add(element); - } - - } + // public class CloneDetection implements IElementConsumer { + // + // private Map<Integer, List<IHierarchicElement>> map = new HashMap<>(); + // + // @Override + // public void printResult() { + // System.out.println("Stuff"); + // } + // + // @Override + // public void apply(IHierarchicElement element) { + // int hash = 1; + // for(IConnector connector : element.getConnectors()) { + // EList<IModelElementSpecification> specifications = connector.getSpecifications(); + // //if(!specifications.isEmpty() && + // // connector.getSpecifications().get(0) instanceof PortSpecification) { + // + // // PortSpecification port = + // // (PortSpecification)connector.getSpecifications().get(0); + // // hash = 31 * hash + (connector instanceof InputPort ? 1 : 2) * + // // port.getType().getClass().hashCode(); + // } else { + // // Clone Detection for State diagrams not supported + // return; + // } + // }map.putIfAbsent(hash,new ArrayList<>()); + // + // List<IHierarchicElement> elements = map.get(hash); + // + // for( + // IHierarchicElement element_b:elements) + // { + // + // List<String> element_a_input = new ArrayList<String>(); + // List<String> element_b_input = new ArrayList<String>(); + // List<String> element_a_output = new ArrayList<String>(); + // List<String> element_b_output = new ArrayList<String>(); + // + // for(IConnector connector : element.getConnectors()) { + // PortSpecification port = (PortSpecification)connector.getSpecifications().get(0); + // String type = port.getType().getClass().getSimpleName(); + // if(connector instanceof InputPort) { + // element_a_input.add(type); + // } else { + // element_a_output.add(type); + // } + // } + // + // for(IConnector connector : element_b.getConnectors()) { + // PortSpecification port = (PortSpecification)connector.getSpecifications().get(0); + // String type = port.getType().getClass().getSimpleName(); + // if(connector instanceof InputPort) { + // element_b_input.add(type); + // } else { + // element_b_output.add(type); + // } + // } + // + // boolean equals = true; + // + // for(String type_a_input : element_a_input) { + // if(!element_b_input.remove(type_a_input)) { + // equals = false; + // break; + // } + // + // } + // + // for(String type_a_output : element_a_output) { + // if(!element_b_output.remove(type_a_output)) { + // equals = false; + // break; + // } + // + // } + // if(equals) { + // System.out + // .println("Found duplicate: " + ((INamedCommentedElement)element).getName() + + // ", " + ((INamedCommentedElement)element_b).getName()); + // break; + // } else { + // System.out.println("Same but not duplicate"); + // } + // }elements.add(element); + // } public class CommentCompleteness extends MultiMethodDemo { @@ -313,6 +357,7 @@ public class MetricCommentProvider implements IMetricProvider<IHierarchicElement public void apply(IHierarchicElement element) { count++; } + } public Map<String, Integer> sizeMetrics(IHierarchicElement ele) { diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java index 7dc053669496a32f577c14cad4f534d50a18d658..abaf5ed5e701d66146d741397b8ec1b74fb63e8b 100644 --- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java +++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/MetricService.java @@ -152,4 +152,11 @@ public class MetricService extends EObjectAwareServiceBase<IMetricProvider<?>> public IIntrospectionDetailsItem getDetailsItem() { return null; } + + /** {@inheritDoc} */ + @Override + public void metricExtractionToCSV() { + // TODO Auto-generated method stub + + } } diff --git a/org.fortiss.tooling.ext.quality/test-src/test/org/fortiss/tooling/ext/quality/metric/MetricTest.java b/org.fortiss.tooling.ext.quality/test-src/test/org/fortiss/tooling/ext/quality/metric/MetricTest.java index d4e07c22410d8a672020213f332fc8d6eaf80309..d49fd8750f7366198e94d29a28ab3059cdddb890 100644 --- a/org.fortiss.tooling.ext.quality/test-src/test/org/fortiss/tooling/ext/quality/metric/MetricTest.java +++ b/org.fortiss.tooling.ext.quality/test-src/test/org/fortiss/tooling/ext/quality/metric/MetricTest.java @@ -15,13 +15,15 @@ +--------------------------------------------------------------------------*/ package test.org.fortiss.tooling.ext.quality.metric; -import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findFirstComponentArchitecture; -import static org.fortiss.af3.project.utils.TestCaseProjectUtils.loadTestProject; +//import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findFirstComponentArchitecture; +//import static org.fortiss.af3.project.utils.TestCaseProjectUtils.loadTestProject; -import org.fortiss.af3.project.model.FileProject; +import java.io.IOException; + +//import org.fortiss.af3.project.model.FileProject; import org.fortiss.tooling.base.model.element.IHierarchicElement; -import org.fortiss.tooling.ext.quality.AF3QualityActivator; import org.fortiss.tooling.ext.quality.service.MetricCommentProvider; +import org.fortiss.tooling.ext.quality.service.MetricCommentProvider.MetricCSVWriter; import org.junit.Before; import org.junit.Test; @@ -36,23 +38,36 @@ public class MetricTest { /** Top component. */ private IHierarchicElement topComponent; - /** Setup the test. */ @Before public void setup() { - FileProject project = loadTestProject(AF3QualityActivator.PLUGIN_ID, - // "test-data/ACC.af3_23"); - "test-data/carla_ff1_rover.af3_23"); + // FileProject project = + // loadTestProject(AF3QualityActivator.PLUGIN_ID, "test-data/ACC.af3_23"); + // "test-data/carla_ff1_rover.af3_23"); // topComponent = (IHierarchicElement) project.getRootElements().get(2); - topComponent = findFirstComponentArchitecture(project).getTopComponent(); + // topComponent = findFirstComponentArchitecture(project).getTopComponent(); } /** Test constraint checker for actions. */ @Test public void actionsConstraintCheck() { MetricCommentProvider mcp = new MetricCommentProvider(); + MetricCSVWriter writer = new MetricCSVWriter(); mcp.startRecursion(topComponent); + try { + writer.openFile(); + writer.writeData(2, 3); + writer.writeData(3, 4); + } catch(IOException e) { + e.printStackTrace(); + } finally { + try { + writer.closeFile(); + } catch(IOException e) { + e.printStackTrace(); + } + } } } diff --git a/src/org/fortiss/tooling/ext/quality/ui/AF3QualityUIActivator.java b/src/org/fortiss/tooling/ext/quality/ui/AF3QualityUIActivator.java new file mode 100644 index 0000000000000000000000000000000000000000..4f51b3dce8b7c9f051324ad57044b2620cf88f46 --- /dev/null +++ b/src/org/fortiss/tooling/ext/quality/ui/AF3QualityUIActivator.java @@ -0,0 +1,65 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2022 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.tooling.ext.quality.ui; + +import static org.eclipse.jface.resource.ResourceLocator.imageDescriptorFromBundle; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + * + * @author Blaschke + */ +public class AF3QualityUIActivator extends AbstractUIPlugin { + + /** The plug-in ID. */ + public static final String PLUGIN_ID = AF3QualityUIActivator.class.getPackage().getName(); // $NON-NLS-1$ + + /** The shared instance. */ + private static AF3QualityUIActivator plugin; + + /** Constructor. */ + public AF3QualityUIActivator() { + // do nothing + } + + /** {@inheritDoc} */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /** {@inheritDoc} */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** Returns the shared instance. */ + public static AF3QualityUIActivator getDefault() { + return plugin; + } + + /** Returns the image descriptor for the given icon file. */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromBundle(PLUGIN_ID, path).orElse(null); + } +} diff --git a/src/org/fortiss/tooling/ext/quality/ui/MetricExportMenu.java b/src/org/fortiss/tooling/ext/quality/ui/MetricExportMenu.java new file mode 100644 index 0000000000000000000000000000000000000000..56264ea19292b6365984a710af5629043245f55a --- /dev/null +++ b/src/org/fortiss/tooling/ext/quality/ui/MetricExportMenu.java @@ -0,0 +1,75 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2022 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.tooling.ext.quality.ui; + +import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.action.IContributionItem; +import org.fortiss.tooling.ext.quality.AF3QualityActivator; +import org.fortiss.tooling.kernel.ui.extension.IContextMenuMultiSelectionContributor; +import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider; + +import com.sun.javafx.iio.common.ImageDescriptor; + +/** + * Context menu entry to automatic layout {@link IHierarchicElement}-based models. + * + * @author blaschke + */ +public class MetricExportMenu implements IContextMenuMultiSelectionContributor { + + /** Returns the icon that is visible in the context menu for this entry. */ + protected ImageDescriptor getActionIcon() { + return AF3QualityUIActivator.getImageDescriptor("icons/MetricIcon.png"); + } + + /** {@inheritDoc} */ + @Override + public void run() { + try(PrintStream ps_final = new PrintStream("test")) { + AF3QualityActivator extractor = new AF3QualityActivator(); + String enterpriseArchitectureFile = extractor.transformFileProjectToSysML("enterpriseArchitect"); + ps_final.println(enterpriseArchitectureFile); + } catch(Exception ex) { + ex.printStackTrace(); + showError("Unable to save the SysML xmi architecture file", ex.getMessage()); + } + } + + /** {@inheritDoc} */ + @Override + public String getMenuSectionID() { + return null; + } + + @Override + public List<IContributionItem> getContributedItems(EObject selection, ContextMenuContextProvider contextProvider) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<IContributionItem> getContributedItems(List<EObject> selection, + ContextMenuContextProvider contextProvider) { + // TODO Auto-generated method stub + return null; + } +}