diff --git a/extexecution.destroy/build.xml b/extexecution.impl/build.xml rename from extexecution.destroy/build.xml rename to extexecution.impl/build.xml --- a/extexecution.destroy/build.xml +++ b/extexecution.impl/build.xml @@ -1,5 +1,5 @@ - - Builds, tests, and runs the project org.netbeans.modules.extexecution.destroy + + Builds, tests, and runs the project org.netbeans.modules.extexecution.impl diff --git a/extexecution.destroy/external/binaries-list b/extexecution.impl/external/binaries-list rename from extexecution.destroy/external/binaries-list rename to extexecution.impl/external/binaries-list diff --git a/extexecution.destroy/external/libpam4j-1.1-license.txt b/extexecution.impl/external/libpam4j-1.1-license.txt rename from extexecution.destroy/external/libpam4j-1.1-license.txt rename to extexecution.impl/external/libpam4j-1.1-license.txt diff --git a/extexecution.destroy/external/processtreekiller-1.0.1-license.txt b/extexecution.impl/external/processtreekiller-1.0.1-license.txt rename from extexecution.destroy/external/processtreekiller-1.0.1-license.txt rename to extexecution.impl/external/processtreekiller-1.0.1-license.txt diff --git a/extexecution.destroy/external/winp-1.14-patched-license.txt b/extexecution.impl/external/winp-1.14-patched-license.txt rename from extexecution.destroy/external/winp-1.14-patched-license.txt rename to extexecution.impl/external/winp-1.14-patched-license.txt diff --git a/extexecution.destroy/external/winp.patch b/extexecution.impl/external/winp.patch rename from extexecution.destroy/external/winp.patch rename to extexecution.impl/external/winp.patch diff --git a/extexecution.destroy/manifest.mf b/extexecution.impl/manifest.mf rename from extexecution.destroy/manifest.mf rename to extexecution.impl/manifest.mf --- a/extexecution.destroy/manifest.mf +++ b/extexecution.impl/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 AutoUpdate-Show-In-Client: false -OpenIDE-Module: org.netbeans.modules.extexecution.destroy -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/destroy/Bundle.properties +OpenIDE-Module: org.netbeans.modules.extexecution.impl +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/impl/Bundle.properties OpenIDE-Module-Specification-Version: 1.13 - +OpenIDE-Module-Provides: org.netbeans.spi.extexecution.open.OptionOpenHandler diff --git a/extexecution.destroy/nbproject/project.properties b/extexecution.impl/nbproject/project.properties rename from extexecution.destroy/nbproject/project.properties rename to extexecution.impl/nbproject/project.properties diff --git a/extexecution.destroy/nbproject/project.xml b/extexecution.impl/nbproject/project.xml rename from extexecution.destroy/nbproject/project.xml rename to extexecution.impl/nbproject/project.xml --- a/extexecution.destroy/nbproject/project.xml +++ b/extexecution.impl/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.apisupport.project - org.netbeans.modules.extexecution.destroy + org.netbeans.modules.extexecution.impl org.apache.commons.io @@ -17,7 +17,7 @@ 1 - 1.3 + 1.23 @@ -26,7 +26,56 @@ 2 - 1.15 + 1.33 + + + + org.netbeans.modules.options.api + + + + 1 + 1.8 + + + + org.openide.awt + + + + 7.2 + + + + org.openide.filesystems + + + + 7.3.1 + + + + org.openide.loaders + + + + 6.7.1 + + + + org.openide.nodes + + + + 7.2.1.1 + + + + org.openide.text + + + + 6.16.1 diff --git a/extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/ProcessDestroyPerformerImpl.java b/extexecution.impl/src/org/netbeans/modules/extexecution/destroy/ProcessTreeDestroyPerformer.java rename from extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/ProcessDestroyPerformerImpl.java rename to extexecution.impl/src/org/netbeans/modules/extexecution/destroy/ProcessTreeDestroyPerformer.java --- a/extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/ProcessDestroyPerformerImpl.java +++ b/extexecution.impl/src/org/netbeans/modules/extexecution/destroy/ProcessTreeDestroyPerformer.java @@ -52,8 +52,9 @@ * @author mkleint */ @ServiceProvider(service=ProcessDestroyPerformer.class) -public class ProcessDestroyPerformerImpl implements ProcessDestroyPerformer { +public class ProcessTreeDestroyPerformer implements ProcessDestroyPerformer { + @Override public void destroy(Process process, Map env) { ProcessTreeKiller.get().kill(process, env); } diff --git a/extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/Bundle.properties b/extexecution.impl/src/org/netbeans/modules/extexecution/impl/Bundle.properties rename from extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/Bundle.properties rename to extexecution.impl/src/org/netbeans/modules/extexecution/impl/Bundle.properties --- a/extexecution.destroy/src/org/netbeans/modules/extexecution/destroy/Bundle.properties +++ b/extexecution.impl/src/org/netbeans/modules/extexecution/impl/Bundle.properties @@ -1,1 +1,1 @@ -OpenIDE-Module-Name=External Execution Process Destroy Support +OpenIDE-Module-Name=External Execution Implementations diff --git a/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbFileOpenHandler.java b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbFileOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbFileOpenHandler.java @@ -0,0 +1,126 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.open; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import org.netbeans.spi.extexecution.open.FileOpenHandler; +import org.openide.cookies.EditorCookie; +import org.openide.cookies.LineCookie; +import org.openide.cookies.OpenCookie; +import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObject; +import org.openide.text.Line; +import org.openide.text.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Petr Hejl + */ +@ServiceProvider(service=FileOpenHandler.class) +public class NbFileOpenHandler implements FileOpenHandler { + + private static final Logger LOGGER = Logger.getLogger(NbFileOpenHandler.class.getName()); + + @Override + public void open(final FileObject file, final int lineno) { + // FIXME this should not be needed + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + open(file, lineno); + } + }); + + return; // not exactly accurate, but.... + } + + try { + DataObject od = DataObject.find(file); + EditorCookie ec = od.getCookie(EditorCookie.class); + LineCookie lc = od.getCookie(LineCookie.class); + + if ((ec != null) && (lc != null)) { + Document doc = ec.openDocument(); + + if (doc != null) { + int line = lineno; + + if (line < 1) { + line = 1; + } + + // XXX .size() call is super-slow for large files, see issue + // #126531. So we fallback to catching IOOBE +// int nOfLines = lines.getLines().size(); +// if (line > nOfLines) { +// line = nOfLines; +// } + try { + Line.Set lines = lc.getLineSet(); + Line l = lines.getCurrent(line - 1); + if (l != null) { + l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS); + return; + } + } catch (IndexOutOfBoundsException ioobe) { + // OK, since .size() cannot be used, see above + } + } + } + + OpenCookie oc = od.getCookie(OpenCookie.class); + + if (oc != null) { + oc.open(); + return; + } + } catch (IOException e) { + LOGGER.log(Level.INFO, null, e); + } + } +} diff --git a/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbHttpOpenHandler.java b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbHttpOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbHttpOpenHandler.java @@ -0,0 +1,60 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.open; + +import java.net.URL; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; +import org.openide.awt.HtmlBrowser; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Petr Hejl + */ +@ServiceProvider(service=HttpOpenHandler.class) +public class NbHttpOpenHandler implements HttpOpenHandler { + + @Override + public void open(URL url) { + HtmlBrowser.URLDisplayer.getDefault().showURL(url); + } +} diff --git a/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbOptionOpenHandler.java b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbOptionOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution.impl/src/org/netbeans/modules/extexecution/open/NbOptionOpenHandler.java @@ -0,0 +1,59 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.open; + +import org.netbeans.api.options.OptionsDisplayer; +import org.netbeans.spi.extexecution.open.OptionOpenHandler; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Petr Hejl + */ +@ServiceProvider(service=OptionOpenHandler.class) +public class NbOptionOpenHandler implements OptionOpenHandler { + + @Override + public void open(String optionsPath) { + OptionsDisplayer.getDefault().open(optionsPath); + } +} diff --git a/extexecution/apichanges.xml b/extexecution/apichanges.xml --- a/extexecution/apichanges.xml +++ b/extexecution/apichanges.xml @@ -107,6 +107,7 @@ External Execution Startup Arguments API External Execution SPI External Execution Process Destroy SPI + External Execution Open Handler SPI External Execution Startup Arguments SPI @@ -116,6 +117,22 @@ + + SPI to allow to split the API and implementation + + + + + + This API/SPI allow splitting the extexecution to real API + and implementation classes. + + + + + + + SPI to allow extending process startup diff --git a/extexecution/arch.xml b/extexecution/arch.xml --- a/extexecution/arch.xml +++ b/extexecution/arch.xml @@ -76,6 +76,12 @@ .

+ The + allows implementation module to determine particular way of file or HTTP + URL opening in predefined covertors. It also makes options dialog opening + pluggable. +

+

There is also API to provide additional startup arguments to interested clients such as projects and servers . @@ -262,6 +268,28 @@ and use the additional arguments for the process.

+ +

+ Some default + LineConvertors + returned by + LineConvertor + needs to open file or URL. A bit special case is also options dialog opening + required by + ExecutionService + to open options dialog specified by + ExecutionDescriptor. + To cover this three usecases in a pluggable way while keeping dependencies + minimal there are three corresponding SPI classes one may implement. + So there is + FileOpenHandler + to handle file opening, + HttpOpenHandler + to deal with HTTP URLs and + OptionOpenHandler + to open proper options dialog. +

+
diff --git a/extexecution/manifest.mf b/extexecution/manifest.mf --- a/extexecution/manifest.mf +++ b/extexecution/manifest.mf @@ -2,5 +2,6 @@ AutoUpdate-Show-In-Client: false OpenIDE-Module: org.netbeans.modules.extexecution/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.32 +OpenIDE-Module-Specification-Version: 1.33 +OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.open.OptionOpenHandler diff --git a/extexecution/nbproject/project.xml b/extexecution/nbproject/project.xml --- a/extexecution/nbproject/project.xml +++ b/extexecution/nbproject/project.xml @@ -24,23 +24,6 @@
- org.netbeans.modules.options.api - - - - 1 - 1.8 - - - - org.openide.awt - - - - 7.2 - - - org.openide.filesystems @@ -57,30 +40,6 @@ - org.openide.loaders - - - - 6.7.1 - - - - org.openide.nodes - - - - 7.2.1.1 - - - - org.openide.text - - - - 6.16.1 - - - org.openide.util @@ -133,6 +92,7 @@ org.netbeans.api.extexecution.startup org.netbeans.spi.extexecution org.netbeans.spi.extexecution.destroy + org.netbeans.spi.extexecution.open org.netbeans.spi.extexecution.startup
diff --git a/extexecution/src/org/netbeans/api/extexecution/ExecutionDescriptor.java b/extexecution/src/org/netbeans/api/extexecution/ExecutionDescriptor.java --- a/extexecution/src/org/netbeans/api/extexecution/ExecutionDescriptor.java +++ b/extexecution/src/org/netbeans/api/extexecution/ExecutionDescriptor.java @@ -49,6 +49,7 @@ import org.netbeans.api.annotations.common.NullAllowed; import org.netbeans.api.extexecution.input.InputProcessor; import org.netbeans.api.extexecution.print.LineConvertor; +import org.netbeans.spi.extexecution.open.OptionOpenHandler; import org.openide.windows.InputOutput; /** @@ -586,10 +587,9 @@ * Returns a descriptor with configured options path. If configured * value is not null the {@link ExecutionService} will * display the button in the output tab displaying the proper options - * when pressed. - *

- * Format of the parameter is described in - * {@link org.netbeans.api.options.OptionsDisplayer#open(java.lang.String)}. + * when pressed. For this to work there has to be + * a {@link OptionOpenHandler} in the system. Otherwise the options button + * won't be displayed. *

* Note that this property has no meaning when custom io is used * (see {@link #inputOutput(org.openide.windows.InputOutput)}). @@ -601,6 +601,7 @@ * * @param optionsPath options path, null allowed * @return this descriptor with configured options path + * @see OptionOpenHandler */ @NonNull @CheckReturnValue diff --git a/extexecution/src/org/netbeans/api/extexecution/ExternalProcessSupport.java b/extexecution/src/org/netbeans/api/extexecution/ExternalProcessSupport.java --- a/extexecution/src/org/netbeans/api/extexecution/ExternalProcessSupport.java +++ b/extexecution/src/org/netbeans/api/extexecution/ExternalProcessSupport.java @@ -42,10 +42,10 @@ package org.netbeans.api.extexecution; -import org.netbeans.spi.extexecution.destroy.*; import java.util.Map; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.modules.extexecution.WrapperProcess; +import org.netbeans.spi.extexecution.destroy.ProcessDestroyPerformer; import org.openide.util.Lookup; import org.openide.util.Parameters; diff --git a/extexecution/src/org/netbeans/api/extexecution/print/LineConvertors.java b/extexecution/src/org/netbeans/api/extexecution/print/LineConvertors.java --- a/extexecution/src/org/netbeans/api/extexecution/print/LineConvertors.java +++ b/extexecution/src/org/netbeans/api/extexecution/print/LineConvertors.java @@ -54,11 +54,15 @@ import org.netbeans.api.annotations.common.CheckForNull; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.annotations.common.NullAllowed; -import org.netbeans.modules.extexecution.print.FindFileListener; -import org.openide.awt.HtmlBrowser; +import org.netbeans.modules.extexecution.open.DefaultFileOpenHandler; +import org.netbeans.modules.extexecution.open.DefaultHttpOpenHandler; +import org.netbeans.modules.extexecution.print.FileListener; +import org.netbeans.modules.extexecution.print.UrlListener; +import org.netbeans.spi.extexecution.open.FileOpenHandler; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; import org.openide.filesystems.FileObject; +import org.openide.util.Lookup; import org.openide.util.Parameters; -import org.openide.windows.OutputEvent; import org.openide.windows.OutputListener; /** @@ -70,6 +74,10 @@ private static final Logger LOGGER = Logger.getLogger(LineConvertors.class.getName()); + private static final DefaultFileOpenHandler DEFAULT_FILE_HANDLER = new DefaultFileOpenHandler(); + + private static final DefaultHttpOpenHandler DEFAULT_HTTP_HANDLER = new DefaultHttpOpenHandler(); + private LineConvertors() { super(); } @@ -135,6 +143,7 @@ * if negative line number is not parsed * @return the convertor searching for lines matching the patterns, * considering matched lines as being files (names or paths) + * @see FileOpenHandler */ @NonNull public static LineConvertor filePattern(@NullAllowed FileLocator fileLocator, @NonNull Pattern linePattern, @@ -162,6 +171,7 @@ * * @return the convertor parsing the line and searching for * http or https URL + * @see HttpOpenHandler */ @NonNull public static LineConvertor httpUrl() { @@ -214,6 +224,8 @@ private static class FilePatternConvertor implements LineConvertor { + private final FileOpenHandler handler; + private final FileLocator locator; private final Pattern linePattern; @@ -232,6 +244,13 @@ public FilePatternConvertor(FileLocator locator, Pattern linePattern, Pattern filePattern, int fileGroup, int lineGroup) { + FileOpenHandler candidate = Lookup.getDefault().lookup(FileOpenHandler.class); + if (candidate != null) { + handler = candidate; + } else { + handler = DEFAULT_FILE_HANDLER; + } + this.locator = locator; this.linePattern = linePattern; this.fileGroup = fileGroup; @@ -279,7 +298,8 @@ } return Collections.singletonList( - ConvertedLine.forText(line, new FindFileListener(file, lineno, locator))); + ConvertedLine.forText(line, + new FileListener(file, lineno, locator, handler))); } return null; @@ -290,10 +310,18 @@ private final Pattern pattern = Pattern.compile(".*(((http)|(https))://\\S+)(\\s.*|$)"); // NOI18N + private final HttpOpenHandler handler; + public HttpUrlConvertor() { - super(); + HttpOpenHandler candidate = Lookup.getDefault().lookup(HttpOpenHandler.class); + if (candidate != null) { + handler = candidate; + } else { + handler = DEFAULT_HTTP_HANDLER; + } } + @Override public List convert(String line) { Matcher matcher = pattern.matcher(line); if (matcher.matches()) { @@ -301,7 +329,7 @@ try { URL url = new URL(stringUrl); return Collections.singletonList( - ConvertedLine.forText(line, new UrlOutputListener(url))); + ConvertedLine.forText(line, new UrlListener(url, handler))); } catch (MalformedURLException ex) { // return null } @@ -311,25 +339,4 @@ } } - - private static class UrlOutputListener implements OutputListener { - - private final URL url; - - public UrlOutputListener(URL url) { - this.url = url; - } - - public void outputLineAction(OutputEvent ev) { - HtmlBrowser.URLDisplayer.getDefault().showURL(url); - } - - public void outputLineCleared(OutputEvent ev) { - // noop - } - - public void outputLineSelected(OutputEvent ev) { - // noop - } - } } diff --git a/extexecution/src/org/netbeans/modules/extexecution/InputOutputManager.java b/extexecution/src/org/netbeans/modules/extexecution/InputOutputManager.java --- a/extexecution/src/org/netbeans/modules/extexecution/InputOutputManager.java +++ b/extexecution/src/org/netbeans/modules/extexecution/InputOutputManager.java @@ -54,6 +54,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Action; +import org.netbeans.spi.extexecution.open.OptionOpenHandler; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.windows.IOProvider; import org.openide.windows.InputOutput; @@ -171,9 +173,16 @@ stopAction = new StopAction(); rerunAction = new RerunAction(); if (optionsPath != null) { - optionsAction = new OptionsAction(optionsPath); - io = IOProvider.getDefault().getIO(displayName, - new Action[] {rerunAction, stopAction, optionsAction}); + OptionOpenHandler handler = Lookup.getDefault().lookup(OptionOpenHandler.class); + if (handler != null) { + optionsAction = new OptionsAction(handler, optionsPath); + io = IOProvider.getDefault().getIO(displayName, + new Action[] {rerunAction, stopAction, optionsAction}); + } else { + LOGGER.log(Level.WARNING, "No available OptionsOpenHandler so no Options button"); + io = IOProvider.getDefault().getIO(displayName, + new Action[] {rerunAction, stopAction}); + } } else { io = IOProvider.getDefault().getIO(displayName, new Action[] {rerunAction, stopAction}); @@ -181,9 +190,15 @@ rerunAction.setParent(io); } else { if (optionsPath != null) { - optionsAction = new OptionsAction(optionsPath); - io = IOProvider.getDefault().getIO(displayName, - new Action[] {optionsAction}); + OptionOpenHandler handler = Lookup.getDefault().lookup(OptionOpenHandler.class); + if (handler != null) { + optionsAction = new OptionsAction(handler, optionsPath); + io = IOProvider.getDefault().getIO(displayName, + new Action[] {optionsAction}); + } else { + LOGGER.log(Level.WARNING, "No available OptionsOpenHandler so no Options button"); + io = IOProvider.getDefault().getIO(displayName, true); + } } else { io = IOProvider.getDefault().getIO(displayName, true); } diff --git a/extexecution/src/org/netbeans/modules/extexecution/OptionsAction.java b/extexecution/src/org/netbeans/modules/extexecution/OptionsAction.java --- a/extexecution/src/org/netbeans/modules/extexecution/OptionsAction.java +++ b/extexecution/src/org/netbeans/modules/extexecution/OptionsAction.java @@ -45,8 +45,7 @@ import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.ImageIcon; -import org.netbeans.api.options.OptionsDisplayer; +import org.netbeans.spi.extexecution.open.OptionOpenHandler; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; @@ -56,18 +55,22 @@ */ public class OptionsAction extends AbstractAction { + private final OptionOpenHandler handler; + private final String optionsPath; - public OptionsAction(String optionsPath) { + public OptionsAction(OptionOpenHandler handler, String optionsPath) { setEnabled(true); // just to be sure putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/extexecution/resources/options.png", false)); // NOI18N putValue(Action.SHORT_DESCRIPTION, NbBundle.getMessage(OptionsAction.class, "Options")); + assert handler != null : "Null handler"; + this.handler = handler; this.optionsPath = optionsPath; } public void actionPerformed(ActionEvent e) { - OptionsDisplayer.getDefault().open(optionsPath); + handler.open(optionsPath); } public String getOptionsPath() { diff --git a/extexecution/src/org/netbeans/modules/extexecution/open/DefaultFileOpenHandler.java b/extexecution/src/org/netbeans/modules/extexecution/open/DefaultFileOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/modules/extexecution/open/DefaultFileOpenHandler.java @@ -0,0 +1,72 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.open; + +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.spi.extexecution.open.FileOpenHandler; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author Petr Hejl + */ +public class DefaultFileOpenHandler implements FileOpenHandler { + + private static final Logger LOGGER = Logger.getLogger(DefaultFileOpenHandler.class.getName()); + + @Override + public void open(FileObject file, int line) { + File realFile = FileUtil.toFile(file); + if (realFile != null) { + try { + Desktop.getDesktop().edit(realFile); + } catch (IOException ex) { + LOGGER.log(Level.INFO, null, ex); + } + } + } +} diff --git a/extexecution/src/org/netbeans/modules/extexecution/open/DefaultHttpOpenHandler.java b/extexecution/src/org/netbeans/modules/extexecution/open/DefaultHttpOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/modules/extexecution/open/DefaultHttpOpenHandler.java @@ -0,0 +1,71 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.open; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; + +/** + * + * @author Petr Hejl + */ +public class DefaultHttpOpenHandler implements HttpOpenHandler { + + private static final Logger LOGGER = Logger.getLogger(DefaultHttpOpenHandler.class.getName()); + + @Override + public void open(URL url) { + try { + Desktop.getDesktop().browse(url.toURI()); + } catch (URISyntaxException ex) { + LOGGER.log(Level.INFO, null, ex); + } catch (IOException ex) { + LOGGER.log(Level.INFO, null, ex); + } + } + +} diff --git a/extexecution/src/org/netbeans/modules/extexecution/print/FindFileListener.java b/extexecution/src/org/netbeans/modules/extexecution/print/FileListener.java rename from extexecution/src/org/netbeans/modules/extexecution/print/FindFileListener.java rename to extexecution/src/org/netbeans/modules/extexecution/print/FileListener.java --- a/extexecution/src/org/netbeans/modules/extexecution/print/FindFileListener.java +++ b/extexecution/src/org/netbeans/modules/extexecution/print/FileListener.java @@ -43,51 +43,51 @@ */ package org.netbeans.modules.extexecution.print; +import java.awt.Desktop; import java.io.File; import java.io.IOException; +import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.SwingUtilities; -import javax.swing.text.Document; - import org.netbeans.api.extexecution.print.LineConvertors.FileLocator; -import org.openide.cookies.EditorCookie; -import org.openide.cookies.LineCookie; -import org.openide.cookies.OpenCookie; +import org.netbeans.spi.extexecution.open.FileOpenHandler; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; -import org.openide.loaders.DataObject; -import org.openide.text.Line; -import org.openide.text.Line.ShowOpenType; -import org.openide.text.Line.ShowVisibilityType; import org.openide.windows.OutputEvent; import org.openide.windows.OutputListener; /** - * An OutputProcessor takes filename and lineno information + * An OutputProcessor takes filename and line information * and produces hyperlinks. Actually resolving filenames * into real FileObjects is done lazily via user-supplied * FileLocators when the links are actually clicked. * * @author Tor Norbye, Petr Hejl */ -public class FindFileListener implements OutputListener { +public class FileListener implements OutputListener { - private static final Logger LOGGER = Logger.getLogger(FindFileListener.class.getName()); + private static final Logger LOGGER = Logger.getLogger(FileListener.class.getName()); private final String file; + private final int lineno; + private final FileLocator fileLocator; - public FindFileListener(String file, int lineno, FileLocator fileLocator) { - if (lineno < 0) { - lineno = 0; + private final FileOpenHandler handler; + + public FileListener(String file, int line, FileLocator fileLocator, + FileOpenHandler handler) { + + if (line < 0) { + line = 0; } // TODO : columns? this.file = file; - this.lineno = lineno; + this.lineno = line; this.fileLocator = fileLocator; + this.handler = handler; } public void outputLineSelected(OutputEvent ev) { @@ -99,10 +99,13 @@ FileObject fo = findFile(file); if (fo != null) { - open(fo, lineno); + handler.open(fo, lineno); } } + public void outputLineCleared(OutputEvent ev) { + } + private FileObject findFile(final String path) { if (fileLocator != null) { FileObject fo = fileLocator.find(path); @@ -113,73 +116,12 @@ // Perhaps it's an absolute path of some sort... try to resolve those // Absolute path? Happens for stack traces in libraries and such - File file = new File(path); - if (file.isFile()) { - return FileUtil.toFileObject(FileUtil.normalizeFile(file)); + File realFile = new File(path); + if (realFile.isFile()) { + return FileUtil.toFileObject(FileUtil.normalizeFile(realFile)); } else { LOGGER.warning("Cannot resolve file for \"" + path + "\" path."); return null; } } - - public void outputLineCleared(OutputEvent ev) { - } - - public static boolean open(final FileObject fo, final int lineno) { - if (!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - open(fo, lineno); - } - }); - - return true; // not exactly accurate, but.... - } - - try { - DataObject od = DataObject.find(fo); - EditorCookie ec = od.getCookie(EditorCookie.class); - LineCookie lc = od.getCookie(LineCookie.class); - - if ((ec != null) && (lc != null)) { - Document doc = ec.openDocument(); - - if (doc != null) { - int line = lineno; - - if (line < 1) { - line = 1; - } - - // XXX .size() call is super-slow for large files, see issue - // #126531. So we fallback to catching IOOBE -// int nOfLines = lines.getLines().size(); -// if (line > nOfLines) { -// line = nOfLines; -// } - try { - Line.Set lines = lc.getLineSet(); - Line l = lines.getCurrent(line - 1); - if (l != null) { - l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS); - return true; - } - } catch (IndexOutOfBoundsException ioobe) { - // OK, since .size() cannot be used, see above - } - } - } - - OpenCookie oc = od.getCookie(OpenCookie.class); - - if (oc != null) { - oc.open(); - return true; - } - } catch (IOException e) { - LOGGER.log(Level.INFO, null, e); - } - - return false; - } } diff --git a/extexecution/src/org/netbeans/modules/extexecution/print/UrlListener.java b/extexecution/src/org/netbeans/modules/extexecution/print/UrlListener.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/modules/extexecution/print/UrlListener.java @@ -0,0 +1,76 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.extexecution.print; + +import java.net.URL; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; +import org.openide.windows.OutputEvent; +import org.openide.windows.OutputListener; + +/** + * + * @author Petr Hejl + */ +public class UrlListener implements OutputListener { + + private final URL url; + + private final HttpOpenHandler handler; + + public UrlListener(URL url, HttpOpenHandler handler) { + this.url = url; + this.handler = handler; + } + + public void outputLineAction(OutputEvent ev) { + handler.open(url); + } + + public void outputLineCleared(OutputEvent ev) { + // noop + } + + public void outputLineSelected(OutputEvent ev) { + // noop + } + +} diff --git a/extexecution/src/org/netbeans/modules/extexecution/resources/Bundle.properties b/extexecution/src/org/netbeans/modules/extexecution/resources/Bundle.properties --- a/extexecution/src/org/netbeans/modules/extexecution/resources/Bundle.properties +++ b/extexecution/src/org/netbeans/modules/extexecution/resources/Bundle.properties @@ -40,7 +40,7 @@ # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. -OpenIDE-Module-Name=External Execution Support +OpenIDE-Module-Name=External Execution API OpenIDE-Module-Display-Category=Base IDE OpenIDE-Module-Short-Description=Supports execution of external processes OpenIDE-Module-Long-Description=Supports execution of external processes. diff --git a/extexecution/src/org/netbeans/spi/extexecution/open/FileOpenHandler.java b/extexecution/src/org/netbeans/spi/extexecution/open/FileOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/spi/extexecution/open/FileOpenHandler.java @@ -0,0 +1,65 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.spi.extexecution.open; + +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.extexecution.print.LineConvertor; +import org.netbeans.api.extexecution.print.LineConvertors; +import org.openide.filesystems.FileObject; + +/** + * Defines a handler for file opening. May be used by default + * {@link LineConvertor}s provided by {@link LineConvertors}. + * + * @author Petr Hejl + * @since 1.33 + */ +public interface FileOpenHandler { + + /** + * Opens a file at the given line. + * + * @param file the file to open + * @param line the line of the while which should be make visible + */ + void open(@NonNull FileObject file, int line); +} diff --git a/extexecution/src/org/netbeans/spi/extexecution/open/HttpOpenHandler.java b/extexecution/src/org/netbeans/spi/extexecution/open/HttpOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/spi/extexecution/open/HttpOpenHandler.java @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.spi.extexecution.open; + +import java.net.URL; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.extexecution.print.LineConvertor; +import org.netbeans.api.extexecution.print.LineConvertors; + +/** + * Defines a handler for HTTP URL opening. May be used by default + * {@link LineConvertor}s provided by {@link LineConvertors}. + * + * @author Petr Hejl + * @since 1.33 + */ +public interface HttpOpenHandler { + + /** + * Opens the URL. + * + * @param url URL to open + */ + void open(@NonNull URL url); +} diff --git a/extexecution/src/org/netbeans/spi/extexecution/open/OptionOpenHandler.java b/extexecution/src/org/netbeans/spi/extexecution/open/OptionOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/src/org/netbeans/spi/extexecution/open/OptionOpenHandler.java @@ -0,0 +1,63 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.spi.extexecution.open; + +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.extexecution.ExecutionDescriptor; + +/** + * Defines a handler for options dialog opening. There has to be a handler + * in the system for {@link ExecutionDescriptor#optionsPath(String)} in order + * to work properly. + * + * @author Petr Hejl + * @since 1.33 + */ +public interface OptionOpenHandler { + + /** + * Opens the option dialog displaying options specified by the path. + * + * @param optionsPath the path describing options to display + */ + void open(@NonNull String optionsPath); +} diff --git a/extexecution/src/org/netbeans/spi/extexecution/destroy/package-info.java b/extexecution/src/org/netbeans/spi/extexecution/open/package-info.java copy from extexecution/src/org/netbeans/spi/extexecution/destroy/package-info.java copy to extexecution/src/org/netbeans/spi/extexecution/open/package-info.java --- a/extexecution/src/org/netbeans/spi/extexecution/destroy/package-info.java +++ b/extexecution/src/org/netbeans/spi/extexecution/open/package-info.java @@ -43,9 +43,13 @@ */ /** - * The support SPI for terminating external processes. + * The support SPI to allow pluggability of predefined + * {@link org.netbeans.api.extexecution.print.LineConvertors}. + * Also allows you to define way how option dialog should be opened. * - * @see org.netbeans.spi.extexecution.destroy.ProcessDestroyPerformer + * @see org.netbeans.spi.extexecution.open.FileOpenHandler + * @see org.netbeans.spi.extexecution.open.HttpOpenHandler + * @see org.netbeans.spi.extexecution.open.OptionOpenHandler */ -package org.netbeans.spi.extexecution.destroy; +package org.netbeans.spi.extexecution.open; diff --git a/extexecution/src/org/netbeans/spi/extexecution/startup/StartupExtenderImplementation.java b/extexecution/src/org/netbeans/spi/extexecution/startup/StartupExtenderImplementation.java --- a/extexecution/src/org/netbeans/spi/extexecution/startup/StartupExtenderImplementation.java +++ b/extexecution/src/org/netbeans/spi/extexecution/startup/StartupExtenderImplementation.java @@ -68,7 +68,7 @@ * start mode. * * @param context the lookup providing the contract between client - * and provider (see {@link StartupExtender#getStartupExtender} + * and provider (see {@link StartupExtender#getExtenders(Lookup context, StartupExtender.StartMode mode)} * for details) * @param mode the startup mode the client is going to use * @return the list of arguments to pass to the process diff --git a/extexecution/test/unit/src/org/netbeans/api/extexecution/print/LineConvertorsTest.java b/extexecution/test/unit/src/org/netbeans/api/extexecution/print/LineConvertorsTest.java --- a/extexecution/test/unit/src/org/netbeans/api/extexecution/print/LineConvertorsTest.java +++ b/extexecution/test/unit/src/org/netbeans/api/extexecution/print/LineConvertorsTest.java @@ -42,18 +42,18 @@ package org.netbeans.api.extexecution.print; -import org.netbeans.api.extexecution.print.ConvertedLine; -import org.netbeans.api.extexecution.print.LineConvertors; -import org.netbeans.api.extexecution.print.LineConvertor; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Pattern; import org.netbeans.junit.NbTestCase; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; import org.openide.filesystems.FileObject; +import org.openide.util.Lookup; import org.openide.windows.InputOutput; import org.openide.windows.OutputEvent; -import org.openide.windows.OutputListener; /** * @@ -205,6 +205,32 @@ } } + public void testHttpOpenHandler() throws MalformedURLException { + LineConvertor convertor = LineConvertors.httpUrl(); + + List lines = new ArrayList(); + assertNull(convertor.convert("nourl1")); + lines.addAll(convertor.convert("NetBeans site: http://www.netbeans.org")); + lines.addAll(convertor.convert("https://www.netbeans.org")); + + assertEquals(2, lines.size()); + assertEquals("NetBeans site: http://www.netbeans.org", lines.get(0).getText()); + assertEquals("https://www.netbeans.org", lines.get(1).getText()); + + for (ConvertedLine line : lines) { + assertNotNull(line.getListener()); + line.getListener().outputLineAction(null); + } + + HttpOpenHandler handler = Lookup.getDefault().lookup(HttpOpenHandler.class); + assertTrue(handler instanceof TestHttpOpenHandler); + + List opened = ((TestHttpOpenHandler) handler).getOpened(); + assertEquals(2, opened.size()); + assertEquals(new URL("http://www.netbeans.org"), opened.get(0)); + assertEquals(new URL("https://www.netbeans.org"), opened.get(1)); + } + private static void assertEquals(List expected, List value) { assertEquals(expected.size(), value.size()); for (int i = 0; i < expected.size(); i++) { diff --git a/extexecution/test/unit/src/org/netbeans/api/extexecution/print/TestHttpOpenHandler.java b/extexecution/test/unit/src/org/netbeans/api/extexecution/print/TestHttpOpenHandler.java new file mode 100644 --- /dev/null +++ b/extexecution/test/unit/src/org/netbeans/api/extexecution/print/TestHttpOpenHandler.java @@ -0,0 +1,67 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.api.extexecution.print; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import org.netbeans.spi.extexecution.open.HttpOpenHandler; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Petr Hejl + */ +@ServiceProvider(service=HttpOpenHandler.class) +public class TestHttpOpenHandler implements HttpOpenHandler { + + private final List opened = new ArrayList(); + + @Override + public void open(URL url) { + opened.add(url); + } + + public List getOpened() { + return opened; + } +} diff --git a/libs.jna/manifest.mf b/libs.jna/manifest.mf --- a/libs.jna/manifest.mf +++ b/libs.jna/manifest.mf @@ -4,4 +4,4 @@ OpenIDE-Module-Install: org/netbeans/libs/jna/Installer.class OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/jna/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 1.22 +OpenIDE-Module-Specification-Version: 1.23 diff --git a/libs.jna/nbproject/project.xml b/libs.jna/nbproject/project.xml --- a/libs.jna/nbproject/project.xml +++ b/libs.jna/nbproject/project.xml @@ -72,7 +72,7 @@ org.netbeans.core.browser.xulrunner org.netbeans.core.nativeaccess org.netbeans.modules.dlight.nativeexecution - org.netbeans.modules.extexecution.destroy + org.netbeans.modules.extexecution.impl org.netbeans.modules.keyring.impl org.netbeans.modules.masterfs.windows org.netbeans.modules.masterfs.linux diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties --- a/nbbuild/cluster.properties +++ b/nbbuild/cluster.properties @@ -285,7 +285,7 @@ editor.util,\ extbrowser,\ extexecution,\ - extexecution.destroy,\ + extexecution.impl,\ git,\ glassfish.common,\ gototest,\