1.1 --- a/nbignore/manifest.mf Mon Aug 08 13:33:19 2016 +0200
1.2 +++ b/nbignore/manifest.mf Tue Aug 09 12:01:40 2016 +0200
1.3 @@ -2,5 +2,5 @@
1.4 AutoUpdate-Show-In-Client: true
1.5 OpenIDE-Module: org.netbeans.modules.nbignore
1.6 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/nbignore/resources/Bundle.properties
1.7 -OpenIDE-Module-Specification-Version: 0.1
1.8 +OpenIDE-Module-Specification-Version: 0.2
1.9
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/nbignore/src/org/netbeans/modules/nbignore/ChangeSupport.java Tue Aug 09 12:01:40 2016 +0200
2.3 @@ -0,0 +1,145 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + */
2.43 +package org.netbeans.modules.nbignore;
2.44 +
2.45 +import java.util.List;
2.46 +import java.util.concurrent.CopyOnWriteArrayList;
2.47 +import java.util.logging.Level;
2.48 +import java.util.logging.Logger;
2.49 +import javax.swing.event.ChangeEvent;
2.50 +import javax.swing.event.ChangeListener;
2.51 +import org.openide.util.Exceptions;
2.52 +
2.53 +// copied from org.openide.util & improved so custom ChangeEvent can be fired
2.54 +public final class ChangeSupport {
2.55 +
2.56 + private static final Logger LOG = Logger.getLogger(ChangeSupport.class.getName());
2.57 +
2.58 + // not private because used in unit tests
2.59 + final List<ChangeListener> listeners = new CopyOnWriteArrayList<>();
2.60 + private final Object source;
2.61 +
2.62 +
2.63 + /**
2.64 + * Creates a new <code>ChangeSupport</code>.
2.65 + *
2.66 + * @param source the instance to be given as the source for events.
2.67 + */
2.68 + public ChangeSupport(Object source) {
2.69 + this.source = source;
2.70 + }
2.71 +
2.72 + /**
2.73 + * Adds a <code>ChangeListener</code> to the listener list. The same
2.74 + * listener object may be added more than once, and will be called
2.75 + * as many times as it is added. If <code>listener</code> is null,
2.76 + * no exception is thrown and no action is taken.
2.77 + *
2.78 + * @param listener the <code>ChangeListener</code> to be added.
2.79 + */
2.80 + public void addChangeListener(ChangeListener listener) {
2.81 + if (listener == null) {
2.82 + return;
2.83 + }
2.84 + if (LOG.isLoggable(Level.FINE) && listeners.contains(listener)) {
2.85 + LOG.log(Level.FINE, "diagnostics for #167491", new IllegalStateException("Added " + listener + " multiply"));
2.86 + }
2.87 + listeners.add(listener);
2.88 + }
2.89 +
2.90 + /**
2.91 + * Removes a <code>ChangeListener</code> from the listener list.
2.92 + * If <code>listener</code> was added more than once,
2.93 + * it will be notified one less time after being removed.
2.94 + * If <code>listener</code> is null, or was never added, no exception is
2.95 + * thrown and no action is taken.
2.96 + *
2.97 + * @param listener the <code>ChangeListener</code> to be removed.
2.98 + */
2.99 + public void removeChangeListener(ChangeListener listener) {
2.100 + if (listener == null) {
2.101 + return;
2.102 + }
2.103 + listeners.remove(listener);
2.104 + }
2.105 +
2.106 + /**
2.107 + * Fires a change event to all registered listeners.
2.108 + */
2.109 + public void fireChange() {
2.110 + fireChange(new ChangeEvent(source));
2.111 + }
2.112 +
2.113 + public void fireChange(ChangeEvent event) {
2.114 + if (listeners.isEmpty()) {
2.115 + return;
2.116 + }
2.117 + fireChangeInternal(event);
2.118 + }
2.119 +
2.120 + /**
2.121 + * Fires the specified <code>ChangeEvent</code> to all registered
2.122 + * listeners. If <code>event</code> is null, no exception is thrown
2.123 + * and no action is taken.
2.124 + *
2.125 + * @param event the <code>ChangeEvent</code> to be fired.
2.126 + */
2.127 + private void fireChangeInternal(ChangeEvent event) {
2.128 + assert event != null;
2.129 + for (ChangeListener listener : listeners) {
2.130 + try {
2.131 + listener.stateChanged(event);
2.132 + } catch (RuntimeException x) {
2.133 + Exceptions.printStackTrace(x);
2.134 + }
2.135 + }
2.136 + }
2.137 +
2.138 + /**
2.139 + * Checks if there are any listeners registered to this<code>ChangeSupport</code>.
2.140 + *
2.141 + * @return true if there are one or more listeners for the given property,
2.142 + * false otherwise.
2.143 + */
2.144 + public boolean hasListeners() {
2.145 + return !listeners.isEmpty();
2.146 + }
2.147 +
2.148 +}
3.1 --- a/nbignore/src/org/netbeans/modules/nbignore/NbIgnoreVisibilityQueryImpl.java Mon Aug 08 13:33:19 2016 +0200
3.2 +++ b/nbignore/src/org/netbeans/modules/nbignore/NbIgnoreVisibilityQueryImpl.java Tue Aug 09 12:01:40 2016 +0200
3.3 @@ -41,13 +41,14 @@
3.4
3.5 import java.io.File;
3.6 import javax.swing.event.ChangeListener;
3.7 +import org.netbeans.spi.queries.VisibilityQueryChangeEvent;
3.8 import org.netbeans.spi.queries.VisibilityQueryImplementation;
3.9 import org.netbeans.spi.queries.VisibilityQueryImplementation2;
3.10 import org.openide.filesystems.FileChangeAdapter;
3.11 import org.openide.filesystems.FileEvent;
3.12 import org.openide.filesystems.FileObject;
3.13 +import org.openide.filesystems.FileRenameEvent;
3.14 import org.openide.filesystems.FileUtil;
3.15 -import org.openide.util.ChangeSupport;
3.16 import org.openide.util.lookup.ServiceProvider;
3.17 import org.openide.util.lookup.ServiceProviders;
3.18
3.19 @@ -114,9 +115,15 @@
3.20 checkNewOrDeletedFile(fe);
3.21 }
3.22
3.23 + @Override
3.24 + public void fileRenamed(FileRenameEvent fe) {
3.25 + checkNewOrDeletedFile(fe);
3.26 + }
3.27 +
3.28 private void checkNewOrDeletedFile(FileEvent fe) {
3.29 - if (fe.getFile().getNameExt().equals(FILE_NAME)) {
3.30 - changeSupport.fireChange();
3.31 + FileObject file = fe.getFile();
3.32 + if (file.getNameExt().equals(FILE_NAME)) {
3.33 + changeSupport.fireChange(new VisibilityQueryChangeEvent(this, new FileObject[] {file.getParent()}));
3.34 }
3.35 }
3.36