4949import java .util .logging .Level ;
5050import java .util .logging .Logger ;
5151import javax .swing .Action ;
52- import org .netbeans .modules .php .project .PhpProject ;
53- import org .netbeans .modules .php .project .ui .actions .DebugFileCommand ;
54- import org .netbeans .modules .php .project .ui .actions .DownloadCommand ;
55- import org .netbeans .modules .php .project .ui .actions .RunFileCommand ;
56- import org .netbeans .modules .php .project .ui .actions .RunTestCommand ;
57- import org .netbeans .modules .php .project .ui .actions .SyncCommand ;
58- import org .netbeans .modules .php .project .ui .actions .UploadCommand ;
59- import org .netbeans .modules .php .project .ui .actions .support .CommandUtils ;
52+ import org .netbeans .modules .php .api .util .FileUtils ;
6053import org .netbeans .spi .project .ui .support .CommonProjectActions ;
6154import org .netbeans .spi .project .ui .support .FileSensitiveActions ;
6255import org .netbeans .spi .project .ui .support .ProjectSensitiveActions ;
6558import org .openide .actions .PasteAction ;
6659import org .openide .actions .ToolsAction ;
6760import org .openide .filesystems .FileObject ;
61+ import org .openide .filesystems .FileUtil ;
6862import org .openide .loaders .DataFilter ;
6963import org .openide .loaders .DataFolder ;
7064import org .openide .loaders .DataObject ;
7165import org .openide .nodes .FilterNode ;
7266import org .openide .nodes .Node ;
7367import org .openide .util .ImageUtilities ;
68+ import org .openide .util .NbBundle ;
7469import org .openide .util .actions .SystemAction ;
7570import org .openide .util .lookup .ProxyLookup ;
7671
@@ -89,12 +84,12 @@ public class MVCNode extends FilterNode {
8984 * creates source root node based on specified DataFolder. Uses specified
9085 * name.
9186 */
92- MVCNode (PhpProject project , DataFolder folder , DataFilter filter , String name ) {
93- this (project , folder , new FilterNode (folder .getNodeDelegate (), folder .createNodeChildren (filter )), name );
87+ MVCNode (DataFolder folder , DataFilter filter , String name ) {
88+ this (folder , new FilterNode (folder .getNodeDelegate (), folder .createNodeChildren (filter )), name );
9489 }
9590
96- private MVCNode (PhpProject project , DataFolder folder , FilterNode node , String name ) {
97- super (node , new MVCNode .FolderChildren (project , node , false ), new ProxyLookup (folder .getNodeDelegate ().getLookup ()));
91+ private MVCNode (DataFolder folder , FilterNode node , String name ) {
92+ super (node , new MVCNode .FolderChildren (node , false ), new ProxyLookup (folder .getNodeDelegate ().getLookup ()));
9893
9994 disableDelegation (DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_GET_ACTIONS );
10095 setDisplayName (name );
@@ -131,13 +126,18 @@ public boolean canDestroy() {
131126 }
132127
133128 @ Override
129+ @ NbBundle .Messages ({
130+ "LBL_DownloadCommand=Download..." ,
131+ "LBL_UploadCommand=Upload..." ,
132+ "LBL_SyncCommand=Synchronize..."
133+ })
134134 public Action [] getActions (boolean context ) {
135135 List <Action > actions = new ArrayList <Action >();
136136 actions .add (CommonProjectActions .newFileAction ());
137137 actions .add (null );
138- actions .add (FileSensitiveActions .fileCommandAction (DownloadCommand . ID , DownloadCommand . DISPLAY_NAME , null ));
139- actions .add (FileSensitiveActions .fileCommandAction (UploadCommand . ID , UploadCommand . DISPLAY_NAME , null ));
140- actions .add (FileSensitiveActions .fileCommandAction (SyncCommand . ID , SyncCommand . DISPLAY_NAME , null ));
138+ actions .add (FileSensitiveActions .fileCommandAction ("dowonload" , Bundle . LBL_DownloadCommand () , null ));
139+ actions .add (FileSensitiveActions .fileCommandAction ("upload" , Bundle . LBL_UploadCommand () , null ));
140+ actions .add (FileSensitiveActions .fileCommandAction ("synchronize" , Bundle . LBL_SyncCommand () , null ));
141141 actions .add (null );
142142 actions .add (SystemAction .get (FileSystemAction .class ));
143143 actions .add (null );
@@ -155,9 +155,9 @@ public Action[] getActions(boolean context) {
155155 }
156156 static final Action [] COMMON_ACTIONS = new Action []{
157157 null ,
158- FileSensitiveActions .fileCommandAction (DownloadCommand . ID , DownloadCommand . DISPLAY_NAME , null ),
159- FileSensitiveActions .fileCommandAction (UploadCommand . ID , UploadCommand . DISPLAY_NAME , null ),
160- FileSensitiveActions .fileCommandAction (SyncCommand . ID , SyncCommand . DISPLAY_NAME , null ),};
158+ FileSensitiveActions .fileCommandAction ("dowonload" , Bundle . LBL_DownloadCommand () , null ),
159+ FileSensitiveActions .fileCommandAction ("upload" , Bundle . LBL_UploadCommand () , null ),
160+ FileSensitiveActions .fileCommandAction ("synchronize" , Bundle . LBL_SyncCommand () , null ),};
161161
162162 public static Action createDownloadAction () {
163163 return COMMON_ACTIONS [1 ];
@@ -177,12 +177,10 @@ public static Action createSynchronizeAction() {
177177 private static class FolderChildren extends FilterNode .Children {
178178 // common actions for both PackageNode and ObjectNode (equals has to be the same)
179179
180- private final PhpProject project ;
181180 private final boolean isTest ;
182181
183- FolderChildren (PhpProject project , final Node originalNode , boolean isTest ) {
182+ FolderChildren (final Node originalNode , boolean isTest ) {
184183 super (originalNode );
185- this .project = project ;
186184 this .isTest = isTest ;
187185 }
188186
@@ -200,16 +198,16 @@ protected Node copyNode(final Node originalNode) {
200198 return super .copyNode (originalNode );
201199 }
202200 if (fo .isFolder ()) {
203- return new MVCNode .PackageNode (project , originalNode , isTest );
201+ return new MVCNode .PackageNode (originalNode , isTest );
204202 }
205203 return new MVCNode .ObjectNode (originalNode , isTest );
206204 }
207205 }
208206
209207 private static final class PackageNode extends FilterNode {
210208
211- public PackageNode (PhpProject project , final Node originalNode , boolean isTest ) {
212- super (originalNode , new MVCNode .FolderChildren (project , originalNode , isTest ),
209+ public PackageNode (final Node originalNode , boolean isTest ) {
210+ super (originalNode , new MVCNode .FolderChildren (originalNode , isTest ),
213211 new ProxyLookup (originalNode .getLookup ()));
214212
215213 }
@@ -290,15 +288,20 @@ public Action[] getActions(boolean context) {
290288 return actions .toArray (new Action [actions .size ()]);
291289 }
292290
291+ @ NbBundle .Messages ({
292+ "LBL_RunProject=Run" ,
293+ "LBL_DebugProject=Debug" ,
294+ "LBL_TestFile=Test"
295+ })
293296 private Action [] getCommonActions () {
294297 List <Action > toAdd = new ArrayList <Action >();
295- if (CommandUtils . isPhpOrHtmlFile (getFileObject ())) {
298+ if (isPhpOrHtmlFile (getFileObject ())) {
296299 // not available for multiple selected nodes => create new instance every time
297300 toAdd .add (null );
298- toAdd .add (ProjectSensitiveActions .projectCommandAction (RunFileCommand . ID , RunFileCommand . DISPLAY_NAME , null ));
299- toAdd .add (ProjectSensitiveActions .projectCommandAction (DebugFileCommand . ID , DebugFileCommand . DISPLAY_NAME , null ));
301+ toAdd .add (ProjectSensitiveActions .projectCommandAction ("run.single" , Bundle . LBL_RunProject () , null ));
302+ toAdd .add (ProjectSensitiveActions .projectCommandAction ("debug.single" , Bundle . LBL_DebugProject () , null ));
300303 if (!isTest ) {
301- toAdd .add (ProjectSensitiveActions .projectCommandAction (RunTestCommand . ID , RunTestCommand . DISPLAY_NAME , null ));
304+ toAdd .add (ProjectSensitiveActions .projectCommandAction ("test.single" , Bundle . LBL_TestFile () , null ));
302305 }
303306 }
304307
@@ -311,6 +314,12 @@ private Action[] getCommonActions() {
311314 return actions .toArray (new Action [actions .size ()]);
312315 }
313316
317+ public static boolean isPhpOrHtmlFile (FileObject file ) {
318+ assert file != null ;
319+ String mimeType = FileUtil .getMIMEType (file , FileUtils .PHP_MIME_TYPE , "text/html" );
320+ return FileUtils .PHP_MIME_TYPE .equals (mimeType ) || "text/html" .equals (mimeType );
321+ }
322+
314323 private FileObject getFileObject () {
315324 FileObject fileObject = originalNode .getLookup ().lookup (FileObject .class );
316325 if (fileObject != null ) {
0 commit comments