Commit 8094b214 authored by Dongyue Mou's avatar Dongyue Mou
Browse files

new ui plugin for mira

parent 7fa88c7e
package org.fortiss.af3.mira.ui.editor;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.jface.databinding.viewers.ObservableMapCellLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.fortiss.af3.mira.model.RequirementRelation;
import org.fortiss.af3.mira.relation.IRelationService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class RequirementUpdateRelationTypeCell extends
ObservableMapCellLabelProvider {
private RequirementEditor requirementEditor;
/**
* @param attributeMaps
*/
public RequirementUpdateRelationTypeCell(IObservableMap[] attributeMaps,
RequirementEditor editor) {
super(attributeMaps);
this.requirementEditor = editor;
}
/** {@inheritDoc} */
@Override
public void update(ViewerCell cell) {
RequirementRelation rel = (RequirementRelation) cell.getElement();
if (rel.getSource().eContainer()
.equals(requirementEditor.getEditedObject())) {
cell.setText(IRelationService.INSTANCE.getHandler(rel)
.getDisplayNameForSource());
} else if (rel.getTarget().eContainer()
.equals(requirementEditor.getEditedObject())) {
cell.setText(IRelationService.INSTANCE.getHandler(rel)
.getDisplayNameForTarget());
}
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import org.eclipse.jface.action.Action;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.validator.IsConsistentVisitor;
import org.fortiss.af3.mira.validator.IsEmptyVisitor;
import org.fortiss.af3.mira.validator.IsRedundantVisitor;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class RequirementValidateAction extends Action {
private RequirementEditor editor;
/**
* @param text
* @param style
*/
public RequirementValidateAction(String text, int style,
RequirementEditor editor) {
super(text, style);
this.editor = editor;
}
@Override
public void run() {
IConstraintCheckerService.INSTANCE
.performAllConstraintChecksRecursively(editor.getEditedObject());
if (true) {
Analysis root = (Analysis) editor.getEditedObject().eContainer();
IsEmptyVisitor iEV = new IsEmptyVisitor();
iEV.deleteMarker(root);
iEV.visit(editor.getEditedObject());
IsRedundantVisitor iRV = new IsRedundantVisitor();
iRV.visit(editor.getEditedObject());
IsConsistentVisitor iCV = new IsConsistentVisitor();
iCV.visit(editor.getEditedObject());
}
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.databinding.viewers.ObservableMapCellLabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.ViewerCell;
import org.fortiss.af3.mira.model.RequirementRelation;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
final class RequirmentFireLabelProviderChanged extends
ObservableMapCellLabelProvider {
/** */
private final RequirementEditor requirementEditor;
/**
* @param attributeMaps
* @param requirementEditor
* TODO
*/
RequirmentFireLabelProviderChanged(RequirementEditor requirementEditor,
IObservableMap[] attributeMaps) {
super(attributeMaps);
this.requirementEditor = requirementEditor;
}
/** {@inheritDoc} */
@Override
public void update(ViewerCell cell) {
try {
RequirementRelation rel = (RequirementRelation) cell.getElement();
EObject o;
if (rel.getSource().eContainer()
.equals(this.requirementEditor.getEditedObject())) {
o = rel.getTarget().eContainer();
cell.setText(IModelElementHandlerService.INSTANCE
.getModelElementHandler(o).getName(o));
} else if (rel.getTarget().eContainer()
.equals(this.requirementEditor.getEditedObject())) {
o = rel.getSource().eContainer();
cell.setText(IModelElementHandlerService.INSTANCE
.getModelElementHandler(o).getName(o));
}
} catch (NullPointerException e) {
cell.setText("");
}
}
/** {@inheritDoc} */
@Override
protected void fireLabelProviderChanged(LabelProviderChangedEvent event) {
Set<Object> newlist = new HashSet<Object>(Arrays.asList(event
.getElements()));
for (Object e : event.getElements()) {
for (IConnection c : ((IHierarchicElement) this.requirementEditor
.getEditedObject()).getConnections())
if (c.getTarget() != null
&& e.equals(c.getTarget().eContainer()))
newlist.add(c);
}
super.fireLabelProviderChanged(new LabelProviderChangedEvent(this,
newlist.toArray()));
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TextCellEditor;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.tooling.kernel.service.ICommandStackService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ScenarioActionEditingSupport extends EditingSupport {
private TableViewerColumn column;
private ScenarioEditor editor;
/**
* @param viewer
*/
public ScenarioActionEditingSupport(TableViewerColumn column,
ScenarioEditor editor) {
super(column.getViewer());
this.column = column;
this.editor = editor;
}
@Override
protected void setValue(Object element, Object value) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
Assert.isNotNull(value);
Assert.isTrue(value instanceof String);
final ScenarioStep step = (ScenarioStep) element;
final String act = value.toString();
ICommandStackService.INSTANCE.runAsCommand(
this.editor.getEditedObject(), new Runnable() {
@Override
public void run() {
step.setAction(act);
}
});
}
@Override
protected Object getValue(Object element) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
return ((ScenarioStep) element).getAction();
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(column.getColumn().getParent());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import java.util.ArrayList;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.af3.mira.model.usecase.ScenarioStepActionType;
import org.fortiss.tooling.kernel.service.ICommandStackService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ScenarioActionTypeColumnEditingSupport extends
EditingSupport {
private TableViewerColumn column;
private ScenarioEditor editor;
/**
* @param viewer
*/
public ScenarioActionTypeColumnEditingSupport(TableViewerColumn column,
ScenarioEditor editor) {
super(column.getViewer());
this.column = column;
this.editor = editor;
}
@Override
protected void setValue(Object element, Object value) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
Assert.isNotNull(value);
Assert.isTrue(value instanceof Integer);
final ScenarioStep step = (ScenarioStep) element;
int index = (Integer) value;
if (index < 0 || index >= ScenarioStepActionType.VALUES.size())
index = ScenarioStepActionType.NOT_CLASSIFIED_VALUE;
final ScenarioStepActionType type = ScenarioStepActionType.VALUES
.get(index);
ICommandStackService.INSTANCE.runAsCommand(
this.editor.getEditedObject(), new Runnable() {
@Override
public void run() {
step.setActionType(type);
}
});
}
@Override
protected Object getValue(Object element) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
return ScenarioStepActionType.VALUES.indexOf(((ScenarioStep) element)
.getActionType());
}
@Override
protected CellEditor getCellEditor(Object element) {
ArrayList<String> actiontypes = new ArrayList<String>();
for (ScenarioStepActionType s : ScenarioStepActionType.VALUES)
actiontypes.add(s.getName());
return new ComboBoxCellEditor(column.getColumn().getParent(),
actiontypes.toArray(new String[0]));
}
@Override
protected boolean canEdit(Object element) {
return true;
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.widgets.Control;
import org.fortiss.af3.mira.model.usecase.Actor;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.ui.dialog.ActorSelectionDialog;
import org.fortiss.tooling.kernel.service.ICommandStackService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ScenarioActorColumnEditingSupport extends EditingSupport {
private TableViewerColumn column;
private ScenarioEditor editor;
/**
* @param viewer
*/
public ScenarioActorColumnEditingSupport(TableViewerColumn column,
ScenarioEditor editor) {
super(column.getViewer());
this.column = column;
this.editor = editor;
}
@Override
protected void setValue(Object element, Object value) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
if (value == null || !(value instanceof Actor))
return;
final ScenarioStep step = (ScenarioStep) element;
final Actor actor = (Actor) value;
ICommandStackService.INSTANCE.runAsCommand(
this.editor.getEditedObject(), new Runnable() {
@Override
public void run() {
step.setActor(actor);
}
});
}
@Override
protected Object getValue(Object element) {
Assert.isNotNull(element);
Assert.isTrue(element instanceof ScenarioStep);
ScenarioStep step = (ScenarioStep) element;
if (step.getActor() == null)
return "";
return step.getActor().getName();
}
@Override
protected CellEditor getCellEditor(Object element) {
DialogCellEditor dce = new DialogCellEditor(column.getColumn()
.getParent()) {
@Override
protected Object openDialogBox(Control cellEditorWindow) {
return ActorSelectionDialog.open(cellEditorWindow.getShell(),
(UseCase) ScenarioActorColumnEditingSupport.this.editor
.getEditedObject().eContainer());
}
};
return dce;
}
@Override
protected boolean canEdit(Object element) {
return true;
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.jface.databinding.viewers.ObservableMapCellLabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.ViewerCell;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ScenarioActorColumnFireLabelProvider extends
ObservableMapCellLabelProvider {
private ScenarioEditor scenarioEditor;
/**
* @param attributeMaps
*/
public ScenarioActorColumnFireLabelProvider(IObservableMap[] attributeMaps,
ScenarioEditor editor) {
super(attributeMaps);
this.scenarioEditor = editor;
}
/** {@inheritDoc} */
@Override
public void update(ViewerCell cell) {
try {
cell.setText(((ScenarioStep) cell.getElement()).getActor()
.getName());
cell.setForeground(ColorConstants.titleForeground);
} catch (NullPointerException e) {
cell.setText("<No Actor>");
cell.setForeground(ColorConstants.gray);
}
}
/** {@inheritDoc} */
@Override
protected void fireLabelProviderChanged(LabelProviderChangedEvent event) {
Set<Object> newlist = new HashSet<Object>(Arrays.asList(event
.getElements()));
for (Object e : event.getElements()) {
for (IHierarchicElement o : ((IHierarchicElementContainer) scenarioEditor
.getEditedObject()).getContainedElements()) {
ScenarioStep s = (ScenarioStep) o;
if (e.equals(s) || e.equals(s.getActor())
|| e.equals(s.getBranch()))
newlist.add(s);
}
}
super.fireLabelProviderChanged(new LabelProviderChangedEvent(this,
newlist.toArray()));
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.fortiss.af3.mira.model.usecase.Actor;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.af3.mira.model.usecase.ScenarioStepActionType;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.model.usecase.UsecaseFactory;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.kernel.service.ICommandStackService;
/**
*
* @author Leonhard Uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ScenarioAddScenarioStepLogic extends SelectionAdapter {
private ScenarioEditor scenarioEditor;
ScenarioAddScenarioStepLogic(ScenarioEditor editor) {
super();
this.scenarioEditor = editor;
}
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
ICommandStackService.INSTANCE.runAsCommand(
this.scenarioEditor.getEditedObject(), new Runnable() {
@Override
public void run() {
Actor actor = UsecaseFactory.eINSTANCE.createActor();
actor.setName("<unknown actor>");
((UseCase) ScenarioAddScenarioStepLogic.this.scenarioEditor
.getEditedObject().eContainer()).getActorList()
.add(actor);
ScenarioStep step = UsecaseFactory.eINSTANCE
.createScenarioStep();
step.setId(((IHierarchicElementContainer) ScenarioAddScenarioStepLogic.this.scenarioEditor
.getEditedObject())
.getContainedElementsLength() + 1);
step.setAction("<no action>");
step.setActor(actor);
step.setActionType(ScenarioStepActionType.NOT_CLASSIFIED);
((IHierarchicElementContainer) ScenarioAddScenarioStepLogic.this.scenarioEditor
.getEditedObject()).getContainedElementsList()
.add(step);
}
});
}
}
\ No newline at end of file
package org.fortiss.af3.mira.ui.editor;
import java.util.ArrayList;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
import org.fortiss.af3.mira.model.usecase.UseCase;