Sketch of #191488.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scrapbook/build.xml Wed May 30 19:26:38 2012 -0400
1.3 @@ -0,0 +1,5 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<project basedir="." default="netbeans" name="contrib/scrapbook">
1.6 + <description>Builds, tests, and runs the project org.netbeans.modules.scrapbook</description>
1.7 + <import file="../../nbbuild/templates/projectized.xml"/>
1.8 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scrapbook/manifest.mf Wed May 30 19:26:38 2012 -0400
2.3 @@ -0,0 +1,5 @@
2.4 +Manifest-Version: 1.0
2.5 +OpenIDE-Module: org.netbeans.modules.scrapbook
2.6 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/scrapbook/Bundle.properties
2.7 +OpenIDE-Module-Specification-Version: 1.0
2.8 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/scrapbook/nbproject/project.properties Wed May 30 19:26:38 2012 -0400
3.3 @@ -0,0 +1,2 @@
3.4 +javac.source=1.6
3.5 +javac.compilerargs=-Xlint -Xlint:-serial
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/scrapbook/nbproject/project.xml Wed May 30 19:26:38 2012 -0400
4.3 @@ -0,0 +1,128 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
4.6 + <type>org.netbeans.modules.apisupport.project</type>
4.7 + <configuration>
4.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
4.9 + <code-name-base>org.netbeans.modules.scrapbook</code-name-base>
4.10 + <module-dependencies>
4.11 + <dependency>
4.12 + <code-name-base>org.netbeans.api.java.classpath</code-name-base>
4.13 + <build-prerequisite/>
4.14 + <compile-dependency/>
4.15 + <run-dependency>
4.16 + <release-version>1</release-version>
4.17 + <specification-version>1.33</specification-version>
4.18 + </run-dependency>
4.19 + </dependency>
4.20 + <dependency>
4.21 + <code-name-base>org.netbeans.core.multiview</code-name-base>
4.22 + <build-prerequisite/>
4.23 + <compile-dependency/>
4.24 + <run-dependency>
4.25 + <release-version>1</release-version>
4.26 + <specification-version>1.29</specification-version>
4.27 + </run-dependency>
4.28 + </dependency>
4.29 + <dependency>
4.30 + <code-name-base>org.netbeans.modules.java.project</code-name-base>
4.31 + <build-prerequisite/>
4.32 + <compile-dependency/>
4.33 + <run-dependency>
4.34 + <release-version>1</release-version>
4.35 + <specification-version>1.46</specification-version>
4.36 + </run-dependency>
4.37 + </dependency>
4.38 + <dependency>
4.39 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
4.40 + <build-prerequisite/>
4.41 + <compile-dependency/>
4.42 + <run-dependency>
4.43 + <release-version>1</release-version>
4.44 + <specification-version>1.46</specification-version>
4.45 + </run-dependency>
4.46 + </dependency>
4.47 + <dependency>
4.48 + <code-name-base>org.openide.awt</code-name-base>
4.49 + <build-prerequisite/>
4.50 + <compile-dependency/>
4.51 + <run-dependency>
4.52 + <specification-version>7.45</specification-version>
4.53 + </run-dependency>
4.54 + </dependency>
4.55 + <dependency>
4.56 + <code-name-base>org.openide.dialogs</code-name-base>
4.57 + <build-prerequisite/>
4.58 + <compile-dependency/>
4.59 + <run-dependency>
4.60 + <specification-version>7.25</specification-version>
4.61 + </run-dependency>
4.62 + </dependency>
4.63 + <dependency>
4.64 + <code-name-base>org.openide.filesystems</code-name-base>
4.65 + <build-prerequisite/>
4.66 + <compile-dependency/>
4.67 + <run-dependency>
4.68 + <specification-version>7.62</specification-version>
4.69 + </run-dependency>
4.70 + </dependency>
4.71 + <dependency>
4.72 + <code-name-base>org.openide.io</code-name-base>
4.73 + <build-prerequisite/>
4.74 + <compile-dependency/>
4.75 + <run-dependency>
4.76 + <specification-version>1.31</specification-version>
4.77 + </run-dependency>
4.78 + </dependency>
4.79 + <dependency>
4.80 + <code-name-base>org.openide.loaders</code-name-base>
4.81 + <build-prerequisite/>
4.82 + <compile-dependency/>
4.83 + <run-dependency>
4.84 + <specification-version>7.37</specification-version>
4.85 + </run-dependency>
4.86 + </dependency>
4.87 + <dependency>
4.88 + <code-name-base>org.openide.nodes</code-name-base>
4.89 + <build-prerequisite/>
4.90 + <compile-dependency/>
4.91 + <run-dependency>
4.92 + <specification-version>7.28</specification-version>
4.93 + </run-dependency>
4.94 + </dependency>
4.95 + <dependency>
4.96 + <code-name-base>org.openide.text</code-name-base>
4.97 + <build-prerequisite/>
4.98 + <compile-dependency/>
4.99 + <run-dependency>
4.100 + <specification-version>6.49</specification-version>
4.101 + </run-dependency>
4.102 + </dependency>
4.103 + <dependency>
4.104 + <code-name-base>org.openide.util</code-name-base>
4.105 + <build-prerequisite/>
4.106 + <compile-dependency/>
4.107 + <run-dependency>
4.108 + <specification-version>8.24</specification-version>
4.109 + </run-dependency>
4.110 + </dependency>
4.111 + <dependency>
4.112 + <code-name-base>org.openide.util.lookup</code-name-base>
4.113 + <build-prerequisite/>
4.114 + <compile-dependency/>
4.115 + <run-dependency>
4.116 + <specification-version>8.15</specification-version>
4.117 + </run-dependency>
4.118 + </dependency>
4.119 + <dependency>
4.120 + <code-name-base>org.openide.windows</code-name-base>
4.121 + <build-prerequisite/>
4.122 + <compile-dependency/>
4.123 + <run-dependency>
4.124 + <specification-version>6.55</specification-version>
4.125 + </run-dependency>
4.126 + </dependency>
4.127 + </module-dependencies>
4.128 + <public-packages/>
4.129 + </data>
4.130 + </configuration>
4.131 +</project>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/Bundle.properties Wed May 30 19:26:38 2012 -0400
5.3 @@ -0,0 +1,1 @@
5.4 +OpenIDE-Module-Name=Scrapbook
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/OpenScrapbookAction.java Wed May 30 19:26:38 2012 -0400
6.3 @@ -0,0 +1,84 @@
6.4 +/*
6.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6.6 + *
6.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
6.8 + *
6.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6.10 + * Other names may be trademarks of their respective owners.
6.11 + *
6.12 + * The contents of this file are subject to the terms of either the GNU
6.13 + * General Public License Version 2 only ("GPL") or the Common
6.14 + * Development and Distribution License("CDDL") (collectively, the
6.15 + * "License"). You may not use this file except in compliance with the
6.16 + * License. You can obtain a copy of the License at
6.17 + * http://www.netbeans.org/cddl-gplv2.html
6.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
6.19 + * specific language governing permissions and limitations under the
6.20 + * License. When distributing the software, include this License Header
6.21 + * Notice in each file and include the License file at
6.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
6.23 + * particular file as subject to the "Classpath" exception as provided
6.24 + * by Oracle in the GPL Version 2 section of the License file that
6.25 + * accompanied this code. If applicable, add the following below the
6.26 + * License Header, with the fields enclosed by brackets [] replaced by
6.27 + * your own identifying information:
6.28 + * "Portions Copyrighted [year] [name of copyright owner]"
6.29 + *
6.30 + * If you wish your version of this file to be governed by only the CDDL
6.31 + * or only the GPL Version 2, indicate your decision by adding
6.32 + * "[Contributor] elects to include this software in this distribution
6.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
6.34 + * single choice of license, a recipient has the option to distribute
6.35 + * your version of this file under either the CDDL, the GPL Version 2 or
6.36 + * to extend the choice of license to its licensees as provided above.
6.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
6.38 + * Version 2 license, then the option applies only if the new code is
6.39 + * made subject to such option by the copyright holder.
6.40 + *
6.41 + * Contributor(s):
6.42 + *
6.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
6.44 + */
6.45 +
6.46 +package org.netbeans.modules.scrapbook;
6.47 +
6.48 +import java.awt.event.ActionListener;
6.49 +import java.awt.event.ActionEvent;
6.50 +import java.io.IOException;
6.51 +import org.netbeans.api.project.Project;
6.52 +import org.netbeans.api.project.ProjectUtils;
6.53 +
6.54 +import org.openide.awt.ActionRegistration;
6.55 +import org.openide.awt.ActionReference;
6.56 +import org.openide.awt.ActionID;
6.57 +import org.openide.filesystems.FileObject;
6.58 +import org.openide.filesystems.FileUtil;
6.59 +import org.openide.loaders.DataObject;
6.60 +import org.openide.text.Line;
6.61 +import org.openide.text.NbDocument;
6.62 +import org.openide.util.Exceptions;
6.63 +import org.openide.util.NbBundle.Messages;
6.64 +
6.65 +@ActionID(category="Project", id="org.netbeans.modules.scrapbook.OpenScrapbookAction")
6.66 +@ActionRegistration(displayName="#CTL_OpenScrapbookAction")
6.67 +@ActionReference(path="Projects/Actions", position=211)
6.68 +@Messages("CTL_OpenScrapbookAction=Open Scrapbook")
6.69 +public final class OpenScrapbookAction implements ActionListener {
6.70 +
6.71 + private final Project project;
6.72 +
6.73 + public OpenScrapbookAction(Project context) {
6.74 + this.project = context;
6.75 + }
6.76 +
6.77 + @Override public void actionPerformed(ActionEvent ev) {
6.78 + try {
6.79 + FileObject scrapbook = FileUtil.createData(ProjectUtils.getCacheDirectory(project, OpenScrapbookAction.class), "scrapbook");
6.80 + scrapbook.setAttribute("project", project.getProjectDirectory().toURL());
6.81 + NbDocument.openDocument(DataObject.find(scrapbook), 0, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
6.82 + } catch (IOException ex) {
6.83 + Exceptions.printStackTrace(ex);
6.84 + }
6.85 + }
6.86 +
6.87 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/RunSnippetAction.java Wed May 30 19:26:38 2012 -0400
7.3 @@ -0,0 +1,88 @@
7.4 +/*
7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
7.6 + *
7.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
7.8 + *
7.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7.10 + * Other names may be trademarks of their respective owners.
7.11 + *
7.12 + * The contents of this file are subject to the terms of either the GNU
7.13 + * General Public License Version 2 only ("GPL") or the Common
7.14 + * Development and Distribution License("CDDL") (collectively, the
7.15 + * "License"). You may not use this file except in compliance with the
7.16 + * License. You can obtain a copy of the License at
7.17 + * http://www.netbeans.org/cddl-gplv2.html
7.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
7.19 + * specific language governing permissions and limitations under the
7.20 + * License. When distributing the software, include this License Header
7.21 + * Notice in each file and include the License file at
7.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
7.23 + * particular file as subject to the "Classpath" exception as provided
7.24 + * by Oracle in the GPL Version 2 section of the License file that
7.25 + * accompanied this code. If applicable, add the following below the
7.26 + * License Header, with the fields enclosed by brackets [] replaced by
7.27 + * your own identifying information:
7.28 + * "Portions Copyrighted [year] [name of copyright owner]"
7.29 + *
7.30 + * If you wish your version of this file to be governed by only the CDDL
7.31 + * or only the GPL Version 2, indicate your decision by adding
7.32 + * "[Contributor] elects to include this software in this distribution
7.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
7.34 + * single choice of license, a recipient has the option to distribute
7.35 + * your version of this file under either the CDDL, the GPL Version 2 or
7.36 + * to extend the choice of license to its licensees as provided above.
7.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
7.38 + * Version 2 license, then the option applies only if the new code is
7.39 + * made subject to such option by the copyright holder.
7.40 + *
7.41 + * Contributor(s):
7.42 + *
7.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
7.44 + */
7.45 +
7.46 +package org.netbeans.modules.scrapbook;
7.47 +
7.48 +import java.awt.event.ActionEvent;
7.49 +import java.awt.event.ActionListener;
7.50 +import javax.swing.JEditorPane;
7.51 +import org.netbeans.api.java.classpath.ClassPath;
7.52 +import org.openide.awt.ActionID;
7.53 +import org.openide.awt.ActionReference;
7.54 +import org.openide.awt.ActionRegistration;
7.55 +import org.openide.awt.StatusDisplayer;
7.56 +import org.openide.cookies.EditorCookie;
7.57 +import org.openide.util.Exceptions;
7.58 +import org.openide.util.NbBundle;
7.59 +
7.60 +@ActionID(category="Project", id="org.netbeans.modules.scrapbook.RunSnippetAction")
7.61 +@ActionRegistration(displayName="#CTL_RunSnippetAction")
7.62 +@ActionReference(path="Editors/" + ScrapbookDataObject.MIME + "/Popup", position=100)
7.63 +@NbBundle.Messages("CTL_RunSnippetAction=Run Snippet")
7.64 +public class RunSnippetAction implements ActionListener {
7.65 +
7.66 + private final EditorCookie ec;
7.67 +
7.68 + public RunSnippetAction(EditorCookie ec) {
7.69 + this.ec = ec;
7.70 + }
7.71 +
7.72 + @Override public void actionPerformed(ActionEvent e) {
7.73 + JEditorPane[] panes = ec.getOpenedPanes();
7.74 + if (panes == null) {
7.75 + return;
7.76 + }
7.77 + JEditorPane pane = panes[0];
7.78 + String sel = pane.getSelectedText();
7.79 + if (sel == null) {
7.80 + StatusDisplayer.getDefault().setStatusText("Select a block of code to run."); // XXX I18N
7.81 + return;
7.82 + }
7.83 + ClassPath cp = Runner.classpath(pane, ClassPath.EXECUTE);
7.84 + try {
7.85 + Runner.run("public class _ {\npublic static void run() {\n" + sel + "\n}\npublic static java.io.PrintWriter _writer;\nprivate static void println(Object o) {\n_writer.println(o);\n}\n}\n", cp);
7.86 + } catch (Exception ex) {
7.87 + Exceptions.printStackTrace(ex);
7.88 + }
7.89 + }
7.90 +
7.91 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/Runner.java Wed May 30 19:26:38 2012 -0400
8.3 @@ -0,0 +1,166 @@
8.4 +/*
8.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8.6 + *
8.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
8.8 + *
8.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8.10 + * Other names may be trademarks of their respective owners.
8.11 + *
8.12 + * The contents of this file are subject to the terms of either the GNU
8.13 + * General Public License Version 2 only ("GPL") or the Common
8.14 + * Development and Distribution License("CDDL") (collectively, the
8.15 + * "License"). You may not use this file except in compliance with the
8.16 + * License. You can obtain a copy of the License at
8.17 + * http://www.netbeans.org/cddl-gplv2.html
8.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
8.19 + * specific language governing permissions and limitations under the
8.20 + * License. When distributing the software, include this License Header
8.21 + * Notice in each file and include the License file at
8.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
8.23 + * particular file as subject to the "Classpath" exception as provided
8.24 + * by Oracle in the GPL Version 2 section of the License file that
8.25 + * accompanied this code. If applicable, add the following below the
8.26 + * License Header, with the fields enclosed by brackets [] replaced by
8.27 + * your own identifying information:
8.28 + * "Portions Copyrighted [year] [name of copyright owner]"
8.29 + *
8.30 + * If you wish your version of this file to be governed by only the CDDL
8.31 + * or only the GPL Version 2, indicate your decision by adding
8.32 + * "[Contributor] elects to include this software in this distribution
8.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
8.34 + * single choice of license, a recipient has the option to distribute
8.35 + * your version of this file under either the CDDL, the GPL Version 2 or
8.36 + * to extend the choice of license to its licensees as provided above.
8.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
8.38 + * Version 2 license, then the option applies only if the new code is
8.39 + * made subject to such option by the copyright holder.
8.40 + *
8.41 + * Contributor(s):
8.42 + *
8.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
8.44 + */
8.45 +
8.46 +package org.netbeans.modules.scrapbook;
8.47 +
8.48 +import java.io.File;
8.49 +import java.io.FileWriter;
8.50 +import java.io.IOException;
8.51 +import java.io.Writer;
8.52 +import java.net.MalformedURLException;
8.53 +import java.net.URL;
8.54 +import java.net.URLClassLoader;
8.55 +import java.util.ArrayList;
8.56 +import java.util.Arrays;
8.57 +import java.util.List;
8.58 +import javax.swing.JEditorPane;
8.59 +import javax.swing.text.Document;
8.60 +import javax.tools.Diagnostic;
8.61 +import javax.tools.DiagnosticListener;
8.62 +import javax.tools.JavaCompiler;
8.63 +import javax.tools.JavaFileObject;
8.64 +import javax.tools.StandardJavaFileManager;
8.65 +import javax.tools.ToolProvider;
8.66 +import org.netbeans.api.java.classpath.ClassPath;
8.67 +import org.netbeans.api.java.project.JavaProjectConstants;
8.68 +import org.netbeans.api.project.Project;
8.69 +import org.netbeans.api.project.ProjectManager;
8.70 +import org.netbeans.api.project.ProjectUtils;
8.71 +import org.netbeans.api.project.SourceGroup;
8.72 +import org.netbeans.spi.java.classpath.support.ClassPathSupport;
8.73 +import org.openide.filesystems.FileObject;
8.74 +import org.openide.filesystems.URLMapper;
8.75 +import org.openide.loaders.DataObject;
8.76 +import org.openide.util.Exceptions;
8.77 +import org.openide.windows.IOProvider;
8.78 +import org.openide.windows.InputOutput;
8.79 +
8.80 +public class Runner {
8.81 +
8.82 + public static void run(String clazz, ClassPath cp/*, ClassPath bootcp*/) throws Exception {
8.83 + JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
8.84 + final InputOutput io = IOProvider.getDefault().getIO("Scrapbook", false);
8.85 + //io.getOut().reset();
8.86 + DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
8.87 + @Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
8.88 + io.getErr().println(diagnostic); // XXX format, hyperlink, etc.
8.89 + }
8.90 + };
8.91 + // XXX implement JavaFileManager directly for speed and robustness
8.92 + StandardJavaFileManager fm = javac.getStandardFileManager(listener, null, null);
8.93 + File d = new File(System.getProperty("java.io.tmpdir"));
8.94 + new File(d, "_.class").delete();
8.95 + final File s = new File(d, "_.java");
8.96 + Writer w = new FileWriter(s); // XXX use UTF-8
8.97 + try {
8.98 + w.write(clazz);
8.99 + w.flush();
8.100 + } finally {
8.101 + w.close();
8.102 + }
8.103 + List<String> opts = Arrays.asList("-d", d.getAbsolutePath(), "-classpath", cp.toString(ClassPath.PathConversionMode.WARN)/*, "-bootclasspath", bootcp.toString(ClassPath.PathConversionMode.WARN)*/);
8.104 + if (!javac.getTask(io.getErr(), fm, listener, opts, null, fm.getJavaFileObjects(s)).call()) {
8.105 + return;
8.106 + }
8.107 + fm.flush();
8.108 + fm.close();
8.109 + List<URL> runcp = new ArrayList<URL>();
8.110 + try {
8.111 + runcp.add(d.toURI().toURL());
8.112 + } catch (MalformedURLException ex) {
8.113 + Exceptions.printStackTrace(ex);
8.114 + return;
8.115 + }
8.116 + for (ClassPath.Entry e : cp.entries()) {
8.117 + runcp.add(e.getURL());
8.118 + }
8.119 + /*
8.120 + for (ClassPath.Entry e : bootcp.entries()) {
8.121 + runcp.add(e.getURL());
8.122 + }
8.123 + */
8.124 + ClassLoader loader = new URLClassLoader(runcp.toArray(new URL[runcp.size()]), ClassLoader.getSystemClassLoader().getParent());
8.125 + Class<?> c = loader.loadClass("_");
8.126 + c.getField("_writer").set(null, io.getOut());
8.127 + c.getMethod("run").invoke(null);
8.128 + }
8.129 +
8.130 + public static ClassPath classpath(JEditorPane pane, String classpathType) {
8.131 + Object o = pane.getDocument().getProperty(Document.StreamDescriptionProperty);
8.132 + FileObject f;
8.133 + if (o instanceof FileObject) {
8.134 + f = (FileObject) o;
8.135 + } else if (o instanceof DataObject) {
8.136 + f = ((DataObject) o).getPrimaryFile();
8.137 + } else {
8.138 + return ClassPath.EMPTY;
8.139 + }
8.140 + Object projectU = f.getAttribute("project");
8.141 + if (!(projectU instanceof URL)) {
8.142 + return ClassPath.EMPTY;
8.143 + }
8.144 + FileObject projectD = URLMapper.findFileObject((URL) projectU);
8.145 + if (projectD == null || !projectD.isFolder()) {
8.146 + return ClassPath.EMPTY;
8.147 + }
8.148 + Project p;
8.149 + try {
8.150 + p = ProjectManager.getDefault().findProject(projectD);
8.151 + } catch (IOException x) {
8.152 + return ClassPath.EMPTY;
8.153 + }
8.154 + if (p == null) {
8.155 + return ClassPath.EMPTY;
8.156 + }
8.157 + List<ClassPath> all = new ArrayList<ClassPath>();
8.158 + for (SourceGroup g : ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
8.159 + ClassPath cp = ClassPath.getClassPath(g.getRootFolder(), classpathType);
8.160 + if (cp != null) {
8.161 + all.add(cp);
8.162 + }
8.163 + }
8.164 + return ClassPathSupport.createProxyClassPath(all.toArray(new ClassPath[all.size()]));
8.165 + }
8.166 +
8.167 + private Runner() {}
8.168 +
8.169 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/ScrapbookDataObject.java Wed May 30 19:26:38 2012 -0400
9.3 @@ -0,0 +1,79 @@
9.4 +/*
9.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9.6 + *
9.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
9.8 + *
9.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
9.10 + * Other names may be trademarks of their respective owners.
9.11 + *
9.12 + * The contents of this file are subject to the terms of either the GNU
9.13 + * General Public License Version 2 only ("GPL") or the Common
9.14 + * Development and Distribution License("CDDL") (collectively, the
9.15 + * "License"). You may not use this file except in compliance with the
9.16 + * License. You can obtain a copy of the License at
9.17 + * http://www.netbeans.org/cddl-gplv2.html
9.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
9.19 + * specific language governing permissions and limitations under the
9.20 + * License. When distributing the software, include this License Header
9.21 + * Notice in each file and include the License file at
9.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
9.23 + * particular file as subject to the "Classpath" exception as provided
9.24 + * by Oracle in the GPL Version 2 section of the License file that
9.25 + * accompanied this code. If applicable, add the following below the
9.26 + * License Header, with the fields enclosed by brackets [] replaced by
9.27 + * your own identifying information:
9.28 + * "Portions Copyrighted [year] [name of copyright owner]"
9.29 + *
9.30 + * If you wish your version of this file to be governed by only the CDDL
9.31 + * or only the GPL Version 2, indicate your decision by adding
9.32 + * "[Contributor] elects to include this software in this distribution
9.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
9.34 + * single choice of license, a recipient has the option to distribute
9.35 + * your version of this file under either the CDDL, the GPL Version 2 or
9.36 + * to extend the choice of license to its licensees as provided above.
9.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
9.38 + * Version 2 license, then the option applies only if the new code is
9.39 + * made subject to such option by the copyright holder.
9.40 + *
9.41 + * Contributor(s):
9.42 + *
9.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
9.44 + */
9.45 +package org.netbeans.modules.scrapbook;
9.46 +
9.47 +import java.io.IOException;
9.48 +import org.netbeans.core.spi.multiview.MultiViewElement;
9.49 +import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
9.50 +import org.openide.filesystems.FileObject;
9.51 +import org.openide.filesystems.MIMEResolver;
9.52 +import org.openide.loaders.DataObject;
9.53 +import org.openide.loaders.DataObjectExistsException;
9.54 +import org.openide.loaders.MultiDataObject;
9.55 +import org.openide.loaders.MultiFileLoader;
9.56 +import org.openide.util.Lookup;
9.57 +import org.openide.util.NbBundle.Messages;
9.58 +import org.openide.windows.TopComponent;
9.59 +
9.60 +@Messages("LBL_Scrapbook_LOADER=Scrapbook pages")
9.61 +@MIMEResolver.Registration(displayName="#LBL_Scrapbook_LOADER", resource="resolver.xml", position=483)
9.62 +@DataObject.Registration(mimeType=ScrapbookDataObject.MIME, iconBase="org/netbeans/modules/scrapbook/editor.gif", displayName="#LBL_Scrapbook_LOADER", position=300)
9.63 +public class ScrapbookDataObject extends MultiDataObject {
9.64 +
9.65 + public static final String MIME = "text/x-java-scrapbook";
9.66 +
9.67 + public ScrapbookDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
9.68 + super(pf, loader);
9.69 + registerEditor(MIME, true);
9.70 + }
9.71 +
9.72 + @Override protected int associateLookup() {
9.73 + return 1;
9.74 + }
9.75 +
9.76 + @MultiViewElement.Registration(displayName = "#LBL_Scrapbook_EDITOR", iconBase="org/netbeans/modules/scrapbook/editor.gif", mimeType=MIME, persistenceType=TopComponent.PERSISTENCE_ALWAYS, preferredID="Scrapbook", position=1000)
9.77 + @Messages("LBL_Scrapbook_EDITOR=Source")
9.78 + public static MultiViewEditorElement createEditor(Lookup lkp) {
9.79 + return new MultiViewEditorElement(lkp);
9.80 + }
9.81 +
9.82 +}
10.1 Binary file scrapbook/src/org/netbeans/modules/scrapbook/editor.gif has changed
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/scrapbook/src/org/netbeans/modules/scrapbook/resolver.xml Wed May 30 19:26:38 2012 -0400
11.3 @@ -0,0 +1,49 @@
11.4 +<?xml version="1.0" encoding="UTF-8"?>
11.5 +<!--
11.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
11.7 +
11.8 +Copyright 2012 Oracle and/or its affiliates. All rights reserved.
11.9 +
11.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
11.11 +Other names may be trademarks of their respective owners.
11.12 +
11.13 +The contents of this file are subject to the terms of either the GNU
11.14 +General Public License Version 2 only ("GPL") or the Common
11.15 +Development and Distribution License("CDDL") (collectively, the
11.16 +"License"). You may not use this file except in compliance with the
11.17 +License. You can obtain a copy of the License at
11.18 +http://www.netbeans.org/cddl-gplv2.html
11.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
11.20 +specific language governing permissions and limitations under the
11.21 +License. When distributing the software, include this License Header
11.22 +Notice in each file and include the License file at
11.23 +nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
11.24 +particular file as subject to the "Classpath" exception as provided
11.25 +by Oracle in the GPL Version 2 section of the License file that
11.26 +accompanied this code. If applicable, add the following below the
11.27 +License Header, with the fields enclosed by brackets [] replaced by
11.28 +your own identifying information:
11.29 +"Portions Copyrighted [year] [name of copyright owner]"
11.30 +
11.31 +If you wish your version of this file to be governed by only the CDDL
11.32 +or only the GPL Version 2, indicate your decision by adding
11.33 +"[Contributor] elects to include this software in this distribution
11.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
11.35 +single choice of license, a recipient has the option to distribute
11.36 +your version of this file under either the CDDL, the GPL Version 2 or
11.37 +to extend the choice of license to its licensees as provided above.
11.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
11.39 +Version 2 license, then the option applies only if the new code is
11.40 +made subject to such option by the copyright holder.
11.41 +
11.42 +Contributor(s):
11.43 +
11.44 +Portions Copyrighted 2012 Sun Microsystems, Inc.
11.45 +-->
11.46 +<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.1//EN" "http://www.netbeans.org/dtds/mime-resolver-1_1.dtd">
11.47 +<MIME-resolver>
11.48 + <file>
11.49 + <name name="scrapbook"/>
11.50 + <resolver mime="text/x-java-scrapbook"/>
11.51 + </file>
11.52 +</MIME-resolver>