summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayant Gupta2013-09-20 02:56:54 (EDT)
committerJayant Gupta2013-09-22 12:02:37 (EDT)
commit746c3043111ccc72229fbfa77725a90a39d4196e (patch)
treef598c8f1845a05a4bb028cf1b301ef2c015a7171
parent3f64e53873ed85db637dcf97488b78b44585b657 (diff)
downloadorg.eclipse.etrice-746c3043111ccc72229fbfa77725a90a39d4196e.zip
org.eclipse.etrice-746c3043111ccc72229fbfa77725a90a39d4196e.tar.gz
org.eclipse.etrice-746c3043111ccc72229fbfa77725a90a39d4196e.tar.bz2
Adds Quick Fix Implementations and corrects QuickFix Dialog layout.refs/changes/26/16626/2
Known Issues (tagged with FIXME): 1. Duplicate Issues in Quick Fix Dialog. Reason: Multiple diagnostics for same issue. 2. Invisibility of Quick Fix Images on first invocation of the Dialog. Change-Id: I22bed5826bb9c471385274eb852313057dc4c823 Signed-off-by: Jayant Gupta <gsocjayant@gmail.com>
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java28
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/QuickFixDialog.java55
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java65
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java30
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/markers/DiagnosingModelObserver.java4
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/quickfix/BehaviorQuickfixProvider.java454
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java41
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java21
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/dialogs/AbstractPropertyDialog.java34
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IDiagramModification.java2
-rw-r--r--plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IssueResolution.java7
13 files changed, 620 insertions, 127 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
index 781c719..fd09094 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
@@ -184,10 +184,10 @@ public class AbstractExecutionValidator implements IRoomValidator {
for (MessageFromIf msg : incoming) {
messageAcceptor.acceptWarning("State should handle the message "
+ msg.getMessage().getName() + " from port "
- + msg.getFrom().getName() + " ", container,
- orig.eContainingFeature(), idx, DIAG_CODE_MISSING_TRIGGER,
- st.getName(), msg.getFrom().getGeneralProtocol().getName(),
- msg.getMessage().getName(), msg.getFrom().getName());
+ + msg.getFrom().getName() + " ", container, orig
+ .eContainingFeature(), idx, DIAG_CODE_MISSING_TRIGGER, st
+ .getName(), msg.getMessage().getName(), msg.getFrom()
+ .getName());
}
List<MessageFromIf> outgoing = propGen.getOutgoingProposals();
@@ -196,8 +196,8 @@ public class AbstractExecutionValidator implements IRoomValidator {
+ msg.getMessage().getName() + " to port "
+ msg.getFrom().getName() + " ", container, orig
.eContainingFeature(), idx, DIAG_CODE_MISSING_MESSAGESEND,
- st.getName(), msg.getFrom().getGeneralProtocol().getName(),
- msg.getMessage().getName(), msg.getFrom().getName());
+ st.getName(), msg.getMessage().getName(), msg.getFrom()
+ .getName());
}
}
@@ -236,13 +236,8 @@ public class AbstractExecutionValidator implements IRoomValidator {
.indexOf(trig),
DIAG_CODE_VIOLATION_TRIGGER,
trigger.getMsg().getName(),
- mif.getFrom()
- .getGeneralProtocol()
- .getName(), mif
- .getMessage()
- .getName(), mif
- .getFrom()
- .getName());
+ mif.getMessage().getName(),
+ mif.getFrom().getName());
}
}
}
@@ -251,10 +246,11 @@ public class AbstractExecutionValidator implements IRoomValidator {
DetailCode dc = (DetailCode) origin;
EObject orig = xpac.getOrig(dc);
messageAcceptor.acceptWarning(
- "The message violates the semantic rule",
- orig.eContainer(), orig.eContainingFeature(),
+ "The message violates the semantic rule", orig
+ .eContainer(), orig.eContainingFeature(),
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
- DIAG_CODE_VIOLATION_MESSAGESEND);
+ DIAG_CODE_VIOLATION_MESSAGESEND, msg.getMsg()
+ .getName(), msg.getIfitem().getName());
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/QuickFixDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/QuickFixDialog.java
index 4709eb0..9a6e2dd 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/QuickFixDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/QuickFixDialog.java
@@ -37,6 +37,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
@@ -60,7 +61,7 @@ public class QuickFixDialog extends SelectionDialog {
private HashMap<FeatureBasedDiagnostic, List<IssueResolution>> issueResolutionsMap;
private TableViewer issueList;
private TableViewer resolutionsList;
- private Label resolutionDescription;
+ private Text resolutionDescription;
/**
* Constructs a list selection dialog.
@@ -83,9 +84,10 @@ public class QuickFixDialog extends SelectionDialog {
* @see Dialog#createDialogArea(Composite)
*/
public Control createDialogArea(Composite parent) {
- Composite contents = (Composite) super.createDialogArea(parent);
- createMessageArea(contents);
+ // FIXME problems with first call to label provider.
+ Composite contents = (Composite) super.createDialogArea(parent);
+
createLabel(contents, ISSUES_LIST_LABEL);
createIssueList(contents);
@@ -110,6 +112,10 @@ public class QuickFixDialog extends SelectionDialog {
issueList = new TableViewer(control, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false);
+ gd.heightHint = 60;
+ issueList.getControl().setLayoutData(gd);
+
issueList.setContentProvider(new IStructuredContentProvider() {
@Override
@@ -179,6 +185,10 @@ public class QuickFixDialog extends SelectionDialog {
resolutionsList = new TableViewer(control, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false);
+ gd.heightHint = 60;
+ resolutionsList.getControl().setLayoutData(gd);
+
resolutionsList.setContentProvider(new IStructuredContentProvider() {
@Override
@@ -247,38 +257,17 @@ public class QuickFixDialog extends SelectionDialog {
return label;
}
- /**
- * Creates the message text widget and sets layout data.
- *
- * @param composite
- * the parent composite of the message area.
- */
- protected Label createMessageArea(Composite composite) {
- Label label = super.createMessageArea(composite);
-
- GridData data = new GridData();
- data.grabExcessVerticalSpace = false;
- data.grabExcessHorizontalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.BEGINNING;
- label.setLayoutData(data);
-
- return label;
- }
-
- private Label createDescritionArea(Composite composite) {
- Label label = super.createMessageArea(composite);
-
- GridData data = new GridData();
- data.grabExcessVerticalSpace = true;
- data.grabExcessHorizontalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.BEGINNING;
- label.setLayoutData(data);
+ private Text createDescritionArea(Composite composite) {
+ Text text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false);
+ gd.heightHint = 60;
+ gd.widthHint = 130;
+ text.setLayoutData(gd);
+ text.setEditable(false);
- resolutionDescription = label;
+ resolutionDescription = text;
- return label;
+ return text;
}
/**
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
index dfe0b45..b477490 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/StatePropertyDialog.java
@@ -15,6 +15,7 @@ import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.core.validation.ValidationUtil.Result;
import org.eclipse.etrice.ui.behavior.Activator;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
@@ -42,6 +43,13 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
private State state;
private boolean inherited;
+ private boolean addCode = false;
+ private String entryCodeSelectionString = "";
+ private String exitCodeSelectionString = "";
+ private String doCodeSelectionString = "";
+ private String messageToDisplay = "";
+ private String messageTitle = "";
+
public StatePropertyDialog(Shell shell, ActorClass ac, State s, boolean edit) {
super(shell, edit?"Edit State":"View State", ac);
this.state = s;
@@ -84,6 +92,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
entry.setLayoutData(gd);
+
+ if (addCode && !entryCodeSelectionString.isEmpty())
+ entry.append(entryCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(entry, entryCodeSelectionString);
}
else {
if (state instanceof RefinedState)
@@ -93,6 +105,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
entry.setLayoutData(gd);
+
+ if (addCode && !entryCodeSelectionString.isEmpty())
+ entry.append(entryCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(entry, entryCodeSelectionString);
}
{
@@ -101,6 +117,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
entry.setLayoutData(gd);
+
+ if (addCode && !entryCodeSelectionString.isEmpty())
+ entry.append(entryCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(entry, entryCodeSelectionString);
}
}
@@ -112,6 +132,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
entry.setLayoutData(gd);
+
+ if (addCode && !exitCodeSelectionString.isEmpty())
+ entry.append(exitCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(entry, exitCodeSelectionString);
}
else {
{
@@ -120,6 +144,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
exit.setLayoutData(gd);
+
+ if (addCode && !exitCodeSelectionString.isEmpty())
+ exit.append(exitCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(exit, exitCodeSelectionString);
}
if (state instanceof RefinedState)
@@ -129,6 +157,10 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
entry.setLayoutData(gd);
+
+ if (addCode && !exitCodeSelectionString.isEmpty())
+ entry.append(exitCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(entry, exitCodeSelectionString);
}
}
@@ -140,9 +172,42 @@ public class StatePropertyDialog extends AbstractMemberAwarePropertyDialog {
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
dotxt.setLayoutData(gd);
+
+ if (addCode && !doCodeSelectionString.isEmpty())
+ dotxt.append(doCodeSelectionString + "();\n");
+ setTextSelectionAndFocus(dotxt, doCodeSelectionString);
}
createMembersAndMessagesButtons(body);
+
+ if (!messageToDisplay.isEmpty()) {
+ getShell().getParent().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openInformation(getShell(), messageTitle,
+ messageToDisplay);
+ }
+ });
+ }
}
+ public void setAddCode(boolean add) {
+ addCode = add;
+ }
+
+ public void setEntryCodeSelectionString(String selectionString) {
+ entryCodeSelectionString = selectionString;
+ }
+
+ public void setExitCodeSelectionString(String selectionString) {
+ exitCodeSelectionString = selectionString;
+ }
+
+ public void setDoCodeSelectionString(String selectionString) {
+ doCodeSelectionString = selectionString;
+ }
+
+ public void setMessageDialogContents(String message, String title) {
+ messageToDisplay = message;
+ messageTitle = title;
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
index 17c570b..84c8d30 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/dialogs/TransitionPropertyDialog.java
@@ -32,6 +32,7 @@ import org.eclipse.etrice.core.validation.ValidationUtil;
import org.eclipse.etrice.core.validation.ValidationUtil.Result;
import org.eclipse.etrice.ui.behavior.Activator;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -184,6 +185,9 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
private boolean triggerError = false;
private boolean inherited;
private RefinedTransition refined;
+ private String actionCodeSelectionString = "";
+ private String messageToDisplay = "";
+ private String messageTitle = "";
public TransitionPropertyDialog(Shell shell, ActorClass ac, Transition trans) {
super(shell, "Edit Transition", ac);
@@ -303,8 +307,10 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
{
String code = RoomHelpers.getInheritedActionCode(trans, getActorClass());
- if (code!=null)
- createFixedText(body, "Base Action Code:", code, true);
+ if (code!=null){
+ Text baseActionCode = createFixedText(body, "Base Action Code:", code, true);
+ setTextSelectionAndFocus(baseActionCode, actionCodeSelectionString);
+ }
}
if (inherited) {
@@ -314,6 +320,7 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
action.setLayoutData(gd);
+ setTextSelectionAndFocus(action, actionCodeSelectionString);
}
}
else
@@ -323,9 +330,19 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
action.setLayoutData(gd);
+ setTextSelectionAndFocus(action, actionCodeSelectionString);
}
createMembersAndMessagesButtons(body);
+
+ if (!messageToDisplay.isEmpty()) {
+ getShell().getParent().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openInformation(getShell(), messageTitle,
+ messageToDisplay);
+ }
+ });
+ }
}
private void disableAll(Composite parent) {
@@ -751,4 +768,13 @@ public class TransitionPropertyDialog extends AbstractMemberAwarePropertyDialog
((Trigger) element).setGuard(guard);
}
}
+
+ public void setActionCodeSelectionString(String selectionString){
+ this.actionCodeSelectionString = selectionString;
+ }
+
+ public void setMessageDialogContents(String message, String title) {
+ messageToDisplay = message;
+ messageTitle = title;
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/markers/DiagnosingModelObserver.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/markers/DiagnosingModelObserver.java
index 236e258..86084ee 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/markers/DiagnosingModelObserver.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/markers/DiagnosingModelObserver.java
@@ -139,6 +139,10 @@ public class DiagnosingModelObserver extends EContentAdapter {
if (elementDiagnosticMap.get(eObject) == null)
elementDiagnosticMap.put(eObject,
new ArrayList<Diagnostic>());
+
+ // FIXME Some Diagnostics are added Multiple times. Remove
+ // duplicate diagnostics. This is the reason for multiple
+ // entries for same issue in Quick Fix Dialog.
elementDiagnosticMap.get(eObject).add(diagnostic);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/quickfix/BehaviorQuickfixProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/quickfix/BehaviorQuickfixProvider.java
index a6e4b09..f990b3c 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/quickfix/BehaviorQuickfixProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/quickfix/BehaviorQuickfixProvider.java
@@ -13,13 +13,47 @@
package org.eclipse.etrice.ui.behavior.quickfix;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator;
-import org.eclipse.etrice.abstractexec.behavior.ReachabilityValidator;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.Message;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.RoomFactory;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.core.room.StateGraph;
+import org.eclipse.etrice.core.room.Transition;
+import org.eclipse.etrice.core.room.TransitionTerminal;
+import org.eclipse.etrice.core.room.Trigger;
+import org.eclipse.etrice.core.room.TriggeredTransition;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.ui.behavior.support.StateSupport.FeatureProvider.PropertyFeature;
+import org.eclipse.etrice.ui.behavior.support.SupportUtil;
+import org.eclipse.etrice.ui.behavior.support.TransitionSupport;
import org.eclipse.etrice.ui.common.quickfix.AbstractQuickfixProvider;
import org.eclipse.etrice.ui.common.quickfix.IDiagramModification;
import org.eclipse.etrice.ui.common.quickfix.IssueResolutionAcceptor;
import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.IRemoveFeature;
+import org.eclipse.graphiti.features.context.ICustomContext;
+import org.eclipse.graphiti.features.context.IRemoveContext;
+import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
+import org.eclipse.graphiti.features.context.impl.CustomContext;
+import org.eclipse.graphiti.features.context.impl.RemoveContext;
+import org.eclipse.graphiti.features.context.impl.UpdateContext;
+import org.eclipse.graphiti.features.custom.ICustomFeature;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.xtext.ui.editor.quickfix.Fix;
import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
@@ -31,23 +65,102 @@ import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
public class BehaviorQuickfixProvider extends AbstractQuickfixProvider {
private static final String ADD_IMG = "icons/quickfix/add.gif";
+ private static final String SUB_IMG = "icons/quickfix/add.gif";
@Fix(AbstractExecutionValidator.DIAG_CODE_MISSING_TRIGGER)
public void fixMissingTrigger(final FeatureBasedDiagnostic issue,
IssueResolutionAcceptor acceptor) {
- acceptor.accept(
- issue,
- "Add the missing trigger",
- "Adds a new transition with trigger to handle message "
- + issue.getIssueData()[2] + " from port "
- + issue.getIssueData()[3], ADD_IMG,
+ final String msgName = issue.getIssueData()[1];
+ final String ifItemName = issue.getIssueData()[2];
+ acceptor.accept(issue, "Add the missing trigger",
+ "Adds a new self-transition with trigger to handle message "
+ + msgName + " from port " + ifItemName, ADD_IMG,
new IDiagramModification() {
@Override
- public void apply(Diagram diagram, IFeatureProvider fp)
+ public boolean apply(Diagram diagram, IFeatureProvider fp)
throws Exception {
- // make a new transition & add a Trigger to handle
+ // make a new self-transition & add a Trigger to handle
// message
+
+ // check preconditions & get pictogram element
+ EObject obj = issue.getSourceEObject();
+ if (!(obj instanceof StateGraph))
+ return false;
+
+ State state = ((StateGraph) obj).getStates().get(
+ issue.getIndex());
+ List<PictogramElement> pes = Graphiti.getLinkService()
+ .getPictogramElements(diagram, state);
+ if (pes.size() != 1
+ || !(pes.get(0) instanceof ContainerShape))
+ // unexpected
+ return false;
+
+ // find matching interface item and message
+ ActorClass ac = SupportUtil.getActorClass(diagram);
+
+ // it is crucial that we consider all emitters of
+ // messages (port, saps, spps)
+ // including base classes
+ List<InterfaceItem> items = RoomHelpers
+ .getAllInterfaceItems(ac);
+ for (InterfaceItem item : items) {
+ if (item.getName().equals(ifItemName)) {
+ List<Message> msgs = RoomHelpers
+ .getIncoming(item);
+ for (Message msg : msgs) {
+ if (msg.getName().equals(msgName)) {
+ // create triggered transition with our
+ // trigger and add it to the state graph
+ TriggeredTransition trans = RoomFactory.eINSTANCE
+ .createTriggeredTransition();
+ trans.setName(RoomNameProvider
+ .getUniqueTransitionName((StateGraph) state
+ .eContainer()));
+ Trigger tri = RoomFactory.eINSTANCE
+ .createTrigger();
+ trans.getTriggers().add(tri);
+ MessageFromIf mif = RoomFactory.eINSTANCE
+ .createMessageFromIf();
+ mif.setFrom(item);
+ mif.setMessage(msg);
+ tri.getMsgFromIfPairs().add(mif);
+ ((StateGraph) obj).getTransitions()
+ .add(trans);
+
+ // connect both ends to our state
+ // caution: the returned
+ // TransitionTerminal is created by this
+ // call and will be
+ // owned by the transition. Therefore we
+ // have to do it twice
+ ContainerShape shape = (ContainerShape) pes
+ .get(0);
+ Anchor anchor = shape.getAnchors().get(
+ 0);
+ TransitionTerminal src = SupportUtil
+ .getTransitionTerminal(anchor,
+ fp);
+ TransitionTerminal tgt = SupportUtil
+ .getTransitionTerminal(anchor,
+ fp);
+ trans.setFrom(src);
+ trans.setTo(tgt);
+
+ // prepare a context for Graphiti
+ AddConnectionContext addContext = new AddConnectionContext(
+ anchor, anchor);
+ addContext.setNewObject(trans);
+
+ // and let the feature provider delegate
+ // to the correct feature
+ return fp.addIfPossible(addContext) != null;
+ }
+ }
+ }
+ }
+ return false;
}
});
}
@@ -55,90 +168,311 @@ public class BehaviorQuickfixProvider extends AbstractQuickfixProvider {
@Fix(AbstractExecutionValidator.DIAG_CODE_MISSING_MESSAGESEND)
public void fixMissingMessageSend(final FeatureBasedDiagnostic issue,
IssueResolutionAcceptor acceptor) {
- acceptor.accept(
- issue,
- "Send message " + issue.getIssueData()[2] + " to port "
- + issue.getIssueData()[3],
- "Adds a new transition with sends message "
- + issue.getIssueData()[2] + " to port "
- + issue.getIssueData()[3], ADD_IMG,
+ final String msgName = issue.getIssueData()[1];
+ final String ifItemName = issue.getIssueData()[2];
+ final String codeString = ifItemName + '.' + msgName;
+ acceptor.accept(issue, "Add Entry Code to send message",
+ "Adds Entry Code to send " + msgName + " to port " + ifItemName
+ + " in Edit State Dialog", ADD_IMG,
new IDiagramModification() {
-
@Override
- public void apply(Diagram diagram, IFeatureProvider fp)
+ public boolean apply(Diagram diagram, IFeatureProvider fp)
throws Exception {
- // make a new transition & send the message to the port
+ // open the State Property Dialog & add detail code to
+ // send message to the port
+
+ // check preconditions & get pictogram element
+ EObject obj = issue.getSourceEObject();
+ if (!(obj instanceof StateGraph))
+ return false;
+ State state = ((StateGraph) obj).getStates().get(
+ issue.getIndex());
+ List<PictogramElement> pes = Graphiti.getLinkService()
+ .getPictogramElements(diagram, state);
+ if (pes.size() != 1
+ || !(pes.get(0) instanceof ContainerShape))
+ // unexpected
+ return false;
+
+ // Open StatePropertyDialog, add line, select added
+ // line
+ PropertyFeature propertyFeature = null;
+ ICustomContext customContext = new CustomContext(pes
+ .toArray(new PictogramElement[pes.size()]));
+ ICustomFeature features[] = fp
+ .getCustomFeatures(customContext);
+ for (ICustomFeature feature : features) {
+ if (feature instanceof PropertyFeature) {
+ propertyFeature = (PropertyFeature) feature;
+ break;
+ }
+ }
+ if (propertyFeature != null) {
+ propertyFeature
+ .setEntryCodeSelectionString(codeString);
+ propertyFeature.setAddCode(true);
+ propertyFeature
+ .setMessageDialogContents(
+ "Please complete the code with the newly inserted and highlighted fragment.",
+ "Quick Fix");
+ propertyFeature.execute(customContext);
+ return propertyFeature.hasDoneChanges();
+ }
+
+ return false;
}
+ });
+
+ acceptor.accept(issue, "Add Exit Code to send message",
+ "Adds Exit Code to send " + msgName + " to port " + ifItemName
+ + " in Edit State Dialog", ADD_IMG,
+ new IDiagramModification() {
+ @Override
+ public boolean apply(Diagram diagram, IFeatureProvider fp)
+ throws Exception {
+ // add new detail code lines to send message to the exit
+ // code section of the state and open the
+ // StatePropertyDialog.
+ // check preconditions & get pictogram element
+ EObject obj = issue.getSourceEObject();
+ if (!(obj instanceof StateGraph))
+ return false;
+
+ State state = ((StateGraph) obj).getStates().get(
+ issue.getIndex());
+ List<PictogramElement> pes = Graphiti.getLinkService()
+ .getPictogramElements(diagram, state);
+ if (pes.size() != 1
+ || !(pes.get(0) instanceof ContainerShape))
+ // unexpected
+ return false;
+
+ // Open StatePropertyDialog, add line & select added
+ // line
+ PropertyFeature propertyFeature = null;
+ ICustomContext customContext = new CustomContext(pes
+ .toArray(new PictogramElement[pes.size()]));
+ ICustomFeature features[] = fp
+ .getCustomFeatures(customContext);
+ for (ICustomFeature feature : features) {
+ if (feature instanceof PropertyFeature) {
+ propertyFeature = (PropertyFeature) feature;
+ break;
+ }
+ }
+ if (propertyFeature != null) {
+ propertyFeature
+ .setExitCodeSelectionString(codeString);
+ propertyFeature.setAddCode(true);
+ propertyFeature
+ .setMessageDialogContents(
+ "Please complete the code with the newly inserted and highlighted fragment.",
+ "Quick Fix");
+ propertyFeature.execute(customContext);
+ return propertyFeature.hasDoneChanges();
+ }
+
+ return false;
+ }
});
}
@Fix(AbstractExecutionValidator.DIAG_CODE_VIOLATION_TRIGGER)
public void fixViolationTrigger(final FeatureBasedDiagnostic issue,
IssueResolutionAcceptor acceptor) {
- acceptor.accept(issue, "Change Trigger", "Changes the trigger",
- ADD_IMG, new IDiagramModification() {
+ final String msgName = issue.getIssueData()[1];
+ final String ifItemName = issue.getIssueData()[2];
+ acceptor.accept(
+ issue,
+ "Remove the Violating Messgae from Trigger",
+ "Remove the handled message "
+ + msgName
+ + " from port "
+ + ifItemName
+ + " from the trigger.\n"
+ + " If there are no more Messages handled by the trigger, the trigger would be removed.\n"
+ + " If there are no more triggers, the transition would be removed.",
+ SUB_IMG, new IDiagramModification() {
@Override
- public void apply(Diagram diagram, IFeatureProvider fp)
+ public boolean apply(Diagram diagram, IFeatureProvider fp)
throws Exception {
- // modify diagram using features and issue data...
- }
+ // Get the pictogram element
+ EObject obj = issue.getSourceEObject();
+ if (!(obj instanceof Trigger))
+ return false;
+
+ MessageFromIf mifToDelete = null;
+ Trigger trig = (Trigger) obj;
+ TriggeredTransition trans = (TriggeredTransition) trig
+ .eContainer();
+
+ List<PictogramElement> pes = Graphiti.getLinkService()
+ .getPictogramElements(diagram, trans);
+ if (pes.size() != 1)
+ // unexpected
+ return false;
+
+ // Test Remove the message from the trigger
+ for (MessageFromIf mif : trig.getMsgFromIfPairs()) {
+ if (mif.getMessage().getName() == msgName
+ && mif.getFrom().getName() == ifItemName) {
+ mifToDelete = mif;
+ break;
+ }
+ }
+
+ if (mifToDelete != null) {
+
+ if (trig.getMsgFromIfPairs().size() - 1 == 0) {
+ // the trigger would be deleted
+
+ if (trans.getTriggers().size() - 1 == 0) {
+ // The transition would be deleted
+ if (trans.getAction() != null) {
+ Shell shell = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell();
+ if (!(MessageDialog
+ .openQuestion(shell, "Warning",
+ "Transition being removed contains Action Code. Do you want to continue?")))
+ return false;
+ }
+
+ IRemoveContext rc = new RemoveContext(pes
+ .get(0));
+ IRemoveFeature removeFeature = fp
+ .getRemoveFeature(rc);
+ if (removeFeature != null) {
+ removeFeature.remove(rc);
+ }
+ EcoreUtil.delete(trans);
+ return true;
+
+ } else
+ trans.getTriggers().remove(trig);
+
+ } else
+ trig.getMsgFromIfPairs().remove(mifToDelete);
+
+ UpdateContext updateContext = new UpdateContext(pes
+ .get(0));
+ return fp.updateIfPossible(updateContext) != null;
+ }
+ return false;
+ }
});
}
@Fix(AbstractExecutionValidator.DIAG_CODE_VIOLATION_MESSAGESEND)
public void fixViolationMessageSend(final FeatureBasedDiagnostic issue,
IssueResolutionAcceptor acceptor) {
- acceptor.accept(issue, "Change Sent Message",
- "Changes the sent message", ADD_IMG,
+ final String msgName = issue.getIssueData()[0];
+ final String ifItemName = issue.getIssueData()[1];
+ final String codeString = ifItemName + '.' + msgName;
+ acceptor.accept(issue, "Inspect & remove the offending message",
+ "Removes the message " + msgName + " sent to the port "
+ + ifItemName + " in Edit State Dialog.", ADD_IMG,
new IDiagramModification() {
@Override
- public void apply(Diagram diagram, IFeatureProvider fp)
+ public boolean apply(Diagram diagram, IFeatureProvider fp)
throws Exception {
- // modify diagram using features and issue data...
+ // Select the offending piece of action code in Property
+ // Dialogs.
- }
+ EObject obj = issue.getSourceEObject();
+ if (obj instanceof State || obj instanceof StateGraph) {
- });
- }
+ // get the pictogram element for State
+ State state;
+ if (obj instanceof StateGraph)
+ state = ((StateGraph) obj).getStates().get(
+ issue.getIndex());
+ else
+ state = (State) obj;
- @Fix(ReachabilityValidator.DIAG_CODE_UNREACHABLE)
- public void fixUnreachable(final FeatureBasedDiagnostic issue,
- IssueResolutionAcceptor acceptor) {
- acceptor.accept(issue,
- "Add Transition from XYZ to " + issue.getIssueData()[0],
- "Adds Transition from XYZ to " + issue.getIssueData()[0],
- ADD_IMG, new IDiagramModification() {
+ List<PictogramElement> pes = Graphiti
+ .getLinkService().getPictogramElements(
+ diagram, state);
+ if (pes.size() != 1
+ || !(pes.get(0) instanceof ContainerShape))
+ // unexpected
+ return false;
- @Override
- public void apply(Diagram diagram, IFeatureProvider fp)
- throws Exception {
- // Add the transition
+ // Open StatePropertyDialog & select the offending
+ // code
+ PropertyFeature propertyFeature = null;
+ ICustomContext customContext = new CustomContext(
+ pes.toArray(new PictogramElement[pes.size()]));
+ ICustomFeature features[] = fp
+ .getCustomFeatures(customContext);
+ for (ICustomFeature feature : features) {
+ if (feature instanceof PropertyFeature) {
+ propertyFeature = (PropertyFeature) feature;
+ break;
+ }
+ }
+ if (propertyFeature != null) {
+ propertyFeature
+ .setEntryCodeSelectionString(codeString);
+ propertyFeature
+ .setExitCodeSelectionString(codeString);
+ propertyFeature
+ .setDoCodeSelectionString(codeString);
+ propertyFeature
+ .setMessageDialogContents(
+ "Please remove the highlighted code after inspection.",
+ "Quick Fix");
+ propertyFeature.execute(customContext);
+ return propertyFeature.hasDoneChanges();
+ }
- }
+ } else if (obj instanceof Transition
+ || obj instanceof Trigger) {
+ // Get pictogram element for Transition
+ Transition transition;
+ if (obj instanceof Trigger)
+ transition = (Transition) obj.eContainer();
+ else
+ transition = (Transition) obj;
- });
- }
-
- @Fix(ReachabilityValidator.DIAG_CODE_UNREACHABLE)
- public void fixUnreachable2(final FeatureBasedDiagnostic issue,
- IssueResolutionAcceptor acceptor) {
- acceptor.accept(issue,
- "Add Transition from ABC to " + issue.getIssueData()[0],
- "Adds Transition from ABC to " + issue.getIssueData()[0],
- ADD_IMG, new IDiagramModification() {
-
- @Override
- public void apply(Diagram diagram, IFeatureProvider fp)
- throws Exception {
- // Add the transition
+ List<PictogramElement> pes = Graphiti
+ .getLinkService().getPictogramElements(
+ diagram, transition);
+ if (pes.size() != 1)
+ // unexpected
+ return false;
+ // Open TransitionPropertyDialog & select the
+ // offending piece of code
+ TransitionSupport.FeatureProvider.PropertyFeature propertyFeature = null;
+ ICustomContext customContext = new CustomContext(
+ pes.toArray(new PictogramElement[pes.size()]));
+ ICustomFeature features[] = fp
+ .getCustomFeatures(customContext);
+ for (ICustomFeature feature : features) {
+ if (feature instanceof TransitionSupport.FeatureProvider.PropertyFeature) {
+ propertyFeature = (TransitionSupport.FeatureProvider.PropertyFeature) feature;
+ break;
+ }
+ }
+ if (propertyFeature != null) {
+ propertyFeature
+ .setActionCodeSelectionString(codeString);
+ propertyFeature
+ .setMessageDialogContents(
+ "Please remove the highlighted code after inspection.",
+ "Quick Fix");
+ propertyFeature.execute(customContext);
+ return propertyFeature.hasDoneChanges();
+ }
+ }
+ return false;
}
-
});
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
index 81a6968..bd0cf64 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateGraphSupport.java
@@ -585,8 +585,7 @@ public class StateGraphSupport {
if (result == null)
return;
else{
- ((IssueResolution)result[0]).apply(getDiagram());
- doneChanges = true;
+ doneChanges = ((IssueResolution)result[0]).apply(getDiagram(), getFeatureProvider());
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
index 8120a8d..4b9b812 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/StateSupport.java
@@ -123,7 +123,7 @@ public class StateSupport {
private static final IColorConstant BACKGROUND = new ColorConstant(200, 200, 200);
private static final IColorConstant INHERITED_BACKGROUND = new ColorConstant(230, 230, 230);
- private static class FeatureProvider extends DefaultFeatureProvider {
+ public static class FeatureProvider extends DefaultFeatureProvider {
private class CreateFeature extends AbstractCreateFeature {
@@ -344,11 +344,18 @@ public class StateSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ public static class PropertyFeature extends AbstractCustomFeature {
private boolean doneChanges = false;
private boolean editable;
+ private boolean addCode = false;
+ private String entryCodeSelectionString = "";
+ private String exitCodeSelectionString = "";
+ private String doCodeSelectionString = "";
+ private String messageToDisplay = "";
+ private String messageTitle = "";
+
public PropertyFeature(IFeatureProvider fp, boolean editable) {
super(fp);
@@ -384,6 +391,12 @@ public class StateSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
StatePropertyDialog dlg = new StatePropertyDialog(shell, ac, s, editable);
+ dlg.setAddCode(addCode);
+ dlg.setEntryCodeSelectionString(entryCodeSelectionString);
+ dlg.setExitCodeSelectionString(exitCodeSelectionString);
+ dlg.setDoCodeSelectionString(doCodeSelectionString);
+ dlg.setMessageDialogContents(messageToDisplay, messageTitle);
+
if (dlg.open()!=Window.OK)
return;
@@ -439,6 +452,27 @@ public class StateSupport {
public boolean hasDoneChanges() {
return doneChanges;
}
+
+ public void setAddCode(boolean add) {
+ addCode = add;
+ }
+
+ public void setEntryCodeSelectionString(String selectionString){
+ entryCodeSelectionString = selectionString;
+ }
+
+ public void setExitCodeSelectionString(String selectionString){
+ exitCodeSelectionString = selectionString;
+ }
+
+ public void setDoCodeSelectionString(String selectionString){
+ doCodeSelectionString = selectionString;
+ }
+
+ public void setMessageDialogContents(String message, String title) {
+ messageToDisplay = message;
+ messageTitle = title;
+ }
}
private static class GoDownFeature extends AbstractCustomFeature implements
@@ -920,8 +954,7 @@ public class StateSupport {
if (result == null)
return;
else{
- ((IssueResolution)result[0]).apply(getDiagram());
- doneChanges = true;
+ doneChanges = ((IssueResolution)result[0]).apply(getDiagram(), getFeatureProvider());
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
index 520268e..8362c0c 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TrPointSupport.java
@@ -770,8 +770,7 @@ public class TrPointSupport {
if (result == null)
return;
else{
- ((IssueResolution)result[0]).apply(getDiagram());
- doneChanges = true;
+ doneChanges = ((IssueResolution)result[0]).apply(getDiagram(), getFeatureProvider());
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
index 50bf5d6..8b82c5c 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/TransitionSupport.java
@@ -114,7 +114,7 @@ public class TransitionSupport {
private static final int LINE_WIDTH = 1;
private static final int MAX_LABEL_LENGTH = 20;
- static class FeatureProvider extends DefaultFeatureProvider {
+ public static class FeatureProvider extends DefaultFeatureProvider {
private class CreateFeature extends AbstractCreateConnectionFeature {
@@ -604,10 +604,13 @@ public class TransitionSupport {
}
}
- private static class PropertyFeature extends AbstractCustomFeature {
+ public static class PropertyFeature extends AbstractCustomFeature {
private boolean doneChanges = false;
private boolean editable;
+ private String actionCodeSelectionString = "";
+ private String messageToDisplay = "";
+ private String messageTitle = "";
public PropertyFeature(IFeatureProvider fp, boolean editable) {
super(fp);
@@ -653,6 +656,8 @@ public class TransitionSupport {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
TransitionPropertyDialog dlg = new TransitionPropertyDialog(shell, SupportUtil.getActorClass(getDiagram()), trans);
+ dlg.setActionCodeSelectionString(actionCodeSelectionString);
+ dlg.setMessageDialogContents(messageToDisplay, messageTitle);
if (dlg.open()!=Window.OK)
return;
@@ -669,6 +674,15 @@ public class TransitionSupport {
public boolean hasDoneChanges() {
return doneChanges;
}
+
+ public void setActionCodeSelectionString(String selectionString){
+ actionCodeSelectionString = selectionString;
+ }
+
+ public void setMessageDialogContents(String message, String title) {
+ messageToDisplay = message;
+ messageTitle = title;
+ }
}
private static class RefineTransitionFeature extends AbstractCustomFeature {
@@ -825,8 +839,7 @@ public class TransitionSupport {
if (result == null)
return;
else{
- ((IssueResolution)result[0]).apply(getDiagram());
- doneChanges = true;
+ doneChanges = ((IssueResolution)result[0]).apply(getDiagram(), getFeatureProvider());
}
}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/dialogs/AbstractPropertyDialog.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/dialogs/AbstractPropertyDialog.java
index 6f2df7f..4bb3a6a 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/dialogs/AbstractPropertyDialog.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/dialogs/AbstractPropertyDialog.java
@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import java.util.Stack;
import org.eclipse.core.databinding.AggregateValidationStatus;
import org.eclipse.core.databinding.Binding;
@@ -570,4 +571,37 @@ public abstract class AbstractPropertyDialog extends FormDialog {
IObservableCollection observableStatusProvider = new WritableList(valProvider, ValidationStatusProvider.class);
return new AggregateValidationStatus(observableStatusProvider, AggregateValidationStatus.MAX_SEVERITY);
}
+
+ /**
+ * Selects the string {@code selectSring(...)} inside the Text & shifts the
+ * keyboard focus to it. If the select string is empty or not present inside
+ * the text, it does nothing.
+ *
+ * @param text
+ * @param selectString
+ *
+ * @author jayant
+ */
+ protected void setTextSelectionAndFocus(Text text, String selectString) {
+ if (selectString.isEmpty())
+ return;
+ String content = text.getText();
+ int start = content.indexOf(selectString+'(');
+ if (start != -1) {
+
+ // find the index of closing brace
+ int end = start + selectString.length() + 1;
+ Stack<Character> parenthesis = new Stack<Character>();
+ parenthesis.push('(');
+ while (end < content.length() && !parenthesis.isEmpty()) {
+ if (content.charAt(end) == '(')
+ parenthesis.push('(');
+ else if (content.charAt(end) == ')')
+ parenthesis.pop();
+ end++;
+ }
+ text.setFocus();
+ text.setSelection(start, end);
+ }
+ }
}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IDiagramModification.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IDiagramModification.java
index 688db32..bbec571 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IDiagramModification.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IDiagramModification.java
@@ -21,5 +21,5 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
*/
public interface IDiagramModification {
- void apply(Diagram diagram, IFeatureProvider fp) throws Exception;
+ boolean apply(Diagram diagram, IFeatureProvider fp) throws Exception;
}
diff --git a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IssueResolution.java b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IssueResolution.java
index 837c6a5..7b78428 100644
--- a/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IssueResolution.java
+++ b/plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui/common/quickfix/IssueResolution.java
@@ -13,6 +13,7 @@
package org.eclipse.etrice.ui.common.quickfix;
import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.pictograms.Diagram;
/**
@@ -30,7 +31,7 @@ public class IssueResolution {
* @param label
* @param image
*/
- public IssueResolution(String description, String label, String image, IDiagramModification modification) {
+ public IssueResolution(String label, String description, String image, IDiagramModification modification) {
this.description = description;
this.label = label;
this.image = image;
@@ -61,9 +62,9 @@ public class IssueResolution {
/**
* @param diagram
*/
- public void apply(Diagram diagram) {
+ public boolean apply(Diagram diagram, IFeatureProvider fp) {
try {
- modification.apply(diagram, null);
+ return modification.apply(diagram, fp);
} catch(Exception exc) {
throw new WrappedException(exc);
}