diff options
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.common/src/org/eclipse/etrice/ui')
3 files changed, 39 insertions, 4 deletions
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 6f2df7fa3..4bb3a6a50 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 688db325f..bbec57197 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 837c6a5ef..7b78428d6 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); } |