Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-03-31 05:53:07 +0000
committerHenrik Rentz-Reichert2011-03-31 05:53:07 +0000
commit86716d92963ac1a63f45f57e9f846dc7bd5a6073 (patch)
tree761dd0c875265fdf066a97af4b748fabea6f2c3b /plugins/org.eclipse.etrice.ui.commands
parent700c5efa549f24955234180d1bc61fe6bd396689 (diff)
downloadorg.eclipse.etrice-86716d92963ac1a63f45f57e9f846dc7bd5a6073.tar.gz
org.eclipse.etrice-86716d92963ac1a63f45f57e9f846dc7bd5a6073.tar.xz
org.eclipse.etrice-86716d92963ac1a63f45f57e9f846dc7bd5a6073.zip
ui.commands: fixed some issues with migration to Xtext 2.0
(auto-naming of transitions still doesn't work)
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.commands')
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java13
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java83
-rw-r--r--plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java4
3 files changed, 10 insertions, 90 deletions
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
index c34418cdc..7fa2bb9fb 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/AbstractEditHandler.java
@@ -31,7 +31,7 @@ import org.eclipse.xtext.resource.IFragmentProvider;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.editor.model.IXtextDocument;
-import org.eclipse.xtext.ui.editor.outline.ContentOutlineNode;
+import org.eclipse.xtext.ui.editor.outline.impl.EObjectNode;
import org.eclipse.xtext.ui.editor.utils.EditorUtils;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
@@ -52,7 +52,10 @@ public abstract class AbstractEditHandler extends AbstractHandler {
@Inject
protected IResourceValidator resourceValidator;
- @Inject IFragmentProvider fragmentProvider;
+ @Inject
+ IFragmentProvider fragmentProvider;
+
+ private EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();
public AbstractEditHandler() {
super();
@@ -74,10 +77,10 @@ public abstract class AbstractEditHandler extends AbstractHandler {
// event from the xtext editor's outline view
IStructuredSelection ss = (IStructuredSelection) selection;
Object sel = ss.getFirstElement();
- if (sel instanceof ContentOutlineNode) {
+ if (sel instanceof EObjectNode) {
XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
IXtextDocument document = xtextEditor.getDocument();
- final String fragment = ((ContentOutlineNode) sel).getURI().fragment();
+ final String fragment = ((EObjectNode) sel).getEObjectURI().fragment();
if (checkPrerequisites(xtextEditor, document, fragment)) {
openEditor(document, fragment);
}
@@ -91,7 +94,7 @@ public abstract class AbstractEditHandler extends AbstractHandler {
String fragment = document.readOnly(new IUnitOfWork<String, XtextResource>() {
@Override
public String exec(XtextResource resource) throws Exception {
- EObject obj = EObjectAtOffsetHelper.resolveElementAt(resource, ss.getOffset(), null);
+ EObject obj = helper.resolveElementAt(resource, ss.getOffset());
while (obj!=null) {
if (obj instanceof ActorClass) {
return fragmentProvider.getFragment(obj, null);
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
index bc2d8dfab..ed731549e 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
@@ -23,27 +23,10 @@ import org.eclipse.etrice.core.room.Transition;
import org.eclipse.etrice.core.ui.RoomUiModule;
import org.eclipse.etrice.ui.behavior.DiagramAccess;
import org.eclipse.jface.dialogs.MessageDialog;
-<<<<<<< HEAD:plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/EditBehaviorHandler.java
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.views.contentoutline.ContentOutline;
-=======
->>>>>>> FETCH_HEAD:plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.editor.outline.impl.EObjectNode;
import org.eclipse.xtext.ui.editor.model.IXtextDocument;
-<<<<<<< HEAD:plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/EditBehaviorHandler.java
-import org.eclipse.xtext.ui.editor.utils.EditorUtils;
-=======
-import org.eclipse.xtext.ui.editor.model.edit.DefaultDocumentEditor;
->>>>>>> FETCH_HEAD:plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
import com.google.inject.Injector;
@@ -59,51 +42,12 @@ import com.google.inject.Injector;
*/
public class EditBehaviorHandler extends AbstractEditHandler {
-<<<<<<< HEAD:plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/EditBehaviorHandler.java
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) selection;
- Object sel = ss.getFirstElement();
- if (sel instanceof EObjectNode) {
- final EObjectNode node = (EObjectNode) sel;
- XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
- if (xtextEditor.isDirty()) {
- if (!MessageDialog.openQuestion(xtextEditor.getSite().getShell(), "Save model file", "The editor will be saved before opening the diagram editor.\nProceed?"))
- return null;
- // postpone save to avoid doing it twice
- }
- if (hasUnnamedTransitions(xtextEditor.getDocument(), node.getEObjectURI().fragment())) {
- if (!MessageDialog.openQuestion(xtextEditor.getSite().getShell(), "Create transition names", "Transition names will be created where missing.\nProceed?"))
- return null;
- createTransitionNames(xtextEditor.getDocument(), node.getEObjectURI().fragment());
- xtextEditor.doSave(new NullProgressMonitor());
- }
- if (xtextEditor.isDirty()) {
- xtextEditor.doSave(new NullProgressMonitor());
- }
- xtextEditor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
- @Override
- public void process(XtextResource resource) throws Exception {
- if (resource != null) {
- EObject object = resource.getEObject(node.getEObjectURI().fragment());
- if (object instanceof ActorClass) {
- DiagramAccess diagramAccess = new DiagramAccess();
- diagramAccess.openDiagramEditor((ActorClass) object);
- }
- }
- }
- });
- }
-=======
protected boolean prepare(XtextEditor xtextEditor, final String fragment) {
if (hasUnnamedTransitions(xtextEditor.getDocument(), fragment)) {
if (!MessageDialog.openQuestion(xtextEditor.getSite().getShell(), "Create transition names", "Transition names will be created where missing.\nProceed?"))
return false;
createTransitionNames(xtextEditor.getDocument(), fragment);
xtextEditor.doSave(new NullProgressMonitor());
->>>>>>> FETCH_HEAD:plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
}
return true;
}
@@ -184,32 +128,6 @@ public class EditBehaviorHandler extends AbstractEditHandler {
});
}
-<<<<<<< HEAD:plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/outline/EditBehaviorHandler.java
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- IWorkbench wb = PlatformUI.getWorkbench();
- IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
- IWorkbenchPage page = win.getActivePage();
- IWorkbenchPart part = page.getActivePart();
- if (part instanceof ContentOutline) {
- ISelection selection = ((ContentOutline)part).getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) selection;
- Object sel = ss.getFirstElement();
- if (sel instanceof EObjectNode) {
- EObjectNode node = (EObjectNode) sel;
- if (RoomFragmentProvider.isActorClass(node.getEObjectURI().fragment()))
- return true;
- }
- }
- }
-
- return false;
- }
-=======
protected void openEditor(EObject object) {
if (object instanceof ActorClass) {
DiagramAccess diagramAccess = new DiagramAccess();
@@ -217,5 +135,4 @@ public class EditBehaviorHandler extends AbstractEditHandler {
}
}
->>>>>>> FETCH_HEAD:plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditBehaviorHandler.java
}
diff --git a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
index d0c5c4164..ae4ed8fcb 100644
--- a/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
+++ b/plugins/org.eclipse.etrice.ui.commands/src/org/eclipse/etrice/ui/commands/handlers/EditModelHandler.java
@@ -14,7 +14,7 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.xtext.resource.ILocationInFileProvider;
import org.eclipse.xtext.ui.editor.XtextEditor;
-import org.eclipse.xtext.util.TextLocation;
+import org.eclipse.xtext.util.ITextRegion;
import com.google.inject.Inject;
import com.google.inject.Injector;
@@ -57,7 +57,7 @@ public class EditModelHandler extends AbstractHandler {
editor = window.getActivePage().getActiveEditor();
if (editor instanceof XtextEditor) {
XtextEditor xed = (XtextEditor) editor;
- TextLocation location = locationProvider.getLocation(sc);
+ ITextRegion location = locationProvider.getFullTextRegion(sc);
xed.selectAndReveal(location.getOffset(), location.getLength());
}
}

Back to the top