Commit f7ba2890 authored by Carmen Carlan's avatar Carmen Carlan
Browse files

deleted is under reviewd because it was replaced with is challenged

refs 3009
parent 31d9e076
/*-------------------------------------------------------------------------+
| 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.safetycases.ui.commands;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.kernel.service.IPersistencyService.getInstance;
import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.AFTER_GLOBAL_MENU_SECTION_ID;
import java.util.ArrayList;
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.fortiss.af3.safetycases.model.ArgumentElement;
import org.fortiss.af3.safetycases.model.Goal;
import org.fortiss.af3.safetycases.ui.AF3SafetyCasesUIActivator;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
/**
* This class implements the action of changing the challenge status of goal
* figure.
*
* @author alext
*/
public class GoalUnderReview implements IContextMenuContributor {
private List<ArgumentElement> challengedElements = new ArrayList<>();
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(selection instanceof Goal && ((Goal)selection).isChallenged() == false) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(new GoalIsUnderReviewAction(
(Goal)selection)));
return contributionItems;
}
if(selection instanceof Goal && ((Goal)selection).isChallenged() == true) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(new GoalIsNotUnderReviewAction(
(Goal)selection)));
return contributionItems;
}
return emptyList();
}
/** {@inheritDoc} */
@Override
public String getMenuSectionID() {
return AFTER_GLOBAL_MENU_SECTION_ID;
}
/** The method to challenge a goal */
public void review(ArgumentElement e) {
e.setChallenged(true);
challengedElements.add(e);
if(e instanceof Goal) {
if(!(e.getConnectors().isEmpty())) {
for(int i = 0; i < e.getConnectors().size(); i++) {
if(!(e.getConnectors().get(i).getOutgoing().isEmpty())) {
if(!((ArgumentElement)e.getConnectors().get(i).getOutgoing().get(0)
.getTarget().getOwner()).isChallenged()) {
review(((ArgumentElement)e.getConnectors().get(i).getOutgoing().get(0)
.getTarget().getOwner()));
}
}
}
}
}
}
/** The action to NOT underReview. */
private class GoalIsNotUnderReviewAction extends Action {
/** The selected solution. */
private Goal selectedGoal;
/** Constructor. */
GoalIsNotUnderReviewAction(Goal selected) {
super("Is Under Review", AF3SafetyCasesUIActivator
.getImageDescriptor("icons/underreview.png"));
this.selectedGoal = selected;
}
/** {@inheritDoc} */
@Override
public void run() {
final ITopLevelElement topLevel = getInstance().getTopLevelElementFor(selectedGoal);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
}
});
}
}
/** The action to underReview. */
private class GoalIsUnderReviewAction extends Action {
/** The selected goal. */
private Goal selectedGoal;
/** Constructor. */
GoalIsUnderReviewAction(Goal selected) {
super("Is Under Review", AF3SafetyCasesUIActivator
.getImageDescriptor("icons/underreview.png"));
this.selectedGoal = selected;
}
/** {@inheritDoc} */
@Override
public void run() {
final ITopLevelElement topLevel = getInstance().getTopLevelElementFor(selectedGoal);
topLevel.runAsCommand(new Runnable() {
@Override
public void run() {
}
});
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment