use of org.erlide.wrangler.refactoring.selection.internal.ErlTextMemberSelection in project erlide_eclipse by erlang.
the class GlobalParameters method setEditor.
/**
* Stores the editor marked as 'current'
*
* @param _editor
* stored editor
*/
public static void setEditor(final IEditorPart _editor) {
GlobalParameters.editor = _editor;
GlobalParameters.wranglerSelection = new ErlTextMemberSelection((ITextEditor) GlobalParameters.editor);
}
use of org.erlide.wrangler.refactoring.selection.internal.ErlTextMemberSelection in project erlide_eclipse by erlang.
the class GlobalParameters method setSelection.
/**
* Stores a selection marked 'current'
*
* @param selection
* Erlang selection
*/
public static void setSelection(final ISelection selection) throws WranglerException {
// TODO:: if the module is selected it is not handled
try {
if (GlobalParameters.editor == null) {
final IWorkbench instance = PlatformUI.getWorkbench();
final IWorkbenchWindow activeWorkbenchWindow = instance.getActiveWorkbenchWindow();
GlobalParameters.editor = activeWorkbenchWindow.getActivePage().getActiveEditor();
}
if (selection instanceof ITextSelection) {
final IWorkbench instance = PlatformUI.getWorkbench();
final IWorkbenchWindow activeWorkbenchWindow = instance.getActiveWorkbenchWindow();
GlobalParameters.editor = activeWorkbenchWindow.getActivePage().getActiveEditor();
GlobalParameters.wranglerSelection = new ErlTextMemberSelection((ITextSelection) selection, (ITextEditor) GlobalParameters.editor);
} else if (selection instanceof ITreeSelection) {
final Object firstElement = ((ITreeSelection) selection).getFirstElement();
if (firstElement instanceof IErlElement) {
final IErlElement element = (IErlElement) firstElement;
final IFile file = (IFile) element.getResource();
GlobalParameters.wranglerSelection = new ErlMemberSelection(element, file, WranglerUtils.getDocument(file));
} else if (firstElement instanceof IFile) {
final IFile file = (IFile) firstElement;
final IErlModule module = ErlangEngine.getInstance().getModel().findModule(file);
GlobalParameters.wranglerSelection = new ErlModuleSelection(module, file);
} else {
GlobalParameters.wranglerSelection = null;
throw new WranglerException("Please select an Erlang element!");
}
} else {
GlobalParameters.wranglerSelection = null;
throw new WranglerException("Please select an Erlang element!");
}
} catch (final ClassCastException e) {
ErlLogger.error(e);
}
/*
* System.out.println(wranglerSelection.getStartLine() + "," +
* wranglerSelection.getStartCol() + ";" +
* wranglerSelection.getEndLine() + "," +
* wranglerSelection.getEndCol());
*/
}
Aggregations