# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: project/src/org/netbeans/modules/apisupport/project/layers/Bundle.properties *** C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\Bundle.properties Base (1.5) --- C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\Bundle.properties Locally Modified (Based On 1.5) *************** *** 38,40 **** --- 38,44 ---- # PickIconAction LBL_pick_icon=Pick Icon... + + # OpenLayerFilesAction + LBL_open_layer_files_action=Open Layer File(s) + #MSG_open_layer_projects=Open Layer File(s) Project(s) Index: project/src/org/netbeans/modules/apisupport/project/layers/LayerNode.java *** C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\LayerNode.java Base (1.21) --- C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\LayerNode.java Locally Modified (Based On 1.21) *************** *** 245,250 **** --- 245,251 ---- return new SystemAction[] { SystemAction.get(PickNameAction.class), SystemAction.get(PickIconAction.class), + SystemAction.get(OpenLayerFilesAction.class), }; } } Index: www/60-ui.html *** C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\www\60-ui.html Base (1.3) --- C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\www\60-ui.html Locally Modified (Based On 1.3) *************** *** 1728,1733 **** --- 1728,1738 ---- may result in branding overrides (e.g. *_hidden files if nonlocal files or folders are Deleted). Files or folders contributed by this module’s layer are boldfaced. Localize Name… and Pick Icon… are available only for the locally contributed files and folders. + Open layer files lets you open the layer file that declares the node. Note: It should be noted that + multiple layer files may declare the DataObject (FileObject) behind the node. For example the Actions + folder. If the opened layer file is owned by a visible module project such as a module project in this module's suite + or other netbeans.org modules in the official clusters in case this module is a netbeans.org module, you will + be able to open the project by using Select in > Projects action in the layer file editor's context menu.

<exported services> displays content of src/META-INF/services folder. Lists all types of exported Index: project/src/org/netbeans/modules/apisupport/project/layers/OpenLayerFilesAction.java *** C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\OpenLayerFilesAction.java No Base Revision --- C:\work\sun\visualweb\cvsworkspaces\visualweb\apisupport\project\src\org\netbeans\modules\apisupport\project\layers\OpenLayerFilesAction.java Locally New *************** *** 1,0 **** --- 1,204 ---- + /* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (the License). You may not use this file except in + * compliance with the License. + * + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + */ + + package org.netbeans.modules.apisupport.project.layers; + + import java.awt.Toolkit; + import java.lang.reflect.InvocationTargetException; + import java.lang.reflect.Method; + import java.net.URL; + //import java.util.Arrays; + //import java.util.HashSet; + //import java.util.Set; + //import org.netbeans.api.project.FileOwnerQuery; + //import org.netbeans.api.project.Project; + //import org.netbeans.api.project.ProjectUtils; + //import org.netbeans.api.project.ui.OpenProjects; + //import org.openide.DialogDisplayer; + //import org.openide.DialogDisplayer; + //import org.openide.NotifyDescriptor; + import org.openide.cookies.EditCookie; + import org.openide.filesystems.FileObject; + import org.openide.filesystems.FileStateInvalidException; + import org.openide.filesystems.FileSystem; + import org.openide.filesystems.MultiFileSystem; + import org.openide.filesystems.MultiFileSystem; + import org.openide.filesystems.URLMapper; + import org.openide.filesystems.XMLFileSystem; + import org.openide.loaders.DataObject; + import org.openide.loaders.DataObjectNotFoundException; + import org.openide.nodes.Node; + import org.openide.util.Exceptions; + import org.openide.util.HelpCtx; + import org.openide.util.NbBundle; + import org.openide.util.actions.CookieAction; + import org.xml.sax.SAXException; + + /** + * Open the layer file(s) declaring the SFS node. + * + * @author Sandip Chitale + */ + public class OpenLayerFilesAction extends CookieAction { + + // HACK Tunnel through the MultiFileSystem to get to the delegates + private static Method getDelegatesMethod; + static { + try { + getDelegatesMethod = MultiFileSystem.class.getDeclaredMethod("getDelegates"); + getDelegatesMethod.setAccessible(true); + } catch (NoSuchMethodException ex) { + Exceptions.printStackTrace(ex); + } catch (SecurityException ex) { + Exceptions.printStackTrace(ex); + } + } + + protected void performAction(Node[] activatedNodes) { + if (getDelegatesMethod == null) { + Toolkit.getDefaultToolkit().beep(); + return; + } + try { + // Set projectsSet = new HashSet(); + FileObject f = activatedNodes[0].getCookie(org.openide.loaders.DataObject.class).getPrimaryFile(); + FileSystem fs = f.getFileSystem(); + while (fs instanceof MultiFileSystem) { + try { + FileSystem[] delegates = (FileSystem[]) getDelegatesMethod.invoke(fs); + if (delegates != null && delegates.length > 0) { + fs = delegates[0]; + if (fs instanceof MultiFileSystem) { + // keep going + continue; + } else if (fs instanceof WritableXMLFileSystem) { + // try current module project's layer file. + FileObject originalF = fs.findResource(f.getPath()); + if (originalF != null) { + URL url = (URL) f.getAttribute("WritableXMLFileSystem.location"); // NOI18N + FileObject layerFileObject = URLMapper.findFileObject(url); + if (layerFileObject != null) { + try { + DataObject layerDataObject = DataObject.find(layerFileObject); + EditCookie editCookie = layerDataObject.getCookie(EditCookie.class); + if (editCookie != null) { + editCookie.edit(); + } + // Project project = FileOwnerQuery.getOwner(layerFileObject); + // if (project != null) { + // projectsSet.add(project); + // } + } catch (DataObjectNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + } + } + // Now, try other layer files visible to the module project + for (int i = 1; i < delegates.length; i++) { + XMLFileSystem xMLFileSystem = (XMLFileSystem) delegates[i]; + + // Have to use deprecated API to get all the Xml URLs + URL[] urls = xMLFileSystem.getXmlUrls(); + for (URL url : urls) { + try { + // Build an XML FS for the given URL + XMLFileSystem aXMLFileSystem = new XMLFileSystem(url); + + // Find the resource usiung the file path + originalF = aXMLFileSystem.findResource(f.getPath()); + + // Found? + if (originalF != null) { + // locate the layer's file object and open it + FileObject layerFileObject = URLMapper.findFileObject(url); + if (layerFileObject != null) { + try { + DataObject layerDataObject = DataObject.find(layerFileObject); + EditCookie editCookie = layerDataObject.getCookie(EditCookie.class); + if (editCookie != null) { + editCookie.edit(); + } + + // Project project = FileOwnerQuery.getOwner(layerFileObject); + // if (project != null) { + // projectsSet.add(project); + // } + } catch (DataObjectNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + } + } + }catch (SAXException ex) { + Exceptions.printStackTrace(ex); + } + } + } + } + } + + // projectsSet.removeAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects())); + // if (projectsSet.size() > 0) { + // Set projectNames = new HashSet(projectsSet.size()); + // for(Project project:projectsSet) { + // projectNames.add(ProjectUtils.getInformation(project).getDisplayName()); + // } + // if (DialogDisplayer.getDefault().notify( + // new NotifyDescriptor.Confirmation( + // projectNames.toArray(new String[0]), + // NbBundle.getMessage(OpenLayerFilesAction.class, "MSG_open_layer_projects"), + // NotifyDescriptor.YES_NO_OPTION, + // NotifyDescriptor.QUESTION_MESSAGE)) == NotifyDescriptor.YES_OPTION) { + // OpenProjects.getDefault().open(projectsSet.toArray(new Project[0]), false); + // } + // } + }catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + } catch (IllegalArgumentException ex) { + Exceptions.printStackTrace(ex); + } catch (InvocationTargetException ex) { + Exceptions.printStackTrace(ex); + } + } + } catch (FileStateInvalidException ex) { + Exceptions.printStackTrace(ex); + } + } + + public String getName() { + return NbBundle.getMessage(OpenLayerFilesAction.class, "LBL_open_layer_files_action"); + } + + protected Class[] cookieClasses() { + return new Class[] {DataObject.class}; + } + + protected int mode() { + return MODE_EXACTLY_ONE; + } + + public HelpCtx getHelpCtx() { + return null; + } + + @Override + protected boolean asynchronous() { + return false; + } + + }