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

(-)a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/layer.xml (-25 / +84 lines)
Lines 43-49 Link Here
43
Version 2 license, then the option applies only if the new code is
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
44
made subject to such option by the copyright holder.
45
-->
45
-->
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
46
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
47
<filesystem>
47
<filesystem>
48
    <folder name="org-netbeans-api-project-libraries">
48
    <folder name="org-netbeans-api-project-libraries">
49
        <folder name="LibraryTypeProviders">
49
        <folder name="LibraryTypeProviders">
Lines 72-125 Link Here
72
        <folder name="application">
72
        <folder name="application">
73
            <folder name="x-java-archive">
73
            <folder name="x-java-archive">
74
                <folder name="Actions">
74
                <folder name="Actions">
75
                    <file name="org-openide-actions-CopyAction.shadow">
75
                    <file name="org-netbeans-core-ui-options-filetypes-OpenAsAction.shadow">
76
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
76
                        <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-core-ui-options-filetypes-OpenAsAction.instance"/>
77
                        <attr name="position" intvalue="600"/>
77
                        <attr name="position" intvalue="150"/>
78
                    </file>
79
                    <file name="org-netbeans-core-ui-sysopen-SystemOpenAction.shadow">
80
                        <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-core-ui-sysopen-SystemOpenAction.instance"/>
81
                        <attr name="position" intvalue="200"/>
82
                    </file>                    
83
                    <file name="sep-1.instance">
84
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
85
                        <attr name="position" intvalue="300"/>
78
                    </file>
86
                    </file>
79
                    <file name="org-openide-actions-CutAction.shadow">
87
                    <file name="org-openide-actions-CutAction.shadow">
80
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
88
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
81
                        <attr name="position" intvalue="500"/>
89
                        <attr name="position" intvalue="500"/>
82
                    </file>
90
                    </file>
83
                    <file name="org-openide-actions-DeleteAction.shadow">
91
                    <file name="org-openide-actions-CopyAction.shadow">
84
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
92
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
85
                        <attr name="position" intvalue="900"/>
93
                        <attr name="position" intvalue="600"/>
86
                    </file>
94
                    </file>
87
                    <file name="org-openide-actions-PasteAction.shadow">
95
                    <file name="org-openide-actions-PasteAction.shadow">
88
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-PasteAction.instance"/>
96
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-PasteAction.instance"/>
89
                        <attr name="position" intvalue="700"/>
97
                        <attr name="position" intvalue="700"/>
90
                    </file>
98
                    </file>
99
                    <file name="sep-3.instance">
100
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
101
                        <attr name="position" intvalue="800"/>
102
                    </file>
103
                    <file name="org-openide-actions-DeleteAction.shadow">
104
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
105
                        <attr name="position" intvalue="900"/>
106
                    </file>
107
                    <file name="org-openide-actions-RenameAction.shadow">
108
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
109
                        <attr name="position" intvalue="1000"/>
110
                    </file>
111
                    <file name="sep-5.instance">
112
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
113
                        <attr name="position" intvalue="1200"/>
114
                    </file>
91
                    <file name="org-openide-actions-FileSystemAction.shadow">
115
                    <file name="org-openide-actions-FileSystemAction.shadow">
92
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
116
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
93
                        <attr name="position" intvalue="1300"/>
117
                        <attr name="position" intvalue="1300"/>
94
                    </file>
118
                    </file>
119
                    <file name="org-openide-actions-ToolsAction.shadow">
120
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
121
                        <attr name="position" intvalue="1400"/>
122
                    </file>
95
                    <file name="org-openide-actions-PropertiesAction.shadow">
123
                    <file name="org-openide-actions-PropertiesAction.shadow">
96
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
124
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
97
                        <attr name="position" intvalue="1500"/>
125
                        <attr name="position" intvalue="1500"/>
98
                    </file>
126
                    </file>
127
                </folder>
128
            </folder>
129
            <folder name="zip">
130
                <folder name="Actions">
131
                    <file name="org-netbeans-core-ui-options-filetypes-OpenAsAction.shadow">
132
                        <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-core-ui-options-filetypes-OpenAsAction.instance"/>
133
                        <attr name="position" intvalue="150"/>
134
                    </file>
135
                    <file name="org-netbeans-core-ui-sysopen-SystemOpenAction.shadow">
136
                        <attr name="originalFile" stringvalue="Actions/Edit/org-netbeans-core-ui-sysopen-SystemOpenAction.instance"/>
137
                        <attr name="position" intvalue="200"/>
138
                    </file>                    
139
                    <file name="sep-1.instance">
140
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
141
                        <attr name="position" intvalue="300"/>
142
                    </file>
143
                    <file name="org-openide-actions-CutAction.shadow">
144
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
145
                        <attr name="position" intvalue="500"/>
146
                    </file>
147
                    <file name="org-openide-actions-CopyAction.shadow">
148
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
149
                        <attr name="position" intvalue="600"/>
150
                    </file>
151
                    <file name="org-openide-actions-PasteAction.shadow">
152
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-PasteAction.instance"/>
153
                        <attr name="position" intvalue="700"/>
154
                    </file>
155
                    <file name="sep-3.instance">
156
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
157
                        <attr name="position" intvalue="800"/>
158
                    </file>
159
                    <file name="org-openide-actions-DeleteAction.shadow">
160
                        <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
161
                        <attr name="position" intvalue="900"/>
162
                    </file>
99
                    <file name="org-openide-actions-RenameAction.shadow">
163
                    <file name="org-openide-actions-RenameAction.shadow">
100
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
164
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
101
                        <attr name="position" intvalue="1000"/>
165
                        <attr name="position" intvalue="1000"/>
102
                    </file>
166
                    </file>
167
                    <file name="sep-5.instance">
168
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
169
                        <attr name="position" intvalue="1200"/>
170
                    </file>
171
                    <file name="org-openide-actions-FileSystemAction.shadow">
172
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
173
                        <attr name="position" intvalue="1300"/>
174
                    </file>
103
                    <file name="org-openide-actions-ToolsAction.shadow">
175
                    <file name="org-openide-actions-ToolsAction.shadow">
104
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
176
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
105
                        <attr name="position" intvalue="1400"/>
177
                        <attr name="position" intvalue="1400"/>
106
                    </file>
178
                    </file>
107
                    <file name="sep-1.instance">
179
                    <file name="org-openide-actions-PropertiesAction.shadow">
108
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
180
                        <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
109
                        <attr name="position" intvalue="200"/>
181
                        <attr name="position" intvalue="1500"/>
110
                    </file>
111
                    <file name="sep-3.instance">
112
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
113
                        <attr name="position" intvalue="800"/>
114
                    </file>
115
                    <file name="sep-5.instance">
116
                        <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
117
                        <attr name="position" intvalue="1200"/>
118
                    </file>
119
                </folder>
120
                <folder name="Factories">
121
                    <file name="org-netbeans-modules-java-jarloader-JarDataLoader.instance">
122
                        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.java.j2seplatform.Bundle"/>
123
                    </file>
182
                    </file>
124
                </folder>
183
                </folder>
125
            </folder>
184
            </folder>
Lines 130-136 Link Here
130
    <folder name="Services">
189
    <folder name="Services">
131
        <folder name="Platforms">
190
        <folder name="Platforms">
132
            <folder name="org-netbeans-api-java-Platform">
191
            <folder name="org-netbeans-api-java-Platform">
133
                 <!-- Placeholder, installed platforms will be created in this folder -->
192
                <!-- Placeholder, installed platforms will be created in this folder -->
134
                <file name="default_platform.xml" url="templates/defaultPlatform.xml">
193
                <file name="default_platform.xml" url="templates/defaultPlatform.xml">
135
                    <attr name="default-platform" boolvalue="true"/>
194
                    <attr name="default-platform" boolvalue="true"/>
136
                </file>
195
                </file>
Lines 159-165 Link Here
159
    </folder>
218
    </folder>
160
    
219
    
161
    <folder name="WarmUp">
220
    <folder name="WarmUp">
162
      <file name="org-netbeans-modules-java-j2seplatform-J2SEPlatformWarmUp.instance"/>
221
        <file name="org-netbeans-modules-java-j2seplatform-J2SEPlatformWarmUp.instance"/>
163
    </folder>
222
    </folder>
164
223
165
</filesystem>
224
</filesystem>
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/Bundle.properties (+5 lines)
Lines 42-44 Link Here
42
42
43
LBL_loaderName=JAR Files
43
LBL_loaderName=JAR Files
44
JarResolver=Java Archive File
44
JarResolver=Java Archive File
45
JarLoader=JAR File Loader
46
47
LBL_ZipLoaderName=ZIP Files
48
ZIPResolver=ZIP File
49
ZIPLoader=ZIP File Loader
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataLoader.java (-9 / +4 lines)
Lines 44-69 Link Here
44
package org.netbeans.modules.java.jarloader;
44
package org.netbeans.modules.java.jarloader;
45
45
46
import java.io.IOException;
46
import java.io.IOException;
47
import org.openide.actions.CopyAction;
48
import org.openide.actions.CutAction;
49
import org.openide.actions.DeleteAction;
50
import org.openide.actions.FileSystemAction;
51
import org.openide.actions.PasteAction;
52
import org.openide.actions.PropertiesAction;
53
import org.openide.actions.RenameAction;
54
import org.openide.actions.ToolsAction;
55
import org.openide.filesystems.FileObject;
47
import org.openide.filesystems.FileObject;
48
import org.openide.loaders.DataObject;
56
import org.openide.loaders.DataObjectExistsException;
49
import org.openide.loaders.DataObjectExistsException;
57
import org.openide.loaders.ExtensionList;
50
import org.openide.loaders.ExtensionList;
58
import org.openide.loaders.MultiDataObject;
51
import org.openide.loaders.MultiDataObject;
59
import org.openide.loaders.UniFileLoader;
52
import org.openide.loaders.UniFileLoader;
60
import org.openide.util.NbBundle;
53
import org.openide.util.NbBundle;
61
import org.openide.util.actions.SystemAction;
62
54
63
/**
55
/**
64
 * Recognizes JAR files and shows their contents.
56
 * Recognizes JAR files and shows their contents.
65
 * @author Jesse Glick
57
 * @author Jesse Glick
66
 */
58
 */
59
@DataObject.Registration(displayName = "org.netbeans.modules.java.jarloader.Bundle#JarLoader", mimeType = "application/x-java-archive")
67
public final class JarDataLoader extends UniFileLoader {
60
public final class JarDataLoader extends UniFileLoader {
68
    
61
    
69
    static final String JAR_MIME_TYPE = "application/x-java-archive";   //NOI18N
62
    static final String JAR_MIME_TYPE = "application/x-java-archive";   //NOI18N
Lines 74-83 Link Here
74
        super("org.netbeans.modules.java.jarloader.JarDataObject"); // NOI18N
67
        super("org.netbeans.modules.java.jarloader.JarDataObject"); // NOI18N
75
    }
68
    }
76
    
69
    
70
    @Override
77
    protected String defaultDisplayName() {
71
    protected String defaultDisplayName() {
78
        return NbBundle.getMessage(JarDataLoader.class, "LBL_loaderName");
72
        return NbBundle.getMessage(JarDataLoader.class, "LBL_loaderName");
79
    }
73
    }
80
    
74
    
75
    @Override
81
    protected void initialize() {
76
    protected void initialize() {
82
        super.initialize();
77
        super.initialize();
83
        ExtensionList extensions = new ExtensionList();
78
        ExtensionList extensions = new ExtensionList();
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataLoaderBeanInfo.java (-2 / +2 lines)
Lines 49-58 Link Here
49
import java.beans.IntrospectionException;
49
import java.beans.IntrospectionException;
50
import java.beans.Introspector;
50
import java.beans.Introspector;
51
import java.beans.SimpleBeanInfo;
51
import java.beans.SimpleBeanInfo;
52
import org.openide.ErrorManager;
53
import org.openide.loaders.UniFileLoader;
52
import org.openide.loaders.UniFileLoader;
54
import org.openide.util.ImageUtilities;
53
import org.openide.util.ImageUtilities;
55
import org.openide.util.Utilities;
56
54
57
/**
55
/**
58
 * Description of {@link JarDataLoader}.
56
 * Description of {@link JarDataLoader}.
Lines 60-65 Link Here
60
 */
58
 */
61
public final class JarDataLoaderBeanInfo extends SimpleBeanInfo {
59
public final class JarDataLoaderBeanInfo extends SimpleBeanInfo {
62
60
61
    @Override
63
    public BeanInfo[] getAdditionalBeanInfo() {
62
    public BeanInfo[] getAdditionalBeanInfo() {
64
        try {
63
        try {
65
            return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)};
64
            return new BeanInfo[] {Introspector.getBeanInfo(UniFileLoader.class)};
Lines 68-73 Link Here
68
        }
67
        }
69
    }
68
    }
70
    
69
    
70
    @Override
71
    public Image getIcon(int type) {
71
    public Image getIcon(int type) {
72
        return ImageUtilities.loadImage("org/netbeans/modules/java/jarloader/jar.gif", true);
72
        return ImageUtilities.loadImage("org/netbeans/modules/java/jarloader/jar.gif", true);
73
    }
73
    }
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataNode.java (-1 / +1 lines)
Lines 78-84 Link Here
78
    public Action getPreferredAction() {
78
    public Action getPreferredAction() {
79
        return null;
79
        return null;
80
    }
80
    }
81
    
81
82
    private static Children childrenFor(FileObject jar) {
82
    private static Children childrenFor(FileObject jar) {
83
        if (!FileUtil.isArchiveFile(jar)) {
83
        if (!FileUtil.isArchiveFile(jar)) {
84
            // Maybe corrupt, etc.
84
            // Maybe corrupt, etc.
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java (-1 / +3 lines)
Lines 56-72 Link Here
56
 * Represents a JAR file.
56
 * Represents a JAR file.
57
 * @author Jesse Glick
57
 * @author Jesse Glick
58
 */
58
 */
59
@MIMEResolver.Registration(resource="../j2seplatform/resources/platforms-mime-resolver.xml", displayName="#JarResolver", position=480)
59
@MIMEResolver.Registration(resource="mime-resolver-jar.xml", displayName="#JarResolver", position=480)
60
public final class JarDataObject extends MultiDataObject {
60
public final class JarDataObject extends MultiDataObject {
61
61
62
    public JarDataObject(FileObject pf, JarDataLoader loader) throws DataObjectExistsException {
62
    public JarDataObject(FileObject pf, JarDataLoader loader) throws DataObjectExistsException {
63
        super(pf, loader);
63
        super(pf, loader);
64
    }
64
    }
65
65
66
    @Override
66
    public HelpCtx getHelpCtx() {
67
    public HelpCtx getHelpCtx() {
67
        return HelpCtx.DEFAULT_HELP;
68
        return HelpCtx.DEFAULT_HELP;
68
    }
69
    }
69
    
70
    
71
    @Override
70
    protected Node createNodeDelegate() {
72
    protected Node createNodeDelegate() {
71
        return new JarDataNode(this);
73
        return new JarDataNode(this);
72
    }
74
    }
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataLoader.java (-19 / +14 lines)
Lines 44-97 Link Here
44
package org.netbeans.modules.java.jarloader;
44
package org.netbeans.modules.java.jarloader;
45
45
46
import java.io.IOException;
46
import java.io.IOException;
47
import org.openide.actions.CopyAction;
48
import org.openide.actions.CutAction;
49
import org.openide.actions.DeleteAction;
50
import org.openide.actions.FileSystemAction;
51
import org.openide.actions.PasteAction;
52
import org.openide.actions.PropertiesAction;
53
import org.openide.actions.RenameAction;
54
import org.openide.actions.ToolsAction;
55
import org.openide.filesystems.FileObject;
47
import org.openide.filesystems.FileObject;
48
import org.openide.loaders.DataObject;
56
import org.openide.loaders.DataObjectExistsException;
49
import org.openide.loaders.DataObjectExistsException;
57
import org.openide.loaders.ExtensionList;
50
import org.openide.loaders.ExtensionList;
58
import org.openide.loaders.MultiDataObject;
51
import org.openide.loaders.MultiDataObject;
59
import org.openide.loaders.UniFileLoader;
52
import org.openide.loaders.UniFileLoader;
60
import org.openide.util.NbBundle;
53
import org.openide.util.NbBundle;
61
import org.openide.util.actions.SystemAction;
62
54
63
/**
55
/**
64
 * Recognizes JAR files and shows their contents.
56
 * Recognizes ZIP files and shows their contents.
65
 * @author Jesse Glick
66
 */
57
 */
67
public final class JarDataLoader extends UniFileLoader {
58
@DataObject.Registration(displayName = "org.netbeans.modules.java.jarloader.Bundle#ZIPLoader", mimeType = "application/zip")
59
public final class ZipDataLoader extends UniFileLoader {
68
    
60
    
69
    static final String JAR_MIME_TYPE = "application/x-java-archive";   //NOI18N
61
    static final String ZIP_MIME_TYPE = "application/zip";   //NOI18N
70
    
62
    
71
    private static final long serialVersionUID = 1L;
63
    private static final long serialVersionUID = 1L;
72
    
64
    
73
    public JarDataLoader() {
65
    public ZipDataLoader() {
74
        super("org.netbeans.modules.java.jarloader.JarDataObject"); // NOI18N
66
        super("org.netbeans.modules.java.jarloader.ZipDataObject"); // NOI18N
75
    }
67
    }
76
    
68
    
69
    @Override
77
    protected String defaultDisplayName() {
70
    protected String defaultDisplayName() {
78
        return NbBundle.getMessage(JarDataLoader.class, "LBL_loaderName");
71
        return NbBundle.getMessage(ZipDataLoader.class, "LBL_ZipLoaderName");
79
    }
72
    }
80
    
73
    
74
    @Override
81
    protected void initialize() {
75
    protected void initialize() {
82
        super.initialize();
76
        super.initialize();
83
        ExtensionList extensions = new ExtensionList();
77
        ExtensionList extensions = new ExtensionList();
84
        extensions.addMimeType(JAR_MIME_TYPE);        
78
        extensions.addMimeType(ZIP_MIME_TYPE);        
85
        setExtensions(extensions);
79
        setExtensions(extensions);
86
    }
80
    }
87
81
88
    @Override
82
    @Override
89
    protected String actionsContext() {
83
    protected String actionsContext() {
90
       return "Loaders/application/x-java-archive/Actions/"; // NOI18N
84
       return "Loaders/application/zip/Actions/"; // NOI18N
91
    }
85
    }
92
    
86
    
87
    @Override
93
    protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
88
    protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
94
        return new JarDataObject(primaryFile, this);
89
        return new ZipDataObject(primaryFile, this);
95
    }
90
    }
96
    
91
    
97
}
92
}
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataNode.java (-79 / +33 lines)
Lines 41-138 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
45
package org.netbeans.modules.java.jarloader;
44
package org.netbeans.modules.java.jarloader;
46
45
47
import java.beans.PropertyChangeListener;
46
import java.awt.Image;
48
import javax.swing.Action;
47
import java.awt.datatransfer.Transferable;
49
import javax.swing.Icon;
50
import org.netbeans.api.project.SourceGroup;
51
import org.netbeans.spi.java.project.support.ui.PackageView;
52
import org.openide.filesystems.FileObject;
48
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.loaders.DataNode;
55
import org.openide.nodes.Children;
56
import org.openide.nodes.FilterNode;
49
import org.openide.nodes.FilterNode;
57
import org.openide.nodes.Node;
50
import org.openide.nodes.Node;
58
import org.openide.util.RequestProcessor;
51
import org.openide.util.ImageUtilities;
59
52
import org.openide.util.datatransfer.PasteType;
60
53
61
/**
54
/**
62
 * A node to represent a JAR file.
55
 * A node to represent a JAR file.
63
 * @author Jesse Glick
64
 */
56
 */
65
final class JarDataNode extends DataNode {
57
final class ZipDataNode extends FilterNode {
66
    private static final RequestProcessor RP = new RequestProcessor(JarDataNode.class.getName(), 1, false, false);
58
    private final Image icon = ImageUtilities.loadImage("org/netbeans/modules/java/jarloader/jar.gif", true);
59
    
60
    private final FileObject realFile;
61
    private final Node folderNode;
62
    
63
    public ZipDataNode(FileObject realFile, Node original, Node folderNode) {
64
        super(original);
65
        this.realFile = realFile;
66
        this.folderNode = folderNode;
67
    }
67
68
68
    public JarDataNode(JarDataObject obj) {
69
    @Override
69
        this(obj, new DummyChildren());
70
    public String getDisplayName() {
71
        return realFile.getNameExt();
70
    }
72
    }
71
    
73
72
    private JarDataNode(JarDataObject obj, DummyChildren c) {
74
    @Override
73
        super(obj, c);
75
    public Image getIcon(int type) {
74
        c.attachJarNode(this);
76
        return icon;
75
        setIconBaseWithExtension("org/netbeans/modules/java/jarloader/jar.gif"); // NOI18N
76
    }
77
    }
77
    
78
78
    public Action getPreferredAction() {
79
    @Override
79
        return null;
80
    public Image getOpenedIcon(int type) {
81
        return icon;
80
    }
82
    }
81
    
83
82
    private static Children childrenFor(FileObject jar) {
84
    @Override
83
        if (!FileUtil.isArchiveFile(jar)) {
85
    public PasteType[] getPasteTypes(Transferable t) {
84
            // Maybe corrupt, etc.
86
        if(folderNode != null) {
85
            return Children.LEAF;
87
            return folderNode.getPasteTypes(t); 
86
        }
87
        final FileObject root = FileUtil.getArchiveRoot(jar);
88
        if (root != null) {
89
            return new FilterNode.Children(PackageView.createPackageView(new SourceGroup() {
90
                @Override public FileObject getRootFolder() {return root;}
91
                @Override public String getName() {return null;}
92
                @Override public String getDisplayName() {return null;}
93
                @Override public Icon getIcon(boolean opened) {return null;}
94
                @Override public boolean contains(FileObject file) {return true;}
95
                @Override public void addPropertyChangeListener(PropertyChangeListener listener) {}
96
                @Override public void removePropertyChangeListener(PropertyChangeListener listener) {}
97
            }));
98
        } else {
88
        } else {
99
            return Children.LEAF;
89
            return null;
100
        }
90
        }
101
    }
91
    }
102
    
92
}
103
    /**
104
     * There is no nice way to lazy create delegating node's children.
105
     * So, in order to fix #83595, here is a little hack that schedules
106
     * replacement of this dummy children on addNotify call.
107
     */
108
    final static class DummyChildren extends Children implements Runnable {
109
110
        private JarDataNode node;
111
112
        protected void addNotify() {
113
            super.addNotify();
114
            assert node != null;
115
            RP.post(this);
116
        }
117
118
        private void attachJarNode(JarDataNode jarDataNode) {
119
            this.node = jarDataNode;
120
        }
121
122
        public void run() {
123
            node.setChildren(childrenFor(node.getDataObject().getPrimaryFile()));
124
        }
125
        
126
        public boolean add(final Node[] nodes) {
127
            // no-op
128
            return false;
129
        }
130
131
        public boolean remove(final Node[] nodes) {
132
            // no-op
133
            return false;
134
        }
135
        
136
    }
137
    
138
}
(-)a/java.j2seplatform/src/org/netbeans/modules/java/jarloader/JarDataObject.java (-8 / +27 lines)
Lines 41-74 Link Here
41
 * Version 2 license, then the option applies only if the new code is
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
42
 * made subject to such option by the copyright holder.
43
 */
43
 */
44
45
package org.netbeans.modules.java.jarloader;
44
package org.netbeans.modules.java.jarloader;
46
45
47
import org.openide.filesystems.FileObject;
46
import org.openide.filesystems.FileObject;
47
import org.openide.filesystems.FileUtil;
48
import org.openide.filesystems.MIMEResolver;
48
import org.openide.filesystems.MIMEResolver;
49
import org.openide.loaders.DataFilter;
50
import org.openide.loaders.DataFolder;
51
import org.openide.loaders.DataNode;
49
import org.openide.loaders.DataObjectExistsException;
52
import org.openide.loaders.DataObjectExistsException;
50
import org.openide.loaders.MultiDataObject;
53
import org.openide.loaders.MultiDataObject;
54
import org.openide.nodes.Children;
51
import org.openide.nodes.Node;
55
import org.openide.nodes.Node;
52
import org.openide.util.HelpCtx;
56
import org.openide.util.HelpCtx;
53
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
54
58
55
/**
59
/**
56
 * Represents a JAR file.
60
 * Recognizes ZIP files and shows their contents.
57
 * @author Jesse Glick
58
 */
61
 */
59
@MIMEResolver.Registration(resource="../j2seplatform/resources/platforms-mime-resolver.xml", displayName="#JarResolver", position=480)
62
@MIMEResolver.Registration(resource="mime-resolver-zip.xml", displayName="#ZIPResolver", position=481)
60
public final class JarDataObject extends MultiDataObject {
63
public final class ZipDataObject extends MultiDataObject {
61
64
62
    public JarDataObject(FileObject pf, JarDataLoader loader) throws DataObjectExistsException {
65
    public ZipDataObject(FileObject pf, ZipDataLoader loader) throws DataObjectExistsException {
63
        super(pf, loader);
66
        super(pf, loader);
64
    }
67
    }
65
68
69
    @Override
66
    public HelpCtx getHelpCtx() {
70
    public HelpCtx getHelpCtx() {
67
        return HelpCtx.DEFAULT_HELP;
71
        return HelpCtx.DEFAULT_HELP;
68
    }
72
    }
69
    
73
    
74
    @Override
70
    protected Node createNodeDelegate() {
75
    protected Node createNodeDelegate() {
71
        return new JarDataNode(this);
76
        Node fileNode = null;
77
        Node folderNode = null;
78
79
        final FileObject folderObject = FileUtil.getArchiveRoot(getPrimaryFile());
80
        if (folderObject != null) {
81
            DataFolder dataFolder = DataFolder.findFolder(folderObject);
82
            fileNode = new DataNode(this, dataFolder.createNodeChildren(DataFilter.ALL));
83
            folderNode = dataFolder.getNodeDelegate();
84
        }
85
86
        if (fileNode == null) {
87
            fileNode = new DataNode(this, Children.LEAF);
88
        }
89
        
90
        return new ZipDataNode(getPrimaryFile(), fileNode, folderNode);
72
    }
91
    }
73
92
74
    @Override
93
    @Override
Lines 76-79 Link Here
76
        return getCookieSet().getLookup();
95
        return getCookieSet().getLookup();
77
    }
96
    }
78
    
97
    
79
}
98
}
(-)a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/platforms-mime-resolver.xml (-17 / +10 lines)
Lines 45-72 Link Here
45
-->
45
-->
46
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
46
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
47
<MIME-resolver>
47
<MIME-resolver>
48
   
49
    <file>        
48
    <file>        
50
        <ext name="jar"/>
51
        <ext name="zip"/>
52
        <ext name="war"/>
49
        <ext name="war"/>
53
        <ext name="ear"/>
50
        <ext name="ear"/>
54
        <ext name="JAR"/>
51
        <ext name="jar"/>
55
        <ext name="ZIP"/>
52
        <ext name="rar"/>
53
        <ext name="sar"/>
54
        <ext name="apk"/>
55
        <ext name="jad"/>
56
        <ext name="WAR"/>
56
        <ext name="WAR"/>
57
        <ext name="EAR"/>
57
        <ext name="EAR"/>
58
        <ext name="JAR"/>
59
        <ext name="RAR"/>
60
        <ext name="SAR"/>
61
        <ext name="APK"/>
62
        <ext name="JAD"/>
58
        <resolver mime="application/x-java-archive"/>
63
        <resolver mime="application/x-java-archive"/>
59
    </file>  
64
    </file>  
60
    
61
    <file>        
62
        <magic  hex="504b0304"
63
               mask="ffffffff"/>
64
        <resolver mime="application/x-java-archive"/>
65
    </file>
66
    
67
    <file>                
68
        <magic  hex="504b0506"
69
               mask="ffffffff"/>
70
        <resolver mime="application/x-java-archive"/>
71
    </file>
72
</MIME-resolver>
65
</MIME-resolver>
(-)a/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/resources/platforms-mime-resolver.xml (-14 / +5 lines)
Lines 45-72 Link Here
45
-->
45
-->
46
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
46
<!DOCTYPE MIME-resolver PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN" "http://www.netbeans.org/dtds/mime-resolver-1_0.dtd">
47
<MIME-resolver>
47
<MIME-resolver>
48
   
49
    <file>        
48
    <file>        
50
        <ext name="jar"/>
51
        <ext name="zip"/>
49
        <ext name="zip"/>
52
        <ext name="war"/>
53
        <ext name="ear"/>
54
        <ext name="JAR"/>
55
        <ext name="ZIP"/>
50
        <ext name="ZIP"/>
56
        <ext name="WAR"/>
51
        <resolver mime="application/zip"/>
57
        <ext name="EAR"/>
58
        <resolver mime="application/x-java-archive"/>
59
    </file>  
52
    </file>  
60
    
53
    
61
    <file>        
54
    <file>        
62
        <magic  hex="504b0304"
55
        <magic  hex="504b0304" mask="ffffffff"/>
63
               mask="ffffffff"/>
56
        <resolver mime="application/zip"/>
64
        <resolver mime="application/x-java-archive"/>
65
    </file>
57
    </file>
66
    
58
    
67
    <file>                
59
    <file>                
68
        <magic  hex="504b0506"
60
        <magic  hex="504b0506" mask="ffffffff"/>
69
               mask="ffffffff"/>
61
        <resolver mime="application/zip"/>
70
        <resolver mime="application/x-java-archive"/>
71
    </file>
62
    </file>
72
</MIME-resolver>
63
</MIME-resolver>

Return to bug 256015