Commit 0a9d4ab9 authored by Johannes Eder's avatar Johannes Eder
Browse files

removed unnecessary editors

Issue-Ref: 3886
Issue-Url: https://af3-developer.fortiss.org/issues/3886

Signed-off-by: Johannes Eder's avatarJohannes Eder <eder@fortiss.org>
parent e5bca5c5
/*-------------------------------------------------------------------------+
| Copyright 2011 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;
import static org.fortiss.af3.mira.ui.utils.ListenerUtils.openClassEditorListener;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.multiLineInputBoundedLayout;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.multiLineInputUnboundedLayout;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.TextStyledTextActionHandler;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.ui.service.IActionService;
/**
* Editor to show an overview over the contained elements of {@link Analysis}.
*
* @author teufl
*/
public class AnalysisEditor extends OverviewEditorBase<Analysis> {
/** The text in the filter bar. */
protected Text filterTextTraces;
/** Minimum size of multi line input grid. */
protected int multiLineMinYSize = 50;
/** Maximum size of multi line input grid. */
protected int multiLineMaxYSize = 120;
/** Multi line input control in general section. */
protected List<Control> multiLineControlList;
/**
* List of all sourceViewers on the form (needed to inform the on updates of
* glossary and requirement source).
*/
protected List<SourceViewer> registeredSourceViewers;
/** {@inheritDoc} */
@Override
protected void setupScrolledForm(ScrolledForm form) {
super.setupScrolledForm(form);
form.getToolBarManager().update(true);
}
/** {@inheritDoc} */
@Override
protected void createOverviewTreeColumns(TreeViewer listTreeViewer) {
multiLineControlList = new ArrayList<Control>();
// Creates the requirement traces filter and section.
createOverviewTreeColumn(listTreeViewer, 130, "Type", 0);
createOverviewTreeColumn(listTreeViewer, 90, "Status", 1);
createOverviewTreeColumn(listTreeViewer, 200, "Name", 2);
createOverviewTreeColumn(listTreeViewer, 600, "Description/Definition", 3);
// Filtering.
listTreeViewer.addFilter(searchFilter);
// Opens EObject on double click.
listTreeViewer.addDoubleClickListener(openClassEditorListener(EObject.class, null));
}
/** {@inheritDoc} */
@Override
protected void addTextStyledText(TextStyledTextActionHandler textStyledTextActionHandler) {
super.addTextStyledText(textStyledTextActionHandler);
textStyledTextActionHandler.addText(filterTextTraces);
}
/** {@inheritDoc} */
@Override
protected void addOverviewList(List<String> overviewList, INamedCommentedElement element) {
overviewLabelProvider.addOverviewContentFor(overviewList, element);
}
/** {@inheritDoc} */
@Override
public void registerGlobalActions(IActionBars bars) {
IActionService.getInstance().registerGlobalUndoRedoActions(bars);
super.registerGlobalActions(bars);
// Refresh general information multi line input control and add listener.
for(Control c : multiLineControlList) {
resizeMultiLineControl(c, multiLineMinYSize);
c.addFocusListener(multiLineControlResizeListener);
}
}
/**
* Resize the given {@link Control} according to the given min and max {@link GridDataFactory}.
*
* @param control
* the handle to the OS resource (Warning: This field is platform dependent)
* @param multiLineMinYSize
* minimum size of hintY
*/
protected void resizeMultiLineControl(Control control, int multiLineMinYSize) {
// Get right height of each field (but with SWT kind-of-a-bug that places too big gaps
// between fields).
multiLineInputUnboundedLayout.applyTo(control);
control.getParent().layout();
int ySizeInRange =
Math.min(Math.max(control.getSize().y, multiLineMinYSize), multiLineMaxYSize);
multiLineInputBoundedLayout(ySizeInRange).applyTo(control);
control.getParent().layout();
form.reflow(true);
}
/** Focus listener to resize multi line input control after editing. */
protected FocusListener multiLineControlResizeListener = new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
resizeMultiLineControl((StyledText)e.getSource(), multiLineMinYSize);
}
@Override
public void focusGained(FocusEvent e) {
// do nothing
}
};
}
/*-------------------------------------------------------------------------+
| Copyright 2013 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;
import static org.fortiss.af3.mira.ui.utils.ListenerUtils.openClassEditorListener;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.TreeViewer;
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.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* Editor to show all contained element list of {@link RequirementsContainer}.
*
* @author wenwenchen
*/
public class RequirementsContainerEditor<T extends RequirementsContainer>
extends OverviewEditorBase<T> {
/** {@inheritDoc} */
@Override
protected void createOverviewTreeColumns(TreeViewer listTreeViewer) {
createOverviewTreeColumn(listTreeViewer, 130, "Type", 0);
createOverviewTreeColumn(listTreeViewer, 90, "Status", 1);
createOverviewTreeColumn(listTreeViewer, 200, "Name", 2);
createOverviewTreeColumn(listTreeViewer, 300, "Description", 3);
createOverviewTreeColumn(listTreeViewer, 200, "Comment", 4);
// filtering
listTreeViewer.addFilter(searchFilter);
// open element on double click
listTreeViewer.addDoubleClickListener(openClassEditorListener(EObject.class, null));
}
/** {@inheritDoc} */
@Override
protected boolean accept(EObject element) {
return element instanceof RequirementsPackage || element instanceof Requirement;
}
/** {@inheritDoc} */
@Override
protected void addOverviewList(List<String> overviewList, INamedCommentedElement element) {
overviewLabelProvider.addOverviewContentFor(overviewList, element);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2013 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;
import static org.fortiss.af3.mira.ui.utils.ListenerUtils.openClassEditorListener;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.TreeViewer;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementsPackage;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* Editor to show all contained element list of {@link RequirementsPackage}.
*
* @author wenwenchen
*/
public class RequirementsPackageEditor<T extends RequirementsPackage>
extends OverviewEditorBase<T> {
/** {@inheritDoc} */
@Override
protected void createOverviewTreeColumns(TreeViewer listTreeViewer) {
createOverviewTreeColumn(listTreeViewer, 130, "Type", 0);
createOverviewTreeColumn(listTreeViewer, 90, "Status", 1);
createOverviewTreeColumn(listTreeViewer, 200, "Name", 2);
createOverviewTreeColumn(listTreeViewer, 300, "Description", 3);
createOverviewTreeColumn(listTreeViewer, 200, "Comment", 4);
// filtering
listTreeViewer.addFilter(searchFilter);
// open requirement on double click
listTreeViewer.addDoubleClickListener(openClassEditorListener(EObject.class, null));
}
/** {@inheritDoc} */
@Override
protected boolean accept(EObject element) {
return element instanceof RequirementsPackage || element instanceof Requirement;
}
/** {@inheritDoc} */
@Override
protected void addOverviewList(List<String> overviewList, INamedCommentedElement element) {
overviewLabelProvider.addOverviewContentFor(overviewList, element);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2012 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.glossary;
import static org.fortiss.af3.mira.ui.utils.ListenerUtils.openClassEditorListener;
import java.util.List;
import org.eclipse.jface.viewers.TreeViewer;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.glossary.GlossaryEntry;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
* Editor to edit a {@link Glossary}.
*
* @author wenwenchen
*/
public class GlossaryEditor extends OverviewEditorBase<Glossary> {
/** {@inheritDoc} */
@Override
protected void createOverviewTreeColumns(TreeViewer listTreeViewer) {
createOverviewTreeColumn(listTreeViewer, 130, "Type", 0);
createOverviewTreeColumn(listTreeViewer, 90, "Status", 1);
createOverviewTreeColumn(listTreeViewer, 200, "Name", 2);
createOverviewTreeColumn(listTreeViewer, 300, "Definition", 3);
createOverviewTreeColumn(listTreeViewer, 300, "Comment", 4);
// filtering
listTreeViewer.addFilter(searchFilter);
// open glossary entry on double click
listTreeViewer.addDoubleClickListener(openClassEditorListener(GlossaryEntry.class, null));
}
/** {@inheritDoc} */
@Override
protected Object[] getTreeElements() {
return editedObject.getGlossaryEntryList().toArray();
}
/** {@inheritDoc} */
@Override
protected void addOverviewList(List<String> overviewList, INamedCommentedElement element) {
overviewLabelProvider.addOverviewContentFor(overviewList, element);
}
}
......@@ -21,6 +21,7 @@ import static org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase.Statist
import static org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase.StatisticEntries.NO_GLOSSARY_ENTRIES;
import static org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase.StatisticEntries.NO_REQS;
import static org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase.StatisticEntries.NO_REQS_TOTAL;
import static org.fortiss.af3.mira.ui.utils.ListenerUtils.openClassEditorListener;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.fillControlFactory;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.singleLineInputFactory;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.singleLineLabelFactory;
......@@ -49,7 +50,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
......@@ -71,7 +71,7 @@ import org.fortiss.tooling.kernel.model.INamedCommentedElement;
*
* @author wenwenchen
*/
public abstract class OverviewEditorBase<T extends IHierarchicElement> extends FormsEditorBase<T> {
public class OverviewEditorBase<T extends IHierarchicElement> extends FormsEditorBase<T> {
/** Enum for Statistics list entries. */
protected enum StatisticEntries {
......@@ -144,7 +144,6 @@ public abstract class OverviewEditorBase<T extends IHierarchicElement> extends F
/** {@inheritDoc} */
@Override
protected void createSections() {
createStatisticsSection();
createFilterSection();
createOverviewSection(new OverviewLabelProvider(), new OverviewComparator());
}
......@@ -155,80 +154,6 @@ public abstract class OverviewEditorBase<T extends IHierarchicElement> extends F
textStyledTextActionHandler.addText(overviewFilterText);
}
/** Creates the statistics section. */
protected void createStatisticsSection() {
final Composite statisticsComposite =
createNewSection("Statistics", "Number of contained elements");
statisticsComposite.setLayout(new GridLayout(2, false));
List<Integer> statistics = calculateStatistics();
// Statistics for Analysis overview.
if(editedObject instanceof Analysis) {
createSingleLineStatisticsField(statisticsComposite, NO_GLOSSARY_ENTRIES.getLabel(),
Integer.toString(statistics.get(NO_GLOSSARY_ENTRIES.ordinal())));
createSingleLineStatisticsField(statisticsComposite, NO_REQS.getLabel(),
Integer.toString(statistics.get(NO_REQS.ordinal())));
createSingleLineStatisticsField(statisticsComposite, NO_REQS_TOTAL.getLabel(),
Integer.toString(statistics.get(NO_REQS_TOTAL.ordinal())));
createSingleLineStatisticsField(statisticsComposite, NO_ALL.getLabel(),
Integer.toString(statistics.get(NO_ALL.ordinal())));
}
// For glossary overview.
else if(editedObject instanceof Glossary) {
createSingleLineStatisticsField(statisticsComposite, NO_GLOSSARY_ENTRIES.getLabel(),
Integer.toString(statistics.get(NO_GLOSSARY_ENTRIES.ordinal())));
createSingleLineStatisticsField(statisticsComposite, NO_ALL.getLabel(),
Integer.toString(statistics.get(NO_ALL.ordinal())));
}
// For requirement container overview.
else if(editedObject instanceof RequirementsContainer ||
editedObject instanceof RequirementsPackage) {
createSingleLineStatisticsField(statisticsComposite, NO_REQS.getLabel(),
Integer.toString(statistics.get(NO_REQS.ordinal())));
createSingleLineStatisticsField(statisticsComposite, NO_REQS_TOTAL.getLabel(),
Integer.toString(statistics.get(NO_REQS_TOTAL.ordinal())));
}
refreshAdapter = new EContentAdapter() {
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification);
if(!statisticsComposite.isDisposed() &&
(notification.getEventType() == Notification.ADD ||
notification.getEventType() == Notification.ADD_MANY ||
notification.getEventType() == Notification.REMOVE ||
notification.getEventType() == Notification.REMOVE_MANY)) {
// Ensure that refresh is run in the UI thread.
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
List<Integer> newStats = calculateStatistics();
Control[] labels = statisticsComposite.getChildren();
Map<String, Integer> map = statisticEntriesMap();
for(int i = 0; i < labels.length; i++) {
if(labels[i] instanceof Label) {
Integer enumRank = map.get(((Label)labels[i]).getText().trim());
if(enumRank != null) {
((Label)labels[i + 1]).setText(newStats.get(enumRank) + "");
}
}
}
}
});
}
}
};
editedObject.eAdapters().add(refreshAdapter);
}
/**
* Create a single line field for statistics.
*
......@@ -390,10 +315,25 @@ public abstract class OverviewEditorBase<T extends IHierarchicElement> extends F
}
/** Adds content to overview list. */
protected abstract void addOverviewList(List<String> checkList, INamedCommentedElement element);
protected void addOverviewList(List<String> overviewList, INamedCommentedElement element) {
overviewLabelProvider.addOverviewContentFor(overviewList, element);
}
/** Creates the columns for the overview tree view. */
protected abstract void createOverviewTreeColumns(TreeViewer listTreeViewer);
protected void createOverviewTreeColumns(TreeViewer listTreeViewer) {
createOverviewTreeColumn(listTreeViewer, 130, "Type", 0);
createOverviewTreeColumn(listTreeViewer, 90, "Status", 1);
createOverviewTreeColumn(listTreeViewer, 200, "Name", 2);
createOverviewTreeColumn(listTreeViewer, 300, "Description", 3);
createOverviewTreeColumn(listTreeViewer, 200, "Comment", 4);
// filtering
listTreeViewer.addFilter(searchFilter);
// open element on double click
listTreeViewer.addDoubleClickListener(openClassEditorListener(EObject.class, null));
}
/**
* Creates a single {@link TreeColumn} for the overview tree view.
......
......@@ -32,7 +32,6 @@ 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.ui.editor.AnalysisEditor;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
/**
......
RelationSection.java c8ffbc035b1619d8c1bd8263835ea589683c46cf YELLOW
RequirementRelationStatusNameValidator.java dbae43c9e77f9785ea1d162bf8e81b855108d1c6 YELLOW
RequirementRelationStatusSelectDialogEditSupport.java 3fc77479a7ef7fd272e9a450c52dfc5a762e0ef9 GREEN
......@@ -19,7 +19,7 @@ import static org.fortiss.af3.mira.utils.MiraUtils.FIRSTEDITORPRIORITY;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.ui.editor.AnalysisEditor;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
......@@ -32,7 +32,7 @@ public class AnalysisEditorBinding extends ModelEditorBindingBase<Analysis> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return AnalysisEditor.class;
return OverviewEditorBase.class;
}
/** {@inheritDoc} */
......
......@@ -20,7 +20,7 @@ import static org.fortiss.af3.mira.utils.MiraUtils.FIRSTEDITORPRIORITY;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.ui.editor.glossary.GlossaryEditor;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
......@@ -34,7 +34,7 @@ public class GlossaryEditorBinding extends ModelEditorBindingBase<Analysis> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return GlossaryEditor.class;
return OverviewEditorBase.class;
}
/** {@inheritDoc} */
......
......@@ -19,7 +19,7 @@ import static org.fortiss.af3.mira.utils.MiraUtils.FIRSTEDITORPRIORITY;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.mira.model.RequirementsContainer;
import org.fortiss.af3.mira.ui.editor.RequirementsContainerEditor;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
......@@ -33,7 +33,7 @@ public class RequirementsContainerEditorBinding
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return RequirementsContainerEditor.class;
return OverviewEditorBase.class;
}
/** {@inheritDoc} */
......
......@@ -19,7 +19,7 @@ import static org.fortiss.af3.mira.utils.MiraUtils.FIRSTEDITORPRIORITY;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.mira.model.RequirementsPackage;
import org.fortiss.af3.mira.ui.editor.RequirementsPackageEditor;
import org.fortiss.af3.mira.ui.editor.overview.OverviewEditorBase;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;