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

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

(-)a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/genfiles.properties (-4 / +4 lines)
Lines 1-8 Link Here
1
build.xml.data.CRC32=46b939b6
1
build.xml.data.CRC32=11daff52
2
build.xml.script.CRC32=f632a4aa
2
build.xml.script.CRC32=f632a4aa
3
build.xml.stylesheet.CRC32=79c3b980@1.37
3
build.xml.stylesheet.CRC32=a56c6a5b@1.44
4
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
4
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
5
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
nbproject/build-impl.xml.data.CRC32=46b939b6
6
nbproject/build-impl.xml.data.CRC32=11daff52
7
nbproject/build-impl.xml.script.CRC32=be1dd9b3
7
nbproject/build-impl.xml.script.CRC32=be1dd9b3
8
nbproject/build-impl.xml.stylesheet.CRC32=261c4bef@1.37
8
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.44
(-)a/apisupport.paintapp/PaintApp-suite/Paint/nbproject/project.xml (+9 lines)
Lines 7-12 Link Here
7
            <suite-component/>
7
            <suite-component/>
8
            <module-dependencies>
8
            <module-dependencies>
9
                <dependency>
9
                <dependency>
10
                    <code-name-base>org.netbeans.modules.settings</code-name-base>
11
                    <build-prerequisite/>
12
                    <compile-dependency/>
13
                    <run-dependency>
14
                        <release-version>1</release-version>
15
                        <specification-version>1.29</specification-version>
16
                    </run-dependency>
17
                </dependency>
18
                <dependency>
10
                    <code-name-base>org.netbeans.swing.colorchooser</code-name-base>
19
                    <code-name-base>org.netbeans.swing.colorchooser</code-name-base>
11
                    <build-prerequisite/>
20
                    <build-prerequisite/>
12
                    <compile-dependency/>
21
                    <compile-dependency/>
(-)a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/NewCanvasAction.java (-42 lines)
Lines 1-42 Link Here
1
/*
2
 * Copyright (c) 2010, Oracle. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are met:
6
 *
7
 * * Redistributions of source code must retain the above copyright notice,
8
 *   this list of conditions and the following disclaimer.
9
 *
10
 * * Redistributions in binary form must reproduce the above copyright notice,
11
 *   this list of conditions and the following disclaimer in the documentation
12
 *   and/or other materials provided with the distribution.
13
 *
14
 * * Neither the name of Oracle nor the names of its contributors
15
 *   may be used to endorse or promote products derived from this software without
16
 *   specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28
 * THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
package org.netbeans.paint;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
33
34
public final class NewCanvasAction implements ActionListener {
35
36
    @Override
37
    public void actionPerformed(ActionEvent e) {
38
        PaintTopComponent tc = new PaintTopComponent();
39
        tc.open();
40
        tc.requestActive();
41
    }
42
}
(-)a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/PaintTopComponent.java (-10 / +30 lines)
Lines 47-55 Link Here
47
import javax.swing.JToolBar;
47
import javax.swing.JToolBar;
48
import javax.swing.event.ChangeEvent;
48
import javax.swing.event.ChangeEvent;
49
import javax.swing.event.ChangeListener;
49
import javax.swing.event.ChangeListener;
50
import org.netbeans.api.settings.ConvertAsProperties;
50
import org.netbeans.swing.colorchooser.ColorChooser;
51
import org.netbeans.swing.colorchooser.ColorChooser;
51
import org.openide.DialogDisplayer;
52
import org.openide.DialogDisplayer;
52
import org.openide.NotifyDescriptor;
53
import org.openide.NotifyDescriptor;
54
import org.openide.awt.ActionID;
55
import org.openide.awt.ActionReference;
56
import org.openide.awt.ActionReferences;
57
import org.openide.awt.ActionRegistration;
53
import org.openide.awt.StatusDisplayer;
58
import org.openide.awt.StatusDisplayer;
54
import org.openide.cookies.SaveCookie;
59
import org.openide.cookies.SaveCookie;
55
import org.openide.filesystems.FileChooserBuilder;
60
import org.openide.filesystems.FileChooserBuilder;
Lines 62-68 Link Here
62
import org.openide.util.lookup.InstanceContent;
67
import org.openide.util.lookup.InstanceContent;
63
import org.openide.windows.TopComponent;
68
import org.openide.windows.TopComponent;
64
69
70
@ConvertAsProperties(dtd = "-//org.netbeans.paint//PaintTopComponent//EN", autostore = false)
71
@TopComponent.Description(preferredID = "PaintTopComponent", iconBase = "/org/netbeans/paint/new_icon.png", persistenceType = TopComponent.PERSISTENCE_ALWAYS)
72
@TopComponent.Registration(mode = "editor", openAtStartup = true)
73
@ActionID(category = "Window", id = "org.netbeans.paint.PaintTopComponent")
74
@ActionRegistration(displayName = "#CTL_NewCanvasAction", iconBase = "/org/netbeans/paint/new_icon.png")
75
@ActionReferences({
76
    @ActionReference(path = "Menu/Window", position = 0),
77
    @ActionReference(path = "Toolbars/File", position = 0)
78
})
79
@TopComponent.OpenActionRegistration(displayName = "#CTL_NewCanvasAction")
65
public final class PaintTopComponent extends TopComponent implements ActionListener, ChangeListener {
80
public final class PaintTopComponent extends TopComponent implements ActionListener, ChangeListener {
81
66
    private static int ct = 0; //A counter you use to provide names for new images
82
    private static int ct = 0; //A counter you use to provide names for new images
67
    private final PaintCanvas canvas = new PaintCanvas(); //The component the user draws on
83
    private final PaintCanvas canvas = new PaintCanvas(); //The component the user draws on
68
    private final JComponent preview = canvas.getBrushSizeView(); //A component in the toolbar that shows the paintbrush size
84
    private final JComponent preview = canvas.getBrushSizeView(); //A component in the toolbar that shows the paintbrush size
Lines 73-80 Link Here
73
    private final JLabel label = new JLabel(
89
    private final JLabel label = new JLabel(
74
            NbBundle.getMessage(PaintTopComponent.class, "LBL_Foreground")); //A label for the color chooser
90
            NbBundle.getMessage(PaintTopComponent.class, "LBL_Foreground")); //A label for the color chooser
75
    private final JLabel brushSizeLabel = new JLabel(
91
    private final JLabel brushSizeLabel = new JLabel(
76
                NbBundle.getMessage(PaintTopComponent.class, "LBL_BrushSize")); //A label for the brush size slider
92
            NbBundle.getMessage(PaintTopComponent.class, "LBL_BrushSize")); //A label for the brush size slider
77
78
    private final JSlider brushSizeSlider = new JSlider(1, 24); //A slider to set the brush size
93
    private final JSlider brushSizeSlider = new JSlider(1, 24); //A slider to set the brush size
79
    private InstanceContent content = new InstanceContent(); //The bag of stuff we add/remove the Saver from, and store the last-used file in
94
    private InstanceContent content = new InstanceContent(); //The bag of stuff we add/remove the Saver from, and store the last-used file in
80
    private Saver saver = new Saver();
95
    private Saver saver = new Saver();
Lines 90-95 Link Here
90
        //Connect our lookup to the rest of the system, so that
105
        //Connect our lookup to the rest of the system, so that
91
        //SaveAction will pay attention to whether or not the Saver is available
106
        //SaveAction will pay attention to whether or not the Saver is available
92
        associateLookup(new AbstractLookup(content));
107
        associateLookup(new AbstractLookup(content));
108
        //Enable the Print action for the canvas:
109
        putClientProperty("print.printable", true);
110
        //Disable the Save action by default:
93
        enableSaveAction(false);
111
        enableSaveAction(false);
94
    }
112
    }
95
113
Lines 101-107 Link Here
101
        brushSizeSlider.setValue(canvas.getBrushDiameter());
119
        brushSizeSlider.setValue(canvas.getBrushDiameter());
102
        brushSizeSlider.addChangeListener(this);
120
        brushSizeSlider.addChangeListener(this);
103
        color.setColor(canvas.getColor());
121
        color.setColor(canvas.getColor());
104
        color.setMaximumSize(new Dimension(16,16));
122
        color.setMaximumSize(new Dimension(16, 16));
105
        //Install the toolbar and the painting component:
123
        //Install the toolbar and the painting component:
106
        add(toolbar, BorderLayout.NORTH);
124
        add(toolbar, BorderLayout.NORTH);
107
        add(new JScrollPane(canvas), BorderLayout.CENTER);
125
        add(new JScrollPane(canvas), BorderLayout.CENTER);
Lines 212-225 Link Here
212
        }
230
        }
213
    }
231
    }
214
232
215
    //TopComponent boilerplate code
233
    void writeProperties(java.util.Properties p) {
216
    @Override
234
        // better to version settings since initial version as advocated at
217
    public int getPersistenceType() {
235
        // http://wiki.apidesign.org/wiki/PropertyFiles
218
        return PERSISTENCE_NEVER;
236
        p.setProperty("version", "1.0");
237
        // TODO store your settings
219
    }
238
    }
220
239
221
    @Override
240
    void readProperties(java.util.Properties p) {
222
    public String preferredID() {
241
        String version = p.getProperty("version");
223
        return "Image";
242
        // TODO read your settings according to their version
224
    }
243
    }
244
225
}
245
}
(-)a/apisupport.paintapp/PaintApp-suite/Paint/src/org/netbeans/paint/layer.xml (-15 lines)
Lines 3-15 Link Here
3
<filesystem>
3
<filesystem>
4
    <folder name="Actions">
4
    <folder name="Actions">
5
        <folder name="File">
5
        <folder name="File">
6
            <file name="org-netbeans-paint-NewCanvasAction.instance">
7
                <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
8
                <attr name="delegate" newvalue="org.netbeans.paint.NewCanvasAction"/>
9
                <attr name="displayName" bundlevalue="org.netbeans.paint.Bundle#CTL_NewCanvasAction"/>
10
                <attr name="iconBase" stringvalue="org/netbeans/paint/new_icon.png"/>
11
                <attr name="noIconInMenu" boolvalue="false"/>
12
            </file>
13
            <file name="org-openide-actions-SaveAction.instance">
6
            <file name="org-openide-actions-SaveAction.instance">
14
                <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.context"/>
7
                <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.context"/>
15
                <attr name="delegate" newvalue="org.openide.actions.SaveAction"/>
8
                <attr name="delegate" newvalue="org.openide.actions.SaveAction"/>
Lines 33-42 Link Here
33
    <folder name="Menu">
26
    <folder name="Menu">
34
        <folder name="File">
27
        <folder name="File">
35
            <attr name="position" intvalue="0"/>
28
            <attr name="position" intvalue="0"/>
36
            <file name="NewCanvasAction.shadow">
37
                <attr name="originalFile" stringvalue="Actions/File/org-netbeans-paint-NewCanvasAction.instance"/>
38
                <attr name="position" intvalue="0"/>
39
            </file>
40
            <file name="SaveAction.shadow">
29
            <file name="SaveAction.shadow">
41
                <attr name="originalFile" stringvalue="Actions/File/org-openide-actions-SaveAction.instance"/>
30
                <attr name="originalFile" stringvalue="Actions/File/org-openide-actions-SaveAction.instance"/>
42
                <attr name="position" intvalue="100"/>
31
                <attr name="position" intvalue="100"/>
Lines 76-85 Link Here
76
    </folder>
65
    </folder>
77
    <folder name="Toolbars">
66
    <folder name="Toolbars">
78
        <folder name="File">
67
        <folder name="File">
79
            <file name="NewCanvasAction.shadow">
80
                <attr name="originalFile" stringvalue="Actions/File/org-netbeans-paint-NewCanvasAction.instance"/>
81
                <attr name="position" intvalue="0"/>
82
            </file>
83
            <file name="SaveAction.shadow">
68
            <file name="SaveAction.shadow">
84
                <attr name="originalFile" stringvalue="Actions/File/org-openide-actions-SaveAction.instance"/>
69
                <attr name="originalFile" stringvalue="Actions/File/org-openide-actions-SaveAction.instance"/>
85
                <attr name="position" intvalue="100"/>
70
                <attr name="position" intvalue="100"/>
(-)a/apisupport.paintapp/PaintApp-suite/nbproject/genfiles.properties (-2 / +2 lines)
Lines 1-8 Link Here
1
build.xml.data.CRC32=3404ca48
1
build.xml.data.CRC32=3404ca48
2
build.xml.script.CRC32=5eaedf68
2
build.xml.script.CRC32=5eaedf68
3
build.xml.stylesheet.CRC32=531c622b@1.30.0.7
3
build.xml.stylesheet.CRC32=eaf9f76a@1.44
4
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
4
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
5
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
nbproject/build-impl.xml.data.CRC32=3404ca48
6
nbproject/build-impl.xml.data.CRC32=3404ca48
7
nbproject/build-impl.xml.script.CRC32=6830b8b0
7
nbproject/build-impl.xml.script.CRC32=6830b8b0
8
nbproject/build-impl.xml.stylesheet.CRC32=56de960a@1.37
8
nbproject/build-impl.xml.stylesheet.CRC32=183e6ef3@1.44

Return to bug 193724