# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/beci/source/jet-undo # 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: refactoring.java/apichanges.xml --- refactoring.java/apichanges.xml Base (BASE) +++ refactoring.java/apichanges.xml Locally Modified (Based On LOCAL) @@ -49,6 +49,21 @@ Java Refactoring API + + + UI helper static method added UI.invokeAfterScanFinished + + + + + +

+ UI helper static method added UI.invokeAfterScanFinished. +

+
+ + +
Added option to generate PropertyChangeSupport in EncapsulateFieldRefactoring. Index: refactoring.java/nbproject/project.properties --- refactoring.java/nbproject/project.properties Base (BASE) +++ refactoring.java/nbproject/project.properties Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ javac.source=1.6 javadoc.arch=${basedir}/arch.xml -spec.version.base=1.32.0 +spec.version.base=1.33.0 #test configs test.config.find.includes=\ **/FindUsagesSuite.class Index: refactoring.java/src/org/netbeans/modules/refactoring/java/spi/ui/UI.java --- refactoring.java/src/org/netbeans/modules/refactoring/java/spi/ui/UI.java Base (BASE) +++ refactoring.java/src/org/netbeans/modules/refactoring/java/spi/ui/UI.java Locally New @@ -0,0 +1,161 @@ +/* + * 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.netbeans.modules.refactoring.java.spi.ui; + +import java.awt.Dialog; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.JLabel; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.border.EmptyBorder; +import org.netbeans.api.java.source.SourceUtils; +import org.netbeans.modules.refactoring.java.RefactoringUtils; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; + +/** + * UI helper class. + * @author Jan Becicka + * @since 1.33 + */ +public class UI { + + /** + * This is a helper method to provide support for delaying invocations of + * actions depending on java model. + *
+ * If classpath scanning is not in progress, runnable's run() is called.
+ * If classpath scanning is in progress, modal cancellable notification + * dialog with specified title is opened. As soon as classpath scanning + * finishes, this dialog is closed and runnable's run() is called. This + * method must be called in AWT EventQueue. Runnable is performed in AWT + * thread. + * + * @param runnable Runnable instance which will be called. + * @param actionName Title of wait dialog. + * @return true action was cancelled
false action was performed + */ + public static boolean invokeAfterScanFinished(final Runnable runnable, final String actionName) { + assert SwingUtilities.isEventDispatchThread(); + if (SourceUtils.isScanInProgress()) { + final ActionPerformer ap = new ActionPerformer(runnable); + ActionListener listener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + ap.cancel(); + waitTask.cancel(); + } + }; + JLabel label = new JLabel(NbBundle.getMessage(RefactoringUtils.class, "MSG_WaitScan"), javax.swing.UIManager.getIcon("OptionPane.informationIcon"), SwingConstants.LEFT); + label.setBorder(new EmptyBorder(12, 12, 11, 11)); + DialogDescriptor dd = new DialogDescriptor(label, actionName, true, new Object[]{NbBundle.getMessage(RefactoringUtils.class, "LBL_CancelAction",actionName)}, null, 0, null, listener); + waitDialog = DialogDisplayer.getDefault().createDialog(dd); + waitDialog.pack(); + //100ms is workaround for 127536 + waitTask = RequestProcessor.getDefault().post(ap, 100); + waitDialog.setVisible(true); + waitTask = null; + waitDialog = null; + return ap.hasBeenCancelled(); + } else { + runnable.run(); + return false; + } + } + private static Dialog waitDialog = null; + private static RequestProcessor.Task waitTask = null; + + private static class ActionPerformer implements Runnable { + + private Runnable action; + private AtomicBoolean cancel = new AtomicBoolean(); + + ActionPerformer(Runnable a) { + this.action = a; + } + + public boolean hasBeenCancelled() { + return cancel.get(); + } + + @Override + public void run() { + try { + SourceUtils.waitScanFinished(); + } catch (InterruptedException ie) { + Exceptions.printStackTrace(ie); + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + if (!cancel.get()) { + if (waitDialog != null) { + waitDialog.setVisible(false); + waitDialog.dispose(); + } + action.run(); + } + } + }); + } + + public void cancel() { + assert SwingUtilities.isEventDispatchThread(); + // check if the scanning did not finish during cancel + // invocation - in such case do not set cancel to true + // and do not try to hide waitDialog window + if (waitDialog != null) { + cancel.set(true); + waitDialog.setVisible(false); + waitDialog.dispose(); + } + } + } + +}