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

(-)a/masterfs/apichanges.xml (+17 lines)
Lines 49-54 Link Here
49
        <apidef name="masterfs">MasterFileSystem API</apidef>
49
        <apidef name="masterfs">MasterFileSystem API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
        <change id="actions.for.files">
53
            <api name="masterfs"/>
54
            <summary>Deprecating actions(Set of FileObjects)</summary>
55
            <version major="2" minor="48"/>
56
            <date day="14" month="5" year="2014"/>
57
            <author login="jtulach"/>
58
            <compatibility addition="yes" binary="compatible" 
59
                source="compatible" semantic="compatible" 
60
                deprecation="no" deletion="no" modification="no"
61
            />
62
            <description>
63
                Adding <code>findExtrasFor</code> method to replace
64
                direct reference to <code>javax.swing.Actions</code>.
65
            </description>
66
            <class package="org.netbeans.modules.masterfs.providers" name="AnnotationProvider"/>
67
            <issue number="243265"/>
68
        </change>
52
        <change id="org.netbeans.io.suspend">
69
        <change id="org.netbeans.io.suspend">
53
            <api name="masterfs"/>
70
            <api name="masterfs"/>
54
            <summary>A property to suspend native listeners</summary>
71
            <summary>A property to suspend native listeners</summary>
(-)a/masterfs/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.masterfs/2
2
OpenIDE-Module: org.netbeans.modules.masterfs/2
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/masterfs/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/masterfs/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 2.47
4
OpenIDE-Module-Specification-Version: 2.48
5
OpenIDE-Module-Recommends: org.netbeans.modules.masterfs.providers.Notifier
5
OpenIDE-Module-Recommends: org.netbeans.modules.masterfs.providers.Notifier
6
OpenIDE-Module-Provides: org.openide.filesystems.FileUtil.toFileObject
6
OpenIDE-Module-Provides: org.openide.filesystems.FileUtil.toFileObject
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
(-)a/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java (-32 / +13 lines)
Lines 48-60 Link Here
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.io.ObjectStreamException;
49
import java.io.ObjectStreamException;
50
import java.io.Serializable;
50
import java.io.Serializable;
51
import java.util.ArrayList;
51
import java.util.Collection;
52
import java.util.Collection;
52
import java.util.Collections;
53
import java.util.Collections;
53
import java.util.HashSet;
54
import java.util.HashSet;
54
import java.util.Iterator;
55
import java.util.Iterator;
56
import java.util.List;
55
import java.util.Map;
57
import java.util.Map;
56
import java.util.Set;
58
import java.util.Set;
57
import java.util.logging.Level;
58
import java.util.logging.Logger;
59
import java.util.logging.Logger;
59
import org.netbeans.modules.masterfs.ProvidedExtensionsProxy;
60
import org.netbeans.modules.masterfs.ProvidedExtensionsProxy;
60
import org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj;
61
import org.netbeans.modules.masterfs.filebasedfs.fileobjects.BaseFileObj;
Lines 69-75 Link Here
69
import org.openide.util.Exceptions;
70
import org.openide.util.Exceptions;
70
import org.openide.util.Lookup;
71
import org.openide.util.Lookup;
71
import org.openide.util.Utilities;
72
import org.openide.util.Utilities;
72
import org.openide.util.actions.SystemAction;
73
import org.openide.util.lookup.ProxyLookup;
73
74
74
/**
75
/**
75
 * @author Radek Matous
76
 * @author Radek Matous
Lines 238-255 Link Here
238
    }
239
    }
239
240
240
    @Override
241
    @Override
241
    public SystemAction[] getActions() {
242
    public Lookup findExtrasFor(Set<FileObject> objects) {
242
        return new SystemAction[] {};
243
        return status.findExtrasFor(objects);
243
    }
244
245
    @Override
246
    public final SystemAction[] getActions(final Set<FileObject> foSet) {
247
        SystemAction[] some = status.getActions (foSet);
248
        if (some != null) {
249
            return some;
250
        }        
251
        return new SystemAction[] {};
252
253
    }
244
    }
254
    
245
    
255
    @Override
246
    @Override
Lines 313-337 Link Here
313
            previousProviders = now;
304
            previousProviders = now;
314
        }
305
        }
315
306
316
        public SystemAction[] getActions(Set<FileObject> foSet) {
307
        public Lookup findExtrasFor(Set<FileObject> foSet) {
317
308
            List<Lookup> arr = new ArrayList<Lookup>();
318
            javax.swing.Action[] retVal = null;
309
            for (AnnotationProvider ap : annotationProviders.allInstances()) {
319
            java.util.Iterator<? extends AnnotationProvider> it = annotationProviders.allInstances().iterator();
310
                final Lookup lkp = ap.findExtrasFor(foSet);
320
            while (retVal == null && it.hasNext()) {
311
                if (lkp != null) {
321
                AnnotationProvider ap = it.next();
312
                    arr.add(lkp);
322
                retVal = ap.actions(foSet);
313
                }
323
            }
314
            }
324
            if (retVal != null) {
315
            return new ProxyLookup(arr.toArray(new Lookup[0]));
325
                // right now we handle just SystemAction, it can be changed if necessary
326
                SystemAction[] ret = new SystemAction[retVal.length];
327
                for (int i = 0; i < retVal.length; i++) {
328
                    if (retVal[i] instanceof SystemAction) {
329
                        ret[i] = (SystemAction) retVal[i];
330
                    }
331
                }
332
                return ret;
333
            }
334
            return null;
335
        }
316
        }
336
317
337
        @Override
318
        @Override
(-)a/masterfs/src/org/netbeans/modules/masterfs/providers/AnnotationProvider.java (-1 / +21 lines)
Lines 51-56 Link Here
51
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileObject;
52
import org.openide.filesystems.FileStatusEvent;
52
import org.openide.filesystems.FileStatusEvent;
53
import org.openide.filesystems.FileStatusListener;
53
import org.openide.filesystems.FileStatusListener;
54
import org.openide.filesystems.FileSystem;
55
import org.openide.util.Lookup;
56
import org.openide.util.lookup.Lookups;
54
57
55
/** Can provide status and actions for FileObjects. Register it using {@link org.openide.util.lookup.ServiceProvider}.
58
/** Can provide status and actions for FileObjects. Register it using {@link org.openide.util.lookup.ServiceProvider}.
56
 *
59
 *
Lines 110-117 Link Here
110
    /** Provides actions that should be added to given set of files.
113
    /** Provides actions that should be added to given set of files.
111
     * @param files an immutable set of {@link FileObject}s belonging to this filesystem
114
     * @param files an immutable set of {@link FileObject}s belonging to this filesystem
112
     * @return null or array of actions for these files.
115
     * @return null or array of actions for these files.
116
     * @deprecated Will be deleted in the future. Overwrite {@link #findExtrasFor(java.util.Set)}.
113
     */
117
     */
114
    public abstract javax.swing.Action[] actions(Set<? extends FileObject> files);
118
    public javax.swing.Action[] actions(Set<? extends FileObject> files) {
119
        return findExtrasFor(files).lookupAll(javax.swing.Action.class).toArray(new javax.swing.Action[0]);
120
    }
121
    
122
    /** Provides various (usually UI related) information about 
123
     * the given set of files.
124
     * 
125
     * @param files the files to 
126
     * @return lookup to be exposed as {@link FileSystem#findExtrasFor}
127
     *   - may return <code>null</code>
128
     * @since 2.48
129
     */
130
    @SuppressWarnings("deprecated")
131
    public Lookup findExtrasFor(Set<? extends FileObject> files) {
132
        Object[] arr = actions(files);
133
        return arr == null ? null : Lookups.fixed((Object[]) arr);
134
    }
115
    
135
    
116
    //
136
    //
117
    // Listener support
137
    // Listener support
(-)a/masterfs/src/org/netbeans/modules/masterfs/watcher/Watcher.java (-4 / +4 lines)
Lines 51-63 Link Here
51
import java.util.WeakHashMap;
51
import java.util.WeakHashMap;
52
import java.util.logging.Level;
52
import java.util.logging.Level;
53
import java.util.logging.Logger;
53
import java.util.logging.Logger;
54
import javax.swing.Action;
55
import org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObjectFactory;
54
import org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObjectFactory;
56
import org.netbeans.modules.masterfs.providers.InterceptionListener;
55
import org.netbeans.modules.masterfs.providers.InterceptionListener;
57
import org.netbeans.modules.masterfs.providers.ProvidedExtensions;
56
import org.netbeans.modules.masterfs.providers.ProvidedExtensions;
58
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileObject;
59
import org.netbeans.modules.masterfs.providers.AnnotationProvider;
58
import org.netbeans.modules.masterfs.providers.AnnotationProvider;
60
import org.openide.util.Exceptions;
61
import org.openide.util.Lookup;
59
import org.openide.util.Lookup;
62
import org.openide.util.Lookup.Item;
60
import org.openide.util.Lookup.Item;
63
import org.openide.util.RequestProcessor;
61
import org.openide.util.RequestProcessor;
Lines 148-157 Link Here
148
    public @Override String annotateNameHtml(String name, Set<? extends FileObject> files) {
146
    public @Override String annotateNameHtml(String name, Set<? extends FileObject> files) {
149
        return null;
147
        return null;
150
    }
148
    }
151
    public @Override Action[] actions(Set<? extends FileObject> files) {
149
150
    @Override
151
    public Lookup findExtrasFor(Set<? extends FileObject> files) {
152
        return null;
152
        return null;
153
    }
153
    }
154
154
    
155
    public @Override InterceptionListener getInterceptionListener() {
155
    public @Override InterceptionListener getInterceptionListener() {
156
        return ext;
156
        return ext;
157
    }
157
    }
(-)a/openide.filesystems/apichanges.xml (+22 lines)
Lines 49-54 Link Here
49
        <apidef name="filesystems">Filesystems API</apidef>
49
        <apidef name="filesystems">Filesystems API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
        <change id="getActionsDeprecated">
53
            <api name="filesystems"/>
54
            <summary>Deprecating FileSystem.getActions</summary>
55
            <version major="8" minor="12"/>
56
            <date year="2014" month="5" day="14"/>
57
            <author login="jtulach"/>
58
            <compatibility addition="yes"/>
59
            <description>
60
                <p>
61
                    Deprecating <code>getActions</code> method in preparation
62
                    of splitting filesystems API into UI (e.g. depending
63
                    on Swing) and non-UI part (that can run on JDK8 compact
64
                    profile). Introducing general replacement 
65
                    <a href="@TOP@org/openide/filesystems/FileSystem.html#findExtrasFor(java.util.Set)">findExtrasFor</a>
66
                    instead...
67
                </p>
68
            </description>
69
            <class package="org.openide.filesystems" name="FileSystem"/>
70
            <class package="org.openide.filesystems" name="AbstractFileSystem"/>
71
            <class package="org.openide.filesystems" name="MultiFileSystem"/>
72
            <issue number="243265"/>
73
        </change>
52
        <change id="MultiFileObject.revealEntriesAttribute">
74
        <change id="MultiFileObject.revealEntriesAttribute">
53
            <api name="filesystems"/>
75
            <api name="filesystems"/>
54
            <summary>Allowed to reveal deleted files, or original files overriden by writable layer</summary>
76
            <summary>Allowed to reveal deleted files, or original files overriden by writable layer</summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
5
OpenIDE-Module-Specification-Version: 8.11
5
OpenIDE-Module-Specification-Version: 8.12
6
6
(-)a/openide.filesystems/src/org/openide/filesystems/AbstractFileSystem.java (-1 / +3 lines)
Lines 273-280 Link Here
273
    /* Action for this filesystem.
273
    /* Action for this filesystem.
274
    *
274
    *
275
    * @return refresh action
275
    * @return refresh action
276
    * @deprecated actions should be provided by higher level parts of the
277
    *   system, not something as low level as filesystems
276
    */
278
    */
277
    public SystemAction[] getActions() {
279
    @Deprecated public SystemAction[] getActions() {
278
        if (!isEnabledRefreshFolder()) {
280
        if (!isEnabledRefreshFolder()) {
279
            return NO_SYSTEM_ACTIONS;
281
            return NO_SYSTEM_ACTIONS;
280
        } else {
282
        } else {
(-)24c4c4e990c9 (+78 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.openide.filesystems;
44
45
import java.util.Arrays;
46
import java.util.Set;
47
import javax.swing.Action;
48
import org.openide.util.lookup.AbstractLookup;
49
import org.openide.util.lookup.InstanceContent;
50
51
/**
52
 *
53
 * @author Jaroslav Tulach <jtulach@netbeans.org>
54
 */
55
final class FileExtrasLkp extends AbstractLookup {
56
    private final FileSystem fs;
57
    private final InstanceContent ic;
58
    private final Set<FileObject> set;
59
60
    public FileExtrasLkp(FileSystem fs, Set<FileObject> set) {
61
        this(fs, new InstanceContent(), set);
62
    }
63
    private FileExtrasLkp(FileSystem fs, InstanceContent content, Set<FileObject> set) {
64
        super(content);
65
        this.fs = fs;
66
        this.ic = content;
67
        this.set = set;
68
    }
69
70
    @Override @SuppressWarnings("deprecation")
71
    protected void beforeLookup(Template<?> template) {
72
        if (Action.class.isAssignableFrom(template.getType())) {
73
            ic.set(Arrays.asList(fs.getActions(set)), null);
74
        }
75
    }
76
    
77
    
78
}
(-)a/openide.filesystems/src/org/openide/filesystems/FileSystem.java (-13 / +45 lines)
Lines 467-494 Link Here
467
    public FileObject createTempFile(FileObject parent, String prefix, String suffix, boolean deleteOnExit) throws IOException {
467
    public FileObject createTempFile(FileObject parent, String prefix, String suffix, boolean deleteOnExit) throws IOException {
468
        throw new IOException("Unsupported operation"); // NOI18N
468
        throw new IOException("Unsupported operation"); // NOI18N
469
    }
469
    }
470
        
470
    
471
    /** Returns an array of actions that can be invoked on any file in
471
    /** 
472
    * this filesystem.
472
     * FileSystems and their implementation 
473
    * These actions should preferably
473
     * should stay UI independent. Should there be a UI related extensions
474
    * support the {@link org.openide.util.actions.Presenter.Menu Menu},
474
     * they can be communicated via {@link #findExtrasFor(java.util.Set)} method.
475
    * {@link org.openide.util.actions.Presenter.Popup Popup},
475
     * <p>
476
    * and {@link org.openide.util.actions.Presenter.Toolbar Toolbar} presenters.
476
     * Returns an array of actions that should somehow be applicable to 
477
    *
477
     * this file system. These actions should preferably
478
    * @return array of available actions
478
     * support the {@link org.openide.util.actions.Presenter.Menu Menu},
479
    */
479
     * {@link org.openide.util.actions.Presenter.Popup Popup},
480
    public abstract SystemAction[] getActions();
480
     * and {@link org.openide.util.actions.Presenter.Toolbar Toolbar} presenters.
481
     *
482
     * @return array of available actions
483
     * @deprecated Actions should be provided by higher level parts of the
484
     *   system, not directly by file system layer.
485
     */
486
    @Deprecated
487
    public SystemAction[] getActions() {
488
        return new SystemAction[0];
489
    }
481
490
482
    /**
491
    /** 
483
     * Get actions appropriate to a certain file selection.
492
     * FileSystems and their implementation 
493
     * should stay UI independent. Should there be UI related extensions
494
     * they can be communicated via {@link #findExtrasFor(java.util.Set)} method.
495
     * In case of actions it should be enough to call:<pre>
496
     * actions = fs.{@link #findExtrasFor(java.util.Set) findUI}(foSet).{@link Lookup#lookupAll(java.lang.Class) lookupAll}({@link javax.swing.Action});
497
     * </pre>
498
     * Used to get actions appropriate to a certain file selection.
484
     * By default, returns the same list as {@link #getActions()}.
499
     * By default, returns the same list as {@link #getActions()}.
485
     * @param foSet one or more files which may be selected
500
     * @param foSet one or more files which may be selected
486
     * @return zero or more actions appropriate to those files
501
     * @return zero or more actions appropriate to those files
502
     * @deprecated Actions should be provided by higher level parts of the
503
     *   system, not directly by file system layer.
487
     */
504
     */
505
    @Deprecated
488
    public SystemAction[] getActions(Set<FileObject> foSet) {
506
    public SystemAction[] getActions(Set<FileObject> foSet) {
489
        return this.getActions();
507
        return this.getActions();
490
    }
508
    }
491
509
510
    /** Finds various extensions for set of file objects coming from
511
     * this file system.
512
     * For example actions should be obtainable as:<pre>
513
     * actions = fs.{@link #findExtrasFor(java.util.Set) findExtrasFor}(foSet).{@link Lookup#lookupAll(java.lang.Class) lookupAll}({@link javax.swing.Action});
514
     * </pre>
515
     * @param objects the set of objects
516
     * @return the lookup providing various extensions (usually visual) 
517
     * for these objects
518
     * @since 8.12
519
     */
520
    public Lookup findExtrasFor(Set<FileObject> objects) {
521
        return new FileExtrasLkp(this, objects);
522
    }
523
492
    /** Reads object from stream and creates listeners.
524
    /** Reads object from stream and creates listeners.
493
    * @param in the input stream to read from
525
    * @param in the input stream to read from
494
    * @exception IOException error during read
526
    * @exception IOException error during read
(-)a/openide.filesystems/src/org/openide/filesystems/MultiFileSystem.java (-1 / +11 lines)
Lines 288-294 Link Here
288
    }
288
    }
289
289
290
    /** Merge actions from all delegates.
290
    /** Merge actions from all delegates.
291
    */
291
     * @deprecated actions should be provided by higher level parts of the
292
     * system, not something as low level as filesystems
293
     */
294
    @Deprecated
292
    public @Override SystemAction[] getActions() {
295
    public @Override SystemAction[] getActions() {
293
        List<SystemAction> al = new ArrayList<SystemAction>(101); // randomly choosen constant
296
        List<SystemAction> al = new ArrayList<SystemAction>(101); // randomly choosen constant
294
        Set<SystemAction> uniq = new HashSet<SystemAction>(101); // not that randommly choosen
297
        Set<SystemAction> uniq = new HashSet<SystemAction>(101); // not that randommly choosen
Lines 312-317 Link Here
312
        return al.toArray(new SystemAction[al.size()]);
315
        return al.toArray(new SystemAction[al.size()]);
313
    }
316
    }
314
317
318
    /**
319
     * Merge actions from all delegates.
320
     *
321
     * @deprecated actions should be provided by higher level parts of the
322
     * system, not something as low level as filesystems
323
     */
324
    @Deprecated
315
    public @Override SystemAction[] getActions(final Set<FileObject> foSet) {
325
    public @Override SystemAction[] getActions(final Set<FileObject> foSet) {
316
        List<SystemAction> al = new ArrayList<SystemAction>(101); // randomly choosen constant
326
        List<SystemAction> al = new ArrayList<SystemAction>(101); // randomly choosen constant
317
        Set<SystemAction> uniq = new HashSet<SystemAction>(101); // not that randommly choosen
327
        Set<SystemAction> uniq = new HashSet<SystemAction>(101); // not that randommly choosen
(-)24c4c4e990c9 (+116 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2014 Sun Microsystems, Inc.
41
 */
42
43
package org.openide.filesystems;
44
45
import java.io.File;
46
import java.util.Collection;
47
import java.util.Collections;
48
import java.util.Set;
49
import javax.swing.Action;
50
import org.netbeans.junit.NbTestCase;
51
import org.openide.util.HelpCtx;
52
import org.openide.util.Lookup;
53
import org.openide.util.actions.CallbackSystemAction;
54
import org.openide.util.actions.SystemAction;
55
56
/**
57
 *
58
 * @author Jaroslav Tulach <jtulach@netbeans.org>
59
 */
60
public class FileSystemTest extends NbTestCase {
61
    private ExtraFS fs;
62
    
63
    public FileSystemTest(String n) {
64
        super(n);
65
    }
66
67
    @Override
68
    protected void setUp() throws Exception {
69
        clearWorkDir();
70
        File f = new File(getWorkDir(), "test.txt");
71
        f.createNewFile();
72
        fs = new ExtraFS(getWorkDir());
73
    }
74
75
    public void testFindExtraUIForActions() {
76
        FileObject fo = fs.findResource("test.txt");
77
        assertNotNull("test.txt found", fo);
78
79
        final Set<FileObject> c = Collections.singleton(fo);
80
        Object[] actions = fs.getActions(c);
81
        assertNotNull(actions);
82
        assertEquals("One is provided", actions.length, 1);
83
        
84
        Lookup lkp = fs.findExtrasFor(c);
85
        assertNotNull(lkp);
86
        Collection<? extends Action> extraAct = lkp.lookupAll(Action.class);
87
        assertEquals("one action", extraAct.size(), 1);
88
        
89
        assertSame("The same action is returned", actions[0], extraAct.iterator().next());
90
    }
91
    
92
    private static final class ExtraFS extends LocalFileSystem {
93
        public ExtraFS(File f) throws Exception {
94
            setRootDirectory(f);
95
        }
96
97
        @Override
98
        public SystemAction[] getActions(Set<FileObject> foSet) {
99
            return new SystemAction[] {
100
                SystemAction.get(MyAction.class)
101
            };
102
        }
103
    }
104
    
105
    public static final class MyAction extends CallbackSystemAction {
106
        @Override
107
        public String getName() {
108
            return "My test";
109
        }
110
111
        @Override
112
        public HelpCtx getHelpCtx() {
113
            return HelpCtx.DEFAULT_HELP;
114
        }
115
    }
116
}
(-)a/openide.loaders/nbproject/project.xml (-1 / +1 lines)
Lines 122-128 Link Here
122
                    <build-prerequisite/>
122
                    <build-prerequisite/>
123
                    <compile-dependency/>
123
                    <compile-dependency/>
124
                    <run-dependency>
124
                    <run-dependency>
125
                        <specification-version>7.58</specification-version>
125
                        <specification-version>8.12</specification-version>
126
                    </run-dependency>
126
                    </run-dependency>
127
                </dependency>
127
                </dependency>
128
                <dependency>
128
                <dependency>
(-)a/openide.loaders/src/org/openide/actions/FileSystemAction.java (-2 / +2 lines)
Lines 130-136 Link Here
130
                return createMenu(Enumerations.<Action>empty(), popUp, lookup);
130
                return createMenu(Enumerations.<Action>empty(), popUp, lookup);
131
            }
131
            }
132
            
132
            
133
            List<SystemAction> result = new LinkedList<SystemAction>();
133
            List<Action> result = new LinkedList<Action>();
134
            Set<FileObject> backSet = new LinkedHashSet<FileObject>();
134
            Set<FileObject> backSet = new LinkedHashSet<FileObject>();
135
            for (Map.Entry<FileSystem,Set<FileObject>> entry : fsSet.entrySet()) {
135
            for (Map.Entry<FileSystem,Set<FileObject>> entry : fsSet.entrySet()) {
136
136
Lines 149-155 Link Here
149
                    }
149
                    }
150
                }                
150
                }                
151
                backSet.addAll(backupList);
151
                backSet.addAll(backupList);
152
                result.addAll(Arrays.asList(fs.getActions (backSet)));
152
                result.addAll(fs.findExtrasFor(backSet).lookupAll(Action.class));
153
            }
153
            }
154
154
155
            if (isManualRefresh()) {
155
            if (isManualRefresh()) {
(-)a/versioning.masterfs/nbproject/project.xml (-1 / +1 lines)
Lines 11-17 Link Here
11
                    <compile-dependency/>
11
                    <compile-dependency/>
12
                    <run-dependency>
12
                    <run-dependency>
13
                        <release-version>2</release-version>
13
                        <release-version>2</release-version>
14
                        <specification-version>2.37</specification-version>
14
                        <specification-version>2.48</specification-version>
15
                    </run-dependency>
15
                    </run-dependency>
16
                </dependency>
16
                </dependency>
17
                <dependency>
17
                <dependency>
(-)a/versioning.masterfs/src/org/netbeans/modules/versioning/masterfs/VersioningAnnotationProvider.java (-8 / +10 lines)
Lines 43-57 Link Here
43
 */
43
 */
44
package org.netbeans.modules.versioning.masterfs;
44
package org.netbeans.modules.versioning.masterfs;
45
45
46
import java.awt.Image;
47
import java.util.*;
48
import javax.swing.*;
49
import org.netbeans.modules.masterfs.providers.AnnotationProvider;
46
import org.netbeans.modules.masterfs.providers.InterceptionListener;
50
import org.netbeans.modules.masterfs.providers.InterceptionListener;
47
import org.netbeans.modules.masterfs.providers.AnnotationProvider;
48
import org.openide.filesystems.*;
49
50
import javax.swing.*;
51
import java.util.*;
52
import java.awt.Image;
53
import org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor;
51
import org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor;
54
import org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor.VCSAnnotationEvent;
52
import org.netbeans.modules.versioning.core.filesystems.VCSFilesystemInterceptor.VCSAnnotationEvent;
53
import org.openide.filesystems.*;
54
import org.openide.util.Lookup;
55
import org.openide.util.lookup.Lookups;
55
56
56
/**
57
/**
57
 * Plugs into IDE filesystem and delegates annotation work to registered versioning systems.
58
 * Plugs into IDE filesystem and delegates annotation work to registered versioning systems.
Lines 76-83 Link Here
76
    }
77
    }
77
78
78
    @Override
79
    @Override
79
    public Action[] actions(Set files) {
80
    public Lookup findExtrasFor(Set<? extends FileObject> files) {
80
        return VCSFilesystemInterceptor.actions(files);
81
        Action[] arr = VCSFilesystemInterceptor.actions(files);
82
        return arr == null ? null : Lookups.fixed((Object[]) arr);
81
    }
83
    }
82
    
84
    
83
    @Override
85
    @Override

Return to bug 243265