Commit 640686cb authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '3914' into 'master'

3914 af3-Branch

See merge request af3/af3!287
parents c8aa75b0 fd736c42
......@@ -80,6 +80,30 @@
modelElementClass="org.fortiss.af3.mira.model.RequirementsPackage">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editor.overview.fx.RequirementsOverviewFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.Analysis">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editor.overview.fx.RequirementsOverviewFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.RequirementsPackage">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editor.overview.fx.RequirementsOverviewFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.RequirementsContainer">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editor.overview.fx.RequirementsOverviewFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.glossary.Glossary">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editor.fx.RequirementFXEditorBinding">
<modelElementClass
......
AF3MiraUIActivator.java 751323d4a666c98a9aae2a29aaef81c808bd113b GREEN
AF3MiraUIActivator.java d23c22cc1450cd21377b8b2ad65c9c70f776c89f GREEN
......@@ -17,6 +17,8 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getURIString;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
......@@ -56,4 +58,9 @@ public class AF3MiraUIActivator extends AbstractUIPlugin {
public static AF3MiraUIActivator getDefault() {
return plugin;
}
/** Returns the FX image URI for the given icon file. */
public static String getFXImageURI(String path) {
return getURIString(PLUGIN_ID, path);
}
}
RequirementsOverviewFXEditor.java 1dd6ec50837cd05bb8799466f8738b282b964e95 GREEN
RequirementsOverviewFXEditorBinding.java c8c5fedf3019b5668b18714f8a4884a94261085a GREEN
RequirementsOverviewFXEditorContentProvider.java a3815c1d4211d9e7f2bea6be700904a6e02150ed GREEN
RequirementsOverviewFXEditorUIProvider.java adece2e83a54cb9094618cd7830358cb6e601d97 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2020 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.mira.ui.editor.overview.fx;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.IDoubleClickHandler;
import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.utils.KernelServiceBasedModelListenerBase;
import javafx.scene.Parent;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.BorderPane;
/**
* FX implementation of the requirements overview editor.
*
* @author bayha
*/
public class RequirementsOverviewFXEditor<T extends IHierarchicElement> extends FXEditorBase<T> {
/** The tree-table viewer. */
private DynamicTreeTableViewer<IHierarchicElement> treeTableViewer;
/** The filter text field if filtering is enabled in content provider. */
private TextField filterWidget;
/** The model listener. */
private KernelServiceBasedModelListenerBase<T> modelListener;
/** {@inheritDoc} */
@Override
protected Parent createSceneRoot() {
T edited = getEditedObject();
modelListener = new KernelServiceBasedModelListenerBase<T>(edited) {
/** {@inheritDoc} */
@Override
public void updateComplete(List<Notification> notifications) {
treeTableViewer.update();
}
};
modelListener.register();
RequirementsOverviewFXEditorContentProvider contentProvider =
new RequirementsOverviewFXEditorContentProvider();
RequirementsOverviewFXEditorUIProvider uiProvider =
new RequirementsOverviewFXEditorUIProvider(this);
filterWidget = new TextField();
filterWidget.textProperty().addListener((obs, oVal, nVal) -> {
contentProvider.setFilterExpression(nVal);
treeTableViewer.update();
treeTableViewer.expandAllItems();
});
filterWidget.setTooltip(new Tooltip("type filter text"));
filterWidget.setPromptText("type filter text");
treeTableViewer = new DynamicTreeTableViewer<IHierarchicElement>(edited, true, 3,
contentProvider, uiProvider);
treeTableViewer.addColumn("Type", 160);
treeTableViewer.addColumn("Status", 160);
treeTableViewer.addColumn("Name", 160);
treeTableViewer.addColumn("Description", 280);
treeTableViewer.addColumn("Comment", 250);
treeTableViewer.setDoubleClickHandler(new IDoubleClickHandler() {
@Override
public void doubleClicked(Object value) {
if(value instanceof EObject) {
IModelEditorBindingService.getInstance().openInEditor((EObject)value);
}
}
});
BorderPane pane = new BorderPane();
pane.setTop(filterWidget);
pane.setCenter(treeTableViewer.getControl());
return pane;
}
/** {@inheritDoc} */
@Override
public void dispose() {
modelListener.unregister();
super.dispose();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2020 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.mira.ui.editor.overview.fx;
import org.eclipse.ui.IEditorPart;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
* Binding for RequirementsOverviewFXEditor.
*
* @author bayha
*/
public class RequirementsOverviewFXEditorBinding
extends ModelEditorBindingBase<IHierarchicElement> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return RequirementsOverviewFXEditor.class;
}
/** {@inheritDoc} */
@Override
public String getLabel() {
return "Requirements Overview (FX)";
}
/** {@inheritDoc} */
@Override
public int getPriority() {
return -100;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2020 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.mira.ui.editor.overview.fx;
import static java.util.stream.Collectors.toList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementsContainer;
import org.fortiss.af3.mira.model.RequirementsPackage;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.glossary.GlossaryEntry;
import org.fortiss.af3.mira.model.glossary.impl.GlossaryImpl;
import org.fortiss.af3.mira.model.impl.RequirementsPackageImpl;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
/**
* Content provider for {@link RequirementsOverviewFXEditor}.
*
* @author bayha
*/
public class RequirementsOverviewFXEditorContentProvider
extends DynamicTreeContentProviderBase<IHierarchicElement> {
/** {@inheritDoc} */
@Override
protected Collection<? extends IHierarchicElement> getChildren(IHierarchicElement parent) {
List<IHierarchicElement> result = new ArrayList<IHierarchicElement>();
if(parent instanceof FXEditorRequirementsContainer) {
return ((FXEditorRequirementsContainer)parent).entries;
}
if(parent instanceof FXEditorGlossaryEntryContainer) {
return ((FXEditorGlossaryEntryContainer)parent).entries;
}
if(parent instanceof Analysis) {
FXEditorGlossaryEntryContainer glosContainer = new FXEditorGlossaryEntryContainer();
FXEditorRequirementsContainer reqContainer = new FXEditorRequirementsContainer();
reqContainer.entries.addAll(getChildrenWithType((EObject)parent, Requirement.class));
glosContainer.entries.addAll(getChildrenWithType((EObject)parent, GlossaryEntry.class));
if(reqContainer.entries.size() > 0) {
result.add(reqContainer);
}
if(glosContainer.entries.size() > 0) {
result.add(glosContainer);
}
}
if(parent instanceof RequirementsPackage || parent instanceof RequirementsContainer) {
result.addAll(getChildrenWithType((EObject)parent, Requirement.class));
}
if(parent instanceof Glossary) {
result.addAll(getChildrenWithType((EObject)parent, GlossaryEntry.class));
}
return result;
}
/** {@inheritDoc} */
@Override
protected boolean filter(IHierarchicElement element, String filterValue) {
if(element == null) {
return false;
}
if(element instanceof Analysis) {
return true;
}
if(element instanceof FXEditorGlossaryEntryContainer) {
List<GlossaryEntry> filteredGlos = ((FXEditorGlossaryEntryContainer)element).entries
.stream().filter(g -> filter(g, filterValue)).collect(toList());
return filteredGlos.size() > 0;
}
if(element instanceof FXEditorRequirementsContainer) {
List<Requirement> filteredReqs = ((FXEditorRequirementsContainer)element).entries
.stream().filter(r -> filter(r, filterValue)).collect(toList());
return filteredReqs.size() > 0;
}
if(element instanceof Requirement) {
Requirement req = (Requirement)element;
String checkStr = req.getName() + req.getDescription() + req.getComment() +
req.getStatus().getName();
return checkStr.toLowerCase().contains(filterValue.toLowerCase());
}
if(element instanceof GlossaryEntry) {
GlossaryEntry ge = (GlossaryEntry)element;
String checkString = ge.getName() + ge.getDefinition() + ge.getStatus().getName();
return checkString.toLowerCase().contains(filterValue.toLowerCase());
}
return false;
}
}
/**
* Artificial {@link Glossary} node to cluster {@link GlossaryEntry}s in the table.
*
* This class extends {@link GlossaryImpl} as every element in an {@link FXEditorBase}
* needs to be an {@link EObject} in any case.
* Otherwise an extra MetaModel-Element would need to be created...
*/
class FXEditorGlossaryEntryContainer extends GlossaryImpl {
/** Entries to be displayed beneath this container. */
protected List<GlossaryEntry> entries = new ArrayList<GlossaryEntry>();
}
/**
* Artificial {@link RequirementsPackage} node to cluster {@link Requirement}s in the table.
*
* This class extends {@link RequirementsPackageImpl} as every element in an {@link FXEditorBase}
* needs to be an {@link EObject} in any case.
* Otherwise an extra MetaModel-Element would need to be created...
*/
class FXEditorRequirementsContainer extends RequirementsPackageImpl {
/** Entries to be displayed beneath this container. */
protected List<Requirement> entries = new ArrayList<Requirement>();
}
/*-------------------------------------------------------------------------+
| Copyright 2020 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.mira.ui.editor.overview.fx;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementsContainer;
import org.fortiss.af3.mira.model.RequirementsPackage;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.glossary.GlossaryEntry;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.ui.editor.fx.controller.ModelElementFXEditorUIProviderBase;
import org.fortiss.tooling.kernel.ui.extension.base.FXEditorBase;
import javafx.scene.Node;
/**
* UIProvider for RequirementsOverviewEditor.
*
* @author bayha
*/
public class RequirementsOverviewFXEditorUIProvider
extends ModelElementFXEditorUIProviderBase<IHierarchicElement> {
/**
* Constructor.
*
* @param editor
* The editor, in which this UIProvider is used.
*/
public RequirementsOverviewFXEditorUIProvider(FXEditorBase<?> editor) {
super(editor);
}
/** {@inheritDoc} */
@Override
public String getLabel(IHierarchicElement element, int column) {
if(element instanceof Analysis) {
if(column == 0) {
return "All elements";
}
return "";
}
if(element instanceof RequirementsContainer) {
switch(column) {
case 0:
return "All Requirements";
default:
return "";
}
}
if(element instanceof Glossary) {
switch(column) {
case 0:
return "All Glossary Entries";
default:
return "";
}
}
if(element instanceof Analysis) {
switch(column) {
case 0:
return ((Analysis)element).getName();
default:
return "";
}
}
if(element instanceof FXEditorRequirementsContainer) {
switch(column) {
case 0:
return "Requirements";
default:
return "";
}
}
if(element instanceof FXEditorGlossaryEntryContainer) {
switch(column) {
case 0:
return "Glossary Entries";
default:
return "";
}
}
if(element instanceof Requirement) {
Requirement req = (Requirement)element;
switch(column) {
case 0:
return "Requirement";
case 1:
return req.getStatus().toString();
case 2:
return req.getName();
case 3:
return req.getDescription();
case 4:
return req.getComment();
default:
return "-";
}
}
if(element instanceof RequirementsPackage) {
RequirementsPackage reqPack = (RequirementsPackage)element;
switch(column) {
case 0:
return "Requirements Package";
case 2:
return reqPack.getName();
case 3:
return reqPack.getComment();
default:
return "-";
}
}
if(element instanceof GlossaryEntry) {
GlossaryEntry glos = (GlossaryEntry)element;
switch(column) {
case 0:
return "Glossary Entry";
case 1:
return glos.getStatus().toString();
case 2:
return glos.getName();
case 3:
return glos.getDefinition();
case 4:
return glos.getComment();
default:
return "-";
}
}
return "";
}
/** {@inheritDoc} */
@Override
public Node getIconNode(IModelElement element, int column) {
if(column == 0) {
return super.getIconNode(element, column);
}
return null;
}
}
AnalysisHandler.java 13127bcfc32c55261fb699a03fa614d579fddcfa GREEN
GlossaryEntryHandler.java e8d9100791c218e8897cf64f1beaf6afb42adeb5 GREEN
GlossaryHandler.java 5399ca3ba430b1f25f40e2b8f99fea126e686d34 GREEN
RequirementHandler.java 9488c816b5b13c7fa13e11507dd8db1af720a494 GREEN
RequirementRelationStatusHandler.java 4fca19e5048f4379ff98228c0b3065bfeb90122e GREEN
RequirementSpecificationHandler.java 8b40f9f3be20cdd70d7c7f9822c4e14c462284b7 GREEN
RequirementsContainerHandler.java e23b42b1d0473c3429f801c238f786f81eef8b58 GREEN
RequirementsPackageHandler.java 0ec42edae04241e0f3c1cf636f6267a3af440386 GREEN
AnalysisHandler.java 4eec2c87131e80da9b6a76b7dce18ec3704e5612 GREEN
GlossaryEntryHandler.java a46722658b9281ed6dd2c63a8420957be5a0a22d GREEN
GlossaryHandler.java e1fd70e472f3f19714d94ecc2cb5c7d51c364538 GREEN
RequirementHandler.java 0f8a955721b5b3a9a06e27de1ae84174df6331ad GREEN
RequirementsContainerHandler.java ed9813de5f9725f1ceb11be76cefa59eb141b10e GREEN
RequirementsPackageHandler.java 354d0c26957380c0381b04b2a8bba828c60c68aa GREEN
......@@ -19,6 +19,7 @@ import static java.util.Collections.sort;
import static org.conqat.lib.commons.string.StringUtils.isEmpty;
import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.getFXImageURI;
import static org.fortiss.af3.mira.utils.MiraUtils.ANALYSISNAVIGATORVIEWWEIGHT;
import static org.fortiss.af3.mira.utils.MiraUtils.getAnalysisComparator;