├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── builds.yml │ ├── codeql.yml │ ├── greetings.yml │ ├── label.yml │ └── maven.yml ├── .gitignore ├── LICENSE ├── README.md ├── _resources ├── 74a5dd8877b9608931b49604ab59440d.png ├── 74a5dd8877b9608931b49604ab59555d.png ├── b18df5a8d44631819affe75ecd6fab61.png ├── cad96c97900764698d62caf7d6bf49b4.png ├── d242d82a04c729be7c6e6b0b84759c2f.png ├── ebaed2b72b503dec7733d6698f3a0a72.png ├── f4ecdf1c9e7648113e8dd265b277366a.png └── f9b73732e9534000af91eb4e9bf11208.png ├── pom.xml ├── ppuc ├── 13 │ └── updates.xml ├── 14 │ └── updates.xml ├── 15 │ └── updates.xml ├── 16 │ └── updates.xml ├── 17 │ └── updates.xml ├── 18 │ └── updates.xml ├── 19 │ └── updates.xml ├── 20 │ └── updates.xml ├── 21 │ └── updates.xml ├── 22 │ └── updates.xml ├── 23 │ └── updates.xml ├── 24 │ └── updates.xml ├── 25 │ └── updates.xml └── 26 │ └── updates.xml └── src └── main ├── java └── org │ └── netbeans │ └── modules │ └── python │ ├── Installer.java │ ├── PythonCustomException.java │ ├── PythonDataObject.java │ ├── PythonLspClient.java │ ├── PythonNodes.java │ ├── PythonOutputLine.java │ ├── PythonPathRecognizer.java │ ├── PythonPrivilegedTemplates.java │ ├── PythonPropertiesNotifier.java │ ├── PythonSharabilityQuery.java │ ├── PythonSources.java │ ├── PythonUtility.java │ ├── UpdateHandler.java │ ├── actions │ ├── PythonBuild.java │ ├── PythonCleanVEnvAction.java │ ├── PythonCreateVEnvAction.java │ ├── PythonDocGenerator.java │ ├── PythonFixIndentAction.java │ ├── PythonGenerateTest.java │ ├── PythonPlatformAction.java │ ├── PythonPylintScoreEnabler.java │ ├── PythonRun.java │ ├── PythonRunAction.java │ ├── PythonRunSelectionAction.java │ ├── PythonVEnvConsoleAction.java │ └── PythonVEnvMenuAction.java │ ├── coverage │ ├── PythonCodeCoverageProvider.java │ └── PythonCoverageMenuAction.java │ ├── debugger │ ├── DebuggerAnnotation.java │ ├── DebuggerBreakpointAnnotation.java │ ├── PythonDebugger.java │ ├── PythonDebuggerActionsProvider.java │ ├── PythonDebuggerCallStack.java │ ├── PythonDebuggerName.java │ ├── PythonDebuggerProvider.java │ ├── PythonDebuggerSessionListener.java │ ├── PythonDebuggerSessionProvider.java │ ├── PythonDebuggerToolTip.java │ ├── PythonDebuggerUtils.java │ ├── attach │ │ ├── Processes.java │ │ ├── PythonDebuggerAttachCustomizer.form │ │ ├── PythonDebuggerAttachCustomizer.java │ │ └── PythonDebuggerAttachType.java │ ├── breakpoints │ │ ├── BreakpointAnnotationProvider.java │ │ ├── BreakpointNodeActionsProvider.java │ │ ├── BreakpointsReader.java │ │ ├── ControllerProvider.java │ │ ├── PersistenceManager.java │ │ ├── PythonBreakpoint.java │ │ ├── PythonBreakpointActionProvider.java │ │ ├── PythonBreakpointBeanInfo.java │ │ ├── PythonBreakpointCustomizer.java │ │ ├── PythonBreakpointCustomizerPanel.form │ │ ├── PythonBreakpointCustomizerPanel.java │ │ └── PythonBreakpointType.java │ ├── models │ │ ├── PythonDebuggerBreakpointModel.java │ │ ├── PythonDebuggerBreakpointsListener.java │ │ ├── PythonDebuggerCallStackModel.java │ │ └── PythonDebuggerSession.java │ ├── pdb │ │ ├── DAPClient.java │ │ └── PdbClient.java │ └── views │ │ └── PythonDebugEngineComponentsProvider.java │ ├── editor │ ├── PythonEditorKit.java │ ├── PythonGsfDocument.java │ ├── PythonReformatTask.java │ ├── PythonReformatTaskFactory.java │ ├── PythonTemplateCompletion.java │ ├── PythonTypedTextFactory.java │ └── PythonTypedTextInterceptor.java │ ├── indexing │ ├── PythonCustomIndexer.java │ ├── PythonCustomIndexerFactory.java │ ├── PythonDefaultError.java │ ├── PythonErrorAnnotator.java │ ├── PythonErrorConvertor.java │ └── PythonIndexQuery.java │ ├── log │ ├── LogViewerSupport.java │ └── PythonLspLog.java │ ├── options │ ├── PythonLspServerConfigsOptionsPanelController.java │ ├── PythonLspServerConfigsPanel.form │ ├── PythonLspServerConfigsPanel.java │ ├── PythonPackageRepoRenderer.java │ ├── PythonPackageRepositoryOptionsPanelController.java │ ├── PythonPackageRepositoryPanel.form │ ├── PythonPackageRepositoryPanel.java │ ├── PythonPackagesListRenderer.java │ ├── PythonPlatformListRenderer.java │ ├── PythonPlatformManager.java │ ├── PythonPlatformOptionsPanelController.java │ ├── PythonPlatformPanel.form │ └── PythonPlatformPanel.java │ ├── package-info.java │ ├── packagemanager │ ├── PythonDataProvider.java │ ├── PythonHeaderRenderer.java │ ├── PythonPackageManagerTopComponent.form │ ├── PythonPackageManagerTopComponent.java │ ├── PythonPackagesModel.java │ ├── PythonRootTreeNode.java │ ├── PythonRowModel.java │ └── PythonTreeWillExpand.java │ ├── poetry │ ├── PythonPoetryInit.java │ ├── PythonPoetryInstall.java │ ├── PythonPoetryMenuAction.java │ ├── PythonPoetryRunScript.java │ ├── PythonPoetryShell.java │ └── PythonPoetryShow.java │ ├── project │ ├── PythonProject.java │ ├── PythonProjectFactory.java │ ├── PythonProjectOpenedHook.java │ ├── PythonProjectProblemProvider.java │ └── PythonProjectStateHandler.java │ ├── projectproperties │ ├── PythonBuildPanel.form │ ├── PythonBuildPanel.java │ ├── PythonBuildProperties.java │ ├── PythonCustomizerProvider.java │ ├── PythonFrameworkCellRenderer.java │ ├── PythonGeneralPanel.form │ ├── PythonGeneralPanel.java │ ├── PythonGeneralProperties.java │ ├── PythonPdocPanel.form │ ├── PythonPdocPanel.java │ ├── PythonPdocProperties.java │ ├── PythonPlatformCellRenderer.java │ ├── PythonRunPanel.form │ ├── PythonRunPanel.java │ ├── PythonRunProperties.java │ ├── PythonTestPanel.form │ ├── PythonTestPanel.java │ └── PythonTestProperties.java │ ├── projectsample │ ├── PythonExtSourceProjectPanelVisual.form │ ├── PythonExtSourceProjectPanelVisual.java │ ├── PythonExtSourceProjectWizardIterator.java │ ├── PythonExtSourceProjectWizardPanel.java │ ├── PythonPoetryPanelVisual.form │ ├── PythonPoetryPanelVisual.java │ ├── PythonPoetryWizardIterator.java │ ├── PythonPoetryWizardPanel.java │ ├── PythonProjectPanelVisual.form │ ├── PythonProjectPanelVisual.java │ ├── PythonProjectWizardIterator.java │ └── PythonProjectWizardPanel.java │ ├── repl │ ├── IPythonTopComponent.form │ ├── IPythonTopComponent.java │ ├── PtPythonTopComponent.form │ ├── PtPythonTopComponent.java │ ├── PythonTerminalConnector.java │ ├── PythonVEnvConsoleActionTopComponent.form │ └── PythonVEnvConsoleActionTopComponent.java │ ├── source │ ├── PythonPylintScoreBar.form │ ├── PythonPylintScoreBar.java │ ├── PythonSymbolProvider.java │ └── PythonTypeProvider.java │ ├── statusbar │ ├── PythonStatusBar.java │ ├── PythonStatusBarPanel.form │ └── PythonStatusBarPanel.java │ ├── tasklist │ ├── PythonActionItems.java │ └── PythonDiagCollector.java │ └── testrunner │ ├── PythonPingyinTestCreator.java │ ├── PythonPyTestCreator.java │ ├── PythonTemplateAttributesProvider.java │ ├── PythonTestCase.java │ ├── PythonTestCreator.java │ ├── PythonTestCreatorConfiguration.java │ ├── PythonTestCreatorUtility.java │ ├── PythonTestGlyphAction.java │ ├── PythonTestLocator.java │ ├── PythonTestManager.java │ ├── PythonTestMethodAnnotation.java │ ├── PythonTestMethodController.java │ ├── PythonTestNodeFactory.java │ ├── PythonTestParser.java │ ├── PythonTestParserTask.java │ ├── PythonTestResultsTopComponent.form │ ├── PythonTestResultsTopComponent.java │ ├── PythonTestRunner.java │ ├── PythonTestSuite.java │ ├── PythonTestTaskFactory.java │ ├── PythonUnitTestCreator.java │ └── PythonUnitTestRunner.java ├── nbm └── manifest.mf └── resources ├── META-INF └── debugger │ └── PYthonSession │ ├── org.netbeans.modules.python.debugger.PythonDebugger │ └── org.netbeans.spi.debugger.DebuggerEngineProvider └── org └── netbeans └── modules └── python ├── Bundle.properties ├── Classes.png ├── EmptyPython.py ├── FontAndColors.xml ├── MagicPython.tmLanguage.json ├── Python.py ├── PythonDescription.html ├── PythonPyTestDescription.html ├── PythonPytest.py ├── PythonUnitTestDescription.html ├── PythonUnittest.py ├── Pythontemplates.xml ├── config-badge.gif ├── debugger ├── Breakpoint.png ├── Bundle.properties ├── CurrentPC2.xml ├── CurrentPC2LinePart.xml ├── CurrentPC2_BP.xml ├── CurrentPC2_DBP.xml ├── CurrentPCLinePart.xml ├── DisabledBreakpoint.png ├── PC.gif ├── attach │ └── Bundle.properties ├── breakpoints │ └── Bundle.properties └── restart24.png ├── envs.json ├── error-badge.png ├── find16.png ├── find16.svg ├── indexing └── Bundle.properties ├── ipython.png ├── layer.xml ├── libraries.png ├── methodPublic.png ├── nb_test_runner.py ├── options └── Bundle.properties ├── package.png ├── package16.png ├── packagemanager └── Bundle.properties ├── passed.png ├── pip.png ├── platforms.json ├── poetry.png ├── project └── Bundle.properties ├── projectproperties └── Bundle.properties ├── projectsample ├── Bundle.properties ├── PythonExtSourceProjectDescription.html ├── PythonPoetryDescription.html ├── PythonProjectDescription.html ├── PythonProjectProject.zip └── pyproject.toml ├── pynguin.png ├── pytest.png ├── python-2.png ├── python-runnable-test-annotation.xml ├── python32.png ├── repos.json ├── restart.png ├── run.gif ├── schema.json ├── settings.json ├── settings.png ├── source └── Bundle.properties ├── statusbar └── Bundle.properties ├── term.png ├── test-error_16.png ├── toml_handler.py └── warning.svg /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: albilu 4 | #patreon: # Replace with a single Patreon username 5 | #open_collective: # Replace with a single Open Collective username 6 | #ko_fi: # Replace with a single Ko-fi username 7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | #liberapay: # Replace with a single Liberapay username 10 | #issuehunt: # Replace with a single IssueHunt username 11 | #otechie: # Replace with a single Otechie username 12 | #lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: albilu 7 | 8 | --- 9 | 10 | **Description** 11 | A clear and concise description of what the bug is. 12 | 13 | **Steps to reproduce the behavior:** 14 | 1. Go to '...' 15 | 2. Click on '....' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Desktop (please complete the following information):** 26 | - OS: [e.g. iOS] 27 | - JDK Version [e.g. 22] 28 | - Python version [e.g. 3.11.8] 29 | - Netbeans Version: [e.g. 22] 30 | - Python Plugin Version: [e.g. 22] 31 | 32 | **Mandatory Logs** 33 | Add any other context about the problem here. 34 | [e.g. Netbeans stacktrace/logs: (View-> IDE Log)] 35 | [e.g. LSP Server logs ${netbeans_userdir}/.pythonlsp/lsp_log_file] 36 | /!\: (this log is cleaned at Netbeans exit) 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea/improvment for this project 4 | title: '' 5 | labels: enhancement, feature-request 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "maven" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "monthly" 12 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "master" ] 20 | 21 | jobs: 22 | analyze: 23 | name: Analyze 24 | runs-on: ubuntu-latest 25 | permissions: 26 | actions: read 27 | contents: read 28 | security-events: write 29 | 30 | strategy: 31 | fail-fast: false 32 | matrix: 33 | language: [ 'java' ] 34 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 35 | # Use only 'java' to analyze code written in Java, Kotlin or both 36 | # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | 56 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). 57 | # If this step fails, then you should remove it and run the build manually (see below) 58 | - name: Autobuild 59 | uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | with: 74 | category: "/language:${{matrix.language}}" 75 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request_target, issues] 4 | 5 | jobs: 6 | greeting: 7 | runs-on: ubuntu-latest 8 | permissions: 9 | issues: write 10 | pull-requests: write 11 | steps: 12 | - uses: actions/first-interaction@v1 13 | with: 14 | repo-token: ${{ secrets.GITHUB_TOKEN }} 15 | issue-message: "Thanks for reporting this issue, we will take a look on ASAP" 16 | pr-message: "Thanks for your contribution and helping move this project forward" 17 | -------------------------------------------------------------------------------- /.github/workflows/label.yml: -------------------------------------------------------------------------------- 1 | # This workflow will triage pull requests and apply a label based on the 2 | # paths that are modified in the pull request. 3 | # 4 | # To use this workflow, you will need to set up a .github/labeler.yml 5 | # file with configuration. For more information, see: 6 | # https://github.com/actions/labeler 7 | 8 | name: Labeler 9 | on: [pull_request_target] 10 | 11 | jobs: 12 | label: 13 | 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: read 17 | pull-requests: write 18 | 19 | steps: 20 | - uses: actions/labeler@v4 21 | with: 22 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.tar.gz 19 | *.rar 20 | 21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 22 | hs_err_pid* 23 | /pom.xml.versionsBackup 24 | /nb-configuration.xml 25 | /nbactions.xml 26 | -------------------------------------------------------------------------------- /_resources/74a5dd8877b9608931b49604ab59440d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/74a5dd8877b9608931b49604ab59440d.png -------------------------------------------------------------------------------- /_resources/74a5dd8877b9608931b49604ab59555d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/74a5dd8877b9608931b49604ab59555d.png -------------------------------------------------------------------------------- /_resources/b18df5a8d44631819affe75ecd6fab61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/b18df5a8d44631819affe75ecd6fab61.png -------------------------------------------------------------------------------- /_resources/cad96c97900764698d62caf7d6bf49b4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/cad96c97900764698d62caf7d6bf49b4.png -------------------------------------------------------------------------------- /_resources/d242d82a04c729be7c6e6b0b84759c2f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/d242d82a04c729be7c6e6b0b84759c2f.png -------------------------------------------------------------------------------- /_resources/ebaed2b72b503dec7733d6698f3a0a72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/ebaed2b72b503dec7733d6698f3a0a72.png -------------------------------------------------------------------------------- /_resources/f4ecdf1c9e7648113e8dd265b277366a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/f4ecdf1c9e7648113e8dd265b277366a.png -------------------------------------------------------------------------------- /_resources/f9b73732e9534000af91eb4e9bf11208.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/_resources/f9b73732e9534000af91eb4e9bf11208.png -------------------------------------------------------------------------------- /ppuc/13/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/14/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/15/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/16/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/17/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/18/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/19/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/20/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/21/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/22/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/23/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/24/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/25/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ppuc/26/updates.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/Installer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import kong.unirest.Unirest; 6 | import org.openide.awt.CheckForUpdatesProvider; 7 | import org.openide.modules.ModuleInstall; 8 | import org.openide.util.Exceptions; 9 | import org.openide.util.Lookup; 10 | import org.openide.util.NbBundle; 11 | import org.openide.util.NbPreferences; 12 | import org.openide.util.RequestProcessor; 13 | 14 | @NbBundle.Messages("CTL_InstallError=Error while installing dependencies!") 15 | public class Installer extends ModuleInstall { 16 | 17 | private static final long serialVersionUID = 1L; 18 | RequestProcessor requestProcessor = new RequestProcessor(this.getClass() 19 | .getName(), 1 20 | ); 21 | 22 | ////TODO 23 | //clean testrunner 24 | //clean ressources 25 | //clean projectproperties 26 | @Override 27 | public void restored() { 28 | Unirest.config().cacheResponses(true); 29 | if (NbPreferences.root().getBoolean("autoUpdate", true)) { 30 | requestProcessor.post(() -> { 31 | if (PythonUtility.installLsp(this.getClass().getClassLoader()) != 0) { 32 | throw new PythonCustomException(Bundle.CTL_InstallError()); 33 | } 34 | }); 35 | } 36 | UpdateHandler.addUC(); 37 | CheckForUpdatesProvider checkForUpdatesProvider = Lookup.getDefault().lookup(CheckForUpdatesProvider.class); 38 | checkForUpdatesProvider.notifyAvailableUpdates(true); 39 | } 40 | 41 | @Override 42 | public void close() { 43 | if (super.closing()) { 44 | try { 45 | Files.deleteIfExists(PythonUtility.PYLSP_VENV_DIR.toPath().resolve("lsp_log_file")); 46 | } catch (IOException ex) { 47 | Exceptions.printStackTrace(ex); 48 | } 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonCustomException.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | public class PythonCustomException extends RuntimeException { 8 | 9 | public PythonCustomException(String string) { 10 | super(string); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonLspClient.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | /** 4 | * 5 | */ 6 | import java.io.IOException; 7 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 8 | import org.netbeans.modules.lsp.client.spi.LanguageServerProvider; 9 | import org.openide.util.Exceptions; 10 | import org.openide.util.Lookup; 11 | 12 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, 13 | service = LanguageServerProvider.class) 14 | public class PythonLspClient implements LanguageServerProvider { 15 | 16 | @Override 17 | public LanguageServerDescription startServer(Lookup lkp) { 18 | try { 19 | Process p = new ProcessBuilder( 20 | PythonUtility.getLspPythonExe(), 21 | "-m", 22 | "pylsp", 23 | "--verbose", 24 | "--log-file", 25 | PythonUtility.PYLSP_VENV_DIR.toPath().resolve("lsp_log_file").toString() 26 | //, 27 | //"-v" 28 | ) 29 | .redirectError(ProcessBuilder.Redirect.INHERIT) 30 | .start(); 31 | return LanguageServerDescription.create(p.getInputStream(), 32 | p.getOutputStream(), p 33 | ); 34 | } catch (IOException ex) { 35 | Exceptions.printStackTrace(ex); 36 | return null; 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonOutputLine.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.util.Collections; 4 | import org.netbeans.api.extexecution.ExecutionDescriptor; 5 | import org.netbeans.api.extexecution.print.ConvertedLine; 6 | import org.netbeans.api.extexecution.print.LineConvertor; 7 | import org.netbeans.api.extexecution.print.LineConvertors; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonOutputLine implements ExecutionDescriptor.LineConvertorFactory { 14 | 15 | static LineConvertor LINE_CONVERTOR = (String line) -> { 16 | PythonUtility.noModuleInstalledHandler(line); 17 | return Collections.singletonList(ConvertedLine.forText(line, null)); 18 | }; 19 | 20 | @Override 21 | public LineConvertor newLineConvertor() { 22 | 23 | return LineConvertors.proxy( 24 | PythonUtility.HTTP_CONVERTOR, 25 | PythonUtility.FILE_CONVERTOR, 26 | LINE_CONVERTOR 27 | ); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonPathRecognizer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | import org.netbeans.api.java.classpath.ClassPath; 8 | import org.netbeans.modules.parsing.spi.indexing.PathRecognizer; 9 | //import org.openide.util.lookup.ServiceProvider; 10 | 11 | /** 12 | * 13 | * @author albilu 14 | */ 15 | //@ServiceProvider(service = PathRecognizer.class) 16 | public class PythonPathRecognizer extends PathRecognizer { 17 | 18 | @Override 19 | public Set getSourcePathIds() { 20 | return Collections.singleton(ClassPath.SOURCE); 21 | } 22 | 23 | @Override 24 | public Set getLibraryPathIds() { 25 | return Collections.emptySet(); 26 | } 27 | 28 | @Override 29 | public Set getBinaryLibraryPathIds() { 30 | return Collections.emptySet(); 31 | } 32 | 33 | @Override 34 | public Set getMimeTypes() { 35 | return new HashSet<>(Arrays.asList(PythonUtility.PYTHON_MIME_TYPE)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonPrivilegedTemplates.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import org.netbeans.spi.project.ui.PrivilegedTemplates; 4 | import org.netbeans.spi.project.ui.RecommendedTemplates; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonPrivilegedTemplates implements RecommendedTemplates, PrivilegedTemplates { 11 | 12 | private static final String[] RECOMMENDED_TYPES = new String[]{ 13 | "Python", 14 | "simple-files" 15 | }; 16 | 17 | private static final String[] PRIVILEGED_NAMES = { 18 | "Templates/Python/Python.py", 19 | "Templates/Python/EmptyPython.py", 20 | "Templates/Python/PythonUnittest.py", 21 | "Templates/Python/PythonPytest.py", 22 | "simple-files" 23 | }; 24 | 25 | @Override 26 | public String[] getPrivilegedTemplates() { 27 | return PRIVILEGED_NAMES; 28 | } 29 | 30 | @Override 31 | public String[] getRecommendedTypes() { 32 | return RECOMMENDED_TYPES; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonPropertiesNotifier.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import javax.swing.event.ChangeListener; 8 | import org.openide.util.ChangeSupport; 9 | 10 | public class PythonPropertiesNotifier { 11 | 12 | private static final ChangeSupport cs = new ChangeSupport(PythonPropertiesNotifier.class); 13 | 14 | public static void addChangeListener(ChangeListener listener) { 15 | cs.addChangeListener(listener); 16 | } 17 | 18 | public static void removeChangeListener(ChangeListener listener) { 19 | cs.removeChangeListener(listener); 20 | } 21 | 22 | public static void firePropertiesChange() { 23 | cs.fireChange(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonSharabilityQuery.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.net.URI; 4 | import org.apache.commons.lang3.StringUtils; 5 | import org.netbeans.api.queries.SharabilityQuery; 6 | import org.netbeans.spi.queries.SharabilityQueryImplementation2; 7 | 8 | /** 9 | * 10 | * @author albilu 11 | */ 12 | public class PythonSharabilityQuery implements SharabilityQueryImplementation2 { 13 | 14 | @Override 15 | public SharabilityQuery.Sharability getSharability(URI uri) { 16 | if (StringUtils.endsWithAny(uri.toString().replaceFirst("/$", ""), PythonUtility.EXCLUDED_DIRS) 17 | || uri.toString().endsWith("-project.properties")) { 18 | return SharabilityQuery.Sharability.NOT_SHARABLE; 19 | } else { 20 | return SharabilityQuery.Sharability.UNKNOWN; 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/PythonSources.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.Properties; 6 | import javax.swing.event.ChangeListener; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.netbeans.api.project.Project; 9 | import org.netbeans.api.project.ProjectInformation; 10 | import org.netbeans.api.project.ProjectUtils; 11 | import org.netbeans.api.project.SourceGroup; 12 | import org.netbeans.api.project.Sources; 13 | import org.netbeans.api.project.ui.OpenProjects; 14 | import org.netbeans.spi.project.support.GenericSources; 15 | import org.openide.filesystems.FileObject; 16 | import org.openide.filesystems.FileUtil; 17 | import org.openide.util.ChangeSupport; 18 | import org.openide.util.Exceptions; 19 | 20 | /** 21 | * 22 | * @author albilu 23 | */ 24 | public class PythonSources implements Sources { 25 | 26 | Project project; 27 | 28 | public PythonSources(Project project) { 29 | this.project = project; 30 | } 31 | 32 | private final ChangeSupport changeSupport = new ChangeSupport(this); 33 | 34 | @Override 35 | public SourceGroup[] getSourceGroups(String type) { 36 | if (Sources.TYPE_GENERIC.equals(type)) { 37 | ProjectInformation information = ProjectUtils.getInformation(project); 38 | return new SourceGroup[]{GenericSources.group(project, project.getProjectDirectory(), 39 | information.getName(), information.getDisplayName(), information.getIcon(), 40 | null 41 | )}; 42 | } 43 | if ("testsources".equals(type)) { 44 | if (!OpenProjects.getDefault().isProjectOpen(project)) { 45 | return new SourceGroup[0]; 46 | } 47 | try { 48 | Properties prop = PythonUtility.getProperties(project, false); 49 | String tfo = prop.getProperty("nbproject.test.dir", "tests"); 50 | ProjectInformation information = ProjectUtils.getInformation(project); 51 | FileObject fo = StringUtils.equalsAny(tfo, "", "tests") ? project.getProjectDirectory() 52 | .getFileObject("tests") : FileUtil.toFileObject(new File(tfo)); 53 | 54 | return fo == null ? new SourceGroup[0] : new SourceGroup[]{GenericSources.group(project, fo, 55 | "Tests", "Tests", information.getIcon(), 56 | null 57 | )}; 58 | } catch (IOException ex) { 59 | Exceptions.printStackTrace(ex); 60 | } 61 | 62 | } 63 | return new SourceGroup[0]; 64 | } 65 | 66 | @Override 67 | public void addChangeListener(ChangeListener listener) { 68 | changeSupport.addChangeListener(listener); 69 | } 70 | 71 | @Override 72 | public void removeChangeListener(ChangeListener listener) { 73 | changeSupport.removeChangeListener(listener); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/UpdateHandler.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python; 2 | 3 | import java.net.MalformedURLException; 4 | import java.net.URL; 5 | import java.util.regex.Matcher; 6 | import java.util.regex.Pattern; 7 | import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; 8 | import org.openide.util.Exceptions; 9 | 10 | /** 11 | * 12 | * @author albilu 13 | */ 14 | public class UpdateHandler { 15 | 16 | static final Pattern NB_VERSION = Pattern.compile("\\s+(\\d+)"); 17 | 18 | public static void addUC() { 19 | 20 | String version = getVersion(); 21 | if (version == null) { 22 | return; 23 | } 24 | 25 | String url = "https://raw.githubusercontent.com/albilu/netbeansPython/master/ppuc/" 26 | + version + "/updates.xml"; 27 | 28 | try { 29 | UpdateUnitProviderFactory.getDefault() 30 | .create("netbeansPythonUC", "netbeansPython Update Center", new URL(url)); 31 | } catch (MalformedURLException ex) { 32 | Exceptions.printStackTrace(ex); 33 | } 34 | 35 | } 36 | 37 | public static String getVersion() { 38 | String netbeansProductVersion = System.getProperty("netbeans.productversion"); 39 | Matcher matcher = NB_VERSION.matcher(netbeansProductVersion); 40 | if (matcher.find()) { 41 | return matcher.group(1); 42 | } 43 | return null; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonDocGenerator.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.io.IOException; 6 | import java.nio.file.Paths; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | import java.util.Properties; 11 | import java.util.logging.Logger; 12 | import org.netbeans.api.extexecution.ExecutionService; 13 | import org.netbeans.api.project.Project; 14 | import org.netbeans.modules.python.PythonOutputLine; 15 | import org.netbeans.modules.python.PythonUtility; 16 | import org.openide.LifecycleManager; 17 | import org.openide.awt.ActionID; 18 | import org.openide.awt.ActionRegistration; 19 | import org.openide.awt.StatusDisplayer; 20 | import org.openide.filesystems.FileUtil; 21 | import org.openide.util.Exceptions; 22 | import org.openide.util.NbBundle.Messages; 23 | 24 | @ActionID( 25 | category = "Project", 26 | id = "org.netbeans.modules.python.actions.PythonDocGenerator" 27 | ) 28 | @ActionRegistration( 29 | displayName = "#CTL_PythonDocGenerator" 30 | ) 31 | @Messages({ 32 | "CTL_PythonDocGenerator=Pdoc Generator", 33 | "CTL_PythonDocMessage=Generating Documentation" 34 | }) 35 | public final class PythonDocGenerator implements ActionListener { 36 | 37 | public static final Logger LOG = Logger.getLogger(PythonDocGenerator.class.getName()); 38 | private final Project context; 39 | 40 | public PythonDocGenerator(Project context) { 41 | this.context = context; 42 | } 43 | 44 | @Override 45 | public void actionPerformed(ActionEvent ev) { 46 | 47 | ProcessBuilder pb = new ProcessBuilder(); 48 | pb.directory(FileUtil.toFile(context.getProjectDirectory())); 49 | PythonUtility.manageRunEnvs(pb); 50 | 51 | try { 52 | String[] params = {}; 53 | List argList = new ArrayList<>(); 54 | Properties prop = PythonUtility.getProperties(context, false); 55 | params = PythonUtility.getParamsTokenizer().reset( 56 | prop.getProperty("nbproject.pdoc.params", "-o docs") 57 | ).getTokenArray(); 58 | List asList1 = null; 59 | 60 | asList1 = Arrays.asList(/*osShell[1],*/PythonUtility.getLspPythonExe(), 61 | "-m", "pdoc", Paths.get(context.getProjectDirectory().getPath()).toString()); 62 | argList.addAll(asList1); 63 | argList.addAll(Arrays.asList(params)); 64 | pb.command(argList); 65 | 66 | LOG.info(() -> Arrays.toString(argList.toArray())); 67 | } catch (IOException ex) { 68 | Exceptions.printStackTrace(ex); 69 | } 70 | 71 | ExecutionService service = ExecutionService.newService(() -> pb.start(), 72 | PythonUtility.getExecutorDescriptor( 73 | new PythonOutputLine(), () -> { 74 | StatusDisplayer.getDefault().setStatusText(Bundle.CTL_PythonDocMessage()); 75 | LifecycleManager.getDefault().saveAll(); 76 | }, () -> { 77 | }, true, true), String.format("%s%s%s", "Pdoc (", context.getProjectDirectory().getName(), ")")); 78 | 79 | service.run(); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonFixIndentAction.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.util.Stack; 6 | import javax.swing.text.BadLocationException; 7 | import javax.swing.text.StyledDocument; 8 | import org.openide.awt.ActionID; 9 | import org.openide.awt.ActionReference; 10 | import org.openide.awt.ActionRegistration; 11 | import org.openide.cookies.EditorCookie; 12 | import org.openide.text.NbDocument; 13 | import org.openide.util.Exceptions; 14 | import org.openide.util.NbBundle.Messages; 15 | 16 | @ActionID( 17 | category = "Edit", 18 | id = "org.netbeans.modules.python.actions.FixIndentAction" 19 | ) 20 | @ActionRegistration( 21 | displayName = "#CTL_FixIndentAction" 22 | ) 23 | @ActionReference(path = "Editors/text/x-python/Popup", position = 595) 24 | @Messages("CTL_FixIndentAction=Fix Indentation") 25 | public final class PythonFixIndentAction implements ActionListener { 26 | 27 | private final EditorCookie context; 28 | 29 | public PythonFixIndentAction(EditorCookie context) { 30 | this.context = context; 31 | } 32 | 33 | @Override 34 | public void actionPerformed(ActionEvent ev) { 35 | StyledDocument doc = context.getDocument(); 36 | int endOffset = doc.getEndPosition().getOffset(); 37 | NbDocument.runAtomic(doc, () -> { 38 | try { 39 | String fixIndentation = fixIndentation(doc.getText(0, endOffset)); 40 | doc.remove(0, endOffset - 1); 41 | doc.insertString(0, fixIndentation, null); 42 | } catch (BadLocationException ex) { 43 | Exceptions.printStackTrace(ex); 44 | } 45 | 46 | }); 47 | } 48 | 49 | //Code generated by chatGPT:) 50 | public static String fixIndentation(String pythonCode) { 51 | Stack indentStack = new Stack<>(); 52 | String[] lines = pythonCode.split("\n"); 53 | StringBuilder fixedCode = new StringBuilder(); 54 | int previousIndent = 0; 55 | for (String line : lines) { 56 | int currentIndent = line.length() - line.replaceAll("^[\t ]*", "").length(); 57 | // check if the current line has less indentation than the previous line 58 | if (currentIndent < previousIndent) { 59 | // if so, pop the indentation stack until the current indentation level is found 60 | while (indentStack.size() > 0 && currentIndent < indentStack.peek()) { 61 | indentStack.pop(); 62 | //fixedCode.append("\n"); 63 | } 64 | } 65 | // add the appropriate number of tabs or spaces to the fixed code 66 | for (int i = 0; i < indentStack.size(); i++) { 67 | fixedCode.append(" "); 68 | } 69 | // add the current line to the fixed code, with leading whitespace removed 70 | fixedCode.append(line.replaceAll("^[\t ]*", "") + "\n"); 71 | // if the current line ends with a colon, add the next indentation level to the stack 72 | if (line.endsWith(":")) { 73 | indentStack.push(currentIndent + 4); 74 | } 75 | previousIndent = currentIndent; 76 | } 77 | return fixedCode.toString(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonPlatformAction.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import org.netbeans.api.options.OptionsDisplayer; 6 | import org.openide.awt.ActionID; 7 | import org.openide.awt.ActionReference; 8 | import org.openide.awt.ActionRegistration; 9 | import org.openide.util.NbBundle.Messages; 10 | 11 | @ActionID( 12 | category = "Tools", 13 | id = "org.netbeans.modules.python.actions.PythonPlatformAction" 14 | ) 15 | @ActionRegistration( 16 | displayName = "#CTL_PythonPlatformAction" 17 | ) 18 | @ActionReference(path = "Menu/Tools", position = 250) 19 | 20 | @Messages("CTL_PythonPlatformAction=Python Platforms") 21 | public final class PythonPlatformAction implements ActionListener { 22 | 23 | @Override 24 | public void actionPerformed(ActionEvent e) { 25 | OptionsDisplayer.getDefault().open("PythonOptions/PyPlatform"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonPylintScoreEnabler.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import javax.swing.text.JTextComponent; 6 | import org.netbeans.api.editor.EditorRegistry; 7 | import org.netbeans.modules.python.source.PythonPylintScoreBar; 8 | import org.openide.awt.ActionID; 9 | import org.openide.awt.ActionReference; 10 | import org.openide.awt.ActionRegistration; 11 | import org.openide.cookies.EditorCookie; 12 | import org.openide.util.NbBundle.Messages; 13 | 14 | @ActionID( 15 | category = "Edit", 16 | id = "org.netbeans.modules.python.actions.PythonPylintScoreEnabler" 17 | ) 18 | @ActionRegistration( 19 | displayName = "#CTL_PylintScore" 20 | ) 21 | @ActionReference(path = "Editors/text/x-python/Popup", position = 905) 22 | @Messages("CTL_PylintScore=Pylint Code Score") 23 | public final class PythonPylintScoreEnabler implements ActionListener { 24 | 25 | public PythonPylintScoreEnabler(EditorCookie context) { 26 | } 27 | 28 | @Override 29 | public void actionPerformed(ActionEvent ev) { 30 | for (JTextComponent target : EditorRegistry.componentList()) { 31 | PythonPylintScoreBar sb = PythonPylintScoreBar.getSideBar(target); 32 | if (sb != null) { 33 | sb.showScorePanel(true); 34 | } 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonRunAction.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.util.Collection; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.Action; 7 | import javax.swing.SwingUtilities; 8 | import org.netbeans.api.project.FileOwnerQuery; 9 | import org.netbeans.api.project.Project; 10 | import org.netbeans.modules.python.project.PythonProject; 11 | import org.openide.awt.ActionID; 12 | import org.openide.awt.ActionReference; 13 | import org.openide.awt.ActionReferences; 14 | import org.openide.awt.ActionRegistration; 15 | import org.openide.awt.DynamicMenuContent; 16 | import org.openide.filesystems.FileObject; 17 | import org.openide.loaders.DataObject; 18 | import org.openide.util.ContextAwareAction; 19 | import org.openide.util.Lookup; 20 | import org.openide.util.LookupEvent; 21 | import org.openide.util.LookupListener; 22 | import org.openide.util.NbBundle.Messages; 23 | import org.openide.util.Utilities; 24 | 25 | @ActionID( 26 | category = "Project", 27 | id = "org.netbeans.modules.python.RunAction" 28 | ) 29 | @ActionRegistration( 30 | displayName = "#CTL_RunAction", lazy = false 31 | ) 32 | @ActionReferences({ 33 | @ActionReference(path = "Editors/text/x-python/Popup", position = 0), 34 | @ActionReference(path = "Loaders/text/x-python/Actions", position = 250) 35 | }) 36 | @Messages("CTL_RunAction=Run Single Python File") 37 | public final class PythonRunAction extends AbstractAction implements LookupListener, ContextAwareAction { 38 | 39 | private static final long serialVersionUID = 1L; 40 | 41 | private Lookup context; 42 | Lookup.Result lkpInfo; 43 | 44 | public PythonRunAction() { 45 | this(Utilities.actionsGlobalContext()); 46 | } 47 | 48 | public PythonRunAction(Lookup context) { 49 | putValue(Action.NAME, Bundle.CTL_RunAction()); 50 | putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); 51 | this.context = context; 52 | } 53 | 54 | void init() { 55 | assert SwingUtilities.isEventDispatchThread() : "this shall be called just from AWT thread"; 56 | if (lkpInfo != null) { 57 | return; 58 | } 59 | //The thing we want to listen for the presence or absence of 60 | //on the global selection 61 | lkpInfo = context.lookupResult(DataObject.class); 62 | lkpInfo.addLookupListener(this); 63 | resultChanged(null); 64 | } 65 | 66 | @Override 67 | public void resultChanged(LookupEvent ev) { 68 | Collection allInstances = lkpInfo.allInstances(); 69 | if (allInstances.isEmpty()) { 70 | setEnabled(false); 71 | return; 72 | } 73 | FileObject primaryFile = lkpInfo.allInstances().stream() 74 | .findFirst().get().getPrimaryFile(); 75 | Project owner = FileOwnerQuery.getOwner(primaryFile); 76 | if (owner != null && (owner instanceof PythonProject)) { 77 | setEnabled(false); 78 | return; 79 | } 80 | setEnabled(true); 81 | } 82 | 83 | @Override 84 | public Action createContextAwareInstance(Lookup context) { 85 | return new PythonRunAction(context); 86 | } 87 | 88 | @Override 89 | public boolean isEnabled() { 90 | init(); 91 | return super.isEnabled(); 92 | } 93 | 94 | @Override 95 | public void actionPerformed(ActionEvent ev) { 96 | PythonRun.runAction(null, lkpInfo.allInstances().stream().findFirst().get(), false); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/actions/PythonVEnvMenuAction.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.actions; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.JMenu; 7 | import javax.swing.JMenuItem; 8 | import org.openide.awt.ActionID; 9 | import org.openide.awt.ActionRegistration; 10 | import org.openide.util.NbBundle; 11 | import org.openide.util.actions.Presenter; 12 | 13 | /** 14 | * 15 | * @author albilu 16 | */ 17 | @ActionID( 18 | category = "Project", 19 | id = "org.netbeans.modules.python.actions.PythonVEnvMenuAction" 20 | ) 21 | @ActionRegistration( 22 | displayName = "#CTL_PythonVEnvMenuAction", 23 | lazy = false, 24 | asynchronous = true 25 | ) 26 | @NbBundle.Messages("CTL_PythonVEnvMenuAction=Virtual Environment") 27 | public final class PythonVEnvMenuAction extends AbstractAction 28 | implements ActionListener, Presenter.Popup { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | @Override 33 | public void actionPerformed(ActionEvent e) { 34 | } 35 | 36 | @Override 37 | public JMenuItem getPopupPresenter() { 38 | JMenu main = new JMenu(Bundle.CTL_PythonVEnvMenuAction()); 39 | main.add(new PythonCreateVEnvAction()); 40 | main.add(new PythonCleanVEnvAction()); 41 | main.add(new PythonVEnvConsoleAction()); 42 | return main; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/coverage/PythonCoverageMenuAction.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.coverage; 2 | 3 | import java.awt.event.ActionEvent; 4 | import javax.swing.AbstractAction; 5 | import javax.swing.Action; 6 | import org.netbeans.api.project.Project; 7 | import org.netbeans.modules.gsf.codecoverage.api.CoverageActionFactory; 8 | import org.openide.awt.ActionID; 9 | import org.openide.awt.ActionReference; 10 | import org.openide.awt.ActionRegistration; 11 | import org.openide.awt.DynamicMenuContent; 12 | import org.openide.util.ContextAwareAction; 13 | import org.openide.util.Lookup; 14 | 15 | //Copy from org/netbeans/modules/gradle/java/coverage/CoveragePopup.java 16 | @ActionID(category = "Project", id = "org.netbeans.modules.python.testrunner.PythonCoverageMenuAction") 17 | @ActionRegistration(displayName = "Test Coverage", lazy = false) 18 | @ActionReference(path = "Projects/org-netbeans-modules-python/Actions", position = 1205) 19 | public class PythonCoverageMenuAction extends AbstractAction implements ContextAwareAction { 20 | 21 | @SuppressWarnings("OverridableMethodCallInConstructor") 22 | public PythonCoverageMenuAction() { 23 | putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); 24 | setEnabled(false); 25 | } 26 | 27 | @Override 28 | public void actionPerformed(ActionEvent e) { 29 | assert false; 30 | } 31 | 32 | @Override 33 | public Action createContextAwareInstance(Lookup ctx) { 34 | Project p = ctx.lookup(Project.class); 35 | if (p == null) { 36 | return this; 37 | } 38 | if (p.getProjectDirectory().getFileObject(".coverage") == null) { 39 | return this; 40 | } 41 | return ((ContextAwareAction) CoverageActionFactory.createCollectorAction(null, null)) 42 | .createContextAwareInstance(ctx); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/DebuggerAnnotation.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | import org.openide.text.Annotatable; 4 | import org.openide.text.Annotation; 5 | import org.openide.util.NbBundle; 6 | 7 | /** 8 | * Debugger Annotation class. 9 | * 10 | * @author albilu 11 | */ 12 | public class DebuggerAnnotation extends Annotation { 13 | 14 | public static final String CURRENT_LINE_ANNOTATION_TYPE = "CurrentPC"; 15 | public static final String CURRENT_LINE_ANNOTATION_TYPE2 = "CurrentPC2"; 16 | public static final String CURRENT_LINE_PART_ANNOTATION_TYPE = "CurrentPCLinePart"; 17 | public static final String CURRENT_LINE_PART_ANNOTATION_TYPE2 = "CurrentPC2LinePart"; 18 | public static final String CALL_STACK_FRAME_ANNOTATION_TYPE = "CallSite"; 19 | 20 | private final String type; 21 | 22 | public DebuggerAnnotation(String type, Annotatable annotatable) { 23 | this.type = type; 24 | attach(annotatable); 25 | } 26 | 27 | @Override 28 | public String getAnnotationType() { 29 | return type; 30 | } 31 | 32 | @Override 33 | @NbBundle.Messages({"TTP_CurrentPC=Current Program Counter", 34 | "TTP_CurrentPC2=Current Target", 35 | "TTP_Callsite=Call Stack Line"}) 36 | public String getShortDescription() { 37 | switch (type) { 38 | case CURRENT_LINE_ANNOTATION_TYPE: 39 | case CURRENT_LINE_PART_ANNOTATION_TYPE: 40 | return Bundle.TTP_CurrentPC(); 41 | case CURRENT_LINE_ANNOTATION_TYPE2: 42 | return Bundle.TTP_CurrentPC2(); 43 | case CALL_STACK_FRAME_ANNOTATION_TYPE: 44 | return Bundle.TTP_Callsite(); 45 | default: 46 | throw new IllegalStateException(type); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/PythonDebuggerCallStack.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | import java.net.URI; 4 | import java.nio.file.Paths; 5 | import org.netbeans.spi.debugger.ui.DebuggingView; 6 | import org.openide.cookies.LineCookie; 7 | import org.openide.filesystems.FileUtil; 8 | import org.openide.loaders.DataObject; 9 | import org.openide.loaders.DataObjectNotFoundException; 10 | import org.openide.text.Line; 11 | import org.openide.util.Exceptions; 12 | 13 | /** 14 | * 15 | * @author albilu 16 | */ 17 | public class PythonDebuggerCallStack implements DebuggingView.DVFrame { 18 | 19 | String filePath; 20 | int lineNumber; 21 | String method; 22 | private boolean current; 23 | 24 | public PythonDebuggerCallStack(String filePath, int lineNumber, String method) { 25 | this.filePath = filePath; 26 | this.lineNumber = lineNumber; 27 | this.method = method; 28 | } 29 | 30 | @Override 31 | public String getName() { 32 | return method; 33 | } 34 | 35 | @Override 36 | public DebuggingView.DVThread getThread() { 37 | return null; 38 | } 39 | 40 | @Override 41 | public void makeCurrent() { 42 | current = true; 43 | } 44 | 45 | public boolean isCurrent() { 46 | return current; 47 | } 48 | 49 | @Override 50 | public URI getSourceURI() { 51 | return Paths.get(filePath).toUri(); 52 | } 53 | 54 | @Override 55 | public int getLine() { 56 | return lineNumber; 57 | } 58 | 59 | @Override 60 | public int getColumn() { 61 | return 0; 62 | } 63 | 64 | public Line location() { 65 | try { 66 | LineCookie lc = DataObject.find(FileUtil.toFileObject(Paths.get(getSourceURI()).toFile())) 67 | .getLookup().lookup(LineCookie.class); 68 | if (lc == null) { 69 | return null; 70 | } 71 | return lc.getLineSet().getOriginal(lineNumber - 1); 72 | } catch (DataObjectNotFoundException ex) { 73 | Exceptions.printStackTrace(ex); 74 | } 75 | return null; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/PythonDebuggerName.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | class PythonDebuggerName { 8 | 9 | String name; 10 | 11 | public PythonDebuggerName(String name) { 12 | this.name = name; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return name; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/PythonDebuggerProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | import org.netbeans.api.debugger.DebuggerEngine; 4 | import org.netbeans.spi.debugger.DebuggerEngineProvider; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonDebuggerProvider extends DebuggerEngineProvider { 11 | 12 | private static final String PYTHON_DEBUGGER_ENGINE = "PYthonDebuggerEngine"; 13 | private DebuggerEngine.Destructor destructor; 14 | 15 | @Override 16 | public String[] getLanguages() { 17 | return new String[]{PythonDebugger.PYTHON_DEBUGGER_LANGUAGE}; 18 | } 19 | 20 | @Override 21 | public String getEngineTypeID() { 22 | return PYTHON_DEBUGGER_ENGINE; 23 | } 24 | 25 | @Override 26 | public Object[] getServices() { 27 | return new Object[]{}; 28 | } 29 | 30 | @Override 31 | public void setDestructor(DebuggerEngine.Destructor d) { 32 | this.destructor = d; 33 | } 34 | 35 | public DebuggerEngine.Destructor getDestructor() { 36 | return destructor; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/PythonDebuggerSessionListener.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | import org.netbeans.api.debugger.DebuggerManagerAdapter; 4 | import org.netbeans.api.debugger.LazyDebuggerManagerListener; 5 | import org.netbeans.api.debugger.Session; 6 | import org.netbeans.spi.debugger.DebuggerServiceRegistration; 7 | 8 | /** 9 | * 10 | * @author albilu 11 | */ 12 | @DebuggerServiceRegistration(types = LazyDebuggerManagerListener.class) 13 | public class PythonDebuggerSessionListener extends DebuggerManagerAdapter { 14 | 15 | @Override 16 | public void sessionAdded(Session session) { 17 | super.sessionAdded(session); 18 | } 19 | 20 | @Override 21 | public void sessionRemoved(Session session) { 22 | super.sessionRemoved(session); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/PythonDebuggerSessionProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger; 2 | 3 | import static org.netbeans.modules.python.debugger.PythonDebugger.PYTHON_DEBUGGER_INFO; 4 | import static org.netbeans.modules.python.debugger.PythonDebugger.PYTHON_SESSION; 5 | import org.netbeans.spi.debugger.ContextProvider; 6 | import org.netbeans.spi.debugger.SessionProvider; 7 | 8 | /** 9 | * 10 | * @author albilu 11 | */ 12 | @SessionProvider.Registration(path = PYTHON_DEBUGGER_INFO) 13 | public class PythonDebuggerSessionProvider extends SessionProvider { 14 | 15 | private final ContextProvider contextProvider; 16 | 17 | public PythonDebuggerSessionProvider(ContextProvider contextProvider) { 18 | this.contextProvider = contextProvider; 19 | } 20 | 21 | @Override 22 | public String getSessionName() { 23 | PythonDebuggerName lookupFirst = contextProvider 24 | .lookupFirst(null, PythonDebuggerName.class); 25 | return lookupFirst.toString(); 26 | } 27 | 28 | @Override 29 | public String getLocationName() { 30 | return "localhost"; 31 | } 32 | 33 | @Override 34 | public String getTypeID() { 35 | return PYTHON_SESSION; 36 | } 37 | 38 | @Override 39 | public Object[] getServices() { 40 | return new Object[]{}; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/attach/PythonDebuggerAttachType.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.attach; 2 | 3 | import java.lang.ref.Reference; 4 | import java.lang.ref.WeakReference; 5 | import javax.swing.JComponent; 6 | import org.netbeans.spi.debugger.ui.AttachType; 7 | import org.netbeans.spi.debugger.ui.Controller; 8 | import org.openide.util.NbBundle; 9 | 10 | /** 11 | * 12 | * @author albilu 13 | */ 14 | @NbBundle.Messages("CTL_PythonConnector_name=Python Debugger") 15 | @AttachType.Registration(displayName = "#CTL_PythonConnector_name") 16 | public class PythonDebuggerAttachType extends AttachType { 17 | 18 | private Reference customizerRef = new WeakReference<>(null); 19 | 20 | @Override 21 | public JComponent getCustomizer() { 22 | PythonDebuggerAttachCustomizer ac = new PythonDebuggerAttachCustomizer(); 23 | customizerRef = new WeakReference<>(ac); 24 | return ac; 25 | } 26 | 27 | @Override 28 | public Controller getController() { 29 | PythonDebuggerAttachCustomizer panel = customizerRef.get(); 30 | if (panel != null) { 31 | return panel.getController(); 32 | } else { 33 | return null; 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/breakpoints/ControllerProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.breakpoints; 2 | 3 | import org.netbeans.spi.debugger.ui.Controller; 4 | 5 | /** 6 | * 7 | * @author albilu 8 | */ 9 | public interface ControllerProvider { 10 | 11 | public Controller getController(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/breakpoints/PythonBreakpointBeanInfo.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.breakpoints; 2 | 3 | import java.beans.BeanDescriptor; 4 | import java.beans.SimpleBeanInfo; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | import org.openide.util.Lookup; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonBreakpointBeanInfo extends SimpleBeanInfo { 14 | 15 | private static final Logger LOG = Logger.getLogger(PythonBreakpointBeanInfo.class.getName()); 16 | 17 | @Override 18 | public BeanDescriptor getBeanDescriptor() { 19 | Class customizer = null; 20 | try { 21 | customizer = Class.forName("org.netbeans.modules.python.debugger.breakpoints.PythonBreakpointCustomizer", 22 | true, Lookup.getDefault().lookup(ClassLoader.class)); 23 | } catch (ClassNotFoundException cnfex) { 24 | LOG.log(Level.WARNING, "No BP customizer", cnfex); 25 | } 26 | return new BeanDescriptor( 27 | PythonBreakpoint.class, 28 | customizer); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/breakpoints/PythonBreakpointCustomizer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.breakpoints; 2 | 3 | import java.awt.GridBagConstraints; 4 | import java.awt.GridBagLayout; 5 | import java.beans.Customizer; 6 | import javax.swing.JPanel; 7 | import org.netbeans.spi.debugger.ui.Controller; 8 | import org.openide.util.NbBundle; 9 | 10 | /** 11 | * 12 | * @author albilu 13 | */ 14 | public class PythonBreakpointCustomizer extends JPanel implements Customizer, Controller { 15 | 16 | private PythonBreakpoint b; 17 | private PythonBreakpointCustomizerPanel c; 18 | 19 | public PythonBreakpointCustomizer() { 20 | } 21 | 22 | @Override 23 | public void setObject(Object bean) { 24 | if (!(bean instanceof PythonBreakpoint)) { 25 | throw new IllegalArgumentException(bean.toString()); 26 | } 27 | this.b = (PythonBreakpoint) bean; 28 | init(b); 29 | } 30 | 31 | private void init(PythonBreakpoint b) { 32 | c = getCustomizerComponent(b); 33 | setLayout(new GridBagLayout()); 34 | GridBagConstraints gbc = new GridBagConstraints(); 35 | gbc.fill = GridBagConstraints.BOTH; 36 | gbc.weightx = 1.0; 37 | gbc.weighty = 1.0; 38 | add(c, gbc); 39 | } 40 | 41 | @NbBundle.Messages("ACSD_Breakpoint_Customizer_Dialog=Customize this breakpoint's properties") 42 | public static PythonBreakpointCustomizerPanel getCustomizerComponent(PythonBreakpoint lb) { 43 | PythonBreakpointCustomizerPanel c; 44 | c = new PythonBreakpointCustomizerPanel(lb); 45 | c.getAccessibleContext().setAccessibleDescription(Bundle.ACSD_Breakpoint_Customizer_Dialog()); 46 | return c; 47 | } 48 | 49 | @Override 50 | public boolean ok() { 51 | Controller cc; 52 | cc = c.getController(); 53 | return cc.ok(); 54 | } 55 | 56 | @Override 57 | public boolean cancel() { 58 | Controller cc; 59 | cc = c.getController(); 60 | return cc.cancel(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/breakpoints/PythonBreakpointType.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.breakpoints; 2 | 3 | import javax.swing.JComponent; 4 | import org.netbeans.modules.python.PythonUtility; 5 | import org.netbeans.spi.debugger.ui.BreakpointType; 6 | import org.netbeans.spi.debugger.ui.Controller; 7 | import org.netbeans.spi.debugger.ui.EditorContextDispatcher; 8 | import org.openide.filesystems.FileObject; 9 | import org.openide.util.NbBundle; 10 | 11 | @NbBundle.Messages({"PythonBreakpointTypeCategory=Python", 12 | "LineBreakpointTypeName=Python Line"}) 13 | @BreakpointType.Registration(displayName = "#LineBreakpointTypeName") 14 | public class PythonBreakpointType extends BreakpointType { 15 | 16 | private PythonBreakpointCustomizerPanel cust; 17 | 18 | /* (non-Javadoc) 19 | * @see org.netbeans.spi.debugger.ui.BreakpointType#getCategoryDisplayName() 20 | */ 21 | @Override 22 | public String getCategoryDisplayName() { 23 | return Bundle.PythonBreakpointTypeCategory(); 24 | } 25 | 26 | /* (non-Javadoc) 27 | * @see org.netbeans.spi.debugger.ui.BreakpointType#getCustomizer() 28 | */ 29 | @Override 30 | public JComponent getCustomizer() { 31 | if (cust == null) { 32 | cust = new PythonBreakpointCustomizerPanel(); 33 | } 34 | return cust; 35 | } 36 | 37 | @Override 38 | public Controller getController() { 39 | getCustomizer(); 40 | return cust.getController(); 41 | } 42 | 43 | /* (non-Javadoc) 44 | * @see org.netbeans.spi.debugger.ui.BreakpointType#getTypeDisplayName() 45 | */ 46 | @Override 47 | public String getTypeDisplayName() { 48 | return Bundle.LineBreakpointTypeName(); 49 | } 50 | 51 | /* (non-Javadoc) 52 | * @see org.netbeans.spi.debugger.ui.BreakpointType#isDefault() 53 | */ 54 | @Override 55 | public boolean isDefault() { 56 | FileObject mostRecentFile = EditorContextDispatcher.getDefault().getMostRecentFile(); 57 | if (mostRecentFile == null) { 58 | return false; 59 | } 60 | String mimeType = mostRecentFile.getMIMEType(); 61 | return PythonUtility.PYTHON_MIME_TYPE.equals(mimeType); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/debugger/models/PythonDebuggerBreakpointsListener.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.debugger.models; 2 | 3 | import javax.swing.event.ChangeListener; 4 | import org.openide.util.ChangeSupport; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonDebuggerBreakpointsListener { 11 | 12 | private static final ChangeSupport cs = new ChangeSupport(PythonDebuggerBreakpointsListener.class); 13 | 14 | public static void addChangeListener(ChangeListener listener) { 15 | cs.addChangeListener(listener); 16 | } 17 | 18 | public static void removeChangeListener(ChangeListener listener) { 19 | cs.removeChangeListener(listener); 20 | } 21 | 22 | public static void firePropertiesChange() { 23 | cs.fireChange(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/editor/PythonEditorKit.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.editor; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import javax.swing.Action; 8 | import javax.swing.text.Document; 9 | import javax.swing.text.EditorKit; 10 | import javax.swing.text.TextAction; 11 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 12 | import org.netbeans.modules.editor.NbEditorKit; 13 | import org.netbeans.modules.python.PythonUtility; 14 | 15 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = EditorKit.class) 16 | public class PythonEditorKit extends NbEditorKit { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | @Override 21 | public String getContentType() { 22 | return PythonUtility.PYTHON_MIME_TYPE; 23 | } 24 | 25 | @Override 26 | public Document createDefaultDocument() { 27 | return new PythonGsfDocument(PythonUtility.PYTHON_MIME_TYPE); 28 | } 29 | 30 | @Override 31 | protected Action[] createActions() { 32 | Action[] actions = new Action[]{new ToggleCommentAction("#")}; 33 | return TextAction.augmentList(super.createActions(), actions); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/editor/PythonGsfDocument.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.editor; 2 | 3 | import org.netbeans.modules.csl.api.GsfLanguage; 4 | import org.netbeans.modules.csl.core.Language; 5 | import org.netbeans.modules.csl.core.LanguageRegistry; 6 | import org.netbeans.modules.editor.NbEditorDocument; 7 | import org.netbeans.modules.python.PythonUtility; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonGsfDocument extends NbEditorDocument { 14 | 15 | private GsfLanguage language = null; 16 | 17 | public PythonGsfDocument(String mimeType) { 18 | super(mimeType); 19 | } 20 | 21 | @Override 22 | public boolean isIdentifierPart(char ch) { 23 | if (language == null) { 24 | Language l = LanguageRegistry.getInstance().getLanguageByMimeType(PythonUtility.PYTHON_MIME_TYPE); 25 | if (l != null) { 26 | language = l.getGsfLanguage(); 27 | } 28 | } 29 | return language != null ? language.isIdentifierChar(ch) 30 | : (Character.toString(ch).equals("_") ? true : super.isIdentifierPart(ch)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/editor/PythonReformatTaskFactory.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.editor; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import org.netbeans.modules.python.PythonUtility; 8 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 9 | import org.netbeans.modules.editor.indent.spi.Context; 10 | import org.netbeans.modules.editor.indent.spi.ReformatTask; 11 | 12 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = ReformatTask.Factory.class) 13 | public class PythonReformatTaskFactory implements ReformatTask.Factory { 14 | 15 | @Override 16 | public ReformatTask createTask(Context context) { 17 | return new PythonReformatTask(context); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/editor/PythonTypedTextFactory.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.editor; 2 | 3 | import org.netbeans.api.editor.mimelookup.MimePath; 4 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 5 | import org.netbeans.modules.python.PythonUtility; 6 | import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor; 7 | 8 | /** 9 | * 10 | * @author albilu 11 | */ 12 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = TypedTextInterceptor.Factory.class) 13 | public class PythonTypedTextFactory implements TypedTextInterceptor.Factory { 14 | 15 | @Override 16 | public TypedTextInterceptor createTypedTextInterceptor(MimePath mimePath) { 17 | return new PythonTypedTextInterceptor(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/indexing/PythonCustomIndexerFactory.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.indexing; 2 | 3 | import java.io.IOException; 4 | import java.util.logging.Level; 5 | import java.util.logging.Logger; 6 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 7 | import org.netbeans.api.project.FileOwnerQuery; 8 | import org.netbeans.api.project.Project; 9 | import org.netbeans.modules.parsing.spi.indexing.Context; 10 | import org.netbeans.modules.parsing.spi.indexing.CustomIndexer; 11 | import org.netbeans.modules.parsing.spi.indexing.CustomIndexerFactory; 12 | import org.netbeans.modules.parsing.spi.indexing.Indexable; 13 | import org.netbeans.modules.parsing.spi.indexing.support.IndexingSupport; 14 | import org.netbeans.modules.python.PythonUtility; 15 | import org.openide.filesystems.FileObject; 16 | 17 | /** 18 | * 19 | * @author albilu 20 | */ 21 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = CustomIndexerFactory.class) 22 | public class PythonCustomIndexerFactory extends CustomIndexerFactory { 23 | 24 | public static final Logger LOG = Logger.getLogger(PythonCustomIndexerFactory.class.getName()); 25 | 26 | @Override 27 | public CustomIndexer createIndexer() { 28 | return new PythonCustomIndexer(); 29 | } 30 | 31 | @Override 32 | public boolean supportsEmbeddedIndexers() { 33 | return false; 34 | } 35 | 36 | @Override 37 | public void filesDeleted(Iterable deleted, Context context) { 38 | FileObject fo = context.getRoot(); 39 | Project owner = fo != null ? FileOwnerQuery.getOwner(fo) : null; 40 | if (owner != null && owner.getClass() 41 | .getName().equals("org.netbeans.modules.python.project.PythonProject")) { 42 | try { 43 | IndexingSupport is = IndexingSupport.getInstance(context); 44 | for (Indexable indexable : deleted) { 45 | is.removeDocuments(indexable); 46 | if (LOG.isLoggable(Level.INFO)) { 47 | LOG.log(Level.INFO, () -> "removed " + indexable.getRelativePath()); 48 | } 49 | } 50 | } catch (IOException ioe) { 51 | LOG.log(Level.WARNING, null, ioe); 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | public void filesDirty(Iterable dirty, Context context) { 58 | FileObject fo = context.getRoot(); 59 | Project owner = fo != null ? FileOwnerQuery.getOwner(fo) : null; 60 | if (owner != null && owner.getClass() 61 | .getName().equals("org.netbeans.modules.python.project.PythonProject")) { 62 | try { 63 | IndexingSupport is = IndexingSupport.getInstance(context); 64 | for (Indexable indexable : dirty) { 65 | is.markDirtyDocuments(indexable); 66 | if (LOG.isLoggable(Level.INFO)) { 67 | LOG.log(Level.INFO, () -> "updated " + indexable.getRelativePath()); 68 | } 69 | } 70 | } catch (IOException ioe) { 71 | LOG.log(Level.WARNING, null, ioe); 72 | } 73 | } 74 | } 75 | 76 | @Override 77 | public String getIndexerName() { 78 | return "PythonIndexer"; 79 | } 80 | 81 | @Override 82 | public int getIndexVersion() { 83 | return 0; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/indexing/PythonDefaultError.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.indexing; 2 | 3 | import org.netbeans.modules.csl.api.Severity; 4 | import org.netbeans.modules.csl.spi.DefaultError; 5 | import org.openide.filesystems.FileObject; 6 | 7 | /** 8 | * 9 | * @author albilu 10 | */ 11 | public class PythonDefaultError extends DefaultError implements org.netbeans.modules.csl.api.Error.Badging { 12 | 13 | public PythonDefaultError(String key, String displayName, String description, 14 | FileObject file, int start, int end, Severity severity) { 15 | super(key, displayName, description, file, start, end, severity); 16 | } 17 | 18 | @Override 19 | public boolean showExplorerBadge() { 20 | return true; 21 | } 22 | 23 | @Override 24 | public boolean isLineError() { 25 | return super.isLineError(); 26 | } 27 | 28 | @Override 29 | public Object[] getParameters() { 30 | return super.getParameters(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/indexing/PythonErrorConvertor.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.indexing; 2 | 3 | import org.netbeans.modules.csl.spi.DefaultError; 4 | import org.netbeans.modules.parsing.spi.indexing.ErrorsCache; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonErrorConvertor implements ErrorsCache.Convertor { 11 | 12 | @Override 13 | public ErrorsCache.ErrorKind getKind(DefaultError t) { 14 | return ErrorsCache.ErrorKind.ERROR; 15 | } 16 | 17 | @Override 18 | public int getLineNumber(DefaultError t) { 19 | return 1; 20 | } 21 | 22 | @Override 23 | public String getMessage(DefaultError t) { 24 | return "PythonError"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/log/PythonLspLog.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.log; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.util.logging.Level; 8 | import java.util.logging.Logger; 9 | import org.netbeans.modules.python.PythonUtility; 10 | import org.openide.awt.ActionID; 11 | import org.openide.awt.ActionReference; 12 | import org.openide.awt.ActionRegistration; 13 | import org.openide.util.NbBundle.Messages; 14 | 15 | @ActionID( 16 | category = "File", 17 | id = "org.netbeans.modules.python.log.PythonLspLog" 18 | ) 19 | @ActionRegistration( 20 | displayName = "#CTL_PythonLspLog" 21 | ) 22 | @ActionReference(path = "Menu/View", position = 550) 23 | @Messages("CTL_PythonLspLog=Python Lsp Log") 24 | public final class PythonLspLog implements ActionListener { 25 | 26 | static final File f = PythonUtility.PYLSP_VENV_DIR.toPath().resolve("lsp_log_file").toFile(); 27 | 28 | @Override 29 | public void actionPerformed(ActionEvent e) { 30 | 31 | if (!f.exists()) { 32 | return; 33 | } 34 | 35 | LogViewerSupport p = new LogViewerSupport(f, Bundle.CTL_PythonLspLog()); 36 | try { 37 | p.showLogViewer(); 38 | } catch (IOException ex) { 39 | Logger.getLogger(PythonLspLog.class.getName()).log(Level.INFO, "Showing Python Lsp log action failed", ex); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonLspServerConfigsOptionsPanelController.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.beans.PropertyChangeListener; 4 | import java.beans.PropertyChangeSupport; 5 | import javax.swing.JComponent; 6 | import javax.swing.SwingUtilities; 7 | import org.netbeans.spi.options.OptionsPanelController; 8 | import org.openide.util.HelpCtx; 9 | import org.openide.util.Lookup; 10 | 11 | @OptionsPanelController.SubRegistration( 12 | location = "PythonOptions", 13 | displayName = "#AdvancedOption_DisplayName_LspServerConfigs", 14 | keywords = "#AdvancedOption_Keywords_LspServerConfigs", 15 | keywordsCategory = "Advanced/LspServerConfigs" 16 | ) 17 | @org.openide.util.NbBundle.Messages({ 18 | "AdvancedOption_DisplayName_LspServerConfigs=Lsp Server", 19 | "AdvancedOption_Keywords_LspServerConfigs=PyLspServer" 20 | }) 21 | public final class PythonLspServerConfigsOptionsPanelController 22 | extends OptionsPanelController { 23 | 24 | private PythonLspServerConfigsPanel panel; 25 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); 26 | private boolean changed; 27 | 28 | @Override 29 | public void update() { 30 | getPanel().load(); 31 | changed = false; 32 | } 33 | 34 | @Override 35 | public void applyChanges() { 36 | SwingUtilities.invokeLater(() -> { 37 | getPanel().store(); 38 | changed = false; 39 | }); 40 | } 41 | 42 | @Override 43 | public void cancel() { 44 | // need not do anything special, if no changes have been persisted yet 45 | } 46 | 47 | @Override 48 | public boolean isValid() { 49 | return getPanel().valid(); 50 | } 51 | 52 | @Override 53 | public boolean isChanged() { 54 | return changed; 55 | } 56 | 57 | @Override 58 | public HelpCtx getHelpCtx() { 59 | return null; // new HelpCtx("...ID") if you have a help set 60 | } 61 | 62 | @Override 63 | public JComponent getComponent(Lookup masterLookup) { 64 | return getPanel(); 65 | } 66 | 67 | @Override 68 | public void addPropertyChangeListener(PropertyChangeListener l) { 69 | pcs.addPropertyChangeListener(l); 70 | } 71 | 72 | @Override 73 | public void removePropertyChangeListener(PropertyChangeListener l) { 74 | pcs.removePropertyChangeListener(l); 75 | } 76 | 77 | private PythonLspServerConfigsPanel getPanel() { 78 | if (panel == null) { 79 | panel = new PythonLspServerConfigsPanel(this); 80 | } 81 | return panel; 82 | } 83 | 84 | void changed() { 85 | if (!changed) { 86 | changed = true; 87 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); 88 | } 89 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonPackageRepoRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.awt.Component; 4 | import javax.swing.DefaultListCellRenderer; 5 | import javax.swing.JLabel; 6 | import javax.swing.JList; 7 | import org.javatuples.Quartet; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonPackageRepoRenderer extends DefaultListCellRenderer { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @Override 18 | public Component getListCellRendererComponent(JList list, Object value, int index, 19 | boolean isSelected, boolean cellHasFocus) { 20 | 21 | JLabel label = (JLabel) super.getListCellRendererComponent( 22 | list, value, index, isSelected, cellHasFocus); 23 | label.setText(((Quartet) value).getValue0().toString()); 24 | label.setHorizontalTextPosition(JLabel.RIGHT); 25 | return label; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonPackageRepositoryOptionsPanelController.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.beans.PropertyChangeListener; 4 | import java.beans.PropertyChangeSupport; 5 | import javax.swing.JComponent; 6 | import javax.swing.SwingUtilities; 7 | import org.netbeans.spi.options.OptionsPanelController; 8 | import org.openide.util.HelpCtx; 9 | import org.openide.util.Lookup; 10 | 11 | @OptionsPanelController.SubRegistration( 12 | location = "PythonOptions", 13 | displayName = "#AdvancedOption_DisplayName_PythonPackageRepository", 14 | keywords = "#AdvancedOption_Keywords_PythonPackageRepository", 15 | keywordsCategory = "PythonOptions/PythonPackageRepository", 16 | id = "PyRepo" 17 | ) 18 | @org.openide.util.NbBundle.Messages({ 19 | "AdvancedOption_DisplayName_PythonPackageRepository=Python Package Repository", 20 | "AdvancedOption_Keywords_PythonPackageRepository=PackageRepo" 21 | }) 22 | public final class PythonPackageRepositoryOptionsPanelController extends OptionsPanelController { 23 | 24 | private PythonPackageRepositoryPanel panel; 25 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); 26 | private boolean changed; 27 | 28 | @Override 29 | public void update() { 30 | getPanel().load(); 31 | changed = false; 32 | } 33 | 34 | @Override 35 | public void applyChanges() { 36 | SwingUtilities.invokeLater(() -> { 37 | getPanel().store(); 38 | changed = false; 39 | }); 40 | } 41 | 42 | @Override 43 | public void cancel() { 44 | // need not do anything special, if no changes have been persisted yet 45 | } 46 | 47 | @Override 48 | public boolean isValid() { 49 | return getPanel().valid(); 50 | } 51 | 52 | @Override 53 | public boolean isChanged() { 54 | return changed; 55 | } 56 | 57 | @Override 58 | public HelpCtx getHelpCtx() { 59 | return null; // new HelpCtx("...ID") if you have a help set 60 | } 61 | 62 | @Override 63 | public JComponent getComponent(Lookup masterLookup) { 64 | return getPanel(); 65 | } 66 | 67 | @Override 68 | public void addPropertyChangeListener(PropertyChangeListener l) { 69 | pcs.addPropertyChangeListener(l); 70 | } 71 | 72 | @Override 73 | public void removePropertyChangeListener(PropertyChangeListener l) { 74 | pcs.removePropertyChangeListener(l); 75 | } 76 | 77 | private PythonPackageRepositoryPanel getPanel() { 78 | if (panel == null) { 79 | panel = new PythonPackageRepositoryPanel(this); 80 | } 81 | return panel; 82 | } 83 | 84 | void changed() { 85 | if (!changed) { 86 | changed = true; 87 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); 88 | } 89 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonPackagesListRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.awt.Component; 4 | import javax.swing.DefaultListCellRenderer; 5 | import javax.swing.Icon; 6 | import javax.swing.JLabel; 7 | import javax.swing.JList; 8 | import org.openide.util.ImageUtilities; 9 | import org.openide.util.Pair; 10 | 11 | /** 12 | * 13 | * @author albilu 14 | */ 15 | public class PythonPackagesListRenderer extends DefaultListCellRenderer { 16 | 17 | private static final long serialVersionUID = 1L; 18 | static final Icon ICON = ImageUtilities.image2Icon(ImageUtilities 19 | .loadImage("org/netbeans/modules/python/passed.png", false)); 20 | static final Icon ICON_ERROR = ImageUtilities.image2Icon(ImageUtilities 21 | .loadImage("org/netbeans/modules/python/test-error_16.png", false)); 22 | static final Icon ICON_WARN = ImageUtilities.image2Icon(ImageUtilities 23 | .loadImage("org/netbeans/modules/python/warning.svg", false)); 24 | 25 | @Override 26 | public Component getListCellRendererComponent(JList list, Object value, int index, 27 | boolean isSelected, boolean cellHasFocus) { 28 | 29 | JLabel label = (JLabel) super.getListCellRendererComponent( 30 | list, value, index, isSelected, cellHasFocus); 31 | Pair pyPackage = (Pair) value; 32 | label.setText(pyPackage.first()); 33 | label.setHorizontalTextPosition(JLabel.LEFT); 34 | if (pyPackage.second()) { 35 | label.setToolTipText("Installed"); 36 | label.setIcon(ICON); 37 | } else if (pyPackage.first().equals("pynguin")) { 38 | label.setToolTipText("Not Installed"); 39 | label.setIcon(ICON_WARN); 40 | } else { 41 | label.setToolTipText("Not Installed"); 42 | label.setIcon(ICON_ERROR); 43 | 44 | } 45 | return label; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonPlatformListRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.awt.Color; 4 | import java.awt.Component; 5 | import java.io.File; 6 | import javax.swing.DefaultListCellRenderer; 7 | import javax.swing.JLabel; 8 | import javax.swing.JList; 9 | import org.javatuples.Quartet; 10 | 11 | /** 12 | * 13 | * @author albilu 14 | */ 15 | public class PythonPlatformListRenderer extends DefaultListCellRenderer { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | @Override 20 | public Component getListCellRendererComponent(JList list, Object value, int index, 21 | boolean isSelected, boolean cellHasFocus) { 22 | 23 | JLabel label = (JLabel) super.getListCellRendererComponent( 24 | list, value, index, isSelected, cellHasFocus); 25 | Quartet pyObject = (Quartet) value; 26 | label.setText(pyObject.getValue0());//name 27 | label.setHorizontalTextPosition(JLabel.LEFT); 28 | if (pyObject.getValue3()) {//boolean 29 | label.setIcon(PythonPackagesListRenderer.ICON); 30 | } 31 | if (!new File(pyObject.getValue1()).exists()) {//cmd 32 | label.setForeground(Color.GRAY); 33 | } 34 | return label; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/options/PythonPlatformOptionsPanelController.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.options; 2 | 3 | import java.beans.PropertyChangeListener; 4 | import java.beans.PropertyChangeSupport; 5 | import javax.swing.JComponent; 6 | import javax.swing.SwingUtilities; 7 | import org.netbeans.spi.options.OptionsPanelController; 8 | import org.openide.util.HelpCtx; 9 | import org.openide.util.Lookup; 10 | 11 | @OptionsPanelController.SubRegistration( 12 | location = "PythonOptions", 13 | displayName = "#AdvancedOption_DisplayName_PythonPlatform", 14 | keywords = "#AdvancedOption_Keywords_PythonPlatform", 15 | keywordsCategory = "PythonOptions/PythonPlatform", 16 | id = "PyPlatform", 17 | position = 1 18 | ) 19 | @org.openide.util.NbBundle.Messages({ 20 | "AdvancedOption_DisplayName_PythonPlatform=Python Platform", 21 | "AdvancedOption_Keywords_PythonPlatform=PythonPlatform" 22 | }) 23 | public final class PythonPlatformOptionsPanelController extends OptionsPanelController { 24 | 25 | private PythonPlatformPanel panel; 26 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); 27 | private boolean changed; 28 | 29 | @Override 30 | public void update() { 31 | getPanel().load(); 32 | changed = false; 33 | } 34 | 35 | @Override 36 | public void applyChanges() { 37 | SwingUtilities.invokeLater(() -> { 38 | getPanel().store(); 39 | changed = false; 40 | }); 41 | } 42 | 43 | @Override 44 | public void cancel() { 45 | // need not do anything special, if no changes have been persisted yet 46 | } 47 | 48 | @Override 49 | public boolean isValid() { 50 | return getPanel().valid(); 51 | } 52 | 53 | @Override 54 | public boolean isChanged() { 55 | return changed; 56 | } 57 | 58 | @Override 59 | public HelpCtx getHelpCtx() { 60 | return null; // new HelpCtx("...ID") if you have a help set 61 | } 62 | 63 | @Override 64 | public JComponent getComponent(Lookup masterLookup) { 65 | return getPanel(); 66 | } 67 | 68 | @Override 69 | public void addPropertyChangeListener(PropertyChangeListener l) { 70 | pcs.addPropertyChangeListener(l); 71 | } 72 | 73 | @Override 74 | public void removePropertyChangeListener(PropertyChangeListener l) { 75 | pcs.removePropertyChangeListener(l); 76 | } 77 | 78 | private PythonPlatformPanel getPanel() { 79 | if (panel == null) { 80 | panel = new PythonPlatformPanel(this); 81 | } 82 | return panel; 83 | } 84 | 85 | void changed() { 86 | if (!changed) { 87 | changed = true; 88 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); 89 | } 90 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/package-info.java: -------------------------------------------------------------------------------- 1 | @TemplateRegistrations({ 2 | @TemplateRegistration( 3 | folder = "Python", 4 | content = "Python.py", 5 | displayName = "#Python_file", 6 | description = "PythonDescription.html", 7 | createHandlerClass = org.netbeans.api.templates.CreateFromTemplateHandler.class, 8 | scriptEngine = "freemarker", 9 | requireProject = false 10 | ), 11 | @TemplateRegistration( 12 | folder = "Python", 13 | content = "EmptyPython.py", 14 | displayName = "#Python_file_1", 15 | description = "PythonDescription.html", 16 | createHandlerClass = org.netbeans.api.templates.CreateFromTemplateHandler.class, 17 | scriptEngine = "freemarker", 18 | requireProject = false 19 | ), 20 | @TemplateRegistration( 21 | folder = "Python", 22 | content = "PythonUnittest.py", 23 | displayName = "#Python_Unittest_file", 24 | description = "PythonUnitTestDescription.html", 25 | createHandlerClass = org.netbeans.api.templates.CreateFromTemplateHandler.class, 26 | scriptEngine = "freemarker", 27 | requireProject = false 28 | ), 29 | @TemplateRegistration( 30 | folder = "Python", 31 | content = "PythonPytest.py", 32 | displayName = "#Python_Pytest_file", 33 | description = "PythonPyTestDescription.html", 34 | createHandlerClass = org.netbeans.api.templates.CreateFromTemplateHandler.class, 35 | scriptEngine = "freemarker", 36 | requireProject = false 37 | ) 38 | }) 39 | @OptionsPanelController.ContainerRegistration( 40 | id = "PythonOptions", 41 | categoryName = "#OptionsCategory_Name_PythonOptions", 42 | iconBase = "org/netbeans/modules/python/python32.png", 43 | keywords = "#OptionsCategory_Keywords_PythonOptions", 44 | keywordsCategory = "PythonOptions" 45 | ) 46 | @NbBundle.Messages( 47 | value = { 48 | "OptionsCategory_Name_PythonOptions=Python", 49 | "OptionsCategory_Keywords_PythonOptions=Python", 50 | "Python_file=Python File", 51 | "Python_file_1=Empty Python File", 52 | "Python_Unittest_file=Python Unit Test File", 53 | "Python_Pytest_file=Python PyTest File" 54 | } 55 | ) 56 | package org.netbeans.modules.python; 57 | 58 | import org.netbeans.api.templates.TemplateRegistration; 59 | import org.netbeans.api.templates.TemplateRegistrations; 60 | import org.netbeans.spi.options.OptionsPanelController; 61 | import org.openide.util.NbBundle; 62 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/packagemanager/PythonDataProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.packagemanager; 2 | 3 | import javax.swing.tree.DefaultMutableTreeNode; 4 | import org.javatuples.Triplet; 5 | import org.netbeans.modules.python.PythonUtility; 6 | import org.netbeans.swing.outline.RenderDataProvider; 7 | import org.openide.util.ImageUtilities; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonDataProvider implements RenderDataProvider { 14 | 15 | @Override 16 | public java.awt.Color getBackground(Object o) { 17 | return null; 18 | } 19 | 20 | @Override 21 | public String getDisplayName(Object o) { 22 | DefaultMutableTreeNode node = (DefaultMutableTreeNode) o; 23 | Triplet leafNode = (Triplet) node 24 | .getUserObject(); 25 | return leafNode.getValue0().toString(); 26 | 27 | } 28 | 29 | @Override 30 | public java.awt.Color getForeground(Object o) { 31 | return null; 32 | } 33 | 34 | @Override 35 | public javax.swing.Icon getIcon(Object o) { 36 | DefaultMutableTreeNode node = (DefaultMutableTreeNode) o; 37 | if (node.isLeaf()) { 38 | return ImageUtilities.image2Icon(PythonUtility.getPythonPackageIcon().getImage()); 39 | 40 | } 41 | return null; 42 | } 43 | 44 | @Override 45 | public String getTooltipText(Object o) { 46 | return null; 47 | } 48 | 49 | @Override 50 | public boolean isHtmlDisplayName(Object o) { 51 | return false; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/packagemanager/PythonHeaderRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.packagemanager; 2 | 3 | import java.awt.Component; 4 | import javax.swing.JLabel; 5 | import javax.swing.JTable; 6 | import javax.swing.table.DefaultTableCellRenderer; 7 | import javax.swing.table.TableCellRenderer; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonHeaderRenderer implements TableCellRenderer { 14 | 15 | @Override 16 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 17 | boolean hasFocus, int row, int col) { 18 | DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) table 19 | .getTableHeader().getDefaultRenderer(); 20 | renderer.setHorizontalAlignment(JLabel.LEFT); 21 | return renderer; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/packagemanager/PythonRootTreeNode.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.packagemanager; 2 | 3 | import javax.swing.tree.DefaultMutableTreeNode; 4 | import org.javatuples.Triplet; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonRootTreeNode extends DefaultMutableTreeNode { 11 | 12 | private static final long serialVersionUID = 1L; 13 | Triplet node; 14 | 15 | public PythonRootTreeNode(Triplet node) { 16 | this.node = node; 17 | } 18 | 19 | @Override 20 | public boolean isLeaf() { 21 | return false; 22 | } 23 | 24 | @Override 25 | public Object getUserObject() { 26 | return node; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return node.getValue0().toString(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/packagemanager/PythonRowModel.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.packagemanager; 2 | 3 | import javax.swing.tree.DefaultMutableTreeNode; 4 | import org.javatuples.Triplet; 5 | import org.netbeans.swing.outline.RowModel; 6 | 7 | /** 8 | * 9 | * @author albilu 10 | */ 11 | public class PythonRowModel implements RowModel { 12 | 13 | @Override 14 | public Class getColumnClass(int column) { 15 | switch (column) { 16 | case 0: 17 | return String.class; 18 | default: 19 | assert false; 20 | } 21 | return null; 22 | } 23 | 24 | @Override 25 | public int getColumnCount() { 26 | return 1; 27 | } 28 | 29 | @Override 30 | public String getColumnName(int column) { 31 | switch (column) { 32 | case 0: 33 | return "Version"; 34 | default: 35 | assert false; 36 | } 37 | return ""; 38 | } 39 | 40 | @Override 41 | public Object getValueFor(Object node, int column) { 42 | DefaultMutableTreeNode newNode = (DefaultMutableTreeNode) node; 43 | 44 | switch (column) { 45 | case 0: 46 | if (newNode.isLeaf()) { 47 | Triplet triNode = (Triplet) newNode.getUserObject(); 48 | return triNode.getValue1(); 49 | } 50 | return ""; 51 | default: 52 | assert false; 53 | } 54 | return null; 55 | } 56 | 57 | @Override 58 | public boolean isCellEditable(Object node, int column) { 59 | return false; 60 | } 61 | 62 | @Override 63 | public void setValueFor(Object node, int column, Object value) { 64 | //do nothing, nothing is editable 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/packagemanager/PythonTreeWillExpand.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.packagemanager; 2 | 3 | import java.io.IOException; 4 | import javax.swing.event.TreeExpansionEvent; 5 | import javax.swing.event.TreeWillExpandListener; 6 | import javax.swing.tree.DefaultMutableTreeNode; 7 | import javax.swing.tree.ExpandVetoException; 8 | import org.javatuples.Triplet; 9 | import org.netbeans.modules.python.PythonUtility; 10 | import org.netbeans.modules.python.statusbar.PythonStatusBarPanel; 11 | import org.openide.util.Exceptions; 12 | 13 | /** 14 | * 15 | * @author albilu 16 | */ 17 | public class PythonTreeWillExpand implements TreeWillExpandListener { 18 | 19 | @Override 20 | public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { 21 | DefaultMutableTreeNode node = (DefaultMutableTreeNode) (event.getPath().getLastPathComponent()); 22 | if (node.getChildCount() > 1) { 23 | return; 24 | } 25 | Triplet name = (Triplet) node.getUserObject(); 26 | switch (name.getValue0().toString()) { 27 | case "Installed": 28 | try { 29 | PythonPackagesModel.loadInstalled(PythonStatusBarPanel.currentPyPath.isEmpty() 30 | ? PythonUtility.getPlatformPythonExe() : PythonStatusBarPanel.currentPyPath); 31 | } catch (IOException ex) { 32 | Exceptions.printStackTrace(ex); 33 | } 34 | break; 35 | case "PyPI": 36 | PythonPackagesModel.loadPyPI(node); 37 | break; 38 | default: 39 | PythonPackagesModel.loadUserRepos(node); 40 | break; 41 | } 42 | 43 | } 44 | 45 | @Override 46 | public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { 47 | DefaultMutableTreeNode node = (DefaultMutableTreeNode) (event.getPath().getLastPathComponent()); 48 | PythonPackagesModel.collapse(node); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/poetry/PythonPoetryInit.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.poetry; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.io.IOException; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.Action; 7 | import org.netbeans.api.extexecution.ExecutionService; 8 | import org.netbeans.modules.python.PythonOutputLine; 9 | import org.netbeans.modules.python.PythonUtility; 10 | import org.openide.awt.ActionID; 11 | import org.openide.awt.ActionRegistration; 12 | import org.openide.filesystems.FileObject; 13 | import org.openide.filesystems.FileUtil; 14 | import org.openide.loaders.DataObject; 15 | import org.openide.util.Exceptions; 16 | import org.openide.util.NbBundle.Messages; 17 | 18 | @ActionID( 19 | category = "Project", 20 | id = "org.netbeans.modules.python.poetry.PythonPoetryInit" 21 | ) 22 | @ActionRegistration( 23 | displayName = "#CTL_PythonPoetryInit", 24 | lazy = false, 25 | asynchronous = true 26 | ) 27 | @Messages("CTL_PythonPoetryInit=Init") 28 | public final class PythonPoetryInit extends AbstractAction { 29 | 30 | DataObject dataObject; 31 | 32 | public PythonPoetryInit(DataObject dataObject) { 33 | putValue(Action.NAME, Bundle.CTL_PythonPoetryInit()); 34 | this.dataObject = dataObject; 35 | } 36 | 37 | public PythonPoetryInit() { 38 | } 39 | 40 | @Override 41 | public void actionPerformed(ActionEvent e) { 42 | try { 43 | FileObject fileObject = dataObject.getPrimaryFile(); 44 | 45 | ProcessBuilder pb = new ProcessBuilder(); 46 | pb.directory(FileUtil.toFile(fileObject)); 47 | 48 | pb.command(PythonUtility.getPlatformPythonExe(), "-m", "poetry", "init"); 49 | PythonUtility.manageRunEnvs(pb); 50 | 51 | ExecutionService service = ExecutionService.newService(() -> pb.start(), 52 | PythonUtility.getExecutorDescriptor(new PythonOutputLine(), () -> { 53 | }, () -> { 54 | }, false, true), 55 | String.format("Poetry %s (%s)", Bundle.CTL_PythonPoetryInit(), 56 | fileObject.getName())); 57 | 58 | service.run(); 59 | } catch (IOException ex) { 60 | Exceptions.printStackTrace(ex); 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/poetry/PythonPoetryInstall.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.poetry; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.io.IOException; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.Action; 7 | import org.netbeans.api.extexecution.ExecutionService; 8 | import org.netbeans.api.project.ProjectUtils; 9 | import org.netbeans.modules.python.PythonOutputLine; 10 | import org.netbeans.modules.python.project.PythonProject; 11 | import org.netbeans.modules.python.PythonUtility; 12 | import org.openide.awt.ActionID; 13 | import org.openide.awt.ActionRegistration; 14 | import org.openide.filesystems.FileObject; 15 | import org.openide.filesystems.FileUtil; 16 | import org.openide.util.Exceptions; 17 | import org.openide.util.NbBundle.Messages; 18 | 19 | @ActionID( 20 | category = "Project", 21 | id = "org.netbeans.modules.python.poetry.PythonPoetryInstall" 22 | ) 23 | @ActionRegistration( 24 | displayName = "#CTL_PythonPoetryInstall", 25 | lazy = false, 26 | asynchronous = true 27 | ) 28 | @Messages("CTL_PythonPoetryInstall=Install") 29 | public final class PythonPoetryInstall extends AbstractAction { 30 | 31 | PythonProject p; 32 | 33 | public PythonPoetryInstall(PythonProject p) { 34 | putValue(Action.NAME, Bundle.CTL_PythonPoetryInstall()); 35 | this.p = p; 36 | } 37 | 38 | public PythonPoetryInstall() { 39 | } 40 | 41 | @Override 42 | public void actionPerformed(ActionEvent e) { 43 | try { 44 | FileObject projectDirectory = p.getProjectDirectory(); 45 | ProcessBuilder pb = new ProcessBuilder(); 46 | pb.directory(FileUtil.toFile(projectDirectory)); 47 | 48 | pb.command(PythonUtility.getProjectPythonExe(projectDirectory), "-m", "poetry", "install"); 49 | PythonUtility.manageRunEnvs(pb); 50 | 51 | ExecutionService service = ExecutionService.newService(() -> pb.start(), 52 | PythonUtility.getExecutorDescriptor(new PythonOutputLine(), () -> { 53 | }, () -> { 54 | }, false, true), 55 | String.format("Poetry %s (%s)", Bundle.CTL_PythonPoetryInstall(), 56 | ProjectUtils.getInformation(p).getDisplayName())); 57 | 58 | service.run(); 59 | } catch (IOException ex) { 60 | Exceptions.printStackTrace(ex); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/poetry/PythonPoetryRunScript.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.poetry; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.io.IOException; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.Action; 7 | import org.netbeans.api.extexecution.ExecutionService; 8 | import org.netbeans.modules.python.PythonOutputLine; 9 | import org.netbeans.modules.python.project.PythonProject; 10 | import org.netbeans.modules.python.PythonUtility; 11 | import org.openide.awt.ActionID; 12 | import org.openide.awt.ActionRegistration; 13 | import org.openide.filesystems.FileObject; 14 | import org.openide.filesystems.FileUtil; 15 | import org.openide.util.Exceptions; 16 | import org.openide.util.NbBundle.Messages; 17 | 18 | @ActionID( 19 | category = "Project", 20 | id = "org.netbeans.modules.python.poetry.PythonPoetryRunScript" 21 | ) 22 | @ActionRegistration( 23 | displayName = "#CTL_PythonPoetryRunScript", 24 | lazy = false, 25 | asynchronous = true 26 | ) 27 | @Messages("CTL_PythonPoetryRunScript=Run") 28 | public final class PythonPoetryRunScript extends AbstractAction { 29 | 30 | PythonProject p; 31 | String script; 32 | 33 | public PythonPoetryRunScript(PythonProject p, String script) { 34 | putValue(Action.NAME, script); 35 | this.p = p; 36 | this.script = script; 37 | } 38 | 39 | public PythonPoetryRunScript() { 40 | } 41 | 42 | @Override 43 | public void actionPerformed(ActionEvent e) { 44 | try { 45 | FileObject projectDirectory = p.getProjectDirectory(); 46 | ProcessBuilder pb = new ProcessBuilder(); 47 | pb.directory(FileUtil.toFile(projectDirectory)); 48 | 49 | pb.command(PythonUtility.getProjectPythonExe(projectDirectory), "-m", "poetry", "run", script); 50 | PythonUtility.manageRunEnvs(pb); 51 | 52 | ExecutionService service = ExecutionService.newService(() -> pb.start(), 53 | PythonUtility.getExecutorDescriptor(new PythonOutputLine(), () -> { 54 | }, () -> { 55 | }, false, true), 56 | String.format("Poetry %s (%s)", Bundle.CTL_PythonPoetryRunScript(), 57 | script)); 58 | 59 | service.run(); 60 | } catch (IOException ex) { 61 | Exceptions.printStackTrace(ex); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/poetry/PythonPoetryShell.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.poetry; 2 | 3 | import java.awt.event.ActionEvent; 4 | import javax.swing.AbstractAction; 5 | import javax.swing.Action; 6 | import org.netbeans.modules.python.project.PythonProject; 7 | import org.netbeans.modules.python.repl.PythonVEnvConsoleActionTopComponent; 8 | import org.openide.awt.ActionID; 9 | import org.openide.awt.ActionRegistration; 10 | import org.openide.util.NbBundle.Messages; 11 | 12 | @ActionID( 13 | category = "Project", 14 | id = "org.netbeans.modules.python.poetry.PythonPoetryShell" 15 | ) 16 | @ActionRegistration( 17 | displayName = "#CTL_PythonPoetryShell", 18 | lazy = false, 19 | asynchronous = true 20 | ) 21 | @Messages("CTL_PythonPoetryShell=Shell") 22 | public final class PythonPoetryShell extends AbstractAction { 23 | 24 | PythonProject p; 25 | 26 | public PythonPoetryShell(PythonProject p) { 27 | putValue(Action.NAME, Bundle.CTL_PythonPoetryShell()); 28 | this.p = p; 29 | } 30 | 31 | public PythonPoetryShell() { 32 | } 33 | 34 | @Override 35 | public void actionPerformed(ActionEvent e) { 36 | PythonVEnvConsoleActionTopComponent pythonVEnvConsoleActionTopComponent 37 | = new PythonVEnvConsoleActionTopComponent(p, PythonProject.POETRY); 38 | pythonVEnvConsoleActionTopComponent.open(); 39 | pythonVEnvConsoleActionTopComponent.requestActive(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/poetry/PythonPoetryShow.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.poetry; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.io.IOException; 5 | import javax.swing.AbstractAction; 6 | import javax.swing.Action; 7 | import org.netbeans.api.extexecution.ExecutionService; 8 | import org.netbeans.api.project.ProjectUtils; 9 | import org.netbeans.modules.python.PythonOutputLine; 10 | import org.netbeans.modules.python.project.PythonProject; 11 | import org.netbeans.modules.python.PythonUtility; 12 | import org.openide.awt.ActionID; 13 | import org.openide.awt.ActionRegistration; 14 | import org.openide.filesystems.FileObject; 15 | import org.openide.filesystems.FileUtil; 16 | import org.openide.util.Exceptions; 17 | import org.openide.util.NbBundle.Messages; 18 | 19 | @ActionID( 20 | category = "Project", 21 | id = "org.netbeans.modules.python.poetry.PythonPoetryShow" 22 | ) 23 | @ActionRegistration( 24 | displayName = "#CTL_PythonPoetryShow", 25 | lazy = false, 26 | asynchronous = true 27 | ) 28 | @Messages("CTL_PythonPoetryShow=Show Packages") 29 | public final class PythonPoetryShow extends AbstractAction { 30 | 31 | PythonProject p; 32 | 33 | public PythonPoetryShow(PythonProject p) { 34 | putValue(Action.NAME, Bundle.CTL_PythonPoetryShow()); 35 | this.p = p; 36 | } 37 | 38 | public PythonPoetryShow() { 39 | } 40 | 41 | @Override 42 | public void actionPerformed(ActionEvent e) { 43 | try { 44 | FileObject projectDirectory = p.getProjectDirectory(); 45 | ProcessBuilder pb = new ProcessBuilder(); 46 | pb.directory(FileUtil.toFile(projectDirectory)); 47 | 48 | pb.command(PythonUtility.getProjectPythonExe(projectDirectory), "-m", "poetry", "show", "--tree"); 49 | PythonUtility.manageRunEnvs(pb); 50 | 51 | ExecutionService service = ExecutionService.newService(() -> pb.start(), 52 | PythonUtility.getExecutorDescriptor(new PythonOutputLine(), () -> { 53 | }, () -> { 54 | }, false, true), 55 | String.format("Poetry %s (%s)", Bundle.CTL_PythonPoetryShow(), 56 | ProjectUtils.getInformation(p).getDisplayName())); 57 | 58 | service.run(); 59 | } catch (IOException ex) { 60 | Exceptions.printStackTrace(ex); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/project/PythonProjectFactory.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.project; 2 | 3 | import java.io.IOException; 4 | import javax.swing.Icon; 5 | import org.netbeans.api.project.Project; 6 | import org.netbeans.api.project.ProjectManager; 7 | import org.netbeans.spi.project.ProjectFactory; 8 | import org.netbeans.spi.project.ProjectFactory2; 9 | import org.netbeans.spi.project.ProjectState; 10 | import org.openide.filesystems.FileObject; 11 | import org.openide.util.ImageUtilities; 12 | import org.openide.util.lookup.ServiceProvider; 13 | 14 | @ServiceProvider(service = ProjectFactory.class) 15 | public class PythonProjectFactory implements ProjectFactory2 { 16 | 17 | static final Icon IMAGE = ImageUtilities.image2Icon(ImageUtilities 18 | .loadImage("org/netbeans/modules/python/python-2.png", true)); 19 | 20 | //Specifies when a project is a project, i.e., 21 | //if "pyproject.toml" is present in a folder: 22 | @Override 23 | public boolean isProject(FileObject projectDirectory) { 24 | return isProject2(projectDirectory) != null; 25 | } 26 | 27 | //Specifies when the project will be opened, i.e., if the project exists: 28 | @Override 29 | public Project loadProject(FileObject dir, ProjectState state) 30 | throws IOException { 31 | return isProject(dir) ? new PythonProject(dir, state) : null; 32 | } 33 | 34 | @Override 35 | public void saveProject(final Project project) throws IOException, 36 | ClassCastException { 37 | // leave unimplemented for the moment 38 | } 39 | 40 | @Override 41 | public ProjectManager.Result isProject2(FileObject projectDirectory) { 42 | if (projectDirectory.getFileObject("pyproject.toml") != null 43 | || projectDirectory.getFileObject("setup.py") != null) { 44 | return new ProjectManager.Result(IMAGE); 45 | } 46 | return null; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/project/PythonProjectStateHandler.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.project; 2 | 3 | import org.netbeans.spi.project.ProjectState; 4 | 5 | /** 6 | * 7 | * @author albilu 8 | */ 9 | public class PythonProjectStateHandler { 10 | 11 | ProjectState state; 12 | 13 | public PythonProjectStateHandler(ProjectState state) { 14 | this.state = state; 15 | } 16 | 17 | public void mark() { 18 | state.markModified(); 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonBuildProperties.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import javax.swing.JComponent; 4 | import org.netbeans.modules.python.project.PythonProject; 5 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 6 | import org.openide.util.Lookup; 7 | import org.openide.util.NbBundle; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonBuildProperties 14 | implements ProjectCustomizer.CompositeCategoryProvider { 15 | 16 | private static final String GENERAL = "Build"; 17 | 18 | @ProjectCustomizer.CompositeCategoryProvider.Registration( 19 | projectType = "org-netbeans-modules-python", position = 25) 20 | public static PythonBuildProperties createBuild() { 21 | return new PythonBuildProperties(); 22 | } 23 | 24 | @NbBundle.Messages("LBL_Config_Build=Build") 25 | @Override 26 | public ProjectCustomizer.Category createCategory(Lookup lkp) { 27 | return ProjectCustomizer.Category.create( 28 | GENERAL, 29 | Bundle.LBL_Config_Build(), 30 | null); 31 | } 32 | 33 | @Override 34 | public JComponent createComponent(ProjectCustomizer.Category category, 35 | Lookup lkp) { 36 | return new PythonBuildPanel(lkp.lookup(PythonProject.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonCustomizerProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import java.awt.Dialog; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.io.IOException; 11 | import org.netbeans.api.project.ProjectManager; 12 | import org.netbeans.api.project.ProjectUtils; 13 | import org.netbeans.api.project.ui.ProjectProblems; 14 | import org.netbeans.modules.python.project.PythonProject; 15 | import org.netbeans.modules.python.project.PythonProjectProblemProvider; 16 | import org.netbeans.modules.python.PythonPropertiesNotifier; 17 | import org.netbeans.spi.project.ui.CustomizerProvider; 18 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 19 | import org.openide.util.Exceptions; 20 | import org.openide.util.lookup.Lookups; 21 | 22 | public class PythonCustomizerProvider implements CustomizerProvider { 23 | 24 | public final PythonProject project; 25 | 26 | public static final String CUSTOMIZER_FOLDER_PATH 27 | = "Projects/org-netbeans-modules-python/Customizer"; 28 | 29 | public PythonCustomizerProvider(PythonProject project) { 30 | this.project = project; 31 | } 32 | 33 | @Override 34 | public void showCustomizer() { 35 | Dialog dialog = ProjectCustomizer.createCustomizerDialog( 36 | //Path to layer folder: 37 | CUSTOMIZER_FOLDER_PATH, 38 | //Lookup, which must contain, at least, the Project: 39 | Lookups.fixed(project), 40 | //Preselected category: 41 | "General", 42 | //OK button listener: 43 | new OKOptionListener(), 44 | //HelpCtx for Help button of dialog: 45 | null); 46 | dialog.setTitle("Project Properties - " + ProjectUtils 47 | .getInformation(project).getDisplayName()); 48 | dialog.setVisible(true); 49 | } 50 | 51 | private class OKOptionListener implements ActionListener { 52 | 53 | @Override 54 | public void actionPerformed(ActionEvent e) { 55 | if (ProjectManager.getDefault().isModified(project)) { 56 | 57 | PythonGeneralPanel.setProperties(project); 58 | 59 | if (PythonRunPanel.scriptTextField != null) { 60 | PythonRunPanel.setProperties(project); 61 | } 62 | if (PythonBuildPanel.buildParamsTextField != null) { 63 | PythonBuildPanel.setProperties(project); 64 | } 65 | 66 | if (PythonTestPanel.testFrameworkComboBox != null) { 67 | PythonTestPanel.setProperties(project); 68 | } 69 | if (PythonPdocPanel.pdocParamsTextField != null) { 70 | PythonPdocPanel.setProperties(project); 71 | } 72 | 73 | if (ProjectProblems.isBroken(project)) { 74 | ProjectProblems.showAlert(project); 75 | } 76 | } 77 | 78 | PythonPropertiesNotifier.firePropertiesChange(); 79 | PythonProjectProblemProvider.problemsProviderSupport.fireProblemsChange(); 80 | try { 81 | ProjectManager.getDefault().saveProject(project); 82 | } catch (IOException ex) { 83 | Exceptions.printStackTrace(ex); 84 | } 85 | } 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonFrameworkCellRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import java.awt.Component; 4 | import javax.swing.DefaultListCellRenderer; 5 | import javax.swing.JLabel; 6 | import javax.swing.JList; 7 | import org.netbeans.modules.python.PythonUtility; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonFrameworkCellRenderer extends DefaultListCellRenderer { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @Override 18 | public Component getListCellRendererComponent( 19 | JList list, Object value, int index, 20 | boolean isSelected, boolean cellHasFocus) { 21 | 22 | JLabel label = (JLabel) super.getListCellRendererComponent( 23 | list, value, index, isSelected, cellHasFocus); 24 | 25 | switch ((String) value) { 26 | case ("unittest"): 27 | label.setIcon(PythonUtility.getPythonIcon()); 28 | label.setHorizontalTextPosition(JLabel.RIGHT); 29 | break; 30 | case ("pytest"): 31 | label.setIcon(PythonUtility.getPytestIcon()); 32 | label.setHorizontalTextPosition(JLabel.RIGHT); 33 | break; 34 | case ("pynguin"): 35 | label.setIcon(PythonUtility.getPynguinIcon()); 36 | label.setHorizontalTextPosition(JLabel.RIGHT); 37 | break; 38 | default: 39 | throw new AssertionError(); 40 | } 41 | return label; 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonGeneralProperties.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import javax.swing.JComponent; 8 | import org.netbeans.modules.python.project.PythonProject; 9 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 10 | import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category; 11 | import org.openide.util.Lookup; 12 | import org.openide.util.NbBundle; 13 | 14 | public class PythonGeneralProperties 15 | implements ProjectCustomizer.CompositeCategoryProvider { 16 | 17 | private static final String GENERAL = "General"; 18 | 19 | @ProjectCustomizer.CompositeCategoryProvider.Registration( 20 | projectType = "org-netbeans-modules-python", position = 10) 21 | public static PythonGeneralProperties createGeneral() { 22 | return new PythonGeneralProperties(); 23 | } 24 | 25 | @NbBundle.Messages("LBL_Config_General=General") 26 | @Override 27 | public Category createCategory(Lookup lkp) { 28 | return ProjectCustomizer.Category.create( 29 | GENERAL, 30 | Bundle.LBL_Config_General(), 31 | null); 32 | } 33 | 34 | @Override 35 | public JComponent createComponent(Category category, Lookup lkp) { 36 | return new PythonGeneralPanel(lkp.lookup(PythonProject.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonPdocProperties.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import javax.swing.JComponent; 4 | import org.netbeans.modules.python.project.PythonProject; 5 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 6 | import org.openide.util.Lookup; 7 | import org.openide.util.NbBundle; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonPdocProperties 14 | implements ProjectCustomizer.CompositeCategoryProvider { 15 | 16 | private static final String GENERAL = "Pdoc"; 17 | 18 | @ProjectCustomizer.CompositeCategoryProvider.Registration( 19 | projectType = "org-netbeans-modules-python", position = 35) 20 | public static PythonPdocProperties createPdoc() { 21 | return new PythonPdocProperties(); 22 | } 23 | 24 | @NbBundle.Messages("LBL_Config_Pdoc=Pdoc") 25 | @Override 26 | public ProjectCustomizer.Category createCategory(Lookup lkp) { 27 | return ProjectCustomizer.Category.create( 28 | GENERAL, 29 | Bundle.LBL_Config_Pdoc(), 30 | null); 31 | } 32 | 33 | @Override 34 | public JComponent createComponent(ProjectCustomizer.Category category, 35 | Lookup lkp) { 36 | return new PythonPdocPanel(lkp.lookup(PythonProject.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonPlatformCellRenderer.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import java.awt.Component; 4 | import javax.swing.DefaultListCellRenderer; 5 | import javax.swing.JLabel; 6 | import javax.swing.JList; 7 | import org.netbeans.modules.python.PythonUtility; 8 | import org.openide.util.Pair; 9 | 10 | /** 11 | * 12 | * @author albilu 13 | */ 14 | public class PythonPlatformCellRenderer extends DefaultListCellRenderer { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Override 19 | public Component getListCellRendererComponent( 20 | JList list, Object value, int index, 21 | boolean isSelected, boolean cellHasFocus) { 22 | 23 | JLabel label = (JLabel) super.getListCellRendererComponent( 24 | list, value, index, isSelected, cellHasFocus); 25 | 26 | if (value != null) { 27 | if (value instanceof Pair) { 28 | label.setIcon(PythonUtility.getPythonIcon()); 29 | label.setText(((Pair) value).first().toString()); 30 | label.setToolTipText(((Pair) value).second().toString()); 31 | } else { 32 | label.setIcon(value.toString().isBlank() ? null : PythonUtility.getPythonIcon()); 33 | label.setText(value.toString()); 34 | 35 | } 36 | label.setHorizontalTextPosition(JLabel.RIGHT); 37 | } 38 | return label; 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonRunProperties.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import javax.swing.JComponent; 4 | import org.netbeans.modules.python.project.PythonProject; 5 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 6 | import org.openide.util.Lookup; 7 | import org.openide.util.NbBundle; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonRunProperties 14 | implements ProjectCustomizer.CompositeCategoryProvider { 15 | 16 | private static final String GENERAL = "Run"; 17 | 18 | @ProjectCustomizer.CompositeCategoryProvider.Registration( 19 | projectType = "org-netbeans-modules-python", position = 20) 20 | public static PythonRunProperties createRun() { 21 | return new PythonRunProperties(); 22 | } 23 | 24 | @NbBundle.Messages("LBL_Config_Run=Run") 25 | @Override 26 | public ProjectCustomizer.Category createCategory(Lookup lkp) { 27 | return ProjectCustomizer.Category.create( 28 | GENERAL, 29 | Bundle.LBL_Config_Run(), 30 | null); 31 | } 32 | 33 | @Override 34 | public JComponent createComponent(ProjectCustomizer.Category category, 35 | Lookup lkp) { 36 | return new PythonRunPanel(lkp.lookup(PythonProject.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectproperties/PythonTestProperties.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectproperties; 2 | 3 | import javax.swing.JComponent; 4 | import org.netbeans.modules.python.project.PythonProject; 5 | import org.netbeans.spi.project.ui.support.ProjectCustomizer; 6 | import org.openide.util.Lookup; 7 | import org.openide.util.NbBundle; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonTestProperties 14 | implements ProjectCustomizer.CompositeCategoryProvider { 15 | 16 | private static final String GENERAL = "Test"; 17 | 18 | @ProjectCustomizer.CompositeCategoryProvider.Registration( 19 | projectType = "org-netbeans-modules-python", position = 30) 20 | public static PythonTestProperties createTest() { 21 | return new PythonTestProperties(); 22 | } 23 | 24 | @NbBundle.Messages("LBL_Config_Test=Test") 25 | @Override 26 | public ProjectCustomizer.Category createCategory(Lookup lkp) { 27 | return ProjectCustomizer.Category.create( 28 | GENERAL, 29 | Bundle.LBL_Config_Test(), 30 | null); 31 | } 32 | 33 | @Override 34 | public JComponent createComponent(ProjectCustomizer.Category category, 35 | Lookup lkp) { 36 | return new PythonTestPanel(lkp.lookup(PythonProject.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectsample/PythonExtSourceProjectWizardPanel.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectsample; 2 | 3 | import java.awt.Component; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | import javax.swing.event.ChangeEvent; 7 | import javax.swing.event.ChangeListener; 8 | import org.openide.WizardDescriptor; 9 | import org.openide.WizardValidationException; 10 | import org.openide.util.HelpCtx; 11 | import org.openide.util.NbBundle; 12 | 13 | /** 14 | * Panel just asking for basic info. 15 | */ 16 | public class PythonExtSourceProjectWizardPanel implements WizardDescriptor.Panel, 17 | WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { 18 | 19 | private WizardDescriptor wizardDescriptor; 20 | private PythonExtSourceProjectPanelVisual component; 21 | 22 | public PythonExtSourceProjectWizardPanel() { 23 | } 24 | 25 | @Override 26 | public Component getComponent() { 27 | if (component == null) { 28 | component = new PythonExtSourceProjectPanelVisual(this); 29 | component.setName(NbBundle.getMessage(PythonExtSourceProjectWizardPanel.class, "LBL_CreateProjectStep")); 30 | } 31 | return component; 32 | } 33 | 34 | @Override 35 | public HelpCtx getHelp() { 36 | return new HelpCtx("org.netbeans.modules.python.projectsample.PythonExtSourceProjectWizardPanel"); 37 | } 38 | 39 | @Override 40 | public boolean isValid() { 41 | getComponent(); 42 | return component.valid(wizardDescriptor); 43 | } 44 | 45 | private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 46 | 47 | @Override 48 | public final void addChangeListener(ChangeListener l) { 49 | synchronized (listeners) { 50 | listeners.add(l); 51 | } 52 | } 53 | 54 | @Override 55 | public final void removeChangeListener(ChangeListener l) { 56 | synchronized (listeners) { 57 | listeners.remove(l); 58 | } 59 | } 60 | 61 | protected final void fireChangeEvent() { 62 | Set ls; 63 | synchronized (listeners) { 64 | ls = new HashSet<>(listeners); 65 | } 66 | ChangeEvent ev = new ChangeEvent(this); 67 | for (ChangeListener l : ls) { 68 | l.stateChanged(ev); 69 | } 70 | } 71 | 72 | @Override 73 | public void readSettings(Object settings) { 74 | wizardDescriptor = (WizardDescriptor) settings; 75 | component.read(wizardDescriptor); 76 | } 77 | 78 | @Override 79 | public void storeSettings(Object settings) { 80 | WizardDescriptor d = (WizardDescriptor) settings; 81 | component.store(d); 82 | } 83 | 84 | @Override 85 | public boolean isFinishPanel() { 86 | return true; 87 | } 88 | 89 | @Override 90 | public void validate() throws WizardValidationException { 91 | getComponent(); 92 | component.validate(wizardDescriptor); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectsample/PythonPoetryWizardPanel.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectsample; 2 | 3 | import java.awt.Component; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | import javax.swing.event.ChangeEvent; 7 | import javax.swing.event.ChangeListener; 8 | import org.openide.WizardDescriptor; 9 | import org.openide.WizardValidationException; 10 | import org.openide.util.HelpCtx; 11 | import org.openide.util.NbBundle; 12 | 13 | /** 14 | * Panel just asking for basic info. 15 | */ 16 | public class PythonPoetryWizardPanel implements WizardDescriptor.Panel, 17 | WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { 18 | 19 | private WizardDescriptor wizardDescriptor; 20 | private PythonPoetryPanelVisual component; 21 | 22 | public PythonPoetryWizardPanel() { 23 | } 24 | 25 | @Override 26 | public Component getComponent() { 27 | if (component == null) { 28 | component = new PythonPoetryPanelVisual(this); 29 | component.setName(NbBundle.getMessage(PythonPoetryWizardPanel.class, "LBL_CreateProjectStep")); 30 | } 31 | return component; 32 | } 33 | 34 | @Override 35 | public HelpCtx getHelp() { 36 | return new HelpCtx("org.netbeans.modules.python.projectsample.PythonPoetryWizardPanel"); 37 | } 38 | 39 | @Override 40 | public boolean isValid() { 41 | getComponent(); 42 | return component.valid(wizardDescriptor); 43 | } 44 | 45 | private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 46 | 47 | @Override 48 | public final void addChangeListener(ChangeListener l) { 49 | synchronized (listeners) { 50 | listeners.add(l); 51 | } 52 | } 53 | 54 | @Override 55 | public final void removeChangeListener(ChangeListener l) { 56 | synchronized (listeners) { 57 | listeners.remove(l); 58 | } 59 | } 60 | 61 | protected final void fireChangeEvent() { 62 | Set ls; 63 | synchronized (listeners) { 64 | ls = new HashSet<>(listeners); 65 | } 66 | ChangeEvent ev = new ChangeEvent(this); 67 | for (ChangeListener l : ls) { 68 | l.stateChanged(ev); 69 | } 70 | } 71 | 72 | @Override 73 | public void readSettings(Object settings) { 74 | wizardDescriptor = (WizardDescriptor) settings; 75 | component.read(wizardDescriptor); 76 | } 77 | 78 | @Override 79 | public void storeSettings(Object settings) { 80 | WizardDescriptor d = (WizardDescriptor) settings; 81 | component.store(d); 82 | } 83 | 84 | @Override 85 | public boolean isFinishPanel() { 86 | return true; 87 | } 88 | 89 | @Override 90 | public void validate() throws WizardValidationException { 91 | getComponent(); 92 | component.validate(wizardDescriptor); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/projectsample/PythonProjectWizardPanel.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.projectsample; 2 | 3 | import java.awt.Component; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | import javax.swing.event.ChangeEvent; 7 | import javax.swing.event.ChangeListener; 8 | import org.openide.WizardDescriptor; 9 | import org.openide.WizardValidationException; 10 | import org.openide.util.HelpCtx; 11 | import org.openide.util.NbBundle; 12 | 13 | /** 14 | * Panel just asking for basic info. 15 | */ 16 | public class PythonProjectWizardPanel implements WizardDescriptor.Panel, 17 | WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel { 18 | 19 | private WizardDescriptor wizardDescriptor; 20 | private PythonProjectPanelVisual component; 21 | 22 | public PythonProjectWizardPanel() { 23 | } 24 | 25 | @Override 26 | public Component getComponent() { 27 | if (component == null) { 28 | component = new PythonProjectPanelVisual(this); 29 | component.setName(NbBundle.getMessage(PythonProjectWizardPanel.class, 30 | "LBL_CreateProjectStep")); 31 | } 32 | return component; 33 | } 34 | 35 | @Override 36 | public HelpCtx getHelp() { 37 | return new HelpCtx("org.netbeans.modules.python.projectsample.PythonProjectWizardPanel"); 38 | } 39 | 40 | @Override 41 | public boolean isValid() { 42 | getComponent(); 43 | return component.valid(wizardDescriptor); 44 | } 45 | 46 | private final Set listeners = new HashSet<>(1); 47 | // or can use ChangeSupport in NB 6.0 48 | 49 | @Override 50 | public final void addChangeListener(ChangeListener l) { 51 | synchronized (listeners) { 52 | listeners.add(l); 53 | } 54 | } 55 | 56 | @Override 57 | public final void removeChangeListener(ChangeListener l) { 58 | synchronized (listeners) { 59 | listeners.remove(l); 60 | } 61 | } 62 | 63 | protected final void fireChangeEvent() { 64 | Set ls; 65 | synchronized (listeners) { 66 | ls = new HashSet<>(listeners); 67 | } 68 | ChangeEvent ev = new ChangeEvent(this); 69 | for (ChangeListener l : ls) { 70 | l.stateChanged(ev); 71 | } 72 | } 73 | 74 | @Override 75 | public void readSettings(Object settings) { 76 | wizardDescriptor = (WizardDescriptor) settings; 77 | component.read(wizardDescriptor); 78 | } 79 | 80 | @Override 81 | public void storeSettings(Object settings) { 82 | WizardDescriptor d = (WizardDescriptor) settings; 83 | component.store(d); 84 | } 85 | 86 | @Override 87 | public boolean isFinishPanel() { 88 | return true; 89 | } 90 | 91 | @Override 92 | public void validate() throws WizardValidationException { 93 | getComponent(); 94 | component.validate(wizardDescriptor); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/repl/IPythonTopComponent.form: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/repl/PtPythonTopComponent.form: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/repl/PythonVEnvConsoleActionTopComponent.form: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/statusbar/PythonStatusBar.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.statusbar; 2 | 3 | import java.awt.Component; 4 | import org.openide.awt.StatusLineElementProvider; 5 | import org.openide.util.lookup.ServiceProvider; 6 | 7 | /** 8 | * 9 | * @author albilu 10 | */ 11 | @ServiceProvider(service = StatusLineElementProvider.class) 12 | public class PythonStatusBar implements StatusLineElementProvider { 13 | 14 | @Override 15 | public Component getStatusLineElement() { 16 | return new PythonStatusBarPanel(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/statusbar/PythonStatusBarPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
60 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/tasklist/PythonActionItems.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.tasklist; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Paths; 5 | import java.util.ArrayList; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import org.apache.commons.lang3.StringUtils; 9 | import org.netbeans.modules.editor.hints.AnnotationHolder; 10 | import org.netbeans.modules.python.PythonUtility; 11 | import org.netbeans.spi.editor.hints.ErrorDescription; 12 | import org.netbeans.spi.editor.hints.Severity; 13 | import org.netbeans.spi.tasklist.FileTaskScanner; 14 | import org.netbeans.spi.tasklist.Task; 15 | import org.openide.filesystems.FileObject; 16 | import org.openide.util.Exceptions; 17 | import org.openide.util.lookup.ServiceProvider; 18 | 19 | /** 20 | * 21 | * @author albilu 22 | */ 23 | @ServiceProvider(service = FileTaskScanner.class, path = "TaskList/Scanners") 24 | public class PythonActionItems extends FileTaskScanner { 25 | 26 | private static final String TASKLIST_ERROR = "nb-tasklist-error"; 27 | private static final String TASKLIST_WARNING = "nb-tasklist-warning"; 28 | 29 | public PythonActionItems() { 30 | super("Python Hints", "Python Files Hints", null); 31 | } 32 | 33 | @Override 34 | public List scan(FileObject resource) { 35 | //FIXME-EXTERNAL: PythonDiagCollector is a hack as Full project diagnostic is not available yet with pylsp see: 36 | ////https://github.com/python-lsp/python-lsp-server/discussions/280 37 | //For now Full project Action items will report flake8 based diagnostics (Disabled) 38 | //This feature will also serve for Error badge 39 | //StatusDisplayer.getDefault().setStatusText("Project ActionsItems not available yet!"); 40 | if (!resource.getExt().equals("py") || StringUtils.containsAny( 41 | Paths.get(resource.getPath()).toString(), PythonUtility.EXCLUDED_DIRS)) { 42 | return Collections.EMPTY_LIST; 43 | } 44 | AnnotationHolder ah = AnnotationHolder.getInstance(resource); 45 | if (ah == null) { 46 | return Collections.EMPTY_LIST; 47 | } 48 | List errors = ah.getErrors(); 49 | List tasks = new ArrayList<>(); 50 | if (/*PythonDiagCollector.errors*/errors != null) { 51 | /*PythonDiagCollector.errors*/ 52 | errors.forEach(error -> { 53 | try { 54 | Task task = Task.create(error.getFile(), 55 | severityToTaskListString(error.getSeverity()), 56 | error.getDescription(), 57 | error.getRange().getBegin().getLine() + 1); 58 | 59 | tasks.add(task); 60 | } catch (IOException ex) { 61 | Exceptions.printStackTrace(ex); 62 | } 63 | }); 64 | } 65 | return tasks; 66 | } 67 | 68 | private static String severityToTaskListString(Severity severity) { 69 | if (severity == Severity.ERROR) { 70 | return TASKLIST_ERROR; 71 | } 72 | return TASKLIST_WARNING; 73 | } 74 | 75 | @Override 76 | public void attach(Callback callback) { 77 | if (callback != null) { 78 | callback.refreshAll(); 79 | } 80 | } 81 | 82 | @Override 83 | public void notifyFinish() { 84 | super.notifyFinish(); 85 | } 86 | 87 | @Override 88 | public void notifyPrepare() { 89 | super.notifyPrepare(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonPingyinTestCreator.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import org.netbeans.api.project.FileOwnerQuery; 4 | import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider; 5 | import org.netbeans.modules.python.project.PythonProject; 6 | import org.netbeans.modules.python.actions.PythonGenerateTest; 7 | import org.openide.filesystems.FileObject; 8 | import org.openide.loaders.DataObject; 9 | import org.openide.loaders.DataObjectNotFoundException; 10 | import org.openide.util.Exceptions; 11 | import org.openide.util.RequestProcessor; 12 | 13 | /** 14 | * 15 | * @author albilu 16 | */ 17 | @TestCreatorProvider.Registration(identifier = "PythonPynguin", displayName = "Pynguin") 18 | public class PythonPingyinTestCreator extends TestCreatorProvider { 19 | 20 | RequestProcessor RP = new RequestProcessor(this.getClass() 21 | .getName(), 2); 22 | 23 | @Override 24 | public boolean enable(FileObject[] activatedFOs) { 25 | if (activatedFOs == null || activatedFOs.length == 0) { 26 | return false; 27 | } 28 | return activatedFOs.length == 1 && !activatedFOs[0].isFolder() 29 | && FileOwnerQuery.getOwner(activatedFOs[0]) instanceof PythonProject; 30 | } 31 | 32 | @Override 33 | public void createTests(Context context) { 34 | RP.post(() -> { 35 | try { 36 | PythonGenerateTest.runAction(DataObject.find(context.getActivatedFOs()[0])); 37 | } catch (DataObjectNotFoundException ex) { 38 | Exceptions.printStackTrace(ex); 39 | } 40 | }); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonPyTestCreator.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import org.netbeans.api.project.FileOwnerQuery; 4 | import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider; 5 | import org.netbeans.modules.python.project.PythonProject; 6 | import org.openide.filesystems.FileObject; 7 | import org.openide.util.RequestProcessor; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | @TestCreatorProvider.Registration(identifier = "PythonPyTest", displayName = "PyTest") 14 | public class PythonPyTestCreator extends TestCreatorProvider { 15 | 16 | RequestProcessor RP = new RequestProcessor(this.getClass() 17 | .getName(), 2); 18 | 19 | @Override 20 | public boolean enable(FileObject[] activatedFOs) { 21 | if (activatedFOs == null || activatedFOs.length == 0) { 22 | return false; 23 | } 24 | return FileOwnerQuery.getOwner(activatedFOs[0]) instanceof PythonProject; 25 | } 26 | 27 | @Override 28 | public void createTests(Context context) { 29 | RP.post(() -> { 30 | PythonTestCreatorUtility.createTests(context, "Templates/Python/PythonPytest.py"); 31 | }); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTemplateAttributesProvider.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import org.netbeans.api.templates.CreateDescriptor; 6 | import org.netbeans.api.templates.CreateFromTemplateAttributes; 7 | import org.openide.util.lookup.ServiceProvider; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | @ServiceProvider(service = CreateFromTemplateAttributes.class) 14 | public class PythonTemplateAttributesProvider implements CreateFromTemplateAttributes { 15 | 16 | @Override 17 | public Map attributesFor(CreateDescriptor desc) { 18 | Map parameters = desc.getParameters(); 19 | HashMap computedParams = new HashMap<>(); 20 | computedParams.putAll(parameters); 21 | computedParams.putIfAbsent("className", desc.getProposedName()); 22 | computedParams.putIfAbsent("methodName", "test_0"); 23 | return computedParams; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestCase.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import org.netbeans.modules.gsf.testrunner.api.TestSession; 4 | import org.netbeans.modules.gsf.testrunner.api.Testcase; 5 | 6 | /** 7 | * 8 | * @author albilu 9 | */ 10 | public class PythonTestCase extends Testcase { 11 | 12 | public PythonTestCase(String name, String type, TestSession session) { 13 | super(name, type, session); 14 | } 15 | 16 | public PythonTestCase(String name, String display, String type, TestSession session) { 17 | super(name, display, type, session); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestCreator.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.List; 7 | import java.util.regex.Pattern; 8 | import org.apache.commons.io.FilenameUtils; 9 | import org.netbeans.api.project.FileOwnerQuery; 10 | import org.netbeans.api.project.ProjectUtils; 11 | import org.netbeans.api.project.SourceGroup; 12 | import org.netbeans.modules.gsf.testrunner.ui.spi.TestCreatorConfiguration; 13 | import org.openide.filesystems.FileObject; 14 | import org.openide.filesystems.FileUtil; 15 | import org.openide.util.Pair; 16 | 17 | /** 18 | * 19 | * @author albilu 20 | */ 21 | public class PythonTestCreator extends TestCreatorConfiguration { 22 | 23 | @Override 24 | public boolean canHandleProject(String string) { 25 | return true; 26 | } 27 | 28 | @Override 29 | public void persistConfigurationPanel(TestCreatorConfiguration.Context cntxt) { 30 | } 31 | 32 | @Override 33 | public Object[] getTestSourceRoots(Collection clctn, FileObject fo) { 34 | List folders = new ArrayList<>(); 35 | SourceGroup[] sourceGroups = ProjectUtils.getSources(FileOwnerQuery 36 | .getOwner(fo)).getSourceGroups("testsources"); 37 | for (SourceGroup sg : sourceGroups) { 38 | if (!sg.contains(fo)) { 39 | if (!folders.contains(sg.getRootFolder())) { 40 | folders.add(sg); 41 | } 42 | } 43 | } 44 | return folders.toArray(); 45 | } 46 | 47 | @Override 48 | public Pair getSourceAndTestClassNames(FileObject fo, boolean bln, boolean bln1) { 49 | // FIXME-NETBEANS: Needs to end absolutly with "Test". This is a bug 50 | // https://github.com/apache/netbeans/blob/c084119009d2e0f736f225d706bc1827af283501/php/php.codeception/src/org/netbeans/modules/php/codeception/create/CodeceptionTestCreatorConfiguration.java#L114 51 | return Pair.of(fo.getName(), FilenameUtils 52 | .removeExtension(FileUtil 53 | .getRelativePath(FileOwnerQuery.getOwner(fo).getProjectDirectory(), fo)) 54 | .replaceAll(Pattern.quote(File.separator), ".") + "Test"); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestCreatorConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import org.netbeans.modules.gsf.testrunner.ui.spi.TestCreatorConfiguration; 4 | import org.netbeans.modules.gsf.testrunner.ui.spi.TestCreatorConfigurationProvider; 5 | import org.openide.filesystems.FileObject; 6 | import org.openide.util.lookup.ServiceProvider; 7 | 8 | /** 9 | * 10 | * @author albilu 11 | */ 12 | @ServiceProvider(service = TestCreatorConfigurationProvider.class, position = 100) 13 | public class PythonTestCreatorConfiguration implements TestCreatorConfigurationProvider { 14 | 15 | @Override 16 | public TestCreatorConfiguration createTestCreatorConfiguration(FileObject[] fos) { 17 | return new PythonTestCreator(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestManager.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import java.io.IOException; 4 | import java.util.Properties; 5 | import org.netbeans.api.project.Project; 6 | import org.netbeans.api.project.ProjectUtils; 7 | import org.netbeans.modules.gsf.testrunner.api.TestSession; 8 | import org.netbeans.modules.gsf.testrunner.ui.api.Manager; 9 | import org.netbeans.modules.python.PythonUtility; 10 | import org.netbeans.modules.python.project.PythonProject; 11 | import org.openide.util.Exceptions; 12 | 13 | /** 14 | * 15 | * @author albilu 16 | */ 17 | public class PythonTestManager { 18 | 19 | public static TestSession getSession(Project owner, String runner) { 20 | return new TestSession(ProjectUtils.getInformation(owner).getName() + " (" + runner + ")", 21 | owner, TestSession.SessionType.TEST); 22 | } 23 | 24 | public static Manager getTestManager() { 25 | Manager manager = Manager.getInstance(); 26 | manager.setNodeFactory(new PythonTestNodeFactory()); 27 | return manager; 28 | } 29 | 30 | public static Object[] getTestRunParams(PythonProject project) { 31 | try { 32 | Properties prop = PythonUtility.getProperties(project, false); 33 | return new Object[]{prop.getProperty("nbproject.test.runner", "unittest"), 34 | PythonUtility.getParamsTokenizer().reset( 35 | prop.getProperty("nbproject.test.params", "*Test.py")).getTokenArray()}; 36 | } catch (IOException ex) { 37 | Exceptions.printStackTrace(ex); 38 | } 39 | return null; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestMethodAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | package org.netbeans.modules.python.testrunner; 6 | 7 | import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodController; 8 | import org.openide.text.Annotation; 9 | import org.openide.util.NbBundle; 10 | 11 | /** 12 | * 13 | * @author albilu 14 | */ 15 | //Copy from org/netbeans/modules/gsf/testrunner/ui/annotation/TestMethodAnnotation.java 16 | public class PythonTestMethodAnnotation extends Annotation { 17 | 18 | public static final Object DOCUMENT_METHODS_KEY = new Object() { 19 | }; 20 | public static final Object DOCUMENT_ANNOTATIONS_KEY = new Object() { 21 | }; 22 | public static final Object DOCUMENT_ANNOTATION_LINES_KEY = new Object() { 23 | }; 24 | 25 | private final TestMethodController.TestMethod testMethod; 26 | 27 | public PythonTestMethodAnnotation(TestMethodController.TestMethod testMethod) { 28 | this.testMethod = testMethod; 29 | } 30 | 31 | @Override 32 | public String getAnnotationType() { 33 | return "org-netbeans-modules-python-testrunner-runnable-test-annotation"; 34 | } 35 | 36 | @Override 37 | @NbBundle.Messages({ 38 | "# {0} - the name of the method", 39 | "SD_TestMethod=Test Method: {0}" 40 | }) 41 | public String getShortDescription() { 42 | return Bundle.SD_TestMethod(testMethod.method().getMethodName()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestParser.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import java.util.Collection; 4 | import javax.swing.event.ChangeListener; 5 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 6 | import org.netbeans.modules.parsing.api.Snapshot; 7 | import org.netbeans.modules.parsing.api.Task; 8 | import org.netbeans.modules.parsing.spi.ParseException; 9 | import org.netbeans.modules.parsing.spi.Parser; 10 | import org.netbeans.modules.parsing.spi.ParserFactory; 11 | import org.netbeans.modules.parsing.spi.SourceModificationEvent; 12 | import org.netbeans.modules.python.PythonUtility; 13 | import org.openide.util.RequestProcessor; 14 | 15 | /** 16 | * 17 | * @author albilu 18 | */ 19 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = ParserFactory.class) 20 | public class PythonTestParser extends ParserFactory { 21 | 22 | @Override 23 | public Parser createParser(Collection snapshots) { 24 | return new PythonParser(); 25 | } 26 | 27 | private static class PythonParser extends Parser { 28 | 29 | static RequestProcessor RP = new RequestProcessor(PythonParser.class); 30 | 31 | @Override 32 | public void parse(Snapshot snapshot, Task task, SourceModificationEvent event) throws ParseException { 33 | RP.post(() -> PythonTestMethodController.setMethods(snapshot)); 34 | } 35 | 36 | @Override 37 | public Result getResult(Task task) throws ParseException { 38 | return null; 39 | } 40 | 41 | @Override 42 | public void addChangeListener(ChangeListener changeListener) { 43 | } 44 | 45 | @Override 46 | public void removeChangeListener(ChangeListener changeListener) { 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestParserTask.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import org.netbeans.modules.parsing.spi.Parser.Result; 8 | import org.netbeans.modules.parsing.spi.ParserResultTask; 9 | import org.netbeans.modules.parsing.spi.Scheduler; 10 | import org.netbeans.modules.parsing.spi.SchedulerEvent; 11 | 12 | public class PythonTestParserTask extends ParserResultTask { 13 | 14 | @Override 15 | public void run(Result result, SchedulerEvent event) { 16 | } 17 | 18 | @Override 19 | public int getPriority() { 20 | return 100; 21 | } 22 | 23 | @Override 24 | public Class getSchedulerClass() { 25 | return Scheduler.EDITOR_SENSITIVE_TASK_SCHEDULER; 26 | } 27 | 28 | @Override 29 | public void cancel() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestResultsTopComponent.form: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestRunner.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import java.io.File; 4 | import org.netbeans.modules.gsf.testrunner.api.TestSession; 5 | import org.netbeans.modules.gsf.testrunner.ui.api.Manager; 6 | import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodController; 7 | import org.netbeans.modules.python.project.PythonProject; 8 | import org.openide.loaders.DataObject; 9 | 10 | /** 11 | * 12 | * @author albilu 13 | */ 14 | public interface PythonTestRunner { 15 | 16 | void runSingleTest(PythonProject project, DataObject dob); 17 | 18 | void runAllTests(PythonProject project, DataObject dob); 19 | 20 | void runTestMethod(PythonProject project, TestMethodController.TestMethod lookup); 21 | 22 | void runner(PythonProject project, Manager manager, TestSession testSession, ProcessBuilder pb, String projectPythonExe, File testRunner); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestSuite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | package org.netbeans.modules.python.testrunner; 6 | 7 | import org.netbeans.modules.gsf.testrunner.api.TestSuite; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | public class PythonTestSuite extends TestSuite { 14 | 15 | public PythonTestSuite(String name) { 16 | super(name); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonTestTaskFactory.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | /** 4 | * 5 | * @author albilu 6 | */ 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import org.netbeans.api.editor.mimelookup.MimeRegistration; 10 | import org.netbeans.modules.parsing.api.Snapshot; 11 | import org.netbeans.modules.parsing.spi.TaskFactory; 12 | import org.netbeans.modules.python.PythonUtility; 13 | 14 | @MimeRegistration(mimeType = PythonUtility.PYTHON_MIME_TYPE, service = TaskFactory.class) 15 | public class PythonTestTaskFactory extends TaskFactory { 16 | 17 | @Override 18 | public Collection create(Snapshot snapshot) { 19 | return Collections.singleton(new PythonTestParserTask()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/netbeans/modules/python/testrunner/PythonUnitTestCreator.java: -------------------------------------------------------------------------------- 1 | package org.netbeans.modules.python.testrunner; 2 | 3 | import org.netbeans.api.project.FileOwnerQuery; 4 | import org.netbeans.modules.gsf.testrunner.api.TestCreatorProvider; 5 | import org.netbeans.modules.python.project.PythonProject; 6 | import org.openide.filesystems.FileObject; 7 | import org.openide.util.RequestProcessor; 8 | 9 | /** 10 | * 11 | * @author albilu 12 | */ 13 | @TestCreatorProvider.Registration(identifier = "PythonUnitTest", displayName = "UnitTest") 14 | public class PythonUnitTestCreator extends TestCreatorProvider { 15 | 16 | RequestProcessor RP = new RequestProcessor(this.getClass() 17 | .getName(), 2); 18 | 19 | @Override 20 | public boolean enable(FileObject[] activatedFOs) { 21 | if (activatedFOs == null || activatedFOs.length == 0) { 22 | return false; 23 | } 24 | return FileOwnerQuery.getOwner(activatedFOs[0]) instanceof PythonProject; 25 | } 26 | 27 | @Override 28 | public void createTests(Context context) { 29 | RP.post(() -> { 30 | PythonTestCreatorUtility.createTests(context, "Templates/Python/PythonUnittest.py"); 31 | }); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/debugger/PYthonSession/org.netbeans.modules.python.debugger.PythonDebugger: -------------------------------------------------------------------------------- 1 | org.netbeans.modules.python.debugger.PythonDebugger -------------------------------------------------------------------------------- /src/main/resources/META-INF/debugger/PYthonSession/org.netbeans.spi.debugger.DebuggerEngineProvider: -------------------------------------------------------------------------------- 1 | org.netbeans.modules.python.debugger.PythonDebuggerProvider -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/Bundle.properties: -------------------------------------------------------------------------------- 1 | #Localized module labels. Defaults taken from POM (, , ) if unset. 2 | OpenIDE-Module-Name=Python 3 | text/x-python=Python 4 | NewJPanel.jLabel1.text=jLabel1 5 | NewJPanel.jLabel2.text=jLabel2 6 | LAB_runnable-test-annotation=Runnable Test 7 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/Classes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/Classes.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/EmptyPython.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Created on : ${date}, ${time} 4 | # Author : ${user} 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/Python.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Created on : ${date}, ${time} 4 | # Author : ${user} 5 | 6 | 7 | # This is a sample Python script. 8 | 9 | # Press Shift+F6 to execute it or replace it with your code. 10 | 11 | 12 | def print_hi(name): 13 | print(f"Hi, {name}") 14 | 15 | 16 | if __name__ == "__main__": 17 | print_hi("Netbeans") 18 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/PythonDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Creates a Simple Python File 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/PythonPyTestDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Creates a Simple PyTest File 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/PythonPytest.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Created on : ${date}, ${time} 4 | # Author : ${user} 5 | 6 | import pytest 7 | 8 | 9 | def ${methodName}(): 10 | assert False # This test fail -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/PythonUnitTestDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Creates a Simple Python Unit Test File 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/PythonUnittest.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Created on : ${date}, ${time} 4 | # Author : ${user} 5 | 6 | import unittest 7 | 8 | 9 | class ${className}(unittest.TestCase): 10 | 11 | @classmethod 12 | def setUpClass(cls): 13 | # add instructions 14 | 15 | pass 16 | 17 | @classmethod 18 | def tearDownClass(cls): 19 | # add instructions 20 | 21 | pass 22 | 23 | def setUp(self): 24 | # add instructions 25 | 26 | pass 27 | 28 | def tearDown(self): 29 | # add instructions 30 | 31 | pass 32 | 33 | @unittest.expectedFailure 34 | def ${methodName}(self): 35 | self.assertEqual(True, False, 'This test is not correct') # add assertion here 36 | 37 | 38 | if __name__ == "__main__": 39 | unittest.main() 40 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/config-badge.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/config-badge.gif -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/Breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/debugger/Breakpoint.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/Bundle.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | PythonBreakpointCustomizerPanel.fileLabel.text=&File: 19 | PythonBreakpointCustomizerPanel.lineLabel.text=&Line Number: 20 | PythonBreakpointCustomizerPanel.conditionCheckBox.text=&Condition: 21 | PythonBreakpointCustomizerPanel.conditionComboBox.toolTipText=Breakpoint is hit when this condition evaluates to true. 22 | PythonBreakpointCustomizerPanel.lineTextField.toolTipText=The line number to break at 23 | PythonBreakpointCustomizerPanel.fileTextField.toolTipText=The file to break in 24 | #Annotations 25 | HINT_CURRENT_PC2=XXX Current Ant Target 26 | HINT_CURRENT_PCPart=XXX Next Ant Target 27 | HINT_CURRENT_PC2Part=XXX Ant Targets 28 | HINT_CURRENT_PC2_BP=XXX Current Ant Target + Breakpoint 29 | HINT_CURRENT_PC2_DBP=XXX Current Ant Target + Disabled Breakpoint 30 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/CurrentPC2.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 32 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/CurrentPC2LinePart.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 32 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/CurrentPC2_BP.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/CurrentPC2_DBP.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/CurrentPCLinePart.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 33 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/DisabledBreakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/debugger/DisabledBreakpoint.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/PC.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/debugger/PC.gif -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/attach/Bundle.properties: -------------------------------------------------------------------------------- 1 | # Process ID 2 | PythonDebuggerAttachCustomizer.processPID.text=PID 3 | PythonDebuggerAttachCustomizer.processCommand.text=Command 4 | PythonDebuggerAttachCustomizer.dbgLabel.text=Debu&gger: 5 | PythonDebuggerAttachCustomizer.attachLabel.text=&Attach to selected process: {0, choice, 0#none|0<{0,number,'#'}} 6 | PythonDebuggerAttachCustomizer.dbgTextField.text=Python 7 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/breakpoints/Bundle.properties: -------------------------------------------------------------------------------- 1 | 2 | PythonBreakpointCustomizerPanel.conditionComboBox.toolTipText=Breakpoint is hit when this condition evaluates to true. 3 | PythonBreakpointCustomizerPanel.conditionCheckBox.text=&Condition: 4 | PythonBreakpointCustomizerPanel.lineTextField.toolTipText=The line number to break at 5 | PythonBreakpointCustomizerPanel.lineLabel.text=&Line Number: 6 | PythonBreakpointCustomizerPanel.fileTextField.toolTipText=The file to break in 7 | # Licensed to the Apache Software Foundation (ASF) under one 8 | # or more contributor license agreements. See the NOTICE file 9 | # distributed with this work for additional information 10 | # regarding copyright ownership. The ASF licenses this file 11 | # to you under the Apache License, Version 2.0 (the 12 | # "License"); you may not use this file except in compliance 13 | # with the License. You may obtain a copy of the License at 14 | 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | # Unless required by applicable law or agreed to in writing, 18 | # software distributed under the License is distributed on an 19 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 20 | # KIND, either express or implied. See the License for the 21 | # specific language governing permissions and limitations 22 | # under the License. 23 | PythonBreakpointCustomizerPanel.fileLabel.text=&File: 24 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/debugger/restart24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/debugger/restart24.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/envs.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/error-badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/error-badge.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/find16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/find16.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/indexing/Bundle.properties: -------------------------------------------------------------------------------- 1 | TP_ErrorBadgeSingle=Error parsing file. 2 | TP_ErrorBadgeFolder=Contains files with errors. 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/ipython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/ipython.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/libraries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/libraries.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/methodPublic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/methodPublic.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/options/Bundle.properties: -------------------------------------------------------------------------------- 1 | PythonLspServerConfigsPanel.lspServerCheckBox.text=Auto Update LSP Server on startup 2 | PythonLspServerConfigsPanel.lspServerLabel.text= 3 | PythonPlatformPanel.makePlatformDefault.text=Make Default 4 | PythonPlatformPanel.command.text= 5 | PythonPlatformPanel.platformName.text= 6 | PythonPlatformPanel.autoDetectPlatform.text=Auto Detect 7 | PythonPlatformPanel.removePlatform.text=Remove 8 | PythonPlatformPanel.newPlatform.text=New 9 | PythonLspServerConfigsPanel.lspSettingsScrollPane.border.title=Configuration 10 | PythonPlatformPanel.platformLabel.text=Platforms 11 | PythonPlatformPanel.mainPanel.TabConstraints.tabTitle=Main 12 | PythonPlatformPanel.platformNameLabel.text=Platform Name 13 | PythonPlatformPanel.platformCommandLabel.text=Command 14 | PythonPlatformPanel.sysPathPanel.TabConstraints.tabTitle=Python SysPath 15 | PythonPlatformPanel.sysPathLabel.text=Get Python System Path 16 | PythonLspServerConfigsPanel.lspPythonVersionLabel.text= 17 | PythonCodeCompletionOptionPanel.jCheckBox1.text=Auto Popup Completion Window 18 | PythonPlatformPanel.deleteButton.text=Delete 19 | PythonPlatformPanel.addVariableButton.text=Add Variable 20 | PythonPackageRepositoryPanel.nameLabel.text=Name: 21 | PythonPackageRepositoryPanel.nameTextField.text= 22 | PythonPackageRepositoryPanel.urlLabel.text=Repository URL: 23 | PythonPackageRepositoryPanel.urlTextField.text= 24 | PythonPackageRepositoryPanel.loginLabel.text=Login: 25 | PythonPackageRepositoryPanel.passLabel.text=Password: 26 | PythonPackageRepositoryPanel.loginTextField.text= 27 | PythonPackageRepositoryPanel.passPasswordField.text= 28 | PythonPackageRepositoryPanel.addButton.text=Add 29 | PythonPackageRepositoryPanel.removeButton.text=Remove 30 | PythonPackageRepositoryPanel.updateButton.text=Update 31 | PythonPlatformPanel.envsPanel.TabConstraints.tabTitle=Environment Variables 32 | PythonPlatformPanel.sysCheckBox.text=Include system environment variables: 33 | PythonLspServerConfigsPanel.errroLabel.text= 34 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/package.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/package16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/package16.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/packagemanager/Bundle.properties: -------------------------------------------------------------------------------- 1 | PythonPackageManagerTopComponent.Installed.toolTipText=Installed 2 | Label2 3 | PythonPackageManagerTopComponent.repositoryButton.label= 4 | PythonPackageManagerTopComponent.repositoryButton.toolTipText=Setting 5 | PythonPackageManagerTopComponent.searchToggleButton.text= 6 | PythonPackageManagerTopComponent.installButton.text= 7 | PythonPackageManagerTopComponent.packageNameLabel.text= 8 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/passed.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/pip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/pip.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/platforms.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/poetry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/poetry.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/project/Bundle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/project/Bundle.properties -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectproperties/Bundle.properties: -------------------------------------------------------------------------------- 1 | PythonPdocPanel.border.title=PDOC 2 | PythonPdocPanel.pdocParamsTextField.text= 3 | PythonPdocPanel.pdocParamsLabel.text=Pdoc Parameters: 4 | PythonBuildPanel.border.title=Hatchling 5 | PythonBuildPanel.buildParamsTextField.text= 6 | PythonBuildPanel.buildParamsLabel.text=Build Parameters: 7 | PythonGeneralPanel.versionTextField.text= 8 | PythonGeneralPanel.projectNameTextField.text= 9 | PythonGeneralPanel.descriptionLabel.text=Description: 10 | PythonGeneralPanel.pythonLabel.text=Python Platform: 11 | PythonGeneralPanel.versionLabel.text=Version: 12 | PythonGeneralPanel.projectNameLabel.text=Project Name: 13 | PythonGeneralPanel.border.title=Project 14 | PythonRunPanel.scriptLabel.text=Script Path: 15 | PythonRunPanel.scriptButton.toolTipText=Choose file 16 | PythonRunPanel.scriptButton.text=Choose 17 | PythonRunPanel.paramsTextField.text= 18 | PythonRunPanel.scriptTextField.text= 19 | PythonRunPanel.paramsLabel.text=Run Parameters: 20 | PythonTestPanel.testFrameworkParamsTextField.text= 21 | PythonTestPanel.testGeneratorLabel.text=Framework: 22 | PythonTestPanel.testGeneratorPanel.border.title=Test Generator 23 | PythonTestPanel.testFrameworkParamsLabel.text=Parameters: 24 | PythonTestPanel.testFrameworkLabel.text=Framework: 25 | PythonTestPanel.testFrameworkPanel.border.title=Test Frameworks 26 | PythonTestPanel.testGeneratorDirButton.text=Choose 27 | PythonTestPanel.testGeneratorDirTextField.text= 28 | PythonTestPanel.testGeneratorDirLabel.text=Generator Directory: 29 | PythonTestPanel.testDirButton.text=Choose 30 | PythonTestPanel.testGeneratorParamsTextField.text= 31 | PythonTestPanel.testFrameworkDirTextField.text= 32 | PythonTestPanel.testGeneratorParamsLabel.text=Parameters: 33 | PythonTestPanel.testFrameworkDirLabel.text=Test Directory: 34 | PythonRunPanel.border.title=Run Configuration 35 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/Bundle.properties: -------------------------------------------------------------------------------- 1 | LBL_CreateProjectStep=Name and Location 2 | PythonProjectPanelVisual.createdFolderLabel.text=Project &Folder: 3 | PythonProjectPanelVisual.browseButton.actionCommand=BROWSE 4 | PythonProjectPanelVisual.browseButton.text=Br&owse... 5 | PythonProjectPanelVisual.projectLocationLabel.text=Project &Location: 6 | PythonProjectPanelVisual.browseButton.text_1=Br&owse... 7 | PythonProjectPanelVisual.projectLocationLabel.text_1=Project &Location: 8 | PythonProjectPanelVisual.projectNameLabel.text=Project &Name: 9 | PythonProjectPanelVisual.createdFolderLabel.text_1=Project &Folder: 10 | PythonProjectPanelVisual.browseButton.actionCommand_1=BROWSE 11 | PythonProjectPanelVisual.projectLocationLabel.text_2=Project &Location: 12 | PythonProjectPanelVisual.projectNameLabel.text_1=Project &Name: 13 | PythonProjectPanelVisual.createdFolderLabel.text_2=Project &Folder: 14 | PythonProjectPanelVisual.browseButton.actionCommand_2=BROWSE 15 | PythonProjectPanelVisual.browseButton.text_2=Br&owse... 16 | PythonProjectPanelVisual.venvLabel.text=Virtual environment: 17 | PythonProjectPanelVisual.pythonLabel.text=Python: 18 | PythonProjectPanelVisual.pythonTextField.text= 19 | PythonProjectPanelVisual.pythonButton.text=Change 20 | PythonExtSourceProjectPanelVisual.projectNameLabel.text=Project &Name: 21 | PythonExtSourceProjectPanelVisual.createdFolderLabel.text=Project &Folder: 22 | PythonExtSourceProjectPanelVisual.browseButton.actionCommand=BROWSE 23 | PythonExtSourceProjectPanelVisual.browseButton.text=Br&owse... 24 | PythonExtSourceProjectPanelVisual.projectLocationLabel.text=Project &Location: 25 | PythonPoetryPanelVisual.browseButton.actionCommand=BROWSE 26 | PythonPoetryPanelVisual.browseButton.text=Br&owse... 27 | PythonPoetryPanelVisual.projectLocationLabel.text=Project &Location: 28 | PythonPoetryPanelVisual.projectNameLabel.text=Project &Name: 29 | PythonPoetryPanelVisual.createdFolderLabel.text=Project &Folder: 30 | PythonPoetryPanelVisual.pythonTextField.text= 31 | PythonPoetryPanelVisual.pythonLabel.text=Python: 32 | PythonPoetryPanelVisual.pythonButton.text=Change 33 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/PythonExtSourceProjectDescription.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | New Project from Sources 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/PythonPoetryDescription.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | New Poetry project 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/PythonProjectDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | New Python Project 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/PythonProjectProject.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/projectsample/PythonProjectProject.zip -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/projectsample/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling"] 3 | build-backend = "hatchling.build" 4 | [project] 5 | description = "" 6 | version = "0.1.0" 7 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/pynguin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/pynguin.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/pytest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/pytest.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/python-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/python-2.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/python-runnable-test-annotation.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 25 | 34 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/python32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/python32.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/repos.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/restart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/restart.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/run.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/run.gif -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/settings.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/source/Bundle.properties: -------------------------------------------------------------------------------- 1 | PythonPylintScoreBar.nameLabel.toolTipText=Pylint Code Score 2 | PythonPylintScoreBar.nameLabel.text=Code Score: 3 | PythonPylintScoreBar.pylintProgressBar.string=0,00\u00a0% 4 | PythonPylintScoreBar.previousLabel.text= 5 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/statusbar/Bundle.properties: -------------------------------------------------------------------------------- 1 | 2 | PythonStatusBarPanel.statusLabel.text= 3 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/term.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/term.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/test-error_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albilu/netbeansPython/9af99f06b1c86ea649c4e34ce0cf193dabb675e0/src/main/resources/org/netbeans/modules/python/test-error_16.png -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/toml_handler.py: -------------------------------------------------------------------------------- 1 | ##Little helper for Netbeans to handle toml files 2 | 3 | import sys 4 | from pathlib import Path 5 | 6 | import tomlkit 7 | 8 | input_path = sys.argv[1] 9 | project_name = sys.argv[2] 10 | project_version = sys.argv[3] 11 | project_description = sys.argv[4] 12 | project_requires_python = sys.argv[5] 13 | type = sys.argv[6] 14 | 15 | file = Path(input_path) 16 | 17 | try: 18 | pyproject = tomlkit.loads(file.read_text()) 19 | with file.open("w") as f: 20 | if type != "poetry": 21 | pyproject["project"]["name"] = project_name 22 | pyproject["project"]["version"] = project_version 23 | pyproject["project"]["description"] = project_description 24 | pyproject["project"]["requires-python"] = project_requires_python 25 | else: 26 | #pyproject["tool"]["poetry"]["name"] = project_name 27 | pyproject["tool"]["poetry"]["version"] = project_version 28 | pyproject["tool"]["poetry"]["description"] = project_description 29 | pyproject["tool"]["poetry"]["dependencies"][ 30 | "python" 31 | ] = project_requires_python 32 | 33 | f.write(tomlkit.dumps(pyproject)) 34 | sys.exit() 35 | except Exception as e: 36 | print("Error updating pyproject.toml: %s" % e) 37 | -------------------------------------------------------------------------------- /src/main/resources/org/netbeans/modules/python/warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 25 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 97 | 98 | 99 | --------------------------------------------------------------------------------