diff --git a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/genfiles.properties b/apisupport.paintapp/PaintApp-suite/Paint/nbproject/genfiles.properties --- a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/genfiles.properties +++ b/apisupport.paintapp/PaintApp-suite/Paint/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=46b939b6 +build.xml.data.CRC32=11daff52 build.xml.script.CRC32=f632a4aa -build.xml.stylesheet.CRC32=79c3b980@1.37 +build.xml.stylesheet.CRC32=a56c6a5b@1.44 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=46b939b6 +nbproject/build-impl.xml.data.CRC32=11daff52 nbproject/build-impl.xml.script.CRC32=be1dd9b3 -nbproject/build-impl.xml.stylesheet.CRC32=261c4bef@1.37 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.44 diff --git a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/project.xml b/apisupport.paintapp/PaintApp-suite/Paint/nbproject/project.xml --- a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/project.xml +++ b/apisupport.paintapp/PaintApp-suite/Paint/nbproject/project.xml @@ -7,6 +7,15 @@ + org.netbeans.modules.settings + + + + 1 + 1.29 + + + org.netbeans.swing.colorchooser diff --git a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/NewCanvasAction.java b/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/NewCanvasAction.java deleted file mode 100644 --- a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/NewCanvasAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010, Oracle. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of Oracle nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.netbeans.paint; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -public final class NewCanvasAction implements ActionListener { - - @Override - public void actionPerformed(ActionEvent e) { - PaintTopComponent tc = new PaintTopComponent(); - tc.open(); - tc.requestActive(); - } -} diff --git a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/PaintTopComponent.java b/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/PaintTopComponent.java --- a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/PaintTopComponent.java +++ b/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/PaintTopComponent.java @@ -47,9 +47,14 @@ import javax.swing.JToolBar; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import org.netbeans.api.settings.ConvertAsProperties; import org.netbeans.swing.colorchooser.ColorChooser; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; import org.openide.awt.StatusDisplayer; import org.openide.cookies.SaveCookie; import org.openide.filesystems.FileChooserBuilder; @@ -62,7 +67,18 @@ import org.openide.util.lookup.InstanceContent; import org.openide.windows.TopComponent; +@ConvertAsProperties(dtd = "-//org.netbeans.paint//PaintTopComponent//EN", autostore = false) +@TopComponent.Description(preferredID = "PaintTopComponent", iconBase = "/org/netbeans/paint/new_icon.png", persistenceType = TopComponent.PERSISTENCE_ALWAYS) +@TopComponent.Registration(mode = "editor", openAtStartup = true) +@ActionID(category = "Window", id = "org.netbeans.paint.PaintTopComponent") +@ActionRegistration(displayName = "#CTL_NewCanvasAction", iconBase = "/org/netbeans/paint/new_icon.png") +@ActionReferences({ + @ActionReference(path = "Menu/Window", position = 0), + @ActionReference(path = "Toolbars/File", position = 0) +}) +@TopComponent.OpenActionRegistration(displayName = "#CTL_NewCanvasAction") public final class PaintTopComponent extends TopComponent implements ActionListener, ChangeListener { + private static int ct = 0; //A counter you use to provide names for new images private final PaintCanvas canvas = new PaintCanvas(); //The component the user draws on private final JComponent preview = canvas.getBrushSizeView(); //A component in the toolbar that shows the paintbrush size @@ -73,8 +89,7 @@ private final JLabel label = new JLabel( NbBundle.getMessage(PaintTopComponent.class, "LBL_Foreground")); //A label for the color chooser private final JLabel brushSizeLabel = new JLabel( - NbBundle.getMessage(PaintTopComponent.class, "LBL_BrushSize")); //A label for the brush size slider - + NbBundle.getMessage(PaintTopComponent.class, "LBL_BrushSize")); //A label for the brush size slider private final JSlider brushSizeSlider = new JSlider(1, 24); //A slider to set the brush size private InstanceContent content = new InstanceContent(); //The bag of stuff we add/remove the Saver from, and store the last-used file in private Saver saver = new Saver(); @@ -90,6 +105,9 @@ //Connect our lookup to the rest of the system, so that //SaveAction will pay attention to whether or not the Saver is available associateLookup(new AbstractLookup(content)); + //Enable the Print action for the canvas: + putClientProperty("print.printable", true); + //Disable the Save action by default: enableSaveAction(false); } @@ -101,7 +119,7 @@ brushSizeSlider.setValue(canvas.getBrushDiameter()); brushSizeSlider.addChangeListener(this); color.setColor(canvas.getColor()); - color.setMaximumSize(new Dimension(16,16)); + color.setMaximumSize(new Dimension(16, 16)); //Install the toolbar and the painting component: add(toolbar, BorderLayout.NORTH); add(new JScrollPane(canvas), BorderLayout.CENTER); @@ -212,14 +230,16 @@ } } - //TopComponent boilerplate code - @Override - public int getPersistenceType() { - return PERSISTENCE_NEVER; + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings } - @Override - public String preferredID() { - return "Image"; + void readProperties(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version } + } diff --git a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/layer.xml b/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/layer.xml --- a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/layer.xml +++ b/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/layer.xml @@ -3,13 +3,6 @@ - - - - - - - @@ -33,10 +26,6 @@ - - - - @@ -76,10 +65,6 @@ - - - - diff --git a/apisupport.paintapp/PaintApp-suite/nbproject/genfiles.properties b/apisupport.paintapp/PaintApp-suite/nbproject/genfiles.properties --- a/apisupport.paintapp/PaintApp-suite/nbproject/genfiles.properties +++ b/apisupport.paintapp/PaintApp-suite/nbproject/genfiles.properties @@ -1,8 +1,8 @@ build.xml.data.CRC32=3404ca48 build.xml.script.CRC32=5eaedf68 -build.xml.stylesheet.CRC32=531c622b@1.30.0.7 +build.xml.stylesheet.CRC32=eaf9f76a@1.44 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=3404ca48 nbproject/build-impl.xml.script.CRC32=6830b8b0 -nbproject/build-impl.xml.stylesheet.CRC32=56de960a@1.37 +nbproject/build-impl.xml.stylesheet.CRC32=183e6ef3@1.44