Skip to content

Commit ec3f7d9

Browse files
committed
Merge branch 'nb74dev'
2 parents 2846a93 + 30b7fa4 commit ec3f7d9

26 files changed

Lines changed: 1797 additions & 41 deletions

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ This is NetBeans plugin for WordPress.
1515
- display and change debug status
1616
- code completion for filter and action
1717
- create new theme action
18-
- hyperlink navigate
18+
- hyperlink navigation
1919
- create new plugin action
2020
- custom content name
2121
- run command (wp-cli)
22+
- upgrade notification
2223

2324
### Impotant Files
2425
It contains wp-config.php
@@ -71,6 +72,7 @@ add_filter('the_content', 'w[Ctrl + Space]'); // e.g. start with 'w'
7172
### Display And Change Debug Status
7273
WP_DEBUG value(wp-config.php) is displayed on bottome-right of IDE.
7374
If you click there, you can change WP_DEBUG value.
75+
WordPress version number is also displayed.
7476

7577
### Create New Theme Action
7678
Right-click Project > WordPress > Create Theme
@@ -116,5 +118,31 @@ Please see the followings:
116118
- https://github.com/wp-cli/wp-cli
117119
- http://wp-cli.org/
118120

121+
### Upgrade Notification
122+
123+
Check whether new versions (for core, plugin and theme) are available when WordPress project is opened.
124+
Furthermore, we can upgrade(run core update, core update-db, e.t.c.) WordPress with notification window if we are setting wp-cli.
125+
126+
If you don't want to check that, please uncheck `Check new version when project is opened` at Options.
127+
128+
## Version Number
129+
130+
| |stable |dev |
131+
|:------|:-----:|:-------:|
132+
|pattern| n.n.n | n.n.n.n |
133+
|e.g. | 1.0.1 | 1.0.1.2 |
134+
135+
### Stable version
136+
137+
Available on [Plugin Portal](http://plugins.netbeans.org/plugin/46542/php-wordpress-blog-cms).
138+
139+
### Development version
140+
141+
If development version exists, it will be available in the same archive as stable version.
142+
143+
### Archive
144+
145+
[github releases](https://github.com/junichi11/netbeans-wordpress-plugin/releases)
146+
119147
## License
120148
[Common Development and Distribution License (CDDL) v1.0 and GNU General Public License (GPL) v2](http://netbeans.org/cddl-gplv2.html)

manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Manifest-Version: 1.0
22
OpenIDE-Module: org.netbeans.modules.php.wordpress
33
OpenIDE-Module-Layer: org/netbeans/modules/php/wordpress/resources/layer.xml
44
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/wordpress/Bundle.properties
5-
OpenIDE-Module-Specification-Version: 0.6.2
5+
OpenIDE-Module-Specification-Version: 0.6.3
66
OpenIDE-Module-Install: org/netbeans/modules/php/wordpress/WordPressModule.class

nbproject/genfiles.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
build.xml.data.CRC32=f6605689
1+
build.xml.data.CRC32=afe7c087
22
build.xml.script.CRC32=f6cbff90
33
build.xml.stylesheet.CRC32=a56c6a5b@2.62.1
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# 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=f6605689
6+
nbproject/build-impl.xml.data.CRC32=afe7c087
77
nbproject/build-impl.xml.script.CRC32=bfa38a5f
88
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.62.1

nbproject/project.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<code-name-base>org.netbeans.modules.php.wordpress</code-name-base>
77
<standalone/>
88
<module-dependencies>
9+
<dependency>
10+
<code-name-base>org.netbeans.api.annotations.common</code-name-base>
11+
<build-prerequisite/>
12+
<compile-dependency/>
13+
<run-dependency>
14+
<release-version>1</release-version>
15+
<specification-version>1.21.1</specification-version>
16+
</run-dependency>
17+
</dependency>
918
<dependency>
1019
<code-name-base>org.netbeans.api.progress</code-name-base>
1120
<build-prerequisite/>
@@ -15,6 +24,15 @@
1524
<specification-version>1.32.1</specification-version>
1625
</run-dependency>
1726
</dependency>
27+
<dependency>
28+
<code-name-base>org.netbeans.libs.json_simple</code-name-base>
29+
<build-prerequisite/>
30+
<compile-dependency/>
31+
<run-dependency>
32+
<release-version>1</release-version>
33+
<specification-version>0.6.1</specification-version>
34+
</run-dependency>
35+
</dependency>
1836
<dependency>
1937
<code-name-base>org.netbeans.modules.csl.api</code-name-base>
2038
<build-prerequisite/>

src/org/netbeans/modules/php/wordpress/WordPressActionsExtender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.netbeans.modules.php.spi.framework.PhpModuleActionsExtender;
4949
import org.netbeans.modules.php.spi.framework.actions.RunCommandAction;
5050
import org.netbeans.modules.php.wordpress.commands.WordPressCli;
51-
import org.netbeans.modules.php.wordpress.ui.actions.CodeCompletionRefreshAction;
51+
import org.netbeans.modules.php.wordpress.ui.actions.RefreshCodeCompletionAction;
5252
import org.netbeans.modules.php.wordpress.ui.actions.CreatePluginAction;
5353
import org.netbeans.modules.php.wordpress.ui.actions.CreateThemeAction;
5454
import org.netbeans.modules.php.wordpress.ui.actions.WordPressRunCommandAction;
@@ -86,7 +86,7 @@ public List<? extends Action> getActions() {
8686
List<Action> actions = new ArrayList<Action>();
8787
actions.add(CreateThemeAction.getInstance());
8888
actions.add(CreatePluginAction.getInstance());
89-
actions.add(new CodeCompletionRefreshAction());
89+
actions.add(new RefreshCodeCompletionAction());
9090
return actions;
9191
}
9292
}

src/org/netbeans/modules/php/wordpress/WordPressPhpModuleExtender.java

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
*/
4242
package org.netbeans.modules.php.wordpress;
4343

44-
import java.awt.Component;
4544
import java.io.BufferedReader;
4645
import java.io.IOException;
4746
import java.io.InputStreamReader;
@@ -83,10 +82,12 @@
8382
import org.netbeans.modules.php.wordpress.util.NetUtils;
8483
import org.netbeans.modules.php.wordpress.util.WPFileUtils;
8584
import org.netbeans.modules.php.wordpress.util.WPZipEntryFilter;
85+
import org.netbeans.modules.php.wordpress.wpapis.WordPressVersionCheckApi;
8686
import org.openide.filesystems.FileObject;
8787
import org.openide.filesystems.FileUtil;
8888
import org.openide.util.Exceptions;
8989
import org.openide.util.HelpCtx;
90+
import org.openide.util.NbBundle;
9091

9192
/**
9293
*
@@ -112,6 +113,7 @@ public class WordPressPhpModuleExtender extends PhpModuleExtender {
112113
private static final Set<String> CONFIG_KEYS = new HashSet<String>();
113114
private static final Map<String, String> CONFIG_MAP = new HashMap<String, String>();
114115
private boolean isInternetReachable = true;
116+
private String errorMessage;
115117
private static final Logger LOGGER = Logger.getLogger(WordPressPhpModuleExtender.class.getName());
116118

117119
static {
@@ -150,31 +152,32 @@ public HelpCtx getHelp() {
150152
return null;
151153
}
152154

155+
@NbBundle.Messages("WordPressPhpModuleExtender.no.installation=There is no available installation method.")
153156
@Override
154157
public boolean isValid() {
155158
String url = panel.getUrlLabel();
156159
String localFile = panel.getLocalFileLabel();
157160
if (!isInternetReachable || url.isEmpty()) {
158161
if (localFile.isEmpty()) {
159-
Component[] components = panel.getComponents();
160-
for (Component component : components) {
161-
component.setEnabled(false);
162-
}
162+
// disable all field
163+
panel.setAllEnabled(panel, false);
164+
panel.setAllEnabled(panel.getWpConfigPanel(), false);
165+
errorMessage = Bundle.WordPressPhpModuleExtender_no_installation();
163166
return false;
164-
165167
}
166168
}
169+
errorMessage = null;
167170
return true;
168171
}
169172

170173
@Override
171174
public String getErrorMessage() {
172-
return null;
175+
return errorMessage;
173176
}
174177

175178
@Override
176179
public String getWarningMessage() {
177-
return null;
180+
return errorMessage;
178181
}
179182

180183
/**
@@ -282,27 +285,31 @@ public Set<FileObject> extend(PhpModule pm) throws ExtendingException {
282285
*/
283286
private String getDownloadUrl() {
284287
String downloadUrl = WordPressOptions.getInstance().getDownloadUrl();
285-
if (downloadUrl != null && !downloadUrl.isEmpty()) {
288+
if (!StringUtils.isEmpty(downloadUrl)) {
286289
return downloadUrl;
287290
}
288-
Locale locale = Locale.getDefault();
289-
String language = locale.getLanguage();
290-
String urlPath = WP_DL_URL_DEFAULT;
291-
if (language != null && !language.isEmpty()) {
292-
if (!language.equals("en")) { // NOI18N
293-
urlPath = String.format(WP_DL_URL_FORMAT, language, language);
291+
292+
// get url from version check api
293+
String wpLocale = WordPressOptions.getInstance().getWpLocale();
294+
if (StringUtils.isEmpty(wpLocale)) {
295+
Locale locale = Locale.getDefault();
296+
wpLocale = locale.getLanguage();
297+
}
298+
if (!StringUtils.isEmpty(wpLocale)) {
299+
WordPressVersionCheckApi versionCheckApi = new WordPressVersionCheckApi(wpLocale);
300+
try {
301+
versionCheckApi.parse();
302+
downloadUrl = versionCheckApi.getDownload();
303+
} catch (IOException ex) {
304+
downloadUrl = WP_DL_URL_DEFAULT;
294305
}
295306
}
296-
try {
297-
URL check = new URL(urlPath);
298-
URLConnection connection = check.openConnection();
299-
connection.connect();
300-
} catch (MalformedURLException ex) {
301-
Exceptions.printStackTrace(ex);
302-
} catch (IOException ex) {
303-
urlPath = WP_DL_URL_DEFAULT;
307+
if (!StringUtils.isEmpty(downloadUrl)) {
308+
return downloadUrl;
304309
}
305-
return urlPath;
310+
311+
// default url
312+
return WP_DL_URL_DEFAULT;
306313
}
307314

308315
private void createWpConfig(FileObject sample) {
@@ -379,7 +386,7 @@ private List<String> getSecretKey() {
379386
HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
380387
BufferedReader reader = new BufferedReader(new InputStreamReader(httpsConnection.getInputStream(), Charset.UTF8)); // NOI18N
381388
try {
382-
String line = null;
389+
String line;
383390
while ((line = reader.readLine()) != null) {
384391
keys.add(line);
385392
}

src/org/netbeans/modules/php/wordpress/WordPressPhpProvider.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
*/
4242
package org.netbeans.modules.php.wordpress;
4343

44+
import org.netbeans.modules.php.wordpress.update.WordPressUpgradeChecker;
4445
import java.io.File;
46+
import java.util.Collection;
4547
import java.util.HashSet;
4648
import java.util.LinkedList;
4749
import java.util.List;
@@ -63,6 +65,7 @@
6365
import org.openide.filesystems.FileObject;
6466
import org.openide.filesystems.FileUtil;
6567
import org.openide.util.ImageUtilities;
68+
import org.openide.util.Lookup;
6669
import org.openide.util.NbBundle;
6770

6871
/**
@@ -173,4 +176,16 @@ public PhpModuleCustomizerExtender createPhpModuleCustomizerExtender(PhpModule p
173176
public EditorExtender getEditorExtender(PhpModule pm) {
174177
return new WordPressEditorExtender();
175178
}
179+
180+
@Override
181+
public void phpModuleOpened(PhpModule phpModule) {
182+
// check new version
183+
Collection<? extends WordPressUpgradeChecker> checkers = Lookup.getDefault().lookupAll(WordPressUpgradeChecker.class);
184+
for (WordPressUpgradeChecker checker : checkers) {
185+
if (checker.hasUpgrade(phpModule)) {
186+
checker.notifyUpgrade(phpModule);
187+
}
188+
}
189+
}
190+
176191
}

0 commit comments

Comments
 (0)