diff --git a/extide/options.java/nbproject/project.xml b/extide/options.java/nbproject/project.xml index f3e816385eaa..922c247c3044 100644 --- a/extide/options.java/nbproject/project.xml +++ b/extide/options.java/nbproject/project.xml @@ -63,6 +63,7 @@ org.netbeans.modules.profiler.options org.netbeans.modules.vmd.componentssupport org.netbeans.modules.jshell.support + org.netbeans.modules.java.file.launcher org.netbeans.modules.options.java.api diff --git a/java/java.file.launcher/nbproject/project.xml b/java/java.file.launcher/nbproject/project.xml index 195981d25ec1..23476f52a29c 100644 --- a/java/java.file.launcher/nbproject/project.xml +++ b/java/java.file.launcher/nbproject/project.xml @@ -140,6 +140,23 @@ 1.84 + + org.netbeans.modules.options.api + + + + 1 + 1.71 + + + + org.netbeans.modules.options.java + + + + 1.39 + + org.netbeans.modules.parsing.api @@ -184,6 +201,14 @@ 1.65 + + org.openide.awt + + + + 7.94 + + org.openide.filesystems diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/AttributeBasedSingleFileOptions.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/AttributeBasedSingleFileOptions.java index 3312081635cf..550ff2e03d00 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/AttributeBasedSingleFileOptions.java +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/AttributeBasedSingleFileOptions.java @@ -20,6 +20,7 @@ import java.net.URI; import javax.swing.event.ChangeListener; +import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.modules.java.file.launcher.queries.MultiSourceRootProvider; import org.netbeans.modules.java.file.launcher.spi.SingleFileOptionsQueryImplementation; import org.openide.filesystems.FileAttributeEvent; @@ -29,6 +30,7 @@ import org.openide.filesystems.FileUtil; import org.openide.util.ChangeSupport; import org.openide.util.Lookup; +import org.openide.util.NbPreferences; import org.openide.util.RequestProcessor; import org.openide.util.WeakListeners; import org.openide.util.lookup.ServiceProvider; @@ -104,7 +106,9 @@ public String getOptions() { vmOptionsObj = root != null ? root.getAttribute(SingleSourceFileUtil.FILE_VM_OPTIONS) : null; - return vmOptionsObj != null ? (String) vmOptionsObj : ""; + String globalVmOptions = NbPreferences.forModule(JavaPlatformManager.class).get(SingleSourceFileUtil.GLOBAL_VM_OPTIONS, ""); // NOI18N + + return vmOptionsObj != null ? (String) vmOptionsObj + " " + globalVmOptions : globalVmOptions; // NOI18N } @Override diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/Bundle.properties b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/Bundle.properties index e091b91b1845..680d623800aa 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/Bundle.properties +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/Bundle.properties @@ -16,3 +16,6 @@ # under the License. OpenIDE-Module-Name=Java File Launcher +GlobalSettingsPanel.vmLabel.text=Additional VM Options: +GlobalSettingsPanel.singleRunCheckBox.text=Stop before Run +GlobalSettingsPanel.jLabel1.text=Execution of standalone Java sources: diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsOptionsPanelController.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsOptionsPanelController.java new file mode 100644 index 000000000000..784b88949d4f --- /dev/null +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsOptionsPanelController.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.java.file.launcher; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import org.netbeans.spi.options.OptionsPanelController; +import org.netbeans.modules.options.java.api.JavaOptions; +import org.openide.util.HelpCtx; +import org.openide.util.Lookup; + +@OptionsPanelController.SubRegistration( + location = JavaOptions.JAVA, + displayName = "#AdvancedOption_DisplayName_GlobalSettings", + keywords = "#AdvancedOption_Keywords_GlobalSettings", + keywordsCategory = "Java/GlobalSettings" +) +@org.openide.util.NbBundle.Messages({"AdvancedOption_DisplayName_GlobalSettings=Source Launcher", "AdvancedOption_Keywords_GlobalSettings=single source"}) +public final class GlobalSettingsOptionsPanelController extends OptionsPanelController { + + private GlobalSettingsPanel panel; + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private boolean changed; + + public void update() { + getPanel().load(); + changed = false; + } + + public void applyChanges() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + getPanel().store(); + changed = false; + } + }); + } + + public void cancel() { + // need not do anything special, if no changes have been persisted yet + } + + public boolean isValid() { + return getPanel().valid(); + } + + public boolean isChanged() { + return changed; + } + + public HelpCtx getHelpCtx() { + return null; // new HelpCtx("...ID") if you have a help set + } + + public JComponent getComponent(Lookup masterLookup) { + return getPanel(); + } + + public void addPropertyChangeListener(PropertyChangeListener l) { + pcs.addPropertyChangeListener(l); + } + + public void removePropertyChangeListener(PropertyChangeListener l) { + pcs.removePropertyChangeListener(l); + } + + private GlobalSettingsPanel getPanel() { + if (panel == null) { + panel = new GlobalSettingsPanel(this); + } + return panel; + } + + void changed() { + if (!changed) { + changed = true; + pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); + } + pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); + } + +} diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.form b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.form new file mode 100644 index 000000000000..b96e849c1781 --- /dev/null +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.form @@ -0,0 +1,105 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.java new file mode 100644 index 000000000000..d61fe085a84f --- /dev/null +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/GlobalSettingsPanel.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.java.file.launcher; + +import java.util.prefs.Preferences; +import org.netbeans.api.java.platform.JavaPlatformManager; +import org.openide.util.NbPreferences; + +final class GlobalSettingsPanel extends javax.swing.JPanel { + + private final GlobalSettingsOptionsPanelController controller; + + GlobalSettingsPanel(GlobalSettingsOptionsPanelController controller) { + this.controller = controller; + initComponents(); + // TODO listen to changes in form fields and call controller.changed() + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + vmTextField = new javax.swing.JTextField(); + vmLabel = new javax.swing.JLabel(); + singleRunCheckBox = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + + vmLabel.setLabelFor(vmTextField); + org.openide.awt.Mnemonics.setLocalizedText(vmLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.vmLabel.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(singleRunCheckBox, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.singleRunCheckBox.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.jLabel1.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(vmLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(singleRunCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(vmTextField))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(vmLabel) + .addComponent(vmTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(singleRunCheckBox) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + void load() { + Preferences prefs = NbPreferences.forModule(JavaPlatformManager.class); + vmTextField.setText(prefs.get(SingleSourceFileUtil.GLOBAL_VM_OPTIONS, "")); // NOI18N + singleRunCheckBox.setSelected(prefs.getBoolean(SingleSourceFileUtil.GLOBAL_STOP_AND_RUN_OPTION, false)); // NOI18N + } + + void store() { + Preferences prefs = NbPreferences.forModule(JavaPlatformManager.class); + prefs.put(SingleSourceFileUtil.GLOBAL_VM_OPTIONS, vmTextField.getText()); // NOI18N + prefs.putBoolean(SingleSourceFileUtil.GLOBAL_STOP_AND_RUN_OPTION, singleRunCheckBox.isSelected()); // NOI18N + } + + boolean valid() { + // TODO check whether form is consistent and complete + return true; + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JCheckBox singleRunCheckBox; + private javax.swing.JLabel vmLabel; + private javax.swing.JTextField vmTextField; + // End of variables declaration//GEN-END:variables +} diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SingleSourceFileUtil.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SingleSourceFileUtil.java index d8fb70bb990a..662bfefb4ab6 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SingleSourceFileUtil.java +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SingleSourceFileUtil.java @@ -31,6 +31,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.netbeans.api.java.platform.JavaPlatform; +import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.modules.java.file.launcher.queries.MultiSourceRootProvider; import org.netbeans.modules.java.file.launcher.spi.SingleFileOptionsQueryImplementation; @@ -41,6 +42,7 @@ import org.openide.loaders.DataObject; import org.openide.util.ChangeSupport; import org.openide.util.Lookup; +import org.openide.util.NbPreferences; /** * @@ -60,6 +62,9 @@ public static int findJavaVersion() throws NumberFormatException { return version; } + public static final String GLOBAL_VM_OPTIONS = "java_file_launcher_global_vm_options"; //NOI18N + public static final String GLOBAL_STOP_AND_RUN_OPTION = "java_file_launcher_global_stop_and_run_option"; //NOI18N + // synced with JavaNode public static final String FILE_ARGUMENTS = "single_file_run_arguments"; //NOI18N public static final String FILE_JDK = "single_file_run_jdk"; //NOI18N @@ -117,6 +122,10 @@ public static Process compileJavaSource(FileObject fileObject, JavaPlatform jdk) if (!vmOptions.isEmpty()) { compileCommandList.addAll(Arrays.asList(vmOptions.split(" "))); //NOI18N } + String globalVmOptions = NbPreferences.forModule(JavaPlatformManager.class).get(GLOBAL_VM_OPTIONS, "").trim(); // NOI18N + if (!globalVmOptions.isEmpty()) { + compileCommandList.addAll(Arrays.asList(globalVmOptions.split(" "))); //NOI18N + } compileCommandList.add(fileObject.getPath()); ProcessBuilder compileProcessBuilder = new ProcessBuilder(compileCommandList); compileProcessBuilder.directory(new File(fileObject.getParent().getPath())); diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/JPDAStart.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/JPDAStart.java index ede73c49dfe4..329b54428eac 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/JPDAStart.java +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/JPDAStart.java @@ -39,7 +39,6 @@ import org.netbeans.api.debugger.jpda.JPDADebugger; import org.netbeans.modules.java.file.launcher.SingleSourceFileUtil; import org.netbeans.spi.java.classpath.support.ClassPathSupport; -import org.openide.windows.InputOutput; /** * Start the JPDA debugger. @@ -52,11 +51,9 @@ public class JPDAStart implements Runnable { private static final String TRANSPORT = "dt_socket"; //NOI18N private final Object[] lock = new Object[2]; - private final InputOutput io; private final FileObject fileObject; - JPDAStart(InputOutput inputOutput, FileObject fileObject) { - io = inputOutput; + JPDAStart(FileObject fileObject) { this.fileObject = fileObject; } @@ -123,16 +120,16 @@ public void run() { JPDADebugger.startListening(flc, args, new Object[]{properties}); } catch (DebuggerStartException ex) { - io.getErr().println("Debugger Start Error."); //NOI18N +// io.getErr().println("Debugger Start Error."); //NOI18N SingleSourceFileUtil.LOG.log(Level.SEVERE, "Debugger Start Error.", ex); } }); } catch (java.io.IOException ioex) { - io.getErr().println("IO Error:"); //NOI18N +// io.getErr().println("IO Error:"); //NOI18N // org.openide.ErrorManager.getDefault().notify(ioex); lock[1] = ioex; } catch (com.sun.jdi.connect.IllegalConnectorArgumentsException icaex) { - io.getErr().println("Illegal Connector"); //NOI18N +// io.getErr().println("Illegal Connector"); //NOI18N lock[1] = icaex; } finally { lock.notify(); diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/LaunchProcess.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/LaunchProcess.java index befa4cf8c89f..daf1bbdddf38 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/LaunchProcess.java +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/LaunchProcess.java @@ -34,6 +34,7 @@ import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.BaseUtilities; +import org.openide.util.NbPreferences; import org.openide.util.Utilities; final class LaunchProcess implements Callable { @@ -82,6 +83,8 @@ private Process setupProcess(String port) throws InterruptedException { ExplicitProcessParameters.builder() .args(readArgumentsFromAttribute(fileObject, SingleSourceFileUtil.FILE_ARGUMENTS)) .launcherArgs(readArgumentsFromAttribute(fileObject, SingleSourceFileUtil.FILE_VM_OPTIONS)) + .launcherArgs(Arrays.asList(BaseUtilities.parseParameters( + NbPreferences.forModule(JavaPlatformManager.class).get(SingleSourceFileUtil.GLOBAL_VM_OPTIONS, "").trim()))) //NOI18N .workingDirectory(workDir) .build(); diff --git a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java index 007764c96487..05c9d1ff1ccd 100644 --- a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java +++ b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/actions/SingleJavaSourceRunActionProvider.java @@ -18,19 +18,22 @@ */ package org.netbeans.modules.java.file.launcher.actions; +import java.nio.charset.Charset; +import java.util.Map; +import java.util.WeakHashMap; import java.util.concurrent.Future; import org.netbeans.api.extexecution.ExecutionDescriptor; import org.netbeans.api.extexecution.ExecutionService; import org.netbeans.modules.java.file.launcher.SingleSourceFileUtil; import org.netbeans.api.extexecution.base.ExplicitProcessParameters; -import org.netbeans.spi.project.ActionProgress; +import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.spi.project.ActionProvider; +import org.openide.LifecycleManager; import org.openide.filesystems.FileObject; import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.openide.util.NbPreferences; import org.openide.util.lookup.ServiceProvider; -import org.openide.windows.IOProvider; -import org.openide.windows.InputOutput; /** * This class provides support to run a single Java file without a parent @@ -40,6 +43,10 @@ */ @ServiceProvider(service = ActionProvider.class) public final class SingleJavaSourceRunActionProvider implements ActionProvider { + + private final Map> running = new WeakHashMap<>(); + private volatile boolean rerun = false; + @Override public String[] getSupportedActions() { return new String[]{ @@ -53,26 +60,43 @@ public String[] getSupportedActions() { }) @Override public void invokeAction(String command, Lookup context) throws IllegalArgumentException { + LifecycleManager.getDefault().saveAll(); FileObject fileObject = SingleSourceFileUtil.getJavaFileWithoutProjectFromLookup(context); - if (fileObject == null) + if (fileObject == null) return; + var previous = running.get(fileObject); + if (previous != null && !previous.isDone()) { + rerun = true; + if (previous.cancel(true)) { + return; + } + rerun = false; + } ExplicitProcessParameters params = ExplicitProcessParameters.buildExplicitParameters(context); - InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_SingleJavaFile(), false); - ActionProgress progress = ActionProgress.start(context); + String preferredEncoding = System.getProperty("native.encoding"); // NOI18N ExecutionDescriptor descriptor = new ExecutionDescriptor(). + showProgress(true). controllable(true). frontWindow(true). preExecution(null). - inputOutput(io). + inputVisible(true). + charset(preferredEncoding != null ? Charset.forName(preferredEncoding) : null). postExecution((exitCode) -> { - progress.finished(exitCode == 0); + if (rerun) { + rerun = false; + invokeAction(command, context); + } }); - LaunchProcess process = invokeActionHelper(io, command, fileObject, params); + LaunchProcess process = invokeActionHelper(command, fileObject, params); ExecutionService exeService = ExecutionService.newService( process, - descriptor, "Running Single Java File"); - Future exitCode = exeService.run(); + descriptor, fileObject.getNameExt()); + + Future future = exeService.run(); + if (NbPreferences.forModule(JavaPlatformManager.class).getBoolean(SingleSourceFileUtil.GLOBAL_STOP_AND_RUN_OPTION, false)) { + running.put(fileObject, future); + } } @Override @@ -80,11 +104,11 @@ public boolean isActionEnabled(String command, Lookup context) throws IllegalArg FileObject fileObject = SingleSourceFileUtil.getJavaFileWithoutProjectFromLookup(context); return fileObject != null; } - - final LaunchProcess invokeActionHelper (InputOutput io, String command, FileObject fo, ExplicitProcessParameters params) { + + final LaunchProcess invokeActionHelper (String command, FileObject fo, ExplicitProcessParameters params) { JPDAStart start = ActionProvider.COMMAND_DEBUG_SINGLE.equals(command) ? - new JPDAStart(io, fo) : null; + new JPDAStart(fo) : null; return new LaunchProcess(fo, start, params); } - + } diff --git a/java/java.source/src/org/netbeans/modules/java/Bundle.properties b/java/java.source/src/org/netbeans/modules/java/Bundle.properties index 1d3268d9067e..e5ea1acd023d 100644 --- a/java/java.source/src/org/netbeans/modules/java/Bundle.properties +++ b/java/java.source/src/org/netbeans/modules/java/Bundle.properties @@ -37,6 +37,8 @@ PROP_JavaNode_singlefile_arguments=Program Arguments HINT_JavaNode_singlefile_arguments=Arguments passed to the main method while running the file. PROP_JavaNode_singlefile_options=VM Options HINT_JavaNode_singlefile_options=VM Options to be considered while running the file. +PROP_JavaNode_singlefile_global_options=Additional VM Options +HINT_JavaNode_singlefile_global_options=Additional VM Options configured in Settings... / Java / Source Launcher. PROP_JavaNode_singlefile_registerRoot=Enable Source File Launcher Indexing HINT_JavaNode_singlefile_registerRoot=The root corresponding to this file should have source file launcher indexing enabled PROP_JavaNode_classfile_version=Classfile Version diff --git a/java/java.source/src/org/netbeans/modules/java/JavaNode.java b/java/java.source/src/org/netbeans/modules/java/JavaNode.java index 60bfeced4598..51089d2cceb3 100644 --- a/java/java.source/src/org/netbeans/modules/java/JavaNode.java +++ b/java/java.source/src/org/netbeans/modules/java/JavaNode.java @@ -82,6 +82,7 @@ import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; +import org.openide.util.NbPreferences; import org.openide.util.RequestProcessor; import org.openide.util.Utilities; import org.openide.util.WeakListeners; @@ -108,6 +109,7 @@ public final class JavaNode extends DataNode implements ChangeListener { private static final String EXECUTABLE_BADGE_URL = "org/netbeans/modules/java/resources/executable-badge.png"; //NOI18N private static final String NEEDS_COMPILE_BADGE_URL = "org/netbeans/modules/java/resources/needs-compile.png"; //NOI18N // synced with org.netbeans.modules.java.file.launcher.SingleSourceFileUtil + private static final String GLOBAL_VM_OPTIONS = "java_file_launcher_global_vm_options"; //NOI18N private static final String FILE_ARGUMENTS = "single_file_run_arguments"; //NOI18N private static final String FILE_JDK = "single_file_run_jdk"; //NOI18N private static final String FILE_VM_OPTIONS = "single_file_vm_options"; //NOI18N @@ -247,6 +249,7 @@ protected final Sheet createSheet () { ss.put(new RunFileJDKProperty(dObj)); ss.put(new JavaFileAttributeProperty(dObj, FILE_ARGUMENTS, "runFileArguments", "singlefile_arguments")); // NOI18N ss.put(new JavaFileAttributeProperty(dObj, FILE_VM_OPTIONS, "runFileVMOptions", "singlefile_options")); // NOI18N + ss.put(new JavaFileGlobalOptionsProperty()); sheet.put(ss); } @@ -522,6 +525,19 @@ public void setValue(String o) { } } + // read-only global VM options + private static final class JavaFileGlobalOptionsProperty extends PropertySupport.ReadOnly { + + public JavaFileGlobalOptionsProperty() { + super("runFileGlobalOptions", String.class, getMessage(JavaNode.class, "PROP_JavaNode_singlefile_global_options"), getMessage(JavaNode.class, "HINT_JavaNode_singlefile_global_options")); // NOI18N + } + + @Override + public String getValue() { + return NbPreferences.forModule(JavaPlatformManager.class).get(GLOBAL_VM_OPTIONS, "").trim(); + } + } + @Override public void stateChanged(ChangeEvent e) { WORKER.post(new BuildStatusTask(this));