Examples of CtxInsensitiveImportComplProposal


Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

        }

        mods.add(tuple);

        String tooltip = importDeclaration + "\n\nNote: Hold Ctrl on apply to do local import.";
        props.add(new CtxInsensitiveImportComplProposal("", offset, 0, 0, importImage, displayImport, null, tooltip,
                IPyCompletionProposal.PRIORITY_LOCALS, importDeclaration) {

            @Override
            public void selected(ITextViewer viewer, boolean smartToggle) {
                //Overridden to do nothing (i.e.: don't leave yellow when ctrl is pressed).
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

                                        //get the image and text for each completion

                                        @Override
                                        public Image getImage(Object element) {
                                            CtxInsensitiveImportComplProposal comp = ((CtxInsensitiveImportComplProposal) element);
                                            return comp.getImage();
                                        }

                                        @Override
                                        public String getText(Object element) {
                                            CtxInsensitiveImportComplProposal comp = ((CtxInsensitiveImportComplProposal) element);
                                            return comp.getDisplayString();
                                        }

                                    }) {

                                //override things to return the last position of the dialog correctly

                                /**
                                 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
                                 */
                                protected IDialogSettings getDialogBoundsSettings() {
                                    IDialogSettings section = dialogSettings.getSection(DIALOG_SETTINGS);
                                    if (section == null) {
                                        section = dialogSettings.addNewSection(DIALOG_SETTINGS);
                                    }
                                    return section;
                                }

                                /* (non-Javadoc)
                                 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
                                 */
                                protected Point getInitialSize() {
                                    IDialogSettings settings = getDialogBoundsSettings();
                                    if (settings != null) {
                                        try {
                                            int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$
                                            int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$
                                            if (width > 0 & height > 0) {
                                                return new Point(width, height);
                                            }
                                        } catch (NumberFormatException nfe) {
                                            //make the default return
                                        }
                                    }
                                    return new Point(300, 300);
                                }
                            };

                            dialog.setTitle("Choose import");
                            dialog.setMessage("Which import should be added?");
                            dialog.setElements(props.toArray());
                            int returnCode = dialog.open();
                            if (returnCode == Window.OK) {
                                ICompletionProposalExtension2 firstResult = (ICompletionProposalExtension2) dialog
                                        .getFirstResult();

                                completionsToApply.add(firstResult);
                            } else if (returnCode == Window.CANCEL) {
                                keepGoing[0] = false;
                                continue;
                            }

                        }
                    } catch (Exception e) {
                        Log.log(e);
                    }
                }

            } catch (Exception e) {
                Log.log(e);
            }
        }

        for (ICompletionProposalExtension2 comp : completionsToApply) {
            int offset = 0; //the offset is not used in this case, because the actual completion does nothing,
                            //we'll only add the import.
            comp.apply(edit.getPySourceViewer(), ' ', 0, offset);
        }

        return true;

    }
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

                displayString.append(declaringModuleName);
                if (hasInit) {
                    displayString.append(".__init__");
                }

                CtxInsensitiveImportComplProposal proposal = new CtxInsensitiveImportComplProposal(rep,
                        request.documentOffset - request.qlen, request.qlen, realImportRep.length(),
                        AnalysisPlugin.getImageForAutoImportTypeInfo(info), displayString.toString(),
                        (IContextInformation) null, "",
                        lowerRep.equals(lowerQual) ? IPyCompletionProposal.PRIORITY_LOCALS_1
                                : IPyCompletionProposal.PRIORITY_GLOBALS, realImportRep.toString());
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

                    if (addAutoImport) {
                        realImportRep.append("import ");
                        realImportRep.append(strings[1]);
                    }

                    CtxInsensitiveImportComplProposal proposal = new CtxInsensitiveImportComplProposal(importRep,
                            request.documentOffset - request.qlen, request.qlen, realImportRep.length(), img,
                            displayString.toString(), (IContextInformation) null, "",
                            lowerImportRep.equals(lowerQual) ? IPyCompletionProposal.PRIORITY_LOCALS_2
                                    : IPyCompletionProposal.PRIORITY_PACKAGES, realImportRep.toString());
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

        props = new ArrayList<ICompletionProposal>();
        participant.addProps(marker, prefs, line, ps, offset, nature, null, props);
        printProps(1, props);
        //appears with __init__
        assertContains("Import DTest (relative.rel1.__init__)", props);
        CtxInsensitiveImportComplProposal compl = (CtxInsensitiveImportComplProposal) props.get(0);

        //but applies without it
        assertEquals("from relative.rel1 import DTest", compl.realImportRep);

    }
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

            props = new ArrayList<ICompletionProposal>();
            participant.addProps(marker, prefs, line, ps, offset, nature, null, props);
            printProps(1, props);
            //appears with _
            assertContains("Import Priv3 (relative.rel1._priv1._priv2._priv3)", props);
            CtxInsensitiveImportComplProposal compl = (CtxInsensitiveImportComplProposal) props.get(0);

            //but applies without it
            assertEquals("from relative.rel1 import Priv3", compl.realImportRep);
        } finally {
            AutoImportsPreferencesPage.TESTS_DO_IGNORE_IMPORT_STARTING_WITH_UNDER = false;
View Full Code Here

Examples of com.python.pydev.analysis.CtxInsensitiveImportComplProposal

        props = new ArrayList<ICompletionProposal>();
        participant.addProps(marker, prefs, line, ps, offset, nature, null, props);
        printProps(1, props);
        //appears with _
        assertContains("Import NotPriv3 (relative.rel1._priv1._priv2.notpriv3)", props);
        CtxInsensitiveImportComplProposal compl = (CtxInsensitiveImportComplProposal) props.get(0);

        //but applies without it
        assertEquals("from relative.rel1._priv1._priv2.notpriv3 import NotPriv3", compl.realImportRep);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.