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/core.io.ui/src/org/netbeans/core/io/ui/IOWindow.java (-11 / +17 lines)
Lines 271-277 Link Here
271
271
272
        @Override
272
        @Override
273
        public void open() {
273
        public void open() {
274
            super.open();
274
            if (!isOpened())
275
		super.open();
275
        }
276
        }
276
277
277
        @Override
278
        @Override
Lines 285-294 Link Here
285
286
286
        @Override
287
        @Override
287
        public void requestVisible() {
288
        public void requestVisible() {
288
            super.requestVisible();
289
            if (!isShowing()) {
289
            if (Boolean.TRUE.equals(getClientProperty("isSliding"))) { //NOI18N
290
		super.requestVisible();
290
                requestActive();
291
		if (Boolean.TRUE.equals(getClientProperty("isSliding"))) { //NOI18N
291
            }
292
		    requestActive();
293
		}
294
	    }
292
        }
295
        }
293
296
294
        boolean activated;
297
        boolean activated;
Lines 360-371 Link Here
360
        }
363
        }
361
364
362
        public void selectTab(JComponent comp) {
365
        public void selectTab(JComponent comp) {
363
            if (!isOpened()) {
366
//	    Calls to open/requestVisible() lifted into Controller, case CMD_SELECT.
364
                open();
367
//	    Tests pushed into this.open() and this.requestVisible().
365
            }
368
//
366
            if (!isShowing()) {
369
//            if (!isOpened()) {
367
                requestVisible();
370
//                open();
368
            }
371
//            }
372
//            if (!isShowing()) {
373
//                requestVisible();
374
//            }
369
            if (singleTab == null) {
375
            if (singleTab == null) {
370
                pane.setSelectedComponent(comp);
376
                pane.setSelectedComponent(comp);
371
            }
377
            }
(-)a/core.output2/src/org/netbeans/core/output2/Controller.java (-3 / +33 lines)
Lines 47-52 Link Here
47
import java.io.FileOutputStream;
47
import java.io.FileOutputStream;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.io.OutputStream;
49
import java.io.OutputStream;
50
import java.util.EnumSet;
50
import java.util.HashMap;
51
import java.util.HashMap;
51
import java.util.HashSet;
52
import java.util.HashSet;
52
import java.util.Map;
53
import java.util.Map;
Lines 60-65 Link Here
60
import org.openide.util.NbPreferences;
61
import org.openide.util.NbPreferences;
61
import org.openide.windows.IOColors;
62
import org.openide.windows.IOColors;
62
import org.openide.windows.IOContainer;
63
import org.openide.windows.IOContainer;
64
import org.openide.windows.IOSelect;
63
import org.openide.windows.OutputEvent;
65
import org.openide.windows.OutputEvent;
64
import org.openide.xml.XMLUtil;
66
import org.openide.xml.XMLUtil;
65
67
Lines 376-385 Link Here
376
                if (tab == null) {
378
                if (tab == null) {
377
                    tab = createOutputTab(io);
379
                    tab = createOutputTab(io);
378
                }
380
                }
379
                if (io.isFocusTaken()) {
381
		if (io.isFocusTaken()) {
380
                    ioContainer.requestActive();
382
		    ioContainer.requestActive();
383
		}
384
385
		// After fixing bug#185209 IOContainer.select() no longer
386
		// performs these operations for us so we have to do them.
387
		ioContainer.open();
388
		ioContainer.requestVisible();
389
390
		ioContainer.select(tab);
391
                break;
392
            case IOEvent.CMD_FINE_SELECT :
393
                if (tab == null) {
394
                    tab = createOutputTab(io);
381
                }
395
                }
382
                ioContainer.select(tab);
396
397
		// We get here via IOSelect.select().
398
		assert data == null || data instanceof EnumSet;
399
		@SuppressWarnings("unchecked")		// NOI18N
400
		EnumSet<IOSelect.AdditionalOperation> extraOps =
401
		    (EnumSet<IOSelect.AdditionalOperation>) data;
402
403
		if (extraOps != null) {
404
		    // the order of these tests mimics the order of calls above.
405
		    if (io.isFocusTaken() && extraOps.contains(IOSelect.AdditionalOperation.REQUEST_ACTIVE))
406
			ioContainer.requestActive();
407
		    if (extraOps.contains(IOSelect.AdditionalOperation.OPEN))
408
			ioContainer.open();
409
		    if (extraOps.contains(IOSelect.AdditionalOperation.REQUEST_VISIBLE))
410
			ioContainer.requestVisible();
411
		}
412
		ioContainer.select(tab);
383
                break;
413
                break;
384
            case IOEvent.CMD_SET_TOOLBAR_ACTIONS :
414
            case IOEvent.CMD_SET_TOOLBAR_ACTIONS :
385
                if (tab != null) {
415
                if (tab != null) {
(-)a/core.output2/src/org/netbeans/core/output2/IOEvent.java (-1 / +8 lines)
Lines 135-142 Link Here
135
135
136
    /** set default colors */
136
    /** set default colors */
137
    static final int CMD_DEF_COLORS = 14;
137
    static final int CMD_DEF_COLORS = 14;
138
139
    /**
140
     * Command to support IOSelect.select() (with "fine" control.
141
     */
142
    static final int CMD_FINE_SELECT=15;
138
    
143
    
139
    private static final int CMD_LAST = 15;
144
    private static final int CMD_LAST = 16;
140
145
141
    /**
146
    /**
142
     * Strings representing the event.
147
     * Strings representing the event.
Lines 156-161 Link Here
156
        "CMD_SET_ICON", //NOI18N
161
        "CMD_SET_ICON", //NOI18N
157
        "CMD_SET_TOOLTIP", //NOI18N
162
        "CMD_SET_TOOLTIP", //NOI18N
158
        "CMD_SCROLL", //NOI18N
163
        "CMD_SCROLL", //NOI18N
164
        "CMD_DEF_COLORS", //NOI18N
165
        "CMD_FINE_SELECT", //NOI18N
159
    };
166
    };
160
167
161
    /**
168
    /**
(-)a/core.output2/src/org/netbeans/core/output2/NbIO.java (-1 / +12 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.core.output2;
42
package org.netbeans.core.output2;
43
43
44
import java.util.EnumSet;
44
import org.openide.windows.InputOutput;
45
import org.openide.windows.InputOutput;
45
import org.openide.windows.OutputListener;
46
import org.openide.windows.OutputListener;
46
import org.openide.windows.OutputWriter;
47
import org.openide.windows.OutputWriter;
Lines 57-62 Link Here
57
import org.openide.windows.IOColors;
58
import org.openide.windows.IOColors;
58
import org.openide.windows.IOContainer;
59
import org.openide.windows.IOContainer;
59
import org.openide.windows.IOPosition;
60
import org.openide.windows.IOPosition;
61
import org.openide.windows.IOSelect;
60
import org.openide.windows.IOTab;
62
import org.openide.windows.IOTab;
61
63
62
/** Implementation of InputOutput.  Implements calls as a set of
64
/** Implementation of InputOutput.  Implements calls as a set of
Lines 272-278 Link Here
272
        if (lookup == null) {
274
        if (lookup == null) {
273
            ioTab = new IOTabImpl();
275
            ioTab = new IOTabImpl();
274
            ioColors = new IOColorsImpl();
276
            ioColors = new IOColorsImpl();
275
            lookup = Lookups.fixed(ioTab, ioColors, new IOPositionImpl(), new IOColorLinesImpl(), new IOColorPrintImpl());
277
            lookup = Lookups.fixed(ioTab, ioColors, new IOPositionImpl(), new IOColorLinesImpl(), new IOColorPrintImpl(), new IOSelectImpl());
276
        }
278
        }
277
        return lookup;
279
        return lookup;
278
    }
280
    }
Lines 502-507 Link Here
502
        }
504
        }
503
    }
505
    }
504
506
507
    private class IOSelectImpl extends IOSelect {
508
509
	@Override
510
	protected void select(EnumSet<AdditionalOperation> extraOps) {
511
	    if (Controller.LOG) Controller.log (this + ": IOSelect.select");
512
	    NbIO.post (NbIO.this, IOEvent.CMD_FINE_SELECT, extraOps);
513
	}
514
    }
515
505
    private class IOColorsImpl extends IOColors {
516
    private class IOColorsImpl extends IOColors {
506
        Color[] clrs = new Color[4];
517
        Color[] clrs = new Color[4];
507
518
(-)a/core.output2/src/org/netbeans/core/output2/OutputTab.java (+4 lines)
Lines 231-236 Link Here
231
231
232
        IOContainer ioContainer = io.getIOContainer();
232
        IOContainer ioContainer = io.getIOContainer();
233
        if (io.isFocusTaken()) {
233
        if (io.isFocusTaken()) {
234
	    // The following two lines pulled up from select per bug#185209
235
	    ioContainer.open();
236
	    // ioContainer.requestVisible();
237
234
            ioContainer.select(this);
238
            ioContainer.select(this);
235
            ioContainer.requestVisible();
239
            ioContainer.requestVisible();
236
        }
240
        }
(-)a/core.output2/test/unit/src/org/netbeans/core/output2/LifecycleTest.java (+41 lines)
Lines 47-52 Link Here
47
import java.lang.reflect.Field;
47
import java.lang.reflect.Field;
48
import java.lang.reflect.InvocationTargetException;
48
import java.lang.reflect.InvocationTargetException;
49
import java.lang.reflect.Method;
49
import java.lang.reflect.Method;
50
import java.util.EnumSet;
50
import javax.swing.JComponent;
51
import javax.swing.JComponent;
51
import javax.swing.JFrame;
52
import javax.swing.JFrame;
52
import javax.swing.SwingUtilities;
53
import javax.swing.SwingUtilities;
Lines 54-59 Link Here
54
import org.netbeans.junit.RandomlyFails;
55
import org.netbeans.junit.RandomlyFails;
55
import org.openide.util.Exceptions;
56
import org.openide.util.Exceptions;
56
import org.openide.windows.IOContainer;
57
import org.openide.windows.IOContainer;
58
import org.openide.windows.IOSelect;
57
import org.openide.windows.OutputWriter;
59
import org.openide.windows.OutputWriter;
58
60
59
/**
61
/**
Lines 338-343 Link Here
338
340
339
    }
341
    }
340
342
343
    // Not really a Lifecycle feature but requires a bonafide TC container
344
    // which this Test provides.
345
    public void testFineSelect() {
346
        System.out.println("testFineSelect");
347
348
	EnumSet<IOSelect.AdditionalOperation> extraOps;
349
350
	extraOps = null;
351
	IOSelect.select(io, extraOps);
352
	sleep();
353
354
	extraOps = EnumSet.noneOf(IOSelect.AdditionalOperation.class);
355
	IOSelect.select(io, extraOps);
356
	sleep();
357
358
	extraOps = EnumSet.of(IOSelect.AdditionalOperation.OPEN);
359
	IOSelect.select(io, extraOps);
360
	sleep();
361
362
	extraOps = EnumSet.of(IOSelect.AdditionalOperation.REQUEST_ACTIVE);
363
	IOSelect.select(io, extraOps);
364
	sleep();
365
366
	extraOps = EnumSet.of(IOSelect.AdditionalOperation.REQUEST_VISIBLE);
367
	IOSelect.select(io, extraOps);
368
	sleep();
369
370
	extraOps = EnumSet.of(IOSelect.AdditionalOperation.OPEN,
371
		              IOSelect.AdditionalOperation.REQUEST_VISIBLE);
372
	IOSelect.select(io, extraOps);
373
	sleep();
374
375
	extraOps = EnumSet.of(IOSelect.AdditionalOperation.OPEN,
376
		              IOSelect.AdditionalOperation.REQUEST_VISIBLE,
377
			      IOSelect.AdditionalOperation.REQUEST_ACTIVE);
378
	IOSelect.select(io, extraOps);
379
	sleep();
380
    }
381
341
    static JComponent getIOWindow() {
382
    static JComponent getIOWindow() {
342
        IOContainer container = IOContainer.getDefault();
383
        IOContainer container = IOContainer.getDefault();
343
        JComponent comp = null;
384
        JComponent comp = null;
(-)a/openide.io/src/org/openide/windows/IOSelect.java (+116 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
    /**
54
     * Additional operations to perform when issuing {@link IOSelect#select}.
55
     * @author ivan
56
     */
57
    public static enum AdditionalOperation {
58
	/**
59
	 * Additionally issue open() on the TopComponent containing the InputOutput.
60
	 */
61
	OPEN,
62
63
	/**
64
	 * Additionally issue requestVisible() on the TopComponent containing the InputOutput.
65
	 */
66
	REQUEST_VISIBLE,
67
68
	/**
69
	 * Additionally issue requestActive() on the TopComponent containing the InputOutput.
70
	 */
71
	REQUEST_ACTIVE
72
    }
73
74
    private static IOSelect find(InputOutput io) {
75
        if (io instanceof Lookup.Provider) {
76
            Lookup.Provider p = (Lookup.Provider) io;
77
            return p.getLookup().lookup(IOSelect.class);
78
        }
79
        return null;
80
    }
81
82
    /**
83
     * With a null or empty 'extraOps' simply selects this io
84
     * without involving it's containing TopComponent.
85
     * <p>
86
     * If this capability is not supported then regular InputOutput.select()
87
     * will be called.
88
     * @param io InputOutput to operate on.
89
     * @param extraOps Additional operations to apply to the containing
90
     * TopComponent.
91
     */
92
    public static void select(InputOutput io, EnumSet<AdditionalOperation> extraOps) {
93
	IOSelect ios = find(io);
94
	if (ios != null)
95
	    ios.select(extraOps);
96
	else
97
	    io.select();	// fallback
98
    }
99
100
    /**
101
     * Checks whether this feature is supported for provided IO
102
     * @param io IO to check on
103
     * @return true if supported
104
     */
105
    public static boolean isSupported(InputOutput io) {
106
        return find(io) != null;
107
    }
108
109
    /**
110
     * With a null or empty 'extraOps' simply selects this io
111
     * without involving it's containing TopComponent.
112
     * @param extraOps Additional operations to apply to the containing
113
     * TopComponent.
114
     */
115
    abstract protected void select(EnumSet<AdditionalOperation> extraOps);
116
}

Return to bug 184894