This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 222135
Collapse All | Expand All

(-)a/web.project/src/org/netbeans/modules/web/project/WebActionProvider.java (-23 / +59 lines)
Lines 82-87 Link Here
82
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
82
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
83
import java.util.HashSet;
83
import java.util.HashSet;
84
import java.util.LinkedList;
84
import java.util.LinkedList;
85
import java.util.concurrent.atomic.AtomicBoolean;
85
import javax.lang.model.element.AnnotationMirror;
86
import javax.lang.model.element.AnnotationMirror;
86
import javax.lang.model.element.TypeElement;
87
import javax.lang.model.element.TypeElement;
87
import javax.swing.JLabel;
88
import javax.swing.JLabel;
Lines 95-100 Link Here
95
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
96
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
96
import org.netbeans.api.java.source.CompilationController;
97
import org.netbeans.api.java.source.CompilationController;
97
import org.netbeans.api.java.source.JavaSource;
98
import org.netbeans.api.java.source.JavaSource;
99
import org.netbeans.api.progress.ProgressUtils;
98
import org.netbeans.modules.j2ee.common.project.WhiteListUpdater;
100
import org.netbeans.modules.j2ee.common.project.WhiteListUpdater;
99
import org.netbeans.modules.j2ee.common.project.ui.J2EEProjectProperties;
101
import org.netbeans.modules.j2ee.common.project.ui.J2EEProjectProperties;
100
import org.netbeans.modules.java.api.common.project.BaseActionProvider;
102
import org.netbeans.modules.java.api.common.project.BaseActionProvider;
Lines 121-127 Link Here
121
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
123
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
122
import org.netbeans.spi.project.support.ant.PropertyUtils;
124
import org.netbeans.spi.project.support.ant.PropertyUtils;
123
import org.openide.DialogDescriptor;
125
import org.openide.DialogDescriptor;
126
import org.openide.util.Cancellable;
124
import org.openide.util.Exceptions;
127
import org.openide.util.Exceptions;
128
import org.openide.util.NbBundle.Messages;
125
import org.openide.util.Parameters;
129
import org.openide.util.Parameters;
126
130
127
/** Action provider of the Web project. This is the place where to do
131
/** Action provider of the Web project. This is the place where to do
Lines 301-306 Link Here
301
        return runServlet(p, javaFile, "LBL_RunAction", COMMAND_DEBUG_SINGLE.equals(command), COMMAND_PROFILE_SINGLE.equals(command), targetNames);
305
        return runServlet(p, javaFile, "LBL_RunAction", COMMAND_DEBUG_SINGLE.equals(command), COMMAND_PROFILE_SINGLE.equals(command), targetNames);
302
    }
306
    }
303
307
308
    @Messages({
309
        "WebActionProvider.lbl.running.action=Running file..."
310
    })
304
    @Override
311
    @Override
305
    public String[] getTargetNames(String command, Lookup context, Properties p, boolean doJavaChecks) throws IllegalArgumentException {
312
    public String[] getTargetNames(String command, Lookup context, Properties p, boolean doJavaChecks) throws IllegalArgumentException {
306
        if (command.equals(COMMAND_RUN_SINGLE) ||command.equals(COMMAND_RUN) ||
313
        if (command.equals(COMMAND_RUN_SINGLE) ||command.equals(COMMAND_RUN) ||
Lines 345-377 Link Here
345
                if (!compile) {
352
                if (!compile) {
346
                    setAllPropertiesForSingleJSPCompilation(p, files);
353
                    setAllPropertiesForSingleJSPCompilation(p, files);
347
                }
354
                }
348
355
                AtomicBoolean completeAction = new AtomicBoolean(false);
349
                String requestParams = RequestParametersQuery.getFileAndParameters(files[0]);
356
                ProgressUtils.showProgressDialogAndRun(new RunSingleJspFileAction(files[0], p, completeAction), Bundle.WebActionProvider_lbl_running_action());
350
                if (requestParams != null) {
357
                return completeAction.get() ? targetNames : null;
351
                    p.setProperty("client.urlPart", requestParams); //NOI18N
352
                    p.setProperty(BaseActionProvider.PROPERTY_RUN_SINGLE_ON_SERVER, "yes");
353
                    return targetNames;
354
                } else {
355
                    return null;
356
                }
357
            } else {
358
            } else {
358
                // run HTML file
359
                // run HTML file
359
                FileObject[] htmlFiles = findHtml(context);
360
                FileObject[] htmlFiles = findHtml(context);
360
                if ((htmlFiles != null) && (htmlFiles.length > 0)) {
361
                if ((htmlFiles != null) && (htmlFiles.length > 0)) {
361
                    String requestParams = RequestParametersQuery.getFileAndParameters(htmlFiles[0]);
362
                    AtomicBoolean completeAction = new AtomicBoolean(false);
362
                    if (requestParams == null) {
363
                    ProgressUtils.showProgressDialogAndRun(new RunSingleHtmlFileAction(htmlFiles[0], p, completeAction), Bundle.WebActionProvider_lbl_running_action());
363
                        requestParams = FileUtil.getRelativePath(WebModule.getWebModule(htmlFiles[0]).getDocumentBase(), htmlFiles[0]); // NOI18N
364
                    return completeAction.get() ? targetNames : null;
364
                        if (requestParams != null) {
365
                            requestParams = "/" + requestParams.replace(" ", "%20"); // NOI18N
366
                        }
367
                    }
368
                    if (requestParams != null) {
369
                        p.setProperty("client.urlPart", requestParams); //NOI18N
370
                        p.setProperty(BaseActionProvider.PROPERTY_RUN_SINGLE_ON_SERVER, "yes"); // NOI18N
371
                        return targetNames;
372
                    } else {
373
                        return null;
374
                    }
375
                }
365
                }
376
            }
366
            }
377
        } else if (command.equals(COMMAND_RUN) || command.equals(WebProjectConstants.COMMAND_REDEPLOY)) {
367
        } else if (command.equals(COMMAND_RUN) || command.equals(WebProjectConstants.COMMAND_REDEPLOY)) {
Lines 1057-1062 Link Here
1057
        }
1047
        }
1058
    }
1048
    }
1059
1049
1050
    private static class RunSingleJspFileAction implements Runnable {
1051
1052
        protected final AtomicBoolean run;
1053
        protected final FileObject fileObject;
1054
        protected final Properties properties;
1055
1056
        protected RunSingleJspFileAction(FileObject fileObject, Properties properties, AtomicBoolean completeAction) {
1057
            this.fileObject = fileObject;
1058
            this.properties = properties;
1059
            this.run = completeAction;
1060
        }
1061
1062
        @Override
1063
        public void run() {
1064
            String requestParams = RequestParametersQuery.getFileAndParameters(fileObject);
1065
            if (requestParams != null) {
1066
                setStatus(properties, requestParams);
1067
            }
1068
        }
1069
1070
        protected void setStatus(Properties p, String requestParams) {
1071
            properties.setProperty("client.urlPart", requestParams); //NOI18N
1072
            properties.setProperty(BaseActionProvider.PROPERTY_RUN_SINGLE_ON_SERVER, "yes");
1073
            run.set(true);
1074
        }
1075
    }
1076
1077
    private static class RunSingleHtmlFileAction extends RunSingleJspFileAction {
1078
1079
        public RunSingleHtmlFileAction(FileObject fileObject, Properties properties, AtomicBoolean completeAction) {
1080
            super(fileObject, properties, completeAction);
1081
        }
1082
1083
        @Override
1084
        public void run() {
1085
            super.run();
1086
            if (!run.get()) {
1087
                String requestParams = FileUtil.getRelativePath(WebModule.getWebModule(fileObject).getDocumentBase(),fileObject);
1088
                if (requestParams != null) {
1089
                    requestParams = "/" + requestParams.replace(" ", "%20"); //NOI18N
1090
                    setStatus(properties, requestParams);
1091
                }
1092
            }
1093
        }
1094
    }
1095
1060
    @ProjectServiceProvider(
1096
    @ProjectServiceProvider(
1061
            service = ActionProvider.class,
1097
            service = ActionProvider.class,
1062
            projectTypes = {@LookupProvider.Registration.ProjectType(id = "org-netbeans-modules-web-project", position=1)})
1098
            projectTypes = {@LookupProvider.Registration.ProjectType(id = "org-netbeans-modules-web-project", position=1)})

Return to bug 222135