Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2013 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
 
 package org.eclipse.xtext.ui.editor.copyqualifiedname;
 
import  org.eclipse.core.commands.ExecutionEvent;
import  org.eclipse.jface.viewers.ISelection;
import  org.eclipse.jface.viewers.IStructuredSelection;
import  org.eclipse.ui.handlers.HandlerUtil;

Author(s):
Anton Kosyakov - Initial contribution and API
Since:
2.4
	protected String getQualifiedName(ExecutionEvent event) {
		IOutlineNode outlineNode = getOutlineNode(event);
		if (outlineNode == null) {
			return null;
		}
		return outlineNode.readOnly(new IUnitOfWork<StringEObject>() {
			public String exec(EObject selectedElementthrows Exception {
				return getQualifiedName(selectedElement);
			}
		});
	}
	private IOutlineNode getOutlineNode(ExecutionEvent event) {
		ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
		if (!(currentSelection instanceof IStructuredSelection)) {
			return null;
		}
		IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
		return (IOutlineNodestructuredSelection.getFirstElement();
	}
New to GrepCode? Check out our FAQ X