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

(-)a/openide.io/src/org/openide/windows/IOContainer.java (+36 lines)
Lines 41-46 Link Here
41
41
42
import java.awt.Component;
42
import java.awt.Component;
43
import java.util.Arrays;
43
import java.util.Arrays;
44
import java.util.EnumSet;
44
import java.util.logging.Level;
45
import java.util.logging.Level;
45
import java.util.logging.Logger;
46
import java.util.logging.Logger;
46
import javax.swing.Action;
47
import javax.swing.Action;
Lines 169-174 Link Here
169
    }
170
    }
170
171
171
    /**
172
    /**
173
     * With a null or empty 'extraOps' simply selects the component
174
     * without involving it's containing TopComponent.
175
     * <p>
176
     * Will only work if provider provides {@link IOContainer.SelectProvider}.
177
     * @param comp component to operate on
178
     * @param comp Component to operate on.
179
     * @param extraOps Additional operations to apply to
180
     * the containing TopComponent.
181
     */
182
    public void select(JComponent comp, EnumSet<SelectExtraOps> extraOps) {
183
        log("selectLite(EnumSet<SelectExtraOps>)", comp);
184
	if (provider instanceof Lookup.Provider) {
185
	    Lookup.Provider p = (Lookup.Provider) provider;
186
	    SelectProvider sp = p.getLookup().lookup(SelectProvider.class);
187
	    if (sp != null)
188
		sp.select(comp, extraOps);
189
	}
190
    }
191
192
    /**
172
     * Gets currently selected component in parent container
193
     * Gets currently selected component in parent container
173
     * @return selected tab
194
     * @return selected tab
174
     */
195
     */
Lines 317-322 Link Here
317
    }
338
    }
318
339
319
    /**
340
    /**
341
     * Capability of an IOContainer.Provider to provide a finer grained
342
     * method of selecting a component.
343
     */
344
    public interface SelectProvider {
345
	/**
346
	 * With a null or empty 'extraOps' simply selects the component
347
	 * without involving it's containing TopComponent.
348
	 * @param comp Component to operate on.
349
	 * @param extraOps Additional operations to apply to
350
	 * the containing TopComponent.
351
	 */
352
	void select(JComponent comp, EnumSet<SelectExtraOps> extraOps);
353
    }
354
355
    /**
320
     * Callbacks from IOContainer to child component corresponding to IO
356
     * Callbacks from IOContainer to child component corresponding to IO
321
     * <p>
357
     * <p>
322
     * {@link IOProvider} implementations can optionally pass <code>Callbacks</code>
358
     * {@link IOProvider} implementations can optionally pass <code>Callbacks</code>
(-)a/openide.io/src/org/openide/windows/IOSelect.java (+92 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.openide.windows;
41
42
import java.util.EnumSet;
43
import org.openide.util.Lookup;
44
45
/**
46
 * Capability of an InputOutput of finer grained selection of a component.
47
 * <p>
48
 * InputOutput.select() does too much.
49
 * @author ivan
50
 */
51
public abstract class IOSelect {
52
53
    private static IOSelect find(InputOutput io) {
54
        if (io instanceof Lookup.Provider) {
55
            Lookup.Provider p = (Lookup.Provider) io;
56
            return p.getLookup().lookup(IOSelect.class);
57
        }
58
        return null;
59
    }
60
61
    /**
62
     * With a null or empty 'extraOps' simply selects this io
63
     * without involving it's containing TopComponent.
64
     * @param io InputOutput to operate on.
65
     * @param extraOps Additional operations to apply to the containing
66
     * TopComponent.
67
     */
68
    public static void select(InputOutput io, EnumSet<SelectExtraOps> extraOps) {
69
	IOSelect ios = find(io);
70
	if (ios != null)
71
	    ios.select(extraOps);
72
	else
73
	    return;
74
    }
75
76
    /**
77
     * Checks whether this feature is supported for provided IO
78
     * @param io IO to check on
79
     * @return true if supported
80
     */
81
    public static boolean isSupported(InputOutput io) {
82
        return find(io) != null;
83
    }
84
85
    /**
86
     * With a null or empty 'extraOps' simply selects this io
87
     * without involving it's containing TopComponent.
88
     * @param extraOps Additional operations to apply to the containing
89
     * TopComponent.
90
     */
91
    abstract protected void select(EnumSet<SelectExtraOps> extraOps);
92
}
(-)a/openide.io/src/org/openide/windows/SelectExtraOps.java (+61 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.openide.windows;
41
42
/**
43
 * Additional operations to perform when issuing {@link IOSelect.select}.
44
 * @author ivan
45
 */
46
public enum SelectExtraOps {
47
    /**
48
     * Additionally issue open() on the TopComponent containing the InputOutput.
49
     */
50
    OPEN,
51
52
    /**
53
     * Additionally issue requestVisible() on the TopComponent containing the InputOutput.
54
     */
55
    REQUEST_VISIBLE,
56
57
    /**
58
     * Additionally issue requestActive() on the TopComponent containing the InputOutput.
59
     */
60
    REQUEST_ACTIVE
61
}

Return to bug 184894