当前位置: 首页>>代码示例>>Java>>正文


Java EditorUtils.getActiveXtextEditor方法代码示例

本文整理汇总了Java中org.eclipse.xtext.ui.editor.utils.EditorUtils.getActiveXtextEditor方法的典型用法代码示例。如果您正苦于以下问题:Java EditorUtils.getActiveXtextEditor方法的具体用法?Java EditorUtils.getActiveXtextEditor怎么用?Java EditorUtils.getActiveXtextEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.ui.editor.utils.EditorUtils的用法示例。


在下文中一共展示了EditorUtils.getActiveXtextEditor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLaunchConfigFromEditor

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
protected LaunchConfig getLaunchConfigFromEditor(ExecutionEvent event) {
    XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
    if (activeXtextEditor == null) {
        return null;
    }
    final ITextSelection selection = (ITextSelection) activeXtextEditor.getSelectionProvider().getSelection();
    return activeXtextEditor.getDocument().priorityReadOnly(new IUnitOfWork<LaunchConfig, XtextResource>() {

        @Override
        public LaunchConfig exec(XtextResource xTextResource) throws Exception {
            EObject lc = eObjectAtOffsetHelper.resolveContainedElementAt(xTextResource, selection.getOffset());
            return findParentLaunchConfig(lc);
        }

    });
}
 
开发者ID:mduft,项目名称:lcdsl,代码行数:17,代码来源:AbstractLaunchConfigGeneratorHandler.java

示例2: execute

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object execute(final ExecutionEvent event) throws ExecutionException {
	final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor != null) {
		final IXtextDocument document = xtextEditor.getDocument();
		document.readOnly(new IUnitOfWork.Void<XtextResource>()  {
			@Override
			public void process(XtextResource state) throws Exception {
				final QuickOutlinePopup quickOutlinePopup = createPopup(xtextEditor.getEditorSite().getShell());
				quickOutlinePopup.setEditor(xtextEditor);
				quickOutlinePopup.setInput(document);
				quickOutlinePopup.setEvent((Event) event.getTrigger());
				quickOutlinePopup.open();
			}
		});
	}
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:ShowQuickOutlineActionHandler.java

示例3: execute

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	try {
		XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
		if (editor != null) {
			final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
			editor.getDocument().readOnly(new IUnitOfWork.Void<XtextResource>() {
				@Override
				public void process(XtextResource state) throws Exception {
					EObject target = eObjectAtOffsetHelper.resolveElementAt(state, selection.getOffset());
					findReferences(target);
				}
			});
		}
	} catch (Exception e) {
		LOG.error(Messages.FindReferencesHandler_3, e);
	}
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:FindReferencesHandler.java

示例4: execute

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor != null) {
		ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();

		IRegion region = new Region(selection.getOffset(), selection.getLength());

		ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();

		IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
		if (hyperlinks != null && hyperlinks.length > 0) {
			IHyperlink hyperlink = hyperlinks[0];
			hyperlink.open();
		}
	}		
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:OpenDeclarationHandler.java

示例5: getQualifiedName

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
@Override
protected String getQualifiedName(ExecutionEvent event) {
	XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (activeXtextEditor == null) {
		return null;
	}
	final ITextSelection selection = getTextSelection(activeXtextEditor);
	return activeXtextEditor.getDocument().readOnly(new IUnitOfWork<String, XtextResource>() {

		public String exec(XtextResource xTextResource) throws Exception {
			EObject context = getContext(selection, xTextResource);
			EObject selectedElement = getSelectedName(selection, xTextResource);
			return getQualifiedName(selectedElement, context);
		}

	});
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:EditorCopyQualifiedNameHandler.java

示例6: getSelectionURI

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
private URI getSelectionURI(ISelection currentSelection) {
	if (currentSelection instanceof IStructuredSelection) {
		IStructuredSelection iss = (IStructuredSelection) currentSelection;
		if (iss.size() == 1) {
			EObjectNode node = (EObjectNode) iss.getFirstElement();
			return node.getEObjectURI();
		}
	} else if (currentSelection instanceof TextSelection) {
		// Selection may be stale, get latest from editor
		XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
		TextSelection ts = (TextSelection) xtextEditor.getSelectionProvider().getSelection();
		return xtextEditor.getDocument().readOnly(resource -> {
			EObject e = new EObjectAtOffsetHelper().resolveContainedElementAt(resource, ts.getOffset());
			return EcoreUtil2.getURI(e);
		});
	}
	return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:19,代码来源:AadlHandler.java

示例7: draw

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
private void draw() {
	XtextEditor editor = EditorUtils.getActiveXtextEditor();
	if (editor != null && (hoveredElement != null || !selectedElements.isEmpty())) {
		ISourceViewer isv = editor.getInternalSourceViewer();
		styledText = isv.getTextWidget();
		drawSelection();
	} else {
		clear();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:EditorOverlay.java

示例8: CFGraph

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
/**
 * Constructor
 */
public CFGraph() {
	locFileProvider = new DefaultLocationInFileProvider();
	editor = EditorUtils.getActiveXtextEditor();
	styledText = editor.getInternalSourceViewer().getTextWidget();
	layoutDone = false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:CFGraph.java

示例9: execute

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
  if (xtextEditor != null && xtextEditor.getEditorInput() instanceof XtextReadonlyEditorInput) {
    return null;
  }
  return super.execute(event);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:9,代码来源:CheckValidateActionHandler.java

示例10: execute

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        final XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
        Optional<EPackage> ePackage = EditorHandlingUtils.determineEPackage(editor);
        Optional<EObjectAtOffsetHelper> eObjectAtOffsetHelper = ePackage
                .flatMap(InjectingFactoryRegistry.INSTANCE::getFactory)
                .map(f -> f.inject(EObjectAtOffsetHelper.class)).map(EObjectAtOffsetHelper.class::cast);
        if (!eObjectAtOffsetHelper.isPresent()) {
            throw new IllegalStateException("Unable to create required helper classes.");
        }

        if (editor != null) {
            final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
            EObject selectedEObject = editor.getDocument()
                    .priorityReadOnly(new IUnitOfWork<EObject, XtextResource>() {
                        @Override
                        public EObject exec(XtextResource resource) throws Exception {
                            return eObjectAtOffsetHelper.get().resolveElementAt(resource, selection.getOffset());
                        }
                    });
            startRename(selectedEObject, editor, editor.getShell());
        }
    } catch (OperationCanceledException e) {
        LOGGER.debug("Refactoring operation has been canceled.", e);
    } catch (Exception exc) {
        LOGGER.error("Error initializing refactoring", exc);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error initializing refactoring",
                exc.getMessage() + "\nSee log for details");
    }
    return null;
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:33,代码来源:RenameUMLElementRefactoringHandler.java

示例11: executeOnEditor

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
@Override
protected Object executeOnEditor(ExecutionEvent event) {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	if (window == null) {
		return null;
	}

	final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor == null) {
		return null;
	}

	FileEditorInput input = (FileEditorInput) xtextEditor.getEditorInput();
	final java.io.File fileOnDisk = input.getFile().getLocation().toFile();

	if (xtextEditor.isDirty()) {
		if (MessageDialog.openConfirm(window.getShell(), "Save and Run JLustre2Excel",
				"The file " + input.getName() + " has unsaved changes. Save file and continue?")) {
			xtextEditor.doSave(null);
		} else {
			return null;
		}
	}

	WorkspaceJob job = new WorkspaceJob("JLustre2Excel") {
		@Override
		public IStatus runInWorkspace(final IProgressMonitor monitor) {
			if (hasErrors(xtextEditor)) {
				return errorStatus("Lustre file contains errors");
			}
			if (hasFunctions(xtextEditor)) {
				return errorStatus("Functions are not support in JLustre2Excel");
			}
			return runJob(fileOnDisk);
		}
	};

	job.schedule();
	return null;
}
 
开发者ID:agacek,项目名称:jkind-xtext,代码行数:41,代码来源:RunJLustre2ExcelHandler.java

示例12: executeOnEditor

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
@Override
protected Object executeOnEditor(ExecutionEvent event) {
	window = HandlerUtil.getActiveWorkbenchWindow(event);
	if (window == null) {
		return null;
	}

	final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor == null) {
		return null;
	}

	FileEditorInput input = (FileEditorInput) xtextEditor.getEditorInput();
	final java.io.File fileOnDisk = input.getFile().getLocation().toFile();

	if (xtextEditor.isDirty()) {
		if (MessageDialog.openConfirm(window.getShell(), "Save and Run JKind", "The file "
				+ input.getName() + " has unsaved changes. Save file and continue?")) {
			xtextEditor.doSave(null);
		} else {
			return null;
		}
	}

	WorkspaceJob job = new WorkspaceJob("JKind Analysis") {
		@Override
		public IStatus runInWorkspace(final IProgressMonitor monitor) {
			activateTerminateHandler(monitor, this);
			JKindResult result = initializeJKindResult(xtextEditor);
			if (result == null) {
				return errorStatus("Lustre file contains errors");
			}
			return runJob(fileOnDisk, result, monitor);
		}
	};

	job.schedule();
	return null;
}
 
开发者ID:agacek,项目名称:jkind-xtext,代码行数:40,代码来源:RunJKindHandler.java

示例13: executeURI

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object executeURI(final URI uri) {
    final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
    if (xtextEditor == null) {
        return null;
    }

    if (!saveChanges(window.getActivePage().getDirtyEditors())) {
        return null;
    }

    WorkspaceJob job = new WorkspaceJob(getJobName()) {
        @Override
        public IStatus runInWorkspace(final IProgressMonitor monitor) {
            return xtextEditor.getDocument().readOnly(
                    new IUnitOfWork<IStatus, XtextResource>() {
                        @Override
                        public IStatus exec(XtextResource resource) throws Exception {
                            EObject eobj = resource.getResourceSet().getEObject(uri, true);
                            if (eobj instanceof Element) {
                                return runJob((Element) eobj, monitor);
                            } else {
                                return Status.CANCEL_STATUS;
                            }
                        }
                    });
        }
    };

    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.schedule();
    return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:33,代码来源:AadlHandler.java

示例14: executeURI

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object executeURI(final URI uri) {
	final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
	if (xtextEditor == null) {
		return null;
	}

	if (!saveChanges(window.getActivePage().getDirtyEditors())) {
		return null;
	}

	WorkspaceJob job = new WorkspaceJob(getJobName()) {
		@Override
		public IStatus runInWorkspace(final IProgressMonitor monitor) {
			return xtextEditor.getDocument().readOnly(new IUnitOfWork<IStatus, XtextResource>() {
				@Override
				public IStatus exec(XtextResource resource) throws Exception {
					EObject eobj = resource.getResourceSet().getEObject(uri, true);
					if (eobj instanceof Element) {
						return runJob((Element) eobj, monitor);
					} else {
						return Status.CANCEL_STATUS;
					}
				}
			});
		}
	};

	job.setRule(ResourcesPlugin.getWorkspace().getRoot());
	job.schedule();
	return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:32,代码来源:AadlHandler.java

示例15: executeURI

import org.eclipse.xtext.ui.editor.utils.EditorUtils; //导入方法依赖的package包/类
public Object executeURI(final URI uri) {
	final XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
	if (xtextEditor == null) {
		return null;
	}

	if (!saveChanges(window.getActivePage().getDirtyEditors())) {
		return null;
	}

	WorkspaceJob job = getWorkspaceJob(xtextEditor, uri);
	job.setRule(ResourcesPlugin.getWorkspace().getRoot());
	job.schedule();
	return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:16,代码来源:AadlHandler.java


注:本文中的org.eclipse.xtext.ui.editor.utils.EditorUtils.getActiveXtextEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。