├── .gitignore
├── DCO.txt
├── build.xml
├── guide
├── complete.rst
├── generate.rst
├── index.rst
├── integrate.rst
├── manager.rst
├── navigate.rst
└── starters.rst
├── license.txt
├── manifest.mf
├── nbproject
├── build-impl.xml
├── genfiles.properties
├── platform.properties
├── project.properties
└── project.xml
├── readme.rst
└── src
└── com
└── codeigniter
└── netbeans
├── Bundle.properties
├── completer
├── CiCompleterProviderBase.java
├── CiCompleterView.java
├── autocomplete.php
└── readme.txt
├── documentation
├── Bundle.properties
├── CISearchToolbar.java
├── GoToDocumentationAction.java
├── HelpSearchPanel.form
├── HelpSearchPanel.java
└── readme.txt
├── generator
├── Bundle.properties
├── GenPanel.form
├── GenPanel.java
├── GenwizardVisualPanel1.form
├── GenwizardVisualPanel1.java
├── GenwizardWizardAction.java
├── GenwizardWizardPanel1.java
├── Newframe.java
├── ScaffwizardVisualPanel1.form
├── ScaffwizardVisualPanel1.java
├── ScaffwizardWizardAction.java
├── ScaffwizardWizardPanel1.java
├── cilogo16.png
├── cilogo24.png
├── cilogo32.png
├── cilogo64.png
├── generatorAction.java
└── readme.txt
├── layer.xml
├── manager
├── AvailablePluginsOptionsPanelController.java
├── AvailablePluginsPanel.form
├── AvailablePluginsPanel.java
├── Bundle.properties
├── CiLocationVersionOptionsPanelController.java
├── CiLocationVersionPanel.form
├── CiLocationVersionPanel.java
├── package-info.java
└── readme.txt
├── navigator
├── CiHyperlinkProviderBase.java
├── CiHyperlinkProviderToFile.java
└── readme.txt
├── shared
├── Assets
│ ├── cilogo.png
│ ├── cilogo24.png
│ └── cilogo32.png
├── CentralManager.java
├── CiClass.java
├── CiFunction.java
├── CiParameter.java
├── FileExtractor.java
├── PHPDocumentParser.java
├── ciDoc.ser
└── readme.txt
└── starter
├── BasicStarter
├── Bundle.properties
├── CI3_Basic_Starter.png
├── CI3_Basic_StarterDescription.html
├── CI3_Basic_StarterPanelVisual.form
├── CI3_Basic_StarterPanelVisual.java
├── CI3_Basic_StarterProject.zip
├── CI3_Basic_StarterWizardIterator.java
└── CI3_Basic_StarterWizardPanel.java
└── readme.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | /netbeans-plugin/nbproject/private/
2 | /nbproject/private/
3 | /nbproject/genfiles.properties
4 | /build/
5 |
--------------------------------------------------------------------------------
/DCO.txt:
--------------------------------------------------------------------------------
1 | Developer's Certificate of Origin 1.1
2 |
3 | By making a contribution to this project, I certify that:
4 |
5 | (1) The contribution was created in whole or in part by me and I
6 | have the right to submit it under the open source license
7 | indicated in the file; or
8 |
9 | (2) The contribution is based upon previous work that, to the best
10 | of my knowledge, is covered under an appropriate open source
11 | license and I have the right under that license to submit that
12 | work with modifications, whether created in whole or in part
13 | by me, under the same open source license (unless I am
14 | permitted to submit under a different license), as indicated
15 | in the file; or
16 |
17 | (3) The contribution was provided directly to me by some other
18 | person who certified (1), (2) or (3) and I have not modified
19 | it.
20 |
21 | (4) I understand and agree that this project and the contribution
22 | are public and that a record of the contribution (including all
23 | personal information I submit with it, including my sign-off) is
24 | maintained indefinitely and may be redistributed consistent with
25 | this project or the open source license(s) involved.
26 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Builds, tests, and runs the project com.codeigniter.netbeans.
7 |
8 |
9 |
--------------------------------------------------------------------------------
/guide/complete.rst:
--------------------------------------------------------------------------------
1 | ###############
2 | Code Completion
3 | ###############
4 |
5 | Code Completion provides method suggestions as you work on your code.
6 |
7 | *************
8 | How To Use It
9 | *************
10 |
11 | When you enter the magic arrow (->) after a variable name, suggested methods
12 | popup in a selectable list, if the variable's object type can be
13 | determined.
14 |
15 | If you have already type a quote for string, then press ctrl+space, then
16 | suggested view file path will also popup in a selectable list.
17 |
18 | ************
19 | How It Works
20 | ************
21 |
22 | The way how most of the code completion work is the same as
23 | http://stackoverflow.com/questions/9308604/how-to-integrate-codeigniter-with-netbeans-fully
24 | where our plugin will automatically generate that file for it if you are
25 | currently in a CodeIgniter project.
26 |
27 | For the view completion, the selectable list will be all the .php files inside
28 | the View folder (and its subfolders).
29 |
--------------------------------------------------------------------------------
/guide/generate.rst:
--------------------------------------------------------------------------------
1 | ###############
2 | Code Generation
3 | ###############
4 |
5 | Generate related components for stuff you are working with.
6 |
7 | It handles
8 |
9 | - generate PHPunit tests for the current component
10 | - given a database table, generate scaffolding for it (model, view,
11 | controller)
12 | - generate snippets of helpful code
13 | - generate client components for REST or XML-RPC services
14 | - generate default controllers for normal, AJAX, REST or XML-RPC
15 |
16 | *************
17 | How To Use It
18 | *************
19 |
20 | From the plugin menu, select the code generation wizard.
21 |
22 | Choose the appropriate thingy you want to accompany your doodah.
23 |
24 | ************
25 | How It Works
26 | ************
27 |
28 | Magic.
--------------------------------------------------------------------------------
/guide/index.rst:
--------------------------------------------------------------------------------
1 | ###############################
2 | NetBeans Plugin for CodeIgniter
3 | ###############################
4 |
5 | The NetBeans Plugin for CodeIgniter is an addon for NetBeans 8, to make it
6 | easier to develop web applications using the CodeIgniter framework.
7 |
8 | Once installed, there will be a search field and CodeIgniter button in
9 | the NetBeans toolbar. Clicking the CodeIgniter button will provide a
10 | drop-down menu of the plugin commands. Entering a term in the search field,
11 | and pressing enter, will open a new browser window searching the online
12 | CodeIgniter User Guide.
13 |
14 | Additional features of this plugin:
15 |
16 | - `Integrated help <./integrate.rst>`_
17 | - `Code completion <./complete.rst>`_
18 | - `Smart navigation <./navigate.rst>`_
19 | - `Starter apps <./starters.rst>`_
20 | - `Code generation <./generate.rst>`_
21 | - `Plugin manager <./manage.rst>`_
22 |
23 | *******************
24 | Release Information
25 | *******************
26 |
27 | This plugin will be released when it is ready.
28 |
29 | **************************
30 | Changelog and New Features
31 | **************************
32 |
33 | This is an under-development-and-not-released plugin :-/
34 |
35 | *******************
36 | Server Requirements
37 | *******************
38 |
39 | - NetBeans version 8.x
40 | - CodeIgniter 3
41 |
42 | ************
43 | Installation
44 | ************
45 |
46 | Coming soon.
47 |
48 | *******
49 | License
50 | *******
51 |
52 | Released under the `MIT License <../license.txt>`_.
53 |
54 | *********
55 | Resources
56 | *********
57 |
58 | - `CodeIgniter `_
59 |
60 | ***************
61 | Acknowledgement
62 | ***************
63 |
64 | The EllisLab team and The Reactor Engineers would like to thank all the
65 | contributors to the CodeIgniter project and you, the CodeIgniter user.
--------------------------------------------------------------------------------
/guide/integrate.rst:
--------------------------------------------------------------------------------
1 | ###############
2 | Integrated Help
3 | ###############
4 |
5 | Integrated help ties you in to the online CodeIgniter User Guide.
6 |
7 | *************
8 | How To Use It
9 | *************
10 |
11 | There are several ways to use the integrated help:
12 |
13 | 1) Use the CodeIgniter search bar in the CodeIgniter toolbar.
14 | - This will open up your default browser and show you the CodeIgniter user guide search results
15 | 2) Use the popup menu
16 | a) Right click on a method in a PHP file
17 | b) Select Go to CI Docs
18 | c) If the method is not a CodeIgniter method, an error tone will play. Otherwise:
19 | - If the method name is not ambiguous (i.e. only one class has a method with that name), the default browser will show the documentation for the selected method
20 | - Otherwise, you will be shown the CodeIgniter User guide search results for that method
21 | 3) Use the shortcut Ctrl+Alt+D when the carat is on the method you wish to see the documentation for.
22 | This has the same behaviour as (2)
23 |
24 | ************
25 | How It Works
26 | ************
27 |
28 | The search bar uses the entered text to create a URL to the CodeIgniter user guide search page.
29 |
30 | The popup menu first gets the name of the method selected. It compares it with a list of known CodeIgniter methods.
31 | If no match is found, an error tone will play. Otherwise, it will see if the method name is ambiguous. In this case,
32 | a URL for the CodeIgniter user guide search page is created. If the method name is not ambiguous, a URL is created to
33 | navigate to the method documentation.
34 |
35 |
--------------------------------------------------------------------------------
/guide/manager.rst:
--------------------------------------------------------------------------------
1 | ##############
2 | Plugin Manager
3 | ##############
4 |
5 | The plugin manager helps you keep track of the thingies you have,
6 | and it helps you get more thingies for your webapp.
7 |
8 | You can manage your local framework installation, you locally installed
9 | plugins, and you can get more of them.
10 |
11 | *************
12 | How To Use It
13 | *************
14 |
15 | Tools->Options->CodeIgniter tab
16 |
17 | ************
18 | How It Works
19 | ************
20 |
21 | It is not fully functioning yet, it aimed to query the plugins from the portal
22 | on the main website for categories of available plugins, and for eligible ones
23 | in a category.
24 |
25 | Compatible plugins are managed on the plugin portal site.
--------------------------------------------------------------------------------
/guide/navigate.rst:
--------------------------------------------------------------------------------
1 | ################
2 | Smart Navigation
3 | ################
4 |
5 | Smart Navigation will open source code windows for related components.
6 |
7 | It ties together models, views, and controllers; maybe even your libraries
8 | and helpers.
9 |
10 | *************
11 | How To Use It
12 | *************
13 |
14 | Press control, and left click inside an editor panel to see links to the related
15 | components source.
16 |
17 | Our plugin are designed for models and views. NetBeans already has some internal
18 | navigation built in ability for libraries and helpers.
19 |
20 | ************
21 | How It Works
22 | ************
23 |
24 | Our plugin will search the standard location where views and models are placed
25 | in CodeIgniter to see if there is a view or model file of the same name.
26 | When the plugin find the file, it will use *Magic* to open the file for you.
--------------------------------------------------------------------------------
/guide/starters.rst:
--------------------------------------------------------------------------------
1 | ####################
2 | Starter Applications
3 | ####################
4 |
5 | This tool generates a starter webapp as a new project or inside an
6 | existing one. It will be configured to use your local settings (eg.
7 | location of the framework).
8 |
9 | *************
10 | How To Use It
11 | *************
12 |
13 | From the plugin's menu, choose the starter apps wizard.
14 | It will give you a list of starter apps to choose from.
15 |
16 | ************
17 | How It Works
18 | ************
19 |
20 | Magic.
21 |
22 | External magic ... using the plugins portal of some similar
23 | thing on the CodeIgniter website to maintain a list of
24 | approved starter apps.
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014, British Columbia Institute of Technology
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | AutoUpdate-Show-In-Client: true
3 | OpenIDE-Module: com.codeigniter.netbeans
4 | OpenIDE-Module-Layer: com/codeigniter/netbeans/layer.xml
5 | OpenIDE-Module-Localizing-Bundle: com/codeigniter/netbeans/Bundle.properties
6 | OpenIDE-Module-Specification-Version: 1.0
7 |
8 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=400dca24
2 | build.xml.script.CRC32=0fdd958d
3 | build.xml.stylesheet.CRC32=a56c6a5b@2.67.1
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=400dca24
7 | nbproject/build-impl.xml.script.CRC32=60f51991
8 | nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1
9 |
--------------------------------------------------------------------------------
/nbproject/platform.properties:
--------------------------------------------------------------------------------
1 | cluster.path=\
2 | ${nbplatform.active.dir}/webcommon:\
3 | ${nbplatform.active.dir}/php:\
4 | ${nbplatform.active.dir}/platform:\
5 | ${nbplatform.active.dir}/extide:\
6 | ${nbplatform.active.dir}/nb:\
7 | ${nbplatform.active.dir}/apisupport:\
8 | ${nbplatform.active.dir}/ide:\
9 | ${nbplatform.active.dir}/enterprise:\
10 | ${nbplatform.active.dir}/profiler:\
11 | ${nbplatform.active.dir}/java:\
12 | ${nbplatform.active.dir}/websvccommon:\
13 | ${nbplatform.active.dir}/harness:\
14 | ${nbplatform.active.dir}/javafx
15 | nbplatform.active=default
16 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
2 | javac.source=1.6
3 | javac.compilerargs=-Xlint -Xlint:-serial
4 | license.file=license.txt
5 | app.name=NetBeans
6 |
7 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.apisupport.project
4 |
5 |
6 | com.codeigniter.netbeans
7 |
8 |
9 |
10 | org.netbeans.modules.csl.api
11 |
12 |
13 |
14 | 2
15 | 2.47.1.2.1.1.8
16 |
17 |
18 |
19 | org.netbeans.modules.editor
20 |
21 |
22 |
23 | 3
24 | 1.79.1.5.22.43
25 |
26 |
27 |
28 | org.netbeans.modules.editor.completion
29 |
30 |
31 |
32 | 1
33 | 1.40.1.2
34 |
35 |
36 |
37 | org.netbeans.modules.editor.lib
38 |
39 |
40 |
41 | 3
42 | 3.49.2.22.43
43 |
44 |
45 |
46 | org.netbeans.modules.editor.mimelookup
47 |
48 |
49 |
50 | 1
51 | 1.36.1
52 |
53 |
54 |
55 | org.netbeans.modules.lexer
56 |
57 |
58 |
59 | 2
60 | 1.59.1.1
61 |
62 |
63 |
64 | org.netbeans.modules.options.api
65 |
66 |
67 |
68 | 1
69 | 1.41.1
70 |
71 |
72 |
73 | org.netbeans.modules.parsing.api
74 |
75 |
76 |
77 | 1
78 | 1.78.3.8
79 |
80 |
81 |
82 | org.netbeans.modules.php.editor
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | org.netbeans.modules.project.ant
91 |
92 |
93 |
94 | 1
95 | 1.60.1
96 |
97 |
98 |
99 | org.netbeans.modules.projectapi
100 |
101 |
102 |
103 | 1
104 | 1.60.2
105 |
106 |
107 |
108 | org.netbeans.modules.projectuiapi
109 |
110 |
111 |
112 | 1
113 | 1.78.1.8
114 |
115 |
116 |
117 | org.openide.awt
118 |
119 |
120 |
121 | 7.62.1
122 |
123 |
124 |
125 | org.openide.dialogs
126 |
127 |
128 |
129 | 7.38.1
130 |
131 |
132 |
133 | org.openide.filesystems
134 |
135 |
136 |
137 | 8.12.1
138 |
139 |
140 |
141 | org.openide.loaders
142 |
143 |
144 |
145 | 7.57.2
146 |
147 |
148 |
149 | org.openide.nodes
150 |
151 |
152 |
153 | 7.39.1
154 |
155 |
156 |
157 | org.openide.util
158 |
159 |
160 |
161 | 8.39.1
162 |
163 |
164 |
165 | org.openide.util.lookup
166 |
167 |
168 |
169 | 8.25.1
170 |
171 |
172 |
173 | org.openide.windows
174 |
175 |
176 |
177 | 6.71.1
178 |
179 |
180 |
181 |
182 | com.codeigniter.netbeans
183 | com.codeigniter.netbeans.completer
184 | com.codeigniter.netbeans.documentation
185 | com.codeigniter.netbeans.generator
186 | com.codeigniter.netbeans.manager
187 | com.codeigniter.netbeans.misc
188 | com.codeigniter.netbeans.navigator
189 | com.codeigniter.netbeans.shared
190 | com.codeigniter.netbeans.shared.Assets
191 | com.codeigniter.netbeans.starter
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/readme.rst:
--------------------------------------------------------------------------------
1 | ###############################
2 | NetBeans Plugin for CodeIgniter
3 | ###############################
4 |
5 | This plugin was started in 2015, but not completed.
6 | The code remains available to anyone who would be able to use it.
7 |
8 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/Bundle.properties:
--------------------------------------------------------------------------------
1 | OpenIDE-Module-Display-Category=PHP
2 | OpenIDE-Module-Long-Description=\
3 | Support for CodeIgniter3
4 | OpenIDE-Module-Name=CodeIgniter3 framework
5 | OpenIDE-Module-Short-Description=Plugin for CodeIgniter
6 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/completer/CiCompleterProviderBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.completer;
7 |
8 | import com.codeigniter.netbeans.shared.FileExtractor;
9 | import javax.swing.text.Document;
10 | import javax.swing.text.JTextComponent;
11 | import org.netbeans.modules.editor.NbEditorUtilities;
12 | import org.netbeans.spi.editor.completion.CompletionProvider;
13 | import org.openide.filesystems.FileObject;
14 |
15 | /**
16 | *
17 | * @author Tamaki_Sakura
18 | */
19 | public abstract class CiCompleterProviderBase implements CompletionProvider {
20 |
21 |
22 | public void initCodeComplete(JTextComponent jtc) {
23 | Document doc = jtc.getDocument();
24 | FileObject docObject = NbEditorUtilities.getFileObject(doc);
25 |
26 | FileExtractor.addCompleteToIncludePathFromDoc(docObject);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/completer/CiCompleterView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.completer;
7 |
8 | import com.codeigniter.netbeans.shared.CentralManager;
9 | import com.codeigniter.netbeans.shared.FileExtractor;
10 | import com.codeigniter.netbeans.shared.PHPDocumentParser;
11 | import java.awt.Color;
12 | import java.awt.Font;
13 | import java.awt.Graphics;
14 | import java.awt.event.KeyEvent;
15 | import java.io.File;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 | import javax.swing.text.Document;
19 | import javax.swing.text.JTextComponent;
20 | import javax.swing.text.StyledDocument;
21 | import org.netbeans.api.editor.completion.Completion;
22 | import org.netbeans.api.editor.mimelookup.MimeRegistration;
23 | import org.netbeans.api.lexer.Token;
24 | import org.netbeans.api.lexer.TokenSequence;
25 | import org.netbeans.modules.editor.NbEditorUtilities;
26 | import org.netbeans.modules.php.editor.lexer.PHPTokenId;
27 | import org.netbeans.spi.editor.completion.CompletionItem;
28 | import org.netbeans.spi.editor.completion.CompletionProvider;
29 | import org.netbeans.spi.editor.completion.CompletionResultSet;
30 | import org.netbeans.spi.editor.completion.CompletionTask;
31 | import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery;
32 | import org.netbeans.spi.editor.completion.support.AsyncCompletionTask;
33 | import org.netbeans.spi.editor.completion.support.CompletionUtilities;
34 | import org.openide.filesystems.FileObject;
35 | import org.openide.util.Exceptions;
36 |
37 | /**
38 | *
39 | * @author Tamaki_Sakura
40 | */
41 | @MimeRegistration(mimeType = "text/x-php5", service = CompletionProvider.class)
42 | public class CiCompleterView extends CiCompleterProviderBase {
43 |
44 | @Override
45 | public CompletionTask createTask(int i, JTextComponent jtc) {
46 | if (i != CompletionProvider.COMPLETION_QUERY_TYPE) {
47 | return null;
48 | }
49 | initCodeComplete(jtc);
50 |
51 | AsyncCompletionQuery mViewCompletionQuery
52 | = new CiViewAsyncCompletionQuery();
53 | return new AsyncCompletionTask(mViewCompletionQuery, jtc);
54 | }
55 |
56 | @Override
57 | public int getAutoQueryTypes(JTextComponent jtc, String string) {
58 | return 0;
59 | }
60 |
61 | public static class CiViewAsyncCompletionQuery extends AsyncCompletionQuery {
62 | @Override
63 | protected void query(
64 | CompletionResultSet completionSet,
65 | Document doc, int offset) {
66 | realQuery(completionSet, doc, offset);
67 | completionSet.finish();
68 | }
69 |
70 | private void realQuery(
71 | CompletionResultSet completionSet,
72 | Document doc, int offset) {
73 |
74 | TokenSequence tokens = PHPDocumentParser.getTokenSequence(doc);
75 | if (tokens == null) {
76 | return;
77 | }
78 |
79 | tokens.move(offset);
80 | tokens.moveNext();
81 | Token token = tokens.token();
82 |
83 | if (token.id() != PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING) {
84 | return;
85 | }
86 |
87 | FileObject docObject = NbEditorUtilities.getFileObject(doc);
88 | if (docObject == null) {
89 | return;
90 | }
91 | FileObject parent = FileExtractor.getCiRoot(docObject);
92 | if (parent == null) {
93 | return;
94 | }
95 |
96 | int startOffset = tokens.offset() + 1;
97 | int removeLength = token.length() - 2;
98 |
99 | String basePath = parent.getFileObject(FileExtractor.VIEW_PATH).getPath();
100 | List phpExtention = new ArrayList();
101 | phpExtention.add("php");
102 | try {
103 | File base = new File(basePath);
104 | List viewFiles = FileExtractor.getFilesFromDirectory(
105 | base, phpExtention, true);
106 |
107 | for (File vf: viewFiles) {
108 | CiViewCompletionItem vfci =
109 | new CiViewCompletionItem(
110 | base.toURI().relativize(vf.toURI()).getPath(),
111 | startOffset, removeLength);
112 | completionSet.addItem(vfci);
113 | }
114 |
115 | } catch (Exception ex) {
116 | Exceptions.printStackTrace(ex);
117 | }
118 | }
119 | }
120 |
121 | public static class CiViewCompletionItem implements CompletionItem {
122 |
123 | private String text;
124 | private int startIndex;
125 | private int removeLength;
126 |
127 | public CiViewCompletionItem(String view, int start, int remove) {
128 | text = view.substring(0, view.length() - 4);
129 | startIndex = start;
130 | removeLength = remove;
131 | }
132 |
133 | @Override
134 | public void defaultAction(JTextComponent jtc) {
135 | try {
136 | final StyledDocument doc = (StyledDocument) jtc.getDocument();
137 | // Replace existing text with complete frase.
138 | doc.remove(startIndex, removeLength);
139 | doc.insertString(startIndex, text, null);
140 | jtc.setCaretPosition(startIndex + text.length());
141 | } catch (Exception ex) {
142 | Exceptions.printStackTrace(ex);
143 | }
144 |
145 | Completion.get().hideAll();
146 | }
147 |
148 | @Override
149 | public void processKeyEvent(KeyEvent ke) {
150 | }
151 |
152 | @Override
153 | public int getPreferredWidth(Graphics grphcs, Font font) {
154 | return CompletionUtilities.getPreferredWidth(text, null, grphcs, font);
155 | }
156 |
157 | @Override
158 | public void render(Graphics grphcs, Font font, Color color, Color color1, int i, int i1, boolean bln) {
159 | CompletionUtilities.renderHtml(CentralManager.ICON,
160 | text, null, grphcs, font, color, i, i1, bln);
161 | }
162 |
163 | @Override
164 | public CompletionTask createDocumentationTask() {
165 | return null;
166 | }
167 |
168 | @Override
169 | public CompletionTask createToolTipTask() {
170 | return null;
171 | }
172 |
173 | @Override
174 | public boolean instantSubstitution(JTextComponent jtc) {
175 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
176 | }
177 |
178 | @Override
179 | public int getSortPriority() {
180 | return 0;
181 | }
182 |
183 | @Override
184 | public CharSequence getSortText() {
185 | return text;
186 | }
187 |
188 | @Override
189 | public CharSequence getInsertPrefix() {
190 | return text;
191 | }
192 |
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/completer/autocomplete.php:
--------------------------------------------------------------------------------
1 |
60 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/completer/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold auto-completion code (Xing)
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/Bundle.properties:
--------------------------------------------------------------------------------
1 | HelpSearchPanel.searchTextField.toolTipText=
2 | HelpSearchPanel.searchTextField.text=Search CI Docs
3 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/CISearchToolbar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This class handled the codeIgniter "Help Search" action.
3 | */
4 | package com.codeigniter.netbeans.documentation;
5 |
6 | import com.codeigniter.netbeans.documentation.HelpSearchPanel;
7 | import java.awt.Component;
8 | import java.awt.event.ActionEvent;
9 | import javax.swing.AbstractAction;
10 | import org.openide.awt.ActionID;
11 | import org.openide.awt.ActionReference;
12 | import org.openide.awt.ActionReferences;
13 | import org.openide.awt.ActionRegistration;
14 | import org.openide.util.NbBundle.Messages;
15 | import org.openide.util.actions.Presenter;
16 |
17 | @ActionID(
18 | category = "CodeIgniter",
19 | id = "com.codeigniter.netbeans.CISearchToolbar"
20 | )
21 | @ActionRegistration(
22 | displayName = "#CTL_CISearchToolbar",
23 | lazy = false
24 | )
25 | @ActionReferences({
26 | @ActionReference(path = "Toolbars/CodeIgniter", position = 100)
27 | })
28 | @Messages("CTL_CISearchToolbar=Search CI Docs")
29 | public final class CISearchToolbar extends AbstractAction implements Presenter.Toolbar {
30 |
31 | @Override
32 | public Component getToolbarPresenter() {
33 | return new HelpSearchPanel();
34 | }
35 |
36 | @Override
37 | public void actionPerformed(ActionEvent e) {
38 | //delegated to toolbar
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/GoToDocumentationAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.documentation;
7 |
8 | import com.codeigniter.netbeans.shared.CentralManager;
9 | import com.codeigniter.netbeans.shared.CiClass;
10 | import static com.codeigniter.netbeans.shared.PHPDocumentParser.*;
11 | import java.awt.event.ActionEvent;
12 | import java.net.MalformedURLException;
13 | import java.net.URL;
14 | import java.util.Hashtable;
15 | import java.util.List;
16 | import javax.swing.text.Document;
17 | import javax.swing.text.JTextComponent;
18 | import org.netbeans.api.lexer.Token;
19 | import org.netbeans.editor.BaseDocument;
20 | import org.openide.awt.ActionID;
21 | import org.openide.awt.ActionReference;
22 | import org.openide.awt.ActionReferences;
23 | import org.openide.awt.ActionRegistration;
24 | import org.openide.util.NbBundle.Messages;
25 | import org.netbeans.editor.ext.ExtKit;
26 | import org.netbeans.modules.php.editor.lexer.PHPTokenId;
27 | import org.openide.awt.HtmlBrowser.URLDisplayer;
28 | import java.awt.Toolkit;
29 |
30 | @ActionID(
31 | category = "Help",
32 | id = "com.codeigniter.netbeans.documentation.GoToDocumentationAction"
33 | )
34 | @ActionRegistration(
35 | displayName = "#CTL_GoToDocumentationAction"
36 | )
37 | @ActionReferences({
38 | @ActionReference(path = "Shortcuts", name = "CA-D"),
39 | @ActionReference(path = "Editors/text/x-php5/Popup", position = 550)
40 | })
41 |
42 | @Messages("CTL_GoToDocumentationAction=Go to CI Docs")
43 | public final class GoToDocumentationAction extends ExtKit.GotoAction {
44 |
45 | private final static String CI_DOC_SEARCH_BASE = "http://www.codeigniter.com/userguide3/search.html?q=";
46 | private final static String CI_DOC_SEARCH_SUFFIX = "&check_keywords=yes&area=default";
47 |
48 | @Override
49 | public void actionPerformed(ActionEvent evt, JTextComponent target) {
50 | int offset = target.getCaretPosition();
51 | Document doc = target.getDocument();
52 |
53 | if (doc == null) {
54 | System.err.println("Unable to get active document. Returning...");
55 | return;
56 | }
57 |
58 | Token token = getToken(doc, offset);
59 | String tokenString = token.text().toString();
60 |
61 | Hashtable> ciFunctions = CentralManager.Instance().getCiFunctions();
62 | if (ciFunctions.containsKey(tokenString)) {
63 | List applicableClasses = ciFunctions.get(tokenString);
64 | if (applicableClasses.size() > 1) {
65 | // More than 1 possible function. Send user to the search
66 | goToSearchURL(tokenString);
67 | }
68 | else if (applicableClasses.size() == 1) {
69 | // Send the user directly to the function in the documentation
70 | CiClass ciClass = applicableClasses.get(0);
71 | if (ciClass.getDocumentationLink() == null) {
72 | // Don't have a link for this class. Go to search
73 | goToSearchURL(tokenString);
74 | }
75 | else {
76 | goToDocumentation(ciClass, tokenString);
77 | }
78 | }
79 | else {
80 | assert (false); // List of classes should never be empty
81 | }
82 | }
83 | else {
84 | Toolkit.getDefaultToolkit().beep();
85 | }
86 |
87 | }
88 |
89 | @Override
90 | protected int getOffsetFromLine(BaseDocument doc, int lineOffset) {
91 | int retval = super.getOffsetFromLine(doc, lineOffset);
92 | System.out.printf("Returning %d from GoToDocumentationAction.getOffsetFromLine()", retval);
93 | return retval;
94 | }
95 |
96 | /**
97 | * Open the default browser showing the CodeIgniter documentation for the given Class and method
98 | * @param ciClass The CiClass must contain a valid documentationLink
99 | * @param methodName
100 | */
101 | private void goToDocumentation(CiClass ciClass, String methodName) {
102 | assert(ciClass.getDocumentationLink() != null);
103 |
104 | try {
105 | URL url = new URL(String.format("%s?#%s::%s", ciClass.getDocumentationLink().toString(),
106 | ciClass.getName(), methodName));
107 | System.out.printf("Going to URL: %s\n", url.toString());
108 | URLDisplayer.getDefault().showURL(url);
109 | }
110 | catch (MalformedURLException mue) {
111 | Toolkit.getDefaultToolkit().beep(); // Play the error sound
112 | mue.printStackTrace(System.err);
113 | }
114 | }
115 |
116 | /**
117 | * Opens the default browser on the CodeIgniter user guide search page with the methodName as the searched for value
118 | * @param methodName
119 | */
120 | private void goToSearchURL(String methodName) {
121 | try {
122 | URL url = new URL(CI_DOC_SEARCH_BASE + methodName + CI_DOC_SEARCH_SUFFIX);
123 | System.out.printf("Going to URL: %s\n", url.toString());
124 | URLDisplayer.getDefault().showURL(url);
125 | }
126 | catch (MalformedURLException mue) {
127 | Toolkit.getDefaultToolkit().beep(); // Play the error sound
128 | mue.printStackTrace(System.err);
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/HelpSearchPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
60 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/HelpSearchPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.documentation;
7 |
8 | import java.awt.Color;
9 | import java.awt.event.FocusEvent;
10 | import java.awt.event.FocusListener;
11 | import java.net.URL;
12 | import java.net.URLEncoder;
13 | import org.openide.awt.HtmlBrowser.URLDisplayer;
14 |
15 | /**
16 | *
17 | * @author jim
18 | */
19 | public class HelpSearchPanel extends javax.swing.JPanel {
20 |
21 | private boolean showingDefaultText = true;
22 | private final static String DEFAULT_TEXT = "Search CI Docs";
23 |
24 | /**
25 | * Creates new form HelpSearchPanel
26 | */
27 | public HelpSearchPanel() {
28 | initComponents();
29 | System.out.println("Init components done");
30 | }
31 |
32 | /**
33 | * This method is called from within the constructor to initialize the form.
34 | * WARNING: Do NOT modify this code. The content of this method is always
35 | * regenerated by the Form Editor.
36 | */
37 | @SuppressWarnings("unchecked")
38 | // //GEN-BEGIN:initComponents
39 | private void initComponents() {
40 |
41 | searchTextField = new javax.swing.JTextField();
42 |
43 | setPreferredSize(new java.awt.Dimension(150, 35));
44 |
45 | searchTextField.setForeground(java.awt.Color.gray);
46 | searchTextField.setText(org.openide.util.NbBundle.getMessage(HelpSearchPanel.class, "HelpSearchPanel.searchTextField.text")); // NOI18N
47 | searchTextField.setToolTipText(org.openide.util.NbBundle.getMessage(HelpSearchPanel.class, "HelpSearchPanel.searchTextField.toolTipText")); // NOI18N
48 | searchTextField.setPreferredSize(new java.awt.Dimension(150, 30));
49 | searchTextField.addFocusListener(new java.awt.event.FocusAdapter() {
50 | public void focusGained(java.awt.event.FocusEvent evt) {
51 | searchTextFieldFocusGained(evt);
52 | }
53 | public void focusLost(java.awt.event.FocusEvent evt) {
54 | searchTextFieldFocusLost(evt);
55 | }
56 | });
57 | searchTextField.addActionListener(new java.awt.event.ActionListener() {
58 | public void actionPerformed(java.awt.event.ActionEvent evt) {
59 | searchTextFieldActionPerformed(evt);
60 | }
61 | });
62 |
63 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
64 | this.setLayout(layout);
65 | layout.setHorizontalGroup(
66 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
67 | .addComponent(searchTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
68 | );
69 | layout.setVerticalGroup(
70 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
71 | .addGroup(layout.createSequentialGroup()
72 | .addComponent(searchTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
73 | .addGap(2, 2, 2))
74 | );
75 | }// //GEN-END:initComponents
76 |
77 | private void searchTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchTextFieldActionPerformed
78 | if (!showingDefaultText) { // Only search if the user has entered something
79 | // Lookup the entered text in the online CodeIgniter help
80 | try {
81 | String searchText = URLEncoder.encode(searchTextField.getText(), "UTF-8");
82 | if (searchText.length() > 0) {
83 | URLDisplayer.getDefault().showURL(
84 | new URL("http://www.codeigniter.com/userguide3/search.html?q="
85 | + searchText + "&check_keywords=yes&area=default"));
86 | }
87 | } catch (Exception e) {
88 | // Do nothing
89 | }
90 | }
91 | }//GEN-LAST:event_searchTextFieldActionPerformed
92 |
93 | private void searchTextFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_searchTextFieldFocusGained
94 | searchTextField.setText("");
95 | searchTextField.setForeground(Color.black);
96 | showingDefaultText = false;
97 | }//GEN-LAST:event_searchTextFieldFocusGained
98 |
99 | private void searchTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_searchTextFieldFocusLost
100 | if (searchTextField.getText().length() == 0) {
101 | searchTextField.setForeground(Color.gray);
102 | searchTextField.setText(DEFAULT_TEXT);
103 | showingDefaultText = true;
104 | }
105 | }//GEN-LAST:event_searchTextFieldFocusLost
106 |
107 | // Variables declaration - do not modify//GEN-BEGIN:variables
108 | private javax.swing.JTextField searchTextField;
109 | // End of variables declaration//GEN-END:variables
110 | }
111 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/documentation/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold code for documentation and integrated help. (David)
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/Bundle.properties:
--------------------------------------------------------------------------------
1 |
2 | GenwizardVisualPanel1.newLabel.text=New:
3 | GenwizardVisualPanel2.linkLabel.text=Link to:
4 | GenwizardVisualPanel2.modelLabel.text=Model
5 | GenwizardVisualPanel2.viewLabel.text=View
6 | GenwizardVisualPanel2.controllerLabel.text=Controller
7 | GenwizardVisualPanel2.noneCheckBox.text=None
8 | GenwizardVisualPanel1.nameLabel.text=Name:
9 | GenwizardVisualPanel1.nameTextField.text=
10 | ScaffwizardVisualPanel1.dLabel.text=Database:
11 | ScaffwizardVisualPanel1.tLabel.text=Table:
12 | GeneratorFrame.MLabel.text=What would you like to do?
13 | GeneratorFrame.NFLabel.text=Create a new M,V,C:
14 | GeneratorFrame.SLabel.text=Provide scaffolding:
15 | GeneratorFrame.NFButton.text=New Files
16 | GeneratorFrame.SButton.text=Scaffolding
17 | GenPanel.sButton.text=Scaffolding
18 | GenPanel.nfButton.text=New Files
19 | GenPanel.nfLabel.text=Create new M,V,C:
20 | GenPanel.sLabel.text=Provide scaffolding:
21 | GenwizardVisualPanel1.jLabel1.text=Create New:
22 | GenwizardVisualPanel1.jLabel2.text=Name:
23 | GenwizardVisualPanel1.nameField.text=
24 | ScaffwizardVisualPanel1.jLabel1.text=Name:
25 | ScaffwizardVisualPanel1.jLabel2.text=Name:
26 | ScaffwizardVisualPanel1.DnameField.text=
27 | ScaffwizardVisualPanel1.TnameField.text=
28 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/GenPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
89 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/GenwizardVisualPanel1.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
96 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/GenwizardVisualPanel1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import javax.swing.JList;
9 | import javax.swing.JPanel;
10 | import javax.swing.JTextField;
11 |
12 | public final class GenwizardVisualPanel1 extends JPanel {
13 |
14 | /**
15 | * Creates new form GenwizardVisualPanel1
16 | */
17 | public GenwizardVisualPanel1() {
18 | initComponents();
19 | }
20 |
21 | @Override
22 | public String getName() {
23 | return "Create New:";
24 | }
25 |
26 | public JTextField getNameField(){
27 | return nameField;
28 | }
29 |
30 | public JList getList(){
31 | return jList1;
32 | }
33 |
34 | /**
35 | * This method is called from within the constructor to initialize the form.
36 | * WARNING: Do NOT modify this code. The content of this method is always
37 | * regenerated by the Form Editor.
38 | */
39 | // //GEN-BEGIN:initComponents
40 | private void initComponents() {
41 |
42 | jLabel1 = new javax.swing.JLabel();
43 | jScrollPane1 = new javax.swing.JScrollPane();
44 | jList1 = new javax.swing.JList();
45 | jLabel2 = new javax.swing.JLabel();
46 | nameField = new javax.swing.JTextField();
47 |
48 | org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(GenwizardVisualPanel1.class, "GenwizardVisualPanel1.jLabel1.text")); // NOI18N
49 |
50 | jList1.setModel(new javax.swing.AbstractListModel() {
51 | String[] strings = { "Model", "View", "Controller" };
52 | public int getSize() { return strings.length; }
53 | public Object getElementAt(int i) { return strings[i]; }
54 | });
55 | jScrollPane1.setViewportView(jList1);
56 |
57 | org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(GenwizardVisualPanel1.class, "GenwizardVisualPanel1.jLabel2.text")); // NOI18N
58 |
59 | nameField.setText(org.openide.util.NbBundle.getMessage(GenwizardVisualPanel1.class, "GenwizardVisualPanel1.nameField.text")); // NOI18N
60 |
61 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
62 | this.setLayout(layout);
63 | layout.setHorizontalGroup(
64 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
65 | .addGroup(layout.createSequentialGroup()
66 | .addContainerGap()
67 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
68 | .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
69 | .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
70 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
71 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
72 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
73 | .addComponent(nameField))
74 | .addContainerGap(161, Short.MAX_VALUE))
75 | );
76 | layout.setVerticalGroup(
77 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78 | .addGroup(layout.createSequentialGroup()
79 | .addContainerGap()
80 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
81 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
82 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
83 | .addGap(29, 29, 29)
84 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
85 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
86 | .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
87 | .addContainerGap(50, Short.MAX_VALUE))
88 | );
89 | }// //GEN-END:initComponents
90 |
91 | // Variables declaration - do not modify//GEN-BEGIN:variables
92 | private javax.swing.JLabel jLabel1;
93 | private javax.swing.JLabel jLabel2;
94 | private javax.swing.JList jList1;
95 | private javax.swing.JScrollPane jScrollPane1;
96 | private javax.swing.JTextField nameField;
97 | // End of variables declaration//GEN-END:variables
98 | }
99 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/GenwizardWizardAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import java.awt.Component;
9 | import java.awt.event.ActionEvent;
10 | import java.awt.event.ActionListener;
11 | import java.text.MessageFormat;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import javax.swing.JComponent;
15 | import org.openide.DialogDisplayer;
16 | import org.openide.WizardDescriptor;
17 |
18 | // An example action demonstrating how the wizard could be called from within
19 | // your code. You can move the code below wherever you need, or register an action:
20 | // @ActionID(category="...", id="com.codeigniter.netbeans.generator.GenwizardWizardAction")
21 | // @ActionRegistration(displayName="Open Genwizard Wizard")
22 | // @ActionReference(path="Menu/Tools", position=...)
23 | public final class GenwizardWizardAction implements ActionListener {
24 |
25 | @Override
26 | public void actionPerformed(ActionEvent e) {
27 | List> panels = new ArrayList>();
28 | panels.add(new GenwizardWizardPanel1());
29 | String[] steps = new String[panels.size()];
30 | for (int i = 0; i < panels.size(); i++) {
31 | Component c = panels.get(i).getComponent();
32 | // Default step name to component name of panel.
33 | steps[i] = c.getName();
34 | if (c instanceof JComponent) { // assume Swing components
35 | JComponent jc = (JComponent) c;
36 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
37 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
38 | jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
39 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
40 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
41 | }
42 | }
43 | WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator(panels));
44 | // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
45 | wiz.setTitleFormat(new MessageFormat("{0}"));
46 | wiz.setTitle("...dialog title...");
47 | if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
48 | // do something
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/GenwizardWizardPanel1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import javax.swing.event.ChangeListener;
9 | import org.openide.WizardDescriptor;
10 | import org.openide.WizardValidationException;
11 | import org.openide.util.HelpCtx;
12 |
13 | public class GenwizardWizardPanel1 implements WizardDescriptor.ValidatingPanel {
14 |
15 | /**
16 | * The visual component that displays this panel. If you need to access the
17 | * component from this class, just use getComponent().
18 | */
19 | private GenwizardVisualPanel1 component;
20 |
21 | // Get the visual component for the panel. In this template, the component
22 | // is kept separate. This can be more efficient: if the wizard is created
23 | // but never displayed, or not all panels are displayed, it is better to
24 | // create only those which really need to be visible.
25 | @Override
26 | public GenwizardVisualPanel1 getComponent() {
27 | if (component == null) {
28 | component = new GenwizardVisualPanel1();
29 | }
30 | return component;
31 | }
32 |
33 | @Override
34 | public HelpCtx getHelp() {
35 | // Show no Help button for this panel:
36 | return HelpCtx.DEFAULT_HELP;
37 | // If you have context help:
38 | // return new HelpCtx("help.key.here");
39 | }
40 |
41 | @Override
42 | public boolean isValid() {
43 | // If it is always OK to press Next or Finish, then:
44 | return true;
45 | // If it depends on some condition (form filled out...) and
46 | // this condition changes (last form field filled in...) then
47 | // use ChangeSupport to implement add/removeChangeListener below.
48 | // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
49 | }
50 |
51 | @Override
52 | public void addChangeListener(ChangeListener l) {
53 | }
54 |
55 | @Override
56 | public void removeChangeListener(ChangeListener l) {
57 | }
58 |
59 | @Override
60 | public void readSettings(WizardDescriptor wiz) {
61 | // use wiz.getProperty to retrieve previous panel state
62 | }
63 |
64 | @Override
65 | public void storeSettings(WizardDescriptor wiz) {
66 | // use wiz.putProperty to remember current panel state
67 | wiz.putProperty("name", component.getNameField().getText());
68 | wiz.putProperty("selection", component.getList().getSelectedIndex());
69 | }
70 |
71 | @Override
72 | public void validate() throws WizardValidationException{
73 | String name = component.getNameField().getText();
74 | if (name.equals("")){
75 | throw new WizardValidationException(null, "Invalid Name", null);
76 | }
77 | if (component.getList().isSelectionEmpty()){
78 | throw new WizardValidationException(null, "No selection made", null);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/Newframe.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 |
9 | import java.awt.Container;
10 | import java.awt.FlowLayout;
11 | import javax.swing.JFrame;
12 |
13 |
14 | /**
15 | *
16 | * @author Maxence
17 | */
18 | public class Newframe extends JFrame {
19 | private final GenPanel p1;
20 | private final Container cp;
21 | public Newframe(String s){
22 | super(s);
23 | setSize(400, 200);
24 | p1 = new GenPanel();
25 | cp = getContentPane();
26 | cp.setLayout(new FlowLayout());
27 | cp.add(p1);
28 | setVisible(true);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/ScaffwizardVisualPanel1.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
116 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/ScaffwizardVisualPanel1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import javax.swing.JPanel;
9 | import javax.swing.JTextField;
10 |
11 | public final class ScaffwizardVisualPanel1 extends JPanel {
12 |
13 | /**
14 | * Creates new form ScaffwizardVisualPanel1
15 | */
16 | public ScaffwizardVisualPanel1() {
17 | initComponents();
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "Step #1";
23 | }
24 |
25 | public JTextField getDNameField(){
26 | return DnameField;
27 | }
28 | public JTextField getTNameField(){
29 | return TnameField;
30 | }
31 | /**
32 | * This method is called from within the constructor to initialize the form.
33 | * WARNING: Do NOT modify this code. The content of this method is always
34 | * regenerated by the Form Editor.
35 | */
36 | // //GEN-BEGIN:initComponents
37 | private void initComponents() {
38 |
39 | dLabel = new javax.swing.JLabel();
40 | tLabel = new javax.swing.JLabel();
41 | jLabel1 = new javax.swing.JLabel();
42 | jLabel2 = new javax.swing.JLabel();
43 | TnameField = new javax.swing.JTextField();
44 | DnameField = new javax.swing.JTextField();
45 |
46 | org.openide.awt.Mnemonics.setLocalizedText(dLabel, org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.dLabel.text")); // NOI18N
47 |
48 | org.openide.awt.Mnemonics.setLocalizedText(tLabel, org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.tLabel.text")); // NOI18N
49 |
50 | org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.jLabel1.text")); // NOI18N
51 |
52 | org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.jLabel2.text")); // NOI18N
53 |
54 | TnameField.setText(org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.TnameField.text")); // NOI18N
55 |
56 | DnameField.setText(org.openide.util.NbBundle.getMessage(ScaffwizardVisualPanel1.class, "ScaffwizardVisualPanel1.DnameField.text")); // NOI18N
57 | DnameField.addActionListener(new java.awt.event.ActionListener() {
58 | public void actionPerformed(java.awt.event.ActionEvent evt) {
59 | DnameFieldActionPerformed(evt);
60 | }
61 | });
62 |
63 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
64 | this.setLayout(layout);
65 | layout.setHorizontalGroup(
66 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
67 | .addGroup(layout.createSequentialGroup()
68 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
69 | .addGroup(layout.createSequentialGroup()
70 | .addGap(31, 31, 31)
71 | .addComponent(dLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
72 | .addGroup(layout.createSequentialGroup()
73 | .addGap(8, 8, 8)
74 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
75 | .addGap(18, 18, 18)
76 | .addComponent(DnameField, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
77 | .addGap(52, 52, 52)
78 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
79 | .addGroup(layout.createSequentialGroup()
80 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
81 | .addGap(26, 26, 26)
82 | .addComponent(TnameField, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
83 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
84 | .addComponent(tLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
85 | .addGap(18, 18, 18)))
86 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
87 | );
88 | layout.setVerticalGroup(
89 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
90 | .addGroup(layout.createSequentialGroup()
91 | .addContainerGap()
92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
93 | .addComponent(dLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
94 | .addComponent(tLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
95 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
96 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
97 | .addComponent(jLabel1)
98 | .addComponent(jLabel2)
99 | .addComponent(TnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
100 | .addComponent(DnameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
101 | .addContainerGap(54, Short.MAX_VALUE))
102 | );
103 | }// //GEN-END:initComponents
104 |
105 | private void DnameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DnameFieldActionPerformed
106 | // TODO add your handling code here:
107 | }//GEN-LAST:event_DnameFieldActionPerformed
108 |
109 | // Variables declaration - do not modify//GEN-BEGIN:variables
110 | private javax.swing.JTextField DnameField;
111 | private javax.swing.JTextField TnameField;
112 | private javax.swing.JLabel dLabel;
113 | private javax.swing.JLabel jLabel1;
114 | private javax.swing.JLabel jLabel2;
115 | private javax.swing.JLabel tLabel;
116 | // End of variables declaration//GEN-END:variables
117 | }
118 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/ScaffwizardWizardAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import java.awt.Component;
9 | import java.awt.event.ActionEvent;
10 | import java.awt.event.ActionListener;
11 | import java.text.MessageFormat;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 | import javax.swing.JComponent;
15 | import org.openide.DialogDisplayer;
16 | import org.openide.WizardDescriptor;
17 |
18 | // An example action demonstrating how the wizard could be called from within
19 | // your code. You can move the code below wherever you need, or register an action:
20 | // @ActionID(category="...", id="com.codeigniter.netbeans.generator.ScaffwizardWizardAction")
21 | // @ActionRegistration(displayName="Open Scaffwizard Wizard")
22 | // @ActionReference(path="Menu/Tools", position=...)
23 | public final class ScaffwizardWizardAction implements ActionListener {
24 |
25 | @Override
26 | public void actionPerformed(ActionEvent e) {
27 | List> panels = new ArrayList>();
28 | panels.add(new ScaffwizardWizardPanel1());
29 | String[] steps = new String[panels.size()];
30 | for (int i = 0; i < panels.size(); i++) {
31 | Component c = panels.get(i).getComponent();
32 | // Default step name to component name of panel.
33 | steps[i] = c.getName();
34 | if (c instanceof JComponent) { // assume Swing components
35 | JComponent jc = (JComponent) c;
36 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
37 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
38 | jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
39 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
40 | jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
41 | }
42 | }
43 | WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator(panels));
44 | // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
45 | wiz.setTitleFormat(new MessageFormat("{0}"));
46 | wiz.setTitle("...dialog title...");
47 | if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
48 | // do something
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/ScaffwizardWizardPanel1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import javax.swing.event.ChangeListener;
9 | import org.openide.WizardDescriptor;
10 | import org.openide.WizardValidationException;
11 | import org.openide.util.HelpCtx;
12 |
13 | public class ScaffwizardWizardPanel1 implements WizardDescriptor.ValidatingPanel {
14 |
15 | /**
16 | * The visual component that displays this panel. If you need to access the
17 | * component from this class, just use getComponent().
18 | */
19 | private ScaffwizardVisualPanel1 component;
20 |
21 | // Get the visual component for the panel. In this template, the component
22 | // is kept separate. This can be more efficient: if the wizard is created
23 | // but never displayed, or not all panels are displayed, it is better to
24 | // create only those which really need to be visible.
25 | @Override
26 | public ScaffwizardVisualPanel1 getComponent() {
27 | if (component == null) {
28 | component = new ScaffwizardVisualPanel1();
29 | }
30 | return component;
31 | }
32 |
33 | @Override
34 | public HelpCtx getHelp() {
35 | // Show no Help button for this panel:
36 | return HelpCtx.DEFAULT_HELP;
37 | // If you have context help:
38 | // return new HelpCtx("help.key.here");
39 | }
40 |
41 | @Override
42 | public boolean isValid() {
43 | // If it is always OK to press Next or Finish, then:
44 | return true;
45 | // If it depends on some condition (form filled out...) and
46 | // this condition changes (last form field filled in...) then
47 | // use ChangeSupport to implement add/removeChangeListener below.
48 | // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
49 | }
50 |
51 | @Override
52 | public void addChangeListener(ChangeListener l) {
53 | }
54 |
55 | @Override
56 | public void removeChangeListener(ChangeListener l) {
57 | }
58 |
59 | @Override
60 | public void readSettings(WizardDescriptor wiz) {
61 | // use wiz.getProperty to retrieve previous panel state
62 | }
63 |
64 | @Override
65 | public void storeSettings(WizardDescriptor wiz) {
66 | // use wiz.putProperty to remember current panel state
67 | wiz.putProperty("Dname", component.getDNameField().getText());
68 | wiz.putProperty("Tname", component.getTNameField().getText());
69 | }
70 |
71 | @Override
72 | public void validate() throws WizardValidationException{
73 | String Dname = component.getDNameField().getText();
74 | if (Dname.equals("")){
75 | throw new WizardValidationException(null, "Invalid DB Name", null);
76 | }
77 | String Tname = component.getTNameField().getText();
78 | if (Tname.equals("")){
79 | throw new WizardValidationException(null, "Invalid Table Name", null);
80 | }
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/cilogo16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/generator/cilogo16.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/cilogo24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/generator/cilogo24.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/cilogo32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/generator/cilogo32.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/cilogo64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/generator/cilogo64.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/generatorAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.generator;
7 |
8 | import java.awt.event.ActionEvent;
9 | import java.awt.event.ActionListener;
10 | import org.openide.awt.ActionID;
11 | import org.openide.awt.ActionReference;
12 | import org.openide.awt.ActionReferences;
13 | import org.openide.awt.ActionRegistration;
14 | import org.openide.util.NbBundle.Messages;
15 |
16 | @ActionID(
17 | category = "CodeIgniter",
18 | id = "com.codeigniter.netbeans.generator.generatorAction"
19 | )
20 | @ActionRegistration(
21 | iconBase = "com/codeigniter/netbeans/generator/cilogo16.png",
22 | displayName = "#CTL_generatorAction"
23 | )
24 | @ActionReferences({
25 | @ActionReference(path = "Toolbars/CodeIgniter", position = -100)
26 | })
27 | @Messages("CTL_generatorAction=CI Generator")
28 | public final class generatorAction implements ActionListener {
29 |
30 | @Override
31 | public void actionPerformed(ActionEvent e) {
32 | // TODO implement action body
33 | Newframe f = new Newframe("CI Generator");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/generator/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold code generation code (Max)
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/layer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/AvailablePluginsOptionsPanelController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.manager;
7 |
8 | import java.beans.PropertyChangeListener;
9 | import java.beans.PropertyChangeSupport;
10 | import javax.swing.JComponent;
11 | import javax.swing.SwingUtilities;
12 | import org.netbeans.spi.options.OptionsPanelController;
13 | import org.openide.util.HelpCtx;
14 | import org.openide.util.Lookup;
15 |
16 | @OptionsPanelController.SubRegistration(
17 | location = "CodeIgniter",
18 | displayName = "#AdvancedOption_DisplayName_Available",
19 | keywords = "#AdvancedOption_Keywords_Available",
20 | keywordsCategory = "CodeIgniter/Available",
21 | position = 2
22 | )
23 | @org.openide.util.NbBundle.Messages({"AdvancedOption_DisplayName_Available=Available", "AdvancedOption_Keywords_Available=Available"})
24 | public final class AvailablePluginsOptionsPanelController extends OptionsPanelController {
25 |
26 | private AvailablePluginsPanel panel;
27 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
28 | private boolean changed;
29 |
30 | public void update() {
31 | getPanel().load();
32 | changed = false;
33 | }
34 |
35 | public void applyChanges() {
36 | SwingUtilities.invokeLater(new Runnable() {
37 | @Override
38 | public void run() {
39 | getPanel().store();
40 | changed = false;
41 | }
42 | });
43 | }
44 |
45 | public void cancel() {
46 | // need not do anything special, if no changes have been persisted yet
47 | }
48 |
49 | public boolean isValid() {
50 | return getPanel().valid();
51 | }
52 |
53 | public boolean isChanged() {
54 | return changed;
55 | }
56 |
57 | public HelpCtx getHelpCtx() {
58 | return null; // new HelpCtx("...ID") if you have a help set
59 | }
60 |
61 | public JComponent getComponent(Lookup masterLookup) {
62 | return getPanel();
63 | }
64 |
65 | public void addPropertyChangeListener(PropertyChangeListener l) {
66 | pcs.addPropertyChangeListener(l);
67 | }
68 |
69 | public void removePropertyChangeListener(PropertyChangeListener l) {
70 | pcs.removePropertyChangeListener(l);
71 | }
72 |
73 | private AvailablePluginsPanel getPanel() {
74 | if (panel == null) {
75 | panel = new AvailablePluginsPanel(this);
76 | }
77 | return panel;
78 | }
79 |
80 | void changed() {
81 | if (!changed) {
82 | changed = true;
83 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
84 | }
85 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/AvailablePluginsPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
135 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/AvailablePluginsPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.manager;
7 |
8 | import javax.swing.JFileChooser;
9 | import org.openide.util.NbPreferences;
10 |
11 | final class AvailablePluginsPanel extends javax.swing.JPanel {
12 |
13 | private final AvailablePluginsOptionsPanelController controller;
14 |
15 | AvailablePluginsPanel(AvailablePluginsOptionsPanelController controller) {
16 | this.controller = controller;
17 | initComponents();
18 | // TODO listen to changes in form fields and call controller.changed()
19 | }
20 |
21 | /**
22 | * This method is called from within the constructor to initialize the form.
23 | * WARNING: Do NOT modify this code. The content of this method is always
24 | * regenerated by the Form Editor.
25 | */
26 | // //GEN-BEGIN:initComponents
27 | private void initComponents() {
28 |
29 | jScrollPane1 = new javax.swing.JScrollPane();
30 | CiPluginListTable = new javax.swing.JTable();
31 | CiPluginDescriptionLable = new javax.swing.JLabel();
32 | CiPluginInstallBtn = new javax.swing.JButton();
33 |
34 | CiPluginListTable.setModel(new javax.swing.table.DefaultTableModel(
35 | new Object [][] {
36 | {"Test1", "1", "Good"},
37 | {"other", "2", "Good"},
38 | {"Another", "3", "No"}
39 | },
40 | new String [] {
41 | "Plugin", "Version", "Stable"
42 | }
43 | ));
44 | jScrollPane1.setViewportView(CiPluginListTable);
45 | if (CiPluginListTable.getColumnModel().getColumnCount() > 0) {
46 | CiPluginListTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(AvailablePluginsPanel.class, "AvailablePluginsPanel.CiPluginListTable.columnModel.title0")); // NOI18N
47 | CiPluginListTable.getColumnModel().getColumn(1).setHeaderValue(org.openide.util.NbBundle.getMessage(AvailablePluginsPanel.class, "AvailablePluginsPanel.CiPluginListTable.columnModel.title1")); // NOI18N
48 | CiPluginListTable.getColumnModel().getColumn(2).setHeaderValue(org.openide.util.NbBundle.getMessage(AvailablePluginsPanel.class, "AvailablePluginsPanel.CiPluginListTable.columnModel.title2")); // NOI18N
49 | }
50 |
51 | org.openide.awt.Mnemonics.setLocalizedText(CiPluginDescriptionLable, org.openide.util.NbBundle.getMessage(AvailablePluginsPanel.class, "AvailablePluginsPanel.CiPluginDescriptionLable.text")); // NOI18N
52 | CiPluginDescriptionLable.setVerticalAlignment(javax.swing.SwingConstants.TOP);
53 | CiPluginDescriptionLable.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(130, 135, 144)));
54 |
55 | org.openide.awt.Mnemonics.setLocalizedText(CiPluginInstallBtn, org.openide.util.NbBundle.getMessage(AvailablePluginsPanel.class, "AvailablePluginsPanel.CiPluginInstallBtn.text")); // NOI18N
56 | CiPluginInstallBtn.addActionListener(new java.awt.event.ActionListener() {
57 | public void actionPerformed(java.awt.event.ActionEvent evt) {
58 | CiPluginInstallBtnActionPerformed(evt);
59 | }
60 | });
61 |
62 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
63 | this.setLayout(layout);
64 | layout.setHorizontalGroup(
65 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
66 | .addGroup(layout.createSequentialGroup()
67 | .addContainerGap()
68 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
69 | .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE)
70 | .addComponent(CiPluginDescriptionLable, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
71 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
72 | .addGap(0, 0, Short.MAX_VALUE)
73 | .addComponent(CiPluginInstallBtn)))
74 | .addContainerGap())
75 | );
76 | layout.setVerticalGroup(
77 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78 | .addGroup(layout.createSequentialGroup()
79 | .addContainerGap()
80 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
81 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
82 | .addComponent(CiPluginDescriptionLable, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
83 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
84 | .addComponent(CiPluginInstallBtn)
85 | .addContainerGap(76, Short.MAX_VALUE))
86 | );
87 | }// //GEN-END:initComponents
88 |
89 | private void CiPluginInstallBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CiPluginInstallBtnActionPerformed
90 | // TODO add your handling code here:
91 | }//GEN-LAST:event_CiPluginInstallBtnActionPerformed
92 |
93 | void load() {
94 | // TODO read settings and initialize GUI
95 | // Example:
96 | // someCheckBox.setSelected(Preferences.userNodeForPackage(AvailablePanel.class).getBoolean("someFlag", false));
97 | // or for org.openide.util with API spec. version >= 7.4:
98 | // someCheckBox.setSelected(NbPreferences.forModule(AvailablePanel.class).getBoolean("someFlag", false));
99 | // or:
100 | // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
101 | }
102 |
103 | void store() {
104 | // TODO store modified settings
105 | // Example:
106 | // Preferences.userNodeForPackage(AvailablePanel.class).putBoolean("someFlag", someCheckBox.isSelected());
107 | // or for org.openide.util with API spec. version >= 7.4:
108 | // NbPreferences.forModule(AvailablePanel.class).putBoolean("someFlag", someCheckBox.isSelected());
109 | // or:
110 | // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
111 | }
112 |
113 | boolean valid() {
114 | // TODO check whether form is consistent and complete
115 | return true;
116 | }
117 |
118 | // Variables declaration - do not modify//GEN-BEGIN:variables
119 | private javax.swing.JLabel CiPluginDescriptionLable;
120 | private javax.swing.JButton CiPluginInstallBtn;
121 | private javax.swing.JTable CiPluginListTable;
122 | private javax.swing.JScrollPane jScrollPane1;
123 | // End of variables declaration//GEN-END:variables
124 | }
125 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/Bundle.properties:
--------------------------------------------------------------------------------
1 | AvailablePanel.jTable1.columnModel.title3=Title 4
2 | CiLocationVersionPanel.CiPathLabel.text=Ci Location:
3 | CiLocationVersionPanel.CiVersionLabel.text=Ci Version:
4 | CiLocationVersionPanel.CiVersion.text=None
5 | CiLocationVersionPanel.CiPath.text=None
6 | CiLocationVersionPanel.CiUpdateButton.text=Update
7 | AvailablePluginsPanel.CiPluginDescriptionLable.text=Sample Description
8 | AvailablePluginsPanel.CiPluginListTable.columnModel.title2=Stable
9 | AvailablePluginsPanel.CiPluginListTable.columnModel.title1=Version
10 | AvailablePluginsPanel.CiPluginListTable.columnModel.title0=Plugin
11 | AvailablePluginsPanel.CiPluginInstallBtn.text=Install
12 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/CiLocationVersionOptionsPanelController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.manager;
7 |
8 | import java.beans.PropertyChangeListener;
9 | import java.beans.PropertyChangeSupport;
10 | import javax.swing.JComponent;
11 | import javax.swing.SwingUtilities;
12 | import org.netbeans.spi.options.OptionsPanelController;
13 | import org.openide.util.HelpCtx;
14 | import org.openide.util.Lookup;
15 |
16 | @OptionsPanelController.SubRegistration(
17 | location = "CodeIgniter",
18 | displayName = "#AdvancedOption_DisplayName_CiLocationVersion",
19 | keywords = "#AdvancedOption_Keywords_CiLocationVersion",
20 | keywordsCategory = "CodeIgniter/CiLocationVersion",
21 | position = 1
22 | )
23 | @org.openide.util.NbBundle.Messages({"AdvancedOption_DisplayName_CiLocationVersion=CI Location/Version", "AdvancedOption_Keywords_CiLocationVersion=CI location version"})
24 | public final class CiLocationVersionOptionsPanelController extends OptionsPanelController {
25 |
26 | private CiLocationVersionPanel panel;
27 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
28 | private boolean changed;
29 |
30 | public void update() {
31 | getPanel().load();
32 | changed = false;
33 | }
34 |
35 | public void applyChanges() {
36 | SwingUtilities.invokeLater(new Runnable() {
37 | @Override
38 | public void run() {
39 | getPanel().store();
40 | changed = false;
41 | }
42 | });
43 | }
44 |
45 | public void cancel() {
46 | // need not do anything special, if no changes have been persisted yet
47 | }
48 |
49 | public boolean isValid() {
50 | return getPanel().valid();
51 | }
52 |
53 | public boolean isChanged() {
54 | return changed;
55 | }
56 |
57 | public HelpCtx getHelpCtx() {
58 | return null; // new HelpCtx("...ID") if you have a help set
59 | }
60 |
61 | public JComponent getComponent(Lookup masterLookup) {
62 | return getPanel();
63 | }
64 |
65 | public void addPropertyChangeListener(PropertyChangeListener l) {
66 | pcs.addPropertyChangeListener(l);
67 | }
68 |
69 | public void removePropertyChangeListener(PropertyChangeListener l) {
70 | pcs.removePropertyChangeListener(l);
71 | }
72 |
73 | private CiLocationVersionPanel getPanel() {
74 | if (panel == null) {
75 | panel = new CiLocationVersionPanel(this);
76 | }
77 | return panel;
78 | }
79 |
80 | void changed() {
81 | if (!changed) {
82 | changed = true;
83 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
84 | }
85 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/CiLocationVersionPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
99 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/CiLocationVersionPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.manager;
7 |
8 | import java.io.BufferedReader;
9 | import java.io.File;
10 | import java.io.FileInputStream;
11 | import java.io.IOException;
12 | import java.io.InputStreamReader;
13 | import javax.swing.JFileChooser;
14 | import org.openide.util.Exceptions;
15 | import org.openide.util.NbPreferences;
16 |
17 | final class CiLocationVersionPanel extends javax.swing.JPanel {
18 |
19 | private final CiLocationVersionOptionsPanelController controller;
20 |
21 | CiLocationVersionPanel(CiLocationVersionOptionsPanelController controller) {
22 | this.controller = controller;
23 | initComponents();
24 | // TODO listen to changes in form fields and call controller.changed()
25 | }
26 |
27 | /**
28 | * This method is called from within the constructor to initialize the form.
29 | * WARNING: Do NOT modify this code. The content of this method is always
30 | * regenerated by the Form Editor.
31 | */
32 | // //GEN-BEGIN:initComponents
33 | private void initComponents() {
34 |
35 | CiPathLabel = new javax.swing.JLabel();
36 | CiPath = new javax.swing.JLabel();
37 | CiVersion = new javax.swing.JLabel();
38 | CiVersionLabel = new javax.swing.JLabel();
39 | CiUpdateButton = new javax.swing.JButton();
40 |
41 | org.openide.awt.Mnemonics.setLocalizedText(CiPathLabel, org.openide.util.NbBundle.getMessage(CiLocationVersionPanel.class, "CiLocationVersionPanel.CiPathLabel.text")); // NOI18N
42 |
43 | org.openide.awt.Mnemonics.setLocalizedText(CiPath, org.openide.util.NbBundle.getMessage(CiLocationVersionPanel.class, "CiLocationVersionPanel.CiPath.text")); // NOI18N
44 |
45 | org.openide.awt.Mnemonics.setLocalizedText(CiVersion, org.openide.util.NbBundle.getMessage(CiLocationVersionPanel.class, "CiLocationVersionPanel.CiVersion.text")); // NOI18N
46 |
47 | org.openide.awt.Mnemonics.setLocalizedText(CiVersionLabel, org.openide.util.NbBundle.getMessage(CiLocationVersionPanel.class, "CiLocationVersionPanel.CiVersionLabel.text")); // NOI18N
48 |
49 | org.openide.awt.Mnemonics.setLocalizedText(CiUpdateButton, org.openide.util.NbBundle.getMessage(CiLocationVersionPanel.class, "CiLocationVersionPanel.CiUpdateButton.text")); // NOI18N
50 | CiUpdateButton.addActionListener(new java.awt.event.ActionListener() {
51 | public void actionPerformed(java.awt.event.ActionEvent evt) {
52 | CiUpdateButtonActionPerformed(evt);
53 | }
54 | });
55 |
56 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
57 | this.setLayout(layout);
58 | layout.setHorizontalGroup(
59 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
60 | .addGroup(layout.createSequentialGroup()
61 | .addContainerGap()
62 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
63 | .addGroup(layout.createSequentialGroup()
64 | .addComponent(CiPathLabel)
65 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
66 | .addComponent(CiPath))
67 | .addGroup(layout.createSequentialGroup()
68 | .addComponent(CiVersionLabel)
69 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
70 | .addComponent(CiVersion))
71 | .addComponent(CiUpdateButton))
72 | .addContainerGap(380, Short.MAX_VALUE))
73 | );
74 | layout.setVerticalGroup(
75 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
76 | .addGroup(layout.createSequentialGroup()
77 | .addContainerGap()
78 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
79 | .addComponent(CiPath)
80 | .addComponent(CiPathLabel))
81 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
82 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
83 | .addComponent(CiVersionLabel)
84 | .addComponent(CiVersion))
85 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
86 | .addComponent(CiUpdateButton)
87 | .addContainerGap(336, Short.MAX_VALUE))
88 | );
89 | }// //GEN-END:initComponents
90 |
91 | private void CiUpdateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CiUpdateButtonActionPerformed
92 | JFileChooser chooser = new JFileChooser();
93 | if (CiPath.getText().compareTo("None") == 0)
94 | chooser.setCurrentDirectory(new java.io.File(CiPath.getText()));
95 | else
96 | chooser.setCurrentDirectory(new java.io.File(CiPath.getText()));
97 | chooser.setDialogTitle("Select CodeIgniter Project Folder..");
98 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
99 | chooser.setAcceptAllFileFilterUsed(false);
100 | if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
101 | String location = chooser.getSelectedFile().toString();
102 | // check framework exists
103 | String coreCi = location + "/system/core/CodeIgniter.php";
104 | String version = "None";
105 | try {
106 | version = loadCiVersion(coreCi);
107 | } catch (IOException ex) {
108 | Exceptions.printStackTrace(ex);
109 | }
110 | CiPath.setText(location);
111 | CiVersion.setText(version);
112 | }
113 | }//GEN-LAST:event_CiUpdateButtonActionPerformed
114 |
115 | void load() {
116 | // TODO read settings and initialize GUI
117 | // Example:
118 | // someCheckBox.setSelected(Preferences.userNodeForPackage(CiLocationVersionPanel.class).getBoolean("someFlag", false));
119 | // or for org.openide.util with API spec. version >= 7.4:
120 | // someCheckBox.setSelected(NbPreferences.forModule(CiLocationVersionPanel.class).getBoolean("someFlag", false));
121 | // or:
122 | // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty());
123 | CiPath.setText((NbPreferences.forModule(AvailablePluginsPanel.class).get("CiPath", CiPath.getText())));
124 | CiVersion.setText((NbPreferences.forModule(AvailablePluginsPanel.class).get("CiVersion", CiPath.getText())));
125 | }
126 |
127 | void store() {
128 | // TODO store modified settings
129 | // Example:
130 | // Preferences.userNodeForPackage(CiLocationVersionPanel.class).putBoolean("someFlag", someCheckBox.isSelected());
131 | // or for org.openide.util with API spec. version >= 7.4:
132 | // NbPreferences.forModule(CiLocationVersionPanel.class).putBoolean("someFlag", someCheckBox.isSelected());
133 | // or:
134 | // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText());
135 | NbPreferences.forModule(AvailablePluginsPanel.class).put("CiPath", CiPath.getText());
136 | NbPreferences.forModule(AvailablePluginsPanel.class).put("CiVersion", CiVersion.getText());
137 | }
138 |
139 | boolean valid() {
140 | // TODO check whether form is consistent and complete
141 | return true;
142 | }
143 |
144 | // Variables declaration - do not modify//GEN-BEGIN:variables
145 | private javax.swing.JLabel CiPath;
146 | private javax.swing.JLabel CiPathLabel;
147 | private javax.swing.JButton CiUpdateButton;
148 | private javax.swing.JLabel CiVersion;
149 | private javax.swing.JLabel CiVersionLabel;
150 | // End of variables declaration//GEN-END:variables
151 |
152 | private String loadCiVersion(String coreCi) throws IOException {
153 | String version = "None";
154 | FileInputStream fis = new FileInputStream(new File(coreCi));
155 | BufferedReader br = new BufferedReader(new InputStreamReader(fis));
156 |
157 | String line = null;
158 | while ((line = br.readLine()) != null) {
159 | if (line.toLowerCase().contains("CI_VERSION".toLowerCase()))
160 | {
161 | String[] tokens = line.split("[,]");
162 | tokens = tokens[1].split("[']");
163 | version = tokens[1];
164 | break;
165 | }
166 | }
167 | br.close();
168 |
169 | return version;
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */// Position default is 2147483647
6 | @OptionsPanelController.ContainerRegistration(id = "CodeIgniter", categoryName = "#OptionsCategory_Name_CodeIgniter", iconBase = "com/codeigniter/netbeans/shared/Assets/cilogo32.png", keywords = "#OptionsCategory_Keywords_CodeIgniter", keywordsCategory = "CodeIgniter", position = 200000000)
7 | @NbBundle.Messages(value = {"OptionsCategory_Name_CodeIgniter=CodeIgniter", "OptionsCategory_Keywords_CodeIgniter=CodeIgniter"})
8 | package com.codeigniter.netbeans.manager;
9 |
10 | import org.netbeans.spi.options.OptionsPanelController;
11 | import org.openide.util.NbBundle;
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/manager/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold miscellaneous code (Jim)
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/navigator/CiHyperlinkProviderBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.navigator;
7 |
8 | import com.codeigniter.netbeans.shared.PHPDocumentParser;
9 | import java.util.EnumSet;
10 | import java.util.Set;
11 | import javax.swing.text.Document;
12 | import org.netbeans.api.lexer.Token;
13 | import org.netbeans.api.lexer.TokenSequence;
14 | import org.netbeans.modules.php.editor.lexer.PHPTokenId;
15 | import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
16 | import org.netbeans.lib.editor.hyperlink.spi.HyperlinkType;
17 |
18 | /**
19 | *
20 | * @author Tamaki_Sakura
21 | */
22 | public abstract class CiHyperlinkProviderBase implements HyperlinkProviderExt {
23 |
24 | private int targetStart;
25 | private int targetEnd;
26 |
27 | @Override
28 | public Set getSupportedHyperlinkTypes() {
29 | return EnumSet.of(HyperlinkType.GO_TO_DECLARATION);
30 | }
31 |
32 | @Override
33 | public int[] getHyperlinkSpan(Document doc, int offset, HyperlinkType ht) {
34 | if ((targetStart != 0) && (targetEnd != 0)) {
35 | return new int[]{targetStart, targetEnd};
36 | }
37 | return null;
38 | }
39 |
40 | /**
41 | * Get the String of the current Token
42 | *
43 | * @param doc document
44 | * @param offset offset in document
45 | * @return target
46 | */
47 | protected String getStringTokenString(Document doc, int offset) {
48 | TokenSequence tokens = PHPDocumentParser.getTokenSequence(doc);
49 | if (tokens == null) {
50 | return null;
51 | }
52 |
53 | resetLengthValue();
54 |
55 | tokens.move(offset);
56 | tokens.moveNext();
57 | int newOffset = tokens.offset();
58 |
59 | Token token = tokens.token();
60 |
61 | String target = token.text().toString();
62 | PHPTokenId id = token.id();
63 | if (id == PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING) {
64 | if (target.length() > 2) {
65 | target = target.substring(1, target.length() - 1);
66 | targetStart = newOffset + 1;
67 | targetEnd = targetStart + target.length();
68 | } else {
69 | target = null;
70 | }
71 | } else {
72 | target = null;
73 | }
74 |
75 | return target;
76 | }
77 |
78 | /**
79 | * Rest the targetStart/End value
80 | */
81 | private void resetLengthValue() {
82 | targetStart = 0;
83 | targetEnd = 0;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/navigator/CiHyperlinkProviderToFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.navigator;
7 |
8 | import com.codeigniter.netbeans.shared.FileExtractor;
9 | import java.io.File;
10 | import javax.swing.text.Document;
11 | import org.netbeans.api.editor.mimelookup.MimeRegistration;
12 | import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
13 | import org.netbeans.lib.editor.hyperlink.spi.HyperlinkType;
14 | import org.netbeans.modules.csl.api.UiUtils;
15 | import org.netbeans.modules.editor.NbEditorUtilities;
16 | import org.openide.filesystems.FileObject;
17 |
18 | /**
19 | *
20 | * @author Tamaki_Sakura
21 | */
22 | @MimeRegistration(mimeType = "text/x-php5", service = HyperlinkProviderExt.class)
23 | public class CiHyperlinkProviderToFile extends CiHyperlinkProviderBase {
24 |
25 | private FileObject target;
26 |
27 | @Override
28 | public boolean isHyperlinkPoint(Document doc, int offset, HyperlinkType ht) {
29 | target = null;
30 | FileObject docObject = NbEditorUtilities.getFileObject(doc);
31 |
32 | if (docObject == null) {
33 | return false;
34 | }
35 |
36 | String extendedPath = getStringTokenString(doc, offset);
37 | if (extendedPath == null) {
38 | return false;
39 | }
40 |
41 | String targetBases[] = {
42 | FileExtractor.VIEW_PATH,
43 | FileExtractor.MODEL_PATH};
44 |
45 | return getFileFromBase(targetBases, extendedPath, docObject);
46 | }
47 |
48 | @Override
49 | public String getTooltipText(Document doc, int offset, HyperlinkType ht) {
50 | //TODO: Implement a Tooltip based on the path
51 | return null;
52 | }
53 |
54 | @Override
55 | public void performClickAction(Document doc, int offset, HyperlinkType ht) {
56 | if (target != null) {
57 | UiUtils.open(target, 0);
58 | }
59 | }
60 |
61 | /**
62 | * Check if there is a corresponding relative path is refer
63 | * to a file that is extended from a selection of folder
64 | * and if there is, set the target object to be the file
65 | *
66 | * @param targetBases a selection of possible bases
67 | * @param extendedPath the extended path from base
68 | * @param docObject the Fileobject of current document
69 | * @return if there is a file from the selected bases
70 | */
71 | private boolean getFileFromBase(
72 | String[] targetBases, String extendedPath, FileObject docObject) {
73 |
74 | for (String base: targetBases) {
75 | String filePath = base + extendedPath + ".php";
76 |
77 | FileObject parent = FileExtractor.getCiRoot(docObject);
78 | if (parent == null) {
79 | continue;
80 | }
81 | FileObject targetFileObject = parent.getFileObject(filePath);
82 | if (targetFileObject == null) {
83 | continue;
84 | }
85 |
86 | File targetFile = new File(targetFileObject.getPath());
87 |
88 | if (targetFile.exists()) {
89 | target = targetFileObject;
90 | return true;
91 | }
92 | }
93 |
94 | return false;
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/navigator/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold smart mavigation code (Xing)
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/Assets/cilogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/shared/Assets/cilogo.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/Assets/cilogo24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/shared/Assets/cilogo24.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/Assets/cilogo32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/shared/Assets/cilogo32.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/CentralManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import static com.codeigniter.netbeans.shared.FileExtractor.getFilesFromDirectory;
9 | import java.io.File;
10 | import java.io.FileInputStream;
11 | import java.io.FileOutputStream;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.io.ObjectInputStream;
15 | import java.io.ObjectOutputStream;
16 | import java.util.ArrayList;
17 | import java.util.Enumeration;
18 | import java.util.Hashtable;
19 | import java.util.LinkedList;
20 | import java.util.List;
21 | import javax.swing.ImageIcon;
22 | import org.openide.util.ImageUtilities;
23 |
24 | /**
25 | *
26 | * @author dwoods
27 | *
28 | * This class is a singleton that stores important plugin-wide information, including
29 | * location of the Code Igniter system folder, list of CI classes, list of all CI functions, etc.
30 | */
31 | public class CentralManager {
32 |
33 | public static final ImageIcon ICON =
34 | new ImageIcon(ImageUtilities.loadImage("com/codeigniter/netbeans/generator/cilogo16.png"));
35 |
36 | private static CentralManager instance = null;
37 | private List ciClasses = null;
38 | private Hashtable> ciFuncs = null;
39 | private static final String CI_CLASSES_FILENAME = "ciDoc.ser";
40 | private static final String CI_CLASSES_BASEPATH = "src/com/codeigniter/netbeans/shared/";
41 | private static final String CI_SYSTEM_FOLDER = "/Applications/XAMPP/htdocs/system3/";
42 |
43 | private CentralManager() {
44 |
45 | }
46 |
47 | /**
48 | *
49 | * @return The CentralManager singleton
50 | */
51 | public static CentralManager Instance() {
52 | if (instance == null) {
53 | instance = new CentralManager();
54 | }
55 |
56 | return instance;
57 | }
58 |
59 | /**
60 | *
61 | * @return A Hashtable with the method name as the key, and list of CIClasses that has that method
62 | */
63 | public Hashtable> getCiFunctions() {
64 | if (this.ciFuncs == null) {
65 | if (this.ciClasses == null) {
66 | getCiClasses();
67 | }
68 |
69 | this.ciFuncs = new Hashtable>();
70 |
71 | for (CiClass ciClass : this.ciClasses) {
72 | for (CiFunction func : ciClass.getFunctions()) {
73 | List classList = new ArrayList();
74 | if (this.ciFuncs.containsKey(func.getMethodName())) {
75 | classList = this.ciFuncs.get(func.getMethodName());
76 | }
77 | classList.add(ciClass);
78 | this.ciFuncs.put(func.getMethodName(), classList);
79 | }
80 | }
81 | }
82 |
83 | return this.ciFuncs;
84 | }
85 |
86 | /**
87 | *
88 | * @return List of all the CI classes
89 | */
90 | public List getCiClasses() {
91 | if (this.ciClasses == null) {
92 | if (!this.loadCiClasses()) {
93 | updateCiClasses(CI_SYSTEM_FOLDER);
94 | }
95 | }
96 |
97 | return this.ciClasses;
98 | }
99 |
100 | /**
101 | * Saves this.ciClasses to disk at the location specified by ciClassesFilename
102 | */
103 | private void saveCiClasses() {
104 | try {
105 | FileOutputStream fileOut = new FileOutputStream(CI_CLASSES_BASEPATH + CI_CLASSES_FILENAME);
106 | ObjectOutputStream out = new ObjectOutputStream(fileOut);
107 | out.writeObject(this.ciClasses);
108 | out.close();
109 | fileOut.close();
110 | }
111 | catch (IOException ioe) {
112 | ioe.printStackTrace(System.err);
113 | }
114 | }
115 |
116 | /**
117 | * Loads the ciDoc.ser file from the location specified by ciClassesFilename
118 | * @return True if successful. False otherwise
119 | */
120 | private boolean loadCiClasses() {
121 | boolean retval = false;
122 | try {
123 | // Look in this package for the serialized file containing a list of all the CI methods
124 | InputStream is = this.getClass().getResourceAsStream(CI_CLASSES_FILENAME);
125 | // Check if file was found
126 | if (is != null) {
127 | ObjectInputStream in = new ObjectInputStream(is);
128 | this.ciClasses = (ArrayList)in.readObject();
129 | in.close();
130 | is.close();
131 | retval = true;
132 | }
133 | else {
134 | System.err.printf("Unable to find %s\n", CI_CLASSES_FILENAME);
135 | }
136 | }
137 | catch (Exception e) {
138 | e.printStackTrace(System.err);
139 | }
140 |
141 | return retval;
142 | }
143 |
144 | /**
145 | * This method updates the file containing the list of CI methods & classes.
146 | * There are several steps required to updating this file:
147 | * 1) Delete the current file. Use CI_CLASSES_BASEPATH & CI_CLASSES_FILENAME to find it
148 | * 2) Change the CI_SYSTEM_FOLDER variable to point to the directory containing the Code Igniter framework
149 | * that is on YOUR system. This directory will be recursively searched for all libraries, helpers, & core CI files.
150 | * It will then extract all classes and public method from these files.
151 | * 3) Call this method and verify that the file has been created.
152 | * @param path The base path for the CI system folder
153 | */
154 | private void updateCiClasses(String path) {
155 | if (!path.endsWith("/")) {
156 | path = path.concat("/");
157 | }
158 |
159 | File ciLibDir = new File(path + "libraries/");
160 | File ciHelperDir = new File(path + "helpers/");
161 | File ciCoreDir = new File(path + "core/");
162 | List fileExts = new LinkedList();
163 | fileExts.add("php");
164 | this.ciClasses = new ArrayList();
165 |
166 | try {
167 | List files = getFilesFromDirectory(ciLibDir, fileExts, false);
168 | files.addAll(getFilesFromDirectory(ciHelperDir, fileExts, false));
169 | files.addAll(getFilesFromDirectory(ciCoreDir, fileExts, false));
170 |
171 | for (File f : files) {
172 | CiClass ciClass = PHPDocumentParser.extractCiClass(f);
173 | ciClass.setFunctions(PHPDocumentParser.extractFunctions(f));
174 | this.ciClasses.add(ciClass);
175 | }
176 |
177 | saveCiClasses();
178 |
179 | // Print
180 | // Enumeration ciEnum = this.ciClasses.keys();
181 | // while (ciEnum.hasMoreElements()) {
182 | // CiClass c = ciEnum.nextElement();
183 | // List funcs = this.ciClasses.get(c);
184 | // System.out.println(c.toString());
185 | // for (CiFunction func : funcs) {
186 | // System.out.println(func.toString());
187 | // }
188 | // }
189 | }
190 | catch (Exception e) {
191 | e.printStackTrace(System.err);
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/CiClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import java.io.Serializable;
9 | import java.net.URL;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * CiClass contains information about a Code Igniter class that's useful for navigating to its documentation page
15 | * @author dwoods
16 | */
17 | public class CiClass implements Serializable {
18 |
19 | private URL documentationLink;
20 | private String name;
21 | private ArrayList functions;
22 |
23 | public CiClass(String name) {
24 | this(name, null);
25 | }
26 |
27 | public CiClass(String name, URL documentationLink) {
28 | assert(name != null);
29 | this.name = name;
30 | this.documentationLink = documentationLink;
31 | this.functions = new ArrayList();
32 | }
33 |
34 | public void addFunction(CiFunction function) {
35 | this.functions.add(function);
36 | }
37 |
38 | public void setFunctions(ArrayList functions) {
39 | this.functions = functions;
40 | }
41 |
42 | public URL getDocumentationLink() {
43 | return this.documentationLink;
44 | }
45 |
46 | public ArrayList getFunctions() {
47 | return this.functions;
48 | }
49 |
50 | public String getName() {
51 | return this.name;
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | String retval = this.name;
57 | if (this.documentationLink != null) {
58 | retval = retval.concat(String.format(" : %s", this.documentationLink.toString()));
59 | }
60 | return retval;
61 | }
62 |
63 | @Override
64 | public int hashCode() {
65 | return this.name.hashCode();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/CiFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import java.io.Serializable;
9 | import java.util.Vector;
10 |
11 | /**
12 | *
13 | * @author dwoods
14 | */
15 | public class CiFunction implements Serializable {
16 |
17 | private String method;
18 | private Vector parameters;
19 |
20 | public CiFunction(String method) {
21 | this(method, new Vector());
22 | }
23 |
24 | public CiFunction(String method, Vector parameters) {
25 | assert(parameters != null);
26 |
27 | this.method = method;
28 | this.parameters = parameters;
29 | }
30 |
31 | public String getMethodName() {
32 | return method;
33 | }
34 |
35 | public Vector getParameters() {
36 | // Defensive copy to prevent external modification
37 | return new Vector(this.parameters);
38 | }
39 |
40 | public void addParameter(CiParameter param) {
41 | assert(this.parameters != null);
42 | this.parameters.add(param);
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | String retval = String.format("%s(", this.method);
48 | boolean first = true;
49 |
50 | for (CiParameter param : this.parameters) {
51 | if (!first) {
52 | retval = retval.concat(", ");
53 | }
54 | retval = retval.concat(param.toString());
55 | first = false;
56 | }
57 |
58 | return retval.concat(")");
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/CiParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import java.io.Serializable;
9 |
10 | /**
11 | *
12 | * @author dwoods
13 | */
14 | class CiParameter implements Serializable {
15 |
16 | public String name;
17 | public String defaultValue; // String representation of the default value or null if no default value
18 |
19 | public CiParameter(String name) {
20 | this(name, null);
21 | }
22 |
23 | public CiParameter(String name, String defaultValue) {
24 | this.name = name;
25 | this.defaultValue = defaultValue;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | /**
33 | *
34 | * @return - The string representation of the default value, or null if there is no default value
35 | */
36 | public String getDefaultValue() {
37 | return defaultValue;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | String retval = this.name;
43 | if (this.defaultValue != null) {
44 | retval = retval.concat(String.format(" = %s", this.defaultValue));
45 | }
46 | return retval;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/FileExtractor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import java.io.File;
9 | import java.io.FileOutputStream;
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.nio.file.DirectoryStream;
13 | import java.nio.file.Files;
14 | import java.nio.file.Path;
15 | import java.util.ArrayList;
16 | import java.util.Arrays;
17 | import java.util.Iterator;
18 | import java.util.LinkedList;
19 | import java.util.List;
20 | import java.util.Locale;
21 | import org.netbeans.api.project.FileOwnerQuery;
22 | import org.netbeans.api.project.Project;
23 | import org.netbeans.api.project.ProjectManager;
24 | import org.netbeans.spi.project.support.ant.AntProjectHelper;
25 | import org.netbeans.spi.project.support.ant.EditableProperties;
26 | import org.netbeans.spi.project.support.ant.PropertyUtils;
27 | import org.openide.filesystems.FileObject;
28 | import org.openide.util.Exceptions;
29 | import org.openide.util.Mutex;
30 |
31 | /**
32 | *
33 | * @author dwoods
34 | *
35 | * This class is designed to contain functions for searching for files on the File System, and other file related functions
36 | *
37 | */
38 | public abstract class FileExtractor {
39 |
40 | public static final String INCLUDE_PATH = "include.path";
41 |
42 | public static final String VIEW_PATH = "application/views/";
43 | public static final String MODEL_PATH = "application/models/";
44 | public static final String CONTROLLER_PATH = "application/controllers/";
45 |
46 | private static final String[] APP_BASE
47 | = {"cache", "config", "controllers", "core", "helpers", "models"};
48 |
49 | /**
50 | *
51 | * @param dir - The directory to be searched
52 | * @param fileExts - The list of valid file extensions for the files to be returned. The "." should not be included
53 | * Pass null to return all files in the directory
54 | * @param recursive - Whether to search the directory recursively (will search all directories within the given directory)
55 | * @return - A List of File's matching the given file extensions
56 | */
57 | public static List getFilesFromDirectory(File dir, List fileExts, boolean recursive) throws IllegalArgumentException, IOException
58 | {
59 | if (!dir.isDirectory()) {
60 | throw new IllegalArgumentException(String.format("%s is not a directory\n", dir.getAbsolutePath()));
61 | }
62 |
63 | List retval = new LinkedList();
64 |
65 | // Use a DirectoryStream to iterate over files in the directory
66 | // since JavaDoc recommends it for its efficiency over other methods
67 | DirectoryStream dirStream = Files.newDirectoryStream(dir.toPath());
68 | Iterator it = dirStream.iterator();
69 |
70 | while (it.hasNext()) {
71 | File nextFile = it.next().toFile();
72 | if (nextFile.isDirectory() && recursive) {
73 | try {
74 | retval.addAll(getFilesFromDirectory(nextFile, fileExts, recursive));
75 | }
76 | catch (IllegalArgumentException iae) {
77 | System.err.println("Illegal Argument: Something went terribly wrong in getFilesFromDirectory()!");
78 | }
79 | catch (IOException ioe) {
80 | System.err.printf("getFilesFromDirectory(): Unable to get files from %s\n", nextFile.getAbsolutePath());
81 | }
82 | }
83 | else if (nextFile.isFile()) {
84 | String ext = getFileExtensionType(nextFile);
85 | if (fileExts == null || fileExts.contains(ext)) {
86 | retval.add(nextFile);
87 | }
88 | }
89 | }
90 |
91 | return retval;
92 | }
93 |
94 | /**
95 | *
96 | * @param file
97 | * @return - The file's extension (not including the ".") or empty string if file doesn't have an extension.
98 | */
99 | public static String getFileExtensionType(File file) throws IllegalArgumentException
100 | {
101 | if (file.isDirectory()) {
102 | throw new IllegalArgumentException(String.format("%s is not a file\n", file.getAbsoluteFile()));
103 | }
104 |
105 | String retval = "";
106 | int index = file.getName().lastIndexOf(".");
107 |
108 | if (index != -1) {
109 | retval = file.getName().substring(index + 1);
110 | }
111 |
112 | return retval;
113 | }
114 |
115 | /**
116 | *
117 | * @param file
118 | * @return True if the file extension is ".php"
119 | */
120 | public static boolean isPHPFile(File file) {
121 | boolean retval = false;
122 |
123 | try {
124 | retval = getFileExtensionType(file).equals("php");
125 | }
126 | catch (IllegalArgumentException iae) {
127 | // Do nothing... will return false
128 | }
129 |
130 | return retval;
131 | }
132 |
133 | /**
134 | * Get the CodeIgniter Root for any file in application folder
135 | *
136 | * @param doc FileObject document
137 | * @return root
138 | */
139 | public static FileObject getCiRoot(FileObject doc) {
140 | //TODO: Need Talk
141 | //What is the best way to know the "root" directory of CodeIgniter?
142 |
143 | while (doc != null) {
144 | doc = doc.getParent();
145 | FileObject[] children = doc.getChildren();
146 | int count = 0;
147 |
148 | for (FileObject child: children) {
149 | for (String folder: APP_BASE) {
150 | if (child
151 | .getName()
152 | .equals(folder.toLowerCase(Locale.ENGLISH))) {
153 | count++;
154 | break;
155 | }
156 | }
157 | }
158 |
159 | if (count == APP_BASE.length) {
160 | break;
161 | }
162 | }
163 |
164 | if (doc == null) {
165 | return null;
166 | }
167 |
168 | FileObject root = doc.getParent();
169 | return root;
170 | }
171 |
172 | /**
173 | * Use the current PHp document as a pointer to add
174 | * auto completion file into the project path
175 | * @param doc any document of the current project
176 | */
177 | public static void addCompleteToIncludePathFromDoc(final FileObject doc) {
178 | FileObject ciRoot = getCiRoot(doc);
179 | if (ciRoot == null) {
180 | return;
181 | }
182 | Project project = FileOwnerQuery.getOwner(ciRoot);
183 | if (project == null) {
184 | return;
185 | }
186 |
187 | addCompleteToIncludePath(ciRoot, project);
188 | }
189 |
190 | /**
191 | * Add auto completion file into the project path
192 | * @param ciRoot Root of CodeIgniter Project
193 | * @param project the Project object of the PHP Project
194 | */
195 | public static void addCompleteToIncludePath(
196 | final FileObject ciRoot, final Project project) {
197 | ProjectManager.mutex().writeAccess(new Mutex.Action() {
198 |
199 | @Override
200 | public Void run() {
201 | try {
202 | AntProjectHelper helper = project.getLookup().lookup(AntProjectHelper.class);
203 | if (helper == null) {
204 | return null;
205 | }
206 |
207 | EditableProperties properties
208 | = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
209 | String currentPaths[]
210 | = PropertyUtils.tokenizePath((properties.getProperty(INCLUDE_PATH)));
211 | ArrayList newPaths
212 | = new ArrayList(Arrays.asList(currentPaths));
213 |
214 | for (String path: currentPaths) {
215 | if (path != null) {
216 | if (path.contains("ci_autocomplete")) {
217 | return null;
218 | } else {
219 | newPaths.add(path);
220 | }
221 | }
222 | }
223 |
224 | String target = getAutocompleteFolderPath(ciRoot);
225 | newPaths.add(target);
226 |
227 | properties.setProperty(
228 | INCLUDE_PATH,
229 | newPaths.toArray(new String[0]));
230 | helper.putProperties(
231 | AntProjectHelper.PROJECT_PROPERTIES_PATH, properties);
232 | ProjectManager.getDefault().saveProject(project);
233 | } catch (IOException ex) {
234 | Exceptions.printStackTrace(ex);
235 | }
236 | return null;
237 | }
238 |
239 | });
240 | }
241 |
242 | /**
243 | * Get the auto complete file path.
244 | * @param ciRoot the Root of codeigniter project where path start
245 | * @return path
246 | * @throws IOException
247 | */
248 | private static String getAutocompleteFolderPath(FileObject ciRoot) throws IOException {
249 | InputStream is = FileExtractor.class.getResourceAsStream(
250 | "/com/codeigniter/netbeans/completer/autocomplete.php");
251 | if (is == null) {
252 | return null;
253 | }
254 | String completionFolderPath = ciRoot.getPath() + "/../ci_autocomplete_folder/";
255 | String completionFilePath = completionFolderPath + "ci_autocomplete.php";
256 | File completionFolder = new File(completionFolderPath);
257 | if (!completionFolder.exists()) {
258 | completionFolder.mkdirs();
259 | }
260 | File completionFile = new File(completionFilePath);
261 | if (!completionFile.exists()) {
262 | completionFile.createNewFile();
263 | }
264 | FileOutputStream os = new FileOutputStream(completionFile, false);
265 | while (is.available() > 0) {
266 | os.write(is.read());
267 | }
268 | is.close();
269 | os.close();
270 |
271 | return completionFolder.getPath();
272 | }
273 |
274 | }
275 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/PHPDocumentParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.shared;
7 |
8 | import java.io.BufferedReader;
9 | import java.io.File;
10 | import java.io.FileNotFoundException;
11 | import java.io.FileReader;
12 | import java.io.IOException;
13 | import java.net.MalformedURLException;
14 | import java.net.URL;
15 | import java.util.ArrayList;
16 | import java.util.Vector;
17 | import javax.swing.text.AbstractDocument;
18 | import javax.swing.text.Document;
19 | import org.netbeans.api.lexer.Token;
20 | import org.netbeans.api.lexer.TokenHierarchy;
21 | import org.netbeans.api.lexer.TokenSequence;
22 | import org.netbeans.modules.php.editor.lexer.PHPTokenId;
23 |
24 | /**
25 | *
26 | * @author dwoods
27 | */
28 | public abstract class PHPDocumentParser {
29 |
30 | private static final String ciDocBase = "http://codeigniter.com/user_guide";
31 |
32 | /**
33 | * Attempts to extract the class name and CI documentation URL from the file.
34 | * Note: Assumes there is at most 1 class per file. Will take the first class name encountered in the event of multiple classes
35 | * @param file
36 | * @return - CiClass for the file. The filename will be used as the className if no class is
37 | * declared in the file (E.g. a helper file)
38 | * @throws FileNotFoundException, IllegalArgumentException
39 | */
40 | public static CiClass extractCiClass(File file)
41 | throws FileNotFoundException, IllegalArgumentException {
42 | if (!FileExtractor.isPHPFile(file)) {
43 | throw new IllegalArgumentException(String.format("%s is not a .php file\n", file.getAbsolutePath()));
44 | }
45 |
46 | CiClass retval = null;
47 | URL docLink = null;
48 | String className = null;
49 | TokenSequence tokenSeq = getTokensFromFile(file);
50 |
51 | if (tokenSeq != null) {
52 | boolean done = false;
53 |
54 | while (!done && tokenSeq.moveNext()) {
55 | // Search for URL in the starting comment blocks
56 | Token token = tokenSeq.token();
57 |
58 | if (token.id().equals(PHPTokenId.PHPDOC_COMMENT)) {
59 | String docComment = token.text().toString();
60 | String[] arr = docComment.split("\\s+");
61 |
62 | for (String s : arr) {
63 | if (s.startsWith(ciDocBase)) {
64 | try {
65 | // Update all links to point to the user_guide 3
66 | s = s.replaceFirst("/user_guide/", "/userguide3/");
67 | /* If http:// is used instead of http://www. then the code igniter website
68 | won't open at the specified function.
69 | For example: http://codeigniter.com/userguide3/libraries/table.html?#CI_Table.make_columns
70 | won't open at the location where make_columns is documented. It works if http://www. is used instead though
71 | */
72 | s = s.replaceFirst("http://", "http://www.");
73 | docLink = new URL(s);
74 | }
75 | catch (MalformedURLException mue) {
76 | mue.printStackTrace(System.err);
77 | }
78 |
79 | // Done if the className has already been found, regardless of the success/failure of the URL
80 | done = (className != null);
81 | break;
82 | }
83 | }
84 | }
85 | else if (token.id().equals(PHPTokenId.PHP_CLASS)) {
86 | // Find the first string after the word "class"
87 | while (tokenSeq.moveNext()) {
88 | if (tokenSeq.token().id().equals(PHPTokenId.PHP_STRING)) {
89 | className = tokenSeq.token().text().toString();
90 | done = (docLink != null);
91 | break;
92 | }
93 | }
94 | }
95 | }
96 |
97 | // If a class name couldn't be found, use the file name without the extension
98 | if (className == null) {
99 | int index = file.getName().lastIndexOf(".");
100 | className = file.getName().substring(0, index);
101 | }
102 | retval = new CiClass(className, docLink);
103 | }
104 |
105 | return retval;
106 | }
107 |
108 | /**
109 | * Extracts all public functions from the PHP file
110 | * @param file
111 | * @return ArrayList of CiFunctions
112 | * @throws FileNotFoundException
113 | * @throws IllegalArgumentException
114 | */
115 | public static ArrayList extractFunctions(File file)
116 | throws FileNotFoundException, IllegalArgumentException {
117 |
118 | if (!FileExtractor.isPHPFile(file)) {
119 | throw new IllegalArgumentException(String.format("%s is not a .php file\n", file.getAbsolutePath()));
120 | }
121 |
122 | ArrayList retval = new ArrayList();
123 | TokenSequence tokenSeq = getTokensFromFile(file);
124 |
125 | if (tokenSeq != null) {
126 | while (tokenSeq.moveNext()) {
127 | Token token = tokenSeq.token();
128 |
129 | if (token.id().equals(PHPTokenId.PHP_FUNCTION)) {
130 | // Found a new function
131 | int backCount = 1; // Number of movePrevious() calls
132 | boolean isPublic = true;
133 |
134 | // Walk backwards to see if the function is private or protected
135 | while (tokenSeq.movePrevious()) {
136 | PHPTokenId id = tokenSeq.token().id();
137 |
138 | if (!id.equals(PHPTokenId.WHITESPACE)) {
139 | if (id.equals(PHPTokenId.PHP_PROTECTED) || id.equals(PHPTokenId.PHP_PRIVATE)) {
140 | isPublic = false;
141 | }
142 | break;
143 | }
144 |
145 | backCount++;
146 | }
147 |
148 | // Move the token sequence back to pointing to the "function" keyword
149 | for (int i = 0; i < backCount; i++) {
150 | tokenSeq.moveNext();
151 | }
152 |
153 | if (isPublic) {
154 | String funcName = null;
155 | // Get the function name
156 | while (tokenSeq.moveNext()) {
157 | if (tokenSeq.token().id().equals(PHPTokenId.PHP_STRING)) {
158 | funcName = tokenSeq.token().text().toString();
159 | break;
160 | }
161 | }
162 |
163 | if (funcName != null) {
164 | // Create a string starting after the first "(" and ending before the closing ")"
165 | StringBuilder stringBuilder = new StringBuilder();
166 | // Move tokenSeq to after the first "("
167 | while (tokenSeq.moveNext()) {
168 | if (tokenSeq.token().text().equals("(")) {
169 | break;
170 | }
171 | }
172 |
173 | int count = 1; // Keep a count of unpaired brackets. When at 0 we've found the closing ")"
174 | while (tokenSeq.moveNext()) {
175 | if (tokenSeq.token().text().equals(")")) {
176 | count--;
177 | }
178 | else if (tokenSeq.token().text().equals("(")) {
179 | count++;
180 | }
181 |
182 | if (count == 0) {
183 | break;
184 | }
185 | else {
186 | stringBuilder = stringBuilder.append(tokenSeq.token().text());
187 | }
188 | }
189 |
190 | Vector params = parseParameterString(stringBuilder.toString());
191 | CiFunction func = new CiFunction(funcName, params);
192 |
193 | retval.add(func);
194 | }
195 | }
196 | }
197 | }
198 | }
199 |
200 | return retval;
201 | }
202 |
203 | /**
204 | * Get the token at offset in the given Document
205 | *
206 | * @param doc document
207 | * @param offset offset in document
208 | * @return token
209 | */
210 | public static Token getToken(Document doc, int offset) {
211 | TokenSequence ts = getTokenSequence(doc);
212 | if (ts == null) {
213 | return null;
214 | }
215 | ts.move(offset);
216 | ts.moveNext();
217 |
218 | Token token = ts.token();
219 |
220 | return token;
221 | }
222 |
223 | /**
224 | * Get the TokenSequence for the full document
225 | *
226 | * @param doc document
227 | * @return tokens or null in the event of an error
228 | */
229 | public static TokenSequence getTokenSequence(Document doc) {
230 | AbstractDocument absDoc = (AbstractDocument) doc;
231 | absDoc.readLock();
232 | TokenSequence tokens = null;
233 | try {
234 | TokenHierarchy hierarchy = TokenHierarchy.get(doc);
235 | tokens = hierarchy.tokenSequence(PHPTokenId.language());
236 | } finally {
237 | absDoc.readUnlock();
238 | }
239 | return tokens;
240 | }
241 |
242 | /**
243 | * Gets the TokenSequence from the specified file
244 | *
245 | * @param file
246 | * @return TokenSequence for the file
247 | */
248 | public static TokenSequence getTokensFromFile(File file) throws FileNotFoundException {
249 | TokenSequence retval = null;
250 |
251 | if (!FileExtractor.isPHPFile(file)) {
252 | throw new IllegalArgumentException(
253 | String.format("%s is not a PHP file\n", file.getPath()));
254 | }
255 |
256 | BufferedReader reader = new BufferedReader(new FileReader(file));
257 | TokenHierarchy th = TokenHierarchy.create(reader, PHPTokenId.language(), null, null);
258 | retval = th.tokenSequence();
259 |
260 | try {
261 | reader.close();
262 | }
263 | catch (IOException ioe) {
264 | System.err.println("Unable to close reader in getTokensFromFile()\n");
265 | }
266 |
267 | return retval;
268 | }
269 |
270 | /**
271 | * Extracts the parameters and their default values
272 | * The string should only contain the portion of the function between the parenthesis
273 | * For example, if the code is: public function foo($bar1, $bar2 = "somevalue") {
274 | * then the string should be "$bar1, $bar2 = "somevalue""
275 | * @param str
276 | * @return
277 | */
278 | private static Vector parseParameterString(String str) {
279 | Vector retval = new Vector();
280 | String[] params = str.split(",");
281 |
282 | for (String param : params) {
283 | String[] nameAndDefault = param.split("=");
284 | if (nameAndDefault.length == 1) {
285 | retval.add(new CiParameter(nameAndDefault[0].trim()));
286 | }
287 | else if (nameAndDefault.length == 2) {
288 | retval.add(new CiParameter(nameAndDefault[0].trim(), nameAndDefault[1].trim()));
289 | }
290 | else {
291 | assert(false); // Shouldn't ever have more than 2 items
292 | }
293 | }
294 |
295 | return retval;
296 | }
297 | }
298 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/ciDoc.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/shared/ciDoc.ser
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/shared/readme.txt:
--------------------------------------------------------------------------------
1 | This package contains any shared classes / functions
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/Bundle.properties:
--------------------------------------------------------------------------------
1 | LBL_CreateProjectStep=Name and Location
2 | CI3_Basic_StarterPanelVisual.projectNameLabel.text=Project &Name:
3 | CI3_Basic_StarterPanelVisual.createdFolderLabel.text=Project &Folder:
4 | CI3_Basic_StarterPanelVisual.browseButton.actionCommand=BROWSE
5 | CI3_Basic_StarterPanelVisual.browseButton.text=Br&owse...
6 | CI3_Basic_StarterPanelVisual.projectLocationLabel.text=Project &Location:
7 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_Starter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_Starter.png
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterDescription.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 | This is a basic template for a CodeIgniter3 web application.
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterPanelVisual.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
123 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterPanelVisual.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.starter.BasicStarter;
7 |
8 | import java.io.File;
9 | import javax.swing.JFileChooser;
10 | import javax.swing.JPanel;
11 | import javax.swing.event.DocumentEvent;
12 | import javax.swing.event.DocumentListener;
13 | import javax.swing.text.Document;
14 | import org.netbeans.spi.project.ui.support.ProjectChooser;
15 | import org.openide.WizardDescriptor;
16 | import org.openide.WizardValidationException;
17 | import org.openide.filesystems.FileUtil;
18 |
19 | public class CI3_Basic_StarterPanelVisual extends JPanel implements DocumentListener {
20 |
21 | public static final String PROP_PROJECT_NAME = "projectName";
22 |
23 | private CI3_Basic_StarterWizardPanel panel;
24 |
25 | public CI3_Basic_StarterPanelVisual(CI3_Basic_StarterWizardPanel panel) {
26 | initComponents();
27 | this.panel = panel;
28 | // Register listener on the textFields to make the automatic updates
29 | projectNameTextField.getDocument().addDocumentListener(this);
30 | projectLocationTextField.getDocument().addDocumentListener(this);
31 | }
32 |
33 | public String getProjectName() {
34 | return this.projectNameTextField.getText();
35 | }
36 |
37 | /**
38 | * This method is called from within the constructor to initialize the form.
39 | * WARNING: Do NOT modify this code. The content of this method is always
40 | * regenerated by the Form Editor.
41 | */
42 | // //GEN-BEGIN:initComponents
43 | private void initComponents() {
44 |
45 | projectNameLabel = new javax.swing.JLabel();
46 | projectNameTextField = new javax.swing.JTextField();
47 | projectLocationLabel = new javax.swing.JLabel();
48 | projectLocationTextField = new javax.swing.JTextField();
49 | browseButton = new javax.swing.JButton();
50 | createdFolderLabel = new javax.swing.JLabel();
51 | createdFolderTextField = new javax.swing.JTextField();
52 |
53 | projectNameLabel.setLabelFor(projectNameTextField);
54 | org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, org.openide.util.NbBundle.getMessage(CI3_Basic_StarterPanelVisual.class, "CI3_Basic_StarterPanelVisual.projectNameLabel.text")); // NOI18N
55 |
56 | projectLocationLabel.setLabelFor(projectLocationTextField);
57 | org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(CI3_Basic_StarterPanelVisual.class, "CI3_Basic_StarterPanelVisual.projectLocationLabel.text")); // NOI18N
58 |
59 | org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(CI3_Basic_StarterPanelVisual.class, "CI3_Basic_StarterPanelVisual.browseButton.text")); // NOI18N
60 | browseButton.setActionCommand(org.openide.util.NbBundle.getMessage(CI3_Basic_StarterPanelVisual.class, "CI3_Basic_StarterPanelVisual.browseButton.actionCommand")); // NOI18N
61 | browseButton.addActionListener(new java.awt.event.ActionListener() {
62 | public void actionPerformed(java.awt.event.ActionEvent evt) {
63 | browseButtonActionPerformed(evt);
64 | }
65 | });
66 |
67 | createdFolderLabel.setLabelFor(createdFolderTextField);
68 | org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, org.openide.util.NbBundle.getMessage(CI3_Basic_StarterPanelVisual.class, "CI3_Basic_StarterPanelVisual.createdFolderLabel.text")); // NOI18N
69 |
70 | createdFolderTextField.setEditable(false);
71 |
72 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
73 | this.setLayout(layout);
74 | layout.setHorizontalGroup(
75 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
76 | .addGroup(layout.createSequentialGroup()
77 | .addContainerGap()
78 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
79 | .addComponent(projectNameLabel)
80 | .addComponent(projectLocationLabel)
81 | .addComponent(createdFolderLabel))
82 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
83 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
84 | .addComponent(projectNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
85 | .addComponent(projectLocationTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
86 | .addComponent(createdFolderTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
87 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
88 | .addComponent(browseButton)
89 | .addContainerGap())
90 | );
91 | layout.setVerticalGroup(
92 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93 | .addGroup(layout.createSequentialGroup()
94 | .addContainerGap()
95 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
96 | .addComponent(projectNameLabel)
97 | .addComponent(projectNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
98 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
99 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
100 | .addComponent(projectLocationLabel)
101 | .addComponent(projectLocationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
102 | .addComponent(browseButton))
103 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
104 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
105 | .addComponent(createdFolderLabel)
106 | .addComponent(createdFolderTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
107 | .addContainerGap(213, Short.MAX_VALUE))
108 | );
109 | }// //GEN-END:initComponents
110 |
111 | private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
112 | String command = evt.getActionCommand();
113 | if ("BROWSE".equals(command)) {
114 | JFileChooser chooser = new JFileChooser();
115 | FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
116 | chooser.setDialogTitle("Select Project Location");
117 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
118 | String path = this.projectLocationTextField.getText();
119 | if (path.length() > 0) {
120 | File f = new File(path);
121 | if (f.exists()) {
122 | chooser.setSelectedFile(f);
123 | }
124 | }
125 | if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
126 | File projectDir = chooser.getSelectedFile();
127 | projectLocationTextField.setText(FileUtil.normalizeFile(projectDir).getAbsolutePath());
128 | }
129 | panel.fireChangeEvent();
130 | }
131 |
132 | }//GEN-LAST:event_browseButtonActionPerformed
133 |
134 | // Variables declaration - do not modify//GEN-BEGIN:variables
135 | private javax.swing.JButton browseButton;
136 | private javax.swing.JLabel createdFolderLabel;
137 | private javax.swing.JTextField createdFolderTextField;
138 | private javax.swing.JLabel projectLocationLabel;
139 | private javax.swing.JTextField projectLocationTextField;
140 | private javax.swing.JLabel projectNameLabel;
141 | private javax.swing.JTextField projectNameTextField;
142 | // End of variables declaration//GEN-END:variables
143 |
144 | @Override
145 | public void addNotify() {
146 | super.addNotify();
147 | //same problem as in 31086, initial focus on Cancel button
148 | projectNameTextField.requestFocus();
149 | }
150 |
151 | boolean valid(WizardDescriptor wizardDescriptor) {
152 |
153 | if (projectNameTextField.getText().length() == 0) {
154 | // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_ERROR_MESSAGE:
155 | wizardDescriptor.putProperty("WizardPanel_errorMessage",
156 | "Project Name is not a valid folder name.");
157 | return false; // Display name not specified
158 | }
159 | File f = FileUtil.normalizeFile(new File(projectLocationTextField.getText()).getAbsoluteFile());
160 | if (!f.isDirectory()) {
161 | String message = "Project Folder is not a valid path.";
162 | wizardDescriptor.putProperty("WizardPanel_errorMessage", message);
163 | return false;
164 | }
165 | final File destFolder = FileUtil.normalizeFile(new File(createdFolderTextField.getText()).getAbsoluteFile());
166 |
167 | File projLoc = destFolder;
168 | while (projLoc != null && !projLoc.exists()) {
169 | projLoc = projLoc.getParentFile();
170 | }
171 | if (projLoc == null || !projLoc.canWrite()) {
172 | wizardDescriptor.putProperty("WizardPanel_errorMessage",
173 | "Project Folder cannot be created.");
174 | return false;
175 | }
176 |
177 | if (FileUtil.toFileObject(projLoc) == null) {
178 | String message = "Project Folder is not a valid path.";
179 | wizardDescriptor.putProperty("WizardPanel_errorMessage", message);
180 | return false;
181 | }
182 |
183 | File[] kids = destFolder.listFiles();
184 | if (destFolder.exists() && kids != null && kids.length > 0) {
185 | // Folder exists and is not empty
186 | wizardDescriptor.putProperty("WizardPanel_errorMessage",
187 | "Project Folder already exists and is not empty.");
188 | return false;
189 | }
190 | wizardDescriptor.putProperty("WizardPanel_errorMessage", "");
191 | return true;
192 | }
193 |
194 | void store(WizardDescriptor d) {
195 | String name = projectNameTextField.getText().trim();
196 | String folder = createdFolderTextField.getText().trim();
197 |
198 | d.putProperty("projdir", new File(folder));
199 | d.putProperty("name", name);
200 | }
201 |
202 | void read(WizardDescriptor settings) {
203 | File projectLocation = (File) settings.getProperty("projdir");
204 | if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory()) {
205 | projectLocation = ProjectChooser.getProjectsFolder();
206 | } else {
207 | projectLocation = projectLocation.getParentFile();
208 | }
209 | this.projectLocationTextField.setText(projectLocation.getAbsolutePath());
210 |
211 | String projectName = (String) settings.getProperty("name");
212 | if (projectName == null) {
213 | projectName = "CI3_Basic_Starter";
214 | }
215 | this.projectNameTextField.setText(projectName);
216 | this.projectNameTextField.selectAll();
217 | }
218 |
219 | void validate(WizardDescriptor d) throws WizardValidationException {
220 | // nothing to validate
221 | }
222 |
223 | // Implementation of DocumentListener --------------------------------------
224 | public void changedUpdate(DocumentEvent e) {
225 | updateTexts(e);
226 | if (this.projectNameTextField.getDocument() == e.getDocument()) {
227 | firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
228 | }
229 | }
230 |
231 | public void insertUpdate(DocumentEvent e) {
232 | updateTexts(e);
233 | if (this.projectNameTextField.getDocument() == e.getDocument()) {
234 | firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
235 | }
236 | }
237 |
238 | public void removeUpdate(DocumentEvent e) {
239 | updateTexts(e);
240 | if (this.projectNameTextField.getDocument() == e.getDocument()) {
241 | firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
242 | }
243 | }
244 |
245 | /**
246 | * Handles changes in the Project name and project directory,
247 | */
248 | private void updateTexts(DocumentEvent e) {
249 |
250 | Document doc = e.getDocument();
251 |
252 | if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
253 | // Change in the project name
254 |
255 | String projectName = projectNameTextField.getText();
256 | String projectFolder = projectLocationTextField.getText();
257 |
258 | //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) {
259 | createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
260 | //}
261 |
262 | }
263 | panel.fireChangeEvent(); // Notify that the panel changed
264 | }
265 |
266 | }
267 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterProject.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bcit-ci/netbeans-plugin/8ba6083eba4e12d6b0eecd68ff64df2b50045cf7/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterProject.zip
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterWizardIterator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.starter.BasicStarter;
7 |
8 | import java.awt.Component;
9 | import java.io.ByteArrayInputStream;
10 | import java.io.ByteArrayOutputStream;
11 | import java.io.File;
12 | import java.io.IOException;
13 | import java.io.InputStream;
14 | import java.io.OutputStream;
15 | import java.text.MessageFormat;
16 | import java.util.Enumeration;
17 | import java.util.LinkedHashSet;
18 | import java.util.NoSuchElementException;
19 | import java.util.Set;
20 | import java.util.zip.ZipEntry;
21 | import java.util.zip.ZipInputStream;
22 | import javax.swing.JComponent;
23 | import javax.swing.event.ChangeListener;
24 | import org.netbeans.api.project.ProjectManager;
25 | import org.netbeans.api.templates.TemplateRegistration;
26 | import org.netbeans.spi.project.ui.support.ProjectChooser;
27 | import org.netbeans.spi.project.ui.templates.support.Templates;
28 | import org.openide.WizardDescriptor;
29 | import org.openide.filesystems.FileObject;
30 | import org.openide.filesystems.FileUtil;
31 | import org.openide.util.Exceptions;
32 | import org.openide.util.NbBundle;
33 | import org.openide.util.NbBundle.Messages;
34 | import org.openide.xml.XMLUtil;
35 | import org.w3c.dom.Document;
36 | import org.w3c.dom.Element;
37 | import org.w3c.dom.NodeList;
38 | import org.xml.sax.InputSource;
39 |
40 | // TODO define position attribute
41 | @TemplateRegistration(folder = "Project/Samples/CodeIgniter", displayName = "#CI3_Basic_Starter_displayName", description = "CI3_Basic_StarterDescription.html", iconBase = "com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_Starter.png", content = "CI3_Basic_StarterProject.zip")
42 | @Messages("CI3_Basic_Starter_displayName=CodeIgniter3 Basic Starter")
43 | public class CI3_Basic_StarterWizardIterator implements WizardDescriptor./*Progress*/InstantiatingIterator {
44 |
45 | private int index;
46 | private WizardDescriptor.Panel[] panels;
47 | private WizardDescriptor wiz;
48 |
49 | public CI3_Basic_StarterWizardIterator() {
50 | }
51 |
52 | public static CI3_Basic_StarterWizardIterator createIterator() {
53 | return new CI3_Basic_StarterWizardIterator();
54 | }
55 |
56 | private WizardDescriptor.Panel[] createPanels() {
57 | return new WizardDescriptor.Panel[]{
58 | new CI3_Basic_StarterWizardPanel(),};
59 | }
60 |
61 | private String[] createSteps() {
62 | return new String[]{
63 | NbBundle.getMessage(CI3_Basic_StarterWizardIterator.class, "LBL_CreateProjectStep")
64 | };
65 | }
66 |
67 | public Set/**/ instantiate(/*ProgressHandle handle*/) throws IOException {
68 | Set resultSet = new LinkedHashSet();
69 | File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
70 | dirF.mkdirs();
71 |
72 | FileObject template = Templates.getTemplate(wiz);
73 | FileObject dir = FileUtil.toFileObject(dirF);
74 | unZipFile(template.getInputStream(), dir);
75 |
76 | // Always open top dir as a project:
77 | resultSet.add(dir);
78 | // Look for nested projects to open as well:
79 | Enumeration extends FileObject> e = dir.getFolders(true);
80 | while (e.hasMoreElements()) {
81 | FileObject subfolder = e.nextElement();
82 | if (ProjectManager.getDefault().isProject(subfolder)) {
83 | resultSet.add(subfolder);
84 | }
85 | }
86 |
87 | File parent = dirF.getParentFile();
88 | if (parent != null && parent.exists()) {
89 | ProjectChooser.setProjectsFolder(parent);
90 | }
91 |
92 | return resultSet;
93 | }
94 |
95 | public void initialize(WizardDescriptor wiz) {
96 | this.wiz = wiz;
97 | index = 0;
98 | panels = createPanels();
99 | // Make sure list of steps is accurate.
100 | String[] steps = createSteps();
101 | for (int i = 0; i < panels.length; i++) {
102 | Component c = panels[i].getComponent();
103 | if (steps[i] == null) {
104 | // Default step name to component name of panel.
105 | // Mainly useful for getting the name of the target
106 | // chooser to appear in the list of steps.
107 | steps[i] = c.getName();
108 | }
109 | if (c instanceof JComponent) { // assume Swing components
110 | JComponent jc = (JComponent) c;
111 | // Step #.
112 | // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
113 | jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
114 | // Step name (actually the whole list for reference).
115 | jc.putClientProperty("WizardPanel_contentData", steps);
116 | }
117 | }
118 | }
119 |
120 | public void uninitialize(WizardDescriptor wiz) {
121 | this.wiz.putProperty("projdir", null);
122 | this.wiz.putProperty("name", null);
123 | this.wiz = null;
124 | panels = null;
125 | }
126 |
127 | public String name() {
128 | return MessageFormat.format("{0} of {1}",
129 | new Object[]{new Integer(index + 1), new Integer(panels.length)});
130 | }
131 |
132 | public boolean hasNext() {
133 | return index < panels.length - 1;
134 | }
135 |
136 | public boolean hasPrevious() {
137 | return index > 0;
138 | }
139 |
140 | public void nextPanel() {
141 | if (!hasNext()) {
142 | throw new NoSuchElementException();
143 | }
144 | index++;
145 | }
146 |
147 | public void previousPanel() {
148 | if (!hasPrevious()) {
149 | throw new NoSuchElementException();
150 | }
151 | index--;
152 | }
153 |
154 | public WizardDescriptor.Panel current() {
155 | return panels[index];
156 | }
157 |
158 | // If nothing unusual changes in the middle of the wizard, simply:
159 | public final void addChangeListener(ChangeListener l) {
160 | }
161 |
162 | public final void removeChangeListener(ChangeListener l) {
163 | }
164 |
165 | private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
166 | try {
167 | ZipInputStream str = new ZipInputStream(source);
168 | ZipEntry entry;
169 | while ((entry = str.getNextEntry()) != null) {
170 | if (entry.isDirectory()) {
171 | FileUtil.createFolder(projectRoot, entry.getName());
172 | } else {
173 | FileObject fo = FileUtil.createData(projectRoot, entry.getName());
174 | if ("nbproject/project.xml".equals(entry.getName())) {
175 | // Special handling for setting name of Ant-based projects; customize as needed:
176 | filterProjectXML(fo, str, projectRoot.getName());
177 | } else {
178 | writeFile(str, fo);
179 | }
180 | }
181 | }
182 | } finally {
183 | source.close();
184 | }
185 | }
186 |
187 | private static void writeFile(ZipInputStream str, FileObject fo) throws IOException {
188 | OutputStream out = fo.getOutputStream();
189 | try {
190 | FileUtil.copy(str, out);
191 | } finally {
192 | out.close();
193 | }
194 | }
195 |
196 | private static void filterProjectXML(FileObject fo, ZipInputStream str, String name) throws IOException {
197 | try {
198 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
199 | FileUtil.copy(str, baos);
200 | Document doc = XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())), false, false, null, null);
201 | NodeList nl = doc.getDocumentElement().getElementsByTagName("name");
202 | if (nl != null) {
203 | for (int i = 0; i < nl.getLength(); i++) {
204 | Element el = (Element) nl.item(i);
205 | if (el.getParentNode() != null && "data".equals(el.getParentNode().getNodeName())) {
206 | NodeList nl2 = el.getChildNodes();
207 | if (nl2.getLength() > 0) {
208 | nl2.item(0).setNodeValue(name);
209 | }
210 | break;
211 | }
212 | }
213 | }
214 | OutputStream out = fo.getOutputStream();
215 | try {
216 | XMLUtil.write(doc, out, "UTF-8");
217 | } finally {
218 | out.close();
219 | }
220 | } catch (Exception ex) {
221 | Exceptions.printStackTrace(ex);
222 | writeFile(str, fo);
223 | }
224 |
225 | }
226 |
227 | }
228 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/BasicStarter/CI3_Basic_StarterWizardPanel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.codeigniter.netbeans.starter.BasicStarter;
7 |
8 | import java.awt.Component;
9 | import java.util.HashSet;
10 | import java.util.Set;
11 | import javax.swing.event.ChangeEvent;
12 | import javax.swing.event.ChangeListener;
13 | import org.openide.WizardDescriptor;
14 | import org.openide.WizardValidationException;
15 | import org.openide.util.HelpCtx;
16 | import org.openide.util.NbBundle;
17 |
18 | /**
19 | * Panel just asking for basic info.
20 | */
21 | public class CI3_Basic_StarterWizardPanel implements WizardDescriptor.Panel,
22 | WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel {
23 |
24 | private WizardDescriptor wizardDescriptor;
25 | private CI3_Basic_StarterPanelVisual component;
26 |
27 | public CI3_Basic_StarterWizardPanel() {
28 | }
29 |
30 | public Component getComponent() {
31 | if (component == null) {
32 | component = new CI3_Basic_StarterPanelVisual(this);
33 | component.setName(NbBundle.getMessage(CI3_Basic_StarterWizardPanel.class, "LBL_CreateProjectStep"));
34 | }
35 | return component;
36 | }
37 |
38 | public HelpCtx getHelp() {
39 | return new HelpCtx(CI3_Basic_StarterWizardPanel.class);
40 | }
41 |
42 | public boolean isValid() {
43 | getComponent();
44 | return component.valid(wizardDescriptor);
45 | }
46 |
47 | private final Set listeners = new HashSet(1); // or can use ChangeSupport in NB 6.0
48 |
49 | public final void addChangeListener(ChangeListener l) {
50 | synchronized (listeners) {
51 | listeners.add(l);
52 | }
53 | }
54 |
55 | public final void removeChangeListener(ChangeListener l) {
56 | synchronized (listeners) {
57 | listeners.remove(l);
58 | }
59 | }
60 |
61 | protected final void fireChangeEvent() {
62 | Set ls;
63 | synchronized (listeners) {
64 | ls = new HashSet(listeners);
65 | }
66 | ChangeEvent ev = new ChangeEvent(this);
67 | for (ChangeListener l : ls) {
68 | l.stateChanged(ev);
69 | }
70 | }
71 |
72 | public void readSettings(Object settings) {
73 | wizardDescriptor = (WizardDescriptor) settings;
74 | component.read(wizardDescriptor);
75 | }
76 |
77 | public void storeSettings(Object settings) {
78 | WizardDescriptor d = (WizardDescriptor) settings;
79 | component.store(d);
80 | }
81 |
82 | public boolean isFinishPanel() {
83 | return true;
84 | }
85 |
86 | public void validate() throws WizardValidationException {
87 | getComponent();
88 | component.validate(wizardDescriptor);
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/com/codeigniter/netbeans/starter/readme.txt:
--------------------------------------------------------------------------------
1 | This folder is meant to hold starter apps code (David)
--------------------------------------------------------------------------------