├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE.md
└── CONTRIBUTING.md
├── test
└── unit
│ ├── data
│ ├── versions
│ │ ├── VERSION-none.txt
│ │ ├── VERSION-3.0.0.txt
│ │ └── VERSION-3.1.0-dev.txt
│ └── dotcake
│ │ └── .cake
│ └── src
│ └── org
│ └── netbeans
│ └── modules
│ └── php
│ └── cake3
│ └── CakeVersionTest.java
├── .gitignore
├── src
└── org
│ └── netbeans
│ └── modules
│ └── php
│ └── cake3
│ ├── resources
│ ├── templates
│ │ ├── CtpTemplate.ctp
│ │ ├── EntityDescription.html
│ │ ├── HelperDescription.html
│ │ ├── ShellDescription.html
│ │ ├── TableDescription.html
│ │ ├── TaskDescription.html
│ │ ├── BehaviorDescription.html
│ │ ├── CellDescription.html
│ │ ├── CtpTemplateDescription.html
│ │ ├── ComponentDescription.html
│ │ ├── ControllerDescription.html
│ │ ├── Controller.php
│ │ ├── Entity.php
│ │ ├── Helper.php
│ │ ├── Table.php
│ │ ├── Behavior.php
│ │ ├── Component.php
│ │ ├── Cell.php
│ │ ├── Shell.php
│ │ ├── Task.php
│ │ └── package-info.java
│ ├── ctp_icon.png
│ ├── php_icon.png
│ ├── goto-cell.png
│ ├── goto-entity.png
│ ├── goto-helper.png
│ ├── goto-table.png
│ ├── badge_icon_8.png
│ ├── goto-behavior.png
│ ├── goto-element.png
│ ├── goto-fixture.png
│ ├── goto-template.png
│ ├── goto-testcase.png
│ ├── cakephp_icon_16.png
│ ├── goto-component.png
│ ├── goto-controller.png
│ ├── goto-view-cell.png
│ ├── Bundle.properties
│ ├── ctp-mime-resolver.xml
│ ├── dotcake-mime-resolver.xml
│ └── layer.xml
│ ├── ui
│ ├── options
│ │ ├── Bundle.properties
│ │ ├── CakePHP3OptionsPanelController.java
│ │ └── CakePHP3OptionsPanel.form
│ ├── wizards
│ │ ├── Bundle.properties
│ │ ├── CakePHP3NewProjectDescription.html
│ │ └── CakePHP3NewProjectWizardPanel.java
│ ├── actions
│ │ ├── gotos
│ │ │ ├── Bundle.properties
│ │ │ ├── items
│ │ │ │ ├── GoToItem.java
│ │ │ │ ├── GoToHelperItem.java
│ │ │ │ ├── GoToTableItem.java
│ │ │ │ ├── GoToEntityItem.java
│ │ │ │ ├── GoToElementItem.java
│ │ │ │ ├── GoToFixtureItem.java
│ │ │ │ ├── GoToBehaviorItem.java
│ │ │ │ ├── GoToComponentItem.java
│ │ │ │ ├── GoToTemplateItem.java
│ │ │ │ ├── GoToTestCaseItem.java
│ │ │ │ ├── GoToViewCellItem.java
│ │ │ │ ├── GoToControllerItem.java
│ │ │ │ ├── GoToTemplateCellItem.java
│ │ │ │ ├── GoToDefaultItem.java
│ │ │ │ └── GoToItemFactory.java
│ │ │ ├── status
│ │ │ │ ├── DefaultStatus.java
│ │ │ │ ├── EntityStatus.java
│ │ │ │ ├── TestCaseStatus.java
│ │ │ │ ├── CakePHP3GoToStatusFactory.java
│ │ │ │ ├── ComponentStatus.java
│ │ │ │ ├── HelperStatus.java
│ │ │ │ └── TableStatus.java
│ │ │ ├── CakePHP3SmartGoToAction.java
│ │ │ └── CakePHP3GoToAction.java
│ │ ├── CakePHP3BaseAction.java
│ │ ├── CakePHP3GoToViewAction.java
│ │ ├── CakePHP3GoToActionAction.java
│ │ ├── CakePHP3RefreshModuleAction.java
│ │ ├── CakePHP3RunCommandAction.java
│ │ ├── CakeServerAction.java
│ │ └── OpenDotcakeAction.java
│ └── customizer
│ │ └── Bundle.properties
│ ├── Bundle.properties
│ ├── resolvers
│ ├── ctp
│ │ └── package-info.java
│ └── dotcake
│ │ └── package-info.java
│ ├── editor
│ ├── visitors
│ │ ├── ComponentVisitor.java
│ │ ├── HelperVisitor.java
│ │ ├── ViewVisitor.java
│ │ ├── TemplateVisitor.java
│ │ └── CakePHP3Visitor.java
│ ├── completion
│ │ ├── resources
│ │ │ └── filepath-parameters.json
│ │ ├── ConstantParameter.java
│ │ ├── ParameterFactory.java
│ │ └── CakePHP3CompletionProvider.java
│ ├── CakePHPTabDecorator.java
│ └── CakePHP3TemplateAttributesProvider.java
│ ├── modules
│ ├── ModuleInfo.java
│ ├── CakePHPModuleDummy.java
│ └── CakePHPModuleFactory.java
│ ├── Versionable.java
│ ├── commands
│ ├── Cake3CommandItem.java
│ ├── Cake3Command.java
│ ├── CakePHP3FrameworkCommandSupport.java
│ ├── CakePHP3ProjectGenerator.java
│ └── CakePHP3CommandXmlParser.java
│ ├── utils
│ ├── JsonSimpleSupport.java
│ └── CakePHPCodeUtils.java
│ ├── CakePHP3Constants.java
│ ├── CakeVersion.java
│ ├── ConfigurationFiles.java
│ ├── CakePHP3ActionsExtender.java
│ ├── options
│ └── CakePHP3Options.java
│ ├── preferences
│ └── CakePHP3Preferences.java
│ ├── dotcake
│ └── DotcakeSupport.java
│ └── CakePHP3FrameworkProvider.java
├── nbproject
├── project.properties
├── genfiles.properties
├── platform.properties
└── build-impl.xml
├── manifest.mf
└── pom
└── pom.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: junichi11
2 |
--------------------------------------------------------------------------------
/test/unit/data/versions/VERSION-none.txt:
--------------------------------------------------------------------------------
1 | // test
2 |
--------------------------------------------------------------------------------
/test/unit/data/versions/VERSION-3.0.0.txt:
--------------------------------------------------------------------------------
1 | // test
2 | 3.0.0
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | nbproject/private
3 | lib
4 | pom.xml.asc
5 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/CtpTemplate.ctp:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/unit/data/versions/VERSION-3.1.0-dev.txt:
--------------------------------------------------------------------------------
1 | // test
2 | 3.1.0-dev
3 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/ctp_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/ctp_icon.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/php_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/php_icon.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-cell.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-entity.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-helper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-helper.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-table.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/badge_icon_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/badge_icon_8.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-behavior.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-behavior.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-element.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-element.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-fixture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-fixture.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-template.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-template.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-testcase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-testcase.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/cakephp_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/cakephp_icon_16.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-component.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-component.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-controller.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-controller.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/goto-view-cell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/junichi11/cakephp3-netbeans/HEAD/src/org/netbeans/modules/php/cake3/resources/goto-view-cell.png
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/options/Bundle.properties:
--------------------------------------------------------------------------------
1 |
2 | CakePHP3OptionsPanel.externalDragAndDropCheckBox.text=External drag and drop
3 | CakePHP3OptionsPanel.customNodesLabel.text=Custom nodes:
4 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | javac.source=1.8
2 | javac.compilerargs=-Xlint -Xlint:-serial
3 | license.file=LICENSE
4 | nbm.homepage=https://github.com/junichi11/cakephp3-netbeans
5 | nbm.module.author=junichi11(Junichi Yamamoto)
6 | project.license=apache20
7 | keystore=nbproject/private/keystore
8 | nbm_alias=cakephp3
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | #### Issue type
2 |
3 | - [x] bug
4 | - [ ] enhancement
5 |
6 | #### Overview description
7 |
8 | #### Steps to reproduce
9 |
10 | 1.
11 | 2.
12 | 3.
13 |
14 | #### Actual results
15 |
16 | #### Expected results
17 |
18 | #### Your environment (NetBeans and plugin version, e.t.c.)
19 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/EntityDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new entity file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/HelperDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new helper file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/ShellDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new shell file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/TableDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new table file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/TaskDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new task file.
9 |
10 |
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | AutoUpdate-Show-In-Client: true
3 | OpenIDE-Module: org.netbeans.modules.php.cake3
4 | OpenIDE-Module-Layer: org/netbeans/modules/php/cake3/resources/layer.xml
5 | OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/cake3/Bundle.properties
6 | OpenIDE-Module-Specification-Version: 0.11.0
7 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/BehaviorDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new behavior file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/CellDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new view cell file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/CtpTemplateDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new ctp file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/ComponentDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new component file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/ControllerDescription.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Create a new controller file.
9 |
10 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/Bundle.properties:
--------------------------------------------------------------------------------
1 | OpenIDE-Module-Display-Category=PHP
2 | OpenIDE-Module-Long-Description=\
3 | Provides support for CakePHP3/4.
Details: See README.md.
4 | OpenIDE-Module-Name=CakePHP3/4 Framework
5 | OpenIDE-Module-Short-Description=Provides support for CakePHP3/4
6 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/wizards/Bundle.properties:
--------------------------------------------------------------------------------
1 | LBL_CreateProjectStep=Name and Location
2 | CakePHP3NewProjectPanelVisual.projectLocationLabel.text=Project &Location:
3 | CakePHP3NewProjectPanelVisual.projectNameLabel.text=Project &Name:
4 | CakePHP3NewProjectPanelVisual.createdFolderLabel.text=Project &Folder:
5 | CakePHP3NewProjectPanelVisual.browseButton.actionCommand=BROWSE
6 | CakePHP3NewProjectPanelVisual.browseButton.text=Br&owse...
7 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Controller.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | /**
12 | * CakePHP ${name}
13 | * @author ${user}
14 | */
15 | class ${name} extends AppController
16 | {
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Entity.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\ORM\Entity;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Entity
18 | {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Helper.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\View\Helper;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Helper
18 | {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Table.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\ORM\Table;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Table
18 | {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Behavior.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\ORM\Behavior;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Behavior
18 | {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Component.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\Controller\Component;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Component
18 | {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=26a6082c
2 | build.xml.script.CRC32=99224ca9
3 | build.xml.stylesheet.CRC32=15ca8a54@2.76
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=9809b2f0
7 | nbproject/build-impl.xml.script.CRC32=3e0b9a07
8 | nbproject/build-impl.xml.stylesheet.CRC32=49aa68b0@2.82
9 |
--------------------------------------------------------------------------------
/nbproject/platform.properties:
--------------------------------------------------------------------------------
1 | cluster.path=\
2 | ${nbplatform.active.dir}/nb:\
3 | ${nbplatform.active.dir}/platform:\
4 | ${nbplatform.active.dir}/apisupport:\
5 | ${nbplatform.active.dir}/php:\
6 | ${nbplatform.active.dir}/ide:\
7 | ${nbplatform.active.dir}/websvccommon:\
8 | ${nbplatform.active.dir}/webcommon:\
9 | ${nbplatform.active.dir}/java:\
10 | ${nbplatform.active.dir}/profiler:\
11 | ${nbplatform.active.dir}/harness
12 | nbplatform.active=default
13 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Cell.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\View\Cell;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Cell
18 | {
19 | public function display()
20 | {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Shell.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\Console\Shell;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Shell
18 | {
19 | public function main()
20 | {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/Task.php:
--------------------------------------------------------------------------------
1 |
3 | <#assign licensePrefix = " * ">
4 | <#assign licenseLast = " */">
5 | <#include "../Licenses/license-${project.license}.txt">
6 |
7 | <#if namespace?? && namespace != "">
8 | namespace ${namespace};
9 |
10 | #if>
11 | use Cake\Console\Shell;
12 |
13 | /**
14 | * CakePHP ${name}
15 | * @author ${user}
16 | */
17 | class ${name} extends Shell
18 | {
19 | public function main()
20 | {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/Bundle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2019 junichi11.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | LBL_CakePHP3ExportName=CakePHP3/4
18 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/Bundle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2019 junichi11.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | cake3-smart-goto=CakePHP3/4:Smart Go To
17 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/wizards/CakePHP3NewProjectDescription.html:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 |
22 |
23 | Create a CakePHP3 project via Composer (create-project).
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resolvers/ctp/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | @NbBundle.Messages({
17 | "LBL_CtpFile=Template file for CakePHP"
18 | })
19 | @MIMEResolver.Registration(displayName = "#LBL_CtpFile", resource = "../../resources/ctp-mime-resolver.xml")
20 | package org.netbeans.modules.php.cake3.resolvers.ctp;
21 |
22 | import org.openide.filesystems.MIMEResolver;
23 | import org.openide.util.NbBundle;
24 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resolvers/dotcake/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | @NbBundle.Messages({
17 | "LBL_DotcakeFile=Dotcake file"
18 | })
19 | @MIMEResolver.Registration(displayName = "#LBL_DotcakeFile", resource = "../../resources/dotcake-mime-resolver.xml")
20 | package org.netbeans.modules.php.cake3.resolvers.dotcake;
21 |
22 | import org.openide.filesystems.MIMEResolver;
23 | import org.openide.util.NbBundle;
24 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/ctp-mime-resolver.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/dotcake-mime-resolver.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/customizer/Bundle.properties:
--------------------------------------------------------------------------------
1 | CakePHP3CustomizerPanel.generalLabel.text=General:
2 | CakePHP3CustomizerPanel.enabledCheckBox.text=Enabled
3 | CakePHP3CustomizerPanel.enabledMessageLabel.text=Enable support for CakePHP3/4 for this project
4 | CakePHP3CustomizerPanel.namespaceLabel.text=Namespace:
5 | CakePHP3CustomizerPanel.namespaceTextField.text=
6 | CakePHP3CustomizerPanel.pathSettingsLabel.text=Path settings:
7 | CakePHP3CustomizerPanel.wwwRootLabel.text=WWW Root:
8 | CakePHP3CustomizerPanel.wwwRootTextField.text=
9 | CakePHP3CustomizerPanel.cssLabel.text=Css:
10 | CakePHP3CustomizerPanel.cssTextField.text=
11 | CakePHP3CustomizerPanel.jsLabel.text=Js:
12 | CakePHP3CustomizerPanel.jsTextField.text=
13 | CakePHP3CustomizerPanel.imgLabel.text=Img:
14 | CakePHP3CustomizerPanel.imgTextField.text=
15 | CakePHP3CustomizerPanel.rootLabel.text=Root:
16 | CakePHP3CustomizerPanel.rootTextField.text=
17 | CakePHP3CustomizerPanel.srcTextField.text=
18 | CakePHP3CustomizerPanel.srcLabel.text=Dir (src):
19 | CakePHP3CustomizerPanel.dotcakeLabel.text=.cake:
20 | CakePHP3CustomizerPanel.dotcakeTextField.text=
21 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.openide.filesystems.FileObject;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | public interface GoToItem {
26 |
27 | public FileObject getFileObject();
28 |
29 | public int getOffset();
30 |
31 | public Icon getIcon();
32 |
33 | public String getBaseName();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakePHP3BaseAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.spi.framework.actions.BaseAction;
19 | import org.openide.util.NbBundle;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | @NbBundle.Messages({
26 | "# {0} - name",
27 | "CakePHPBaseAction.fullName=CakePHP3/4: {0}"
28 | })
29 | public abstract class CakePHP3BaseAction extends BaseAction {
30 |
31 | private static final long serialVersionUID = -3168997800688946207L;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/test/unit/data/dotcake/.cake:
--------------------------------------------------------------------------------
1 | {
2 | "cake": "..\/vendor\/cakephp\/cakephp",
3 | "build_path": {
4 | "entities": [
5 | ".\/src\/Model\/Entity\/"
6 | ],
7 | "tables": [
8 | ".\/src\/Model\/Table\/"
9 | ],
10 | "behaviors": [
11 | ".\/src\/Model\/Behavior\/"
12 | ],
13 | "controllers": [
14 | ".\/src\/Controller\/"
15 | ],
16 | "components": [
17 | ".\/src\/Controller\/Component\/"
18 | ],
19 | "templates": [
20 | ".\/src\/Template\/"
21 | ],
22 | "views": [
23 | ".\/src\/View\/"
24 | ],
25 | "helpers": [
26 | ".\/src\/View\/Helper\/"
27 | ],
28 | "consoles": [
29 | ".\/src\/Console\/"
30 | ],
31 | "shells": [
32 | ".\/src\/Shell\/"
33 | ],
34 | "tasks": [
35 | ".\/src\/Shell\/Task\/"
36 | ],
37 | "locales": [
38 | ".\/src\/Locale\/"
39 | ],
40 | "vendors": [
41 | ".\/vendor\/"
42 | ],
43 | "plugins": [
44 | ".\/plugins\/"
45 | ]
46 | }
47 | }
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/visitors/ComponentVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.visitors;
17 |
18 | import java.util.Collections;
19 | import java.util.Set;
20 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
21 |
22 | public class ComponentVisitor extends ControllerVisitor {
23 |
24 | public ComponentVisitor(PhpModule phpModule) {
25 | super(phpModule);
26 | }
27 |
28 | @Override
29 | public Set getAvailableFieldNames() {
30 | return Collections.singleton(COMPONENTS);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/visitors/HelperVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.visitors;
17 |
18 | import java.util.Collections;
19 | import java.util.Set;
20 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
21 |
22 | public class HelperVisitor extends FieldsVisitor {
23 |
24 | public HelperVisitor(PhpModule phpModule) {
25 | super(phpModule);
26 | }
27 |
28 | @Override
29 | public Set getAvailableFieldNames() {
30 | return Collections.singleton(FieldsVisitor.HELPERS);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/modules/ModuleInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.modules;
17 |
18 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Base;
19 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
20 | import org.openide.filesystems.FileObject;
21 |
22 | /**
23 | *
24 | * @author junichi11
25 | */
26 | public interface ModuleInfo {
27 |
28 | public FileObject getFileObject();
29 |
30 | public Base getBase();
31 |
32 | public Category getCategory();
33 |
34 | public String getPluginName();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ## Questions
4 |
5 | Please don't submit a question as an issue.
6 | If you have some questions, please post them to [my twitter account(@junichi_11)](https://twitter.com/junichi_11)
7 |
8 | ## Issues
9 |
10 | [Submit an Issue](https://github.com/junichi11/cakephp3-netbeans/issues/new?title=&body=%23%23%23%23%20Overview%20description%0D%0A%0D%0A%23%23%23%23%20Steps%20to%20reproduce%0D%0A1.%20%0D%0A2.%20%0D%0A3.%20%0D%0A%0D%0A%23%23%23%23%20Actual%20results%0D%0A%0D%0A%23%23%23%23%20Expected%20results%0D%0A%0D%0A%23%23%23%23%20Version%20number%20of%20the%20plugin%0D%0A%0D%0A%23%23%23%23%20Version%20information%20of%20NetBeans%0D%0A%0D%0A)
11 |
12 | Please use the following template:
13 |
14 | ```markdown
15 | #### Overview description
16 |
17 | #### Steps to reproduce
18 | 1.
19 | 2.
20 | 3.
21 |
22 | #### Actual results
23 |
24 | #### Expected results
25 |
26 | #### Version number of the plugin
27 |
28 | #### Version information of NetBeans
29 |
30 | ```
31 |
32 | ## Pull Requests
33 |
34 | Please don't send your pull requests to the `master` branch.
35 | Please let me know if the repository has only the `master` branch.
36 |
37 | A branch for development will be named nb** (e.g. nb80).
38 | Please send your pull requests there.
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/completion/resources/filepath-parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "HtmlHelper": {
3 | "css": {
4 | "0": [
5 | "css"
6 | ]
7 | },
8 | "script": {
9 | "0": [
10 | "js"
11 | ]
12 | },
13 | "image": {
14 | "0": [
15 | "img"
16 | ]
17 | }
18 | },
19 | "Controller": {
20 | "render": {
21 | "0": [
22 | "template"
23 | ],
24 | "1": [
25 | "layout"
26 | ]
27 | },
28 | "loadComponent" : {
29 | "0": [
30 | "component"
31 | ]
32 | }
33 | },
34 | "ModelAwareTrait": {
35 | "loadModel" : {
36 | "0": [
37 | "table"
38 | ]
39 | }
40 | },
41 | "View": {
42 | "element": {
43 | "0": [
44 | "element"
45 | ]
46 | },
47 | "extend": {
48 | "0": [
49 | "template"
50 | ]
51 | },
52 | "loadHelper": {
53 | "0": [
54 | "helper"
55 | ]
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakePHP3GoToViewAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.cake3.ui.actions.gotos.CakePHP3SmartGoToAction;
19 | import org.netbeans.modules.php.spi.framework.actions.GoToViewAction;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | public class CakePHP3GoToViewAction extends GoToViewAction {
26 |
27 | private static final long serialVersionUID = -8407813132091607464L;
28 |
29 | @Override
30 | public boolean goToView() {
31 | CakePHP3SmartGoToAction action = new CakePHP3SmartGoToAction();
32 | action.actionPerformed(null);
33 | return true;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakePHP3GoToActionAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.cake3.ui.actions.gotos.CakePHP3SmartGoToAction;
19 | import org.netbeans.modules.php.spi.framework.actions.GoToActionAction;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | public class CakePHP3GoToActionAction extends GoToActionAction {
26 |
27 | private static final long serialVersionUID = -5042861266295175782L;
28 |
29 | @Override
30 | public boolean goToAction() {
31 | CakePHP3SmartGoToAction action = new CakePHP3SmartGoToAction();
32 | action.actionPerformed(null);
33 | return true;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/layer.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToHelperItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | class GoToHelperItem extends GoToDefaultItem {
24 |
25 | public GoToHelperItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToHelperItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_HELPER_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToTableItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToTableItem extends GoToDefaultItem {
24 |
25 | public GoToTableItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToTableItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_TABLE_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/DefaultStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.Collections;
19 | import java.util.List;
20 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
21 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
22 | import org.openide.filesystems.FileObject;
23 |
24 | class DefaultStatus extends CakePHP3GoToStatus {
25 |
26 | public DefaultStatus(FileObject fileObject, int offset) {
27 | super(fileObject, offset);
28 | }
29 |
30 | @Override
31 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
32 | }
33 |
34 | @Override
35 | public List getSmart() {
36 | return Collections.emptyList();
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToEntityItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToEntityItem extends GoToDefaultItem {
24 |
25 | public GoToEntityItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToEntityItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_ENTITY_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToElementItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToElementItem extends GoToDefaultItem {
24 |
25 | public GoToElementItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToElementItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_ELEMENT_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToFixtureItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToFixtureItem extends GoToDefaultItem {
24 |
25 | public GoToFixtureItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToFixtureItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_FIXTURE_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToBehaviorItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToBehaviorItem extends GoToDefaultItem {
24 |
25 | public GoToBehaviorItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToBehaviorItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_BEHAVIOR_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToComponentItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | class GoToComponentItem extends GoToDefaultItem {
24 |
25 | public GoToComponentItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToComponentItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_COMPONENT_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToTemplateItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToTemplateItem extends GoToDefaultItem {
24 |
25 | public GoToTemplateItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToTemplateItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_TEMPLATE_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToTestCaseItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToTestCaseItem extends GoToDefaultItem {
24 |
25 | public GoToTestCaseItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToTestCaseItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_TESTCASE_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToViewCellItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToViewCellItem extends GoToDefaultItem {
24 |
25 | public GoToViewCellItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToViewCellItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_VIEW_CELL_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToControllerItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToControllerItem extends GoToDefaultItem {
24 |
25 | public GoToControllerItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToControllerItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_CONTROLLER_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToTemplateCellItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import javax.swing.Icon;
19 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
20 | import org.openide.filesystems.FileObject;
21 | import org.openide.util.ImageUtilities;
22 |
23 | public class GoToTemplateCellItem extends GoToDefaultItem {
24 |
25 | public GoToTemplateCellItem(FileObject fileObject, int offset) {
26 | super(fileObject, offset);
27 | }
28 |
29 | public GoToTemplateCellItem(FileObject fileObject, int offset, String baseName) {
30 | super(fileObject, offset, baseName);
31 | }
32 |
33 | @Override
34 | public Icon getIcon() {
35 | return ImageUtilities.loadImageIcon(CakePHP3Constants.GOTO_TEMPLATE_CELL_ICON, true);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/CakePHP3SmartGoToAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos;
17 |
18 | import java.util.List;
19 | import org.netbeans.api.editor.EditorActionRegistration;
20 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
21 | import org.netbeans.modules.php.cake3.ui.actions.gotos.status.CakePHP3GoToStatus;
22 |
23 | @EditorActionRegistration(name = "cake3-smart-goto")
24 | public class CakePHP3SmartGoToAction extends CakePHP3GoToAction {
25 |
26 | private static final long serialVersionUID = -3287999601900817083L;
27 |
28 | @Override
29 | protected List getGoToItems(CakePHP3GoToStatus status) {
30 | return status.getSmart();
31 | }
32 |
33 | @Override
34 | protected String getPopupTitle() {
35 | return "Smart Go To"; // NOI18N
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/completion/ConstantParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.completion;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import org.netbeans.spi.editor.completion.CompletionItem;
21 | import org.openide.filesystems.FileObject;
22 |
23 | public class ConstantParameter extends Parameter {
24 |
25 | ConstantParameter(int position, String className, String methodName, FileObject fileObject) {
26 | super(position, className, methodName, fileObject);
27 | }
28 |
29 | @Override
30 | public List getCompletionItems(String filter, int caretOffset) {
31 | List items = new ArrayList<>();
32 | for (String element : getElements(getPosition(), getClassName(), getMethodName())) {
33 | if (element.startsWith(filter)) {
34 | items.add(new CakePHP3CompletionItem(element, filter, caretOffset));
35 | }
36 | }
37 | return items;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/Versionable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | /**
19 | *
20 | * @author junichi11
21 | */
22 | public interface Versionable {
23 |
24 | public static final String UNNKOWN = "UNKNOWN"; // NOI18N
25 | public static final String MAJOR = "major"; // NOI18N
26 | public static final String MINOR = "minor"; // NOI18N
27 | public static final String PATCH = "patch"; // NOI18N
28 |
29 | /**
30 | * Get a full version number.
31 | *
32 | * @return a full version number
33 | */
34 | public String getVersionNumber();
35 |
36 | /**
37 | * Get a major version number.
38 | *
39 | * @return a major version number
40 | */
41 | public int getMajor();
42 |
43 | /**
44 | * Get a minor version number.
45 | *
46 | * @return a minor version number
47 | */
48 | public int getMinor();
49 |
50 | /**
51 | * Get a patch version number.
52 | *
53 | * @return a patch version number
54 | */
55 | public int getPatch();
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/commands/Cake3CommandItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.commands;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | /**
22 | * @author junichi11
23 | */
24 | public class Cake3CommandItem {
25 |
26 | private final String command;
27 | private final String description;
28 | private final String displayName;
29 | private final List subcommands = new ArrayList<>();
30 |
31 | public Cake3CommandItem(String command, String description, String displayName) {
32 | this.command = command;
33 | this.description = description;
34 | this.displayName = displayName;
35 | }
36 |
37 | public String getCommand() {
38 | return command;
39 | }
40 |
41 | public String getDescription() {
42 | return description;
43 | }
44 |
45 | public String getDisplayName() {
46 | return displayName;
47 | }
48 |
49 | public List getSubcommands() {
50 | return subcommands;
51 | }
52 |
53 | public void addSubcommand(Cake3CommandItem subcommand) {
54 | this.subcommands.add(subcommand);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/completion/ParameterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.completion;
17 |
18 | import org.netbeans.api.annotations.common.CheckForNull;
19 | import org.openide.filesystems.FileObject;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | public final class ParameterFactory {
26 |
27 | private static final ParameterFactory INSTANCE = new ParameterFactory();
28 |
29 | private ParameterFactory() {
30 | }
31 |
32 | public static final ParameterFactory getInstance() {
33 | return INSTANCE;
34 | }
35 |
36 | @CheckForNull
37 | public Parameter create(int position, String className, String methodName, FileObject fileObject) {
38 | Parameter.Type type = Parameter.getType(position, className, methodName);
39 | switch (type) {
40 | case Constant:
41 | return new ConstantParameter(position, className, methodName, fileObject);
42 | case Path:
43 | return new FilePathParameter(position, className, methodName, fileObject);
44 | default:
45 | break;
46 | }
47 | return null;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakePHP3RefreshModuleAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
19 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
20 | import org.netbeans.modules.php.cake3.modules.CakePHPModuleFactory;
21 | import org.openide.util.NbBundle;
22 |
23 | /**
24 | *
25 | * @author junichi11
26 | */
27 | public class CakePHP3RefreshModuleAction extends CakePHP3BaseAction {
28 |
29 | private static final long serialVersionUID = -8188380453371163703L;
30 |
31 | @Override
32 | protected String getFullName() {
33 | return Bundle.CakePHPBaseAction_fullName(getPureName());
34 | }
35 |
36 | @NbBundle.Messages({
37 | "CakePHP3RefreshModuleAction.name=Refresh"
38 | })
39 | @Override
40 | protected String getPureName() {
41 | return Bundle.CakePHP3RefreshModuleAction_name();
42 | }
43 |
44 | @Override
45 | protected void actionPerformed(PhpModule phpModule) {
46 | if (!CakePHPModule.isCakePHP(phpModule)) {
47 | return;
48 | }
49 | CakePHPModuleFactory.getInstance().remove(phpModule);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakePHP3RunCommandAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
19 | import org.netbeans.modules.php.cake3.CakePHP3FrameworkProvider;
20 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
21 | import org.netbeans.modules.php.spi.framework.actions.RunCommandAction;
22 |
23 | /**
24 | *
25 | * @author junichi11
26 | */
27 | public final class CakePHP3RunCommandAction extends RunCommandAction {
28 |
29 | private static final CakePHP3RunCommandAction INSTANCE = new CakePHP3RunCommandAction();
30 | private static final long serialVersionUID = 3541330098499478637L;
31 |
32 | public static CakePHP3RunCommandAction getInstance() {
33 | return INSTANCE;
34 | }
35 |
36 | @Override
37 | public void actionPerformed(PhpModule phpModule) {
38 | if (!CakePHPModule.isCakePHP(phpModule)) {
39 | return;
40 | }
41 | CakePHP3FrameworkProvider.getInstance().getFrameworkCommandSupport(phpModule).openPanel();
42 | }
43 |
44 | @Override
45 | protected String getFullName() {
46 | return Bundle.CakePHPBaseAction_fullName(getPureName());
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/modules/CakePHPModuleDummy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.modules;
17 |
18 | import java.util.Collections;
19 | import java.util.List;
20 | import org.openide.filesystems.FileObject;
21 |
22 | public class CakePHPModuleDummy extends CakePHPModuleImpl {
23 |
24 | CakePHPModuleDummy() {
25 | super(null);
26 | }
27 |
28 | @Override
29 | public boolean isTemplateFile(FileObject fileObject) {
30 | return false;
31 | }
32 |
33 | @Override
34 | public List getDirectories(CakePHPModule.Base base) {
35 | return Collections.emptyList();
36 | }
37 |
38 | @Override
39 | public List getDirectories(CakePHPModule.Base base, CakePHPModule.Category category, String pluginName) {
40 | return Collections.emptyList();
41 | }
42 |
43 | @Override
44 | public FileObject getController(FileObject template) {
45 | return null;
46 | }
47 |
48 | @Override
49 | public FileObject getController(FileObject template, boolean fallback) {
50 | return null;
51 | }
52 |
53 | @Override
54 | public FileObject getViewCell(FileObject template) {
55 | return null;
56 | }
57 |
58 | @Override
59 | public FileObject getTemplate(String relativePath, FileObject controller, String themeName) {
60 | return null;
61 | }
62 |
63 | @Override
64 | public FileObject getEntity(FileObject table) {
65 | return null;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/CakeServerAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException;
19 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
20 | import org.netbeans.modules.php.cake3.commands.Cake3Script;
21 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
22 | import org.openide.util.NbBundle;
23 |
24 | /**
25 | *
26 | * @author junichi11
27 | */
28 | public class CakeServerAction extends CakePHP3BaseAction {
29 |
30 | private static final long serialVersionUID = -7115541061573607385L;
31 |
32 | @Override
33 | protected String getFullName() {
34 | return Bundle.CakePHPBaseAction_fullName(getPureName());
35 | }
36 |
37 | @NbBundle.Messages({
38 | "CakeServerAction.displayName=Run server"
39 | })
40 | @Override
41 | protected String getPureName() {
42 | return Bundle.CakeServerAction_displayName();
43 | }
44 |
45 | @Override
46 | protected void actionPerformed(PhpModule phpModule) {
47 | // via shortcut
48 | if (!CakePHPModule.isCakePHP(phpModule)) {
49 | return;
50 | }
51 | try {
52 | Cake3Script cakeScript = Cake3Script.forPhpModule(phpModule, true); // show an error dialog
53 | cakeScript.server(phpModule);
54 | } catch (InvalidPhpExecutableException ex) {
55 | // ignore since an error dialog is shown
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/commands/Cake3Command.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.commands;
17 |
18 | import java.lang.ref.WeakReference;
19 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException;
20 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
21 | import org.netbeans.modules.php.api.util.UiUtils;
22 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand;
23 |
24 | /**
25 | *
26 | * @author junichi11
27 | */
28 | public class Cake3Command extends FrameworkCommand {
29 |
30 | private final WeakReference phpModule;
31 |
32 | public Cake3Command(PhpModule phpModule, String command, String description, String displayName) {
33 | super(command, description, displayName);
34 | assert phpModule != null;
35 | this.phpModule = new WeakReference<>(phpModule);
36 | }
37 |
38 | public Cake3Command(PhpModule phpModule, String[] command, String description, String displayName) {
39 | super(command, description, displayName);
40 | assert phpModule != null;
41 | this.phpModule = new WeakReference<>(phpModule);
42 | }
43 |
44 | @Override
45 | protected String getHelpInternal() {
46 | PhpModule module = phpModule.get();
47 | if (module == null) {
48 | return ""; // NOI18N
49 | }
50 | try {
51 | return Cake3Script.forPhpModule(module, false).getHelp(module, getCommands());
52 | } catch (InvalidPhpExecutableException ex) {
53 | UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), UiUtils.FRAMEWORKS_AND_TOOLS_OPTIONS_PATH);
54 | }
55 | return ""; // NOI18N
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/CakePHPTabDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor;
17 |
18 | import java.awt.Component;
19 | import org.netbeans.core.multitabs.TabDecorator;
20 | import org.netbeans.swing.tabcontrol.TabData;
21 | import org.openide.filesystems.FileObject;
22 | import org.openide.util.Lookup;
23 | import org.openide.util.lookup.ServiceProvider;
24 | import org.openide.windows.TopComponent;
25 |
26 | /**
27 | *
28 | * @author junichi11
29 | */
30 | @ServiceProvider(service = TabDecorator.class, position = 1000)
31 | public class CakePHPTabDecorator extends TabDecorator {
32 |
33 | @Override
34 | public String getText(TabData tab) {
35 | // show a parent directory name if it's a view file
36 | // e.g. home.ctp [Pages]
37 | String text = tab.getText();
38 | if (text.endsWith(".ctp")) { // NOI18N
39 | Component component = tab.getComponent();
40 | if (component instanceof TopComponent) {
41 | TopComponent topComponent = (TopComponent) component;
42 | Lookup lookup = topComponent.getLookup();
43 | if (lookup != null) {
44 | FileObject fileObject = lookup.lookup(FileObject.class);
45 | if (fileObject != null) {
46 | FileObject parent = fileObject.getParent();
47 | if (parent != null) {
48 | String parentName = parent.getName();
49 | return String.format("%s [%s]", text, parentName); // NOI18N
50 | }
51 | }
52 | }
53 | }
54 | }
55 | return super.getText(tab);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/completion/CakePHP3CompletionProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.completion;
17 |
18 | import javax.swing.text.Document;
19 | import javax.swing.text.JTextComponent;
20 | import org.netbeans.modules.editor.NbEditorUtilities;
21 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
22 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
23 | import org.netbeans.spi.editor.completion.CompletionProvider;
24 | import org.netbeans.spi.editor.completion.CompletionTask;
25 | import org.openide.filesystems.FileObject;
26 |
27 | /**
28 | *
29 | * @author junichi11
30 | */
31 | public abstract class CakePHP3CompletionProvider implements CompletionProvider {
32 |
33 | @Override
34 | public CompletionTask createTask(int queryType, JTextComponent textComponent) {
35 | if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
36 | return null;
37 | }
38 | Document document = textComponent.getDocument();
39 | if (document == null) {
40 | return null;
41 | }
42 | FileObject fo = NbEditorUtilities.getFileObject(document);
43 | if (fo == null) {
44 | return null;
45 | }
46 | PhpModule phpModule = PhpModule.Factory.forFileObject(fo);
47 | if (!CakePHPModule.isCakePHP(phpModule)) {
48 | return null;
49 | }
50 | return createTask(queryType, textComponent, phpModule, fo);
51 | }
52 |
53 | @Override
54 | public int getAutoQueryTypes(JTextComponent jtc, String string) {
55 | return 0;
56 | }
57 |
58 | public abstract CompletionTask createTask(int queryType, JTextComponent textComponent, PhpModule phpModule, FileObject fo);
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/OpenDotcakeAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions;
17 |
18 | import java.io.File;
19 | import javax.swing.SwingUtilities;
20 | import org.netbeans.modules.csl.api.UiUtils;
21 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
22 | import org.netbeans.modules.php.cake3.dotcake.Dotcake;
23 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
24 | import org.openide.filesystems.FileObject;
25 | import org.openide.filesystems.FileUtil;
26 | import org.openide.util.NbBundle;
27 |
28 | /**
29 | *
30 | * @author junichi11
31 | */
32 | public class OpenDotcakeAction extends CakePHP3BaseAction {
33 |
34 | private static final long serialVersionUID = -516324482137680128L;
35 |
36 | @Override
37 | protected String getFullName() {
38 | return Bundle.CakePHPBaseAction_fullName(getPureName());
39 | }
40 |
41 | @NbBundle.Messages({
42 | "OpenDotcakeAction.displayName=Open .cake"
43 | })
44 | @Override
45 | protected String getPureName() {
46 | return Bundle.OpenDotcakeAction_displayName();
47 | }
48 |
49 | @Override
50 | protected void actionPerformed(PhpModule phpModule) {
51 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
52 | Dotcake dotcake = cakeModule.getDotcake();
53 | if (dotcake == null) {
54 | return;
55 | }
56 | File file = dotcake.getDotcakeFile();
57 | if (file == null) {
58 | return;
59 | }
60 | final FileObject dotcakeFile = FileUtil.toFileObject(file);
61 | if (dotcakeFile == null) {
62 | return;
63 | }
64 | SwingUtilities.invokeLater(new Runnable() {
65 | @Override
66 | public void run() {
67 | UiUtils.open(dotcakeFile, 0);
68 | }
69 | });
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/CakePHP3TemplateAttributesProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor;
17 |
18 | import java.util.Collections;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import org.netbeans.api.templates.CreateDescriptor;
22 | import org.netbeans.api.templates.CreateFromTemplateAttributes;
23 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
24 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
25 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
26 | import org.openide.filesystems.FileObject;
27 | import org.openide.util.lookup.ServiceProvider;
28 |
29 | /**
30 | *
31 | * @author junichi11
32 | */
33 | @ServiceProvider(service = CreateFromTemplateAttributes.class)
34 | public class CakePHP3TemplateAttributesProvider implements CreateFromTemplateAttributes {
35 |
36 | private static final String NAMESPACE = "namespace"; // NOI18N
37 |
38 | @Override
39 | public Map attributesFor(CreateDescriptor desc) {
40 | // target
41 | FileObject targetDirectory = desc.getTarget();
42 | PhpModule phpModule = PhpModule.Factory.forFileObject(targetDirectory);
43 | if (phpModule == null) {
44 | return Collections.emptyMap();
45 | }
46 | if (!CakePHPModule.isCakePHP(phpModule)) {
47 | return Collections.emptyMap();
48 | }
49 |
50 | // template
51 | Map attributes = new HashMap<>();
52 | FileObject template = desc.getTemplate();
53 | FileObject parent = template.getParent();
54 | if (parent == null) {
55 | return Collections.emptyMap();
56 | }
57 |
58 | // set attributes
59 | if (parent.isFolder() && parent.getNameExt().equals(CakePHP3Constants.CAKEPHP3_FRAMEWORK)) {
60 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
61 | String namespace = cakeModule.getNamespace(targetDirectory);
62 | attributes.put(NAMESPACE, namespace);
63 | }
64 |
65 | return attributes;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/test/unit/src/org/netbeans/modules/php/cake3/CakeVersionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import java.io.File;
19 | import org.junit.After;
20 | import org.junit.AfterClass;
21 | import org.junit.Before;
22 | import org.junit.BeforeClass;
23 | import org.junit.Test;
24 | import org.netbeans.junit.NbTestCase;
25 | import org.openide.filesystems.FileObject;
26 | import org.openide.filesystems.FileUtil;
27 |
28 | /**
29 | *
30 | * @author junichi11
31 | */
32 | public class CakeVersionTest extends NbTestCase {
33 |
34 | private FileObject versionsDirectory;
35 |
36 | public CakeVersionTest(String name) {
37 | super(name);
38 | }
39 |
40 | @BeforeClass
41 | public static void setUpClass() {
42 | }
43 |
44 | @AfterClass
45 | public static void tearDownClass() {
46 | }
47 |
48 | @Before
49 | @Override
50 | public void setUp() {
51 | if (versionsDirectory == null) {
52 | File dataDir = getDataDir();
53 | FileObject dataDirectory = FileUtil.toFileObject(dataDir);
54 | versionsDirectory = dataDirectory.getFileObject("versions");
55 | }
56 | }
57 |
58 | @After
59 | @Override
60 | public void tearDown() {
61 | versionsDirectory = null;
62 | }
63 |
64 | /**
65 | * Test of create method, of class CakeVersion.
66 | */
67 | @Test
68 | public void testVersionFile() {
69 | testVersionFile("VERSION-3.0.0.txt", new int[]{3, 0, 0}, "3.0.0");
70 | testVersionFile("VERSION-3.1.0-dev.txt", new int[]{3, 1, 0}, "3.1.0-dev");
71 | testVersionFile("VERSION-none.txt", new int[]{-1, -1, -1}, "UNKNOWN");
72 | }
73 |
74 | private void testVersionFile(String fileName, int[] numbers, String fullVersion) {
75 | FileObject versionFile = versionsDirectory.getFileObject(fileName);
76 | CakeVersion version = CakeVersion.create(versionFile);
77 | assertEquals(numbers[0], version.getMajor());
78 | assertEquals(numbers[1], version.getMinor());
79 | assertEquals(numbers[2], version.getPatch());
80 | assertEquals(fullVersion, version.getVersionNumber());
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/EntityStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.List;
21 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
22 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
23 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
24 | import org.netbeans.modules.php.cake3.modules.ModuleInfo;
25 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
26 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItemFactory;
27 | import org.netbeans.modules.php.cake3.utils.Inflector;
28 | import org.openide.filesystems.FileObject;
29 |
30 | public class EntityStatus extends CakePHP3GoToStatus {
31 |
32 | public EntityStatus(FileObject fileObject, int offset) {
33 | super(fileObject, offset);
34 | }
35 |
36 | @Override
37 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
38 | }
39 |
40 | @Override
41 | public List getSmart() {
42 | List items = new ArrayList<>(getTables());
43 | items.addAll(getTestCases());
44 | return items;
45 | }
46 |
47 | @Override
48 | public List getTables() {
49 | FileObject fileObject = getFileObject();
50 | if (fileObject == null) {
51 | return Collections.emptyList();
52 | }
53 | CakePHPModule cakeModule = CakePHPModule.forFileObject(fileObject);
54 | ModuleInfo info = cakeModule.createModuleInfo(fileObject);
55 | String name = fileObject.getName();
56 | Inflector inflector = Inflector.getInstance();
57 | String pluralizedName = inflector.pluralize(name);
58 | String relativePath = cakeModule.toPhpFileName(Category.TABLE, pluralizedName);
59 | FileObject file = cakeModule.getFile(info.getBase(), Category.TABLE, relativePath, info.getPluginName());
60 | if (file == null) {
61 | return Collections.emptyList();
62 | }
63 | return Collections.singletonList(GoToItemFactory.create(Category.TABLE, file, DEFAULT_OFFSET));
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/TestCaseStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.ArrayList;
19 | import java.util.HashSet;
20 | import java.util.List;
21 | import java.util.Set;
22 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
23 | import org.netbeans.modules.php.api.util.FileUtils;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
25 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
26 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItemFactory;
27 | import org.netbeans.modules.php.editor.api.elements.ClassElement;
28 | import org.openide.filesystems.FileObject;
29 |
30 | public class TestCaseStatus extends CakePHP3GoToStatus {
31 |
32 | private final Set testeds = new HashSet<>();
33 |
34 | public TestCaseStatus(FileObject fileObject, int offset) {
35 | super(fileObject, offset);
36 | }
37 |
38 | @Override
39 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
40 | if (fileObject.isFolder() || !FileUtils.isPhpFile(fileObject)) {
41 | return;
42 | }
43 | FileObject sourceDirectory = phpModule.getSourceDirectory();
44 | if (sourceDirectory == null) {
45 | return;
46 | }
47 | String name = fileObject.getName();
48 | int lastIndexOfTest = name.lastIndexOf("Test"); // NOI18N
49 | String testedClassName = ""; // NOI18N
50 | if (lastIndexOfTest != -1) {
51 | testedClassName = name.substring(0, lastIndexOfTest);
52 | }
53 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
54 | Set classElements = getClassElements(sourceDirectory, testedClassName);
55 | for (ClassElement classElement : classElements) {
56 | FileObject fo = classElement.getFileObject();
57 | if (fo != null && fo != fileObject) {
58 | CakePHPModule.Category category = cakeModule.getCategory(fo);
59 | testeds.add(GoToItemFactory.create(category, fo, offset));
60 | }
61 | }
62 | }
63 |
64 | @Override
65 | public List getSmart() {
66 | List items = new ArrayList<>(testeds);
67 | return items;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/CakePHP3GoToStatusFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
19 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
20 | import org.openide.filesystems.FileObject;
21 |
22 | /**
23 | *
24 | * @author junichi11
25 | */
26 | public final class CakePHP3GoToStatusFactory {
27 |
28 | private static final CakePHP3GoToStatusFactory INSTANCE = new CakePHP3GoToStatusFactory();
29 | // private static final CakePHP3GoToStatus DUMMY_STATUS = new DefaultStatus(null, 0);
30 |
31 | private CakePHP3GoToStatusFactory() {
32 | }
33 |
34 | public static CakePHP3GoToStatusFactory getInstance() {
35 | return INSTANCE;
36 | }
37 |
38 | public CakePHP3GoToStatus create(FileObject fileObject, int offset) {
39 | CakePHPModule cakeModule = CakePHPModule.forFileObject(fileObject);
40 | Category category = cakeModule.getCategory(fileObject);
41 | CakePHP3GoToStatus status;
42 | switch (category) {
43 | case CONTROLLER: // fallthrough
44 | case VIEW_CELL:
45 | status = new ControllerStatus(fileObject, offset);
46 | break;
47 | case TEMPLATE: // fallthrough
48 | case TEMPLATE_CELL:
49 | case ELEMENT:
50 | case EMAIL:
51 | case ERROR:
52 | case PAGES:
53 | case LAYOUT:
54 | status = new TemplateStatus(fileObject, offset);
55 | break;
56 | case TEST_CASE:
57 | status = new TestCaseStatus(fileObject, offset);
58 | break;
59 | case TABLE:
60 | status = new TableStatus(fileObject, offset);
61 | break;
62 | case ENTITY:
63 | status = new EntityStatus(fileObject, offset);
64 | break;
65 | case COMPONENT:
66 | status = new ComponentStatus(fileObject, offset);
67 | break;
68 | case HELPER:
69 | status = new HelperStatus(fileObject, offset);
70 | break;
71 | default:
72 | // status = DUMMY_STATUS;
73 | status = new DefaultStatus(fileObject, offset);
74 | break;
75 | }
76 | return status;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/utils/JsonSimpleSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.utils;
17 |
18 | import java.io.IOException;
19 | import java.io.Reader;
20 | import java.lang.reflect.Field;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.logging.Level;
24 | import java.util.logging.Logger;
25 | import org.json.simple.JSONObject;
26 | import org.json.simple.parser.JSONParser;
27 | import org.json.simple.parser.ParseException;
28 |
29 | /**
30 | *
31 | * @author junichi11
32 | */
33 | public final class JsonSimpleSupport {
34 |
35 | private static final Logger LOGGER = Logger.getLogger(JsonSimpleSupport.class.getName());
36 |
37 | private JsonSimpleSupport() {
38 | }
39 |
40 | public static T fromJson(Reader reader, Class type) throws IOException {
41 | JSONParser parser = new JSONParser();
42 | if (reader == null || type == null) {
43 | return null;
44 | }
45 | Object object = null;
46 | try {
47 | object = parser.parse(reader);
48 | } catch (ParseException ex) {
49 | LOGGER.log(Level.INFO, "Can't parse json file");
50 | }
51 | if (object == null) {
52 | return null;
53 | }
54 | return fromJson(object, type);
55 | }
56 |
57 | private static T fromJson(Object o, Class type) {
58 | if (type == String.class
59 | || type == Integer.class
60 | || type == Map.class
61 | || type == Long.class
62 | || type == List.class) {
63 | return type.cast(o);
64 | }
65 | JSONObject jsonObject = (JSONObject) o;
66 | T instance = null;
67 | try {
68 | instance = type.newInstance();
69 | for (Object key : jsonObject.keySet()) {
70 | try {
71 | Field field = type.getDeclaredField((String) key);
72 | Object value = fromJson(jsonObject.get(key), field.getType());
73 | field.setAccessible(true);
74 | field.set(instance, value);
75 | } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
76 | LOGGER.log(Level.WARNING, ex.getMessage());
77 | }
78 | }
79 | } catch (InstantiationException | IllegalAccessException ex) {
80 | LOGGER.log(Level.WARNING, ex.getMessage());
81 | }
82 | return instance;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/ComponentStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import org.netbeans.modules.parsing.spi.ParseException;
21 | import org.netbeans.modules.php.api.editor.PhpClass;
22 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
23 | import org.netbeans.modules.php.cake3.editor.visitors.ComponentVisitor;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
25 | import static org.netbeans.modules.php.cake3.modules.CakePHPModule.Category.COMPONENT;
26 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
27 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItemFactory;
28 | import org.openide.filesystems.FileObject;
29 | import org.openide.util.Exceptions;
30 | import org.openide.util.Pair;
31 |
32 | public class ComponentStatus extends CakePHP3GoToStatus {
33 |
34 | private final List components = new ArrayList<>();
35 |
36 | public ComponentStatus(FileObject fileObject, int offset) {
37 | super(fileObject, offset);
38 | }
39 |
40 | @Override
41 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
42 | clear();
43 | ComponentVisitor visitor = new ComponentVisitor(phpModule);
44 | try {
45 | scan(visitor, fileObject);
46 | } catch (ParseException ex) {
47 | Exceptions.printStackTrace(ex);
48 | }
49 | addItems(COMPONENT, visitor.getComponents());
50 | }
51 |
52 | private void addItems(Category category, List> phpClasses) {
53 | for (Pair clazz : phpClasses) {
54 | PhpClass phpClass = clazz.second();
55 | FileObject file = phpClass.getFile();
56 | if (file == null) {
57 | continue;
58 | }
59 | switch (category) {
60 | case COMPONENT:
61 | components.add(GoToItemFactory.create(category, file, DEFAULT_OFFSET));
62 | break;
63 | default:
64 | break;
65 | }
66 | }
67 | }
68 |
69 | @Override
70 | public List getSmart() {
71 | return getComponents();
72 | }
73 |
74 | @Override
75 | public List getComponents() {
76 | List items = new ArrayList<>(components);
77 | return items;
78 | }
79 |
80 | private void clear() {
81 | components.clear();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/HelperStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import org.netbeans.modules.parsing.spi.ParseException;
21 | import org.netbeans.modules.php.api.editor.PhpClass;
22 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
23 | import org.netbeans.modules.php.cake3.editor.visitors.HelperVisitor;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
25 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
26 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
27 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItemFactory;
28 | import static org.netbeans.modules.php.cake3.ui.actions.gotos.status.CakePHP3GoToStatus.DEFAULT_OFFSET;
29 | import org.openide.filesystems.FileObject;
30 | import org.openide.util.Exceptions;
31 | import org.openide.util.Pair;
32 |
33 | public class HelperStatus extends CakePHP3GoToStatus {
34 |
35 | private final List helpers = new ArrayList<>();
36 |
37 | public HelperStatus(FileObject fileObject, int offset) {
38 | super(fileObject, offset);
39 | }
40 |
41 | @Override
42 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
43 | clear();
44 | HelperVisitor visitor = new HelperVisitor(phpModule);
45 | try {
46 | scan(visitor, fileObject);
47 | } catch (ParseException ex) {
48 | Exceptions.printStackTrace(ex);
49 | }
50 | addItems(Category.HELPER, visitor.getHelpers());
51 | }
52 |
53 | private void addItems(CakePHPModule.Category category, List> phpClasses) {
54 | for (Pair clazz : phpClasses) {
55 | PhpClass phpClass = clazz.second();
56 | FileObject file = phpClass.getFile();
57 | if (file == null) {
58 | continue;
59 | }
60 | switch (category) {
61 | case HELPER:
62 | helpers.add(GoToItemFactory.create(category, file, DEFAULT_OFFSET));
63 | break;
64 | default:
65 | break;
66 | }
67 | }
68 | }
69 |
70 | @Override
71 | public List getSmart() {
72 | return getHelpers();
73 | }
74 |
75 | @Override
76 | public List getHelpers() {
77 | List items = new ArrayList<>(helpers);
78 | return items;
79 | }
80 |
81 | private void clear() {
82 | helpers.clear();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/CakePHP3Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import org.netbeans.api.annotations.common.StaticResource;
19 |
20 | /**
21 | *
22 | * @author junichi11
23 | */
24 | public final class CakePHP3Constants {
25 |
26 | @StaticResource
27 | public static final String CAKE_ICON_16 = "org/netbeans/modules/php/cake3/resources/cakephp_icon_16.png"; // NOI18N
28 | @StaticResource
29 | public static final String PHP_ICON = "org/netbeans/modules/php/cake3/resources/php_icon.png"; // NOI18N
30 | @StaticResource
31 | public static final String CTP_ICON = "org/netbeans/modules/php/cake3/resources/ctp_icon.png"; // NOI18N
32 | @StaticResource
33 | public static final String GOTO_BEHAVIOR_ICON = "org/netbeans/modules/php/cake3/resources/goto-behavior.png"; // NOI18N
34 | @StaticResource
35 | public static final String GOTO_TEMPLATE_CELL_ICON = "org/netbeans/modules/php/cake3/resources/goto-cell.png"; // NOI18N
36 | @StaticResource
37 | public static final String GOTO_CONTROLLER_ICON = "org/netbeans/modules/php/cake3/resources/goto-controller.png"; // NOI18N
38 | @StaticResource
39 | public static final String GOTO_ELEMENT_ICON = "org/netbeans/modules/php/cake3/resources/goto-element.png"; // NOI18N
40 | @StaticResource
41 | public static final String GOTO_ENTITY_ICON = "org/netbeans/modules/php/cake3/resources/goto-entity.png"; // NOI18N
42 | @StaticResource
43 | public static final String GOTO_FIXTURE_ICON = "org/netbeans/modules/php/cake3/resources/goto-fixture.png"; // NOI18N
44 | @StaticResource
45 | public static final String GOTO_TABLE_ICON = "org/netbeans/modules/php/cake3/resources/goto-table.png"; // NOI18N
46 | @StaticResource
47 | public static final String GOTO_TEMPLATE_ICON = "org/netbeans/modules/php/cake3/resources/goto-template.png"; // NOI18N
48 | @StaticResource
49 | public static final String GOTO_TESTCASE_ICON = "org/netbeans/modules/php/cake3/resources/goto-testcase.png"; // NOI18N
50 | @StaticResource
51 | public static final String GOTO_COMPONENT_ICON = "org/netbeans/modules/php/cake3/resources/goto-component.png"; // NOI18N
52 | @StaticResource
53 | public static final String GOTO_HELPER_ICON = "org/netbeans/modules/php/cake3/resources/goto-helper.png"; // NOI18N
54 | @StaticResource
55 | public static final String GOTO_VIEW_CELL_ICON = "org/netbeans/modules/php/cake3/resources/goto-view-cell.png"; // NOI18N
56 |
57 | public static final String CAKEPHP3 = "CakePHP3"; // NOI18N
58 | public static final String CAKEPHP3_FRAMEWORK = "CakePHP3 Framework"; // NOI18N
59 | public static final String UTF8 = "UTF-8"; // NOI18N
60 |
61 | private CakePHP3Constants() {
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/CakeVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import java.io.IOException;
19 | import java.util.List;
20 | import java.util.regex.Matcher;
21 | import java.util.regex.Pattern;
22 | import org.openide.filesystems.FileObject;
23 | import org.openide.util.Exceptions;
24 |
25 | public class CakeVersion implements Versionable {
26 |
27 | private static final Pattern VERSION_PATTERN = Pattern.compile("^(?\\d)\\.(?\\d)\\.(?\\d)(?.*)$"); // NOI18N
28 |
29 | private String version = UNNKOWN;
30 | private int major = -1;
31 | private int minor = -1;
32 | private int patch = -1;
33 |
34 | private CakeVersion() {
35 | }
36 |
37 | private CakeVersion major(int major) {
38 | this.major = major;
39 | return this;
40 | }
41 |
42 | private CakeVersion minor(int minor) {
43 | this.minor = minor;
44 | return this;
45 | }
46 |
47 | private CakeVersion patch(int patch) {
48 | this.patch = patch;
49 | return this;
50 | }
51 |
52 | private CakeVersion version(String version) {
53 | this.version = version;
54 | return this;
55 | }
56 |
57 | public static CakeVersion create(FileObject file) {
58 | CakeVersion version = new CakeVersion();
59 | if (file == null || file.isFolder()) {
60 | return version;
61 | }
62 | try {
63 | List lines = file.asLines(CakePHP3Constants.UTF8);
64 | for (String line : lines) {
65 | Matcher matcher = VERSION_PATTERN.matcher(line);
66 | if (!matcher.matches()) {
67 | continue;
68 | }
69 | int major = Integer.parseInt(matcher.group(MAJOR));
70 | int minor = Integer.parseInt(matcher.group(MINOR));
71 | int patch = Integer.parseInt(matcher.group(PATCH));
72 | version.major(major)
73 | .minor(minor)
74 | .patch(patch)
75 | .version(line);
76 | break;
77 | }
78 | } catch (IOException ex) {
79 | Exceptions.printStackTrace(ex);
80 | }
81 | return version;
82 | }
83 |
84 | @Override
85 | public String getVersionNumber() {
86 | return version;
87 | }
88 |
89 | @Override
90 | public int getMajor() {
91 | return major;
92 | }
93 |
94 | @Override
95 | public int getMinor() {
96 | return minor;
97 | }
98 |
99 | @Override
100 | public int getPatch() {
101 | return patch;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/visitors/ViewVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.visitors;
17 |
18 | import java.util.Collections;
19 | import java.util.HashSet;
20 | import java.util.List;
21 | import java.util.Set;
22 | import org.netbeans.modules.php.api.editor.PhpClass;
23 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
24 | import org.netbeans.modules.php.api.util.StringUtils;
25 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
26 | import org.netbeans.modules.php.cake3.utils.CakePHPCodeUtils;
27 | import org.netbeans.modules.php.editor.CodeUtils;
28 | import org.netbeans.modules.php.editor.parser.astnodes.Expression;
29 | import org.netbeans.modules.php.editor.parser.astnodes.FunctionInvocation;
30 | import org.netbeans.modules.php.editor.parser.astnodes.MethodInvocation;
31 | import org.openide.util.Pair;
32 |
33 | /**
34 | *
35 | * @author junichi11
36 | */
37 | public class ViewVisitor extends CakePHP3Visitor {
38 |
39 | // pair of alias name and PhpClass
40 | private final Set> phpClasses = Collections.synchronizedSet(new HashSet<>());
41 | private static final String LOAD_HELPER_METHOD = "loadHelper"; // NOI18N
42 |
43 | public ViewVisitor(PhpModule phpModule) {
44 | super(phpModule);
45 | }
46 |
47 | @Override
48 | public void visit(MethodInvocation node) {
49 | FunctionInvocation method = node.getMethod();
50 | handleMethod(method);
51 | super.visit(node);
52 | }
53 |
54 | private void handleMethod(FunctionInvocation method) {
55 | String methodName = CodeUtils.extractFunctionName(method);
56 | if (StringUtils.isEmpty(methodName)) {
57 | return;
58 | }
59 | switch (methodName) {
60 | case LOAD_HELPER_METHOD:
61 | addHelper(method);
62 | break;
63 | default:
64 | break;
65 | }
66 | }
67 |
68 | private synchronized void addHelper(FunctionInvocation method) {
69 | List parameters = method.getParameters();
70 | Pair aliasAndEntityName = CakePHPCodeUtils.getAliasAndEntityName(parameters);
71 | String aliasName = aliasAndEntityName.first();
72 | String entityName = aliasAndEntityName.second();
73 | if (!StringUtils.isEmpty(aliasName)) {
74 | if (StringUtils.isEmpty(entityName)) {
75 | entityName = aliasName;
76 | }
77 | Pair phpClass = createPhpClass(Category.HELPER, aliasName, entityName);
78 | if (phpClass != null) {
79 | phpClasses.add(phpClass);
80 | }
81 | }
82 | }
83 |
84 | public Set> getPhpClasses() {
85 | return new HashSet<>(phpClasses);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/commands/CakePHP3FrameworkCommandSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.commands;
17 |
18 | import java.io.File;
19 | import java.util.ArrayList;
20 | import java.util.Arrays;
21 | import java.util.Collections;
22 | import java.util.List;
23 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException;
24 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
25 | import org.netbeans.modules.php.api.util.UiUtils;
26 | import org.netbeans.modules.php.cake3.CakeVersion;
27 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
28 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand;
29 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommandSupport;
30 |
31 | /**
32 | *
33 | * @author junichi11
34 | */
35 | public final class CakePHP3FrameworkCommandSupport extends FrameworkCommandSupport {
36 |
37 | public CakePHP3FrameworkCommandSupport(PhpModule phpModule) {
38 | super(phpModule);
39 | }
40 |
41 | @Override
42 | public String getFrameworkName() {
43 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
44 | CakeVersion cakeVersion = cakeModule.getVersion();
45 | int majorVersion = cakeVersion.getMajor();
46 | String version = majorVersion < 3 ? "" : String.valueOf(majorVersion); // NOI18N
47 | return "CakePHP" + version; // NOI18N
48 | }
49 |
50 | @Override
51 | public void runCommand(CommandDescriptor commandDescriptor, Runnable postExecution) {
52 | String[] commands = commandDescriptor.getFrameworkCommand().getCommands();
53 | String[] commandParams = commandDescriptor.getCommandParams();
54 | List params = new ArrayList<>(commands.length + commandParams.length);
55 | params.addAll(Arrays.asList(commands));
56 | params.addAll(Arrays.asList(commandParams));
57 | try {
58 | Cake3Script.forPhpModule(phpModule, false).runCommand(phpModule, params, postExecution);
59 | } catch (InvalidPhpExecutableException ex) {
60 | UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), getOptionsPath());
61 | }
62 | }
63 |
64 | @Override
65 | protected String getOptionsPath() {
66 | return UiUtils.FRAMEWORKS_AND_TOOLS_OPTIONS_PATH;
67 | }
68 |
69 | @Override
70 | protected File getPluginsDirectory() {
71 | return null;
72 | }
73 |
74 | @Override
75 | protected List getFrameworkCommandsInternal() {
76 | try {
77 | return Cake3Script.forPhpModule(phpModule, true).getCommands(phpModule);
78 | } catch (InvalidPhpExecutableException ex) {
79 | UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), getOptionsPath());
80 | }
81 | return Collections.emptyList();
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToDefaultItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import java.util.Objects;
19 | import javax.swing.Icon;
20 | import org.netbeans.modules.php.api.util.StringUtils;
21 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
22 | import org.openide.filesystems.FileObject;
23 | import org.openide.util.ImageUtilities;
24 |
25 | class GoToDefaultItem implements GoToItem {
26 |
27 | private final FileObject fileObject;
28 | private final int offset;
29 | private final String baseName;
30 | private String offsetName = ""; // NOI18N
31 |
32 | public GoToDefaultItem(FileObject fileObject, int offset) {
33 | this(fileObject, offset, ""); // NOI18N
34 | }
35 |
36 | public GoToDefaultItem(FileObject fileObject, int offset, String baseName) {
37 | this.fileObject = fileObject;
38 | this.offset = offset;
39 | this.baseName = baseName;
40 | }
41 |
42 | @Override
43 | public String getBaseName() {
44 | return baseName;
45 | }
46 |
47 | @Override
48 | public FileObject getFileObject() {
49 | return fileObject;
50 | }
51 |
52 | @Override
53 | public int getOffset() {
54 | return offset;
55 | }
56 |
57 | @Override
58 | public Icon getIcon() {
59 | return ImageUtilities.loadImageIcon(CakePHP3Constants.CAKE_ICON_16, false);
60 | }
61 |
62 | @Override
63 | public int hashCode() {
64 | int hash = 7;
65 | return hash;
66 | }
67 |
68 | @Override
69 | public boolean equals(Object obj) {
70 | if (obj == null) {
71 | return false;
72 | }
73 | if (getClass() != obj.getClass()) {
74 | return false;
75 | }
76 | final GoToDefaultItem other = (GoToDefaultItem) obj;
77 | if (!Objects.equals(this.fileObject, other.fileObject)) {
78 | return false;
79 | }
80 | return this.offset == other.offset;
81 | }
82 |
83 | public void setOffsetName(String offsetName) {
84 | this.offsetName = offsetName;
85 | }
86 |
87 | @Override
88 | public String toString() {
89 | FileObject parent = getFileObject().getParent();
90 | String nameWithExt = getFileObject().getNameExt();
91 | StringBuilder sb = new StringBuilder();
92 | if (!StringUtils.isEmpty(baseName)) {
93 | sb.append("[").append(baseName).append("] "); // NOI18N
94 | }
95 | if (parent != null) {
96 | sb.append(parent.getName());
97 | sb.append("/"); // NOI18N
98 | }
99 | sb.append(nameWithExt);
100 | if (!StringUtils.isEmpty(offsetName)) {
101 | sb.append(":").append(offsetName); // NOI18N
102 | }
103 | return sb.toString();
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/commands/CakePHP3ProjectGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.commands;
17 |
18 | import java.io.File;
19 | import java.util.Arrays;
20 | import java.util.concurrent.ExecutionException;
21 | import java.util.concurrent.Future;
22 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException;
23 | import org.netbeans.modules.php.api.executable.PhpExecutable;
24 | import org.netbeans.modules.php.api.util.StringUtils;
25 | import org.netbeans.modules.php.api.util.UiUtils;
26 | import org.netbeans.modules.php.cake3.options.CakePHP3Options;
27 | import org.openide.util.NbBundle;
28 |
29 | /**
30 | *
31 | * @author junichi11
32 | */
33 | public final class CakePHP3ProjectGenerator {
34 |
35 | private final String composerPath;
36 | private static final String CREATE_PROJECT_COMMAND = "create-project"; // NOI18N
37 | private static final String NO_INTERACTION_PARAM = "--no-interaction"; // NOI18N
38 | private static final String PREFER_DIST_PARAM = "--prefer-dist"; // NOI18N
39 | private static final String CAKEPHP_APP = "cakephp/app"; // NOI18N
40 |
41 | private CakePHP3ProjectGenerator(String composerPath) {
42 | this.composerPath = composerPath;
43 | }
44 |
45 | /**
46 | * Get default CakePHP3ProjectGenerator.
47 | *
48 | * @return
49 | * @throws InvalidPhpExecutableException
50 | */
51 | @NbBundle.Messages({
52 | "CakePHP3ProjectGenerator.invalid.composer=Is not set composer path. Please set it to Options."
53 | })
54 | public static CakePHP3ProjectGenerator getDefault() throws InvalidPhpExecutableException {
55 | CakePHP3Options options = CakePHP3Options.getInstance();
56 | String composerPath = options.getComposerPath();
57 | if (!StringUtils.isEmpty(composerPath)) {
58 | return new CakePHP3ProjectGenerator(composerPath);
59 | }
60 | throw new InvalidPhpExecutableException(Bundle.CakePHP3ProjectGenerator_invalid_composer());
61 | }
62 |
63 | /**
64 | * Generate project via Composer. Use composer create-project command.
65 | *
66 | * @param projectDirectory project directory
67 | * @param projectName project name
68 | */
69 | public void generate(File projectDirectory, String projectName) {
70 | File workDir = projectDirectory.getParentFile();
71 | PhpExecutable phpExecutable = new PhpExecutable(composerPath)
72 | .workDir(workDir)
73 | .additionalParameters(Arrays.asList(CREATE_PROJECT_COMMAND, NO_INTERACTION_PARAM, PREFER_DIST_PARAM, CAKEPHP_APP, projectName)); // NOI18N
74 | Future result = phpExecutable.run();
75 | if (result != null) {
76 | try {
77 | result.get();
78 | } catch (InterruptedException ex) {
79 | Thread.currentThread().interrupt();
80 | } catch (ExecutionException ex) {
81 | UiUtils.processExecutionException(ex);
82 | }
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/items/GoToItemFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.items;
17 |
18 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
19 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
20 | import org.openide.filesystems.FileObject;
21 |
22 | /**
23 | *
24 | * @author junichi11
25 | */
26 | public final class GoToItemFactory {
27 |
28 | private GoToItemFactory() {
29 | }
30 |
31 | public static GoToItem create(Category category, FileObject fileObject, int offset) {
32 | return create(category, fileObject, offset, "");
33 | }
34 |
35 | public static GoToItem create(Category category, FileObject fileObject, int offset, String offsetName) {
36 | CakePHPModule cakeModule = CakePHPModule.forFileObject(fileObject);
37 | CakePHPModule.Base base = cakeModule.getBase(fileObject);
38 | String baseName = ""; // NOI18N
39 | switch (base) {
40 | case APP:
41 | baseName = cakeModule.getNameSpace();
42 | break;
43 | case CORE:
44 | baseName = "Core"; // NOI18N
45 | break;
46 | case PLUGIN:
47 | baseName = cakeModule.getPluginName(fileObject);
48 | break;
49 | default:
50 | break;
51 | }
52 | switch (category) {
53 | case BEHAVIOR:
54 | return new GoToBehaviorItem(fileObject, offset, baseName);
55 | case COMPONENT:
56 | return new GoToComponentItem(fileObject, offset, baseName);
57 | case CONTROLLER:
58 | GoToControllerItem controllerItem = new GoToControllerItem(fileObject, offset, baseName);
59 | controllerItem.setOffsetName(offsetName);
60 | return controllerItem;
61 | case ELEMENT:
62 | return new GoToElementItem(fileObject, offset, baseName);
63 | case ENTITY:
64 | return new GoToEntityItem(fileObject, offset, baseName);
65 | case FIXTURE:
66 | return new GoToFixtureItem(fileObject, offset, baseName);
67 | case HELPER:
68 | return new GoToHelperItem(fileObject, offset, baseName);
69 | case TABLE:
70 | return new GoToTableItem(fileObject, offset, baseName);
71 | case TEMPLATE:
72 | return new GoToTemplateItem(fileObject, offset, baseName);
73 | case TEMPLATE_CELL:
74 | return new GoToTemplateCellItem(fileObject, offset, baseName);
75 | case TEST_CASE:
76 | return new GoToTestCaseItem(fileObject, offset, baseName);
77 | case VIEW_CELL:
78 | GoToViewCellItem viewCellItem = new GoToViewCellItem(fileObject, offset, baseName);
79 | viewCellItem.setOffsetName(offsetName);
80 | return viewCellItem;
81 | default:
82 | return new GoToDefaultItem(fileObject, offset);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/wizards/CakePHP3NewProjectWizardPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.wizards;
17 |
18 | import java.awt.Component;
19 | import java.util.HashSet;
20 | import java.util.Set;
21 | import javax.swing.event.ChangeEvent;
22 | import javax.swing.event.ChangeListener;
23 | import org.openide.WizardDescriptor;
24 | import org.openide.WizardValidationException;
25 | import org.openide.util.HelpCtx;
26 | import org.openide.util.NbBundle;
27 |
28 | /**
29 | * Panel just asking for basic info.
30 | */
31 | public class CakePHP3NewProjectWizardPanel implements WizardDescriptor.Panel,
32 | WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
33 |
34 | private WizardDescriptor wizardDescriptor;
35 | private CakePHP3NewProjectPanelVisual component;
36 | public static final String PROP_NAME = "name"; // NOI18N
37 | public static final String PROP_PROJ_DIR = "projdir"; // NOI18N
38 | public static final String PROP_PROJECT_TYPE = "repository-name"; // NOI18N
39 |
40 | public CakePHP3NewProjectWizardPanel() {
41 | }
42 |
43 | @Override
44 | public Component getComponent() {
45 | if (component == null) {
46 | component = new CakePHP3NewProjectPanelVisual(this);
47 | component.setName(NbBundle.getMessage(CakePHP3NewProjectWizardPanel.class, "LBL_CreateProjectStep"));
48 | }
49 | return component;
50 | }
51 |
52 | @Override
53 | public HelpCtx getHelp() {
54 | return null;
55 | }
56 |
57 | @Override
58 | public boolean isValid() {
59 | getComponent();
60 | return component.valid(wizardDescriptor);
61 | }
62 |
63 | private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
64 |
65 | @Override
66 | public final void addChangeListener(ChangeListener l) {
67 | synchronized (listeners) {
68 | listeners.add(l);
69 | }
70 | }
71 |
72 | @Override
73 | public final void removeChangeListener(ChangeListener l) {
74 | synchronized (listeners) {
75 | listeners.remove(l);
76 | }
77 | }
78 |
79 | protected final void fireChangeEvent() {
80 | Set ls;
81 | synchronized (listeners) {
82 | ls = new HashSet<>(listeners);
83 | }
84 | ChangeEvent ev = new ChangeEvent(this);
85 | for (ChangeListener l : ls) {
86 | l.stateChanged(ev);
87 | }
88 | }
89 |
90 | @Override
91 | public void readSettings(Object settings) {
92 | wizardDescriptor = (WizardDescriptor) settings;
93 | component.read(wizardDescriptor);
94 | }
95 |
96 | @Override
97 | public void storeSettings(Object settings) {
98 | WizardDescriptor d = (WizardDescriptor) settings;
99 | component.store(d);
100 | }
101 |
102 | @Override
103 | public boolean isFinishPanel() {
104 | return true;
105 | }
106 |
107 | @Override
108 | public void validate() throws WizardValidationException {
109 | getComponent();
110 | component.validate(wizardDescriptor);
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/options/CakePHP3OptionsPanelController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.options;
17 |
18 | import java.beans.PropertyChangeListener;
19 | import java.beans.PropertyChangeSupport;
20 | import javax.swing.JComponent;
21 | import javax.swing.SwingUtilities;
22 | import org.netbeans.modules.php.api.util.UiUtils;
23 | import org.netbeans.spi.options.OptionsPanelController;
24 | import org.openide.util.HelpCtx;
25 | import org.openide.util.Lookup;
26 | import org.openide.util.NbBundle;
27 |
28 | @UiUtils.PhpOptionsPanelRegistration(
29 | id = CakePHP3OptionsPanelController.ID,
30 | displayName = "#LBL_CakePHP3OptionsName",
31 | position = 490
32 | )
33 | @NbBundle.Messages({
34 | "LBL_CakePHP3OptionsName=CakePHP3/4",
35 | "CakePHP3.options.keywords.TabTitle=Frameworks & Tools",
36 | "AdvancedOption_Keywords_CakePHP3=cake, cakephp, cakephp3, CakePHP3, cakephp4, CakePHP4"
37 | })
38 | @OptionsPanelController.Keywords(
39 | keywords = "#AdvancedOption_Keywords_CakePHP3",
40 | location = UiUtils.OPTIONS_PATH, tabTitle = "#CakePHP3.options.keywords.TabTitle"
41 | )
42 | public final class CakePHP3OptionsPanelController extends OptionsPanelController {
43 |
44 | static final String ID = "CakePHP3/4"; // NOI18N
45 | private CakePHP3OptionsPanel panel;
46 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
47 | private boolean changed;
48 |
49 | @Override
50 | public void update() {
51 | getPanel().load();
52 | changed = false;
53 | }
54 |
55 | @Override
56 | public void applyChanges() {
57 | SwingUtilities.invokeLater(new Runnable() {
58 | @Override
59 | public void run() {
60 | getPanel().store();
61 | changed = false;
62 | }
63 | });
64 | }
65 |
66 | @Override
67 | public void cancel() {
68 | // need not do anything special, if no changes have been persisted yet
69 | }
70 |
71 | @Override
72 | public boolean isValid() {
73 | return getPanel().valid();
74 | }
75 |
76 | @Override
77 | public boolean isChanged() {
78 | return changed;
79 | }
80 |
81 | @Override
82 | public HelpCtx getHelpCtx() {
83 | return null; // new HelpCtx("...ID") if you have a help set
84 | }
85 |
86 | @Override
87 | public JComponent getComponent(Lookup masterLookup) {
88 | return getPanel();
89 | }
90 |
91 | @Override
92 | public void addPropertyChangeListener(PropertyChangeListener l) {
93 | pcs.addPropertyChangeListener(l);
94 | }
95 |
96 | @Override
97 | public void removePropertyChangeListener(PropertyChangeListener l) {
98 | pcs.removePropertyChangeListener(l);
99 | }
100 |
101 | private CakePHP3OptionsPanel getPanel() {
102 | if (panel == null) {
103 | panel = new CakePHP3OptionsPanel(this);
104 | }
105 | return panel;
106 | }
107 |
108 | void changed() {
109 | if (!changed) {
110 | changed = true;
111 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
112 | }
113 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/commands/CakePHP3CommandXmlParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.commands;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 | import java.util.List;
21 | import javax.xml.parsers.DocumentBuilder;
22 | import javax.xml.parsers.DocumentBuilderFactory;
23 | import javax.xml.parsers.ParserConfigurationException;
24 | import org.openide.util.Exceptions;
25 | import org.w3c.dom.Document;
26 | import org.w3c.dom.Element;
27 | import org.w3c.dom.NamedNodeMap;
28 | import org.w3c.dom.Node;
29 | import org.w3c.dom.NodeList;
30 | import org.xml.sax.SAXException;
31 |
32 | /**
33 | * @author junichi11
34 | */
35 | public class CakePHP3CommandXmlParser {
36 |
37 | private final List commands;
38 |
39 | public CakePHP3CommandXmlParser(List commands) {
40 | this.commands = commands;
41 | }
42 |
43 | public static void parse(File file, List commands) throws SAXException {
44 | // XXX use XMLReader? : FileUtils.createXmlReader
45 | CakePHP3CommandXmlParser parser = new CakePHP3CommandXmlParser(commands);
46 | DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
47 | try {
48 | DocumentBuilder builder = builderFactory.newDocumentBuilder();
49 | Document document = builder.parse(file);
50 | Element root = document.getDocumentElement();
51 | switch (root.getNodeName()) {
52 | case "shells": // NOI18N
53 | parser.parseCommandList(root);
54 | break;
55 | case "shell": // NOI18N
56 | parser.parseCommand(root);
57 | break;
58 | default:
59 | break;
60 | }
61 | } catch (IOException | ParserConfigurationException ex) {
62 | Exceptions.printStackTrace(ex);
63 | }
64 | }
65 |
66 | protected void parseCommandList(Element root) {
67 | NodeList nodeList = root.getChildNodes();
68 | for (int i = 0; i < nodeList.getLength(); i++) {
69 | Node node = nodeList.item(i);
70 | NamedNodeMap attr = node.getAttributes();
71 | commands.add(new Cake3CommandItem(
72 | attr.getNamedItem("call_as").getNodeValue(), attr.getNamedItem("provider").getNodeValue(), attr.getNamedItem("name").getNodeValue())); // NOI18N
73 | }
74 | }
75 |
76 | protected void parseCommand(Element root) {
77 | String command = root.getElementsByTagName("command").item(0).getTextContent(); // NOI18N
78 | String description = root.getElementsByTagName("description").item(0).getTextContent(); // NOI18N
79 | Cake3CommandItem item = new Cake3CommandItem(command, description, command);
80 | NodeList subcommands = root.getElementsByTagName("subcommands"); // NOI18N
81 | for (int i = 0; i < subcommands.getLength(); i++) {
82 | Node node = subcommands.item(i);
83 | NodeList children = node.getChildNodes();
84 | for (int j = 0; j < children.getLength(); j++) {
85 | Node child = children.item(j);
86 | NamedNodeMap attr = child.getAttributes();
87 | item.addSubcommand(new Cake3CommandItem(
88 | attr.getNamedItem("name").getTextContent(), // NOI18N
89 | attr.getNamedItem("help").getTextContent(), // NOI18N
90 | attr.getNamedItem("name").getTextContent())); // NOI18N
91 | }
92 | }
93 | commands.add(item);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/visitors/TemplateVisitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.visitors;
17 |
18 | import java.util.Collections;
19 | import java.util.HashSet;
20 | import java.util.Set;
21 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
22 | import org.netbeans.modules.php.api.util.StringUtils;
23 | import org.netbeans.modules.php.cake3.utils.CakePHPCodeUtils;
24 | import org.netbeans.modules.php.editor.CodeUtils;
25 | import org.netbeans.modules.php.editor.parser.astnodes.FunctionInvocation;
26 | import org.netbeans.modules.php.editor.parser.astnodes.MethodInvocation;
27 | import org.netbeans.modules.php.editor.parser.astnodes.Variable;
28 |
29 | public class TemplateVisitor extends CakePHP3Visitor {
30 |
31 | private static final String ELEMENT_METHOD = "element"; // NOI18N
32 | private static final String EXTEND_METHOD = "extend"; // NOI18N
33 | private static final String CELL_METHOD = "cell"; // NOI18N
34 | private final Set elements = Collections.synchronizedSet(new HashSet<>());
35 | private final Set extendz = Collections.synchronizedSet(new HashSet<>());
36 | private final Set cells = Collections.synchronizedSet(new HashSet<>());
37 |
38 | public TemplateVisitor(PhpModule phpModule) {
39 | super(phpModule);
40 | }
41 |
42 | @Override
43 | public void visit(MethodInvocation node) {
44 | super.visit(node);
45 | if (!(node.getDispatcher() instanceof Variable) || !"$this".equals(CodeUtils.extractVariableName((Variable) node.getDispatcher()))) { // NOI18N
46 | return;
47 | }
48 | FunctionInvocation method = node.getMethod();
49 | handleMethod(method);
50 | }
51 |
52 | private void handleMethod(FunctionInvocation method) {
53 | String methodName = CodeUtils.extractFunctionName(method);
54 | if (StringUtils.isEmpty(methodName)) {
55 | return;
56 | }
57 | switch (methodName) {
58 | case ELEMENT_METHOD:
59 | addElements(method);
60 | break;
61 | case EXTEND_METHOD:
62 | addExtends(method);
63 | break;
64 | case CELL_METHOD:
65 | addCells(method);
66 | break;
67 | default:
68 | break;
69 | }
70 |
71 | }
72 |
73 | private void addElements(FunctionInvocation method) {
74 | String elementPath = getFirstParameter(method);
75 | if (!StringUtils.isEmpty(elementPath)) {
76 | elements.add(elementPath);
77 | }
78 | }
79 |
80 | private void addExtends(FunctionInvocation method) {
81 | String extendsPath = getFirstParameter(method);
82 | if (!StringUtils.isEmpty(extendsPath)) {
83 | extendz.add(extendsPath);
84 | }
85 | }
86 |
87 | private void addCells(FunctionInvocation method) {
88 | String cell = getFirstParameter(method);
89 | if (!StringUtils.isEmpty(cell)) {
90 | cells.add(cell);
91 | }
92 | }
93 |
94 | private String getFirstParameter(FunctionInvocation method) {
95 | return CakePHPCodeUtils.getFirstParameter(method);
96 | }
97 |
98 | public Set getElements() {
99 | return new HashSet<>(elements);
100 | }
101 |
102 | public Set getExtends() {
103 | return new HashSet<>(extendz);
104 | }
105 |
106 | public Set getCells() {
107 | return new HashSet<>(cells);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ConfigurationFiles.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import java.io.File;
19 | import java.util.ArrayList;
20 | import java.util.Collection;
21 | import java.util.List;
22 | import javax.swing.event.ChangeListener;
23 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
25 | import org.netbeans.modules.php.spi.phpmodule.ImportantFilesImplementation;
26 | import org.openide.filesystems.FileChangeAdapter;
27 | import org.openide.filesystems.FileEvent;
28 | import org.openide.filesystems.FileObject;
29 | import org.openide.filesystems.FileRenameEvent;
30 | import org.openide.filesystems.FileUtil;
31 | import org.openide.util.ChangeSupport;
32 |
33 | /**
34 | *
35 | * @author junichi11
36 | */
37 | public final class ConfigurationFiles extends FileChangeAdapter implements ImportantFilesImplementation {
38 |
39 | private final PhpModule phpModule;
40 | private final ChangeSupport changeSupport = new ChangeSupport(this);
41 |
42 | // @GuardedBy("this")
43 | private boolean isInitialized = false;
44 |
45 | public ConfigurationFiles(PhpModule phpModule) {
46 | assert phpModule != null;
47 | this.phpModule = phpModule;
48 | }
49 |
50 | @Override
51 | public Collection getFiles() {
52 | List directories = getConfigDirectories();
53 | List files = new ArrayList<>();
54 | for (FileObject directory : directories) {
55 | FileObject[] children = directory.getChildren();
56 | for (FileObject child : children) {
57 | if (child.isFolder()) {
58 | continue;
59 | }
60 | files.add(new FileInfo(child));
61 | }
62 | }
63 | return files;
64 | }
65 |
66 | private synchronized List getConfigDirectories() {
67 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
68 | List directories = cakeModule.getDirectories(CakePHPModule.Base.APP, CakePHPModule.Category.CONFIG, null);
69 | if (!isInitialized) {
70 | isInitialized = true;
71 | for (FileObject directory : directories) {
72 | addListener(FileUtil.toFile(directory));
73 | }
74 | }
75 | return directories;
76 | }
77 |
78 | private void addListener(File path) {
79 | try {
80 | FileUtil.addRecursiveListener(this, path);
81 | } catch (IllegalArgumentException ex) {
82 | // noop, already listening
83 | assert false : path;
84 | }
85 | }
86 |
87 | @Override
88 | public void addChangeListener(ChangeListener listener) {
89 | changeSupport.addChangeListener(listener);
90 | }
91 |
92 | @Override
93 | public void removeChangeListener(ChangeListener listener) {
94 | changeSupport.removeChangeListener(listener);
95 | }
96 |
97 | private void fireChange() {
98 | changeSupport.fireChange();
99 | }
100 |
101 | //~ FS
102 | @Override
103 | public void fileRenamed(FileRenameEvent fe) {
104 | fireChange();
105 | }
106 |
107 | @Override
108 | public void fileDeleted(FileEvent fe) {
109 | fireChange();
110 | }
111 |
112 | @Override
113 | public void fileDataCreated(FileEvent fe) {
114 | fireChange();
115 | }
116 |
117 | @Override
118 | public void fileFolderCreated(FileEvent fe) {
119 | fireChange();
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/editor/visitors/CakePHP3Visitor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.editor.visitors;
17 |
18 | import java.util.Collection;
19 | import java.util.logging.Level;
20 | import java.util.logging.Logger;
21 | import org.netbeans.api.annotations.common.CheckForNull;
22 | import org.netbeans.modules.php.api.editor.EditorSupport;
23 | import org.netbeans.modules.php.api.editor.PhpClass;
24 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
25 | import org.netbeans.modules.php.api.util.StringUtils;
26 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
27 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
28 | import org.netbeans.modules.php.editor.parser.astnodes.visitors.DefaultVisitor;
29 | import org.openide.filesystems.FileObject;
30 | import org.openide.util.Lookup;
31 | import org.openide.util.Pair;
32 |
33 | /**
34 | *
35 | * @author junichi11
36 | */
37 | public class CakePHP3Visitor extends DefaultVisitor {
38 |
39 | private final PhpModule phpModule;
40 | private static final Logger LOGGER = Logger.getLogger(CakePHP3Visitor.class.getName());
41 |
42 | public CakePHP3Visitor(PhpModule phpModule) {
43 | this.phpModule = phpModule;
44 | }
45 |
46 | public PhpModule getPhpModule() {
47 | return phpModule;
48 | }
49 |
50 | @CheckForNull
51 | public Pair createPhpClass(Category category, String aliasName, String entityName) {
52 | if (StringUtils.isEmpty(aliasName)) {
53 | return null;
54 | }
55 |
56 | if (StringUtils.isEmpty(entityName)) {
57 | entityName = aliasName;
58 | }
59 | boolean isSame = aliasName.equals(entityName);
60 | // plugin?
61 | String pluginName = null;
62 | int dotPosition = entityName.indexOf("."); // NOI18N
63 | if (dotPosition > 0) {
64 | pluginName = entityName.substring(0, dotPosition);
65 | entityName = entityName.substring(dotPosition + 1);
66 | if (isSame) {
67 | aliasName = entityName;
68 | }
69 | }
70 |
71 | //get entity file
72 | FileObject entityFile = getEntityFile(category, entityName, pluginName);
73 | if (entityFile == null) {
74 | return null;
75 | }
76 |
77 | return createPhpClass(aliasName, entityFile);
78 | }
79 |
80 | @CheckForNull
81 | private Pair createPhpClass(String aliasName, FileObject entityFile) {
82 | EditorSupport editorSupport = Lookup.getDefault().lookup(EditorSupport.class);
83 | if (editorSupport == null) {
84 | LOGGER.log(Level.INFO, "Not found:{0}", EditorSupport.class);
85 | return null;
86 | }
87 |
88 | if (StringUtils.isEmpty(aliasName)) {
89 | return null;
90 | }
91 | Collection phpClasses = editorSupport.getClasses(entityFile);
92 | for (PhpClass phpClass : phpClasses) {
93 | phpClass.setFile(entityFile);
94 | return Pair.of(aliasName, phpClass);
95 | }
96 | return null;
97 | }
98 |
99 | @CheckForNull
100 | protected FileObject getEntityFile(Category category, String entityName, String pluginName) {
101 | CakePHPModule module = CakePHPModule.forPhpModule(phpModule);
102 | CakePHPModule.Base base;
103 | if (!StringUtils.isEmpty(pluginName)) {
104 | base = CakePHPModule.Base.PLUGIN;
105 | } else {
106 | base = CakePHPModule.Base.APP;
107 | }
108 | String relativePath = module.toPhpFileName(category, entityName);
109 | return module.getFile(base, category, relativePath, pluginName);
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/CakePHP3ActionsExtender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.List;
21 | import javax.swing.Action;
22 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
23 | import org.netbeans.modules.php.cake3.dotcake.Dotcake;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
25 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
26 | import org.netbeans.modules.php.cake3.ui.actions.CakePHP3BaseAction;
27 | import org.netbeans.modules.php.cake3.ui.actions.CakePHP3GoToActionAction;
28 | import org.netbeans.modules.php.cake3.ui.actions.CakePHP3GoToViewAction;
29 | import org.netbeans.modules.php.cake3.ui.actions.CakePHP3RefreshModuleAction;
30 | import org.netbeans.modules.php.cake3.ui.actions.CakePHP3RunCommandAction;
31 | import org.netbeans.modules.php.cake3.ui.actions.CakeServerAction;
32 | import org.netbeans.modules.php.cake3.ui.actions.OpenDotcakeAction;
33 | import org.netbeans.modules.php.spi.framework.PhpModuleActionsExtender;
34 | import org.netbeans.modules.php.spi.framework.actions.GoToActionAction;
35 | import org.netbeans.modules.php.spi.framework.actions.GoToViewAction;
36 | import org.netbeans.modules.php.spi.framework.actions.RunCommandAction;
37 | import org.openide.filesystems.FileObject;
38 | import org.openide.util.NbBundle;
39 |
40 | /**
41 | *
42 | * @author junichi11
43 | */
44 | public class CakePHP3ActionsExtender extends PhpModuleActionsExtender {
45 |
46 | private final PhpModule phpModule;
47 |
48 | public CakePHP3ActionsExtender(PhpModule phpModule) {
49 | this.phpModule = phpModule;
50 | }
51 |
52 | @NbBundle.Messages({
53 | "# {0} - version",
54 | "CakePHP3ActionsExtender.menuName=CakePHP{0}"
55 | })
56 | @Override
57 | public String getMenuName() {
58 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
59 | int majorVersion = cakeModule.getVersion().getMajor();
60 | assert majorVersion >= 3 : "Invalid major version:" + majorVersion; // NOI18N
61 | String version = majorVersion < 3 ? "" : String.valueOf(majorVersion);
62 | return Bundle.CakePHP3ActionsExtender_menuName(version);
63 | }
64 |
65 | @Override
66 | public List extends Action> getActions() {
67 | List defaultActions = Arrays.asList(
68 | new CakeServerAction(),
69 | new CakePHP3RefreshModuleAction()
70 | );
71 | List actions = new ArrayList<>(defaultActions);
72 | CakePHPModule cakeModule = CakePHPModule.forPhpModule(phpModule);
73 | Dotcake dotcake = cakeModule.getDotcake();
74 | if (dotcake != null) {
75 | actions.add(new OpenDotcakeAction());
76 | }
77 | return actions;
78 | }
79 |
80 | @Override
81 | public GoToViewAction getGoToViewAction(FileObject fo, int offset) {
82 | return new CakePHP3GoToViewAction();
83 | }
84 |
85 | @Override
86 | public GoToActionAction getGoToActionAction(FileObject fo, int offset) {
87 | return new CakePHP3GoToActionAction();
88 | }
89 |
90 | @Override
91 | public boolean isActionWithView(FileObject fo) {
92 | CakePHPModule cakeModule = CakePHPModule.forFileObject(fo);
93 | CakePHPModule.Category category = cakeModule.getCategory(fo);
94 | return category == Category.CONTROLLER;
95 | }
96 |
97 | @Override
98 | public boolean isViewWithAction(FileObject fo) {
99 | CakePHPModule cakeModule = CakePHPModule.forFileObject(fo);
100 | return cakeModule.isTemplateFile(fo);
101 | }
102 |
103 | @Override
104 | public RunCommandAction getRunCommandAction() {
105 | return CakePHP3RunCommandAction.getInstance();
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/pom/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.junichi11.netbeans.modules
5 | netbeans-cakephp3
6 |
7 | 0.11.0
8 | nbm
9 | NetBeans CakePHP3/4 Framework
10 | https://github.com/junichi11/
11 | This plugin provides support for CakePHP3/4.
12 |
13 |
14 | junichi11
15 | Junichi Yamamoto
16 | https://github.com/junichi11
17 |
18 |
19 |
20 | scm:git:https://github.com/junichi11/cakephp3-netbeans.git
21 | scm:git:https://github.com/junichi11/cakephp3-netbeans.git
22 | https://github.com/junichi11/cakephp3-netbeans
23 | HEAD
24 |
25 |
26 |
27 | Apache License, Version 2.0
28 | https://www.apache.org/licenses/LICENSE-2.0
29 |
30 |
31 |
32 |
33 | ossrh
34 | https://oss.sonatype.org/content/repositories/snapshots
35 |
36 |
37 | ossrh
38 | https://oss.sonatype.org/service/local/staging/deploy/maven2/
39 |
40 |
41 |
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-deploy-plugin
46 | 3.0.0-M1
47 |
48 |
49 | org.sonatype.plugins
50 | nexus-staging-maven-plugin
51 | 1.6.7
52 | true
53 |
54 | ossrh
55 | https://oss.sonatype.org/
56 | true
57 |
58 |
59 |
60 | org.apache.netbeans.utilities
61 | nbm-maven-plugin
62 | 4.5
63 | true
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-compiler-plugin
68 | 3.8.1
69 |
70 | 1.8
71 | 1.8
72 |
73 |
74 |
75 | org.apache.maven.plugins
76 | maven-jar-plugin
77 | 3.1.2
78 |
79 |
80 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF
81 |
82 |
83 |
84 |
85 | org.apache.maven.plugins
86 | maven-gpg-plugin
87 | 1.6
88 |
89 |
90 | sign-artifacts
91 | verify
92 |
93 | sign
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/options/CakePHP3OptionsPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
80 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/options/CakePHP3Options.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.options;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Arrays;
20 | import java.util.Collections;
21 | import java.util.List;
22 | import java.util.prefs.Preferences;
23 | import org.netbeans.modules.php.api.util.StringUtils;
24 | import org.netbeans.modules.php.composer.api.Composer;
25 | import org.openide.util.NbPreferences;
26 |
27 | /**
28 | *
29 | * @author junichi11
30 | */
31 | public class CakePHP3Options {
32 |
33 | private static final String PREFERENCES_PATH = "cakephp3"; // NOI18N
34 | private static final String EXTERNAL_DRAG_AND_DROP = "external.drop"; // NOI18N
35 | private static final String AVAILABLE_CUSTOM_NODES = "available-custom-nodes"; // NOI18N
36 | private static final String COMPOSER_PREFERENCES_PATH = "composer"; // NOI18N
37 | private static final CakePHP3Options INSTANCE = new CakePHP3Options();
38 | public static final List DEFAULT_AVAILABLE_NODES = Arrays.asList(
39 | "Console", // NOI18N
40 | "Controller", // NOI18N
41 | "Component", // NOI18N
42 | "Model", // NOI18N
43 | "View", // NOI18N
44 | "Helper", // NOI18N
45 | "webroot" // NOI18N
46 | );
47 | public static final List ALL_AVAILABLE_NODES = new ArrayList<>(DEFAULT_AVAILABLE_NODES);
48 |
49 | static {
50 | ALL_AVAILABLE_NODES.add("Command"); // NOI18N
51 | ALL_AVAILABLE_NODES.add("Element"); // NOI18N
52 | ALL_AVAILABLE_NODES.add("Entity"); // NOI18N
53 | ALL_AVAILABLE_NODES.add("Fixture"); // NOI18N
54 | ALL_AVAILABLE_NODES.add("Form"); // NOI18N
55 | ALL_AVAILABLE_NODES.add("Mailer"); // NOI18N
56 | ALL_AVAILABLE_NODES.add("Middleware"); // NOI18N
57 | ALL_AVAILABLE_NODES.add("Shell"); // NOI18N
58 | ALL_AVAILABLE_NODES.add("Shell/Helper"); // NOI18N
59 | ALL_AVAILABLE_NODES.add("Shell/Task"); // NOI18N
60 | ALL_AVAILABLE_NODES.add("Table"); // NOI18N
61 | ALL_AVAILABLE_NODES.add("Template"); // NOI18N
62 | ALL_AVAILABLE_NODES.add("Template/Cell"); // NOI18N
63 | ALL_AVAILABLE_NODES.add("TestCase"); // NOI18N
64 | ALL_AVAILABLE_NODES.add("View/Cell"); // NOI18N
65 | ALL_AVAILABLE_NODES.add("app/plugins"); // NOI18N
66 | ALL_AVAILABLE_NODES.add("config/Seeds"); // NOI18N
67 | Collections.sort(ALL_AVAILABLE_NODES);
68 | }
69 |
70 | private CakePHP3Options() {
71 | }
72 |
73 | public static CakePHP3Options getInstance() {
74 | return INSTANCE;
75 | }
76 |
77 | public boolean isExternalDragAndDrop() {
78 | return getPreferences().getBoolean(EXTERNAL_DRAG_AND_DROP, false);
79 | }
80 |
81 | public void setExternalDragAndDrop(boolean isEnabled) {
82 | getPreferences().putBoolean(EXTERNAL_DRAG_AND_DROP, isEnabled);
83 | }
84 |
85 | public String getComposerPath() {
86 | return getComposerPreferences().get("composer.path", ""); // NOI18N
87 | }
88 |
89 | public List getAvailableCustomNodes() {
90 | String nodes = getPreferences().get(AVAILABLE_CUSTOM_NODES, null);
91 | if (nodes == null) {
92 | return DEFAULT_AVAILABLE_NODES;
93 | }
94 | return StringUtils.explode(nodes, "|"); // NOI18N
95 | }
96 |
97 | public void setAvailableCustomNodes(List nodes) {
98 | getPreferences().put(AVAILABLE_CUSTOM_NODES, StringUtils.implode(nodes, "|")); // NOI18N
99 | }
100 |
101 | private Preferences getPreferences() {
102 | return NbPreferences.forModule(CakePHP3Options.class).node(PREFERENCES_PATH);
103 | }
104 |
105 | private Preferences getComposerPreferences() {
106 | return NbPreferences.forModule(Composer.class).node(COMPOSER_PREFERENCES_PATH); // NOI18N
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/status/TableStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos.status;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collection;
20 | import java.util.List;
21 | import java.util.Set;
22 | import org.netbeans.modules.parsing.spi.ParseException;
23 | import org.netbeans.modules.php.api.editor.PhpClass;
24 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
25 | import org.netbeans.modules.php.cake3.editor.visitors.TableVisitor;
26 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
27 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
28 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
29 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItemFactory;
30 | import static org.netbeans.modules.php.cake3.ui.actions.gotos.status.CakePHP3GoToStatus.DEFAULT_OFFSET;
31 | import org.openide.filesystems.FileObject;
32 | import org.openide.util.Exceptions;
33 | import org.openide.util.Pair;
34 |
35 | public class TableStatus extends CakePHP3GoToStatus {
36 |
37 | private final List tables = new ArrayList<>();
38 | private final List behaviors = new ArrayList<>();
39 |
40 | public TableStatus(FileObject fileObject, int offset) {
41 | super(fileObject, offset);
42 | }
43 |
44 | @Override
45 | protected void scan(PhpModule phpModule, FileObject fileObject, int offset) {
46 | clear();
47 | TableVisitor tableVisitor = new TableVisitor(phpModule);
48 | try {
49 | scan(tableVisitor, fileObject);
50 | } catch (ParseException ex) {
51 | Exceptions.printStackTrace(ex);
52 | }
53 | addTables(tableVisitor.getTables());
54 | addBehaviors(tableVisitor.getBehaviors());
55 |
56 | }
57 |
58 | private void addTables(Set> tables) {
59 | addItems(Category.TABLE, tables);
60 | }
61 |
62 | private void addBehaviors(Set> behaviors) {
63 | addItems(Category.BEHAVIOR, behaviors);
64 | }
65 |
66 | private void addItems(CakePHPModule.Category category, Collection> phpClasses) {
67 | for (Pair clazz : phpClasses) {
68 | PhpClass phpClass = clazz.second();
69 | FileObject file = phpClass.getFile();
70 | if (file == null) {
71 | continue;
72 | }
73 | switch (category) {
74 | case BEHAVIOR:
75 | behaviors.add(GoToItemFactory.create(category, file, DEFAULT_OFFSET));
76 | break;
77 | case TABLE:
78 | tables.add(GoToItemFactory.create(category, file, DEFAULT_OFFSET));
79 | break;
80 | default:
81 | break;
82 | }
83 | }
84 | }
85 |
86 | @Override
87 | public List getSmart() {
88 | List items = new ArrayList<>(getEntities());
89 | items.addAll(tables);
90 | items.addAll(behaviors);
91 | items.addAll(getTestCases());
92 | return items;
93 | }
94 |
95 | @Override
96 | public List getEntities() {
97 | List items = new ArrayList<>();
98 | CakePHPModule cakeModule = CakePHPModule.forFileObject(getFileObject());
99 | FileObject entity = cakeModule.getEntity(getFileObject());
100 | if (entity != null) {
101 | items.add(GoToItemFactory.create(Category.ENTITY, entity, DEFAULT_OFFSET));
102 | }
103 | items.addAll(super.getEntities());
104 | return items;
105 | }
106 |
107 | @Override
108 | public List getTables() {
109 | return new ArrayList<>(tables);
110 | }
111 |
112 | @Override
113 | public List getBehaviors() {
114 | return new ArrayList<>(behaviors);
115 | }
116 |
117 | private void clear() {
118 | tables.clear();
119 | behaviors.clear();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/ui/actions/gotos/CakePHP3GoToAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.ui.actions.gotos;
17 |
18 | import java.awt.Point;
19 | import java.awt.Rectangle;
20 | import java.awt.event.ActionEvent;
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import java.util.concurrent.atomic.AtomicBoolean;
24 | import javax.swing.SwingUtilities;
25 | import javax.swing.text.BadLocationException;
26 | import javax.swing.text.Document;
27 | import javax.swing.text.JTextComponent;
28 | import org.netbeans.api.progress.BaseProgressUtils;
29 | import org.netbeans.editor.BaseAction;
30 | import org.netbeans.modules.editor.NbEditorUtilities;
31 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
32 | import org.netbeans.modules.php.api.util.FileUtils;
33 | import org.netbeans.modules.php.cake3.modules.CakePHPModule;
34 | import org.netbeans.modules.php.cake3.ui.GoToPopup;
35 | import org.netbeans.modules.php.cake3.ui.PopupUtil;
36 | import org.netbeans.modules.php.cake3.ui.actions.gotos.items.GoToItem;
37 | import org.netbeans.modules.php.cake3.ui.actions.gotos.status.CakePHP3GoToStatus;
38 | import org.netbeans.modules.php.cake3.ui.actions.gotos.status.CakePHP3GoToStatusFactory;
39 | import org.openide.filesystems.FileObject;
40 | import org.openide.util.Exceptions;
41 |
42 | /**
43 | *
44 | * @author junichi11
45 | */
46 | public abstract class CakePHP3GoToAction extends BaseAction {
47 |
48 | private static final long serialVersionUID = 7403447287856842348L;
49 |
50 | @Override
51 | public final void actionPerformed(ActionEvent event, final JTextComponent textComponent) {
52 | Document document = textComponent.getDocument();
53 | if (document == null) {
54 | return;
55 | }
56 | final FileObject fileObject = NbEditorUtilities.getFileObject(document);
57 | if (fileObject == null) {
58 | return;
59 | }
60 | PhpModule phpModule = PhpModule.Factory.forFileObject(fileObject);
61 | if (phpModule == null) {
62 | return;
63 | }
64 | if (!CakePHPModule.isCakePHP(phpModule)) {
65 | return;
66 | }
67 | // only php files
68 | String mimeType = fileObject.getMIMEType(FileUtils.PHP_MIME_TYPE); // NOI18N
69 | if (!FileUtils.PHP_MIME_TYPE.equals(mimeType)) {
70 | return;
71 | }
72 | final AtomicBoolean cancel = new AtomicBoolean();
73 | CakePHP3GoToStatusFactory factory = CakePHP3GoToStatusFactory.getInstance();
74 | final CakePHP3GoToStatus status = factory.create(fileObject, textComponent.getCaretPosition());
75 | final List defaultItems = new ArrayList<>();
76 | BaseProgressUtils.runOffEventDispatchThread(new Runnable() {
77 |
78 | @Override
79 | public void run() {
80 | status.scan();
81 | defaultItems.addAll(getGoToItems(status));
82 | }
83 | }, "CakePHP3/4 Go To", cancel, false);
84 |
85 | // show popup
86 | try {
87 | Rectangle rectangle = textComponent.modelToView(textComponent.getCaretPosition());
88 | final Point point = new Point(rectangle.x, rectangle.y + rectangle.height);
89 | SwingUtilities.convertPointToScreen(point, textComponent);
90 | SwingUtilities.invokeLater(new Runnable() {
91 | @Override
92 | public void run() {
93 | String title = getPopupTitle();
94 | if (title == null) {
95 | title = ""; // NOI18N
96 | }
97 | PopupUtil.showPopup(new GoToPopup(title, defaultItems, status), title, point.x, point.y, true, 0);
98 | }
99 | });
100 | } catch (BadLocationException ex) {
101 | Exceptions.printStackTrace(ex);
102 | }
103 | }
104 |
105 | protected String getPopupTitle() {
106 | return "Go To"; // NOI18N
107 | }
108 |
109 | protected abstract List getGoToItems(CakePHP3GoToStatus status);
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/preferences/CakePHP3Preferences.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.preferences;
17 |
18 | import java.util.prefs.Preferences;
19 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
20 |
21 | /**
22 | *
23 | * @author junichi11
24 | */
25 | public final class CakePHP3Preferences {
26 |
27 | private static final String ENABLED = "enabled"; // NOI18N
28 | private static final String ROOT_PATH = "root-path"; // NOI18N
29 | private static final String SRC = "src"; // NOI18N
30 | private static final String IMAGE_URL = "image-url"; // NOI18N
31 | private static final String CSS_URL = "css-url"; // NOI18N
32 | private static final String JS_URL = "js-url"; // NOI18N
33 | private static final String WWW_ROOT = "www-root"; // NOI18N
34 | private static final String NAMESPACE = "namespace"; // NOI18N
35 | private static final String CTP_EXT = "ctp-ext"; // NOI18N
36 | private static final String DOTCAKE = "dotcake"; // NOI18N
37 |
38 | public static boolean isEnabled(PhpModule phpModule) {
39 | return getPreferences(phpModule).getBoolean(ENABLED, false);
40 | }
41 |
42 | public static void setEnabled(PhpModule phpModule, boolean isEnabled) {
43 | getPreferences(phpModule).putBoolean(ENABLED, isEnabled);
44 | }
45 |
46 | public static String getCtpExt(PhpModule phpModule) {
47 | return getPreferences(phpModule).get(CTP_EXT, "ctp"); // NOI18N
48 | }
49 |
50 | public static void setCtpExt(PhpModule phpModule, String ext) {
51 | getPreferences(phpModule).put(CTP_EXT, ext);
52 | }
53 |
54 | public static String getNamespace(PhpModule phpModule) {
55 | return getPreferences(phpModule).get(NAMESPACE, "App"); // NOI18N
56 | }
57 |
58 | public static void setNamespace(PhpModule phpModule, String namespace) {
59 | getPreferences(phpModule).put(NAMESPACE, namespace);
60 | }
61 |
62 | public static String getRootPath(PhpModule phpModule) {
63 | return getPreferences(phpModule).get(ROOT_PATH, ""); // NOI18N
64 | }
65 |
66 | public static void setRootPath(PhpModule phpModule, String path) {
67 | getPreferences(phpModule).put(ROOT_PATH, path);
68 | }
69 |
70 | public static String getSrcName(PhpModule phpModule) {
71 | return getPreferences(phpModule).get(SRC, "src");
72 | }
73 |
74 | public static void setSrcName(PhpModule phpModule, String srcName) {
75 | getPreferences(phpModule).put(SRC, srcName);
76 | }
77 |
78 | public static String getImageUrl(PhpModule phpModule) {
79 | return getPreferences(phpModule).get(IMAGE_URL, "img"); // NOI18N
80 | }
81 |
82 | public static void setImageUrl(PhpModule phpModule, String url) {
83 | getPreferences(phpModule).put(IMAGE_URL, url);
84 | }
85 |
86 | public static String getCssUrl(PhpModule phpModule) {
87 | return getPreferences(phpModule).get(CSS_URL, "css"); // NOI18N
88 | }
89 |
90 | public static void setCssUrl(PhpModule phpModule, String url) {
91 | getPreferences(phpModule).put(CSS_URL, url);
92 | }
93 |
94 | public static String getJsUrl(PhpModule phpModule) {
95 | return getPreferences(phpModule).get(JS_URL, "js"); // NOI18N
96 | }
97 |
98 | public static void setJsUrl(PhpModule phpModule, String url) {
99 | getPreferences(phpModule).put(JS_URL, url);
100 | }
101 |
102 | public static String getWWWRootPath(PhpModule phpModule) {
103 | return getPreferences(phpModule).get(WWW_ROOT, "webroot"); // NOI18N
104 | }
105 |
106 | public static void setWWWRootPath(PhpModule phpModule, String path) {
107 | getPreferences(phpModule).put(WWW_ROOT, path);
108 | }
109 |
110 | public static String getDotcakePath(PhpModule phpModule) {
111 | return getPreferences(phpModule).get(DOTCAKE, ""); // NOI18N
112 | }
113 |
114 | public static void setDotcakePath(PhpModule phpModule, String path) {
115 | getPreferences(phpModule).put(DOTCAKE, path);
116 | }
117 |
118 | private static Preferences getPreferences(PhpModule phpModule) {
119 | return phpModule.getPreferences(CakePHP3Preferences.class, true);
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/utils/CakePHPCodeUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.utils;
17 |
18 | import java.util.List;
19 | import org.netbeans.modules.php.editor.parser.astnodes.ArrayCreation;
20 | import org.netbeans.modules.php.editor.parser.astnodes.ArrayElement;
21 | import org.netbeans.modules.php.editor.parser.astnodes.Expression;
22 | import org.netbeans.modules.php.editor.parser.astnodes.FunctionInvocation;
23 | import org.netbeans.modules.php.editor.parser.astnodes.Scalar;
24 | import org.netbeans.modules.php.editor.parser.astnodes.SingleFieldDeclaration;
25 | import org.openide.util.Pair;
26 |
27 | /**
28 | *
29 | * @author junichi11
30 | */
31 | public final class CakePHPCodeUtils {
32 |
33 | private CakePHPCodeUtils() {
34 | }
35 |
36 | /**
37 | * Get string name from Expression
38 | *
39 | * @param e Expression
40 | * @return string name | empty string
41 | */
42 | public static String getStringValue(Expression e) {
43 | String name = ""; // NOI18N
44 | if (e instanceof Scalar) {
45 | Scalar s = (Scalar) e;
46 | if (s.getScalarType() == Scalar.Type.STRING) {
47 | name = s.getStringValue();
48 | }
49 | if (name.length() > 2) {
50 | name = name.substring(1, name.length() - 1);
51 | } else {
52 | name = ""; // NOI18N
53 | }
54 | }
55 | return name;
56 | }
57 |
58 | /**
59 | * Get entity. Return a class Expression if "className" exists in the array.
60 | *
61 | * @param ac ArrayCreation
62 | * @return entity | null
63 | */
64 | public static Expression getEntity(ArrayCreation ac) {
65 | if (ac == null) {
66 | return null;
67 | }
68 | for (ArrayElement element : ac.getElements()) {
69 | Expression key = element.getKey();
70 | String keyName = getStringValue(key);
71 | if (keyName.equals("className")) { // NOI18N
72 | return element.getValue();
73 | }
74 | }
75 | return null;
76 | }
77 |
78 | /**
79 | * Get ArrayCreation
80 | *
81 | * @param field
82 | * @return
83 | */
84 | public static ArrayCreation getArrayCreation(SingleFieldDeclaration field) {
85 | ArrayCreation arrayCreation = null;
86 | Expression value = field.getValue();
87 | if (value instanceof ArrayCreation) {
88 | arrayCreation = (ArrayCreation) value;
89 | }
90 | return arrayCreation;
91 | }
92 |
93 | /**
94 | * Get pair of alias and entity name from method parameters. If "className"
95 | * element doesn't exist in the parameter's array, entity name will be empty
96 | * string.
97 | *
98 | * @param parameters method parameters
99 | * @return Pair of alias and entity name
100 | */
101 | public static Pair getAliasAndEntityName(List parameters) {
102 | String aliasName = ""; // NOI18N
103 | String entityName = ""; // NOI18N
104 | for (Expression parameter : parameters) {
105 | if (parameter instanceof Scalar) {
106 | aliasName = getStringValue(parameter);
107 | }
108 | if (parameter instanceof ArrayCreation) {
109 | Expression entity = getEntity((ArrayCreation) parameter);
110 | entityName = getStringValue(entity);
111 | }
112 | }
113 | return Pair.of(aliasName, entityName);
114 | }
115 |
116 | /**
117 | * Get the first parameter string.
118 | *
119 | * @param method
120 | * @return the first parameter if it is string, otherwise empty string
121 | */
122 | public static String getFirstParameter(FunctionInvocation method) {
123 | List parameters = method.getParameters();
124 | String firstParameter = ""; // NOI18N
125 | for (Expression parameter : parameters) {
126 | if (parameter instanceof Scalar) {
127 | firstParameter = CakePHPCodeUtils.getStringValue(parameter);
128 | }
129 | // only the first parameter
130 | break;
131 | }
132 | return firstParameter;
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/dotcake/DotcakeSupport.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.dotcake;
17 |
18 | import java.io.File;
19 | import java.util.ArrayList;
20 | import java.util.Collections;
21 | import java.util.List;
22 | import org.netbeans.modules.php.api.util.StringUtils;
23 | import org.netbeans.modules.php.cake3.dotcake.Dotcake.BuildPathCategory;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModule.Category;
25 | import org.openide.filesystems.FileObject;
26 | import org.openide.filesystems.FileUtil;
27 |
28 | /**
29 | *
30 | * @author junichi11
31 | */
32 | public final class DotcakeSupport {
33 |
34 | private DotcakeSupport() {
35 | }
36 |
37 | /**
38 | * Get CakePHP core directory.
39 | *
40 | * @param dotcake Dotcake
41 | * @return core directory
42 | */
43 | public static FileObject getCoreDirectory(Dotcake dotcake) {
44 | if (dotcake == null) {
45 | return null;
46 | }
47 |
48 | File dotcakeFile = dotcake.getDotcakeFile();
49 | if (dotcakeFile == null) {
50 | return null;
51 | }
52 |
53 | FileObject dotcakeFileObject = FileUtil.toFileObject(dotcakeFile);
54 | String cakePath = dotcake.getCake();
55 | if (StringUtils.isEmpty(cakePath)) {
56 | return null;
57 | }
58 | return dotcakeFileObject.getParent().getFileObject(cakePath);
59 | }
60 |
61 | /**
62 | * Get plugins directories.
63 | *
64 | * @param dotcake Dotcake
65 | * @return pluigns directories
66 | */
67 | public static List getPluignsDirectories(Dotcake dotcake) {
68 | return getDirectories(dotcake, BuildPathCategory.PLUGINS);
69 | }
70 |
71 | /**
72 | * Get directories from dotcake information
73 | *
74 | * @param dotcake
75 | * @param category
76 | * @return directories for a category
77 | */
78 | public static List getDirectories(Dotcake dotcake, Category category) {
79 | BuildPathCategory buildPathCategory = getBuildPathCategory(category);
80 | return getDirectories(dotcake, buildPathCategory);
81 | }
82 |
83 | private static List getDirectories(Dotcake dotcake, BuildPathCategory buildPathCategory) {
84 | if (dotcake == null || buildPathCategory == BuildPathCategory.UNKNOWN) {
85 | return Collections.emptyList();
86 | }
87 |
88 | // get .cake file
89 | File dotcakeFile = dotcake.getDotcakeFile();
90 | if (dotcakeFile == null) {
91 | return Collections.emptyList();
92 | }
93 |
94 | // get directories
95 | FileObject dotcakeFileObject = FileUtil.toFileObject(dotcakeFile);
96 | List buildPaths = dotcake.getBuildPaths(buildPathCategory);
97 | ArrayList directories = new ArrayList<>(buildPaths.size());
98 | for (String path : buildPaths) {
99 | FileObject fileObject = dotcakeFileObject.getParent().getFileObject(path);
100 | if (fileObject != null && fileObject.isFolder()) {
101 | directories.add(fileObject);
102 | }
103 | }
104 | return directories;
105 | }
106 |
107 | /**
108 | * Change {@link FILE_TYPE} to {@link BuildPathCategory}.
109 | *
110 | * @param category
111 | * @return BuildPathCategory
112 | */
113 | private static BuildPathCategory getBuildPathCategory(Category category) {
114 | // XXX more?
115 | switch (category) {
116 | case ENTITY:
117 | return BuildPathCategory.ENTITIES;
118 | case TABLE:
119 | return BuildPathCategory.TABLES;
120 | case BEHAVIOR:
121 | return BuildPathCategory.BEHAVIORS;
122 | case CONTROLLER:
123 | return BuildPathCategory.CONTROLLERS;
124 | case COMPONENT:
125 | return BuildPathCategory.COMPONENTS;
126 | case TEMPLATE:
127 | return BuildPathCategory.TEMPLATES;
128 | case HELPER:
129 | return BuildPathCategory.HELPERS;
130 | case CONSOLE:
131 | return BuildPathCategory.CONSOLES;
132 | default:
133 | return BuildPathCategory.UNKNOWN;
134 | }
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/CakePHP3FrameworkProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3;
17 |
18 | import org.netbeans.api.annotations.common.StaticResource;
19 | import org.netbeans.modules.php.api.framework.BadgeIcon;
20 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
21 | import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
22 | import org.netbeans.modules.php.cake3.commands.CakePHP3FrameworkCommandSupport;
23 | import org.netbeans.modules.php.cake3.editor.CakePHP3EditorExtender;
24 | import org.netbeans.modules.php.cake3.modules.CakePHPModuleFactory;
25 | import org.netbeans.modules.php.cake3.preferences.CakePHP3Preferences;
26 | import org.netbeans.modules.php.spi.editor.EditorExtender;
27 | import org.netbeans.modules.php.spi.framework.PhpFrameworkProvider;
28 | import org.netbeans.modules.php.spi.framework.PhpModuleActionsExtender;
29 | import org.netbeans.modules.php.spi.framework.PhpModuleCustomizerExtender;
30 | import org.netbeans.modules.php.spi.framework.PhpModuleExtender;
31 | import org.netbeans.modules.php.spi.framework.PhpModuleIgnoredFilesExtender;
32 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommandSupport;
33 | import org.netbeans.modules.php.spi.phpmodule.ImportantFilesImplementation;
34 | import org.openide.util.ImageUtilities;
35 | import org.openide.util.NbBundle;
36 |
37 | /**
38 | *
39 | * @author junichi11
40 | */
41 | public class CakePHP3FrameworkProvider extends PhpFrameworkProvider {
42 |
43 | private static final CakePHP3FrameworkProvider INSTANCE = new CakePHP3FrameworkProvider();
44 | @StaticResource
45 | private static final String ICON_PATH = "org/netbeans/modules/php/cake3/resources/badge_icon_8.png"; // NOI18N
46 | private final BadgeIcon badgeIcon;
47 |
48 | @NbBundle.Messages({
49 | "CakePHP3FrameworkProvider.name=CakePHP3/4",
50 | "CakePHP3FrameworkProvider.description=CakePHP3/4"
51 | })
52 | private CakePHP3FrameworkProvider() {
53 | super("cakephp3", // NOI18N
54 | Bundle.CakePHP3FrameworkProvider_name(),
55 | Bundle.CakePHP3FrameworkProvider_description());
56 | badgeIcon = new BadgeIcon(
57 | ImageUtilities.loadImage(ICON_PATH),
58 | CakePHP3FrameworkProvider.class.getResource("/" + ICON_PATH) // NOI18N
59 | );
60 | }
61 |
62 | @PhpFrameworkProvider.Registration(position = 499)
63 | public static CakePHP3FrameworkProvider getInstance() {
64 | return INSTANCE;
65 | }
66 |
67 | @Override
68 | public BadgeIcon getBadgeIcon() {
69 | return badgeIcon;
70 | }
71 |
72 | @Override
73 | public boolean isInPhpModule(PhpModule phpModule) {
74 | // #25
75 | if (phpModule == null) {
76 | return false;
77 | }
78 | return CakePHP3Preferences.isEnabled(phpModule);
79 | }
80 |
81 | @Override
82 | public ImportantFilesImplementation getConfigurationFiles2(PhpModule phpModule) {
83 | return new ConfigurationFiles(phpModule);
84 | }
85 |
86 | @Override
87 | public PhpModuleExtender createPhpModuleExtender(PhpModule phpModule) {
88 | // TODO
89 | return null;
90 | }
91 |
92 | @Override
93 | public PhpModuleProperties getPhpModuleProperties(PhpModule phpModule) {
94 | return new PhpModuleProperties();
95 | }
96 |
97 | @Override
98 | public PhpModuleActionsExtender getActionsExtender(PhpModule phpModule) {
99 | return new CakePHP3ActionsExtender(phpModule);
100 | }
101 |
102 | @Override
103 | public PhpModuleIgnoredFilesExtender getIgnoredFilesExtender(PhpModule phpModule) {
104 | // TODO
105 | return null;
106 | }
107 |
108 | @Override
109 | public FrameworkCommandSupport getFrameworkCommandSupport(PhpModule phpModule) {
110 | return new CakePHP3FrameworkCommandSupport(phpModule);
111 | }
112 |
113 | @Override
114 | public PhpModuleCustomizerExtender createPhpModuleCustomizerExtender(PhpModule phpModule) {
115 | return new CakePHP3ModuleCustomizerExtender(phpModule);
116 | }
117 |
118 | @Override
119 | public EditorExtender getEditorExtender(PhpModule phpModule) {
120 | return new CakePHP3EditorExtender(phpModule);
121 | }
122 |
123 | @Override
124 | public void phpModuleClosed(PhpModule phpModule) {
125 | // release CakePHPModule
126 | CakePHPModuleFactory factory = CakePHPModuleFactory.getInstance();
127 | factory.remove(phpModule);
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/resources/templates/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | @TemplateRegistrations({
17 | @TemplateRegistration(
18 | position = 100,
19 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
20 | iconBase = CakePHP3Constants.CTP_ICON,
21 | displayName = "#Ctp_DisplayName",
22 | content = "CtpTemplate.ctp",
23 | description = "CtpTemplateDescription.html",
24 | scriptEngine = "freemarker"),
25 | @TemplateRegistration(
26 | position = 110,
27 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
28 | iconBase = CakePHP3Constants.PHP_ICON,
29 | displayName = "#Controller_DisplayName",
30 | content = "Controller.php",
31 | description = "ControllerDescription.html",
32 | scriptEngine = "freemarker"),
33 | @TemplateRegistration(
34 | position = 120,
35 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
36 | iconBase = CakePHP3Constants.PHP_ICON,
37 | displayName = "#Table_DisplayName",
38 | content = "Table.php",
39 | description = "TableDescription.html",
40 | scriptEngine = "freemarker"),
41 | @TemplateRegistration(
42 | position = 130,
43 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
44 | iconBase = CakePHP3Constants.PHP_ICON,
45 | displayName = "#Entity_DisplayName",
46 | content = "Entity.php",
47 | description = "EntityDescription.html",
48 | scriptEngine = "freemarker"),
49 | @TemplateRegistration(
50 | position = 200,
51 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
52 | iconBase = CakePHP3Constants.PHP_ICON,
53 | displayName = "#Helper_DisplayName",
54 | content = "Helper.php",
55 | description = "HelperDescription.html",
56 | scriptEngine = "freemarker"),
57 | @TemplateRegistration(
58 | position = 300,
59 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
60 | iconBase = CakePHP3Constants.PHP_ICON,
61 | displayName = "#Component_DisplayName",
62 | content = "Component.php",
63 | description = "ComponentDescription.html",
64 | scriptEngine = "freemarker"),
65 | @TemplateRegistration(
66 | position = 400,
67 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
68 | iconBase = CakePHP3Constants.PHP_ICON,
69 | displayName = "#Behavior_DisplayName",
70 | content = "Behavior.php",
71 | description = "BehaviorDescription.html",
72 | scriptEngine = "freemarker"),
73 | @TemplateRegistration(
74 | position = 500,
75 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
76 | iconBase = CakePHP3Constants.PHP_ICON,
77 | displayName = "#Shell_DisplayName",
78 | content = "Shell.php",
79 | description = "ShellDescription.html",
80 | scriptEngine = "freemarker"),
81 | @TemplateRegistration(
82 | position = 600,
83 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
84 | iconBase = CakePHP3Constants.PHP_ICON,
85 | displayName = "#Task_DisplayName",
86 | content = "Task.php",
87 | description = "TaskDescription.html",
88 | scriptEngine = "freemarker"),
89 | @TemplateRegistration(
90 | position = 700,
91 | folder = CakePHP3Constants.CAKEPHP3_FRAMEWORK,
92 | iconBase = CakePHP3Constants.PHP_ICON,
93 | displayName = "#Cell_DisplayName",
94 | content = "Cell.php",
95 | description = "CellDescription.html",
96 | scriptEngine = "freemarker")
97 | })
98 | @NbBundle.Messages({
99 | "Controller_DisplayName=CakePHP3 Controller",
100 | "Table_DisplayName=CakePHP3 Table",
101 | "Entity_DisplayName=CakePHP3 Entity",
102 | "Component_DisplayName=CakePHP3 Component",
103 | "Helper_DisplayName=CakePHP3 Helper",
104 | "Behavior_DisplayName=CakePHP3 Behavior",
105 | "Shell_DisplayName=CakePHP3 Shell",
106 | "Task_DisplayName=CakePHP3 Task",
107 | "Cell_DisplayName=CakePHP3 View Cell",
108 | "Ctp_DisplayName=Empty ctp file"})
109 |
110 | package org.netbeans.modules.php.cake3.resources.templates;
111 |
112 | import org.netbeans.api.templates.TemplateRegistration;
113 | import org.netbeans.api.templates.TemplateRegistrations;
114 | import org.netbeans.modules.php.cake3.CakePHP3Constants;
115 | import org.openide.util.NbBundle;
116 |
--------------------------------------------------------------------------------
/src/org/netbeans/modules/php/cake3/modules/CakePHPModuleFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 junichi11.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.netbeans.modules.php.cake3.modules;
17 |
18 | import java.util.Collections;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 | import java.util.logging.Level;
22 | import java.util.logging.Logger;
23 | import org.netbeans.api.annotations.common.CheckForNull;
24 | import org.netbeans.modules.php.api.phpmodule.PhpModule;
25 | import org.netbeans.modules.php.api.util.StringUtils;
26 | import org.netbeans.modules.php.cake3.CakeVersion;
27 | import org.netbeans.modules.php.cake3.dotcake.Dotcake;
28 | import org.netbeans.modules.php.cake3.dotcake.DotcakeSupport;
29 | import org.netbeans.modules.php.cake3.preferences.CakePHP3Preferences;
30 | import org.openide.filesystems.FileObject;
31 |
32 | /**
33 | *
34 | * @author junichi11
35 | */
36 | public final class CakePHPModuleFactory {
37 |
38 | public static final CakePHPModule DUMMY_MODULE = new CakePHPModule(new CakePHPModuleDummy(), CakeVersion.create(null));
39 | private static final CakePHPModuleFactory INSTANCE = new CakePHPModuleFactory();
40 | private static final Map MODULES = Collections.synchronizedMap(new HashMap());
41 | private static final Logger LOGGER = Logger.getLogger(CakePHPModuleFactory.class.getName());
42 |
43 | private CakePHPModuleFactory() {
44 | }
45 |
46 | public static CakePHPModuleFactory getInstance() {
47 | return INSTANCE;
48 | }
49 |
50 | public CakePHPModule create(PhpModule phpModule) {
51 | CakePHPModule module = MODULES.get(phpModule);
52 | if (module == null) {
53 | Dotcake dotcake = createDotcake(phpModule);
54 | CakeVersion version = createVersion(dotcake, phpModule);
55 | CakePHPModuleImpl impl;
56 | switch (version.getMajor()) {
57 | case 3:
58 | impl = new CakePHP3ModuleDefault(phpModule);
59 | break;
60 | case 4:
61 | impl = new CakePHP4ModuleDefault(phpModule);
62 | break;
63 | default:
64 | LOGGER.log(Level.WARNING, "Unsupported version: {0}", version.getVersionNumber()); // NOI18N
65 | impl = new CakePHP4ModuleDefault(phpModule);
66 | break;
67 | }
68 | impl.dotcake(dotcake);
69 | module = new CakePHPModule(impl, version);
70 | MODULES.put(phpModule, module);
71 | }
72 | return module;
73 | }
74 |
75 | public void remove(PhpModule phpModule) {
76 | MODULES.remove(phpModule);
77 | }
78 |
79 | private CakeVersion createVersion(Dotcake dotcake, PhpModule phpModule) {
80 | FileObject coreDirecotry = getCoreDirecotry(dotcake, phpModule);
81 | FileObject versionFile = null;
82 | if (coreDirecotry != null) {
83 | versionFile = coreDirecotry.getFileObject("VERSION.txt"); // NOI18N
84 | }
85 | return CakeVersion.create(versionFile);
86 | }
87 |
88 | @CheckForNull
89 | private FileObject getCoreDirecotry(Dotcake dotcake, PhpModule phpModule) {
90 | // Dotcake support
91 | if (dotcake != null) {
92 | FileObject coreDirectory = DotcakeSupport.getCoreDirectory(dotcake);
93 | if (coreDirectory != null) {
94 | return coreDirectory;
95 | }
96 | }
97 |
98 | // default
99 | FileObject rootDirectory = getRootDirectory(phpModule);
100 | if (rootDirectory == null) {
101 | return null;
102 | }
103 | return rootDirectory.getFileObject("vendor/cakephp/cakephp"); // NOI18N
104 | }
105 |
106 | @CheckForNull
107 | private FileObject getRootDirectory(PhpModule phpModule) {
108 | if (phpModule == null) {
109 | return null;
110 | }
111 | String rootPath = CakePHP3Preferences.getRootPath(phpModule);
112 | FileObject sourceDirectory = phpModule.getSourceDirectory();
113 | if (sourceDirectory != null) {
114 | return sourceDirectory.getFileObject(rootPath);
115 | }
116 | return null;
117 | }
118 |
119 | @CheckForNull
120 | private Dotcake createDotcake(PhpModule phpModule) {
121 | String dotcakePath = CakePHP3Preferences.getDotcakePath(phpModule);
122 | FileObject sourceDirectory = phpModule.getSourceDirectory();
123 | if (sourceDirectory == null) {
124 | return null;
125 | }
126 | if (!StringUtils.isEmpty(dotcakePath)) {
127 | FileObject dotcakeFile = sourceDirectory.getFileObject(dotcakePath);
128 | return Dotcake.fromJson(dotcakeFile);
129 | }
130 | return null;
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------