use of org.python.pydev.editor.actions.PyOpenAction in project Pydev by fabioz.
the class PyEdit method createActions.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
*
* TODO: Fix content assist to work in emacs mode:
* http://wiki.eclipse.org/index.php/FAQ_How_do_I_add_Content_Assist_to_my_editor%3F
* http://www.eclipse.org/newsportal/article.php?id=61744&group=eclipse.platform#61744
*/
@Override
protected void createActions() {
super.createActions();
try {
MyResources resources = new MyResources();
IAction action;
// Quick-Assist: it's added to the platform as of Eclipse 3.2, so, we do not have to put the binding here
// -------------------------------------------------------------------------------------
// This action will fire a CONTENTASSIST_PROPOSALS operation
// when executed
action = new ContentAssistAction(resources, "ContentAssistProposal.", this);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction("ContentAssistProposal", action);
markAsStateDependentAction("ContentAssistProposal", true);
// -------------------------------------------------------------------------------------
// open action
IAction openAction = new PyOpenAction();
setAction(ACTION_OPEN, openAction);
// -------------------------------------------------------------------------------------
// Offline action
action = new OfflineAction(resources, "Pyedit.ScriptEngine.", this);
action.setActionDefinitionId("org.python.pydev.editor.actions.scriptEngine");
action.setId("org.python.pydev.editor.actions.scriptEngine");
setAction("PyDevScriptEngine", action);
// move lines
if (this.getIndentPrefs().getSmartLineMove()) {
// Don't even bind the action if the smart line move is not set.
// This means 2 things:
// - Uses the default action when asked
// - An editor restart will be needed to have it applied
action = new PyMoveLineUpAction(resources, "Pyedit.MoveLinesUp.", this);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
action.setId("org.python.pydev.editor.actions.moveLineUp");
setAction(ITextEditorActionConstants.MOVE_LINE_UP, action);
action = new PyMoveLineDownAction(resources, "Pyedit.MoveLinesDown.", this);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
action.setId("org.python.pydev.editor.actions.moveLineDown");
setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action);
}
notifier.notifyOnCreateActions(resources);
onCreateActions.call(this);
} catch (Throwable e) {
Log.log(e);
}
}
use of org.python.pydev.editor.actions.PyOpenAction in project Pydev by fabioz.
the class HierarchyViewer method createPartControl.
public void createPartControl(Composite parent) {
this.fParent = parent;
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.verticalSpacing = 2;
layout.marginWidth = 0;
layout.marginHeight = 2;
parent.setLayout(layout);
sash = new SashForm(parent, SWT.VERTICAL);
GridData layoutData = new GridData();
layoutData.grabExcessHorizontalSpace = true;
layoutData.grabExcessVerticalSpace = true;
layoutData.horizontalAlignment = GridData.FILL;
layoutData.verticalAlignment = GridData.FILL;
sash.setLayoutData(layoutData);
parent = sash;
treeClassesViewer = new TreeViewer(parent);
treeClassesViewer.setContentProvider(new DataAndImageTreeNodeContentProvider());
treeClassesViewer.setLabelProvider(createLabelProvider());
treeClassesViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
ISelection selection = event.getSelection();
handleSelection(selection, 2);
}
});
treeClassesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
handleSelection(selection, 1);
}
});
treeMembers = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
treeMembers.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
TreeItem[] selection = treeMembers.getSelection();
if (selection.length > 0) {
Object data = selection[0].getData();
ItemPointer p = (ItemPointer) data;
if (p != null) {
new PyOpenAction().run(p);
}
}
}
});
}
use of org.python.pydev.editor.actions.PyOpenAction in project Pydev by fabioz.
the class PyGlobalsBrowser method doSelect.
/**
* @param pythonNatures the natures from were we can get info
* @param additionalInfo the additional informations
* @param selectedText the text that should be initially set as a filter
*/
public static void doSelect(List<IPythonNature> pythonNatures, List<AbstractAdditionalTokensInfo> additionalInfo, String selectedText) {
SelectionDialog dialog = GlobalsDialogFactory.create(EditorUtils.getShell(), additionalInfo, selectedText);
dialog.open();
Object[] result = dialog.getResult();
if (result != null && result.length > 0) {
for (Object obj : result) {
IInfo entry;
if (obj instanceof AdditionalInfoAndIInfo) {
AdditionalInfoAndIInfo additional = (AdditionalInfoAndIInfo) obj;
try {
// all of the input natures).
if (additional.additionalInfo instanceof AdditionalProjectInterpreterInfo) {
AdditionalProjectInterpreterInfo projectInterpreterInfo = (AdditionalProjectInterpreterInfo) additional.additionalInfo;
IProject project = projectInterpreterInfo.getProject();
PythonNature pythonNature = PythonNature.getPythonNature(project);
if (pythonNature != null) {
pythonNatures = new ArrayList<IPythonNature>();
pythonNatures.add(pythonNature);
}
} else if (additional.additionalInfo instanceof AdditionalSystemInterpreterInfo) {
AdditionalSystemInterpreterInfo systemInterpreterInfo = (AdditionalSystemInterpreterInfo) additional.additionalInfo;
SystemPythonNature pythonNature = new SystemPythonNature(systemInterpreterInfo.getManager());
pythonNatures = new ArrayList<IPythonNature>();
pythonNatures.add(pythonNature);
}
} catch (Throwable e) {
Log.log(e);
}
entry = additional.info;
} else {
entry = (IInfo) obj;
}
List<ItemPointer> pointers = new ArrayList<ItemPointer>();
ICompletionState completionCache = new CompletionState();
for (IPythonNature pythonNature : pythonNatures) {
// try to find in one of the natures...
ICodeCompletionASTManager astManager = pythonNature.getAstManager();
if (astManager == null) {
continue;
}
AnalysisPlugin.getDefinitionFromIInfo(pointers, astManager, pythonNature, entry, completionCache, false, true);
if (pointers.size() > 0) {
new PyOpenAction().run(pointers.get(0));
// don't check the other natures
break;
}
}
}
}
}
Aggregations