Skip to content

Commit d593226

Browse files
committed
Merge branch 'nb80dev'
2 parents 7b9aeee + 2f2c968 commit d593226

5 files changed

Lines changed: 71 additions & 21 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ WordPress version number is also displayed.
8484
### Create New Theme Action
8585
Right-click Project > WordPress > Create Theme
8686

87-
### Create New Child Theme Action
88-
Right-click Project > WordPress > Create Child Theme
89-
90-
- Create a new directory for child theme
91-
- Add style.css for child theme
92-
9387
#### Underscores
9488
Create theme from [Underscores | A Starter Theme for WordPress](http://underscores.me/). Underscores is awesome!
9589
This plugin uses [Automattic/_s · GitHub](https://github.com/automattic/_s).
@@ -99,6 +93,12 @@ This plugin uses [Automattic/_s · GitHub](https://github.com/automattic/_s).
9993
#### Barebones
10094
Create theme form [welcomebrand/Barebones · GitHub](https://github.com/welcomebrand/Barebones).
10195

96+
### Create New Child Theme Action
97+
Right-click Project > WordPress > Create Child Theme
98+
99+
- Create a new directory for child theme
100+
- Add style.css for child theme
101+
102102
### Create New Plugin Action
103103
Right-click Project > WordPress > Create Plugin
104104

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.7.2
5+
OpenIDE-Module-Specification-Version: 0.7.3
66
OpenIDE-Module-Install: org/netbeans/modules/php/wordpress/WordPressModuleInstall.class

src/org/netbeans/modules/php/wordpress/ui/actions/ZipAction.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@
4444
import java.awt.event.ActionEvent;
4545
import java.awt.event.ActionListener;
4646
import java.io.IOException;
47+
import java.util.logging.Level;
48+
import java.util.logging.Logger;
4749
import org.netbeans.modules.php.wordpress.WordPress;
4850
import org.netbeans.modules.php.wordpress.util.WPFileUtils;
51+
import org.openide.DialogDisplayer;
52+
import org.openide.NotifyDescriptor;
4953
import org.openide.awt.ActionID;
5054
import org.openide.awt.ActionReference;
5155
import org.openide.awt.ActionReferences;
5256
import org.openide.awt.ActionRegistration;
5357
import org.openide.filesystems.FileObject;
5458
import org.openide.loaders.DataObject;
55-
import org.openide.util.Exceptions;
5659
import org.openide.util.NbBundle.Messages;
5760

5861
@ActionID(
@@ -69,11 +72,16 @@
6972
public final class ZipAction implements ActionListener {
7073

7174
private final DataObject context;
75+
private static final Logger LOGGER = Logger.getLogger(ZipAction.class.getName());
7276

7377
public ZipAction(DataObject context) {
7478
this.context = context;
7579
}
7680

81+
@Messages({
82+
"# {0} - file name",
83+
"ZipAction.error.file.already.exist=Zip file ({0}) already exists."
84+
})
7785
@Override
7886
public void actionPerformed(ActionEvent ev) {
7987
if (!isValidDirectory()) {
@@ -85,7 +93,9 @@ public void actionPerformed(ActionEvent ev) {
8593
try {
8694
WPFileUtils.zip(target);
8795
} catch (IOException ex) {
88-
Exceptions.printStackTrace(ex);
96+
// #36
97+
LOGGER.log(Level.WARNING, ex.getMessage());
98+
showErrorDialog(Bundle.ZipAction_error_file_already_exist(target.getName() + ".zip")); // NOI18N
8999
}
90100
}
91101

@@ -110,9 +120,26 @@ private boolean isValidDirectory() {
110120
String name = parent.getNameExt();
111121
if (parent.isFolder()) {
112122
if (name.equals("plugins") || name.equals("themes")) { // NOI18N
123+
// #36
124+
String zipFileName = target.getName() + ".zip"; // NOI18N
125+
FileObject zipFile = parent.getFileObject(zipFileName);
126+
if (zipFile != null) {
127+
showErrorDialog(Bundle.ZipAction_error_file_already_exist(zipFileName));
128+
return false;
129+
}
113130
return true;
114131
}
115132
}
116133
return false;
117134
}
135+
136+
/**
137+
* Show error message dialog.
138+
*
139+
* @param errorMessage Error message
140+
*/
141+
private void showErrorDialog(String errorMessage) {
142+
NotifyDescriptor.Message message = new NotifyDescriptor.Message(errorMessage, NotifyDescriptor.ERROR_MESSAGE);
143+
DialogDisplayer.getDefault().notify(message);
144+
}
118145
}

src/org/netbeans/modules/php/wordpress/ui/status/DebugStatusLineElement.java

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import javax.swing.Popup;
6767
import javax.swing.PopupFactory;
6868
import javax.swing.SwingConstants;
69+
import javax.swing.SwingUtilities;
6970
import javax.swing.event.ListSelectionEvent;
7071
import javax.swing.event.ListSelectionListener;
7172
import javax.swing.text.BadLocationException;
@@ -301,31 +302,49 @@ public String getDebugLevel(FileObject config) {
301302
*
302303
* @param debugLv true or false
303304
*/
304-
private void setDebugLevelLabel(String debugLv) {
305-
if (debugLv.matches("^(true|false)$")) { // NOI18N
306-
debugLabel.setText(debugLevel.get(debugLv));
307-
} else {
308-
debugLabel.setText(debugLv);
309-
}
305+
private void setDebugLevelLabel(final String debugLv) {
306+
SwingUtilities.invokeLater(new Runnable() {
307+
308+
@Override
309+
public void run() {
310+
if (debugLv.matches("^(true|false)$")) { // NOI18N
311+
debugLabel.setText(debugLevel.get(debugLv));
312+
} else {
313+
debugLabel.setText(debugLv);
314+
}
315+
}
316+
});
310317
}
311318

312319
/**
313320
* Set version versionLv.
314321
*
315322
* @param versionNumber
316323
*/
317-
private void setVersionLabel(String versionNumber) {
318-
versionLabel.setText(versionNumber);
319-
versionLabel.setIcon(icon);
324+
private void setVersionLabel(final String versionNumber) {
325+
SwingUtilities.invokeLater(new Runnable() {
326+
327+
@Override
328+
public void run() {
329+
versionLabel.setText(versionNumber);
330+
versionLabel.setIcon(icon);
331+
}
332+
});
320333
}
321334

322335
/**
323336
* Clear debug label
324337
*/
325338
private void clearLabel() {
326-
debugLabel.setText(""); //NOI18N
327-
versionLabel.setText(""); // NOI18N
328-
versionLabel.setIcon(null);
339+
SwingUtilities.invokeLater(new Runnable() {
340+
341+
@Override
342+
public void run() {
343+
debugLabel.setText(""); //NOI18N
344+
versionLabel.setText(""); // NOI18N
345+
versionLabel.setIcon(null);
346+
}
347+
});
329348
}
330349

331350
public void setLevel(String level) {

src/org/netbeans/modules/php/wordpress/wpapis/WordPressVersionCheckApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ public void parse() throws IOException {
8888
InputStream inputStream = openStream();
8989
try {
9090
JSONObject jsonObject = (JSONObject) JSONValue.parse(new InputStreamReader(inputStream, Charset.UTF8));
91+
if (jsonObject == null) {
92+
LOGGER.log(Level.INFO, "Can't get json for version check information."); // NOI18N
93+
return;
94+
}
9195
JSONArray offers = (JSONArray) jsonObject.get("offers"); // NOI18N
9296

9397
// get version and locale

0 commit comments

Comments
 (0)