# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\_r\hg\jet-main # 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: openide.explorer/apichanges.xml --- openide.explorer/apichanges.xml Base (BASE) +++ openide.explorer/apichanges.xml Locally Modified (Based On LOCAL) @@ -50,6 +50,22 @@ Explorer API + + + API method for creating a PropertyEnv instance + + + + + + Added PropertyEnv.create + method for creating an instance of PropertyEnv for given property and beans (nodes). + To be used when there is a need to initialize an ExPropertyEditor instance independently from + PropertySheet or PropertyPanel infrastructure (e.g. before the property appears in UI). + + + + In-place rename can be processed on background Index: openide.explorer/manifest.mf --- openide.explorer/manifest.mf Base (BASE) +++ openide.explorer/manifest.mf Locally Modified (Based On LOCAL) @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.explorer OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 6.38 +OpenIDE-Module-Specification-Version: 6.39 Index: openide.explorer/nbproject/project.xml --- openide.explorer/nbproject/project.xml Base (BASE) +++ openide.explorer/nbproject/project.xml Locally Modified (Based On LOCAL) @@ -86,7 +86,7 @@ - 7.7 + 7.24 Index: openide.explorer/src/org/netbeans/modules/openide/explorer/NodeOperationImpl.java --- openide.explorer/src/org/netbeans/modules/openide/explorer/NodeOperationImpl.java Base (BASE) +++ openide.explorer/src/org/netbeans/modules/openide/explorer/NodeOperationImpl.java Locally Modified (Based On LOCAL) @@ -46,8 +46,10 @@ import java.awt.BorderLayout; import java.awt.Component; +import java.awt.EventQueue; import javax.swing.*; +import org.openide.explorer.propertysheet.PropertyEnv; import org.openide.explorer.propertysheet.PropertySheet; import org.openide.explorer.view.BeanTreeView; import org.openide.nodes.*; @@ -136,4 +138,39 @@ return em; } } + + /** + * Shows a modal dialog with the custom editor of given property, just like + * it would be invoked when clicking the [...] button next to a property in + * the property sheet. The property value is updated if the dialog is + * successfully closed via the OK button. + * @param property The property to be edited (its property editor to be used). + * @param beans The objects the property belongs to. Typically one item + * array with the Node of the property. The meaning is the same as in + * {@link org.openide.explorer.propertysheet.PropertyEnv#getBeans()}. + */ + @Override + public void showCustomEditorDialog(Node.Property property, Object... beans) { + if (!EventQueue.isDispatchThread()) { + throw new IllegalStateException(); } + if (accessor == null) { + try { + // hack to make sure the accessor initialized from PropertyEnv static init + Class.forName(PropertyEnv.class.getName(), true, getClass().getClassLoader()); + } catch (ClassNotFoundException ex) { + } + } + accessor.showDialog(property, beans); + } + + private static CustomEditorAccessor accessor; + + public static void registerCustomEditorAccessor(CustomEditorAccessor acc) { + accessor = acc; + } + + public interface CustomEditorAccessor { + void showDialog(Node.Property property, Object[] beans); + } +} Index: openide.explorer/src/org/openide/explorer/propertysheet/CustomEditorAccessorImpl.java --- openide.explorer/src/org/openide/explorer/propertysheet/CustomEditorAccessorImpl.java Base (BASE) +++ openide.explorer/src/org/openide/explorer/propertysheet/CustomEditorAccessorImpl.java Locally New @@ -0,0 +1,163 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development and + * Distribution License("CDDL") (collectively, 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-gplv2.html or + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language + * governing permissions and limitations under the License. When distributing + * the software, include this License Header Notice in each file and include + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided by + * Oracle in the GPL Version 2 section of the License file that accompanied + * this code. If applicable, add the following below the License Header, with + * the fields enclosed by brackets [] replaced by your own identifying + * information: "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you do not indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to its + * licensees as provided above. However, if you add GPL Version 2 code and + * therefore, elected the GPL Version 2 license, then the option applies only + * if the new code is made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.openide.explorer.propertysheet; + +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.event.ActionEvent; +import java.beans.FeatureDescriptor; +import java.beans.PropertyEditor; +import org.netbeans.modules.openide.explorer.NodeOperationImpl; +import org.openide.nodes.Node; +import org.openide.nodes.Node.Property; +import org.openide.util.NbBundle; + +/** + * Provides access to package private classes around CustomEditorAction so + * the NodeOperationImpl (in a different package) can invoke a custom editor + * dialog for given property. + * + * @author Tomas Pavek + */ +final class CustomEditorAccessorImpl implements NodeOperationImpl.CustomEditorAccessor { + + static void register() { + NodeOperationImpl.registerCustomEditorAccessor(new CustomEditorAccessorImpl()); + } + + private CustomEditorAccessorImpl() {} + + /** + * Shows a modal dialog with the custom editor of given property the same + * way as property sheet, just like + * it would be invoked when clicking the [...] button next to a property in + * the property sheet. + */ + @Override + public void showDialog(Property property, Object[] beans) { + new CustomEditorAction(new Invoker(property, beans)) + .actionPerformed(new ActionEvent(property, ActionEvent.ACTION_PERFORMED, "invokeCustomEditor")); // NOI18N + } + + private static class Invoker implements CustomEditorAction.Invoker { + private Node.Property property; + private Object[] beans; + private ReusablePropertyEnv propertyEnv; + + Invoker(Node.Property prop, Object[] beans) { + property = prop; + this.beans = beans; + propertyEnv = new ReusablePropertyEnv(); + ReusablePropertyModel rpm = new ReusablePropertyModel(propertyEnv); + rpm.setProperty(prop); + propertyEnv.setNode(beans); // will unwrap as needed + } + + @Override + public FeatureDescriptor getSelection() { + return property; + } + + @Override + public Object getPartialValue() { + return null; + } + + @Override + public Component getCursorChangeComponent() { + return null; + } + + @Override + public String getBeanName() { + if (beans instanceof Node[]) { + Node[] nodes = (Node[]) beans; + StringBuilder name = new StringBuilder(); + String delim = NbBundle.getMessage(ProxyNode.class, "CTL_List_Delimiter"); // NOI18N + for (int i=0; i < nodes.length; i++) { + name.append(nodes[i].getDisplayName()); + if (i < nodes.length - 1) { + name.append(delim); + if (i >= 2) { + name.append(NbBundle.getMessage(ProxyNode.class, "MSG_ELLIPSIS")); // NOI18N + break; + } + } + } + return name.toString(); + } + return null; + } + + @Override + public void editorOpening() { + } + + @Override + public void editorOpened() { + } + + @Override + public void editorClosed() { + } + + @Override + public void valueChanged(PropertyEditor editor) { + } + + @Override + public boolean allowInvoke() { + return true; + } + + @Override + public void failed() { + } + + @Override + public boolean wantAllChanges() { + return false; // do not set changed values to the property before the dialog closes + } + + @Override + public ReusablePropertyEnv getReusablePropertyEnv() { + return propertyEnv; + } + } + +} Index: openide.explorer/src/org/openide/explorer/propertysheet/PropertyEnv.java --- openide.explorer/src/org/openide/explorer/propertysheet/PropertyEnv.java Base (BASE) +++ openide.explorer/src/org/openide/explorer/propertysheet/PropertyEnv.java Locally Modified (Based On LOCAL) @@ -164,6 +164,10 @@ boolean editable = true; private static final Logger LOG = Logger.getLogger(PropertyEnv.class.getName()); + static { + CustomEditorAccessorImpl.register(); + } + /** Default constructor has package access - * we do not want the instances to be created outside * our package. @@ -172,6 +176,21 @@ } /** + * Creates a PropertyEnv instance for given feature descriptor (property) + * and beans (nodes). To be used for initializing property editors not + * managed by the property sheet classes. + * @param fd Feature descritor that describes the property. + * @param beans Objects that the edited property belongs to (typically its node). + * @return the created PropertyEnv instance + */ + public static PropertyEnv create(FeatureDescriptor fd, Object... beans) { + PropertyEnv env = new PropertyEnv(); + env.setFeatureDescriptor(fd); + env.setBeans(beans); + return env; + } + + /** * Array of beans that the edited property belongs to. */ public Object[] getBeans() { Index: openide.explorer/test/unit/src/org/openide/explorer/propertysheet/NodeOperationImplTest.java --- openide.explorer/test/unit/src/org/openide/explorer/propertysheet/NodeOperationImplTest.java Base (BASE) +++ openide.explorer/test/unit/src/org/openide/explorer/propertysheet/NodeOperationImplTest.java Locally New @@ -0,0 +1,78 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development and + * Distribution License("CDDL") (collectively, 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-gplv2.html or + * nbbuild/licenses/CDDL-GPL-2-CP. See the License for the specific language + * governing permissions and limitations under the License. When distributing + * the software, include this License Header Notice in each file and include + * the License file at nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided by + * Oracle in the GPL Version 2 section of the License file that accompanied + * this code. If applicable, add the following below the License Header, with + * the fields enclosed by brackets [] replaced by your own identifying + * information: "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you do not indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to its + * licensees as provided above. However, if you add GPL Version 2 code and + * therefore, elected the GPL Version 2 license, then the option applies only + * if the new code is made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.openide.explorer.propertysheet; + +import java.awt.EventQueue; +import java.lang.reflect.InvocationTargetException; +import org.netbeans.junit.NbTestCase; +import org.openide.nodes.Node; +import org.openide.nodes.NodeOperation; +import org.openide.nodes.PropertySupport; + +public class NodeOperationImplTest extends NbTestCase { + public NodeOperationImplTest(String name) { + super(name); + } + + /** + * Verifies that NodeOperationImpl is correctly initialized with the + * accessor for showing custom editor dialog. + */ + public void testCustomEditorDialog() { + final Node.Property prop = new PropertySupport.ReadOnly("", String.class, "", "") { + @Override + public String getValue() throws IllegalAccessException, InvocationTargetException { + return "dummy"; + } + }; + try { + // The property has no custom editor, no dialog will open, so we can + // do blocking call. + EventQueue.invokeAndWait(new Runnable() { + @Override + public void run() { + NodeOperation.getDefault().showCustomEditorDialog(prop, new Object[]{}); + } + }); + } catch (InterruptedException ex) { + } catch (InvocationTargetException ex) { + ex.getTargetException().printStackTrace(); + fail("Can't show custom editor dialog"); + } + } +} Index: openide.nodes/apichanges.xml --- openide.nodes/apichanges.xml Base (BASE) +++ openide.nodes/apichanges.xml Locally Modified (Based On LOCAL) @@ -49,6 +49,20 @@ Nodes API + + + A way to show a custom editor dialog for a property + + + + + + Added NodeOperation.showCustomEditorDialog method that shows a modal dialog for given property + just like when the ... button in property sheet is pressed. + + + + A mechanism to provide node's children lazily. Index: openide.nodes/manifest.mf --- openide.nodes/manifest.mf Base (BASE) +++ openide.nodes/manifest.mf Locally Modified (Based On LOCAL) @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.nodes OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 7.23 +OpenIDE-Module-Specification-Version: 7.24 Index: openide.nodes/src/org/openide/nodes/NodeOperation.java --- openide.nodes/src/org/openide/nodes/NodeOperation.java Base (BASE) +++ openide.nodes/src/org/openide/nodes/NodeOperation.java Locally Modified (Based On LOCAL) @@ -106,6 +106,20 @@ */ public abstract void showProperties(Node[] n); + /** + * Shows a modal dialog with the custom editor of given property, just like + * it would be invoked when clicking the [...] button next to a property in + * the property sheet. The property value is updated if the dialog is + * successfully closed via the OK button. + * @param property The property to be edited (its property editor to be used). + * @param beans The objects the property belongs to. Typically one item + * array with the Node of the property. The meaning is the same as in + * {@link org.openide.explorer.propertysheet.PropertyEnv#getBeans()}. + */ + public void showCustomEditorDialog(Node.Property property, Object... beans) { + throw new UnsupportedOperationException(); + } + /** Open a modal Explorer on a root node, permitting a node selection to be returned. *

The acceptor * should be asked each time the set of selected nodes changes, whether to accept or