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 61635
Collapse All | Expand All

(-)palette/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.spi.palette/0
2
OpenIDE-Module: org.netbeans.spi.palette/0
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/palette/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/palette/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.0
4
OpenIDE-Module-Specification-Version: 1.1
5
OpenIDE-Module-Layer: org/netbeans/modules/palette/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/palette/resources/layer.xml
6
6
(-)palette/api/doc/changes/apichanges.xml (+22 lines)
Lines 87-92 Link Here
87
    </change>      
87
    </change>      
88
  </changes>
88
  </changes>
89
89
90
  <changes>
91
    <change>
92
        <api name="palette_api"/>
93
        <summary>Palette client support released</summary>
94
        <version major="1" minor="1"/>
95
        <date day="10" month="8" year="2005"/>
96
        <author login="lkotouc"/>
97
        <compatibility addition="yes"/>
98
        <description>
99
            The first release of the Palette client support. It involves namely DTD describing item definition file format
100
            and some implementation addons regarding definition file parsing and custom implementation class loading.
101
            
102
            The palette item implementor can ither directly provide the item body 
103
            or her own item class implementing <code>org.openide.text.ActiveEditorDrop</code> interface.
104
            
105
            Lookup that holds object(s) representing the selected item then associates 
106
            custom item class instance with the <code>org.openide.text.ActiveEditorDrop.class</code> key and 
107
            the body with <code>java.lang.String</code> key.
108
        </description>
109
    </change>      
110
  </changes>
111
  
90
    <!-- Now the surrounding HTML text and document structure: -->
112
    <!-- Now the surrounding HTML text and document structure: -->
91
113
92
    <htmlcontents>
114
    <htmlcontents>
(-)palette/nbproject/project.xml (+8 lines)
Lines 64-69 Link Here
64
                    </run-dependency>
64
                    </run-dependency>
65
                </dependency>
65
                </dependency>
66
                <dependency>
66
                <dependency>
67
                    <code-name-base>org.openide.text</code-name-base>
68
                    <build-prerequisite/>
69
                    <compile-dependency/>
70
                    <run-dependency>
71
                        <specification-version>6.5</specification-version>
72
                    </run-dependency>
73
                </dependency>
74
                <dependency>
67
                    <code-name-base>org.openide.util</code-name-base>
75
                    <code-name-base>org.openide.util</code-name-base>
68
                    <build-prerequisite/>
76
                    <build-prerequisite/>
69
                    <compile-dependency/>
77
                    <compile-dependency/>
(-)palette/src/org/netbeans/modules/palette/Bundle.properties (+3 lines)
Lines 72-74 Link Here
72
72
73
CTL_PaletteAction=Common Palette
73
CTL_PaletteAction=Common Palette
74
74
75
# Editor Palette Item parsing error messages
76
MSG_UnknownEditorPaletteItemVersion=Unknown editor palette item version.
77
MSG_UnsupportedEditorPaletteItemVersion=Unsupported editor palette item version.
(-)palette/src/org/netbeans/modules/palette/PaletteEnvironmentProvider.java (+279 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.palette;
15
import java.awt.Image;
16
import java.io.IOException;
17
import java.lang.ref.Reference;
18
import java.lang.ref.WeakReference;
19
import java.net.URL;
20
import java.util.ArrayList;
21
import org.openide.ErrorManager;
22
import org.openide.filesystems.FileObject;
23
import org.openide.loaders.DataObject;
24
import org.openide.loaders.Environment;
25
import org.openide.loaders.XMLDataObject;
26
import org.openide.nodes.Node;
27
import org.openide.text.ActiveEditorDrop;
28
import org.openide.util.Lookup;
29
import org.openide.util.NbBundle;
30
import org.openide.util.Utilities;
31
import org.openide.util.lookup.AbstractLookup;
32
import org.openide.util.lookup.InstanceContent;
33
import org.openide.util.lookup.Lookups;
34
import org.openide.xml.EntityCatalog;
35
import org.openide.xml.XMLUtil;
36
import org.xml.sax.SAXException;
37
import org.xml.sax.XMLReader;
38
39
/**
40
 *
41
 * @author Libor Kotouc
42
 */
43
public class PaletteEnvironmentProvider implements Environment.Provider {
44
    
45
    private static PaletteEnvironmentProvider createProvider() {
46
        return new PaletteEnvironmentProvider();
47
    }
48
49
    private PaletteEnvironmentProvider() {
50
    }
51
52
// ----------------   Environment.Provider ----------------------------    
53
    
54
    public Lookup getEnvironment(DataObject obj) {
55
56
        PaletteItemNodeFactory nodeFactory = new PaletteItemNodeFactory((XMLDataObject)obj);
57
        return nodeFactory.getLookup();
58
    }
59
60
    
61
    private static class PaletteItemNodeFactory implements InstanceContent.Convertor {
62
63
//        private static final String URL_PREFIX_INSTANCES = "PaletteItems/";
64
        
65
        private XMLDataObject xmlDataObject = null;
66
67
        private Lookup lookup = null;
68
        
69
        Reference refNode = new WeakReference(null);
70
71
        PaletteItemNodeFactory(XMLDataObject obj) {
72
73
            xmlDataObject = obj;
74
75
            InstanceContent content = new InstanceContent();
76
            content.add(Node.class, this);
77
78
            lookup = new AbstractLookup(content);
79
        }
80
        
81
        Lookup getLookup() {
82
            return lookup;
83
        }
84
        
85
        // ----------------   InstanceContent.Convertor ----------------------------    
86
87
        public Class type(Object obj) {
88
            return (Class)obj;
89
        }
90
91
        public String id(Object obj) {
92
            return obj.toString();
93
        }
94
95
        public String displayName(Object obj) {
96
            return ((Class)obj).getName();
97
        }
98
99
        public Object convert(Object obj) {
100
            Object o = null;
101
            if (obj == Node.class) {
102
                try {
103
                    o = getInstance();
104
                } catch (Exception ex) {
105
                    ErrorManager.getDefault().notify(ex);
106
                }
107
            }
108
            return o;
109
        }
110
        
111
        // ----------------   helper methods  ----------------------------    
112
        
113
        public PaletteItemNode getInstance() {
114
115
            synchronized (this) {
116
                PaletteItemNode node = (PaletteItemNode)refNode.get();
117
                if (node != null)
118
                    return node;
119
                
120
                FileObject file = xmlDataObject.getPrimaryFile();
121
                if (file.getSize() == 0L) // item file is empty
122
                    return null;
123
                
124
                PaletteItemHandler handler = new PaletteItemHandler();
125
                try {
126
                    XMLReader reader = XMLUtil.createXMLReader(true);
127
                    reader.setContentHandler(handler);
128
                    reader.setEntityResolver(EntityCatalog.getDefault());
129
                    String urlString = xmlDataObject.getPrimaryFile().getURL().toExternalForm();
130
                    reader.parse(urlString);
131
                }
132
                catch (SAXException saxe) {
133
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, saxe);
134
                } 
135
                catch (IOException ioe) {
136
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);
137
                }
138
139
                node = createPaletteItemNode(handler);
140
                refNode = new WeakReference(node);
141
                
142
                return node;
143
            }
144
        }
145
146
        private PaletteItemNode createPaletteItemNode(PaletteItemHandler handler) {
147
148
            String displayName = getDisplayName(handler.getBundleName(), handler.getDisplayNameKey(), handler.getInstanceName());
149
            String tooltip = getTooltip(handler.getBundleName(), handler.getTooltipKey(), handler.getInstanceName(), handler.getDisplayNameKey());
150
            Image icon16 = getIcon(handler.getIcon16URL());
151
            if (icon16 == null)
152
                icon16 = Utilities.loadImage("org/netbeans/editor/ext/palette/resources/unknown16.gif"); // NOI18N
153
            Image icon32 = getIcon(handler.getIcon32URL());
154
            if (icon32 == null)
155
                icon32 = Utilities.loadImage("org/netbeans/editor/ext/palette/resources/unknown32.gif"); // NOI18N
156
            
157
            
158
            ArrayList objectsToLookup = new ArrayList();
159
160
            ActiveEditorDrop drop = getActiveEditorDrop(handler.getInstanceName());
161
            if (drop != null)
162
                objectsToLookup.add(drop);
163
            if (handler.getBody() != null)
164
                objectsToLookup.add(handler.getBody());
165
            Lookup lookup = Lookups.fixed(objectsToLookup.toArray());
166
167
            PaletteItemNode node = new PaletteItemNode(displayName, tooltip, icon16, icon32, lookup);
168
169
            return node;
170
        }
171
        
172
        public String getDisplayName(
173
                String bundleName, 
174
                String displayNameKey, 
175
                String instanceName) 
176
        {
177
178
            String displayName = null;
179
            try {
180
                displayName = NbBundle.getBundle(bundleName).getString(displayNameKey);
181
182
                if (displayName == null && displayNameKey != null)
183
                    displayName = displayNameKey;
184
185
                if (displayName == null) {//derive name from the instance name
186
                    if (instanceName != null && instanceName.trim().length() > 0) {
187
                        int dashIndex = instanceName.lastIndexOf('-') + 1; // NOI18N
188
                        int dotIndex = instanceName.indexOf('.'); // NOI18N
189
                        displayName = instanceName.substring(dashIndex, dotIndex);
190
                    }
191
                }
192
193
                if (displayName == null) // no name derived from the item
194
                    displayName = xmlDataObject.getName();
195
196
            }
197
            catch (Exception ex) {
198
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
199
            }
200
            
201
            return (displayName == null ? "" : displayName);
202
        }
203
204
        public String getTooltip(
205
                String bundleName, 
206
                String tooltipKey, 
207
                String instanceName, 
208
                String displayNameKey) 
209
        {
210
211
            String tooltip = null;
212
            try {
213
                tooltip = NbBundle.getBundle(bundleName).getString(tooltipKey);
214
215
                if (tooltip == null && tooltipKey != null)
216
                    tooltip = tooltipKey;
217
218
                if (tooltip == null) {//derive name from instance name
219
                    if (instanceName != null && instanceName.trim().length() > 0) {
220
                        int dotIndex = instanceName.indexOf('.'); // NOI18N
221
                        tooltip = instanceName.substring(0, dotIndex).replace('-', '.'); // NOI18N
222
                    }
223
                }
224
225
                if (tooltip == null) // no tooltip derived from the item
226
                    tooltip = getDisplayName(bundleName, displayNameKey, instanceName);
227
                
228
            }
229
            catch (Exception ex) {
230
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
231
            }
232
233
            return (tooltip == null ? "" :  tooltip);
234
        }
235
236
        public Image getIcon(String iconURL) {
237
238
            Image icon = null;
239
            try {
240
                URL url = new URL(iconURL);
241
                icon = java.awt.Toolkit.getDefaultToolkit().getImage(url);
242
            }
243
            catch (Exception ex) {
244
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
245
            }
246
247
            return icon;
248
        }
249
250
        private ActiveEditorDrop getActiveEditorDrop(String instanceName) {
251
252
            ActiveEditorDrop drop = null;
253
254
            if (instanceName != null && instanceName.trim().length() > 0) {//we should try to instantiate item drop
255
                try {
256
//                    Repository rep = (Repository) Lookup.getDefault().lookup(Repository.class);
257
//                    FileObject fo = rep.getDefaultFileSystem().findResource(URL_PREFIX_INSTANCES + instanceName);
258
//                    DataObject _do = DataObject.find(fo);
259
//                    InstanceDataObject ido = (InstanceDataObject) _do;
260
//                    drop = (ActiveEditorDrop)ido.instanceCreate();
261
262
                    ClassLoader loader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
263
                    if (loader == null)
264
                        loader = getClass ().getClassLoader ();
265
                    Class instanceClass = loader.loadClass (instanceName);
266
                    drop = (ActiveEditorDrop)instanceClass.newInstance();
267
                }
268
                catch (Exception ex) {
269
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
270
                }
271
            }
272
273
            return drop;
274
        }
275
276
    }
277
    
278
    
279
}
(-)palette/src/org/netbeans/modules/palette/PaletteItemHandler.java (+161 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.palette;
15
import java.util.LinkedList;
16
import org.openide.util.NbBundle;
17
import org.xml.sax.Attributes;
18
import org.xml.sax.SAXException;
19
import org.xml.sax.helpers.DefaultHandler;
20
21
22
/**
23
 *
24
 * @author Libor Kotouc
25
 */
26
public final class PaletteItemHandler extends DefaultHandler {
27
28
    private static final String XML_ROOT = "editor_palette_item"; // NOI18N
29
    private static final String ATTR_VERSION = "version"; // NOI18N
30
//    private static final String TAG_ATTRIBUTES = "attributes"; // NOI18N
31
//    private static final String TAG_ATTRIBUTE = "attribute"; // NOI18N
32
//    private static final String ATTR_ATTRIBNAME = "name"; // NOI18N
33
//    private static final String ATTR_ATTRIBVALUE = "value"; // NOI18N
34
    private static final String TAG_BODY = "body"; // NOI18N
35
    private static final String TAG_INSTANCE = "instance"; // NOI18N
36
    private static final String ATTR_INSTANCENAME = "name"; // NOI18N
37
    private static final String TAG_CUSTOMIZER = "customizer"; // NOI18N
38
    private static final String ATTR_CUSTNAME = "name"; // NOI18N
39
    private static final String TAG_ICON16 = "icon16"; // NOI18N
40
    private static final String ATTR_URL = "urlvalue"; // NOI18N
41
    private static final String TAG_ICON32 = "icon32"; // NOI18N
42
    private static final String TAG_DESCRIPTION = "description"; // NOI18N
43
    private static final String ATTR_BUNDLE = "localizing-bundle"; // NOI18N
44
    private static final String ATTR_DISPLAY_NAME_KEY = "display-name-key"; // NOI18N
45
    private static final String ATTR_TOOLTIP_KEY = "tooltip-key"; // NOI18N
46
47
    private LinkedList/*<String>*/ bodyLines;
48
    private boolean insideBody = false;
49
    
50
    //raw data read from the file
51
//    private HashMap attributeMap;
52
    private String body;
53
    private String instanceName;
54
    private String customizerName;
55
    
56
    private String icon16URL;
57
    private String icon32URL;
58
    private String bundleName;
59
    private String displayNameKey;
60
    private String tooltipKey;
61
    
62
//    public Map getAttributes() { return (attributeMap == null ? new HashMap() : attributeMap); }
63
    public String getBody() { return body; }
64
    public String getInstanceName() { return instanceName; }
65
    
66
    public String getIcon16URL() { return icon16URL; }
67
    public String getIcon32URL() { return icon32URL; }
68
    public String getBundleName() { return bundleName; }
69
    public String getDisplayNameKey() { return displayNameKey; }
70
    public String getTooltipKey() { return tooltipKey; }
71
    
72
    public void startElement(String uri, String localName, String qName, Attributes attributes) 
73
        throws SAXException 
74
    {
75
        if (XML_ROOT.equals(qName)) {
76
            String version = attributes.getValue(ATTR_VERSION);
77
            if (version == null) {
78
                String message = NbBundle.getBundle(PaletteItemHandler.class)
79
                    .getString("MSG_UnknownEditorPaletteItemVersion"); // NOI18N
80
                throw new SAXException(message);
81
            } else if (!version.equals("1.0")) { // NOI18N
82
                String message = NbBundle.getBundle(PaletteItemHandler.class)
83
                    .getString("MSG_UnsupportedEditorPaletteItemVersion"); // NOI18N
84
                throw new SAXException(message);
85
            }
86
//        } else if (TAG_ATTRIBUTES.equals(qName)) {
87
//            attributeMap = new HashMap();
88
//        } else if (TAG_ATTRIBUTE.equals(qName)) {
89
//            String name = attributes.getValue(ATTR_ATTRIBNAME);
90
//            String value = attributes.getValue(ATTR_ATTRIBVALUE);
91
//            attributeMap.put(name, value);
92
        } else if (TAG_BODY.equals(qName)) {
93
            bodyLines = new LinkedList();
94
            insideBody = true;
95
        } else if (TAG_INSTANCE.equals(qName)) {
96
            instanceName = attributes.getValue(ATTR_INSTANCENAME);
97
        } else if (TAG_ICON16.equals(qName)) {
98
            icon16URL = attributes.getValue(ATTR_URL);
99
            // TODO support also class resource name for icons
100
        } else if (TAG_ICON32.equals(qName)) {
101
            icon32URL = attributes.getValue(ATTR_URL);
102
            // TODO support also class resource name for icons
103
        } else if (TAG_DESCRIPTION.equals(qName)) {
104
            bundleName = attributes.getValue(ATTR_BUNDLE);
105
            displayNameKey = attributes.getValue(ATTR_DISPLAY_NAME_KEY);
106
            tooltipKey = attributes.getValue(ATTR_TOOLTIP_KEY);
107
        }
108
    }
109
    
110
    public void endElement(String uri, String localName, String qName) throws SAXException {
111
112
        if (TAG_BODY.equals(qName)) {
113
            insideBody = false;
114
            body = trimSurroundingLines(bodyLines);
115
        }
116
    }
117
    
118
    public void characters(char buf[], int offset, int len)
119
        throws SAXException
120
    {
121
        if (insideBody) {
122
            String chars = new String(buf, offset, len).trim();
123
            bodyLines.add(chars + "\n");
124
        }
125
    }
126
127
    /**
128
     * Trims empty lines from the beginning and the end of the line list
129
     */
130
    private String trimSurroundingLines(LinkedList/*<String>*/ lines) {
131
        
132
        int nlines = lines.size();
133
        
134
        int firstNonEmpty = nlines;
135
136
        //going from the beginning and skipping empty lines until the first nonempty line occurs
137
        for (int i = 0; i < firstNonEmpty; i++) {
138
            String line = (String)lines.get(i);
139
            if (line.trim().length() != 0)
140
                firstNonEmpty = i;
141
        }
142
            
143
        int lastNonEmpty = -1;
144
        
145
        //going from the end and skipping empty lines until the first nonempty line occurs
146
        for (int i = nlines - 1; i > lastNonEmpty; i--) {
147
            String line = (String)lines.get(i);
148
            if (line.trim().length() != 0)
149
                lastNonEmpty = i;
150
        }
151
152
        StringBuffer sb = new StringBuffer();
153
        for (int i = firstNonEmpty; i <= lastNonEmpty; i++)
154
            sb.append((String)lines.get(i));
155
        
156
        String body = sb.toString();
157
        
158
        return body;
159
    }
160
}
161
(-)palette/src/org/netbeans/modules/palette/PaletteItemNode.java (+148 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.palette;
15
16
import java.awt.Image;
17
import java.awt.datatransfer.Transferable;
18
import java.beans.BeanInfo;
19
import java.io.IOException;
20
import javax.swing.text.BadLocationException;
21
import javax.swing.text.Caret;
22
import javax.swing.text.Document;
23
import javax.swing.text.JTextComponent;
24
import org.openide.nodes.AbstractNode;
25
import org.openide.nodes.Children;
26
import org.openide.nodes.Node;
27
import org.openide.text.ActiveEditorDrop;
28
import org.openide.util.Lookup;
29
import org.openide.util.datatransfer.ExTransferable;
30
31
32
33
/**
34
 *
35
 * @author Libor Kotouc
36
 */
37
public final class PaletteItemNode extends AbstractNode {
38
    
39
    private static final Node.PropertySet[] NO_PROPERTIES = new Node.PropertySet[0];
40
    
41
    String displayName;
42
    String description;
43
    Image icon16;
44
    Image icon32;
45
    
46
    PaletteItemNode(String displayName, String description, Image icon16, Image icon32, Lookup lookup) {
47
        super(Children.LEAF, lookup);
48
        
49
        this.displayName = displayName;
50
        this.description = description;
51
        this.icon16 = icon16;
52
        this.icon32 = icon32;
53
    }
54
 
55
    public String getDisplayName() {
56
        return displayName;
57
    }
58
59
    public String getShortDescription() {
60
        return description;
61
    }
62
63
    public Image getIcon(int type) {
64
65
        Image icon = icon16;
66
        
67
        if (type == BeanInfo.ICON_COLOR_32x32 || type == BeanInfo.ICON_MONO_32x32)
68
            icon = icon32;
69
        
70
        return icon;
71
    }
72
    
73
    public boolean canRename() {
74
        return false;
75
    }
76
77
    // TODO properties
78
    public Node.PropertySet[] getPropertySets() {
79
        return NO_PROPERTIES;
80
    }
81
82
    public Transferable clipboardCopy() throws IOException {
83
84
        ExTransferable t = ExTransferable.create( super.clipboardCopy() );
85
        
86
        Lookup lookup = getLookup();
87
        ActiveEditorDrop drop = (ActiveEditorDrop) lookup.lookup(ActiveEditorDrop.class);
88
        if (drop == null) {
89
            String body = (String)lookup.lookup(String.class);
90
            drop = new ActiveEditorDropDefault(body);
91
        }
92
        
93
        ActiveEditorDropTransferable s = new ActiveEditorDropTransferable(drop);
94
        t.put(s);
95
96
        return t;
97
    }
98
99
    private static class ActiveEditorDropTransferable extends ExTransferable.Single {
100
        
101
        private ActiveEditorDrop drop;
102
103
        ActiveEditorDropTransferable(ActiveEditorDrop drop) {
104
            super(ActiveEditorDrop.FLAVOR);
105
            
106
            this.drop = drop;
107
        }
108
               
109
        public Object getData () {
110
            return drop;
111
        }
112
        
113
    }
114
115
    private static class ActiveEditorDropDefault implements ActiveEditorDrop {
116
117
        String body;
118
119
        public ActiveEditorDropDefault(String body) {
120
            this.body = body;
121
        }
122
123
        public boolean handleTransfer(JTextComponent targetComponent) {
124
125
            if (targetComponent == null)
126
                return false;
127
128
            try {
129
                Document doc = targetComponent.getDocument();
130
                Caret caret = targetComponent.getCaret();
131
                int p0 = Math.min(caret.getDot(), caret.getMark());
132
                int p1 = Math.max(caret.getDot(), caret.getMark());
133
                doc.remove(p0, p1 - p0);
134
135
                //replace selected text by the inserted one
136
                int start = caret.getDot();
137
                doc.insertString(start, body, null);
138
            }
139
            catch (BadLocationException ble) {
140
                return false;
141
            }
142
143
            return true;
144
        }
145
146
    }
147
    
148
}
(-)palette/src/org/netbeans/modules/palette/resources/editor-palette-item-1_0.dtd (+43 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
                Sun Public License Notice
4
5
The contents of this file are subject to the Sun Public License
6
Version 1.0 (the "License"). You may not use this file except in
7
compliance with the License. A copy of the License is available at
8
http://www.sun.com/
9
10
The Original Code is NetBeans. The Initial Developer of the Original
11
Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
12
Microsystems, Inc. All Rights Reserved.
13
-->
14
15
<!--- Editor Palette Item -->
16
<!ELEMENT editor_palette_item ((instance|body),icon16,icon32,description)>
17
<!ATTLIST editor_palette_item
18
    version CDATA #REQUIRED
19
>
20
21
<!ELEMENT instance EMPTY>
22
<!ATTLIST instance 
23
    name CDATA #REQUIRED
24
>
25
26
<!ELEMENT body (#PCDATA)>
27
28
<!ELEMENT icon16 EMPTY>
29
<!ATTLIST icon16 
30
    urlvalue CDATA #REQUIRED
31
>
32
33
<!ELEMENT icon32 EMPTY>
34
<!ATTLIST icon32 
35
    urlvalue CDATA #REQUIRED
36
>
37
38
<!ELEMENT description EMPTY>
39
<!ATTLIST description 
40
    localizing-bundle CDATA #REQUIRED
41
    display-name-key CDATA #REQUIRED
42
    tooltip-key CDATA #REQUIRED
43
>
(-)palette/src/org/netbeans/modules/palette/resources/layer.xml (+21 lines)
Lines 56-59 Link Here
56
        <!-- Palette stores its non-public settings here -->
56
        <!-- Palette stores its non-public settings here -->
57
    </folder>
57
    </folder>
58
58
59
    <folder name="xml">
60
        <folder name="entities">
61
            <folder name="NetBeans" >
62
                <file name="Editor_Palette_Item_1_0" url="editor-palette-item-1_0.dtd">
63
                    <attr name="hint.originalPublicID" stringvalue="-//NetBeans//Editor Palette Item 1.0//EN"/>
64
                </file>
65
            </folder>
66
        </folder>
67
        
68
        <folder name="lookups">
69
            <folder name="NetBeans">
70
                <file name="Editor_Palette_Item_1_0.instance">
71
                    <attr name="instanceClass" stringvalue="org.netbeans.modules.palette.PaletteEnvironmentProvider"/>
72
                    <attr name="instanceOf" stringvalue="org.openide.loaders.Environment.Provider"/>
73
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.palette.PaletteEnvironmentProvider.createProvider"/>
74
                </file>
75
            </folder>
76
        </folder>
77
78
    </folder>
79
59
</filesystem>
80
</filesystem>

Return to bug 61635